Merge commit 'origin/gallium-0.1' into gallium-0.2
authorKeith Whitwell <keith@tungstengraphics.com>
Thu, 18 Sep 2008 18:06:20 +0000 (19:06 +0100)
committerKeith Whitwell <keith@tungstengraphics.com>
Thu, 18 Sep 2008 18:07:33 +0000 (19:07 +0100)
Conflicts:

src/mesa/shader/slang/slang_link.c

942 files changed:
.gitattributes [new file with mode: 0644]
.gitignore
Makefile
acinclude.m4 [new file with mode: 0644]
autogen.sh [new file with mode: 0755]
bin/confdiff.sh [new file with mode: 0755]
bin/config.guess [new file with mode: 0755]
bin/config.sub [new file with mode: 0755]
bin/install-sh [new symlink]
bin/minstall
bin/mklib
bin/version.mk [new file with mode: 0755]
configs/.gitignore
configs/aix-gcc
configs/autoconf.in [new file with mode: 0644]
configs/beos
configs/bluegene-osmesa [new file with mode: 0644]
configs/bluegene-xlc-osmesa [new file with mode: 0644]
configs/catamount-osmesa-pgi [new file with mode: 0644]
configs/config.mgw [new file with mode: 0644]
configs/darwin
configs/darwin-fat-32bit [new file with mode: 0644]
configs/darwin-fat-all [new file with mode: 0644]
configs/darwin-static [deleted file]
configs/darwin-static-x86ppc [deleted file]
configs/default
configs/freebsd
configs/freebsd-dri
configs/hpux10-gcc
configs/linux
configs/linux-alpha
configs/linux-alpha-static
configs/linux-directfb
configs/linux-dri
configs/linux-dri-x86
configs/linux-dri-x86-64
configs/linux-dri-xcb
configs/linux-fbdev
configs/linux-glide
configs/linux-indirect
configs/linux-osmesa
configs/linux-osmesa16
configs/linux-osmesa16-static
configs/linux-osmesa32
configs/linux-ppc-static
configs/linux-solo
configs/linux-solo-x86
configs/linux-static
configs/linux-x86-64-static
configs/linux-x86-glide
configs/linux-x86-static
configs/netbsd
configs/openbsd
configs/solaris-x86-gcc
configs/solaris-x86-gcc-static
configs/sunos4-gcc
configs/sunos5-gcc
configs/sunos5-v9-cc-g++ [new file with mode: 0644]
configs/ultrix-gcc
configure.ac [new file with mode: 0644]
docs/MESA_packed_depth_stencil.spec [deleted file]
docs/MESA_program_debug.spec [deleted file]
docs/MESA_sprite_point.spec [deleted file]
docs/MESA_trace.spec [deleted file]
docs/OLD/MESA_packed_depth_stencil.spec [new file with mode: 0644]
docs/OLD/MESA_program_debug.spec [new file with mode: 0644]
docs/OLD/MESA_sprite_point.spec [new file with mode: 0644]
docs/OLD/MESA_trace.spec [new file with mode: 0644]
docs/README.MINGW32
docs/autoconf.html [new file with mode: 0644]
docs/bugs.html
docs/cell.html [new file with mode: 0644]
docs/contents.html
docs/devinfo.html
docs/download.html
docs/faq.html
docs/fbdev-dri.html
docs/helpwanted.html
docs/install.html
docs/intro.html
docs/license.html
docs/lists.html
docs/modelers.html
docs/news.html
docs/relnotes-7.0.1.html [new file with mode: 0644]
docs/relnotes-7.0.2.html [new file with mode: 0644]
docs/relnotes-7.0.3.html [new file with mode: 0644]
docs/relnotes-7.0.4.html [new file with mode: 0644]
docs/relnotes-7.1.html
docs/relnotes.html
docs/repository.html
docs/shading.html
doxygen/Makefile
include/GL/foomesa.h [deleted file]
include/GL/glu.h
include/GL/glut.h
include/GL/glutf90.h
include/GL/internal/dri_interface.h
include/GL/internal/glcore.h
include/GL/mesa_wgl.h
include/GL/wmesa.h
include/GL/xmesa_xf86.h
progs/Makefile
progs/beos/Makefile
progs/demos/.gitignore
progs/demos/Makefile
progs/demos/copypix.c [new file with mode: 0644]
progs/demos/cubemap.c
progs/demos/descrip.mms [new file with mode: 0644]
progs/demos/engine.c
progs/demos/fbo_firecube.c [new file with mode: 0644]
progs/demos/fslight.c
progs/demos/gearbox.c
progs/demos/glslnoise.c [changed mode: 0755->0644]
progs/demos/multiarb.c
progs/demos/rain.cxx
progs/demos/shadowtex.c
progs/directfb/Makefile
progs/egl/Makefile
progs/fbdev/Makefile
progs/fp/Makefile [changed mode: 0644->0755]
progs/fp/add-swz.txt [new file with mode: 0644]
progs/fp/fp-tri.c
progs/fp/mul-swz.txt [new file with mode: 0644]
progs/fp/negate.txt [new file with mode: 0644]
progs/fp/run.sh [new file with mode: 0755]
progs/glsl/.gitignore
progs/glsl/CH06-brick.frag [new file with mode: 0644]
progs/glsl/CH06-brick.frag.txt [deleted file]
progs/glsl/CH06-brick.vert [new file with mode: 0644]
progs/glsl/CH06-brick.vert.txt [deleted file]
progs/glsl/CH11-bumpmap.frag [new file with mode: 0644]
progs/glsl/CH11-bumpmap.frag.txt [deleted file]
progs/glsl/CH11-bumpmap.vert [new file with mode: 0644]
progs/glsl/CH11-bumpmap.vert.txt [deleted file]
progs/glsl/CH11-toyball.frag [new file with mode: 0644]
progs/glsl/CH11-toyball.frag.txt [deleted file]
progs/glsl/CH11-toyball.vert [new file with mode: 0644]
progs/glsl/CH11-toyball.vert.txt [deleted file]
progs/glsl/CH18-mandel.frag [new file with mode: 0644]
progs/glsl/CH18-mandel.frag.txt [deleted file]
progs/glsl/CH18-mandel.vert [new file with mode: 0644]
progs/glsl/CH18-mandel.vert.txt [deleted file]
progs/glsl/Makefile
progs/glsl/bitmap.c [new file with mode: 0644]
progs/glsl/brick.c
progs/glsl/bump.c
progs/glsl/convolutions.c
progs/glsl/cubemap.frag [new file with mode: 0644]
progs/glsl/cubemap.frag.txt [deleted file]
progs/glsl/deriv.c
progs/glsl/mandelbrot.c
progs/glsl/multitex.c [new file with mode: 0644]
progs/glsl/multitex.frag [new file with mode: 0644]
progs/glsl/multitex.vert [new file with mode: 0644]
progs/glsl/noise.c
progs/glsl/pointcoord.c [new file with mode: 0644]
progs/glsl/points.c [new file with mode: 0644]
progs/glsl/reflect.vert [new file with mode: 0644]
progs/glsl/reflect.vert.txt [deleted file]
progs/glsl/shadowtex.frag [new file with mode: 0644]
progs/glsl/shadowtex.frag.txt [deleted file]
progs/glsl/simple.vert [new file with mode: 0644]
progs/glsl/simple.vert.txt [deleted file]
progs/glsl/texdemo1.c
progs/glsl/toyball.c
progs/glsl/trirast.c [new file with mode: 0644]
progs/glsl/twoside.c [new file with mode: 0644]
progs/miniglx/Makefile
progs/osdemos/Makefile
progs/osdemos/ostest1.c
progs/redbook/Makefile
progs/samples/Makefile
progs/samples/Makefile.mgw [new file with mode: 0644]
progs/samples/blendeq.c
progs/slang/Makefile
progs/tests/.gitignore
progs/tests/Makefile
progs/tests/antialias.c
progs/tests/cva.c
progs/tests/dinoshade.c
progs/tests/exactrast.c [new file with mode: 0644]
progs/tests/fbotexture.c
progs/tests/lineclip.c [new file with mode: 0644]
progs/tests/multipal.c
progs/tests/shader_api.c [new file with mode: 0644]
progs/tests/stencil_twoside.c [new file with mode: 0644]
progs/tests/texline.c
progs/tests/unfilledclip.c [new file with mode: 0644]
progs/tools/trace/Makefile
progs/tools/trace/gltrace_support.cc
progs/trivial/Makefile
progs/trivial/dlist-degenerate.c [new file with mode: 0644]
progs/trivial/point-param.c
progs/trivial/quad-clip-nearplane.c
progs/trivial/tri.c
progs/util/shaderutil.c [new file with mode: 0644]
progs/util/shaderutil.h [new file with mode: 0644]
progs/vp/Makefile
progs/vp/run.sh [new file with mode: 0755]
progs/xdemos/.gitignore
progs/xdemos/Makefile
progs/xdemos/corender.c [new file with mode: 0644]
progs/xdemos/glxgears_pixmap.c [new file with mode: 0644]
progs/xdemos/glxinfo.c
progs/xdemos/glxsnoop.c [new file with mode: 0644]
progs/xdemos/glxswapcontrol.c
progs/xdemos/ipc.c [new file with mode: 0644]
progs/xdemos/ipc.h [new file with mode: 0644]
progs/xdemos/offset.c
progs/xdemos/pbutil.c
progs/xdemos/pbutil.h
progs/xdemos/shape.c
src/Makefile
src/egl/Makefile
src/egl/drivers/demo/Makefile
src/egl/drivers/dri/Makefile
src/egl/main/Makefile
src/gallium/Makefile
src/gallium/auxiliary/draw/draw_vs_exec.c
src/gallium/auxiliary/rtasm/rtasm_ppc.c [new file with mode: 0644]
src/gallium/auxiliary/rtasm/rtasm_ppc.h [new file with mode: 0644]
src/gallium/auxiliary/rtasm/rtasm_ppc_spe.c
src/gallium/auxiliary/rtasm/rtasm_ppc_spe.h
src/gallium/auxiliary/tgsi/tgsi_build.c
src/gallium/auxiliary/tgsi/tgsi_exec.c
src/gallium/auxiliary/tgsi/tgsi_parse.c
src/gallium/drivers/cell/common.h
src/gallium/drivers/cell/ppu/cell_context.c
src/gallium/drivers/cell/ppu/cell_gen_fp.c
src/gallium/drivers/cell/ppu/cell_gen_fragment.c
src/gallium/drivers/cell/ppu/cell_pipe_state.c
src/gallium/drivers/cell/ppu/cell_screen.c
src/gallium/drivers/cell/ppu/cell_state_emit.c
src/gallium/drivers/cell/spu/spu_main.c
src/gallium/drivers/cell/spu/spu_per_fragment_op.c
src/gallium/drivers/cell/spu/spu_tri.c
src/gallium/drivers/softpipe/sp_fs_exec.c
src/gallium/winsys/drm/intel/dri/intel_screen.c
src/gallium/winsys/drm/intel/dri/intel_swapbuffers.c
src/glu/Makefile
src/glu/glu.pc.in [new file with mode: 0644]
src/glu/mesa/Makefile
src/glu/mesa/project.c
src/glu/mini/project.c
src/glu/sgi/Makefile
src/glu/sgi/Makefile.mgw [new file with mode: 0644]
src/glu/sgi/glu.exports.darwin [new file with mode: 0644]
src/glu/sgi/libnurbs/interface/bezierPatch.cc
src/glu/sgi/libnurbs/interface/insurfeval.cc
src/glu/sgi/libnurbs/interface/mystdio.h
src/glu/sgi/libnurbs/internals/backend.cc
src/glu/sgi/libnurbs/internals/backend.h
src/glu/sgi/libnurbs/internals/bufpool.cc
src/glu/sgi/libnurbs/internals/bufpool.h
src/glu/sgi/libnurbs/internals/knotvector.cc
src/glu/sgi/libnurbs/internals/knotvector.h
src/glu/sgi/libnurbs/internals/nurbstess.cc
src/glu/sgi/libnurbs/internals/nurbstess.h
src/glu/sgi/libutil/error.c
src/glu/sgi/libutil/mipmap.c
src/glu/sgi/libutil/project.c
src/glu/sgi/libutil/quad.c
src/glut/beos/Makefile
src/glut/directfb/Makefile
src/glut/directfb/callback.c
src/glut/directfb/internal.h
src/glut/directfb/window.c
src/glut/fbdev/Makefile
src/glut/ggi/Makefile
src/glut/glx/Makefile
src/glut/glx/Makefile.mgw [new file with mode: 0644]
src/glut/glx/glut.pc.in [new file with mode: 0644]
src/glut/glx/glut_dstr.c
src/glut/glx/glut_event.c
src/glut/glx/glut_fbc.c [deleted file]
src/glut/glx/glut_fcb.c [new file with mode: 0644]
src/glut/mini/Makefile
src/glut/mini/glut.pc.in [new file with mode: 0644]
src/glw/Makefile
src/glw/glw.pc.in [new file with mode: 0644]
src/glx/Makefile
src/glx/mini/Makefile
src/glx/x11/.gitignore [deleted file]
src/glx/x11/Makefile
src/glx/x11/XF86dri.c
src/glx/x11/dri2.c [new file with mode: 0644]
src/glx/x11/dri2.h [new file with mode: 0644]
src/glx/x11/dri2_glx.c [new file with mode: 0644]
src/glx/x11/dri_common.c [new file with mode: 0644]
src/glx/x11/dri_common.h [new file with mode: 0644]
src/glx/x11/dri_glx.c
src/glx/x11/dri_glx.h [deleted file]
src/glx/x11/drisw_glx.c [new file with mode: 0644]
src/glx/x11/glcontextmodes.c
src/glx/x11/glcontextmodes.h
src/glx/x11/glx_pbuffer.c
src/glx/x11/glx_texture_compression.c [deleted file]
src/glx/x11/glxclient.h
src/glx/x11/glxcmds.c
src/glx/x11/glxcurrent.c [new file with mode: 0644]
src/glx/x11/glxext.c
src/glx/x11/glxextensions.c
src/glx/x11/glxextensions.h
src/glx/x11/glxhash.c [new file with mode: 0644]
src/glx/x11/glxhash.h [new file with mode: 0644]
src/glx/x11/indirect.c
src/glx/x11/indirect_texture_compression.c [new file with mode: 0644]
src/glx/x11/indirect_va_private.h [deleted file]
src/glx/x11/indirect_vertex_array.c
src/glx/x11/indirect_vertex_array_priv.h [new file with mode: 0644]
src/glx/x11/indirect_vertex_program.c
src/glx/x11/pixelstore.c
src/glx/x11/singlepix.c
src/glx/x11/xf86dri.h
src/glx/x11/xfont.c
src/mesa/Makefile
src/mesa/Makefile.mgw [new file with mode: 0644]
src/mesa/descrip.mms [new file with mode: 0644]
src/mesa/drivers/beos/Makefile
src/mesa/drivers/common/descrip.mms [new file with mode: 0644]
src/mesa/drivers/common/driverfuncs.c
src/mesa/drivers/common/sources [deleted file]
src/mesa/drivers/directfb/Makefile
src/mesa/drivers/directfb/idirectfbgl_mesa.c
src/mesa/drivers/dri/Makefile
src/mesa/drivers/dri/Makefile.template
src/mesa/drivers/dri/common/depthtmp.h
src/mesa/drivers/dri/common/dri_bufpool.h [deleted file]
src/mesa/drivers/dri/common/dri_drmpool.c [deleted file]
src/mesa/drivers/dri/common/dri_util.c
src/mesa/drivers/dri/common/dri_util.h
src/mesa/drivers/dri/common/extension_helper.h
src/mesa/drivers/dri/common/memops.h
src/mesa/drivers/dri/common/mmio.h
src/mesa/drivers/dri/common/spantmp2.h
src/mesa/drivers/dri/common/texmem.c
src/mesa/drivers/dri/common/utils.c
src/mesa/drivers/dri/common/utils.h
src/mesa/drivers/dri/common/vblank.c
src/mesa/drivers/dri/common/vblank.h
src/mesa/drivers/dri/common/xmlconfig.c
src/mesa/drivers/dri/common/xmlpool/Makefile
src/mesa/drivers/dri/dri.pc.in [new file with mode: 0644]
src/mesa/drivers/dri/fb/fb_dri.c
src/mesa/drivers/dri/ffb/ffb_clear.c
src/mesa/drivers/dri/ffb/ffb_linetmp.h
src/mesa/drivers/dri/ffb/ffb_pointtmp.h
src/mesa/drivers/dri/ffb/ffb_vtxfmt.c
src/mesa/drivers/dri/ffb/ffb_xmesa.c
src/mesa/drivers/dri/gamma/gamma_context.h
src/mesa/drivers/dri/gamma/gamma_render.c
src/mesa/drivers/dri/gamma/gamma_span.c
src/mesa/drivers/dri/gamma/gamma_xmesa.c
src/mesa/drivers/dri/glcore/glcore_driver.c [deleted file]
src/mesa/drivers/dri/i810/i810context.c
src/mesa/drivers/dri/i810/i810ioctl.h
src/mesa/drivers/dri/i810/i810render.c
src/mesa/drivers/dri/i810/i810screen.c
src/mesa/drivers/dri/i810/i810span.c
src/mesa/drivers/dri/i810/i810state.c
src/mesa/drivers/dri/i810/i810texmem.c
src/mesa/drivers/dri/i810/i810tris.c
src/mesa/drivers/dri/i915/Makefile
src/mesa/drivers/dri/i915/i830_context.c
src/mesa/drivers/dri/i915/i830_context.h
src/mesa/drivers/dri/i915/i830_metaops.c
src/mesa/drivers/dri/i915/i830_reg.h
src/mesa/drivers/dri/i915/i830_state.c
src/mesa/drivers/dri/i915/i830_tex.c
src/mesa/drivers/dri/i915/i830_texblend.c
src/mesa/drivers/dri/i915/i830_texstate.c
src/mesa/drivers/dri/i915/i830_vtbl.c
src/mesa/drivers/dri/i915/i915_context.c
src/mesa/drivers/dri/i915/i915_context.h
src/mesa/drivers/dri/i915/i915_debug.c
src/mesa/drivers/dri/i915/i915_debug.h [new file with mode: 0644]
src/mesa/drivers/dri/i915/i915_debug_fp.c [new file with mode: 0644]
src/mesa/drivers/dri/i915/i915_fragprog.c
src/mesa/drivers/dri/i915/i915_metaops.c
src/mesa/drivers/dri/i915/i915_program.c
src/mesa/drivers/dri/i915/i915_program.h
src/mesa/drivers/dri/i915/i915_reg.h
src/mesa/drivers/dri/i915/i915_state.c
src/mesa/drivers/dri/i915/i915_tex.c
src/mesa/drivers/dri/i915/i915_tex_layout.c [new file with mode: 0644]
src/mesa/drivers/dri/i915/i915_texprog.c [deleted file]
src/mesa/drivers/dri/i915/i915_texstate.c
src/mesa/drivers/dri/i915/i915_vtbl.c
src/mesa/drivers/dri/i915/intel_batchbuffer.c [changed from file to symlink]
src/mesa/drivers/dri/i915/intel_batchbuffer.h [deleted file]
src/mesa/drivers/dri/i915/intel_blit.c [new symlink]
src/mesa/drivers/dri/i915/intel_buffer_objects.c [new symlink]
src/mesa/drivers/dri/i915/intel_buffers.c [new symlink]
src/mesa/drivers/dri/i915/intel_context.c [changed from file to symlink]
src/mesa/drivers/dri/i915/intel_context.h [deleted file]
src/mesa/drivers/dri/i915/intel_decode.c [new symlink]
src/mesa/drivers/dri/i915/intel_depthstencil.c [new symlink]
src/mesa/drivers/dri/i915/intel_fbo.c [new symlink]
src/mesa/drivers/dri/i915/intel_ioctl.c [deleted file]
src/mesa/drivers/dri/i915/intel_mipmap_tree.c [new symlink]
src/mesa/drivers/dri/i915/intel_pixel.c [changed from file to symlink]
src/mesa/drivers/dri/i915/intel_pixel_bitmap.c [new symlink]
src/mesa/drivers/dri/i915/intel_pixel_copy.c [new symlink]
src/mesa/drivers/dri/i915/intel_pixel_draw.c [new symlink]
src/mesa/drivers/dri/i915/intel_pixel_read.c [new file with mode: 0644]
src/mesa/drivers/dri/i915/intel_reg.h [deleted file]
src/mesa/drivers/dri/i915/intel_regions.c [new symlink]
src/mesa/drivers/dri/i915/intel_render.c
src/mesa/drivers/dri/i915/intel_rotate.c [deleted file]
src/mesa/drivers/dri/i915/intel_rotate.h [deleted file]
src/mesa/drivers/dri/i915/intel_screen.h [deleted file]
src/mesa/drivers/dri/i915/intel_span.c [changed from file to symlink]
src/mesa/drivers/dri/i915/intel_span.h [deleted file]
src/mesa/drivers/dri/i915/intel_state.c
src/mesa/drivers/dri/i915/intel_structs.h [new file with mode: 0644]
src/mesa/drivers/dri/i915/intel_tex.c [changed from file to symlink]
src/mesa/drivers/dri/i915/intel_tex.h [deleted file]
src/mesa/drivers/dri/i915/intel_tex_copy.c [new symlink]
src/mesa/drivers/dri/i915/intel_tex_format.c [new symlink]
src/mesa/drivers/dri/i915/intel_tex_image.c [new symlink]
src/mesa/drivers/dri/i915/intel_tex_layout.c [new symlink]
src/mesa/drivers/dri/i915/intel_tex_subimage.c [new symlink]
src/mesa/drivers/dri/i915/intel_tex_validate.c [new symlink]
src/mesa/drivers/dri/i915/intel_texmem.c [deleted file]
src/mesa/drivers/dri/i915/intel_tris.c
src/mesa/drivers/dri/i915/intel_tris.h
src/mesa/drivers/dri/i915/server/intel.h [deleted file]
src/mesa/drivers/dri/i915/server/intel_dri.c [changed from file to symlink]
src/mesa/drivers/dri/i965/Makefile
src/mesa/drivers/dri/i965/brw_aub.c [deleted file]
src/mesa/drivers/dri/i965/brw_aub.h [deleted file]
src/mesa/drivers/dri/i965/brw_aub_playback.c [deleted file]
src/mesa/drivers/dri/i965/brw_cc.c
src/mesa/drivers/dri/i965/brw_clip.c
src/mesa/drivers/dri/i965/brw_clip.h
src/mesa/drivers/dri/i965/brw_clip_line.c
src/mesa/drivers/dri/i965/brw_clip_state.c
src/mesa/drivers/dri/i965/brw_clip_tri.c
src/mesa/drivers/dri/i965/brw_clip_unfilled.c
src/mesa/drivers/dri/i965/brw_clip_util.c
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_curbe.c
src/mesa/drivers/dri/i965/brw_defines.h
src/mesa/drivers/dri/i965/brw_draw.c
src/mesa/drivers/dri/i965/brw_draw.h
src/mesa/drivers/dri/i965/brw_draw_upload.c
src/mesa/drivers/dri/i965/brw_eu.c
src/mesa/drivers/dri/i965/brw_eu.h
src/mesa/drivers/dri/i965/brw_eu_emit.c
src/mesa/drivers/dri/i965/brw_exec_generic.c [deleted file]
src/mesa/drivers/dri/i965/brw_fallback.c
src/mesa/drivers/dri/i965/brw_gs.c
src/mesa/drivers/dri/i965/brw_gs.h
src/mesa/drivers/dri/i965/brw_gs_state.c
src/mesa/drivers/dri/i965/brw_hal.c [deleted file]
src/mesa/drivers/dri/i965/brw_hal.h [deleted file]
src/mesa/drivers/dri/i965/brw_metaops.c
src/mesa/drivers/dri/i965/brw_misc_state.c
src/mesa/drivers/dri/i965/brw_program.c
src/mesa/drivers/dri/i965/brw_sf.c
src/mesa/drivers/dri/i965/brw_sf.h
src/mesa/drivers/dri/i965/brw_sf_emit.c
src/mesa/drivers/dri/i965/brw_sf_state.c
src/mesa/drivers/dri/i965/brw_state.h
src/mesa/drivers/dri/i965/brw_state_batch.c
src/mesa/drivers/dri/i965/brw_state_cache.c
src/mesa/drivers/dri/i965/brw_state_dump.c [new file with mode: 0644]
src/mesa/drivers/dri/i965/brw_state_pool.c [deleted file]
src/mesa/drivers/dri/i965/brw_state_upload.c
src/mesa/drivers/dri/i965/brw_structs.h
src/mesa/drivers/dri/i965/brw_tex.c
src/mesa/drivers/dri/i965/brw_tex_layout.c
src/mesa/drivers/dri/i965/brw_urb.c
src/mesa/drivers/dri/i965/brw_util.c
src/mesa/drivers/dri/i965/brw_vs.c
src/mesa/drivers/dri/i965/brw_vs.h
src/mesa/drivers/dri/i965/brw_vs_constval.c
src/mesa/drivers/dri/i965/brw_vs_emit.c
src/mesa/drivers/dri/i965/brw_vs_state.c
src/mesa/drivers/dri/i965/brw_vs_tnl.c
src/mesa/drivers/dri/i965/brw_vtbl.c
src/mesa/drivers/dri/i965/brw_wm.c
src/mesa/drivers/dri/i965/brw_wm.h
src/mesa/drivers/dri/i965/brw_wm_emit.c
src/mesa/drivers/dri/i965/brw_wm_fp.c
src/mesa/drivers/dri/i965/brw_wm_glsl.c [new file with mode: 0644]
src/mesa/drivers/dri/i965/brw_wm_pass0.c
src/mesa/drivers/dri/i965/brw_wm_pass1.c
src/mesa/drivers/dri/i965/brw_wm_pass2.c
src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
src/mesa/drivers/dri/i965/brw_wm_state.c
src/mesa/drivers/dri/i965/brw_wm_surface_state.c
src/mesa/drivers/dri/i965/bufmgr.h [deleted file]
src/mesa/drivers/dri/i965/bufmgr_fake.c [deleted file]
src/mesa/drivers/dri/i965/intel_batchbuffer.c [changed from file to symlink]
src/mesa/drivers/dri/i965/intel_batchbuffer.h [deleted file]
src/mesa/drivers/dri/i965/intel_blit.c [changed from file to symlink]
src/mesa/drivers/dri/i965/intel_blit.h [deleted file]
src/mesa/drivers/dri/i965/intel_buffer_objects.c [changed from file to symlink]
src/mesa/drivers/dri/i965/intel_buffer_objects.h [deleted file]
src/mesa/drivers/dri/i965/intel_buffers.c [changed from file to symlink]
src/mesa/drivers/dri/i965/intel_context.c [changed from file to symlink]
src/mesa/drivers/dri/i965/intel_context.h [deleted file]
src/mesa/drivers/dri/i965/intel_decode.c [new symlink]
src/mesa/drivers/dri/i965/intel_depthstencil.c [new symlink]
src/mesa/drivers/dri/i965/intel_fbo.c [new symlink]
src/mesa/drivers/dri/i965/intel_ioctl.c [deleted file]
src/mesa/drivers/dri/i965/intel_ioctl.h [deleted file]
src/mesa/drivers/dri/i965/intel_mipmap_tree.c [changed from file to symlink]
src/mesa/drivers/dri/i965/intel_mipmap_tree.h [deleted file]
src/mesa/drivers/dri/i965/intel_pixel.c [new symlink]
src/mesa/drivers/dri/i965/intel_pixel_bitmap.c [changed from file to symlink]
src/mesa/drivers/dri/i965/intel_pixel_copy.c [changed from file to symlink]
src/mesa/drivers/dri/i965/intel_reg.h [deleted file]
src/mesa/drivers/dri/i965/intel_regions.c [changed from file to symlink]
src/mesa/drivers/dri/i965/intel_regions.h [deleted file]
src/mesa/drivers/dri/i965/intel_screen.h [deleted file]
src/mesa/drivers/dri/i965/intel_span.c [changed from file to symlink]
src/mesa/drivers/dri/i965/intel_span.h [deleted file]
src/mesa/drivers/dri/i965/intel_state.c
src/mesa/drivers/dri/i965/intel_tex.c [changed from file to symlink]
src/mesa/drivers/dri/i965/intel_tex.h [deleted file]
src/mesa/drivers/dri/i965/intel_tex_copy.c [new symlink]
src/mesa/drivers/dri/i965/intel_tex_format.c [new symlink]
src/mesa/drivers/dri/i965/intel_tex_image.c [new symlink]
src/mesa/drivers/dri/i965/intel_tex_subimage.c [new symlink]
src/mesa/drivers/dri/i965/intel_tex_validate.c [changed from file to symlink]
src/mesa/drivers/dri/i965/server/intel.h [deleted file]
src/mesa/drivers/dri/i965/server/intel_dri.c [changed from file to symlink]
src/mesa/drivers/dri/intel/intel_batchbuffer.c [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_batchbuffer.h [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_blit.c [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_blit.h [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_buffer_objects.c [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_buffer_objects.h [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_buffers.c [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_buffers.h [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_chipset.h [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_context.c [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_context.h [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_decode.c [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_decode.h [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_depthstencil.c [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_depthstencil.h [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_fbo.c [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_fbo.h [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_mipmap_tree.c [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_mipmap_tree.h [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_pixel.c [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_pixel.h [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_pixel_bitmap.c [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_pixel_copy.c [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_pixel_draw.c [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_reg.h [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_regions.c [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_regions.h [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_screen.c [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_screen.h [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_span.c [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_span.h [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_tex.c [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_tex.h [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_tex_copy.c [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_tex_format.c [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_tex_image.c [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_tex_layout.c
src/mesa/drivers/dri/intel/intel_tex_layout.h
src/mesa/drivers/dri/intel/intel_tex_obj.h [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_tex_subimage.c [new file with mode: 0644]
src/mesa/drivers/dri/intel/intel_tex_validate.c [new file with mode: 0644]
src/mesa/drivers/dri/intel/server/i830_dri.h [new file with mode: 0644]
src/mesa/drivers/dri/intel/server/intel.h [new file with mode: 0644]
src/mesa/drivers/dri/intel/server/intel_dri.c [new file with mode: 0644]
src/mesa/drivers/dri/mach64/mach64_context.c
src/mesa/drivers/dri/mach64/mach64_context.h
src/mesa/drivers/dri/mach64/mach64_ioctl.c
src/mesa/drivers/dri/mach64/mach64_ioctl.h
src/mesa/drivers/dri/mach64/mach64_lock.c
src/mesa/drivers/dri/mach64/mach64_screen.c
src/mesa/drivers/dri/mach64/mach64_screen.h
src/mesa/drivers/dri/mach64/mach64_span.c
src/mesa/drivers/dri/mach64/mach64_state.c
src/mesa/drivers/dri/mach64/mach64_tex.h
src/mesa/drivers/dri/mach64/mach64_tris.c
src/mesa/drivers/dri/mga/mga_xmesa.c
src/mesa/drivers/dri/mga/mgacontext.h
src/mesa/drivers/dri/mga/mgadd.c
src/mesa/drivers/dri/mga/mgaioctl.c
src/mesa/drivers/dri/mga/mgaioctl.h
src/mesa/drivers/dri/mga/mgarender.c
src/mesa/drivers/dri/mga/mgaspan.c
src/mesa/drivers/dri/mga/mgastate.c
src/mesa/drivers/dri/mga/mgatris.c
src/mesa/drivers/dri/nouveau/Makefile [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_bufferobj.h [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_buffers.c [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_buffers.h [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_card.c [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_card.h [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_card_list.h [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_context.c [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_ctrlreg.h [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_dri.h [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_driver.c [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_driver.h [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_lock.c [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_lock.h [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_msg.h [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_object.c [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_object.h [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_query.c [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_query.h [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_reg.h [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_shader.c [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_shader.h [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_shader_0.c [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_shader_1.c [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_shader_2.c [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_span.c [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_span.h [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_state.c [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_state.h [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_state_cache.c [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_state_cache.h [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_swtcl.c [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_swtcl.h [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_sync.c [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_sync.h [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_tex.c [deleted file]
src/mesa/drivers/dri/nouveau/nouveau_tex.h [deleted file]
src/mesa/drivers/dri/nouveau/nv04_state.c [deleted file]
src/mesa/drivers/dri/nouveau/nv04_swtcl.c [deleted file]
src/mesa/drivers/dri/nouveau/nv04_swtcl.h [deleted file]
src/mesa/drivers/dri/nouveau/nv10_state.c [deleted file]
src/mesa/drivers/dri/nouveau/nv10_swtcl.c [deleted file]
src/mesa/drivers/dri/nouveau/nv10_swtcl.h [deleted file]
src/mesa/drivers/dri/nouveau/nv20_shader.h [deleted file]
src/mesa/drivers/dri/nouveau/nv20_state.c [deleted file]
src/mesa/drivers/dri/nouveau/nv20_vertprog.c [deleted file]
src/mesa/drivers/dri/nouveau/nv30_fragprog.c [deleted file]
src/mesa/drivers/dri/nouveau/nv30_shader.h [deleted file]
src/mesa/drivers/dri/nouveau/nv30_state.c [deleted file]
src/mesa/drivers/dri/nouveau/nv30_vertprog.c [deleted file]
src/mesa/drivers/dri/nouveau/nv40_fragprog.c [deleted file]
src/mesa/drivers/dri/nouveau/nv40_shader.h [deleted file]
src/mesa/drivers/dri/nouveau/nv40_vertprog.c [deleted file]
src/mesa/drivers/dri/nouveau/nv50_state.c [deleted file]
src/mesa/drivers/dri/r128/r128_context.c
src/mesa/drivers/dri/r128/r128_context.h
src/mesa/drivers/dri/r128/r128_ioctl.c
src/mesa/drivers/dri/r128/r128_ioctl.h
src/mesa/drivers/dri/r128/r128_screen.c
src/mesa/drivers/dri/r128/r128_screen.h
src/mesa/drivers/dri/r128/r128_span.c
src/mesa/drivers/dri/r128/r128_state.c
src/mesa/drivers/dri/r128/r128_tex.h
src/mesa/drivers/dri/r200/r200_context.c
src/mesa/drivers/dri/r200/r200_context.h
src/mesa/drivers/dri/r200/r200_fragshader.c
src/mesa/drivers/dri/r200/r200_ioctl.c
src/mesa/drivers/dri/r200/r200_ioctl.h
src/mesa/drivers/dri/r200/r200_pixel.c
src/mesa/drivers/dri/r200/r200_span.c
src/mesa/drivers/dri/r200/r200_state.c
src/mesa/drivers/dri/r200/r200_tcl.c
src/mesa/drivers/dri/r200/r200_tex.c
src/mesa/drivers/dri/r200/r200_tex.h
src/mesa/drivers/dri/r200/r200_texmem.c
src/mesa/drivers/dri/r200/r200_texstate.c
src/mesa/drivers/dri/r200/r200_vertprog.c
src/mesa/drivers/dri/r300/Makefile
src/mesa/drivers/dri/r300/r300_cmdbuf.c
src/mesa/drivers/dri/r300/r300_cmdbuf.h
src/mesa/drivers/dri/r300/r300_context.c
src/mesa/drivers/dri/r300/r300_context.h
src/mesa/drivers/dri/r300/r300_emit.c
src/mesa/drivers/dri/r300/r300_emit.h
src/mesa/drivers/dri/r300/r300_fragprog.c
src/mesa/drivers/dri/r300/r300_fragprog.h
src/mesa/drivers/dri/r300/r300_fragprog_emit.c [new file with mode: 0644]
src/mesa/drivers/dri/r300/r300_fragprog_swizzle.c [new file with mode: 0644]
src/mesa/drivers/dri/r300/r300_fragprog_swizzle.h [new file with mode: 0644]
src/mesa/drivers/dri/r300/r300_ioctl.c
src/mesa/drivers/dri/r300/r300_program.h [deleted file]
src/mesa/drivers/dri/r300/r300_reg.h
src/mesa/drivers/dri/r300/r300_render.c
src/mesa/drivers/dri/r300/r300_shader.c
src/mesa/drivers/dri/r300/r300_state.c
src/mesa/drivers/dri/r300/r300_state.h
src/mesa/drivers/dri/r300/r300_swtcl.c
src/mesa/drivers/dri/r300/r300_tex.c
src/mesa/drivers/dri/r300/r300_tex.h
src/mesa/drivers/dri/r300/r300_texmem.c
src/mesa/drivers/dri/r300/r300_texstate.c
src/mesa/drivers/dri/r300/r300_vertprog.c
src/mesa/drivers/dri/r300/r300_vertprog.h
src/mesa/drivers/dri/r300/r500_fragprog.c [new file with mode: 0644]
src/mesa/drivers/dri/r300/r500_fragprog.h [new file with mode: 0644]
src/mesa/drivers/dri/r300/r500_fragprog_emit.c [new file with mode: 0644]
src/mesa/drivers/dri/r300/radeon_context.c
src/mesa/drivers/dri/r300/radeon_context.h
src/mesa/drivers/dri/r300/radeon_ioctl.c
src/mesa/drivers/dri/r300/radeon_ioctl.h
src/mesa/drivers/dri/r300/radeon_lock.c
src/mesa/drivers/dri/r300/radeon_nqssadce.c [new file with mode: 0644]
src/mesa/drivers/dri/r300/radeon_nqssadce.h [new file with mode: 0644]
src/mesa/drivers/dri/r300/radeon_program.c [new file with mode: 0644]
src/mesa/drivers/dri/r300/radeon_program.h [new file with mode: 0644]
src/mesa/drivers/dri/r300/radeon_program_alu.c [new file with mode: 0644]
src/mesa/drivers/dri/r300/radeon_program_alu.h [new file with mode: 0644]
src/mesa/drivers/dri/r300/radeon_program_pair.c [new file with mode: 0644]
src/mesa/drivers/dri/r300/radeon_program_pair.h [new file with mode: 0644]
src/mesa/drivers/dri/r300/radeon_span.c
src/mesa/drivers/dri/r300/radeon_state.c
src/mesa/drivers/dri/radeon/radeon_chipset.h
src/mesa/drivers/dri/radeon/radeon_context.c
src/mesa/drivers/dri/radeon/radeon_context.h
src/mesa/drivers/dri/radeon/radeon_ioctl.c
src/mesa/drivers/dri/radeon/radeon_ioctl.h
src/mesa/drivers/dri/radeon/radeon_screen.c
src/mesa/drivers/dri/radeon/radeon_screen.h
src/mesa/drivers/dri/radeon/radeon_span.c
src/mesa/drivers/dri/radeon/radeon_state.c
src/mesa/drivers/dri/radeon/radeon_tcl.c
src/mesa/drivers/dri/radeon/radeon_tex.h
src/mesa/drivers/dri/radeon/radeon_texmem.c
src/mesa/drivers/dri/radeon/radeon_texstate.c
src/mesa/drivers/dri/s3v/s3v_context.h
src/mesa/drivers/dri/s3v/s3v_macros.h
src/mesa/drivers/dri/s3v/s3v_render.c
src/mesa/drivers/dri/s3v/s3v_span.c
src/mesa/drivers/dri/s3v/s3v_xmesa.c
src/mesa/drivers/dri/savage/savage_xmesa.c
src/mesa/drivers/dri/savage/savageioctl.h
src/mesa/drivers/dri/savage/savagerender.c
src/mesa/drivers/dri/savage/savagespan.c
src/mesa/drivers/dri/savage/savagespan.h
src/mesa/drivers/dri/savage/savagestate.c
src/mesa/drivers/dri/savage/savagetex.c
src/mesa/drivers/dri/savage/savagetris.c
src/mesa/drivers/dri/sis/sis6326_state.c
src/mesa/drivers/dri/sis/sis_context.h
src/mesa/drivers/dri/sis/sis_screen.c
src/mesa/drivers/dri/sis/sis_span.c
src/mesa/drivers/dri/sis/sis_state.c
src/mesa/drivers/dri/sis/sis_tex.c
src/mesa/drivers/dri/sis/sis_tris.c
src/mesa/drivers/dri/sis/sis_tris.h
src/mesa/drivers/dri/sis/sis_tritmp.h
src/mesa/drivers/dri/swrast/Makefile [new file with mode: 0644]
src/mesa/drivers/dri/swrast/swrast.c [new file with mode: 0644]
src/mesa/drivers/dri/swrast/swrast_priv.h [new file with mode: 0644]
src/mesa/drivers/dri/swrast/swrast_span.c [new file with mode: 0644]
src/mesa/drivers/dri/swrast/swrast_spantemp.h [new file with mode: 0644]
src/mesa/drivers/dri/tdfx/tdfx_context.h
src/mesa/drivers/dri/tdfx/tdfx_render.c
src/mesa/drivers/dri/tdfx/tdfx_screen.c
src/mesa/drivers/dri/tdfx/tdfx_state.c
src/mesa/drivers/dri/trident/trident_context.c
src/mesa/drivers/dri/trident/trident_context.h
src/mesa/drivers/dri/trident/trident_state.c
src/mesa/drivers/dri/unichrome/via_context.c
src/mesa/drivers/dri/unichrome/via_context.h
src/mesa/drivers/dri/unichrome/via_ioctl.c
src/mesa/drivers/dri/unichrome/via_ioctl.h
src/mesa/drivers/dri/unichrome/via_render.c
src/mesa/drivers/dri/unichrome/via_screen.c
src/mesa/drivers/dri/unichrome/via_screen.h
src/mesa/drivers/dri/unichrome/via_span.c
src/mesa/drivers/dri/unichrome/via_state.c
src/mesa/drivers/dri/unichrome/via_tex.c
src/mesa/drivers/dri/unichrome/via_tris.c
src/mesa/drivers/fbdev/Makefile
src/mesa/drivers/fbdev/glfbdev.c
src/mesa/drivers/glide/fxdd.c
src/mesa/drivers/glide/fxddspan.c
src/mesa/drivers/glslcompiler/Makefile
src/mesa/drivers/osmesa/Makefile
src/mesa/drivers/osmesa/descrip.mms [new file with mode: 0644]
src/mesa/drivers/osmesa/osmesa.c
src/mesa/drivers/svga/svgamesa24.c
src/mesa/drivers/svga/svgamesa32.c
src/mesa/drivers/windows/gdi/mesa.def
src/mesa/drivers/windows/gdi/wgl.c
src/mesa/drivers/windows/gdi/wmesa.c
src/mesa/drivers/x11/Makefile
src/mesa/drivers/x11/descrip.mms [new file with mode: 0644]
src/mesa/drivers/x11/fakeglx.c
src/mesa/drivers/x11/glxapi.c
src/mesa/drivers/x11/glxheader.h
src/mesa/drivers/x11/sources [deleted file]
src/mesa/drivers/x11/xm_api.c
src/mesa/drivers/x11/xm_dd.c
src/mesa/drivers/x11/xm_glide.c
src/mesa/drivers/x11/xm_line.c
src/mesa/drivers/x11/xm_tri.c
src/mesa/drivers/x11/xmesaP.h
src/mesa/gl.pc.in [new file with mode: 0644]
src/mesa/glapi/EXT_framebuffer_object.xml
src/mesa/glapi/Makefile
src/mesa/glapi/glX_API.xml
src/mesa/glapi/glX_XML.py
src/mesa/glapi/glX_proto_send.py
src/mesa/glapi/gl_API.xml
src/mesa/glapi/glthread.c
src/mesa/glapi/sources [deleted file]
src/mesa/main/api_validate.c
src/mesa/main/attrib.c
src/mesa/main/attrib.h
src/mesa/main/bufferobj.c
src/mesa/main/bufferobj.h
src/mesa/main/buffers.c
src/mesa/main/buffers.h
src/mesa/main/clear.c
src/mesa/main/config.h
src/mesa/main/context.c
src/mesa/main/context.h
src/mesa/main/dd.h
src/mesa/main/depthstencil.c
src/mesa/main/descrip.mms [new file with mode: 0644]
src/mesa/main/dlist.c
src/mesa/main/drawpix.c
src/mesa/main/enable.c
src/mesa/main/enums.c
src/mesa/main/execmem.c
src/mesa/main/extensions.c
src/mesa/main/fbobject.c
src/mesa/main/framebuffer.c
src/mesa/main/get.c
src/mesa/main/get_gen.py
src/mesa/main/getstring.c
src/mesa/main/glheader.h
src/mesa/main/image.c
src/mesa/main/imports.c
src/mesa/main/imports.h
src/mesa/main/light.c
src/mesa/main/lines.c
src/mesa/main/mipmap.c
src/mesa/main/mtypes.h
src/mesa/main/points.c
src/mesa/main/polygon.c
src/mesa/main/state.c
src/mesa/main/texcompress_fxt1.c
src/mesa/main/texcompress_s3tc.c
src/mesa/main/texenvprogram.c
src/mesa/main/texformat.h
src/mesa/main/texformat_tmp.h
src/mesa/main/teximage.c
src/mesa/main/texstate.c
src/mesa/main/texstate.h
src/mesa/main/texstore.c
src/mesa/main/texstore.h
src/mesa/main/varray.c
src/mesa/main/varray.h
src/mesa/main/version.h
src/mesa/math/descrip.mms [new file with mode: 0644]
src/mesa/math/m_debug_util.h
src/mesa/math/sources [deleted file]
src/mesa/shader/descrip.mms [new file with mode: 0644]
src/mesa/shader/grammar/sources [deleted file]
src/mesa/shader/prog_execute.c
src/mesa/shader/prog_statevars.c
src/mesa/shader/prog_statevars.h
src/mesa/shader/prog_uniform.c
src/mesa/shader/program.c
src/mesa/shader/program.h
src/mesa/shader/slang/descrip.mms [new file with mode: 0644]
src/mesa/shader/slang/library/slang_pp_directives.syn [changed mode: 0755->0644]
src/mesa/shader/slang/library/slang_pp_expression.syn [changed mode: 0755->0644]
src/mesa/shader/slang/library/slang_version.syn [changed mode: 0755->0644]
src/mesa/shader/slang/slang_link.c
src/mesa/shader/slang/sources [deleted file]
src/mesa/shader/sources [deleted file]
src/mesa/sources [new file with mode: 0644]
src/mesa/state_tracker/st_atom_framebuffer.c
src/mesa/state_tracker/st_cb_blit.c
src/mesa/state_tracker/st_cb_strings.c
src/mesa/swrast/descrip.mms [new file with mode: 0644]
src/mesa/swrast/s_aalinetemp.h
src/mesa/swrast/s_aatritemp.h
src/mesa/swrast/s_accum.c
src/mesa/swrast/s_blend.c
src/mesa/swrast/s_blit.c
src/mesa/swrast/s_buffers.c
src/mesa/swrast/s_context.c
src/mesa/swrast/s_context.h
src/mesa/swrast/s_copypix.c
src/mesa/swrast/s_drawpix.c
src/mesa/swrast/s_fragprog.c
src/mesa/swrast/s_linetemp.h
src/mesa/swrast/s_points.c
src/mesa/swrast/s_readpix.c
src/mesa/swrast/s_span.c
src/mesa/swrast/s_stencil.c
src/mesa/swrast/s_texfilter.c
src/mesa/swrast/s_texstore.c
src/mesa/swrast/s_triangle.c
src/mesa/swrast/s_tritemp.h
src/mesa/swrast/s_zoom.c
src/mesa/swrast/sources [deleted file]
src/mesa/swrast/swrast.h
src/mesa/swrast_setup/descrip.mms [new file with mode: 0644]
src/mesa/swrast_setup/sources [deleted file]
src/mesa/swrast_setup/ss_context.c
src/mesa/swrast_setup/ss_triangle.c
src/mesa/swrast_setup/ss_tritmp.h
src/mesa/tnl/descrip.mms [new file with mode: 0644]
src/mesa/tnl/sources [deleted file]
src/mesa/tnl/t_context.c
src/mesa/tnl/t_draw.c
src/mesa/tnl/t_pipeline.c
src/mesa/tnl/t_vb_fog.c
src/mesa/tnl/t_vb_program.c
src/mesa/tnl/t_vertex_sse.c
src/mesa/tnl/t_vp_build.c
src/mesa/tnl/tnl.h
src/mesa/tnl_dd/t_dd_tritmp.h
src/mesa/vbo/descrip.mms [new file with mode: 0644]
src/mesa/vbo/vbo_context.c
src/mesa/vbo/vbo_exec_draw.c
src/mesa/vbo/vbo_split_copy.c
src/mesa/x86-64/Makefile
src/mesa/x86-64/xform4.S
src/mesa/x86/Makefile
src/mesa/x86/read_rgba_span_x86.S
src/mesa/x86/rtasm/x86sse.c
src/mesa/x86/rtasm/x86sse.h
windows/VC6/progs/glut/glut.dsp [new file with mode: 0644]
windows/VC7/mesa/gdi/gdi.vcproj [new file with mode: 0644]
windows/VC7/mesa/glu/glu.vcproj [new file with mode: 0644]
windows/VC7/mesa/mesa.sln [new file with mode: 0644]
windows/VC7/mesa/mesa/mesa.vcproj [new file with mode: 0644]
windows/VC7/mesa/osmesa/osmesa.vcproj [new file with mode: 0644]
windows/VC7/progs/glut/glut.vcproj [new file with mode: 0644]
windows/VC8/mesa/gdi/gdi.vcproj [new file with mode: 0644]
windows/VC8/mesa/glu/glu.vcproj [new file with mode: 0644]
windows/VC8/mesa/mesa.sln [new file with mode: 0644]
windows/VC8/mesa/mesa/mesa.vcproj [new file with mode: 0644]
windows/VC8/progs/glut/glut.vcproj [new file with mode: 0644]

diff --git a/.gitattributes b/.gitattributes
new file mode 100644 (file)
index 0000000..23c6280
--- /dev/null
@@ -0,0 +1,4 @@
+*.dsp -crlf
+*.dsw -crlf
+*.sln -crlf
+*.vcproj -crlf
index 5c9129535a12b80f150e3929b5d0ea2669edb0f9..d519cab474beeb254b66cdac1feef8f0ebbe50b3 100644 (file)
@@ -4,11 +4,18 @@
 *.pyo
 *.so
 *.sw[a-z]
+*.pc
 *~
 depend
 depend.bak
 lib
 lib64
+configure
+autom4te.cache
+aclocal.m4
+config.log
+config.status
+cscope*
 .sconsign*
 config.py
 build
index b6b8bce3e791a2ab66b8a02c5d8f47a6ce3ca739..3fc9f5b6f2750e7aaab02076412f3afad51507a1 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -18,26 +18,23 @@ all: default
 doxygen:
        cd doxygen && $(MAKE)
 
-.PHONY: doxygen
-
-
 clean:
-       @for dir in $(SUBDIRS) ; do \
+       -@touch $(TOP)/configs/current
+       -@for dir in $(SUBDIRS) ; do \
                if [ -d $$dir ] ; then \
                        (cd $$dir && $(MAKE) clean) ; \
                fi \
        done
+       -@test -s $(TOP)/configs/current || rm -f $(TOP)/configs/current
 
 
-realclean:
-       -rm -f `find . -name \*.o`
-       -rm -f `find . -name \*.a`
-       -rm -f `find . -name \*.so`
-       -rm -f `find . -name depend`
-       -rm -f `find . -name depend.bak`
+realclean: clean
        -rm -rf lib*
-       $(MAKE) clean
        -rm -f $(TOP)/configs/current
+       -rm -f $(TOP)/configs/autoconf
+       -rm -rf autom4te.cache
+       -find . '(' -name '*.o' -o -name '*.a' -o -name '*.so' -o \
+         -name depend -o -name depend.bak ')' -exec rm -f '{}' ';'
 
 
 install:
@@ -52,14 +49,20 @@ install:
 linux-directfb-install:
        cd src/mesa/drivers/directfb && $(MAKE) install
 
+.PHONY: default doxygen clean realclean install linux-directfb-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"
+       @ls -1 $(TOP)/configs | grep -v "current\|default\|CVS\|autoconf.*"
        @echo
        @echo "Then type 'make <config>' (ex: 'make linux-x86')"
+       @echo
+       @echo "Or, run './configure' then 'make'"
+       @echo "See './configure --help' for details"
+       @echo
        @echo "(ignore the following error message)"
        @exit 1
 
@@ -70,11 +73,16 @@ aix-64 \
 aix-64-static \
 aix-gcc \
 aix-static \
+autoconf \
+bluegene-osmesa \
+bluegene-xlc-osmesa \
 beos \
+catamount-osmesa-pgi \
 darwin \
+darwin-fat-32bit \
+darwin-fat-all \
 darwin-static \
 darwin-static-x86ppc \
-darwin-x86ppc \
 freebsd \
 freebsd-dri \
 freebsd-dri-amd64 \
@@ -162,8 +170,9 @@ sunos5-v8 \
 sunos5-v8-static \
 sunos5-v9 \
 sunos5-v9-static \
+sunos5-v9-cc-g++ \
 ultrix-gcc:
-       @ if [ -e configs/current ] ; then \
+       @ if test -f configs/current || test -L configs/current ; then \
                echo "Please run 'make realclean' before changing configs" ; \
                exit 1 ; \
        fi
@@ -173,17 +182,25 @@ ultrix-gcc:
 
 # Rules for making release tarballs
 
-DIRECTORY = Mesa-7.1pre
-LIB_NAME = MesaLib-7.1pre
-DEMO_NAME = MesaDemos-7.1pre
-GLUT_NAME = MesaGLUT-7.1pre
+DIRECTORY = Mesa-7.1-rc4
+LIB_NAME = MesaLib-7.1-rc4
+DEMO_NAME = MesaDemos-7.1-rc4
+GLUT_NAME = MesaGLUT-7.1-rc4
 
 MAIN_FILES = \
        $(DIRECTORY)/Makefile*                                          \
+       $(DIRECTORY)/configure                                          \
+       $(DIRECTORY)/configure.ac                                       \
+       $(DIRECTORY)/acinclude.m4                                       \
+       $(DIRECTORY)/aclocal.m4                                         \
        $(DIRECTORY)/descrip.mms                                        \
        $(DIRECTORY)/mms-config.                                        \
+       $(DIRECTORY)/bin/config.guess                                   \
+       $(DIRECTORY)/bin/config.sub                                     \
+       $(DIRECTORY)/bin/install-sh                                     \
        $(DIRECTORY)/bin/mklib                                          \
        $(DIRECTORY)/bin/minstall                                       \
+       $(DIRECTORY)/bin/version.mk                                     \
        $(DIRECTORY)/configs/[a-z]*                                     \
        $(DIRECTORY)/docs/*.html                                        \
        $(DIRECTORY)/docs/COPYING                                       \
@@ -220,51 +237,44 @@ MAIN_FILES = \
        $(DIRECTORY)/src/mesa/Makefile*                                 \
        $(DIRECTORY)/src/mesa/sources                                   \
        $(DIRECTORY)/src/mesa/descrip.mms                               \
+       $(DIRECTORY)/src/mesa/gl.pc.in                                  \
        $(DIRECTORY)/src/mesa/depend                                    \
        $(DIRECTORY)/src/mesa/main/*.[chS]                              \
        $(DIRECTORY)/src/mesa/main/descrip.mms                          \
-       $(DIRECTORY)/src/mesa/main/sources                              \
        $(DIRECTORY)/src/mesa/glapi/*.[chS]                             \
        $(DIRECTORY)/src/mesa/glapi/descrip.mms                         \
-       $(DIRECTORY)/src/mesa/glapi/sources                             \
        $(DIRECTORY)/src/mesa/math/*.[ch]                               \
        $(DIRECTORY)/src/mesa/math/descrip.mms                          \
-       $(DIRECTORY)/src/mesa/math/sources                              \
        $(DIRECTORY)/src/mesa/shader/*.[ch]                             \
        $(DIRECTORY)/src/mesa/shader/descrip.mms                        \
-       $(DIRECTORY)/src/mesa/shader/sources                            \
        $(DIRECTORY)/src/mesa/shader/grammar/*.[ch]                     \
        $(DIRECTORY)/src/mesa/shader/grammar/descrip.mms                \
-       $(DIRECTORY)/src/mesa/shader/grammar/sources                    \
        $(DIRECTORY)/src/mesa/shader/slang/*.[ch]                       \
        $(DIRECTORY)/src/mesa/shader/slang/descrip.mms                  \
-       $(DIRECTORY)/src/mesa/shader/slang/sources                      \
        $(DIRECTORY)/src/mesa/shader/slang/library/*.[ch]               \
        $(DIRECTORY)/src/mesa/shader/slang/library/*.gc                 \
        $(DIRECTORY)/src/mesa/shader/slang/library/*.syn                \
        $(DIRECTORY)/src/mesa/shader/slang/library/Makefile             \
        $(DIRECTORY)/src/mesa/swrast/*.[ch]                             \
        $(DIRECTORY)/src/mesa/swrast/descrip.mms                        \
-       $(DIRECTORY)/src/mesa/swrast/sources                            \
        $(DIRECTORY)/src/mesa/swrast_setup/*.[ch]                       \
        $(DIRECTORY)/src/mesa/swrast_setup/descrip.mms                  \
-       $(DIRECTORY)/src/mesa/swrast_setup/sources                      \
        $(DIRECTORY)/src/mesa/vbo/*.[chS]                               \
        $(DIRECTORY)/src/mesa/vbo/descrip.mms                           \
        $(DIRECTORY)/src/mesa/tnl/*.[chS]                               \
        $(DIRECTORY)/src/mesa/tnl/descrip.mms                           \
-       $(DIRECTORY)/src/mesa/tnl/sources                               \
        $(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/Makefile                          \
        $(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/common/sources                    \
        $(DIRECTORY)/src/mesa/drivers/directfb/*.[ch]                   \
        $(DIRECTORY)/src/mesa/drivers/directfb/Makefile                 \
        $(DIRECTORY)/src/mesa/drivers/dos/*.[chS]                       \
+       $(DIRECTORY)/src/mesa/drivers/fbdev/Makefile                    \
        $(DIRECTORY)/src/mesa/drivers/fbdev/glfbdev.c                   \
        $(DIRECTORY)/src/mesa/drivers/glide/*.[ch]                      \
        $(DIRECTORY)/src/mesa/drivers/ggi/*.[ch]                        \
@@ -274,6 +284,7 @@ MAIN_FILES = \
        $(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                   \
        $(DIRECTORY)/src/mesa/drivers/osmesa/Makefile.win               \
        $(DIRECTORY)/src/mesa/drivers/osmesa/descrip.mms                \
        $(DIRECTORY)/src/mesa/drivers/osmesa/osmesa.def                 \
@@ -281,8 +292,8 @@ MAIN_FILES = \
        $(DIRECTORY)/src/mesa/drivers/svga/*.[ch]                       \
        $(DIRECTORY)/src/mesa/drivers/windows/*/*.[ch]                  \
        $(DIRECTORY)/src/mesa/drivers/windows/*/*.def                   \
+       $(DIRECTORY)/src/mesa/drivers/x11/Makefile                      \
        $(DIRECTORY)/src/mesa/drivers/x11/descrip.mms                   \
-       $(DIRECTORY)/src/mesa/drivers/x11/sources                       \
        $(DIRECTORY)/src/mesa/drivers/x11/*.[ch]                        \
        $(DIRECTORY)/src/mesa/ppc/*.[ch]                                \
        $(DIRECTORY)/src/mesa/sparc/*.[chS]                             \
@@ -311,12 +322,14 @@ MAIN_FILES = \
 
 DRI_FILES = \
        $(DIRECTORY)/include/GL/internal/dri_interface.h                \
+       $(DIRECTORY)/include/GL/internal/dri_sarea.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/dri.pc.in                     \
        $(DIRECTORY)/src/mesa/drivers/dri/common/xmlpool/*.[ch]         \
        $(DIRECTORY)/src/mesa/drivers/dri/common/xmlpool/*.po           \
        $(DIRECTORY)/src/mesa/drivers/dri/*/*.[chS]                     \
@@ -327,6 +340,7 @@ DRI_FILES = \
 SGI_GLU_FILES = \
        $(DIRECTORY)/src/glu/Makefile                                   \
        $(DIRECTORY)/src/glu/descrip.mms                                \
+       $(DIRECTORY)/src/glu/glu.pc.in                                  \
        $(DIRECTORY)/src/glu/sgi/Makefile                               \
        $(DIRECTORY)/src/glu/sgi/Makefile.mgw                           \
        $(DIRECTORY)/src/glu/sgi/Makefile.win                           \
@@ -334,6 +348,8 @@ SGI_GLU_FILES = \
        $(DIRECTORY)/src/glu/sgi/glu.def                                \
        $(DIRECTORY)/src/glu/sgi/dummy.cc                               \
        $(DIRECTORY)/src/glu/sgi/descrip.mms                            \
+       $(DIRECTORY)/src/glu/sgi/glu.exports                            \
+       $(DIRECTORY)/src/glu/sgi/glu.exports.darwin                     \
        $(DIRECTORY)/src/glu/sgi/mesaglu.opt                            \
        $(DIRECTORY)/src/glu/sgi/include/gluos.h                        \
        $(DIRECTORY)/src/glu/sgi/libnurbs/interface/*.h                 \
@@ -360,6 +376,7 @@ GLW_FILES = \
        $(DIRECTORY)/src/glw/*.[ch]                     \
        $(DIRECTORY)/src/glw/Makefile*                  \
        $(DIRECTORY)/src/glw/README                     \
+       $(DIRECTORY)/src/glw/glw.pc.in                  \
        $(DIRECTORY)/src/glw/depend
 
 DEMO_FILES = \
@@ -388,7 +405,8 @@ DEMO_FILES = \
        $(DIRECTORY)/progs/samples/*.c                  \
        $(DIRECTORY)/progs/glsl/Makefile*               \
        $(DIRECTORY)/progs/glsl/*.c                     \
-       $(DIRECTORY)/progs/glsl/*.txt                   \
+       $(DIRECTORY)/progs/glsl/*.frag                  \
+       $(DIRECTORY)/progs/glsl/*.vert                  \
        $(DIRECTORY)/progs/windml/Makefile.ugl          \
        $(DIRECTORY)/progs/windml/*.c                   \
        $(DIRECTORY)/progs/windml/*.bmp                 \
@@ -403,6 +421,7 @@ GLUT_FILES = \
        $(DIRECTORY)/include/GL/glutf90.h               \
        $(DIRECTORY)/src/glut/glx/Makefile*             \
        $(DIRECTORY)/src/glut/glx/depend                \
+       $(DIRECTORY)/src/glut/glx/glut.pc.in            \
        $(DIRECTORY)/src/glut/glx/*def                  \
        $(DIRECTORY)/src/glut/glx/descrip.mms           \
        $(DIRECTORY)/src/glut/glx/mms_depend            \
@@ -418,6 +437,10 @@ GLUT_FILES = \
        $(DIRECTORY)/src/glut/fbdev/Makefile            \
        $(DIRECTORY)/src/glut/fbdev/*[ch]               \
        $(DIRECTORY)/src/glut/mini/*[ch]                \
+       $(DIRECTORY)/src/glut/mini/glut.pc.in           \
+       $(DIRECTORY)/src/glut/directfb/Makefile         \
+       $(DIRECTORY)/src/glut/directfb/NOTES            \
+       $(DIRECTORY)/src/glut/directfb/*[ch]            \
        $(DIRECTORY)/windows/VC6/progs/glut/glut.dsp    \
        $(DIRECTORY)/windows/VC7/progs/glut/glut.vcproj
 
@@ -433,9 +456,20 @@ 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
+tarballs: rm_depend configure aclocal.m4 lib_gz demo_gz glut_gz \
+       lib_bz2 demo_bz2 glut_bz2 lib_zip demo_zip glut_zip md5
 
 
+# Helper for autoconf builds
+ACLOCAL = aclocal
+ACLOCAL_FLAGS =
+AUTOCONF = autoconf
+AC_FLAGS =
+aclocal.m4: configure.ac acinclude.m4
+       $(ACLOCAL) $(ACLOCAL_FLAGS)
+configure: configure.ac aclocal.m4 acinclude.m4
+       $(AUTOCONF) $(AC_FLAGS)
+
 rm_depend:
        @for dep in $(DEPEND_FILES) ; do \
                rm -f $$dep ; \
@@ -444,6 +478,7 @@ rm_depend:
 
 lib_gz:
        rm -f configs/current ; \
+       rm -f configs/autoconf ; \
        cd .. ; \
        tar -cf $(LIB_NAME).tar $(LIB_FILES) ; \
        gzip $(LIB_NAME).tar ; \
@@ -463,6 +498,7 @@ glut_gz:
 
 lib_bz2:
        rm -f configs/current ; \
+       rm -f configs/autoconf ; \
        cd .. ; \
        tar -cf $(LIB_NAME).tar $(LIB_FILES) ; \
        bzip2 $(LIB_NAME).tar ; \
@@ -482,6 +518,7 @@ glut_bz2:
 
 lib_zip:
        rm -f configs/current ; \
+       rm -f configs/autoconf ; \
        rm -f $(LIB_NAME).zip ; \
        cd .. ; \
        zip -qr $(LIB_NAME).zip $(LIB_FILES) ; \
@@ -509,3 +546,6 @@ md5:
        @-md5sum $(GLUT_NAME).tar.gz
        @-md5sum $(GLUT_NAME).tar.bz2
        @-md5sum $(GLUT_NAME).zip
+
+.PHONY: tarballs rm_depend lib_gz demo_gz glut_gz lib_bz2 demo_bz2 \
+       glut_bz2 lib_zip demo_zip glut_zip md5
diff --git a/acinclude.m4 b/acinclude.m4
new file mode 100644 (file)
index 0000000..a5b389d
--- /dev/null
@@ -0,0 +1,119 @@
+# A few convenience macros for Mesa, mostly to keep all the platform
+# specifics out of configure.ac.
+
+# MESA_PIC_FLAGS()
+#
+# Find out whether to build PIC code using the option --enable-pic and
+# the configure enable_static/enable_shared settings. If PIC is needed,
+# figure out the necessary flags for the platform and compiler.
+#
+# The platform checks have been shamelessly taken from libtool and
+# stripped down to just what's needed for Mesa. See _LT_COMPILER_PIC in
+# /usr/share/aclocal/libtool.m4 or
+# http://git.savannah.gnu.org/gitweb/?p=libtool.git;a=blob;f=libltdl/m4/libtool.m4;hb=HEAD
+#
+AC_DEFUN([MESA_PIC_FLAGS],
+[AC_REQUIRE([AC_PROG_CC])dnl
+AC_ARG_VAR([PIC_FLAGS], [compiler flags for PIC code])
+AC_ARG_ENABLE([pic],
+    [AS_HELP_STRING([--disable-pic],
+        [compile PIC objects @<:@default=enabled for shared builds
+        on supported platforms@:>@])],
+    [enable_pic="$enableval"
+    test "x$enable_pic" = x && enable_pic=auto],
+    [enable_pic=auto])
+# disable PIC by default for static builds
+if test "$enable_pic" = auto && test "$enable_static" = yes; then
+    enable_pic=no
+fi
+# if PIC hasn't been explicitly disabled, try to figure out the flags
+if test "$enable_pic" != no; then
+    AC_MSG_CHECKING([for $CC option to produce PIC])
+    # allow the user's flags to override
+    if test "x$PIC_FLAGS" = x; then
+        # see if we're using GCC
+        if test "x$GCC" = xyes; then
+            case "$host_os" in
+            aix*|beos*|cygwin*|irix5*|irix6*|osf3*|osf4*|osf5*)
+                # PIC is the default for these OSes.
+                ;;
+            mingw*|os2*|pw32*)
+                # This hack is so that the source file can tell whether
+                # it is being built for inclusion in a dll (and should
+                # export symbols for example).
+                PIC_FLAGS="-DDLL_EXPORT"
+                ;;
+            darwin*|rhapsody*)
+                # PIC is the default on this platform
+                # Common symbols not allowed in MH_DYLIB files
+                PIC_FLAGS="-fno-common"
+                ;;
+            hpux*)
+                # PIC is the default for IA64 HP-UX and 64-bit HP-UX,
+                # but not for PA HP-UX.
+                case $host_cpu in
+                hppa*64*|ia64*)
+                    ;;
+                *)
+                    PIC_FLAGS="-fPIC"
+                    ;;
+                esac
+                ;;
+            *)
+                # Everyone else on GCC uses -fPIC
+                PIC_FLAGS="-fPIC"
+                ;;
+            esac
+        else # !GCC
+            case "$host_os" in
+            hpux9*|hpux10*|hpux11*)
+                # PIC is the default for IA64 HP-UX and 64-bit HP-UX,
+                # but not for PA HP-UX.
+                case "$host_cpu" in
+                hppa*64*|ia64*)
+                    # +Z the default
+                    ;;
+                *)
+                    PIC_FLAGS="+Z"
+                    ;;
+                esac
+                ;;
+            linux*|k*bsd*-gnu)
+                case `basename "$CC"` in
+                icc*|ecc*|ifort*)
+                    PIC_FLAGS="-KPIC"
+                    ;;
+                pgcc*|pgf77*|pgf90*|pgf95*)
+                    # Portland Group compilers (*not* the Pentium gcc
+                    # compiler, which looks to be a dead project)
+                    PIC_FLAGS="-fpic"
+                    ;;
+                ccc*)
+                    # All Alpha code is PIC.
+                    ;;
+                xl*)
+                    # IBM XL C 8.0/Fortran 10.1 on PPC
+                    PIC_FLAGS="-qpic"
+                    ;;
+                *)
+                    case `$CC -V 2>&1 | sed 5q` in
+                    *Sun\ C*|*Sun\ F*)
+                        # Sun C 5.9 or Sun Fortran
+                        PIC_FLAGS="-KPIC"
+                        ;;
+                    esac
+                esac
+                ;;
+            solaris*)
+                PIC_FLAGS="-KPIC"
+                ;;
+            sunos4*)
+                PIC_FLAGS="-PIC"
+                ;;
+            esac
+        fi # GCC
+    fi # PIC_FLAGS
+    AC_MSG_RESULT([$PIC_FLAGS])
+fi
+AC_SUBST([PIC_FLAGS])
+])# MESA_PIC_FLAGS
diff --git a/autogen.sh b/autogen.sh
new file mode 100755 (executable)
index 0000000..19e5b55
--- /dev/null
@@ -0,0 +1,16 @@
+#! /bin/sh
+
+srcdir=`dirname "$0"`
+test -z "$srcdir" && srcdir=.
+
+SRCDIR=`(cd "$srcdir" && pwd)`
+ORIGDIR=`pwd`
+
+if test "x$SRCDIR" != "x$ORIGDIR"; then
+       echo "Mesa cannot be built when srcdir != builddir" 1>&2
+       exit 1
+fi
+
+autoreconf -v --install || exit 1
+
+"$srcdir"/configure "$@"
diff --git a/bin/confdiff.sh b/bin/confdiff.sh
new file mode 100755 (executable)
index 0000000..568fcd6
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/bash -e
+
+usage()
+{
+       echo "Usage: $0 <target1> <target2>"
+       echo "Highlight differences between Mesa configs"
+       echo "Example:"
+       echo "  $0 linux linux-x86"
+}
+
+die()
+{
+       echo "$@" >&2
+       return 1
+}
+
+case "$1" in
+-h|--help) usage; exit 0;;
+esac
+
+[ $# -lt 2 ] && die 2 targets needed. See $0 --help
+target1=$1
+target2=$2
+
+topdir=$(cd "`dirname $0`"/..; pwd)
+cd "$topdir"
+
+[ -f "./configs/$target1" ] || die Missing configs/$target1
+[ -f "./configs/$target2" ] || die Missing configs/$target2
+
+trap 'rm -f "$t1" "$t2"' 0
+
+t1=$(mktemp)
+t2=$(mktemp)
+
+make -f- -n -p <<EOF | sed '/^# Not a target/,/^$/d' > $t1
+TOP = .
+include \$(TOP)/configs/$target1
+default:
+EOF
+
+make -f- -n -p <<EOF | sed '/^# Not a target/,/^$/d' > $t2
+TOP = .
+include \$(TOP)/configs/$target2
+default:
+EOF
+
+diff -pu -I'^#' $t1 $t2
diff --git a/bin/config.guess b/bin/config.guess
new file mode 100755 (executable)
index 0000000..278f9e9
--- /dev/null
@@ -0,0 +1,1516 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
+#   Inc.
+
+timestamp='2007-07-22'
+
+# This file 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 of the License, 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., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Originally written by Per Bothner <per@bothner.com>.
+# Please send patches to <config-patches@gnu.org>.  Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub.  If it succeeds, it prints the system name on stdout, and
+# exits with 0.  Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )        # Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help" >&2
+       exit 1 ;;
+    * )
+       break ;;
+  esac
+done
+
+if test $# != 0; then
+  echo "$me: too many arguments$help" >&2
+  exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,)    echo "int x;" > $dummy.c ;
+       for c in cc gcc c89 c99 ; do
+         if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+            CC_FOR_BUILD="$c"; break ;
+         fi ;
+       done ;
+       if test x"$CC_FOR_BUILD" = x ; then
+         CC_FOR_BUILD=no_compiler_found ;
+       fi
+       ;;
+ ,,*)   CC_FOR_BUILD=$CC ;;
+ ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+       PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    *:NetBSD:*:*)
+       # NetBSD (nbsd) targets should (where applicable) match one or
+       # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+       # *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
+       # switched to ELF, *-*-netbsd* would select the old
+       # object file format.  This provides both forward
+       # compatibility and a consistent mechanism for selecting the
+       # object file format.
+       #
+       # Note: NetBSD doesn't particularly care about the vendor
+       # portion of the name.  We always set it to "unknown".
+       sysctl="sysctl -n hw.machine_arch"
+       UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+           /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+       case "${UNAME_MACHINE_ARCH}" in
+           armeb) machine=armeb-unknown ;;
+           arm*) machine=arm-unknown ;;
+           sh3el) machine=shl-unknown ;;
+           sh3eb) machine=sh-unknown ;;
+           sh5el) machine=sh5le-unknown ;;
+           *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+       esac
+       # The Operating System including object format, if it has switched
+       # to ELF recently, or will in the future.
+       case "${UNAME_MACHINE_ARCH}" in
+           arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+               eval $set_cc_for_build
+               if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+                       | grep __ELF__ >/dev/null
+               then
+                   # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+                   # Return netbsd for either.  FIX?
+                   os=netbsd
+               else
+                   os=netbsdelf
+               fi
+               ;;
+           *)
+               os=netbsd
+               ;;
+       esac
+       # The OS release
+       # Debian GNU/NetBSD machines have a different userland, and
+       # thus, need a distinct triplet. However, they do not need
+       # kernel version information, so it can be replaced with a
+       # suitable tag, in the style of linux-gnu.
+       case "${UNAME_VERSION}" in
+           Debian*)
+               release='-gnu'
+               ;;
+           *)
+               release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+               ;;
+       esac
+       # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+       # contains redundant information, the shorter form:
+       # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+       echo "${machine}-${os}${release}"
+       exit ;;
+    *:OpenBSD:*:*)
+       UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+       echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+       exit ;;
+    *:ekkoBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+       exit ;;
+    *:SolidBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+       exit ;;
+    macppc:MirBSD:*:*)
+       echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+       exit ;;
+    *:MirBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+       exit ;;
+    alpha:OSF1:*:*)
+       case $UNAME_RELEASE in
+       *4.0)
+               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+               ;;
+       *5.*)
+               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+               ;;
+       esac
+       # According to Compaq, /usr/sbin/psrinfo has been available on
+       # OSF/1 and Tru64 systems produced since 1995.  I hope that
+       # covers most systems running today.  This code pipes the CPU
+       # types through head -n 1, so we only detect the type of CPU 0.
+       ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+       case "$ALPHA_CPU_TYPE" in
+           "EV4 (21064)")
+               UNAME_MACHINE="alpha" ;;
+           "EV4.5 (21064)")
+               UNAME_MACHINE="alpha" ;;
+           "LCA4 (21066/21068)")
+               UNAME_MACHINE="alpha" ;;
+           "EV5 (21164)")
+               UNAME_MACHINE="alphaev5" ;;
+           "EV5.6 (21164A)")
+               UNAME_MACHINE="alphaev56" ;;
+           "EV5.6 (21164PC)")
+               UNAME_MACHINE="alphapca56" ;;
+           "EV5.7 (21164PC)")
+               UNAME_MACHINE="alphapca57" ;;
+           "EV6 (21264)")
+               UNAME_MACHINE="alphaev6" ;;
+           "EV6.7 (21264A)")
+               UNAME_MACHINE="alphaev67" ;;
+           "EV6.8CB (21264C)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.8AL (21264B)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.8CX (21264D)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.9A (21264/EV69A)")
+               UNAME_MACHINE="alphaev69" ;;
+           "EV7 (21364)")
+               UNAME_MACHINE="alphaev7" ;;
+           "EV7.9 (21364A)")
+               UNAME_MACHINE="alphaev79" ;;
+       esac
+       # A Pn.n version is a patched version.
+       # A Vn.n version is a released version.
+       # A Tn.n version is a released field test version.
+       # A Xn.n version is an unreleased experimental baselevel.
+       # 1.2 uses "1.2" for uname -r.
+       echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+       exit ;;
+    Alpha\ *:Windows_NT*:*)
+       # How do we know it's Interix rather than the generic POSIX subsystem?
+       # Should we change UNAME_MACHINE based on the output of uname instead
+       # of the specific Alpha model?
+       echo alpha-pc-interix
+       exit ;;
+    21064:Windows_NT:50:3)
+       echo alpha-dec-winnt3.5
+       exit ;;
+    Amiga*:UNIX_System_V:4.0:*)
+       echo m68k-unknown-sysv4
+       exit ;;
+    *:[Aa]miga[Oo][Ss]:*:*)
+       echo ${UNAME_MACHINE}-unknown-amigaos
+       exit ;;
+    *:[Mm]orph[Oo][Ss]:*:*)
+       echo ${UNAME_MACHINE}-unknown-morphos
+       exit ;;
+    *:OS/390:*:*)
+       echo i370-ibm-openedition
+       exit ;;
+    *:z/VM:*:*)
+       echo s390-ibm-zvmoe
+       exit ;;
+    *:OS400:*:*)
+        echo powerpc-ibm-os400
+       exit ;;
+    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+       echo arm-acorn-riscix${UNAME_RELEASE}
+       exit ;;
+    arm:riscos:*:*|arm:RISCOS:*:*)
+       echo arm-unknown-riscos
+       exit ;;
+    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+       echo hppa1.1-hitachi-hiuxmpp
+       exit ;;
+    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+       # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+       if test "`(/bin/universe) 2>/dev/null`" = att ; then
+               echo pyramid-pyramid-sysv3
+       else
+               echo pyramid-pyramid-bsd
+       fi
+       exit ;;
+    NILE*:*:*:dcosx)
+       echo pyramid-pyramid-svr4
+       exit ;;
+    DRS?6000:unix:4.0:6*)
+       echo sparc-icl-nx6
+       exit ;;
+    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+       case `/usr/bin/uname -p` in
+           sparc) echo sparc-icl-nx7; exit ;;
+       esac ;;
+    sun4H:SunOS:5.*:*)
+       echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+       echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+       echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:6*:*)
+       # According to config.sub, this is the proper way to canonicalize
+       # SunOS6.  Hard to guess exactly what SunOS6 will be like, but
+       # it's likely to be more like Solaris than SunOS4.
+       echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:*:*)
+       case "`/usr/bin/arch -k`" in
+           Series*|S4*)
+               UNAME_RELEASE=`uname -v`
+               ;;
+       esac
+       # Japanese Language versions have a version number like `4.1.3-JL'.
+       echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+       exit ;;
+    sun3*:SunOS:*:*)
+       echo m68k-sun-sunos${UNAME_RELEASE}
+       exit ;;
+    sun*:*:4.2BSD:*)
+       UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+       test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+       case "`/bin/arch`" in
+           sun3)
+               echo m68k-sun-sunos${UNAME_RELEASE}
+               ;;
+           sun4)
+               echo sparc-sun-sunos${UNAME_RELEASE}
+               ;;
+       esac
+       exit ;;
+    aushp:SunOS:*:*)
+       echo sparc-auspex-sunos${UNAME_RELEASE}
+       exit ;;
+    # The situation for MiNT is a little confusing.  The machine name
+    # can be virtually everything (everything which is not
+    # "atarist" or "atariste" at least should have a processor
+    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
+    # to the lowercase version "mint" (or "freemint").  Finally
+    # the system name "TOS" denotes a system which is actually not
+    # MiNT.  But MiNT is downward compatible to TOS, so this should
+    # be no problem.
+    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+       exit ;;
+    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+       echo m68k-atari-mint${UNAME_RELEASE}
+        exit ;;
+    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+       exit ;;
+    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+        echo m68k-milan-mint${UNAME_RELEASE}
+        exit ;;
+    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+        echo m68k-hades-mint${UNAME_RELEASE}
+        exit ;;
+    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+        echo m68k-unknown-mint${UNAME_RELEASE}
+        exit ;;
+    m68k:machten:*:*)
+       echo m68k-apple-machten${UNAME_RELEASE}
+       exit ;;
+    powerpc:machten:*:*)
+       echo powerpc-apple-machten${UNAME_RELEASE}
+       exit ;;
+    RISC*:Mach:*:*)
+       echo mips-dec-mach_bsd4.3
+       exit ;;
+    RISC*:ULTRIX:*:*)
+       echo mips-dec-ultrix${UNAME_RELEASE}
+       exit ;;
+    VAX*:ULTRIX*:*:*)
+       echo vax-dec-ultrix${UNAME_RELEASE}
+       exit ;;
+    2020:CLIX:*:* | 2430:CLIX:*:*)
+       echo clipper-intergraph-clix${UNAME_RELEASE}
+       exit ;;
+    mips:*:*:UMIPS | mips:*:*:RISCos)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+       int main (int argc, char *argv[]) {
+#else
+       int main (argc, argv) int argc; char *argv[]; {
+#endif
+       #if defined (host_mips) && defined (MIPSEB)
+       #if defined (SYSTYPE_SYSV)
+         printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+       #endif
+       #if defined (SYSTYPE_SVR4)
+         printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+       #endif
+       #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+         printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+       #endif
+       #endif
+         exit (-1);
+       }
+EOF
+       $CC_FOR_BUILD -o $dummy $dummy.c &&
+         dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+         SYSTEM_NAME=`$dummy $dummyarg` &&
+           { echo "$SYSTEM_NAME"; exit; }
+       echo mips-mips-riscos${UNAME_RELEASE}
+       exit ;;
+    Motorola:PowerMAX_OS:*:*)
+       echo powerpc-motorola-powermax
+       exit ;;
+    Motorola:*:4.3:PL8-*)
+       echo powerpc-harris-powermax
+       exit ;;
+    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+       echo powerpc-harris-powermax
+       exit ;;
+    Night_Hawk:Power_UNIX:*:*)
+       echo powerpc-harris-powerunix
+       exit ;;
+    m88k:CX/UX:7*:*)
+       echo m88k-harris-cxux7
+       exit ;;
+    m88k:*:4*:R4*)
+       echo m88k-motorola-sysv4
+       exit ;;
+    m88k:*:3*:R3*)
+       echo m88k-motorola-sysv3
+       exit ;;
+    AViiON:dgux:*:*)
+        # DG/UX returns AViiON for all architectures
+        UNAME_PROCESSOR=`/usr/bin/uname -p`
+       if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+       then
+           if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+              [ ${TARGET_BINARY_INTERFACE}x = x ]
+           then
+               echo m88k-dg-dgux${UNAME_RELEASE}
+           else
+               echo m88k-dg-dguxbcs${UNAME_RELEASE}
+           fi
+       else
+           echo i586-dg-dgux${UNAME_RELEASE}
+       fi
+       exit ;;
+    M88*:DolphinOS:*:*)        # DolphinOS (SVR3)
+       echo m88k-dolphin-sysv3
+       exit ;;
+    M88*:*:R3*:*)
+       # Delta 88k system running SVR3
+       echo m88k-motorola-sysv3
+       exit ;;
+    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+       echo m88k-tektronix-sysv3
+       exit ;;
+    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+       echo m68k-tektronix-bsd
+       exit ;;
+    *:IRIX*:*:*)
+       echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+       exit ;;
+    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+       echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
+       exit ;;               # Note that: echo "'`uname -s`'" gives 'AIX '
+    i*86:AIX:*:*)
+       echo i386-ibm-aix
+       exit ;;
+    ia64:AIX:*:*)
+       if [ -x /usr/bin/oslevel ] ; then
+               IBM_REV=`/usr/bin/oslevel`
+       else
+               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+       fi
+       echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+       exit ;;
+    *:AIX:2:3)
+       if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+               eval $set_cc_for_build
+               sed 's/^                //' << EOF >$dummy.c
+               #include <sys/systemcfg.h>
+
+               main()
+                       {
+                       if (!__power_pc())
+                               exit(1);
+                       puts("powerpc-ibm-aix3.2.5");
+                       exit(0);
+                       }
+EOF
+               if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+               then
+                       echo "$SYSTEM_NAME"
+               else
+                       echo rs6000-ibm-aix3.2.5
+               fi
+       elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+               echo rs6000-ibm-aix3.2.4
+       else
+               echo rs6000-ibm-aix3.2
+       fi
+       exit ;;
+    *:AIX:*:[45])
+       IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+       if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+               IBM_ARCH=rs6000
+       else
+               IBM_ARCH=powerpc
+       fi
+       if [ -x /usr/bin/oslevel ] ; then
+               IBM_REV=`/usr/bin/oslevel`
+       else
+               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+       fi
+       echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+       exit ;;
+    *:AIX:*:*)
+       echo rs6000-ibm-aix
+       exit ;;
+    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+       echo romp-ibm-bsd4.4
+       exit ;;
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
+       echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
+       exit ;;                             # report: romp-ibm BSD 4.3
+    *:BOSX:*:*)
+       echo rs6000-bull-bosx
+       exit ;;
+    DPX/2?00:B.O.S.:*:*)
+       echo m68k-bull-sysv3
+       exit ;;
+    9000/[34]??:4.3bsd:1.*:*)
+       echo m68k-hp-bsd
+       exit ;;
+    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+       echo m68k-hp-bsd4.4
+       exit ;;
+    9000/[34678]??:HP-UX:*:*)
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+       case "${UNAME_MACHINE}" in
+           9000/31? )            HP_ARCH=m68000 ;;
+           9000/[34]?? )         HP_ARCH=m68k ;;
+           9000/[678][0-9][0-9])
+               if [ -x /usr/bin/getconf ]; then
+                   sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+                    case "${sc_cpu_version}" in
+                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+                      532)                      # CPU_PA_RISC2_0
+                        case "${sc_kernel_bits}" in
+                          32) HP_ARCH="hppa2.0n" ;;
+                          64) HP_ARCH="hppa2.0w" ;;
+                         '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
+                        esac ;;
+                    esac
+               fi
+               if [ "${HP_ARCH}" = "" ]; then
+                   eval $set_cc_for_build
+                   sed 's/^              //' << EOF >$dummy.c
+
+              #define _HPUX_SOURCE
+              #include <stdlib.h>
+              #include <unistd.h>
+
+              int main ()
+              {
+              #if defined(_SC_KERNEL_BITS)
+                  long bits = sysconf(_SC_KERNEL_BITS);
+              #endif
+                  long cpu  = sysconf (_SC_CPU_VERSION);
+
+                  switch (cpu)
+               {
+               case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+               case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+               case CPU_PA_RISC2_0:
+              #if defined(_SC_KERNEL_BITS)
+                   switch (bits)
+                       {
+                       case 64: puts ("hppa2.0w"); break;
+                       case 32: puts ("hppa2.0n"); break;
+                       default: puts ("hppa2.0"); break;
+                       } break;
+              #else  /* !defined(_SC_KERNEL_BITS) */
+                   puts ("hppa2.0"); break;
+              #endif
+               default: puts ("hppa1.0"); break;
+               }
+                  exit (0);
+              }
+EOF
+                   (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+                   test -z "$HP_ARCH" && HP_ARCH=hppa
+               fi ;;
+       esac
+       if [ ${HP_ARCH} = "hppa2.0w" ]
+       then
+           eval $set_cc_for_build
+
+           # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+           # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
+           # generating 64-bit code.  GNU and HP use different nomenclature:
+           #
+           # $ CC_FOR_BUILD=cc ./config.guess
+           # => hppa2.0w-hp-hpux11.23
+           # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+           # => hppa64-hp-hpux11.23
+
+           if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+               grep __LP64__ >/dev/null
+           then
+               HP_ARCH="hppa2.0w"
+           else
+               HP_ARCH="hppa64"
+           fi
+       fi
+       echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+       exit ;;
+    ia64:HP-UX:*:*)
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+       echo ia64-hp-hpux${HPUX_REV}
+       exit ;;
+    3050*:HI-UX:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #include <unistd.h>
+       int
+       main ()
+       {
+         long cpu = sysconf (_SC_CPU_VERSION);
+         /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+            true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
+            results, however.  */
+         if (CPU_IS_PA_RISC (cpu))
+           {
+             switch (cpu)
+               {
+                 case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+                 default: puts ("hppa-hitachi-hiuxwe2"); break;
+               }
+           }
+         else if (CPU_IS_HP_MC68K (cpu))
+           puts ("m68k-hitachi-hiuxwe2");
+         else puts ("unknown-hitachi-hiuxwe2");
+         exit (0);
+       }
+EOF
+       $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+               { echo "$SYSTEM_NAME"; exit; }
+       echo unknown-hitachi-hiuxwe2
+       exit ;;
+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+       echo hppa1.1-hp-bsd
+       exit ;;
+    9000/8??:4.3bsd:*:*)
+       echo hppa1.0-hp-bsd
+       exit ;;
+    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+       echo hppa1.0-hp-mpeix
+       exit ;;
+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+       echo hppa1.1-hp-osf
+       exit ;;
+    hp8??:OSF1:*:*)
+       echo hppa1.0-hp-osf
+       exit ;;
+    i*86:OSF1:*:*)
+       if [ -x /usr/sbin/sysversion ] ; then
+           echo ${UNAME_MACHINE}-unknown-osf1mk
+       else
+           echo ${UNAME_MACHINE}-unknown-osf1
+       fi
+       exit ;;
+    parisc*:Lites*:*:*)
+       echo hppa1.1-hp-lites
+       exit ;;
+    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+       echo c1-convex-bsd
+        exit ;;
+    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+        exit ;;
+    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+       echo c34-convex-bsd
+        exit ;;
+    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+       echo c38-convex-bsd
+        exit ;;
+    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+       echo c4-convex-bsd
+        exit ;;
+    CRAY*Y-MP:*:*:*)
+       echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*[A-Z]90:*:*:*)
+       echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+       | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+             -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+             -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*TS:*:*:*)
+       echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*T3E:*:*:*)
+       echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*SV1:*:*:*)
+       echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    *:UNICOS/mp:*:*)
+       echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+       FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+        exit ;;
+    5000:UNIX_System_V:4.*:*)
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+       exit ;;
+    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+       echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+       exit ;;
+    sparc*:BSD/OS:*:*)
+       echo sparc-unknown-bsdi${UNAME_RELEASE}
+       exit ;;
+    *:BSD/OS:*:*)
+       echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+       exit ;;
+    *:FreeBSD:*:*)
+       case ${UNAME_MACHINE} in
+           pc98)
+               echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+           amd64)
+               echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+           *)
+               echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+       esac
+       exit ;;
+    i*:CYGWIN*:*)
+       echo ${UNAME_MACHINE}-pc-cygwin
+       exit ;;
+    *:MINGW*:*)
+       echo ${UNAME_MACHINE}-pc-mingw32
+       exit ;;
+    i*:windows32*:*)
+       # uname -m includes "-pc" on this system.
+       echo ${UNAME_MACHINE}-mingw32
+       exit ;;
+    i*:PW*:*)
+       echo ${UNAME_MACHINE}-pc-pw32
+       exit ;;
+    *:Interix*:[3456]*)
+       case ${UNAME_MACHINE} in
+           x86)
+               echo i586-pc-interix${UNAME_RELEASE}
+               exit ;;
+           EM64T | authenticamd)
+               echo x86_64-unknown-interix${UNAME_RELEASE}
+               exit ;;
+       esac ;;
+    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+       echo i${UNAME_MACHINE}-pc-mks
+       exit ;;
+    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+       # How do we know it's Interix rather than the generic POSIX subsystem?
+       # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+       # UNAME_MACHINE based on the output of uname instead of i386?
+       echo i586-pc-interix
+       exit ;;
+    i*:UWIN*:*)
+       echo ${UNAME_MACHINE}-pc-uwin
+       exit ;;
+    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+       echo x86_64-unknown-cygwin
+       exit ;;
+    p*:CYGWIN*:*)
+       echo powerpcle-unknown-cygwin
+       exit ;;
+    prep*:SunOS:5.*:*)
+       echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    *:GNU:*:*)
+       # the GNU system
+       echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+       exit ;;
+    *:GNU/*:*:*)
+       # other systems with GNU libc and userland
+       echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+       exit ;;
+    i*86:Minix:*:*)
+       echo ${UNAME_MACHINE}-pc-minix
+       exit ;;
+    arm*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    avr32*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    cris:Linux:*:*)
+       echo cris-axis-linux-gnu
+       exit ;;
+    crisv32:Linux:*:*)
+       echo crisv32-axis-linux-gnu
+       exit ;;
+    frv:Linux:*:*)
+       echo frv-unknown-linux-gnu
+       exit ;;
+    ia64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    m32r*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    m68*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    mips:Linux:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #undef CPU
+       #undef mips
+       #undef mipsel
+       #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+       CPU=mipsel
+       #else
+       #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+       CPU=mips
+       #else
+       CPU=
+       #endif
+       #endif
+EOF
+       eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+           /^CPU/{
+               s: ::g
+               p
+           }'`"
+       test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+       ;;
+    mips64:Linux:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #undef CPU
+       #undef mips64
+       #undef mips64el
+       #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+       CPU=mips64el
+       #else
+       #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+       CPU=mips64
+       #else
+       CPU=
+       #endif
+       #endif
+EOF
+       eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+           /^CPU/{
+               s: ::g
+               p
+           }'`"
+       test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+       ;;
+    or32:Linux:*:*)
+       echo or32-unknown-linux-gnu
+       exit ;;
+    ppc:Linux:*:*)
+       echo powerpc-unknown-linux-gnu
+       exit ;;
+    ppc64:Linux:*:*)
+       echo powerpc64-unknown-linux-gnu
+       exit ;;
+    alpha:Linux:*:*)
+       case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+         EV5)   UNAME_MACHINE=alphaev5 ;;
+         EV56)  UNAME_MACHINE=alphaev56 ;;
+         PCA56) UNAME_MACHINE=alphapca56 ;;
+         PCA57) UNAME_MACHINE=alphapca56 ;;
+         EV6)   UNAME_MACHINE=alphaev6 ;;
+         EV67)  UNAME_MACHINE=alphaev67 ;;
+         EV68*) UNAME_MACHINE=alphaev68 ;;
+        esac
+       objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+       if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+       echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+       exit ;;
+    parisc:Linux:*:* | hppa:Linux:*:*)
+       # Look for CPU level
+       case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+         PA7*) echo hppa1.1-unknown-linux-gnu ;;
+         PA8*) echo hppa2.0-unknown-linux-gnu ;;
+         *)    echo hppa-unknown-linux-gnu ;;
+       esac
+       exit ;;
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+       echo hppa64-unknown-linux-gnu
+       exit ;;
+    s390:Linux:*:* | s390x:Linux:*:*)
+       echo ${UNAME_MACHINE}-ibm-linux
+       exit ;;
+    sh64*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    sh*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    sparc:Linux:*:* | sparc64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    vax:Linux:*:*)
+       echo ${UNAME_MACHINE}-dec-linux-gnu
+       exit ;;
+    x86_64:Linux:*:*)
+       echo x86_64-unknown-linux-gnu
+       exit ;;
+    xtensa:Linux:*:*)
+       echo xtensa-unknown-linux-gnu
+       exit ;;
+    i*86:Linux:*:*)
+       # The BFD linker knows what the default object file format is, so
+       # first see if it will tell us. cd to the root directory to prevent
+       # problems with other programs or directories called `ld' in the path.
+       # Set LC_ALL=C to ensure ld outputs messages in English.
+       ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
+                        | sed -ne '/supported targets:/!d
+                                   s/[         ][      ]*/ /g
+                                   s/.*supported targets: *//
+                                   s/ .*//
+                                   p'`
+        case "$ld_supported_targets" in
+         elf32-i386)
+               TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+               ;;
+         a.out-i386-linux)
+               echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+               exit ;;
+         coff-i386)
+               echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+               exit ;;
+         "")
+               # Either a pre-BFD a.out linker (linux-gnuoldld) or
+               # one that does not give us useful --help.
+               echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+               exit ;;
+       esac
+       # Determine whether the default compiler is a.out or elf
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #include <features.h>
+       #ifdef __ELF__
+       # ifdef __GLIBC__
+       #  if __GLIBC__ >= 2
+       LIBC=gnu
+       #  else
+       LIBC=gnulibc1
+       #  endif
+       # else
+       LIBC=gnulibc1
+       # endif
+       #else
+       #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+       LIBC=gnu
+       #else
+       LIBC=gnuaout
+       #endif
+       #endif
+       #ifdef __dietlibc__
+       LIBC=dietlibc
+       #endif
+EOF
+       eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+           /^LIBC/{
+               s: ::g
+               p
+           }'`"
+       test x"${LIBC}" != x && {
+               echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+               exit
+       }
+       test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
+       ;;
+    i*86:DYNIX/ptx:4*:*)
+       # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+       # earlier versions are messed up and put the nodename in both
+       # sysname and nodename.
+       echo i386-sequent-sysv4
+       exit ;;
+    i*86:UNIX_SV:4.2MP:2.*)
+        # Unixware is an offshoot of SVR4, but it has its own version
+        # number series starting with 2...
+        # I am not positive that other SVR4 systems won't match this,
+       # I just have to hope.  -- rms.
+        # Use sysv4.2uw... so that sysv4* matches it.
+       echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+       exit ;;
+    i*86:OS/2:*:*)
+       # If we were able to find `uname', then EMX Unix compatibility
+       # is probably installed.
+       echo ${UNAME_MACHINE}-pc-os2-emx
+       exit ;;
+    i*86:XTS-300:*:STOP)
+       echo ${UNAME_MACHINE}-unknown-stop
+       exit ;;
+    i*86:atheos:*:*)
+       echo ${UNAME_MACHINE}-unknown-atheos
+       exit ;;
+    i*86:syllable:*:*)
+       echo ${UNAME_MACHINE}-pc-syllable
+       exit ;;
+    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+       echo i386-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    i*86:*DOS:*:*)
+       echo ${UNAME_MACHINE}-pc-msdosdjgpp
+       exit ;;
+    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+       UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+       if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+               echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+       else
+               echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+       fi
+       exit ;;
+    i*86:*:5:[678]*)
+       # UnixWare 7.x, OpenUNIX and OpenServer 6.
+       case `/bin/uname -X | grep "^Machine"` in
+           *486*)           UNAME_MACHINE=i486 ;;
+           *Pentium)        UNAME_MACHINE=i586 ;;
+           *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+       esac
+       echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+       exit ;;
+    i*86:*:3.2:*)
+       if test -f /usr/options/cb.name; then
+               UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+               echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+       elif /bin/uname -X 2>/dev/null >/dev/null ; then
+               UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+               (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+               (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+                       && UNAME_MACHINE=i586
+               (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+                       && UNAME_MACHINE=i686
+               (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+                       && UNAME_MACHINE=i686
+               echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+       else
+               echo ${UNAME_MACHINE}-pc-sysv32
+       fi
+       exit ;;
+    pc:*:*:*)
+       # Left here for compatibility:
+        # uname -m prints for DJGPP always 'pc', but it prints nothing about
+        # the processor, so we play safe by assuming i386.
+       echo i386-pc-msdosdjgpp
+        exit ;;
+    Intel:Mach:3*:*)
+       echo i386-pc-mach3
+       exit ;;
+    paragon:*:*:*)
+       echo i860-intel-osf1
+       exit ;;
+    i860:*:4.*:*) # i860-SVR4
+       if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+         echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+       else # Add other i860-SVR4 vendors below as they are discovered.
+         echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
+       fi
+       exit ;;
+    mini*:CTIX:SYS*5:*)
+       # "miniframe"
+       echo m68010-convergent-sysv
+       exit ;;
+    mc68k:UNIX:SYSTEM5:3.51m)
+       echo m68k-convergent-sysv
+       exit ;;
+    M680?0:D-NIX:5.3:*)
+       echo m68k-diab-dnix
+       exit ;;
+    M68*:*:R3V[5678]*:*)
+       test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+       OS_REL=''
+       test -r /etc/.relid \
+       && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+       /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+         && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+       /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+         && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+          && { echo i486-ncr-sysv4; exit; } ;;
+    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+       echo m68k-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    mc68030:UNIX_System_V:4.*:*)
+       echo m68k-atari-sysv4
+       exit ;;
+    TSUNAMI:LynxOS:2.*:*)
+       echo sparc-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    rs6000:LynxOS:2.*:*)
+       echo rs6000-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+       echo powerpc-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    SM[BE]S:UNIX_SV:*:*)
+       echo mips-dde-sysv${UNAME_RELEASE}
+       exit ;;
+    RM*:ReliantUNIX-*:*:*)
+       echo mips-sni-sysv4
+       exit ;;
+    RM*:SINIX-*:*:*)
+       echo mips-sni-sysv4
+       exit ;;
+    *:SINIX-*:*:*)
+       if uname -p 2>/dev/null >/dev/null ; then
+               UNAME_MACHINE=`(uname -p) 2>/dev/null`
+               echo ${UNAME_MACHINE}-sni-sysv4
+       else
+               echo ns32k-sni-sysv
+       fi
+       exit ;;
+    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                      # says <Richard.M.Bartel@ccMail.Census.GOV>
+        echo i586-unisys-sysv4
+        exit ;;
+    *:UNIX_System_V:4*:FTX*)
+       # From Gerald Hewes <hewes@openmarket.com>.
+       # How about differentiating between stratus architectures? -djm
+       echo hppa1.1-stratus-sysv4
+       exit ;;
+    *:*:*:FTX*)
+       # From seanf@swdc.stratus.com.
+       echo i860-stratus-sysv4
+       exit ;;
+    i*86:VOS:*:*)
+       # From Paul.Green@stratus.com.
+       echo ${UNAME_MACHINE}-stratus-vos
+       exit ;;
+    *:VOS:*:*)
+       # From Paul.Green@stratus.com.
+       echo hppa1.1-stratus-vos
+       exit ;;
+    mc68*:A/UX:*:*)
+       echo m68k-apple-aux${UNAME_RELEASE}
+       exit ;;
+    news*:NEWS-OS:6*:*)
+       echo mips-sony-newsos6
+       exit ;;
+    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+       if [ -d /usr/nec ]; then
+               echo mips-nec-sysv${UNAME_RELEASE}
+       else
+               echo mips-unknown-sysv${UNAME_RELEASE}
+       fi
+        exit ;;
+    BeBox:BeOS:*:*)    # BeOS running on hardware made by Be, PPC only.
+       echo powerpc-be-beos
+       exit ;;
+    BeMac:BeOS:*:*)    # BeOS running on Mac or Mac clone, PPC only.
+       echo powerpc-apple-beos
+       exit ;;
+    BePC:BeOS:*:*)     # BeOS running on Intel PC compatible.
+       echo i586-pc-beos
+       exit ;;
+    SX-4:SUPER-UX:*:*)
+       echo sx4-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-5:SUPER-UX:*:*)
+       echo sx5-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-6:SUPER-UX:*:*)
+       echo sx6-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-7:SUPER-UX:*:*)
+       echo sx7-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-8:SUPER-UX:*:*)
+       echo sx8-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-8R:SUPER-UX:*:*)
+       echo sx8r-nec-superux${UNAME_RELEASE}
+       exit ;;
+    Power*:Rhapsody:*:*)
+       echo powerpc-apple-rhapsody${UNAME_RELEASE}
+       exit ;;
+    *:Rhapsody:*:*)
+       echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+       exit ;;
+    *:Darwin:*:*)
+       UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+       case $UNAME_PROCESSOR in
+           unknown) UNAME_PROCESSOR=powerpc ;;
+       esac
+       echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+       exit ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+       UNAME_PROCESSOR=`uname -p`
+       if test "$UNAME_PROCESSOR" = "x86"; then
+               UNAME_PROCESSOR=i386
+               UNAME_MACHINE=pc
+       fi
+       echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+       exit ;;
+    *:QNX:*:4*)
+       echo i386-pc-qnx
+       exit ;;
+    NSE-?:NONSTOP_KERNEL:*:*)
+       echo nse-tandem-nsk${UNAME_RELEASE}
+       exit ;;
+    NSR-?:NONSTOP_KERNEL:*:*)
+       echo nsr-tandem-nsk${UNAME_RELEASE}
+       exit ;;
+    *:NonStop-UX:*:*)
+       echo mips-compaq-nonstopux
+       exit ;;
+    BS2000:POSIX*:*:*)
+       echo bs2000-siemens-sysv
+       exit ;;
+    DS/*:UNIX_System_V:*:*)
+       echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+       exit ;;
+    *:Plan9:*:*)
+       # "uname -m" is not consistent, so use $cputype instead. 386
+       # is converted to i386 for consistency with other x86
+       # operating systems.
+       if test "$cputype" = "386"; then
+           UNAME_MACHINE=i386
+       else
+           UNAME_MACHINE="$cputype"
+       fi
+       echo ${UNAME_MACHINE}-unknown-plan9
+       exit ;;
+    *:TOPS-10:*:*)
+       echo pdp10-unknown-tops10
+       exit ;;
+    *:TENEX:*:*)
+       echo pdp10-unknown-tenex
+       exit ;;
+    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+       echo pdp10-dec-tops20
+       exit ;;
+    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+       echo pdp10-xkl-tops20
+       exit ;;
+    *:TOPS-20:*:*)
+       echo pdp10-unknown-tops20
+       exit ;;
+    *:ITS:*:*)
+       echo pdp10-unknown-its
+       exit ;;
+    SEI:*:*:SEIUX)
+        echo mips-sei-seiux${UNAME_RELEASE}
+       exit ;;
+    *:DragonFly:*:*)
+       echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+       exit ;;
+    *:*VMS:*:*)
+       UNAME_MACHINE=`(uname -p) 2>/dev/null`
+       case "${UNAME_MACHINE}" in
+           A*) echo alpha-dec-vms ; exit ;;
+           I*) echo ia64-dec-vms ; exit ;;
+           V*) echo vax-dec-vms ; exit ;;
+       esac ;;
+    *:XENIX:*:SysV)
+       echo i386-pc-xenix
+       exit ;;
+    i*86:skyos:*:*)
+       echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+       exit ;;
+    i*86:rdos:*:*)
+       echo ${UNAME_MACHINE}-pc-rdos
+       exit ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+          "4"
+#else
+         ""
+#endif
+         ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+  printf ("arm-acorn-riscix\n"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+  printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+    struct utsname un;
+
+    uname(&un);
+
+    if (strncmp(un.version, "V2", 2) == 0) {
+       printf ("i386-sequent-ptx2\n"); exit (0);
+    }
+    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+       printf ("i386-sequent-ptx1\n"); exit (0);
+    }
+    printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+#  include <sys/param.h>
+#  if defined (BSD)
+#   if BSD == 43
+      printf ("vax-dec-bsd4.3\n"); exit (0);
+#   else
+#    if BSD == 199006
+      printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#    else
+      printf ("vax-dec-bsd\n"); exit (0);
+#    endif
+#   endif
+#  else
+    printf ("vax-dec-bsd\n"); exit (0);
+#  endif
+# else
+    printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+       { echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+    case `getsysinfo -f cpu_type` in
+    c1*)
+       echo c1-convex-bsd
+       exit ;;
+    c2*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+       exit ;;
+    c34*)
+       echo c34-convex-bsd
+       exit ;;
+    c38*)
+       echo c38-convex-bsd
+       exit ;;
+    c4*)
+       echo c4-convex-bsd
+       exit ;;
+    esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
+and
+  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo               = `(hostinfo) 2>/dev/null`
+/bin/universe          = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch              = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM  = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/bin/config.sub b/bin/config.sub
new file mode 100755 (executable)
index 0000000..1761d8b
--- /dev/null
@@ -0,0 +1,1626 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
+#   Inc.
+
+timestamp='2007-06-28'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine.  It does not imply ALL GNU software can.
+#
+# This file 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 of the License, 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., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Please send patches to <config-patches@gnu.org>.  Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support.  The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+#      CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+#      CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+       $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )        # Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help"
+       exit 1 ;;
+
+    *local*)
+       # First pass through any local machine types.
+       echo $1
+       exit ;;
+
+    * )
+       break ;;
+  esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+    exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+    exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+  nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
+  uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+  storm-chaos* | os2-emx* | rtmk-nova*)
+    os=-$maybe_os
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+    ;;
+  *)
+    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+    if [ $basic_machine != $1 ]
+    then os=`echo $1 | sed 's/.*-/-/'`
+    else os=; fi
+    ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work.  We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+       -sun*os*)
+               # Prevent following clause from handling this invalid input.
+               ;;
+       -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+       -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+       -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+       -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+       -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+       -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+       -apple | -axis | -knuth | -cray)
+               os=
+               basic_machine=$1
+               ;;
+       -sim | -cisco | -oki | -wec | -winbond)
+               os=
+               basic_machine=$1
+               ;;
+       -scout)
+               ;;
+       -wrs)
+               os=-vxworks
+               basic_machine=$1
+               ;;
+       -chorusos*)
+               os=-chorusos
+               basic_machine=$1
+               ;;
+       -chorusrdb)
+               os=-chorusrdb
+               basic_machine=$1
+               ;;
+       -hiux*)
+               os=-hiuxwe2
+               ;;
+       -sco6)
+               os=-sco5v6
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco5)
+               os=-sco3.2v5
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco4)
+               os=-sco3.2v4
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco3.2.[4-9]*)
+               os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco3.2v[4-9]*)
+               # Don't forget version if it is 3.2v4 or newer.
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco5v6*)
+               # Don't forget version if it is 3.2v4 or newer.
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco*)
+               os=-sco3.2v2
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -udk*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -isc)
+               os=-isc2.2
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -clix*)
+               basic_machine=clipper-intergraph
+               ;;
+       -isc*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -lynx*)
+               os=-lynxos
+               ;;
+       -ptx*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+               ;;
+       -windowsnt*)
+               os=`echo $os | sed -e 's/windowsnt/winnt/'`
+               ;;
+       -psos*)
+               os=-psos
+               ;;
+       -mint | -mint[0-9]*)
+               basic_machine=m68k-atari
+               os=-mint
+               ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+       # Recognize the basic CPU types without company name.
+       # Some are omitted here because they have special meanings below.
+       1750a | 580 \
+       | a29k \
+       | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+       | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+       | am33_2.0 \
+       | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+       | bfin \
+       | c4x | clipper \
+       | d10v | d30v | dlx | dsp16xx \
+       | fido | fr30 | frv \
+       | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+       | i370 | i860 | i960 | ia64 \
+       | ip2k | iq2000 \
+       | m32c | m32r | m32rle | m68000 | m68k | m88k \
+       | maxq | mb | microblaze | mcore | mep \
+       | mips | mipsbe | mipseb | mipsel | mipsle \
+       | mips16 \
+       | mips64 | mips64el \
+       | mips64vr | mips64vrel \
+       | mips64orion | mips64orionel \
+       | mips64vr4100 | mips64vr4100el \
+       | mips64vr4300 | mips64vr4300el \
+       | mips64vr5000 | mips64vr5000el \
+       | mips64vr5900 | mips64vr5900el \
+       | mipsisa32 | mipsisa32el \
+       | mipsisa32r2 | mipsisa32r2el \
+       | mipsisa64 | mipsisa64el \
+       | mipsisa64r2 | mipsisa64r2el \
+       | mipsisa64sb1 | mipsisa64sb1el \
+       | mipsisa64sr71k | mipsisa64sr71kel \
+       | mipstx39 | mipstx39el \
+       | mn10200 | mn10300 \
+       | mt \
+       | msp430 \
+       | nios | nios2 \
+       | ns16k | ns32k \
+       | or32 \
+       | pdp10 | pdp11 | pj | pjl \
+       | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+       | pyramid \
+       | score \
+       | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+       | sh64 | sh64le \
+       | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+       | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+       | spu | strongarm \
+       | tahoe | thumb | tic4x | tic80 | tron \
+       | v850 | v850e \
+       | we32k \
+       | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+       | z8k)
+               basic_machine=$basic_machine-unknown
+               ;;
+       m6811 | m68hc11 | m6812 | m68hc12)
+               # Motorola 68HC11/12.
+               basic_machine=$basic_machine-unknown
+               os=-none
+               ;;
+       m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+               ;;
+       ms1)
+               basic_machine=mt-unknown
+               ;;
+
+       # We use `pc' rather than `unknown'
+       # because (1) that's what they normally are, and
+       # (2) the word "unknown" tends to confuse beginning users.
+       i*86 | x86_64)
+         basic_machine=$basic_machine-pc
+         ;;
+       # Object if more than one company name word.
+       *-*-*)
+               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               exit 1
+               ;;
+       # Recognize the basic CPU types with company name.
+       580-* \
+       | a29k-* \
+       | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+       | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+       | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+       | arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
+       | avr-* | avr32-* \
+       | bfin-* | bs2000-* \
+       | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+       | clipper-* | craynv-* | cydra-* \
+       | d10v-* | d30v-* | dlx-* \
+       | elxsi-* \
+       | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
+       | h8300-* | h8500-* \
+       | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+       | i*86-* | i860-* | i960-* | ia64-* \
+       | ip2k-* | iq2000-* \
+       | m32c-* | m32r-* | m32rle-* \
+       | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+       | m88110-* | m88k-* | maxq-* | mcore-* \
+       | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+       | mips16-* \
+       | mips64-* | mips64el-* \
+       | mips64vr-* | mips64vrel-* \
+       | mips64orion-* | mips64orionel-* \
+       | mips64vr4100-* | mips64vr4100el-* \
+       | mips64vr4300-* | mips64vr4300el-* \
+       | mips64vr5000-* | mips64vr5000el-* \
+       | mips64vr5900-* | mips64vr5900el-* \
+       | mipsisa32-* | mipsisa32el-* \
+       | mipsisa32r2-* | mipsisa32r2el-* \
+       | mipsisa64-* | mipsisa64el-* \
+       | mipsisa64r2-* | mipsisa64r2el-* \
+       | mipsisa64sb1-* | mipsisa64sb1el-* \
+       | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+       | mipstx39-* | mipstx39el-* \
+       | mmix-* \
+       | mt-* \
+       | msp430-* \
+       | nios-* | nios2-* \
+       | none-* | np1-* | ns16k-* | ns32k-* \
+       | orion-* \
+       | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+       | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+       | pyramid-* \
+       | romp-* | rs6000-* \
+       | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+       | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+       | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+       | sparclite-* \
+       | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
+       | tahoe-* | thumb-* \
+       | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+       | tron-* \
+       | v850-* | v850e-* | vax-* \
+       | we32k-* \
+       | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+       | xstormy16-* | xtensa-* \
+       | ymp-* \
+       | z8k-*)
+               ;;
+       # Recognize the various machine names and aliases which stand
+       # for a CPU type and a company and sometimes even an OS.
+       386bsd)
+               basic_machine=i386-unknown
+               os=-bsd
+               ;;
+       3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+               basic_machine=m68000-att
+               ;;
+       3b*)
+               basic_machine=we32k-att
+               ;;
+       a29khif)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       abacus)
+               basic_machine=abacus-unknown
+               ;;
+       adobe68k)
+               basic_machine=m68010-adobe
+               os=-scout
+               ;;
+       alliant | fx80)
+               basic_machine=fx80-alliant
+               ;;
+       altos | altos3068)
+               basic_machine=m68k-altos
+               ;;
+       am29k)
+               basic_machine=a29k-none
+               os=-bsd
+               ;;
+       amd64)
+               basic_machine=x86_64-pc
+               ;;
+       amd64-*)
+               basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       amdahl)
+               basic_machine=580-amdahl
+               os=-sysv
+               ;;
+       amiga | amiga-*)
+               basic_machine=m68k-unknown
+               ;;
+       amigaos | amigados)
+               basic_machine=m68k-unknown
+               os=-amigaos
+               ;;
+       amigaunix | amix)
+               basic_machine=m68k-unknown
+               os=-sysv4
+               ;;
+       apollo68)
+               basic_machine=m68k-apollo
+               os=-sysv
+               ;;
+       apollo68bsd)
+               basic_machine=m68k-apollo
+               os=-bsd
+               ;;
+       aux)
+               basic_machine=m68k-apple
+               os=-aux
+               ;;
+       balance)
+               basic_machine=ns32k-sequent
+               os=-dynix
+               ;;
+       c90)
+               basic_machine=c90-cray
+               os=-unicos
+               ;;
+       convex-c1)
+               basic_machine=c1-convex
+               os=-bsd
+               ;;
+       convex-c2)
+               basic_machine=c2-convex
+               os=-bsd
+               ;;
+       convex-c32)
+               basic_machine=c32-convex
+               os=-bsd
+               ;;
+       convex-c34)
+               basic_machine=c34-convex
+               os=-bsd
+               ;;
+       convex-c38)
+               basic_machine=c38-convex
+               os=-bsd
+               ;;
+       cray | j90)
+               basic_machine=j90-cray
+               os=-unicos
+               ;;
+       craynv)
+               basic_machine=craynv-cray
+               os=-unicosmp
+               ;;
+       cr16)
+               basic_machine=cr16-unknown
+               os=-elf
+               ;;
+       crds | unos)
+               basic_machine=m68k-crds
+               ;;
+       crisv32 | crisv32-* | etraxfs*)
+               basic_machine=crisv32-axis
+               ;;
+       cris | cris-* | etrax*)
+               basic_machine=cris-axis
+               ;;
+       crx)
+               basic_machine=crx-unknown
+               os=-elf
+               ;;
+       da30 | da30-*)
+               basic_machine=m68k-da30
+               ;;
+       decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+               basic_machine=mips-dec
+               ;;
+       decsystem10* | dec10*)
+               basic_machine=pdp10-dec
+               os=-tops10
+               ;;
+       decsystem20* | dec20*)
+               basic_machine=pdp10-dec
+               os=-tops20
+               ;;
+       delta | 3300 | motorola-3300 | motorola-delta \
+             | 3300-motorola | delta-motorola)
+               basic_machine=m68k-motorola
+               ;;
+       delta88)
+               basic_machine=m88k-motorola
+               os=-sysv3
+               ;;
+       djgpp)
+               basic_machine=i586-pc
+               os=-msdosdjgpp
+               ;;
+       dpx20 | dpx20-*)
+               basic_machine=rs6000-bull
+               os=-bosx
+               ;;
+       dpx2* | dpx2*-bull)
+               basic_machine=m68k-bull
+               os=-sysv3
+               ;;
+       ebmon29k)
+               basic_machine=a29k-amd
+               os=-ebmon
+               ;;
+       elxsi)
+               basic_machine=elxsi-elxsi
+               os=-bsd
+               ;;
+       encore | umax | mmax)
+               basic_machine=ns32k-encore
+               ;;
+       es1800 | OSE68k | ose68k | ose | OSE)
+               basic_machine=m68k-ericsson
+               os=-ose
+               ;;
+       fx2800)
+               basic_machine=i860-alliant
+               ;;
+       genix)
+               basic_machine=ns32k-ns
+               ;;
+       gmicro)
+               basic_machine=tron-gmicro
+               os=-sysv
+               ;;
+       go32)
+               basic_machine=i386-pc
+               os=-go32
+               ;;
+       h3050r* | hiux*)
+               basic_machine=hppa1.1-hitachi
+               os=-hiuxwe2
+               ;;
+       h8300hms)
+               basic_machine=h8300-hitachi
+               os=-hms
+               ;;
+       h8300xray)
+               basic_machine=h8300-hitachi
+               os=-xray
+               ;;
+       h8500hms)
+               basic_machine=h8500-hitachi
+               os=-hms
+               ;;
+       harris)
+               basic_machine=m88k-harris
+               os=-sysv3
+               ;;
+       hp300-*)
+               basic_machine=m68k-hp
+               ;;
+       hp300bsd)
+               basic_machine=m68k-hp
+               os=-bsd
+               ;;
+       hp300hpux)
+               basic_machine=m68k-hp
+               os=-hpux
+               ;;
+       hp3k9[0-9][0-9] | hp9[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hp9k2[0-9][0-9] | hp9k31[0-9])
+               basic_machine=m68000-hp
+               ;;
+       hp9k3[2-9][0-9])
+               basic_machine=m68k-hp
+               ;;
+       hp9k6[0-9][0-9] | hp6[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hp9k7[0-79][0-9] | hp7[0-79][0-9])
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k78[0-9] | hp78[0-9])
+               # FIXME: really hppa2.0-hp
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+               # FIXME: really hppa2.0-hp
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[0-9][13679] | hp8[0-9][13679])
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[0-9][0-9] | hp8[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hppa-next)
+               os=-nextstep3
+               ;;
+       hppaosf)
+               basic_machine=hppa1.1-hp
+               os=-osf
+               ;;
+       hppro)
+               basic_machine=hppa1.1-hp
+               os=-proelf
+               ;;
+       i370-ibm* | ibm*)
+               basic_machine=i370-ibm
+               ;;
+# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
+       i*86v32)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv32
+               ;;
+       i*86v4*)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv4
+               ;;
+       i*86v)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv
+               ;;
+       i*86sol2)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-solaris2
+               ;;
+       i386mach)
+               basic_machine=i386-mach
+               os=-mach
+               ;;
+       i386-vsta | vsta)
+               basic_machine=i386-unknown
+               os=-vsta
+               ;;
+       iris | iris4d)
+               basic_machine=mips-sgi
+               case $os in
+                   -irix*)
+                       ;;
+                   *)
+                       os=-irix4
+                       ;;
+               esac
+               ;;
+       isi68 | isi)
+               basic_machine=m68k-isi
+               os=-sysv
+               ;;
+       m88k-omron*)
+               basic_machine=m88k-omron
+               ;;
+       magnum | m3230)
+               basic_machine=mips-mips
+               os=-sysv
+               ;;
+       merlin)
+               basic_machine=ns32k-utek
+               os=-sysv
+               ;;
+       mingw32)
+               basic_machine=i386-pc
+               os=-mingw32
+               ;;
+       mingw32ce)
+               basic_machine=arm-unknown
+               os=-mingw32ce
+               ;;
+       miniframe)
+               basic_machine=m68000-convergent
+               ;;
+       *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+               basic_machine=m68k-atari
+               os=-mint
+               ;;
+       mips3*-*)
+               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+               ;;
+       mips3*)
+               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+               ;;
+       monitor)
+               basic_machine=m68k-rom68k
+               os=-coff
+               ;;
+       morphos)
+               basic_machine=powerpc-unknown
+               os=-morphos
+               ;;
+       msdos)
+               basic_machine=i386-pc
+               os=-msdos
+               ;;
+       ms1-*)
+               basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+               ;;
+       mvs)
+               basic_machine=i370-ibm
+               os=-mvs
+               ;;
+       ncr3000)
+               basic_machine=i486-ncr
+               os=-sysv4
+               ;;
+       netbsd386)
+               basic_machine=i386-unknown
+               os=-netbsd
+               ;;
+       netwinder)
+               basic_machine=armv4l-rebel
+               os=-linux
+               ;;
+       news | news700 | news800 | news900)
+               basic_machine=m68k-sony
+               os=-newsos
+               ;;
+       news1000)
+               basic_machine=m68030-sony
+               os=-newsos
+               ;;
+       news-3600 | risc-news)
+               basic_machine=mips-sony
+               os=-newsos
+               ;;
+       necv70)
+               basic_machine=v70-nec
+               os=-sysv
+               ;;
+       next | m*-next )
+               basic_machine=m68k-next
+               case $os in
+                   -nextstep* )
+                       ;;
+                   -ns2*)
+                     os=-nextstep2
+                       ;;
+                   *)
+                     os=-nextstep3
+                       ;;
+               esac
+               ;;
+       nh3000)
+               basic_machine=m68k-harris
+               os=-cxux
+               ;;
+       nh[45]000)
+               basic_machine=m88k-harris
+               os=-cxux
+               ;;
+       nindy960)
+               basic_machine=i960-intel
+               os=-nindy
+               ;;
+       mon960)
+               basic_machine=i960-intel
+               os=-mon960
+               ;;
+       nonstopux)
+               basic_machine=mips-compaq
+               os=-nonstopux
+               ;;
+       np1)
+               basic_machine=np1-gould
+               ;;
+       nsr-tandem)
+               basic_machine=nsr-tandem
+               ;;
+       op50n-* | op60c-*)
+               basic_machine=hppa1.1-oki
+               os=-proelf
+               ;;
+       openrisc | openrisc-*)
+               basic_machine=or32-unknown
+               ;;
+       os400)
+               basic_machine=powerpc-ibm
+               os=-os400
+               ;;
+       OSE68000 | ose68000)
+               basic_machine=m68000-ericsson
+               os=-ose
+               ;;
+       os68k)
+               basic_machine=m68k-none
+               os=-os68k
+               ;;
+       pa-hitachi)
+               basic_machine=hppa1.1-hitachi
+               os=-hiuxwe2
+               ;;
+       paragon)
+               basic_machine=i860-intel
+               os=-osf
+               ;;
+       pbd)
+               basic_machine=sparc-tti
+               ;;
+       pbb)
+               basic_machine=m68k-tti
+               ;;
+       pc532 | pc532-*)
+               basic_machine=ns32k-pc532
+               ;;
+       pc98)
+               basic_machine=i386-pc
+               ;;
+       pc98-*)
+               basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentium | p5 | k5 | k6 | nexgen | viac3)
+               basic_machine=i586-pc
+               ;;
+       pentiumpro | p6 | 6x86 | athlon | athlon_*)
+               basic_machine=i686-pc
+               ;;
+       pentiumii | pentium2 | pentiumiii | pentium3)
+               basic_machine=i686-pc
+               ;;
+       pentium4)
+               basic_machine=i786-pc
+               ;;
+       pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+               basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentiumpro-* | p6-* | 6x86-* | athlon-*)
+               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentium4-*)
+               basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pn)
+               basic_machine=pn-gould
+               ;;
+       power)  basic_machine=power-ibm
+               ;;
+       ppc)    basic_machine=powerpc-unknown
+               ;;
+       ppc-*)  basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppcle | powerpclittle | ppc-le | powerpc-little)
+               basic_machine=powerpcle-unknown
+               ;;
+       ppcle-* | powerpclittle-*)
+               basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppc64)  basic_machine=powerpc64-unknown
+               ;;
+       ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+               basic_machine=powerpc64le-unknown
+               ;;
+       ppc64le-* | powerpc64little-*)
+               basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ps2)
+               basic_machine=i386-ibm
+               ;;
+       pw32)
+               basic_machine=i586-unknown
+               os=-pw32
+               ;;
+       rdos)
+               basic_machine=i386-pc
+               os=-rdos
+               ;;
+       rom68k)
+               basic_machine=m68k-rom68k
+               os=-coff
+               ;;
+       rm[46]00)
+               basic_machine=mips-siemens
+               ;;
+       rtpc | rtpc-*)
+               basic_machine=romp-ibm
+               ;;
+       s390 | s390-*)
+               basic_machine=s390-ibm
+               ;;
+       s390x | s390x-*)
+               basic_machine=s390x-ibm
+               ;;
+       sa29200)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       sb1)
+               basic_machine=mipsisa64sb1-unknown
+               ;;
+       sb1el)
+               basic_machine=mipsisa64sb1el-unknown
+               ;;
+       sde)
+               basic_machine=mipsisa32-sde
+               os=-elf
+               ;;
+       sei)
+               basic_machine=mips-sei
+               os=-seiux
+               ;;
+       sequent)
+               basic_machine=i386-sequent
+               ;;
+       sh)
+               basic_machine=sh-hitachi
+               os=-hms
+               ;;
+       sh5el)
+               basic_machine=sh5le-unknown
+               ;;
+       sh64)
+               basic_machine=sh64-unknown
+               ;;
+       sparclite-wrs | simso-wrs)
+               basic_machine=sparclite-wrs
+               os=-vxworks
+               ;;
+       sps7)
+               basic_machine=m68k-bull
+               os=-sysv2
+               ;;
+       spur)
+               basic_machine=spur-unknown
+               ;;
+       st2000)
+               basic_machine=m68k-tandem
+               ;;
+       stratus)
+               basic_machine=i860-stratus
+               os=-sysv4
+               ;;
+       sun2)
+               basic_machine=m68000-sun
+               ;;
+       sun2os3)
+               basic_machine=m68000-sun
+               os=-sunos3
+               ;;
+       sun2os4)
+               basic_machine=m68000-sun
+               os=-sunos4
+               ;;
+       sun3os3)
+               basic_machine=m68k-sun
+               os=-sunos3
+               ;;
+       sun3os4)
+               basic_machine=m68k-sun
+               os=-sunos4
+               ;;
+       sun4os3)
+               basic_machine=sparc-sun
+               os=-sunos3
+               ;;
+       sun4os4)
+               basic_machine=sparc-sun
+               os=-sunos4
+               ;;
+       sun4sol2)
+               basic_machine=sparc-sun
+               os=-solaris2
+               ;;
+       sun3 | sun3-*)
+               basic_machine=m68k-sun
+               ;;
+       sun4)
+               basic_machine=sparc-sun
+               ;;
+       sun386 | sun386i | roadrunner)
+               basic_machine=i386-sun
+               ;;
+       sv1)
+               basic_machine=sv1-cray
+               os=-unicos
+               ;;
+       symmetry)
+               basic_machine=i386-sequent
+               os=-dynix
+               ;;
+       t3e)
+               basic_machine=alphaev5-cray
+               os=-unicos
+               ;;
+       t90)
+               basic_machine=t90-cray
+               os=-unicos
+               ;;
+       tic54x | c54x*)
+               basic_machine=tic54x-unknown
+               os=-coff
+               ;;
+       tic55x | c55x*)
+               basic_machine=tic55x-unknown
+               os=-coff
+               ;;
+       tic6x | c6x*)
+               basic_machine=tic6x-unknown
+               os=-coff
+               ;;
+       tx39)
+               basic_machine=mipstx39-unknown
+               ;;
+       tx39el)
+               basic_machine=mipstx39el-unknown
+               ;;
+       toad1)
+               basic_machine=pdp10-xkl
+               os=-tops20
+               ;;
+       tower | tower-32)
+               basic_machine=m68k-ncr
+               ;;
+       tpf)
+               basic_machine=s390x-ibm
+               os=-tpf
+               ;;
+       udi29k)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       ultra3)
+               basic_machine=a29k-nyu
+               os=-sym1
+               ;;
+       v810 | necv810)
+               basic_machine=v810-nec
+               os=-none
+               ;;
+       vaxv)
+               basic_machine=vax-dec
+               os=-sysv
+               ;;
+       vms)
+               basic_machine=vax-dec
+               os=-vms
+               ;;
+       vpp*|vx|vx-*)
+               basic_machine=f301-fujitsu
+               ;;
+       vxworks960)
+               basic_machine=i960-wrs
+               os=-vxworks
+               ;;
+       vxworks68)
+               basic_machine=m68k-wrs
+               os=-vxworks
+               ;;
+       vxworks29k)
+               basic_machine=a29k-wrs
+               os=-vxworks
+               ;;
+       w65*)
+               basic_machine=w65-wdc
+               os=-none
+               ;;
+       w89k-*)
+               basic_machine=hppa1.1-winbond
+               os=-proelf
+               ;;
+       xbox)
+               basic_machine=i686-pc
+               os=-mingw32
+               ;;
+       xps | xps100)
+               basic_machine=xps100-honeywell
+               ;;
+       ymp)
+               basic_machine=ymp-cray
+               os=-unicos
+               ;;
+       z8k-*-coff)
+               basic_machine=z8k-unknown
+               os=-sim
+               ;;
+       none)
+               basic_machine=none-none
+               os=-none
+               ;;
+
+# Here we handle the default manufacturer of certain CPU types.  It is in
+# some cases the only manufacturer, in others, it is the most popular.
+       w89k)
+               basic_machine=hppa1.1-winbond
+               ;;
+       op50n)
+               basic_machine=hppa1.1-oki
+               ;;
+       op60c)
+               basic_machine=hppa1.1-oki
+               ;;
+       romp)
+               basic_machine=romp-ibm
+               ;;
+       mmix)
+               basic_machine=mmix-knuth
+               ;;
+       rs6000)
+               basic_machine=rs6000-ibm
+               ;;
+       vax)
+               basic_machine=vax-dec
+               ;;
+       pdp10)
+               # there are many clones, so DEC is not a safe bet
+               basic_machine=pdp10-unknown
+               ;;
+       pdp11)
+               basic_machine=pdp11-dec
+               ;;
+       we32k)
+               basic_machine=we32k-att
+               ;;
+       sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
+               basic_machine=sh-unknown
+               ;;
+       sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
+               basic_machine=sparc-sun
+               ;;
+       cydra)
+               basic_machine=cydra-cydrome
+               ;;
+       orion)
+               basic_machine=orion-highlevel
+               ;;
+       orion105)
+               basic_machine=clipper-highlevel
+               ;;
+       mac | mpw | mac-mpw)
+               basic_machine=m68k-apple
+               ;;
+       pmac | pmac-mpw)
+               basic_machine=powerpc-apple
+               ;;
+       *-unknown)
+               # Make sure to match an already-canonicalized machine name.
+               ;;
+       *)
+               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               exit 1
+               ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+       *-digital*)
+               basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+               ;;
+       *-commodore*)
+               basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+               ;;
+       *)
+               ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+        # First match some system type aliases
+        # that might get confused with valid system types.
+       # -solaris* is a basic system type, with this one exception.
+       -solaris1 | -solaris1.*)
+               os=`echo $os | sed -e 's|solaris1|sunos4|'`
+               ;;
+       -solaris)
+               os=-solaris2
+               ;;
+       -svr4*)
+               os=-sysv4
+               ;;
+       -unixware*)
+               os=-sysv4.2uw
+               ;;
+       -gnu/linux*)
+               os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+               ;;
+       # First accept the basic system types.
+       # The portable systems comes first.
+       # Each alternative MUST END IN A *, to match a version number.
+       # -sysv* is not here because it comes later, after sysvr4.
+       -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+             | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+             | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+             | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+             | -aos* \
+             | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+             | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+             | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+             | -openbsd* | -solidbsd* \
+             | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+             | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+             | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+             | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+             | -chorusos* | -chorusrdb* \
+             | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+             | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+             | -uxpv* | -beos* | -mpeix* | -udk* \
+             | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+             | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+             | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+             | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+             | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+             | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+             | -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
+       # Remember, each alternative MUST END IN *, to match a version number.
+               ;;
+       -qnx*)
+               case $basic_machine in
+                   x86-* | i*86-*)
+                       ;;
+                   *)
+                       os=-nto$os
+                       ;;
+               esac
+               ;;
+       -nto-qnx*)
+               ;;
+       -nto*)
+               os=`echo $os | sed -e 's|nto|nto-qnx|'`
+               ;;
+       -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+             | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+             | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+               ;;
+       -mac*)
+               os=`echo $os | sed -e 's|mac|macos|'`
+               ;;
+       -linux-dietlibc)
+               os=-linux-dietlibc
+               ;;
+       -linux*)
+               os=`echo $os | sed -e 's|linux|linux-gnu|'`
+               ;;
+       -sunos5*)
+               os=`echo $os | sed -e 's|sunos5|solaris2|'`
+               ;;
+       -sunos6*)
+               os=`echo $os | sed -e 's|sunos6|solaris3|'`
+               ;;
+       -opened*)
+               os=-openedition
+               ;;
+        -os400*)
+               os=-os400
+               ;;
+       -wince*)
+               os=-wince
+               ;;
+       -osfrose*)
+               os=-osfrose
+               ;;
+       -osf*)
+               os=-osf
+               ;;
+       -utek*)
+               os=-bsd
+               ;;
+       -dynix*)
+               os=-bsd
+               ;;
+       -acis*)
+               os=-aos
+               ;;
+       -atheos*)
+               os=-atheos
+               ;;
+       -syllable*)
+               os=-syllable
+               ;;
+       -386bsd)
+               os=-bsd
+               ;;
+       -ctix* | -uts*)
+               os=-sysv
+               ;;
+       -nova*)
+               os=-rtmk-nova
+               ;;
+       -ns2 )
+               os=-nextstep2
+               ;;
+       -nsk*)
+               os=-nsk
+               ;;
+       # Preserve the version number of sinix5.
+       -sinix5.*)
+               os=`echo $os | sed -e 's|sinix|sysv|'`
+               ;;
+       -sinix*)
+               os=-sysv4
+               ;;
+        -tpf*)
+               os=-tpf
+               ;;
+       -triton*)
+               os=-sysv3
+               ;;
+       -oss*)
+               os=-sysv3
+               ;;
+       -svr4)
+               os=-sysv4
+               ;;
+       -svr3)
+               os=-sysv3
+               ;;
+       -sysvr4)
+               os=-sysv4
+               ;;
+       # This must come after -sysvr4.
+       -sysv*)
+               ;;
+       -ose*)
+               os=-ose
+               ;;
+       -es1800*)
+               os=-ose
+               ;;
+       -xenix)
+               os=-xenix
+               ;;
+       -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+               os=-mint
+               ;;
+       -aros*)
+               os=-aros
+               ;;
+       -kaos*)
+               os=-kaos
+               ;;
+       -zvmoe)
+               os=-zvmoe
+               ;;
+       -none)
+               ;;
+       *)
+               # Get rid of the `-' at the beginning of $os.
+               os=`echo $os | sed 's/[^-]*-//'`
+               echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+               exit 1
+               ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system.  Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+        score-*)
+               os=-elf
+               ;;
+        spu-*)
+               os=-elf
+               ;;
+       *-acorn)
+               os=-riscix1.2
+               ;;
+       arm*-rebel)
+               os=-linux
+               ;;
+       arm*-semi)
+               os=-aout
+               ;;
+        c4x-* | tic4x-*)
+               os=-coff
+               ;;
+       # This must come before the *-dec entry.
+       pdp10-*)
+               os=-tops20
+               ;;
+       pdp11-*)
+               os=-none
+               ;;
+       *-dec | vax-*)
+               os=-ultrix4.2
+               ;;
+       m68*-apollo)
+               os=-domain
+               ;;
+       i386-sun)
+               os=-sunos4.0.2
+               ;;
+       m68000-sun)
+               os=-sunos3
+               # This also exists in the configure program, but was not the
+               # default.
+               # os=-sunos4
+               ;;
+       m68*-cisco)
+               os=-aout
+               ;;
+        mep-*)
+               os=-elf
+               ;;
+       mips*-cisco)
+               os=-elf
+               ;;
+       mips*-*)
+               os=-elf
+               ;;
+       or32-*)
+               os=-coff
+               ;;
+       *-tti)  # must be before sparc entry or we get the wrong os.
+               os=-sysv3
+               ;;
+       sparc-* | *-sun)
+               os=-sunos4.1.1
+               ;;
+       *-be)
+               os=-beos
+               ;;
+       *-haiku)
+               os=-haiku
+               ;;
+       *-ibm)
+               os=-aix
+               ;;
+       *-knuth)
+               os=-mmixware
+               ;;
+       *-wec)
+               os=-proelf
+               ;;
+       *-winbond)
+               os=-proelf
+               ;;
+       *-oki)
+               os=-proelf
+               ;;
+       *-hp)
+               os=-hpux
+               ;;
+       *-hitachi)
+               os=-hiux
+               ;;
+       i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+               os=-sysv
+               ;;
+       *-cbm)
+               os=-amigaos
+               ;;
+       *-dg)
+               os=-dgux
+               ;;
+       *-dolphin)
+               os=-sysv3
+               ;;
+       m68k-ccur)
+               os=-rtu
+               ;;
+       m88k-omron*)
+               os=-luna
+               ;;
+       *-next )
+               os=-nextstep
+               ;;
+       *-sequent)
+               os=-ptx
+               ;;
+       *-crds)
+               os=-unos
+               ;;
+       *-ns)
+               os=-genix
+               ;;
+       i370-*)
+               os=-mvs
+               ;;
+       *-next)
+               os=-nextstep3
+               ;;
+       *-gould)
+               os=-sysv
+               ;;
+       *-highlevel)
+               os=-bsd
+               ;;
+       *-encore)
+               os=-bsd
+               ;;
+       *-sgi)
+               os=-irix
+               ;;
+       *-siemens)
+               os=-sysv4
+               ;;
+       *-masscomp)
+               os=-rtu
+               ;;
+       f30[01]-fujitsu | f700-fujitsu)
+               os=-uxpv
+               ;;
+       *-rom68k)
+               os=-coff
+               ;;
+       *-*bug)
+               os=-coff
+               ;;
+       *-apple)
+               os=-macos
+               ;;
+       *-atari*)
+               os=-mint
+               ;;
+       *)
+               os=-none
+               ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer.  We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+       *-unknown)
+               case $os in
+                       -riscix*)
+                               vendor=acorn
+                               ;;
+                       -sunos*)
+                               vendor=sun
+                               ;;
+                       -aix*)
+                               vendor=ibm
+                               ;;
+                       -beos*)
+                               vendor=be
+                               ;;
+                       -hpux*)
+                               vendor=hp
+                               ;;
+                       -mpeix*)
+                               vendor=hp
+                               ;;
+                       -hiux*)
+                               vendor=hitachi
+                               ;;
+                       -unos*)
+                               vendor=crds
+                               ;;
+                       -dgux*)
+                               vendor=dg
+                               ;;
+                       -luna*)
+                               vendor=omron
+                               ;;
+                       -genix*)
+                               vendor=ns
+                               ;;
+                       -mvs* | -opened*)
+                               vendor=ibm
+                               ;;
+                       -os400*)
+                               vendor=ibm
+                               ;;
+                       -ptx*)
+                               vendor=sequent
+                               ;;
+                       -tpf*)
+                               vendor=ibm
+                               ;;
+                       -vxsim* | -vxworks* | -windiss*)
+                               vendor=wrs
+                               ;;
+                       -aux*)
+                               vendor=apple
+                               ;;
+                       -hms*)
+                               vendor=hitachi
+                               ;;
+                       -mpw* | -macos*)
+                               vendor=apple
+                               ;;
+                       -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+                               vendor=atari
+                               ;;
+                       -vos*)
+                               vendor=stratus
+                               ;;
+               esac
+               basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+               ;;
+esac
+
+echo $basic_machine$os
+exit
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/bin/install-sh b/bin/install-sh
new file mode 120000 (symlink)
index 0000000..088407d
--- /dev/null
@@ -0,0 +1 @@
+minstall
\ No newline at end of file
index 819b2bc7e4acfa58a93755ca40414ce356c25aa5..8ee96089fa618d7d98866f5bb59420294501eb6b 100755 (executable)
@@ -42,6 +42,8 @@ if [ $# -ge 2 ] ; then
                        exit 0
                fi
 
+               PWDSAVE=`pwd`
+
                # determine file's type
                if [ -h "$FILE" ] ; then
                        #echo $FILE is a symlink
@@ -57,7 +59,6 @@ if [ $# -ge 2 ] ; then
 
                        FILE=`basename "$FILE"`
                        # Go to $DEST and make the link
-                       PWDSAVE="$PWD"
                        cd "$DEST"        # pushd
                                $RM "$FILE"
                                $SYMLINK "$TARGET" "$FILE"
index 031e049c615584ea026de641d30aa3e96e30518e..a25d5bfaeb2b7f31b72a6cc3424c42513b2e69a4 100755 (executable)
--- a/bin/mklib
+++ b/bin/mklib
@@ -34,6 +34,7 @@ MINOR=0
 PATCH=""
 DEPS=""
 LINK=""
+LDFLAGS=""
 CPLUSPLUS=0
 STATIC=0
 DLOPEN=0
@@ -42,7 +43,7 @@ ARCH="auto"
 ARCHOPT=""
 NOPREFIX=0
 EXPORTS=""
-
+ID=""
 
 #
 # Parse arguments
@@ -60,17 +61,21 @@ do
            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 '  -LDIR         search in DIR for library dependencies at build time'
+           echo '  -RDIR         search in DIR for library dependencies at run time'
            echo '  -linker L     explicity specify the linker program to use (eg: gcc, g++)'
            echo '                Not observed on all systems at this time.'
+           echo '  -ldflags OPT  specify any additional linker flags in OPT'
            echo '  -cplusplus    link with C++ runtime'
            echo '  -static       make a static library (default is dynamic/shared)'
            echo '  -dlopen       make a shared library suitable for dynamic loading'
            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 '  -altopts OPTS alternate options to override all others'
            echo "  -noprefix     don't prefix library name with 'lib' nor add any suffix"
            echo '  -exports FILE only export the symbols listed in FILE'
+           echo '  -id NAME      Sets the id of the dylib (Darwin)'
            echo '  -h, --help    display this information and exit'
            exit 1
            ;;
@@ -94,12 +99,22 @@ do
            shift 1;
            LINK=$1
            ;;
+       '-ldflags')
+           shift 1;
+           LDFLAGS=$1
+           ;;
        -l*)
            DEPS="$DEPS $1"
            ;;
        -L*)
            DEPS="$DEPS $1"
            ;;
+       -R*)
+           DEPS="$DEPS $1"
+           ;;
+       -Wl*)
+            DEPS="$DEPS $1"
+            ;;
        -pthread)
            # this is a special case (see bugzilla 10876)
            DEPS="$DEPS $1"
@@ -128,6 +143,10 @@ do
            shift 1;
            ARCHOPT=$1
            ;;
+       '-altopts')
+            shift 1;
+            ALTOPTS=$1
+            ;;
        '-noprefix')
            NOPREFIX=1
            ;;
@@ -135,6 +154,10 @@ do
            shift 1;
            EXPORTS=$1
            ;;
+       '-id')
+           shift 1;
+           ID=$1
+           ;;
        -*)
            echo "mklib: Unknown option: " $1 ;
            exit 1
@@ -178,6 +201,7 @@ if [  ]  ; then
     echo PATCH is $PATCH
     echo DEPS are $DEPS
     echo "EXPORTS in" $EXPORTS
+    echo ID is $ID
     echo "-----------------"
 fi
 
@@ -187,7 +211,7 @@ fi
 #
 case $ARCH in
 
-    'Linux' | 'OpenBSD' | 'GNU' | GNU/*)
+    'Linux' | 'OpenBSD' | 'DragonFly' | 'GNU' | GNU/*)
        # we assume gcc
 
        if [ "x$LINK" = "x" ] ; then
@@ -218,9 +242,13 @@ case $ARCH in
                OPTS="-m32 ${OPTS}"
            fi
 
+            if [ "${ALTOPTS}" ] ; then
+                OPTS=${ALTOPTS}
+            fi
+
             rm -f ${LIBNAME}
             # make lib
-            ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
+            ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
             # finish up
             FINAL_LIBS="${LIBNAME}"
         elif [ $STATIC = 1 ] ; then
@@ -228,6 +256,9 @@ case $ARCH in
             echo "mklib: Making" $ARCH "static library: " ${LIBNAME}
             LINK="ar"
             OPTS="-ru"
+            if [ "${ALTOPTS}" ] ; then
+                OPTS=${ALTOPTS}
+            fi
             rm -f ${LIBNAME}
             # make lib
             ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
@@ -263,6 +294,9 @@ case $ARCH in
            if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
                OPTS="-m32 ${OPTS}"
            fi
+            if [ "${ALTOPTS}" ] ; then
+                OPTS=${ALTOPTS}
+            fi
 
            if [ x${PATCH} = "x" ] ; then
                VERSION="${MAJOR}.${MINOR}"
@@ -278,7 +312,7 @@ case $ARCH in
             rm -f ${LIBNAME}.so
 
             # make lib
-            ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
+            ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
             # make usual symlinks
             ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
             ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
@@ -312,7 +346,7 @@ case $ARCH in
                        # use g++
                        LINK="g++"
                    else
-                       echo "mklib: warning: can't find C++ comiler, trying CC."
+                       echo "mklib: warning: can't find C++ compiler, trying CC."
                        LINK="CC"
                    fi
                else
@@ -341,19 +375,23 @@ case $ARCH in
            # Check if objects are SPARC v9
            # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1
            set ${OBJECTS}
-           SPARCV9=`file $1 | grep SPARCV9`
-           if [ "${SPARCV9}" ] ; then
-               OPTS="${OPTS} -xarch=v9"
+           if [ ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
+               SPARCV9=`file $1 | grep SPARCV9`
+               if [ "${SPARCV9}" ] ; then
+                   OPTS="${OPTS} -xarch=v9"
+               fi
            fi
-
+            if [ "${ALTOPTS}" ] ; then
+                OPTS=${ALTOPTS}
+            fi
            # for debug:
            #echo "mklib: linker is" ${LINK} ${OPTS}
            if [ $NOPREFIX = 1 ] ; then
                rm -f ${LIBNAME}
-               ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
+               ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
            else
                rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
-               ${LINK} ${OPTS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
+               ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.${MAJOR} -h ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
                ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
            fi
            FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}"
@@ -376,8 +414,11 @@ case $ARCH in
            # No "lib" or ".so" part
            echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
            OPTS="-shared"
+            if [ "${ALTOPTS}" ] ; then
+                OPTS=${ALTOPTS}
+            fi
            rm -f ${LIBNAME}
-           ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
+           ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
            FINAL_LIBS=${LIBNAME}
         elif [ $STATIC = 1 ] ; then
            STLIB="lib${LIBNAME}.a"
@@ -389,9 +430,12 @@ case $ARCH in
        else
            SHLIB="lib${LIBNAME}.so.${MAJOR}"
            OPTS="-shared -Wl,-soname,${SHLIB}"
+            if [ "${ALTOPTS}" ] ; then
+                OPTS=${ALTOPTS}
+            fi
            echo "mklib: Making FreeBSD shared library: " ${SHLIB}
            rm -f ${SHLIB}
-           ${LINK} ${OPTS} -o ${SHLIB} ${OBJECTS} ${DEPS}
+           ${LINK} ${OPTS} ${LDFLAGS} -o ${SHLIB} ${OBJECTS} ${DEPS}
            ln -sf ${SHLIB} "lib${LIBNAME}.so"
            FINAL_LIBS="${SHLIB} lib${LIBNAME}.so"
        fi
@@ -442,6 +486,10 @@ case $ARCH in
                exit 1
            fi
 
+            if [ "${ALTOPTS}" ] ; then
+                OPTS=${ALTOPTS}
+            fi
+
            if [ $CPLUSPLUS = 1 ] ; then
                LINK="CC"
            else
@@ -449,7 +497,7 @@ case $ARCH in
            fi
 
            echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME}
-           ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
+           ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
            FINAL_LIBS=${LIBNAME}
        fi
        ;;
@@ -522,12 +570,16 @@ case $ARCH in
                }
            }' | sort -u >> ${EXPFILE}
 
+            if [ "${ALTOPTS}" ] ; then
+                OPTS=${ALTOPTS}
+            fi
+
             # On AIX a shared library is linked differently when
             # you want to dlopen the file
            if [ $DLOPEN = "1" ] ; then
-               cc -G ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
+               cc -G ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
            else
-               cc ${OPTS} -o ${OFILE} ${OBJECTS} ${DEPS}
+               cc ${OPTS} ${LDFLAGS} -o ${OFILE} ${OBJECTS} ${DEPS}
                ar ${X64} -r ${LIBNAME} ${OFILE}
            fi
 
@@ -573,6 +625,9 @@ case $ARCH in
             echo "mklib: Making Darwin static library: " ${LIBNAME}
             LINK="ar"
             OPTS="-ruvs"
+            if [ "${ALTOPTS}" ] ; then
+                OPTS=${ALTOPTS}
+            fi
             ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
             FINAL_LIBS=${LIBNAME}
         else
@@ -581,22 +636,46 @@ case $ARCH in
                 LIBSUFFIX="bundle"
                 OPTS="${ARCHOPT} -bundle -multiply_defined suppress"
             else
-               LIBSUFFIX="dylib"
-                OPTS="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
+                LIBSUFFIX="dylib"
+                if [ -z "$ID" ] ; then
+                    ID="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
+                fi
+                OPTS="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name ${ID}"
             fi
-            LINKNAME="lib${LIBNAME}.${LIBSUFFIX}"
-            LIBNAME="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
+
+            if [ ${EXPORTS} ] ; then
+                if [ -f ${EXPORTS}".darwin" ] ; then
+                    EXPORTS=$EXPORTS".darwin"
+                fi
+                OPTS="${OPTS} -exported_symbols_list ${EXPORTS}"
+            fi
+
+            LINKNAME="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
+            LINKNAME2="lib${LIBNAME}.${LIBSUFFIX}"
+            LIBNAME="lib${LIBNAME}.${MAJOR}.${MINOR}.${LIBSUFFIX}"
 
            # examine first object to determine ABI
            set ${OBJECTS}
-           ABI_PPC=`file $1 | grep 'object ppc'`
-           ABI_I386=`file $1 | grep 'object i386'`
-           if [ "${ABI_PPC}" ] ; then
-               OPTS="${OPTS} -arch ppc"
-           fi
-           if [ "${ABI_I386}" ] ; then
-               OPTS="${OPTS} -arch i386"
-           fi
+            ABI_PPC=`file $1 | grep ' ppc'`
+            ABI_I386=`file $1 | grep ' i386'`
+            ABI_PPC64=`file $1 | grep ' ppc64'`
+            ABI_X86_64=`file $1 | grep ' x86_64'`
+            if [ "${ABI_PPC}" ] ; then
+                OPTS="${OPTS} -arch ppc"
+            fi
+            if [ "${ABI_I386}" ] ; then
+                OPTS="${OPTS} -arch i386"
+            fi
+            if [ "${ABI_PPC64}" ] ; then
+                OPTS="${OPTS} -arch ppc64"
+            fi
+            if [ "${ABI_X86_64}" ] ; then
+                OPTS="${OPTS} -arch x86_64"
+            fi
+
+            if [ "${ALTOPTS}" ] ; then
+                OPTS=${ALTOPTS}
+            fi
 
            # XXX can we always add -isysroot /Developer/SDKs/MacOSX10.4u.sdk
            # to OPTS here?
@@ -609,9 +688,11 @@ case $ARCH in
            fi
 
             echo "mklib: Making Darwin shared library: " ${LIBNAME}
-            ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
+
+            ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
             ln -s ${LIBNAME} ${LINKNAME}
-            FINAL_LIBS="${LIBNAME} ${LINKNAME}"
+            ln -s ${LIBNAME} ${LINKNAME2}
+            FINAL_LIBS="${LIBNAME} ${LINKNAME} ${LINKNAME2}"
         fi
         ;;
 
@@ -663,6 +744,9 @@ case $ARCH in
             echo "mklib: Making Intel ICC static library: " ${LIBNAME}.a
             LINK="ar"
             OPTS="-ruv"
+            if [ "${ALTOPTS}" ] ; then
+                OPTS=${ALTOPTS}
+            fi
             # make lib
             ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
             # finish up
@@ -673,6 +757,9 @@ case $ARCH in
             else
                  OPTS="-shared"
             fi
+            if [ "${ALTOPTS}" ] ; then
+                OPTS=${ALTOPTS}
+            fi
             VERSION="${MAJOR}.${MINOR}.${PATCH}"
             echo "mklib: Making Intel ICC shared library: " ${LIBNAME}.so.${VERSION}
 
@@ -686,7 +773,7 @@ case $ARCH in
             rm -f ${LIBNAME}.so.${MAJOR}
             rm -f ${LIBNAME}.so
             # make lib
-            ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
+            ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
             # make usual symlinks
             ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
             ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
@@ -737,6 +824,9 @@ case $ARCH in
             echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a
             LINK="ar"
             OPTS="-ru"
+            if [ "${ALTOPTS}" ] ; then
+                OPTS=${ALTOPTS}
+            fi
             # make lib
             ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
            ranlib ${LIBNAME}.a
@@ -744,6 +834,9 @@ case $ARCH in
             FINAL_LIBS=${LIBNAME}.a
         else
            OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a"
+            if [ "${ALTOPTS}" ] ; then
+                OPTS=${ALTOPTS}
+            fi
             echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}-${MAJOR}.dll
 
             if [ $CPLUSPLUS = 1 ] ; then
@@ -758,7 +851,7 @@ case $ARCH in
             rm -f ${LIBNAME}.a
 
             # make lib
-            ${LINK} ${OPTS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
+            ${LINK} ${OPTS} ${LDFLAGS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
             # make usual symlinks
             ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
             # finish up
diff --git a/bin/version.mk b/bin/version.mk
new file mode 100755 (executable)
index 0000000..ab20d79
--- /dev/null
@@ -0,0 +1,17 @@
+#!/usr/bin/make -sf
+# Print the various Mesa version fields. This is mostly used to add the
+# version to configure.
+
+# This reflects that this script is usually called from the toplevel
+TOP = .
+
+include $(TOP)/configs/default
+
+version:
+       @echo $(MESA_VERSION)
+major:
+       @echo $(MESA_MAJOR)
+minor:
+       @echo $(MESA_MINOR)
+tiny:
+       @echo $(MESA_TINY)
index 5b9023a315ae79fd8cbe9e8c3a6f8053f0ed3ddb..97ac5b7326f5159d0af99eac255212e3b5c1fe06 100644 (file)
@@ -1 +1,2 @@
 current
+autoconf
index 81467082a73acd27ff1729cb39c5acec245aeebe..3b964f351f72e65f3e41673cf7b535fa736eb89c 100644 (file)
@@ -11,6 +11,10 @@ CXX = g++
 CFLAGS = -O2 -DAIXV3
 CXXFLAGS = -O2 -DAIXV3
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
+
 MKLIB_OPTIONS = -arch aix-gcc
 GL_LIB_DEPS = -lX11 -lXext -lm
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm
diff --git a/configs/autoconf.in b/configs/autoconf.in
new file mode 100644 (file)
index 0000000..a3eaed5
--- /dev/null
@@ -0,0 +1,107 @@
+# Autoconf configuration
+
+# Pull in the defaults
+include $(TOP)/configs/default
+
+# This is generated by configure
+CONFIG_NAME = autoconf
+
+# Compiler and flags
+CC = @CC@
+CXX = @CXX@
+OPT_FLAGS = @OPT_FLAGS@
+ARCH_FLAGS = @ARCH_FLAGS@
+ASM_FLAGS = @ASM_FLAGS@
+PIC_FLAGS = @PIC_FLAGS@
+DEFINES = @DEFINES@
+CFLAGS = @CPPFLAGS@ @CFLAGS@ \
+       $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(ASM_FLAGS) $(DEFINES)
+CXXFLAGS = @CPPFLAGS@ @CXXFLAGS@ \
+       $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES)
+LDFLAGS = @LDFLAGS@
+EXTRA_LIB_PATH = @EXTRA_LIB_PATH@
+
+# Assembler
+ASM_SOURCES = @ASM_SOURCES@
+ASM_API = @ASM_API@
+
+# Misc tools and flags
+MAKE = @MAKE@
+SHELL = @SHELL@
+MKLIB_OPTIONS = @MKLIB_OPTIONS@
+MKDEP = @MKDEP@
+MKDEP_OPTIONS = @MKDEP_OPTIONS@
+
+# 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_LIB@
+
+# Library names (actual file names)
+GL_LIB_NAME = @GL_LIB_NAME@
+GLU_LIB_NAME = @GLU_LIB_NAME@
+GLUT_LIB_NAME = @GLUT_LIB_NAME@
+GLW_LIB_NAME = @GLW_LIB_NAME@
+OSMESA_LIB_NAME = @OSMESA_LIB_NAME@
+
+# Directories to build
+LIB_DIR = @LIB_DIR@
+SRC_DIRS = @SRC_DIRS@
+GLU_DIRS = @GLU_DIRS@
+DRIVER_DIRS = @DRIVER_DIRS@
+# Which subdirs under $(TOP)/progs/ to enter:
+PROGRAM_DIRS = @PROGRAM_DIRS@
+
+# Driver specific build vars
+DRI_DIRS = @DRI_DIRS@
+WINDOW_SYSTEM = @WINDOW_SYSTEM@
+USING_EGL = @USING_EGL@
+
+# Dependencies
+X11_INCLUDES = @X11_INCLUDES@
+
+# GLw motif setup
+GLW_SOURCES = @GLW_SOURCES@
+MOTIF_CFLAGS = @MOTIF_CFLAGS@
+
+# Library/program dependencies
+GL_LIB_DEPS = $(EXTRA_LIB_PATH) @GL_LIB_DEPS@
+OSMESA_LIB_DEPS = -L$(TOP)/$(LIB_DIR) @OSMESA_MESA_DEPS@ \
+       $(EXTRA_LIB_PATH) @OSMESA_LIB_DEPS@
+GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) @GLU_MESA_DEPS@ \
+       $(EXTRA_LIB_PATH) @GLU_LIB_DEPS@
+GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) @GLUT_MESA_DEPS@ \
+       $(EXTRA_LIB_PATH) @GLUT_LIB_DEPS@
+GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) @GLW_MESA_DEPS@ \
+       $(EXTRA_LIB_PATH) @GLW_LIB_DEPS@
+APP_LIB_DEPS = $(EXTRA_LIB_PATH) @APP_LIB_DEPS@
+
+# DRI dependencies
+DRI_LIB_DEPS = $(EXTRA_LIB_PATH) @DRI_LIB_DEPS@
+LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
+LIBDRM_LIB = @LIBDRM_LIBS@
+DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
+EXPAT_INCLUDES = @EXPAT_INCLUDES@
+
+# Autoconf directories
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+libdir = @libdir@
+includedir = @includedir@
+
+# Installation directories (for make install)
+INSTALL_DIR = $(prefix)
+INSTALL_LIB_DIR = $(libdir)
+INSTALL_INC_DIR = $(includedir)
+
+# DRI installation directories
+DRI_DRIVER_INSTALL_DIR = @DRI_DRIVER_INSTALL_DIR@
+
+# Where libGL will look for DRI hardware drivers
+DRI_DRIVER_SEARCH_DIR = $(DRI_DRIVER_INSTALL_DIR)
index c6e972789a5842e754fefefc6a9c30993332c36d..897c36868feb69d237c92664b817d69452b0f19f 100644 (file)
@@ -39,6 +39,10 @@ ifeq ($(CPU), x86)
 
        CXXFLAGS = $(CFLAGS)
 
+       # Work around aliasing bugs - developers should comment this out
+       CFLAGS += -fno-strict-aliasing
+       CXXFLAGS += -fno-strict-aliasing
+
        LDFLAGS += -Xlinker
 
        ifdef DEBUG
diff --git a/configs/bluegene-osmesa b/configs/bluegene-osmesa
new file mode 100644 (file)
index 0000000..d22454f
--- /dev/null
@@ -0,0 +1,33 @@
+# Configuration for building only libOSMesa on BlueGene, no Xlib driver
+# This doesn't really have a lot of dependencies, so it should be usable
+# on other (gcc-based) systems too.
+# It uses static linking and disables multithreading.
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = bluegene-osmesa
+
+# Compiler and flags
+CC = /bgl/BlueLight/ppcfloor/blrts-gnu/bin/powerpc-bgl-blrts-gnu-gcc
+CXX = /bgl/BlueLight/ppcfloor/blrts-gnu/bin/powerpc-bgl-blrts-gnu-g++
+CFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
+CXXFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURC
+
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
+
+MKLIB_OPTIONS = -static
+
+OSMESA_LIB_NAME = libOSMesa.a
+
+# Directories
+SRC_DIRS = mesa glu
+DRIVER_DIRS = osmesa
+PROGRAM_DIRS = osdemos
+
+
+# Dependencies
+OSMESA_LIB_DEPS = -lm
+GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(OSMESA_LIB)
+APP_LIB_DEPS = -lOSMesa -lGLU -lm
diff --git a/configs/bluegene-xlc-osmesa b/configs/bluegene-xlc-osmesa
new file mode 100644 (file)
index 0000000..b0c762d
--- /dev/null
@@ -0,0 +1,29 @@
+# Configuration for building only libOSMesa on BlueGene using the IBM xlc compiler
+# This doesn't really have a lot of dependencies, so it should be usable
+# on similar systems too.
+# It uses static linking and disables multithreading.
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = bluegene-osmesa
+
+# Compiler and flags
+CC = /opt/ibmcmp/vacpp/bg/8.0/bin/blrts_xlc
+CXX = /opt/ibmcmp/vacpp/bg/8.0/bin/blrts_xlC
+CFLAGS = -O3 -pedantic -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
+CXXFLAGS = -O3 -pedantic -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
+
+MKLIB_OPTIONS = -static
+
+OSMESA_LIB_NAME = libOSMesa.a
+
+# Directories
+SRC_DIRS = mesa glu
+DRIVER_DIRS = osmesa
+PROGRAM_DIRS = osdemos
+
+
+# Dependencies
+OSMESA_LIB_DEPS = -lm
+GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(OSMESA_LIB)
+APP_LIB_DEPS = -lOSMesa -lGLU -lm
diff --git a/configs/catamount-osmesa-pgi b/configs/catamount-osmesa-pgi
new file mode 100644 (file)
index 0000000..835f6eb
--- /dev/null
@@ -0,0 +1,32 @@
+# Configuration for building only libOSMesa on Cray Xt3
+# for the compute nodes running Catamount using the 
+# Portland Group compiler. The Portland Group toolchain has to be 
+# enabled before using "module switch PrgEnv-gnu PrgEnv-pgi" .
+# This doesn't really have a lot of dependencies, so it should be usable
+# on other similar systems too.
+# It uses static linking and disables multithreading.
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = catamount-osmesa-pgi
+
+# Compiler and flags
+CC = cc
+CXX = CC
+CFLAGS = -target=catamount -fastsse -O3 -Mnontemporal -Mprefetch=distance:8,nta   -fPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
+CXXFLAGS = -target=catamount -fastsse -O3 -Mnontemporal -Mprefetch=distance:8,nta -fPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
+
+MKLIB_OPTIONS = -static
+
+OSMESA_LIB_NAME = libOSMesa.a
+
+# Directories
+SRC_DIRS = mesa glu
+DRIVER_DIRS = osmesa
+PROGRAM_DIRS = osdemos
+
+
+# Dependencies
+OSMESA_LIB_DEPS = -lm
+GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(OSMESA_LIB)
+APP_LIB_DEPS = -lOSMesa -lGLU -lm
diff --git a/configs/config.mgw b/configs/config.mgw
new file mode 100644 (file)
index 0000000..af74fda
--- /dev/null
@@ -0,0 +1,42 @@
+# MinGW config include file updated for Mesa 7.0
+#
+#  Updated : by Heromyth, on 2007-7-21
+#  Email   : zxpmyth@yahoo.com.cn
+#  Bugs    : 1) All the default settings work fine. But the setting X86=1 can't work. 
+#            The others havn't been tested yet.
+#            2) The generated DLLs are *not* compatible with the ones built
+#            with the other compilers like VC8, especially for GLUT. 
+#            3) Although more tests are needed, it can be used individually!
+
+# The generated DLLs by MingW with STDCALL are not totally compatible 
+# with the ones linked by Microsoft's compilers.
+#
+# xxx_USING_STDCALL = 1          Compiling MESA with __stdcall. This is default!
+# 
+# xxx_USING_STDCALL = 0          Compiling MESA without __stdcall. I like this:)
+#  
+
+# In fact, GL_USING_STDCALL and GLUT_USING_STDCALL can be
+# different. For example:
+#
+#   GL_USING_STDCALL = 0
+#   GLUT_USING_STDCALL = 1
+# 
+# Suggested setting:
+#
+#     ALL_USING_STDCALL = 1
+#
+# That's default!
+#
+
+
+ALL_USING_STDCALL = 1
+
+
+ifeq ($(ALL_USING_STDCALL),1)
+  GL_USING_STDCALL = 1
+  GLUT_USING_STDCALL = 1
+else
+  GL_USING_STDCALL = 0
+  GLUT_USING_STDCALL = 0
+endif
index bba7802696279a5af78e24660e8e74544535f114..aa9efb66f5c2aefb0e378aedf7f25dfd536e7de8 100644 (file)
@@ -4,11 +4,26 @@ include $(TOP)/configs/default
 
 CONFIG_NAME = darwin
 
+INSTALL_DIR = /usr/X11
+
 # 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
+CC = gcc
+CXX = gcc
+PIC_FLAGS = -fPIC
+DEFINES =  -D_DARWIN_C_SOURCE -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L \
+          -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE -DPTHREADS \
+          -DGLX_INDIRECT_RENDERING \
+          -DGLX_ALIAS_UNSUPPORTED
+
+# -DGLX_DIRECT_RENDERING - pulls in libdrm stuff in glx/x11
+# -DIN_DRI_DRIVER
+
+ARCH_FLAGS += $(RC_CFLAGS)
+
+CFLAGS =  -g -O2 -Wall -Wmissing-prototypes -std=c99 -ffast-math -fno-strict-aliasing \
+       -I$(INSTALL_DIR)/include $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(ASM_FLAGS) $(DEFINES)
+CXXFLAGS =  -g -O2 -Wall -fno-strict-aliasing \
+       -I$(INSTALL_DIR)/include $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(ASM_FLAGS) $(DEFINES)
 
 # Library names (actual file names)
 GL_LIB_NAME = libGL.dylib
@@ -17,13 +32,24 @@ 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$(TOP)/$(LIB_DIR) -lGL
-GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -lGL
-GLUT_LIB_DEPS = -L$(TOP)/$(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
+# globs used to install the lib and all symlinks
+GL_LIB_GLOB = libGL.*dylib
+GLU_LIB_GLOB = libGLU.*dylib
+GLUT_LIB_GLOB = libglut.*dylib
+GLW_LIB_GLOB = libGLw.*dylib
+OSMESA_LIB_GLOB = libOSMesa.*dylib
 
-# omit glw lib for now:
-SRC_DIRS = gallium mesa glu glut/glx
+GL_LIB_DEPS = -L$(INSTALL_DIR)/$(LIB_DIR) -lX11 -lXext -lm -lpthread
+OSMESA_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB)
+GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB)
+GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB)  -L$(INSTALL_DIR)/$(LIB_DIR) -lX11 -lXmu -lXi -lXext
+GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L$(INSTALL_DIR)/$(LIB_DIR) -lX11 -lXt
+APP_LIB_DEPS = -L$(TOP)/lib -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L$(INSTALL_DIR)/$(LIB_DIR) -lX11 -lXmu -lXt -lXi -lm
 
+# omit glw lib for now:
+SRC_DIRS = glx/x11 mesa glu glw glut/glx
+GLU_DIRS = sgi
+DRIVER_DIRS = osmesa
+#DRIVER_DIRS = dri
+DRI_DIRS = swrast
+PROGRAM_DIRS = xdemos
diff --git a/configs/darwin-fat-32bit b/configs/darwin-fat-32bit
new file mode 100644 (file)
index 0000000..56bc6a3
--- /dev/null
@@ -0,0 +1,7 @@
+# Configuration for Darwin / MacOS X, making 32bit fat dynamic libs
+
+RC_CFLAGS=-arch ppc -arch i386
+
+include $(TOP)/configs/darwin
+
+CONFIG_NAME = darwin-fat-32bit
diff --git a/configs/darwin-fat-all b/configs/darwin-fat-all
new file mode 100644 (file)
index 0000000..b8668dc
--- /dev/null
@@ -0,0 +1,7 @@
+# Configuration for Darwin / MacOS X, making 32bit and 64bit fat dynamic libs
+
+RC_CFLAGS=-arch ppc -arch i386 -arch ppc64 -arch x86_64
+
+include $(TOP)/configs/darwin
+
+CONFIG_NAME = darwin-fat-all
diff --git a/configs/darwin-static b/configs/darwin-static
deleted file mode 100644 (file)
index 3eb6581..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-# 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 =
-OSMESA_LIB_DEPS = 
-GLU_LIB_DEPS = 
-GLUT_LIB_DEPS = 
-GLW_LIB_DEPS = 
-APP_LIB_DEPS = -Wl,-search_paths_first -L$(TOP)/lib -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lstdc++ -lgcc_s.1 -lm
diff --git a/configs/darwin-static-x86ppc b/configs/darwin-static-x86ppc
deleted file mode 100644 (file)
index 844a1d2..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-# Configuration for Darwin / MacOS X, making static libs
-
-include $(TOP)/configs/darwin
-
-CONFIG_NAME = darwin-static
-
-# Compiler and flags
-CFLAGS = -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk \
-         -I/usr/X11R6/include -O3 -fno-common -ffast-math -funroll-loops -fexpensive-optimizations -no-cpp-precomp -dynamic -Ddarwin
-CXXFLAGS = -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk \
-           -I/usr/X11R6/include -O3 -fno-common -ffast-math -funroll-loops -fexpensive-optimizations -no-cpp-precomp -dynamic -Ddarwin
-MKLIB_OPTIONS = -static -archopt "-isysroot /Developer/SDKs/MacOSX10.4u.sdk"
-
-# 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 =
-OSMESA_LIB_DEPS = 
-GLU_LIB_DEPS = 
-GLUT_LIB_DEPS = 
-GLW_LIB_DEPS = 
-APP_LIB_DEPS = -Wl,-search_paths_first -L$(TOP)/lib -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lstdc++ -lgcc_s.1 -lm
index 94582d82746f61c88ca7f5912528f80b6a113f81..5fd4c26d37b3ddc2c9fb02b6c632bf115584bd4e 100644 (file)
@@ -9,8 +9,9 @@ CONFIG_NAME = default
 
 # Version info
 MESA_MAJOR=7
-MESA_MINOR=1
+MESA_MINOR=3
 MESA_TINY=0
+MESA_VERSION = $(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY)
 
 # external projects.  This should be useless now that we use libdrm.
 DRM_SOURCE_PATH=$(TOP)/../drm
@@ -21,6 +22,7 @@ CXX = CC
 HOST_CC = $(CC)
 CFLAGS = -O
 CXXFLAGS = -O
+LDFLAGS =
 GLU_CFLAGS = 
 
 # Compiler for building demos/tests/etc
@@ -28,15 +30,19 @@ APP_CC = $(CC)
 APP_CXX = $(CXX)
 
 # Misc tools and flags
+SHELL = /bin/sh
+MKLIB = $(SHELL) $(TOP)/bin/mklib
 MKLIB_OPTIONS = 
 MKDEP = makedepend
 MKDEP_OPTIONS = -fdepend
 MAKE = make
-INSTALL = $(TOP)/bin/minstall
+INSTALL = $(SHELL) $(TOP)/bin/minstall
 
-# Python and flags (generally only needed by the developers)
+# Tools for regenerating glapi (generally only needed by the developers)
 PYTHON2 = python
 PYTHON_FLAGS = -t -O -O
+INDENT = indent
+INDENT_FLAGS = -i4 -nut -br -brs -npcs -ce -T GLubyte -T GLbyte -T Bool
 
 # Library names (base name)
 GL_LIB = GL
@@ -53,6 +59,12 @@ GLUT_LIB_NAME = lib$(GLUT_LIB).so
 GLW_LIB_NAME = lib$(GLW_LIB).so
 OSMESA_LIB_NAME = lib$(OSMESA_LIB).so
 
+# globs used to install the lib and all symlinks
+GL_LIB_GLOB = $(GL_LIB_NAME)*
+GLU_LIB_GLOB = $(GLU_LIB_NAME)*
+GLUT_LIB_GLOB = $(GLUT_LIB_NAME)*
+GLW_LIB_GLOB = $(GLW_LIB_NAME)*
+OSMESA_LIB_GLOB = $(OSMESA_LIB_NAME)*
 
 # Optional assembly language optimization files for libGL
 MESA_ASM_SOURCES = 
@@ -60,11 +72,12 @@ MESA_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
+MOTIF_CFLAGS = -I/usr/include/Motif1.2
 
 
 # Directories to build
 LIB_DIR = lib
-SRC_DIRS = gallium mesa egl gallium/winsys glu glut/glx glw
+SRC_DIRS = mesa gallium egl gallium/winsys glu glut/glx glw
 GLU_DIRS = sgi
 DRIVER_DIRS = 
 # Which subdirs under $(TOP)/progs/ to enter:
@@ -81,7 +94,7 @@ GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVER_DIRS),$(TOP)/src/gallium/driver
 GALLIUM_WINSYS_DIRS = xlib egl_xlib
 
 
-# Library/program dependencies
+# Library dependencies
 #EXTRA_LIB_PATH ?=
 GL_LIB_DEPS     = $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread
 OSMESA_LIB_DEPS = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GL_LIB)
@@ -90,11 +103,15 @@ GLUT_LIB_DEPS   = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB)
 GLW_LIB_DEPS    = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lXt -lX11
 APP_LIB_DEPS    = $(EXTRA_LIB_PATH) -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
 
+# Program dependencies - specific GL/glut libraries added in Makefiles
+APP_LIB_DEPS = -lm
 
 
 # Installation directories (for make install)
 INSTALL_DIR = /usr/local
-DRI_DRIVER_INSTALL_DIR = /usr/lib/dri
+INSTALL_LIB_DIR = $(INSTALL_DIR)/$(LIB_DIR)
+INSTALL_INC_DIR = $(INSTALL_DIR)/include
+DRI_DRIVER_INSTALL_DIR = $(INSTALL_LIB_DIR)/dri
 
 # Where libGL will look for DRI hardware drivers
 DRI_DRIVER_SEARCH_DIR = $(DRI_DRIVER_INSTALL_DIR)
index db7dd3b78a04277d16559129199697fe9e6d2532..976ddd19e6f01ba1f594a79f11882fad03914b36 100644 (file)
@@ -13,9 +13,9 @@ OPT_FLAGS  = -O2
 PIC_FLAGS  = -fPIC
 
 DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -DUSE_XSHM \
-       -DHZ=100 -DHAVE_POSIX_MEMALIGN
+       -DHZ=100
 
-X11_INCLUDES = -I/usr/X11R6/include
+X11_INCLUDES = -I/usr/local/include
 
 CFLAGS += $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(DEFINES) $(X11_INCLUDES) -ffast-math -pedantic
 
@@ -23,5 +23,9 @@ CXXFLAGS += $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(DEFINES) $(X11_INCLUDES)
 
 GLUT_CFLAGS = -fexceptions
 
-EXTRA_LIB_PATH = -L/usr/X11R6/lib
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
+
+EXTRA_LIB_PATH = -L/usr/local/lib
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) $(EXTRA_LIB_PATH) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lXext -lXmu -lXi -lX11 -lm
index 6fc1abbc80236575a78bba84729fb3f980f7d272..f7e1fa0c190b07512e0149a0c2604e02b54d2d84 100644 (file)
@@ -9,30 +9,35 @@ CONFIG_NAME = freebsd-dri
 CC = gcc
 CXX = g++
 WARN_FLAGS = -Wall
-OPT_FLAGS = -O
+OPT_FLAGS = -O -g
 
 EXPAT_INCLUDES = -I/usr/local/include
-X11_INCLUDES = -I/usr/X11R6/include
+X11_INCLUDES = -I/usr/local/include
 DEFINES = -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER \
        -DGLX_DIRECT_RENDERING -DGLX_INDIRECT_RENDERING \
-       -DHAVE_ALIAS -DHAVE_POSIX_MEMALIGN
+       -DHAVE_ALIAS
 
 CFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) -Wmissing-prototypes -std=c99 -Wundef -ffast-math \
        $(ASM_FLAGS) $(X11_INCLUDES) $(DEFINES)
 
 CXXFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(DEFINES) -Wall -ansi -pedantic $(ASM_FLAGS) $(X11_INCLUDES) 
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
+
+ASM_SOURCES = 
 MESA_ASM_SOURCES = 
 
 # Library/program dependencies
 LIBDRM_CFLAGS = `pkg-config --cflags libdrm`
 LIBDRM_LIB = `pkg-config --libs libdrm`
 DRI_LIB_DEPS = -L/usr/local/lib -lm -pthread -lexpat $(LIBDRM_LIB)
-GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lXdamage -lXfixes \
+GL_LIB_DEPS = -L/usr/local/lib -lX11 -lXext -lXxf86vm -lXdamage -lXfixes \
        -lm -pthread $(LIBDRM_LIB)
 
-GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -L/usr/X11R6/lib -lGLU -lGL -lX11 -lXmu -lXt -lXi -lm
-GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -L/usr/X11R6/lib -lGL -lXt -lX11
+GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -L/usr/local/lib -lGLU -lGL -lX11 -lXmu -lXt -lXi -lm
+GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -L/usr/local/lib -lGL -lXt -lX11
 
 
 # Directories
index 10a9ad5cd57bc21540e6948f326bdaf612b507be..be396f854996723d02905ac9b4595cebf386e87c 100644 (file)
@@ -12,5 +12,9 @@ CFLAGS = -ansi -O3 -D_HPUX_SOURCE -I/usr/include/X11R6 -I/usr/contrib/X11R6/incl
 CXXFLAGS = -ansi -O3 -D_HPUX_SOURCE
 GLUT_CFLAGS = -fexceptions
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
+
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -L/usr/lib/X11R6 -L/usr/contrib/X11R6/lib -lXext -lXmu -lXi -lX11 -lm
 
index 0d455ff46a51a2783fb9df7ef92b4a36fcc87cb9..15700a1a3bf4236b75a0df38de5f6ecf035b88c4 100644 (file)
@@ -28,6 +28,10 @@ CFLAGS = -Wall -Wmissing-prototypes $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) \
 CXXFLAGS = -Wall $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
        $(X11_INCLUDES) 
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
+
 GLUT_CFLAGS = -fexceptions
 
 EXTRA_LIB_PATH = -L/usr/X11R6/lib
index d69aabb7307c07aca79e4a946662757a277230a5..65bf0c2ab6abbf0bc4d7671a54ef5e9ee3164c21 100644 (file)
@@ -11,6 +11,10 @@ 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
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
+
 GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread
 GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
 GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L/usr/X11R6/lib -lXt -lX11
index 2a30af9b68be99de12e4de03f7d5d7ce8001f42a..53808d77ca4b866fad685635865261482c06f413 100644 (file)
@@ -11,7 +11,11 @@ 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
+PIC_FLAGS =
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
 
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
index 2ed94fe27506ad41cda65703f2e8fb5a1028d67f..b1fb914a2dca8caab47a04570196529f0e97a210 100644 (file)
@@ -13,6 +13,10 @@ CFLAGS   = -Wall -O3 -ffast-math -fPIC -std=c99 -D_GNU_SOURCE -D_POSIX_SOURCE -D
 
 CXXFLAGS = -Wall -O3 -fPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE   
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
+
 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
index d441194b08c98978aa454a05178006e252e6a0da..eb6f307dac55b6c87df8f4fc0960ed999a572ee0 100644 (file)
@@ -32,6 +32,11 @@ CFLAGS = -Wall -Wmissing-prototypes -std=c99 -ffast-math \
 
 CXXFLAGS = -Wall $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES)
 
+GLUT_CFLAGS = -fexceptions
+
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
 
 MESA_ASM_SOURCES = 
 
@@ -42,14 +47,22 @@ LIBDRM_CFLAGS = $(shell pkg-config --cflags libdrm)
 LIBDRM_LIB = $(shell pkg-config --libs libdrm)
 DRI_LIB_DEPS  = $(EXTRA_LIB_PATH) -lm -lpthread -lexpat -ldl $(LIBDRM_LIB)
 GL_LIB_DEPS   = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lXdamage -lXfixes \
-               -lm -lpthread -ldl \
-                $(LIBDRM_LIB)
+               -lm -lpthread -ldl $(LIBDRM_LIB)
 
 
 # Directories
 SRC_DIRS := glx/x11 egl $(SRC_DIRS)
 
 
+# Directories
+ifeq ($(USING_EGL), 1)
+SRC_DIRS = egl glx/x11 gallium mesa glu glut/glx glw
+PROGRAM_DIRS = egl xdemos
+else
+SRC_DIRS = glx/x11 gallium mesa glu glut/glx glw
+PROGRAM_DIRS = xdemos
+endif
+
 # EGL directories
 EGL_DRIVERS_DIRS = demo dri xdri
 
@@ -59,4 +72,11 @@ GALLIUM_WINSYS_DIRS = drm egl_xlib
 
 # gamma are missing because they have not been converted to use the new
 # interface.
+
+# XXX: need to figure out a way for gallium and non-gallium builds to
+# coexist:
+#
+
+#DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
+#      savage sis tdfx trident unichrome ffb
 DRI_DIRS = intel 
index ec8242dd68fa7b55883444e618eaede977509ec7..4eedfa52f7e0e528c4ae1fa9994a6a911031e139 100644 (file)
@@ -5,9 +5,6 @@ include $(TOP)/configs/linux-dri
 
 CONFIG_NAME = linux-dri-x86
 
-# Unnecessary on x86, generally.
-PIC_FLAGS = 
-
 # Add -m32 to CFLAGS:
 ARCH_FLAGS = -m32
 
index bb56de375a14bda3e067fff57941b1a4260e1fb8..ceab05d5db43305afd7625041f766409d3ecc5bb 100644 (file)
@@ -20,5 +20,5 @@ EXTRA_LIB_PATH=-L/usr/X11R6/lib64
 # the new interface.  i810 are missing because there is no x86-64
 # system where they could *ever* be used.
 #
-DRI_DIRS = i915tex i915 i965 mach64 mga r128 r200 radeon tdfx unichrome savage r300
+DRI_DIRS = i915 i965 mach64 mga r128 r200 r300 radeon savage tdfx unichrome
 
index fbf9b9b268770c6ac90c2ae7a8edfca97c3a07bc..d7b00a266ed46ffe6a80b472b060b9c3e4442767 100644 (file)
@@ -32,6 +32,9 @@ CFLAGS = -Wall -Wmissing-prototypes $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) \
 
 CXXFLAGS = -Wall $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES)
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
 
 MESA_ASM_SOURCES = 
 
@@ -57,7 +60,7 @@ SRC_DIRS = egl glx/x11 gallium mesa glu glut/glx glw
 PROGRAM_DIRS = egl
 else
 SRC_DIRS = glx/x11 gallium mesa glu glut/glx glw
-PROGRAM_DIRS =
+PROGRAM_DIRS = xdemos
 endif
 
 DRIVER_DIRS = dri
@@ -66,4 +69,4 @@ WINDOW_SYSTEM=dri
 # gamma are missing because they have not been converted to use the new
 # interface.
 DRI_DIRS = i810 i915 mach64 mga r128 r200 r300 radeon s3v \
-       savage sis tdfx trident unichrome ffb nouveau
+       savage sis tdfx trident unichrome ffb 
index 1ddccb3f52bdf075bd6032d48c9dda78d6c3785b..f54c73695a3c5028c84749a8965302d5d6ed2685 100644 (file)
@@ -6,6 +6,9 @@ CONFIG_NAME = linux-fbdev
 
 CFLAGS = -O3 -ffast-math -ansi -pedantic -fPIC -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DPTHREADS -DUSE_GLFBDEV_DRIVER
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+
 SRC_DIRS = gallium mesa glu glut/fbdev
 DRIVER_DIRS = fbdev osmesa
 PROGRAM_DIRS = fbdev demos redbook samples
index 0a40521e1b7d7d9ae14374bc8e74913b1bd698d0..31475c81d847da4a012bb0a55e982de083046eeb 100644 (file)
@@ -12,6 +12,9 @@ CFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE
 CXXFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
 GLUT_CFLAGS = -fexceptions
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
 
 # Library/program dependencies
 GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -L/usr/local/glide/lib -lglide3x -lm -lpthread
index 0c4805ea87cc7e500678e870bc95c6b3c61b14ce..310ae6dde63d070f137e8a5534fdd897f8c221cb 100644 (file)
@@ -33,6 +33,9 @@ CFLAGS   = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
 
 CXXFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES)
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
 
 MESA_ASM_SOURCES = 
 
index 0382a19553a835c23409fb303d75b6040ed49d7e..c112642f8991f257426c8f39a272f23422233117 100644 (file)
@@ -12,6 +12,9 @@ CXX = g++
 CFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DPTHREADS
 CXXFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
 
 # Directories
 SRC_DIRS = gallium mesa glu
@@ -22,4 +25,4 @@ PROGRAM_DIRS = osdemos
 # Dependencies
 OSMESA_LIB_DEPS = -lm -lpthread
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(OSMESA_LIB)
-APP_LIB_DEPS = -lOSMesa -lGLU
+APP_LIB_DEPS = -lm -lpthread
index 9a527592f1d156fc7d1c3eaef69efc959d7e1b6a..b3c8da0991606a29a4f7dce68849e9e9015b33b6 100644 (file)
@@ -10,6 +10,9 @@ 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
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
 
 # Library names
 OSMESA_LIB = OSMesa16
@@ -25,4 +28,4 @@ PROGRAM_DIRS =
 # Dependencies
 OSMESA_LIB_DEPS = -lm -lpthread
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(OSMESA_LIB)
-APP_LIB_DEPS = -lOSMesa16
+APP_LIB_DEPS = -lm -lpthread
index 1e6380b02e078098f0f071cbe2cedb5fb005604f..146aeb85a6f32e191aeeecbed91bbf5b9754c434 100644 (file)
@@ -10,7 +10,11 @@ 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
+PIC_FLAGS =
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
 
 # Library names
 OSMESA_LIB = OSMesa16
@@ -25,4 +29,4 @@ PROGRAM_DIRS =
 
 # Dependencies
 OSMESA_LIB_DEPS = -lm -lpthread
-APP_LIB_DEPS = -lOSMesa16
+APP_LIB_DEPS = -lm -lpthread
index f0ef1831b0909595d00875ab0abb8d1a6c9e7361..5804ef8e5f77d9e47c7d52588dccec83381c7b09 100644 (file)
@@ -10,6 +10,9 @@ 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
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
 
 # Library names
 OSMESA_LIB = OSMesa32
@@ -25,4 +28,4 @@ PROGRAM_DIRS =
 # Dependencies
 OSMESA_LIB_DEPS = -lm -lpthread
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(OSMESA_LIB)
-APP_LIB_DEPS = -lOSMesa32
+APP_LIB_DEPS = -lm -lpthread
index d0e168811f84af6060133faf5fb6519749642549..3f3dc5564370aa92e37a59cc1554f9ba21f822ad 100644 (file)
@@ -5,6 +5,7 @@ include $(TOP)/configs/linux-ppc
 CONFIG_NAME = linux-ppc-static
 
 MKLIB_OPTIONS = -static
+PIC_FLAGS =
 
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
index 3145e1277575fa8d5494a98cbf9a64ed348fd08b..4be7680ca59e6fddf5daaec29eff956b20e6ec36 100644 (file)
@@ -32,6 +32,9 @@ CFLAGS   = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
 
 CXXFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES)
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
 
 MESA_ASM_SOURCES = 
 
index 5f5aa09c82640f4e4dc0eaa22d61e1c41b019a49..a9bf388260242a4ac6026b39e72cc6009b9ce69b 100644 (file)
@@ -5,9 +5,6 @@ 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
 MESA_ASM_SOURCES = $(X86_SOURCES)
 GLAPI_ASM_SOURCES = $(X86_API)
index d5fbe9cf6511550821e69c1401b906ab46663d81..2fc39ff83ef2e23014a83a118b0572baa9fbc911 100644 (file)
@@ -5,6 +5,7 @@ include $(TOP)/configs/linux
 CONFIG_NAME = linux-static
 
 MKLIB_OPTIONS = -static
+PIC_FLAGS =
 
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
@@ -23,5 +24,5 @@ GLW_LIB_DEPS =
 # Need to specify all libraries we may need
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -Wl,--start-group \
        -l$(GL_LIB) $(TOP)/src/mesa/pipe/softpipe/libsoftpipe.a -Wl,--end-group -lm \
-       -L/usr/X11R6/lib/ -lX11 -lXmu -lXi -lpthread
+       -L/usr/X11R6/lib/ -lX11 -lXext -lXmu -lXi -lpthread
 
index 909965da36878b58d7defe8521af108f574d0a8e..626d579ac0ef562cd84bd5f6d1ff31dc0690f657 100644 (file)
@@ -5,6 +5,7 @@ include $(TOP)/configs/linux-x86-64
 CONFIG_NAME = linux-x86-64-static
 
 MKLIB_OPTIONS = -static
+PIC_FLAGS =
 
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
@@ -23,4 +24,4 @@ GLW_LIB_DEPS =
 # Need to specify all libraries we may need
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -Wl,--start-group \
                -l$(GL_LIB) $(TOP)/src/mesa/pipe/softpipe/libsoftpipe.a -Wl,--end-group \
-               $(EXTRA_LIB_PATH) -lX11 -lXmu -lXt -lXi -lpthread -lstdc++ -lm
+               $(EXTRA_LIB_PATH) -lX11 -lXext -lXmu -lXt -lXi -lpthread -lstdc++ -lm
index b963fbdc66b06310493f9a9c86c10fd3ae943d74..603b2bf758b91fa9b405f8f05edffb76cac5f75d 100644 (file)
@@ -14,6 +14,9 @@ CXXFLAGS = -Wall -O3 -ansi -pedantic -fPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199
 
 GLUT_CFLAGS = -fexceptions
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
 
 MESA_ASM_SOURCES = $(X86_SOURCES)
 GLAPI_ASM_SOURCES = $(X86_API)
index 3b281e6685efc72604deb008b4b9d2e8150d363e..65c92cf3524cbe18b4df838925b235140c92cfeb 100644 (file)
@@ -5,6 +5,7 @@ include $(TOP)/configs/linux-x86
 CONFIG_NAME = linux-x86-static
 
 MKLIB_OPTIONS = -static
+PIC_FLAGS =
 
 # Library names (actual file names)
 GL_LIB_NAME = libGL.a
@@ -23,4 +24,4 @@ GLW_LIB_DEPS =
 # Need to specify all libraries we may need
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -Wl,--start-group \
                -l$(GL_LIB) $(TOP)/src/mesa/pipe/softpipe/libsoftpipe.a -Wl,--end-group \
-               $(EXTRA_LIB_PATH) -lX11 -lXmu -lXt -lXi -lpthread -lstdc++ -lm
+               $(EXTRA_LIB_PATH) -lX11 -lXext -lXmu -lXt -lXi -lpthread -lstdc++ -lm
index f5a61a89570af163b532c6f7d5714b456fb878fd..aec45695071b534c09a7b837c5fb1f11f29848e0 100644 (file)
@@ -12,3 +12,6 @@ CXXFLAGS = -O2 -fPIC
 GLUT_CFLAGS = -fexceptions
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -L/usr/X11R6/lib -lXext -lXmu -lXi -lX11 -lm
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
index 6ad6e2bd3d093ee360cbd560a985dc07e276a3e5..bd19fa84d39e8785ff5ce88b006a7ef22ee05038 100644 (file)
@@ -10,6 +10,10 @@ CXX = g++
 CFLAGS = -O2 -fPIC -I/usr/X11R6/include -DUSE_XSHM -DHZ=100
 CXXFLAGS = -O2 -fPIC -I/usr/X11R6/include -DHZ=100
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
+
 GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm
 OSMESA_LIB_DEPS = -lm
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB)
index 5ec7237f991af9ef1b3daf5d516454bdd3516aeb..616bfdfd778967090fd4799a9d62aa4eb9100e75 100644 (file)
@@ -11,6 +11,10 @@ CFLAGS = -O3 -march=i486 -fPIC -I/usr/openwin/include -DUSE_XSHM
 CXXFLAGS = -O3 -march=i486 -fPIC
 GLUT_CFLAGS = -fexceptions
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
+
 GL_LIB_DEPS = -L/usr/openwin/lib -lX11 -lXext -lm -lpthread
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm
 GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/openwin/lib -lX11 -lXmu -lXt -lXi -lm
index be02735f028c6d65afb2a090172d685be858a73c..4850284a59f979739d3ca96cb17fb32ad7b8d950 100644 (file)
@@ -12,6 +12,10 @@ CXXFLAGS = -O3 -march=i486 -fPIC
 GLUT_CFLAGS = -fexceptions
 MKLIB_OPTIONS = -static
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
+
 GL_LIB_DEPS = -L/usr/openwin/lib -lX11 -lXext -lm -lpthread
 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm
 GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/openwin/lib -lX11 -lXmu -lXt -lXi -lm
index 2022dd7e8e7d40fd692c87f54a3dec0e55733793..0942291589463df8ba66113194964ad31e857540 100644 (file)
@@ -11,5 +11,9 @@ CFLAGS = -fPIC -O3 -I/usr/openwin/include -I/usr/include/X11R5 -I/usr/include/X1
 CXXFLAGS = -fPIC -O3 -I/usr/openwin/include -DSUNOS4
 GLUT_CFLAGS = -fexceptions -DSOLARIS_2_4_BUG
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
+
 APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -L/usr/openwin/lib -lX11 -lXext -lXmu -lXi -lm
 
index 3fa13d0496f71c78b76d38f08b90e115a62710be..571ff24a2b17f9301d682cb77c744c9ab5932c0e 100644 (file)
@@ -28,6 +28,10 @@ CXXFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
 
 GLUT_CFLAGS = -fexceptions -DSOLARIS_2_4_BUG
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
+
 # Library/program dependencies
 EXTRA_LIB_PATH=-L/usr/openwin/lib
 
diff --git a/configs/sunos5-v9-cc-g++ b/configs/sunos5-v9-cc-g++
new file mode 100644 (file)
index 0000000..8656251
--- /dev/null
@@ -0,0 +1,35 @@
+# Configuration for SunOS 5, SPARC V9 and cc/g++ (for C and C++ sources)
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = sunos5-v9-cc-g++
+
+MKLIB_OPTIONS = -cplusplus
+
+LIB_DIR = lib64
+
+# Compiler and flags
+CC = cc
+CXX = g++
+
+CXX_WARN_FLAGS = -Wall
+CXX_PIC_FLAGS  = -fPIC
+CXX_OPT_FLAGS  = -O3 -m64 -mcpu=ultrasparc -mv8plus -mvis -g -fomit-frame-pointer -pipe
+CXX_ARCH_FLAGS = -m64
+
+
+CXXFLAGS = $(CXX_WARN_FLAGS) $(CXX_OPT_FLAGS) $(CXX_PIC_FLAGS) $(CXX_ARCH_FLAGS) $(DEFINES) \
+        -I/usr/openwin/include
+
+# Work around aliasing bugs - developers should comment this out
+CXXFLAGS += -fno-strict-aliasing
+
+CFLAGS = -xarch=v9 -KPIC -O -I/usr/openwin/include -I/usr/dt/include -DUSE_XSHM -DPTHREADS
+#CXXFLAGS = -xarch=v9 -KPIC -O -I/usr/openwin/include -I/usr/dt/include -DPTHREADS
+GLUT_CFLAGS = -DSOLARIS_2_4_BUG
+
+GL_LIB_DEPS = -L/usr/openwin/lib -L/usr/dt/lib -lX11 -lXext -lXmu -lXi -lm -lpthread
+GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm -lCstd -lCrun
+GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lm
+GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L/usr/openwin/lib -lXt -lX11
+APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -lX11 -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
index 5c0f22d7ae746b01bc59bbeb7ebaaf14463db6b1..455b6932d373345b8b228a9082fa6678ac55e26e 100644 (file)
@@ -12,6 +12,10 @@ CXXFLAGS = -pedantic -O2
 GLUT_CFLAGS = -fexceptions
 MKLIB_OPTIONS = -static
 
+# Work around aliasing bugs - developers should comment this out
+CFLAGS += -fno-strict-aliasing
+CXXFLAGS += -fno-strict-aliasing
+
 GL_LIB_NAME = libGL.a
 GLU_LIB_NAME = libGLU.a
 GLUT_LIB_NAME = libglut.a
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..463821b
--- /dev/null
@@ -0,0 +1,1068 @@
+dnl Process this file with autoconf to create configure.
+
+AC_PREREQ([2.59])
+
+dnl Versioning - scrape the version from configs/default
+m4_define([mesa_version],
+    [m4_esyscmd([${MAKE-make} -s -f bin/version.mk version | tr -d '\n'])])
+m4_ifval(mesa_version,[],[
+    m4_errprint([Error: Failed to get the Mesa version from the output of
+       running `make -f bin/version.mk version'
+])
+    m4_exit([1])
+])
+
+dnl Tell the user about autoconf.html in the --help output
+m4_divert_once([HELP_END], [
+See docs/autoconf.html for more details on the options for Mesa.])
+
+AC_INIT([Mesa],[mesa_version],
+    [https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa])
+AC_CONFIG_AUX_DIR([bin])
+AC_CANONICAL_HOST
+
+dnl Versions for external dependencies
+LIBDRM_REQUIRED=2.3.1
+DRI2PROTO_REQUIRED=1.99.1
+
+dnl Check for progs
+AC_PROG_CPP
+AC_PROG_CC
+AC_PROG_CXX
+AC_CHECK_PROGS([MAKE], [gmake make])
+AC_PATH_PROG([MKDEP], [makedepend])
+AC_PATH_PROG([SED], [sed])
+
+dnl We need a POSIX shell for parts of the build. Assume we have one
+dnl in most cases.
+case "$host_os" in
+solaris*)
+    # Solaris /bin/sh is too old/non-POSIX compliant
+    AC_PATH_PROGS(POSIX_SHELL, [ksh93 ksh sh])
+    SHELL="$POSIX_SHELL"
+    ;;
+esac
+
+MKDEP_OPTIONS=-fdepend
+dnl Ask gcc where it's keeping its secret headers
+if test "x$GCC" = xyes; then
+    GCC_INCLUDES=`$CC -print-file-name=include`
+    if test "x$GCC_INCLUDES" != x; then
+        MKDEP_OPTIONS="$MKDEP_OPTIONS -I$GCC_INCLUDES"
+    fi
+fi
+AC_SUBST([MKDEP_OPTIONS])
+
+dnl Make sure the pkg-config macros are defined
+m4_ifdef([PKG_PROG_PKG_CONFIG],[],[
+    m4_errprint([Error: Could not locate the pkg-config autoconf macros.
+       These are usually located in /usr/share/aclocal/pkg.m4. If your
+       macros are in a different location, try setting the environment
+       variable ACLOCAL="aclocal -I/other/macro/dir" before running
+       autoreconf.
+])
+    m4_exit([1])
+])
+PKG_PROG_PKG_CONFIG()
+
+dnl LIB_DIR - library basename
+LIB_DIR=`echo $libdir | $SED 's%.*/%%'`
+AC_SUBST([LIB_DIR])
+
+dnl Cache LDFLAGS so we can add EXTRA_LIB_PATH and restore it later
+_SAVE_LDFLAGS="$LDFLAGS"
+AC_ARG_VAR([EXTRA_LIB_PATH],[Extra -L paths for the linker])
+AC_SUBST([EXTRA_LIB_PATH])
+
+dnl Cache CPPFLAGS so we can add *_INCLUDES and restore it later
+_SAVE_CPPFLAGS="$CPPFLAGS"
+AC_ARG_VAR([X11_INCLUDES],[Extra -I paths for X11 headers])
+AC_SUBST([X11_INCLUDES])
+
+dnl Compiler macros
+DEFINES=""
+AC_SUBST([DEFINES])
+case "$host_os" in
+linux*)
+if test "x$GCC" = xyes; then
+    DEFINES="$DEFINES -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE"
+fi
+    DEFINES="$DEFINES -D_SVID_SOURCE -D_GNU_SOURCE -DPTHREADS"
+    ;;
+solaris*)
+    DEFINES="$DEFINES -DPTHREADS -DSVR4"
+    ;;
+esac
+
+dnl Add flags for gcc and g++
+if test "x$GCC" = xyes; then
+    CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math"
+
+    # Work around aliasing bugs - developers should comment this out
+    CFLAGS="$CFLAGS -fno-strict-aliasing"
+fi
+if test "x$GXX" = xyes; then
+    CXXFLAGS="$CXXFLAGS -Wall"
+
+    # Work around aliasing bugs - developers should comment this out
+    CXXFLAGS="$CXXFLAGS -fno-strict-aliasing"
+fi
+
+dnl These should be unnecessary, but let the user set them if they want
+AC_ARG_VAR([OPT_FLAGS], [Additional optimization flags for the compiler.
+    Default is to use CFLAGS.])
+AC_ARG_VAR([ARCH_FLAGS], [Additional architecture specific flags for the
+    compiler. Default is to use CFLAGS.])
+AC_SUBST([OPT_FLAGS])
+AC_SUBST([ARCH_FLAGS])
+
+dnl
+dnl Hacks to enable 32 or 64 bit build
+dnl
+AC_ARG_ENABLE([32-bit],
+    [AS_HELP_STRING([--enable-32-bit],
+        [build 32-bit libraries @<:@default=auto@:>@])],
+    [enable_32bit="$enableval"],
+    [enable_32bit=auto]
+)
+if test "x$enable_32bit" = xyes; then
+    if test "x$GCC" = xyes; then
+        CFLAGS="$CFLAGS -m32"
+    fi
+    if test "x$GXX" = xyes; then
+        CXXFLAGS="$CXXFLAGS -m32"
+    fi
+fi
+AC_ARG_ENABLE([64-bit],
+    [AS_HELP_STRING([--enable-64-bit],
+        [build 64-bit libraries @<:@default=auto@:>@])],
+    [enable_64bit="$enableval"],
+    [enable_64bit=auto]
+)
+if test "x$enable_64bit" = xyes; then
+    if test "x$GCC" = xyes; then
+        CFLAGS="$CFLAGS -m64"
+    fi
+    if test "x$GXX" = xyes; then
+        CXXFLAGS="$CXXFLAGS -m64"
+    fi
+fi
+
+dnl
+dnl shared/static libraries, mimic libtool options
+dnl
+AC_ARG_ENABLE([static],
+    [AS_HELP_STRING([--enable-static],
+        [build static libraries @<:@default=disabled@:>@])],
+    [enable_static="$enableval"],
+    [enable_static=no]
+)
+case "x$enable_static" in
+xyes|xno ) ;;
+x ) enable_static=no ;;
+* )
+    AC_MSG_ERROR([Static library option '$enable_static' is not a valid])
+    ;;
+esac
+AC_ARG_ENABLE([shared],
+    [AS_HELP_STRING([--disable-shared],
+        [build shared libraries @<:@default=enabled@:>@])],
+    [enable_shared="$enableval"],
+    [enable_shared=yes]
+)
+case "x$enable_shared" in
+xyes|xno ) ;;
+x ) enable_shared=yes ;;
+* )
+    AC_MSG_ERROR([Shared library option '$enable_shared' is not a valid])
+    ;;
+esac
+
+dnl Can't have static and shared libraries, default to static if user
+dnl explicitly requested. If both disabled, set to static since shared
+dnl was explicitly requirested.
+case "x$enable_static$enable_shared" in
+xyesyes )
+    AC_MSG_WARN([Can't build static and shared libraries, disabling shared])
+    enable_shared=no
+    ;;
+xnono )
+    AC_MSG_WARN([Can't disable both static and shared libraries, enabling static])
+    enable_static=yes
+    ;;
+esac
+
+dnl
+dnl mklib options
+dnl
+AC_ARG_VAR([MKLIB_OPTIONS],[Options for the Mesa library script, mklib])
+if test "$enable_static" = yes; then
+    MKLIB_OPTIONS="$MKLIB_OPTIONS -static"
+fi
+AC_SUBST([MKLIB_OPTIONS])
+
+dnl
+dnl other compiler options
+dnl
+AC_ARG_ENABLE([debug],
+    [AS_HELP_STRING([--enable-debug],
+        [use debug compiler flags and macros @<:@default=disabled@:>@])],
+    [enable_debug="$enableval"],
+    [enable_debug=no]
+)
+if test "x$enable_debug" = xyes; then
+    DEFINES="$DEFINES -DDEBUG"
+    if test "x$GCC" = xyes; then
+        CFLAGS="$CFLAGS -g"
+    fi
+    if test "x$GXX" = xyes; then
+        CXXFLAGS="$CXXFLAGS -g"
+    fi
+fi
+
+dnl
+dnl library names
+dnl
+if test "$enable_static" = yes; then
+    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_LIB).a'
+else
+    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'
+fi
+AC_SUBST([GL_LIB_NAME])
+AC_SUBST([GLU_LIB_NAME])
+AC_SUBST([GLUT_LIB_NAME])
+AC_SUBST([GLW_LIB_NAME])
+AC_SUBST([OSMESA_LIB_NAME])
+
+dnl
+dnl Arch/platform-specific settings
+dnl
+AC_ARG_ENABLE([asm],
+    [AS_HELP_STRING([--disable-asm],
+        [disable assembly usage @<:@default=enabled on supported plaforms@:>@])],
+    [enable_asm="$enableval"],
+    [enable_asm=yes]
+)
+asm_arch=""
+ASM_FLAGS=""
+ASM_SOURCES=""
+ASM_API=""
+AC_MSG_CHECKING([whether to enable assembly])
+test "x$enable_asm" = xno && AC_MSG_RESULT([no])
+# disable if cross compiling on x86/x86_64 since we must run gen_matypes
+if test "x$enable_asm" = xyes && test "x$cross_compiling" = xyes; then
+    case "$host_cpu" in
+    i?86 | x86_64)
+        enable_asm=no
+        AC_MSG_RESULT([no, cross compiling])
+        ;;
+    esac
+fi
+# check for supported arches
+if test "x$enable_asm" = xyes; then
+    case "$host_cpu" in
+    i?86)
+        case "$host_os" in
+        linux* | freebsd* | dragonfly*)
+            test "x$enable_64bit" = xyes && asm_arch=x86_64 || asm_arch=x86
+            ;;
+        esac
+        ;;
+    x86_64)
+        case "$host_os" in
+        linux* | freebsd* | dragonfly*)
+            test "x$enable_32bit" = xyes && asm_arch=x86 || asm_arch=x86_64
+            ;;
+        esac
+        ;;
+    powerpc)
+        case "$host_os" in
+        linux*)
+            asm_arch=ppc
+            ;;
+        esac
+        ;;
+    esac
+
+    case "$asm_arch" in
+    x86)
+        ASM_FLAGS="-DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM"
+        ASM_SOURCES='$(X86_SOURCES)'
+        ASM_API='$(X86_API)'
+        AC_MSG_RESULT([yes, x86])
+        ;;
+    x86_64)
+        ASM_FLAGS="-DUSE_X86_64_ASM"
+        ASM_SOURCES='$(X86-64_SOURCES)'
+        ASM_API='$(X86-64_API)'
+        AC_MSG_RESULT([yes, x86_64])
+        ;;
+    ppc)
+        ASM_FLAGS="-DUSE_PPC_ASM -DUSE_VMX_ASM"
+        ASM_SOURCES='$(PPC_SOURCES)'
+        AC_MSG_RESULT([yes, ppc])
+        ;;
+    *)
+        AC_MSG_RESULT([no, platform not supported])
+        ;;
+    esac
+fi
+AC_SUBST([ASM_FLAGS])
+AC_SUBST([ASM_SOURCES])
+AC_SUBST([ASM_API])
+
+dnl PIC code macro
+MESA_PIC_FLAGS
+
+dnl Check to see if dlopen is in default libraries (like Solaris, which
+dnl has it in libc), or if libdl is needed to get it.
+AC_CHECK_FUNC([dlopen], [],
+    [AC_CHECK_LIB([dl], [dlopen], [DLOPEN_LIBS="-ldl"])])
+
+dnl See if posix_memalign is available
+AC_CHECK_FUNC([posix_memalign], [DEFINES="$DEFINES -DHAVE_POSIX_MEMALIGN"])
+
+dnl SELinux awareness.
+AC_ARG_ENABLE([selinux],
+    [AS_HELP_STRING([--enable-selinux],
+        [Build SELinux-aware Mesa @<:@default=disabled@:>@])],
+    [MESA_SELINUX="$enableval"],
+    [MESA_SELINUX=no])
+if test "x$enable_selinux" = "xyes"; then
+    AC_CHECK_HEADER([selinux/selinux.h],[],
+                    [AC_MSG_ERROR([SELinux headers not found])])
+    AC_CHECK_LIB([selinux],[is_selinux_enabled],[],
+                 [AC_MSG_ERROR([SELinux library not found])])
+    SELINUX_LIBS="-lselinux"
+    DEFINES="$DEFINES -DMESA_SELINUX"
+fi
+
+dnl OS-specific libraries
+OS_LIBS=""
+case "$host_os" in
+solaris*)
+    OS_LIBS="-lc"
+    if test "x$GXX" != xyes; then
+        OS_CPLUSPLUS_LIBS="-lCrun $OS_LIBS"
+    fi
+    ;;
+esac
+
+dnl
+dnl Driver configuration. Options are xlib, dri and osmesa right now.
+dnl More later: directfb, fbdev, ...
+dnl
+default_driver="xlib"
+
+case "$host_os" in
+linux*)
+    case "$host_cpu" in
+    i*86|x86_64|powerpc*) default_driver="dri";;
+    esac
+    ;;
+freebsd* | dragonfly*)
+    case "$host_cpu" in
+    i*86|x86_64) default_driver="dri";;
+    esac
+    ;;
+esac
+
+AC_ARG_WITH([driver],
+    [AS_HELP_STRING([--with-driver=DRIVER],
+        [driver for Mesa: xlib,dri,osmesa @<:@default=dri when available, or xlib@:>@])],
+    [mesa_driver="$withval"],
+    [mesa_driver="$default_driver"])
+dnl Check for valid option
+case "x$mesa_driver" in
+xxlib|xdri|xosmesa)
+    ;;
+*)
+    AC_MSG_ERROR([Driver '$mesa_driver' is not a valid option])
+    ;;
+esac
+
+dnl
+dnl Driver specific build directories
+dnl
+SRC_DIRS="mesa"
+GLU_DIRS="sgi"
+WINDOW_SYSTEM=""
+case "$mesa_driver" in
+xlib)
+    DRIVER_DIRS="x11"
+    ;;
+dri)
+    SRC_DIRS="glx/x11 $SRC_DIRS"
+    DRIVER_DIRS="dri"
+    WINDOW_SYSTEM="dri"
+    ;;
+osmesa)
+    DRIVER_DIRS="osmesa"
+    ;;
+esac
+AC_SUBST([SRC_DIRS])
+AC_SUBST([GLU_DIRS])
+AC_SUBST([DRIVER_DIRS])
+AC_SUBST([WINDOW_SYSTEM])
+
+dnl
+dnl User supplied program configuration
+dnl
+if test -d "$srcdir/progs/demos"; then
+    default_demos=yes
+else
+    default_demos=no
+fi
+AC_ARG_WITH([demos],
+    [AS_HELP_STRING([--with-demos@<:@=DIRS...@:>@],
+        [optional comma delimited demo directories to build
+        @<:@default=auto if source available@:>@])],
+    [with_demos="$withval"],
+    [with_demos="$default_demos"])
+if test "x$with_demos" = x; then
+    with_demos=no
+fi
+
+dnl If $with_demos is yes, directories will be added as libs available
+PROGRAM_DIRS=""
+case "$with_demos" in
+no) ;;
+yes)
+    # If the driver isn't osmesa, we have libGL and can build xdemos
+    if test "$mesa_driver" != osmesa; then
+        PROGRAM_DIRS="xdemos"
+    fi
+    ;;
+*)
+    # verify the requested demos directories exist
+    demos=`IFS=,; echo $with_demos`
+    for demo in $demos; do
+        test -d "$srcdir/progs/$demo" || \
+            AC_MSG_ERROR([Program directory '$demo' doesn't exist])
+    done
+    PROGRAM_DIRS="$demos"
+    ;;
+esac
+
+dnl
+dnl Find out if X is available. The variable have_x is set if libX11 is
+dnl found to mimic AC_PATH_XTRA.
+dnl
+if test -n "$PKG_CONFIG"; then
+    AC_MSG_CHECKING([pkg-config files for X11 are available])
+    PKG_CHECK_EXISTS([x11],[
+        x11_pkgconfig=yes
+        have_x=yes
+        ],[
+        x11_pkgconfig=no
+    ])
+    AC_MSG_RESULT([$x11_pkgconfig])
+else
+    x11_pkgconfig=no
+fi
+dnl Use the autoconf macro if no pkg-config files
+if test "$x11_pkgconfig" = no; then
+    AC_PATH_XTRA
+fi
+
+dnl Try to tell the user that the --x-* options are only used when
+dnl pkg-config is not available. This must be right after AC_PATH_XTRA.
+m4_divert_once([HELP_BEGIN],
+[These options are only used when the X libraries cannot be found by the
+pkg-config utility.])
+
+dnl We need X for xlib and dri, so bomb now if it's not found
+case "$mesa_driver" in
+xlib|dri)
+    if test "$no_x" = yes; then
+        AC_MSG_ERROR([X11 development libraries needed for $mesa_driver driver])
+    fi
+    ;;
+esac
+
+dnl XCB - this is only used for GLX right now
+AC_ARG_ENABLE([xcb],
+    [AS_HELP_STRING([--enable-xcb],
+        [use XCB for GLX @<:@default=disabled@:>@])],
+    [enable_xcb="$enableval"],
+    [enable_xcb=no])
+if test "x$enable_xcb" = xyes; then
+    DEFINES="$DEFINES -DUSE_XCB"
+else
+    enable_xcb=no
+fi
+
+dnl
+dnl libGL configuration per driver
+dnl
+case "$mesa_driver" in
+xlib)
+    if test "$x11_pkgconfig" = yes; then
+        PKG_CHECK_MODULES([XLIBGL], [x11 xext])
+        X11_INCLUDES="$X11_INCLUDES $XLIBGL_CFLAGS"
+        GL_LIB_DEPS="$XLIBGL_LIBS"
+    else
+        # should check these...
+        X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
+        GL_LIB_DEPS="$X_LIBS -lX11 -lXext"
+    fi
+    GL_LIB_DEPS="$GL_LIB_DEPS $SELINUX_LIBS -lm -lpthread $OS_LIBS"
+
+    # if static, move the external libraries to the programs
+    # and empty the libraries for libGL
+    if test "$enable_static" = yes; then
+        APP_LIB_DEPS="$APP_LIB_DEPS $GL_LIB_DEPS"
+        GL_LIB_DEPS=""
+    fi
+    ;;
+dri)
+    # DRI must be shared, I think
+    if test "$enable_static" = yes; then
+        AC_MSG_ERROR([Can't use static libraries for DRI drivers])
+    fi
+
+    # Check for libdrm
+    PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED])
+    PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED])
+
+    # find the DRI deps for libGL
+    if test "$x11_pkgconfig" = yes; then
+        # add xcb modules if necessary
+        dri_modules="x11 xext xxf86vm xdamage xfixes"
+        if test "$enable_xcb" = yes; then
+            dri_modules="$dri_modules x11-xcb xcb-glx"
+        fi
+
+        PKG_CHECK_MODULES([DRIGL], [$dri_modules])
+        X11_INCLUDES="$X11_INCLUDES $DRIGL_CFLAGS"
+        GL_LIB_DEPS="$DRIGL_LIBS"
+    else
+        # should check these...
+        X11_INCLUDES="$X11_INCLUDES $X_CFLAGS"
+        GL_LIB_DEPS="$X_LIBS -lX11 -lXext -lXxf86vm -lXdamage -lXfixes"
+
+        # XCB can only be used from pkg-config
+        if test "$enable_xcb" = yes; then
+            PKG_CHECK_MODULES([XCB],[x11-xcb xcb-glx])
+            X11_INCLUDES="$X11_INCLUDES $XCB_CFLAGS"
+            GL_LIB_DEPS="$GL_LIB_DEPS $XCB_LIBS"
+        fi
+    fi
+
+    # need DRM libs, -lpthread, etc.
+    GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS $OS_LIBS"
+    ;;
+osmesa)
+    # No libGL for osmesa
+    GL_LIB_DEPS="$OS_LIBS"
+    ;;
+esac
+AC_SUBST([GL_LIB_DEPS])
+
+dnl
+dnl More X11 setup
+dnl
+if test "$mesa_driver" = xlib; then
+    DEFINES="$DEFINES -DUSE_XSHM"
+fi
+
+dnl
+dnl More DRI setup
+dnl
+AC_ARG_ENABLE([glx-tls],
+    [AS_HELP_STRING([--enable-glx-tls],
+        [enable TLS support in GLX @<:@default=disabled@:>@])],
+    [GLX_USE_TLS="$enableval"],
+    [GLX_USE_TLS=no])
+dnl Directory for DRI drivers
+AC_ARG_WITH([dri-driverdir],
+    [AS_HELP_STRING([--with-dri-driverdir=DIR],
+        [directory for the DRI drivers @<:@${libdir}/dri@:>@])],
+    [DRI_DRIVER_INSTALL_DIR="$withval"],
+    [DRI_DRIVER_INSTALL_DIR='${libdir}/dri'])
+AC_SUBST([DRI_DRIVER_INSTALL_DIR])
+dnl Direct rendering or just indirect rendering
+AC_ARG_ENABLE([driglx-direct],
+    [AS_HELP_STRING([--disable-driglx-direct],
+        [enable direct rendering in GLX for DRI @<:@default=enabled@:>@])],
+    [driglx_direct="$enableval"],
+    [driglx_direct="yes"])
+dnl Which drivers to build - default is chosen by platform
+AC_ARG_WITH([dri-drivers],
+    [AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
+        [comma delimited DRI drivers list, e.g.
+        "swrast,i965,radeon,nouveau" @<:@default=auto@:>@])],
+    [with_dri_drivers="$withval"],
+    [with_dri_drivers=yes])
+if test "x$with_dri_drivers" = x; then
+    with_dri_drivers=no
+fi
+
+dnl If $with_dri_drivers is yes, directories will be added through
+dnl platform checks
+DRI_DIRS=""
+case "$with_dri_drivers" in
+no) ;;
+yes)
+    DRI_DIRS="yes"
+    ;;
+*)
+    # verify the requested driver directories exist
+    dri_drivers=`IFS=', '; echo $with_dri_drivers`
+    for driver in $dri_drivers; do
+        test -d "$srcdir/src/mesa/drivers/dri/$driver" || \
+            AC_MSG_ERROR([DRI driver directory '$driver' doesn't exist])
+    done
+    DRI_DIRS="$dri_drivers"
+    ;;
+esac
+
+dnl Just default to no EGL for now
+USING_EGL=0
+AC_SUBST([USING_EGL])
+
+dnl Set DRI_DIRS, DEFINES and LIB_DEPS
+if test "$mesa_driver" = dri; then
+    # Use TLS in GLX?
+    if test "x$GLX_USE_TLS" = xyes; then
+        DEFINES="$DEFINES -DGLX_USE_TLS -DPTHREADS"
+    fi
+
+    if test "x$USING_EGL" = x1; then
+        PROGRAM_DIRS="egl"
+    fi
+
+    # Platform specific settings and drivers to build
+    case "$host_os" in
+    linux*)
+        DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
+        DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS"
+        if test "x$driglx_direct" = xyes; then
+            DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
+        fi
+
+        case "$host_cpu" in
+        x86_64)
+            # ffb, gamma, and sis are missing because they have not be
+            # converted to use the new interface.  i810 are missing
+            # because there is no x86-64 system where they could *ever*
+            # be used.
+            if test "x$DRI_DIRS" = "xyes"; then
+                DRI_DIRS="i915 i965 mach64 mga r128 r200 r300 radeon \
+                    savage tdfx unichrome swrast"
+            fi
+            ;;
+        powerpc*)
+            # Build only the drivers for cards that exist on PowerPC.
+            # At some point MGA will be added, but not yet.
+            if test "x$DRI_DIRS" = "xyes"; then
+                DRI_DIRS="mach64 r128 r200 r300 radeon tdfx swrast"
+            fi
+            ;;
+        sparc*)
+            # Build only the drivers for cards that exist on sparc`
+            if test "x$DRI_DIRS" = "xyes"; then
+                DRI_DIRS="mach64 r128 r200 r300 radeon ffb swrast"
+            fi
+            ;;
+        esac
+        ;;
+    freebsd* | dragonfly*)
+        DEFINES="$DEFINES -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1"
+        DEFINES="$DEFINES -DIN_DRI_DRIVER -DHAVE_ALIAS"
+        DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
+        if test "x$driglx_direct" = xyes; then
+            DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
+        fi
+        if test "x$GXX" = xyes; then
+            CXXFLAGS="$CXXFLAGS -ansi -pedantic"
+        fi
+
+        # ffb and gamma are missing because they have not been converted
+        # to use the new interface.
+        if test "x$DRI_DIRS" = "xyes"; then
+            DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon tdfx \
+                unichrome savage sis swrast"
+        fi
+        ;;
+    solaris*)
+        DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER"
+        DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING"
+        if test "x$driglx_direct" = xyes; then
+            DEFINES="$DEFINES -DGLX_DIRECT_RENDERING"
+        fi
+        ;;
+    esac
+
+    # default drivers
+    if test "x$DRI_DIRS" = "xyes"; then
+        DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
+            savage sis tdfx trident unichrome ffb swrast"
+    fi
+
+    DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/  */ /g'`
+
+    # Check for expat
+    EXPAT_INCLUDES=""
+    EXPAT_LIB=-lexpat
+    AC_ARG_WITH([expat],
+        [AS_HELP_STRING([--with-expat=DIR],
+            [expat install directory])],[
+        EXPAT_INCLUDES="-I$withval/include"
+        CPPFLAGS="$CPPFLAGS $EXPAT_INCLUDES"
+        LDFLAGS="$LDFLAGS -L$withval/$LIB_DIR"
+        EXPAT_LIB="-L$withval/$LIB_DIR -lexpat"
+        ])
+    AC_CHECK_HEADER([expat.h],[],[AC_MSG_ERROR([Expat required for DRI.])])
+    AC_CHECK_LIB([expat],[XML_ParserCreate],[],
+        [AC_MSG_ERROR([Expat required for DRI.])])
+
+    # put all the necessary libs together
+    DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS"
+fi
+AC_SUBST([DRI_DIRS])
+AC_SUBST([EXPAT_INCLUDES])
+AC_SUBST([DRI_LIB_DEPS])
+
+dnl
+dnl OSMesa configuration
+dnl
+if test "$mesa_driver" = xlib; then
+    default_gl_osmesa=yes
+else
+    default_gl_osmesa=no
+fi
+AC_ARG_ENABLE([gl-osmesa],
+    [AS_HELP_STRING([--enable-gl-osmesa],
+        [enable OSMesa on libGL @<:@default=enabled for xlib driver@:>@])],
+    [gl_osmesa="$enableval"],
+    [gl_osmesa="$default_gl_osmesa"])
+if test "x$gl_osmesa" = xyes; then
+    if test "$mesa_driver" = osmesa; then
+        AC_MSG_ERROR([libGL is not available for OSMesa driver])
+    else
+        DRIVER_DIRS="$DRIVER_DIRS osmesa"
+    fi
+fi
+
+dnl Configure the channel bits for OSMesa (libOSMesa, libOSMesa16, ...)
+AC_ARG_WITH([osmesa-bits],
+    [AS_HELP_STRING([--with-osmesa-bits=BITS],
+        [OSMesa channel bits and library name: 8, 16, 32 @<:@default=8@:>@])],
+    [osmesa_bits="$withval"],
+    [osmesa_bits=8])
+if test "$mesa_driver" != osmesa && test "x$osmesa_bits" != x8; then
+    AC_MSG_WARN([Ignoring OSMesa channel bits for non-OSMesa driver])
+    osmesa_bits=8
+fi
+case "x$osmesa_bits" in
+x8)
+    OSMESA_LIB=OSMesa
+    ;;
+x16|x32)
+    OSMESA_LIB="OSMesa$osmesa_bits"
+    DEFINES="$DEFINES -DCHAN_BITS=$osmesa_bits -DDEFAULT_SOFTWARE_DEPTH_BITS=31"
+    ;;
+*)
+    AC_MSG_ERROR([OSMesa bits '$osmesa_bits' is not a valid option])
+    ;;
+esac
+AC_SUBST([OSMESA_LIB])
+
+case "$mesa_driver" in
+osmesa)
+    # only link libraries with osmesa if shared
+    if test "$enable_static" = no; then
+        OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS"
+    else
+        OSMESA_LIB_DEPS=""
+    fi
+    OSMESA_MESA_DEPS=""
+    ;;
+*)
+    # Link OSMesa to libGL otherwise
+    OSMESA_LIB_DEPS=""
+    # only link libraries with osmesa if shared
+    if test "$enable_static" = no; then
+        OSMESA_MESA_DEPS='-l$(GL_LIB)'
+    else
+        OSMESA_MESA_DEPS=""
+    fi
+    ;;
+esac
+if test "$enable_static" = no; then
+    OSMESA_LIB_DEPS="$OSMESA_LIB_DEPS $OS_LIBS"
+fi
+AC_SUBST([OSMESA_LIB_DEPS])
+AC_SUBST([OSMESA_MESA_DEPS])
+
+dnl
+dnl GLU configuration
+dnl
+AC_ARG_ENABLE([glu],
+    [AS_HELP_STRING([--disable-glu],
+        [enable OpenGL Utility library @<:@default=enabled@:>@])],
+    [enable_glu="$enableval"],
+    [enable_glu=yes])
+if test "x$enable_glu" = xyes; then
+    SRC_DIRS="$SRC_DIRS glu"
+
+    case "$mesa_driver" in
+    osmesa)
+        # If GLU is available and we have libOSMesa (not 16 or 32),
+        # we can build the osdemos
+        if test "$with_demos" = yes && test "$osmesa_bits" = 8; then
+            PROGRAM_DIRS="$PROGRAM_DIRS osdemos"
+        fi
+
+        # Link libGLU to libOSMesa instead of libGL
+        GLU_LIB_DEPS=""
+        if test "$enable_static" = no; then
+            GLU_MESA_DEPS='-l$(OSMESA_LIB)'
+        else
+            GLU_MESA_DEPS=""
+        fi
+        ;;
+    *)
+        # If static, empty GLU_LIB_DEPS and add libs for programs to link
+        if test "$enable_static" = no; then
+            GLU_LIB_DEPS="-lm"
+            GLU_MESA_DEPS='-l$(GL_LIB)'
+        else
+            GLU_LIB_DEPS=""
+            GLU_MESA_DEPS=""
+            APP_LIB_DEPS="$APP_LIB_DEPS -lstdc++"
+        fi
+        ;;
+    esac
+fi
+if test "$enable_static" = no; then
+    GLU_LIB_DEPS="$GLU_LIB_DEPS $OS_CPLUSPLUS_LIBS"
+fi
+AC_SUBST([GLU_LIB_DEPS])
+AC_SUBST([GLU_MESA_DEPS])
+
+dnl
+dnl GLw configuration
+dnl
+AC_ARG_ENABLE([glw],
+    [AS_HELP_STRING([--disable-glw],
+        [enable Xt/Motif widget library @<:@default=enabled@:>@])],
+    [enable_glw="$enableval"],
+    [enable_glw=yes])
+dnl Don't build GLw on osmesa
+if test "x$enable_glw" = xyes && test "$mesa_driver" = osmesa; then
+    AC_MSG_WARN([Disabling GLw since the driver is OSMesa])
+    enable_glw=no
+fi
+AC_ARG_ENABLE([motif],
+    [AS_HELP_STRING([--enable-motif],
+        [use Motif widgets in GLw @<:@default=disabled@:>@])],
+    [enable_motif="$enableval"],
+    [enable_motif=no])
+
+if test "x$enable_glw" = xyes; then
+    SRC_DIRS="$SRC_DIRS glw"
+    if test "$x11_pkgconfig" = yes; then
+        PKG_CHECK_MODULES([GLW],[x11 xt])
+        GLW_LIB_DEPS="$GLW_LIBS"
+    else
+        # should check these...
+        GLW_LIB_DEPS="$X_LIBS -lXt -lX11"
+    fi
+
+    GLW_SOURCES="GLwDrawA.c"
+    MOTIF_CFLAGS=
+    if test "x$enable_motif" = xyes; then
+        GLW_SOURCES="$GLW_SOURCES GLwMDrawA.c"
+        AC_PATH_PROG([MOTIF_CONFIG], [motif-config], [no])
+        if test "x$MOTIF_CONFIG" != xno; then
+            MOTIF_CFLAGS=`$MOTIF_CONFIG --cflags`
+            MOTIF_LIBS=`$MOTIF_CONFIG --libs`
+        else
+            AC_CHECK_HEADER([Xm/PrimitiveP.h], [],
+                [AC_MSG_ERROR([Can't locate Motif headers])])
+            AC_CHECK_LIB([Xm], [XmGetPixmap], [MOTIF_LIBS="-lXm"],
+                [AC_MSG_ERROR([Can't locate Motif Xm library])])
+        fi
+        # MOTIF_LIBS is prepended to GLW_LIB_DEPS since Xm needs Xt/X11
+        GLW_LIB_DEPS="$MOTIF_LIBS $GLW_LIB_DEPS"
+    fi
+
+    # If static, empty GLW_LIB_DEPS and add libs for programs to link
+    if test "$enable_static" = no; then
+        GLW_MESA_DEPS='-l$(GL_LIB)'
+        GLW_LIB_DEPS="$GLW_LIB_DEPS $OS_LIBS"
+    else
+        APP_LIB_DEPS="$APP_LIB_DEPS $GLW_LIB_DEPS"
+        GLW_LIB_DEPS=""
+        GLW_MESA_DEPS=""
+    fi
+fi
+AC_SUBST([GLW_LIB_DEPS])
+AC_SUBST([GLW_MESA_DEPS])
+AC_SUBST([GLW_SOURCES])
+AC_SUBST([MOTIF_CFLAGS])
+
+dnl
+dnl GLUT configuration
+dnl
+if test -f "$srcdir/include/GL/glut.h"; then
+    default_glut=yes
+else
+    default_glut=no
+fi
+AC_ARG_ENABLE([glut],
+    [AS_HELP_STRING([--disable-glut],
+        [enable GLUT library @<:@default=enabled if source available@:>@])],
+    [enable_glut="$enableval"],
+    [enable_glut="$default_glut"])
+
+dnl Can't build glut if GLU not available
+if test "x$enable_glu$enable_glut" = xnoyes; then
+    AC_MSG_WARN([Disabling glut since GLU is disabled])
+    enable_glut=no
+fi
+dnl Don't build glut on osmesa
+if test "x$enable_glut" = xyes && test "$mesa_driver" = osmesa; then
+    AC_MSG_WARN([Disabling glut since the driver is OSMesa])
+    enable_glut=no
+fi
+
+if test "x$enable_glut" = xyes; then
+    SRC_DIRS="$SRC_DIRS glut/glx"
+    GLUT_CFLAGS=""
+    if test "x$GCC" = xyes; then
+        GLUT_CFLAGS="-fexceptions"
+    fi
+    if test "$x11_pkgconfig" = yes; then
+        PKG_CHECK_MODULES([GLUT],[x11 xmu xi])
+        GLUT_LIB_DEPS="$GLUT_LIBS"
+    else
+        # should check these...
+        GLUT_LIB_DEPS="$X_LIBS -lX11 -lXmu -lXi"
+    fi
+    GLUT_LIB_DEPS="$GLUT_LIB_DEPS -lm $OS_LIBS"
+
+    # If glut is available, we can build most programs
+    if test "$with_demos" = yes; then
+        PROGRAM_DIRS="$PROGRAM_DIRS demos redbook samples glsl"
+    fi
+
+    # If static, empty GLUT_LIB_DEPS and add libs for programs to link
+    if test "$enable_static" = no; then
+        GLUT_MESA_DEPS='-l$(GLU_LIB) -l$(GL_LIB)'
+    else
+        APP_LIB_DEPS="$APP_LIB_DEPS $GLUT_LIB_DEPS"
+        GLUT_LIB_DEPS=""
+        GLUT_MESA_DEPS=""
+    fi
+fi
+AC_SUBST([GLUT_LIB_DEPS])
+AC_SUBST([GLUT_MESA_DEPS])
+AC_SUBST([GLUT_CFLAGS])
+
+dnl
+dnl Program library dependencies
+dnl    Only libm is added here if necessary as the libraries should
+dnl    be pulled in by the linker
+dnl
+if test "x$APP_LIB_DEPS" = x; then
+    case "$host_os" in
+    solaris*)
+        APP_LIB_DEPS="-lX11 -lsocket -lnsl -lm"
+        ;;
+    *)
+        APP_LIB_DEPS="-lm"
+        ;;
+    esac
+fi
+AC_SUBST([APP_LIB_DEPS])
+AC_SUBST([PROGRAM_DIRS])
+
+
+dnl Restore LDFLAGS and CPPFLAGS
+LDFLAGS="$_SAVE_LDFLAGS"
+CPPFLAGS="$_SAVE_CPPFLAGS"
+
+dnl Substitute the config
+AC_CONFIG_FILES([configs/autoconf])
+
+dnl Replace the configs/current symlink
+AC_CONFIG_COMMANDS([configs],[
+if test -f configs/current || test -L configs/current; then
+    rm -f configs/current
+fi
+ln -s autoconf configs/current
+])
+
+AC_OUTPUT
+
+dnl
+dnl Output some configuration info for the user
+dnl
+echo ""
+echo "        prefix:          $prefix"
+echo "        exec_prefix:     $exec_prefix"
+echo "        libdir:          $libdir"
+echo "        includedir:      $includedir"
+
+dnl Driver info
+echo ""
+echo "        Driver:          $mesa_driver"
+if echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1; then
+    echo "        OSMesa:          lib$OSMESA_LIB"
+else
+    echo "        OSMesa:          no"
+fi
+if test "$mesa_driver" = dri; then
+    # cleanup the drivers var
+    dri_dirs=`echo $DRI_DIRS | $SED 's/^ *//;s/  */ /;s/ *$//'`
+if test "x$DRI_DIRS" = x; then
+    echo "        DRI drivers:     no"
+else
+    echo "        DRI drivers:     $dri_dirs"
+fi
+    echo "        DRI driver dir:  $DRI_DRIVER_INSTALL_DIR"
+fi
+
+dnl Libraries
+echo ""
+echo "        Shared libs:     $enable_shared"
+echo "        Static libs:     $enable_static"
+echo "        GLU:             $enable_glu"
+echo "        GLw:             $enable_glw (Motif: $enable_motif)"
+echo "        glut:            $enable_glut"
+
+dnl Programs
+# cleanup the programs var for display
+program_dirs=`echo $PROGRAM_DIRS | $SED 's/^ *//;s/  */ /;s/ *$//'`
+if test "x$program_dirs" = x; then
+    echo "        Demos:           no"
+else
+    echo "        Demos:           $program_dirs"
+fi
+
+dnl Compiler options
+# cleanup the CFLAGS/CXXFLAGS/DEFINES vars
+cflags=`echo $CFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
+    $SED 's/^ *//;s/  */ /;s/ *$//'`
+cxxflags=`echo $CXXFLAGS $OPT_FLAGS $PIC_FLAGS $ARCH_FLAGS | \
+    $SED 's/^ *//;s/  */ /;s/ *$//'`
+defines=`echo $DEFINES $ASM_FLAGS | $SED 's/^ *//;s/  */ /;s/ *$//'`
+echo ""
+echo "        CFLAGS:          $cflags"
+echo "        CXXFLAGS:        $cxxflags"
+echo "        Macros:          $defines"
+
+echo ""
+echo "        Run '${MAKE-make}' to build Mesa"
+echo ""
diff --git a/docs/MESA_packed_depth_stencil.spec b/docs/MESA_packed_depth_stencil.spec
deleted file mode 100644 (file)
index 112b730..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-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
-
-
-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/docs/MESA_program_debug.spec b/docs/MESA_program_debug.spec
deleted file mode 100644 (file)
index 7694fdc..0000000
+++ /dev/null
@@ -1,356 +0,0 @@
-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
-
-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/docs/MESA_sprite_point.spec b/docs/MESA_sprite_point.spec
deleted file mode 100644 (file)
index b50d78e..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-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
-
-
-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/docs/MESA_trace.spec b/docs/MESA_trace.spec
deleted file mode 100644 (file)
index dc4166e..0000000
+++ /dev/null
@@ -1,359 +0,0 @@
-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
-
-
-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/docs/OLD/MESA_packed_depth_stencil.spec b/docs/OLD/MESA_packed_depth_stencil.spec
new file mode 100644 (file)
index 0000000..112b730
--- /dev/null
@@ -0,0 +1,230 @@
+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
+
+
+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/docs/OLD/MESA_program_debug.spec b/docs/OLD/MESA_program_debug.spec
new file mode 100644 (file)
index 0000000..7694fdc
--- /dev/null
@@ -0,0 +1,356 @@
+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
+
+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/docs/OLD/MESA_sprite_point.spec b/docs/OLD/MESA_sprite_point.spec
new file mode 100644 (file)
index 0000000..b50d78e
--- /dev/null
@@ -0,0 +1,190 @@
+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
+
+
+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/docs/OLD/MESA_trace.spec b/docs/OLD/MESA_trace.spec
new file mode 100644 (file)
index 0000000..dc4166e
--- /dev/null
@@ -0,0 +1,359 @@
+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
+
+
+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)
+
index 138dd43eaccfe0d3b3ddc6f308ae800f0ee3624d..9477b2bd3182ccd12175845f75d508e8b314b64e 100644 (file)
@@ -91,9 +91,11 @@ Running the Build:
 
 
 
-*******************This section is added by Heromyth*****************************
-Updated on 2007-7-21, by Heromyth <zxpmyth@yahoo.com.cn>
+******This section is added by Heromyth <zxpmyth@yahoo.com.cn>*************
 
+====================
+Updated on 2007-7-21
+====================
 
 Notice:
        1) The generated DLLs are *not* compatible with the ones built
@@ -115,7 +117,7 @@ For example, run:
 , and delete all the lines where all the wgl*() functions are. Because they would 
 be conflicted with the ones in <Mesa3D-root>\include\GL\mesa_wgl.h.
 
-======= Conflicted Functions List ======
+>>>>>>>>>> Conflicted Functions List >>>>>>>>>>
 WINGDIAPI BOOL WINAPI wglCopyContext(HGLRC,HGLRC,UINT);
 WINGDIAPI HGLRC WINAPI wglCreateContext(HDC);
 WINGDIAPI HGLRC WINAPI wglCreateLayerContext(HDC,int);
@@ -134,6 +136,18 @@ WINGDIAPI BOOL WINAPI wglUseFontBitmapsA(HDC,DWORD,DWORD,DWORD);
 WINGDIAPI BOOL WINAPI wglUseFontBitmapsW(HDC,DWORD,DWORD,DWORD);
 WINGDIAPI BOOL WINAPI wglUseFontOutlinesA(HDC,DWORD,DWORD,DWORD,FLOAT,FLOAT,int,LPGLYPHMETRICSFLOAT);
 WINGDIAPI BOOL WINAPI wglUseFontOutlinesW(HDC,DWORD,DWORD,DWORD,FLOAT,FLOAT,int,LPGLYPHMETRICSFLOAT);
-===================
+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+====================
+Updated on 2007-7-22
+====================
+       I havn't thought that I would find a better way to solve my problems so soon. 
+I changed the method in which the import-libs and DLLs are made. After this update,
+the DLLs of MESA are more optimized and more compatible. 
+       It seems that there is no need to keep the building way of 'NO-STDCALL'.The 
+way of USING_STDCALL is so nice! The file <Mesa3D-root>\configs\config.mgw is 
+also not needed, and can be deleted safely!
+       
+
 
 *********************************************************************************
\ No newline at end of file
diff --git a/docs/autoconf.html b/docs/autoconf.html
new file mode 100644 (file)
index 0000000..936ddcf
--- /dev/null
@@ -0,0 +1,289 @@
+<html>
+
+<title>Compilation and Installation using Autoconf</title>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<body>
+
+
+<h1>Compilation and Installation using Autoconf</h1>
+
+<ol>
+<li><a href="#basic">Basic Usage</a></li>
+<li><a href="#driver">Driver Options</a></li>
+  <ul>
+  <li><a href="#xlib">Xlib Driver Options</a></li>
+  <li><a href="#dri">DRI Driver Options</a></li>
+  <li><a href="#osmesa">OSMesa Driver Options</a></li>
+  </ul>
+<li><a href="#library">Library Options</a></li>
+  <ul>
+  <li><a href="#glu">GLU</a></li>
+  <li><a href="#glw">GLw</a></li>
+  <li><a href="#glut">GLUT</a></li>
+  </ul>
+<li><a href="#demos">Demo Program Options</a></li>
+</ol>
+
+
+<a name="basic">
+<h2>1. Basic Usage</h2>
+
+<p>
+The autoconf generated configure script can be used to guess your
+platform and change various options for building Mesa. To use the
+configure script, type:
+</p>
+
+<pre>
+    ./configure
+</pre>
+
+<p>
+To see a short description of all the options, type <code>./configure
+--help</code>. If you are using a development snapshot and the configure
+script does not exist, type <code>./autogen.sh</code> to generate it
+first. If you know the options you want to pass to
+<code>configure</code>, you can pass them to <code>autogen.sh</code>. It
+will run <code>configure</code> with these options after it is
+generated. Once you have run <code>configure</code> and set the options
+to your preference, type:
+</p>
+
+<pre>
+    make
+</pre>
+
+<p>
+This will produce libGL.so and several other libraries depending on the
+options you have chosen. Later, if you want to rebuild for a different
+configuration run <code>make realclean</code> before rebuilding.
+</p>
+
+<p>
+Some of the generic autoconf options are used with Mesa:
+
+<ul>
+<li><code>--prefix=PREFIX</code> - This is the root directory where
+files will be installed by <code>make install</code>. The default is
+<code>/usr/local</code>.
+</li>
+<li><code>--exec-prefix=EPREFIX</code> - This is the root directory
+where architecture-dependent files will be installed. In Mesa, this is
+only used to derive the directory for the libraries. The default is
+<code>${prefix}</code>.
+</li>
+<li><code>--libdir=LIBDIR</code> - This option specifies the directory
+where the GL libraries will be installed. The default is
+<code>${exec_prefix}/lib</code>. It also serves as the name of the
+library staging area in the source tree. For instance, if the option
+<code>--libdir=/usr/local/lib64</code> is used, the libraries will be
+created in a <code>lib64</code> directory at the top of the Mesa source
+tree.
+</li>
+<li><code>--enable-static, --disable-shared</code> - By default, Mesa
+will build shared libraries. Either of these options will force static
+libraries to be built. It is not currently possible to build static and
+shared libraries in a single pass.
+</li>
+<li><code>CC, CFLAGS, CXX, CXXFLAGS</code> - These environment variables
+control the C and C++ compilers used during the build. By default,
+<code>gcc</code> and <code>g++</code> are used with the options
+<code>"-g -O2"</code>.
+</li>
+<li><code>LDFLAGS</code> - An environment variable specifying flags to
+pass when linking programs. These are normally empty, but can be used
+to direct the linker to use libraries in nonstandard directories. For
+example, <code>LDFLAGS="-L/usr/X11R6/lib"</code>.
+</li>
+<li><code>PKG_CONFIG_PATH</code> - When available, the
+<code>pkg-config</code> utility is used to search for external libraries
+on the system. This environment variable is used to control the search
+path for <code>pkg-config</code>. For instance, setting
+<code>PKG_CONFIG_PATH=/usr/X11R6/lib/pkgconfig</code> will search for
+package metadata in <code>/usr/X11R6</code> before the standard
+directories.
+</li>
+</ul>
+</p>
+
+<p>
+There are also a few general options for altering the Mesa build:
+<ul>
+<li><code>--with-x</code> - When the X11 development libraries are
+needed, the <code>pkg-config</code> utility <a href="#pkg-config">will
+be used</a> for locating them. If they cannot be found through
+<code>pkg-config</code> a fallback routing using <code>imake</code> will
+be used. In this case, the <code>--with-x</code>,
+<code>--x-includes</code> and <code>--x-libraries</code> options can
+control the use of X for Mesa.
+</li>
+<li><code>--enable-gl-osmesa</code> - The <a href="osmesa.html">OSMesa
+library</a> can be built on top of libGL for drivers that provide it.
+This option controls whether to build libOSMesa. By default, this is
+enabled for the Xlib driver and disabled otherwise. Note that this
+option is different than using OSMesa as the driver.
+</li>
+<li><code>--enable-debug</code> - This option will enable compiler
+options and macros to aid in debugging the Mesa libraries.
+</li>
+<li><code>--disable-asm</code> - There are assembly routines
+available for a few architectures. These will be used by default if
+one of these architectures is detected. This option ensures that
+assembly will not be used.
+</li>
+<li><code>--enable-32-bit, --enable-64-bit</code> - By default, the
+build will compile code as directed by the environment variables
+<code>CC</code>, <code>CFLAGS</code>, etc. If the compiler is
+<code>gcc</code>, these options offer a helper to add the compiler flags
+to force 32- or 64-bit code generation as used on the x86 and x86_64
+architectures.
+</li>
+</ul>
+</p>
+
+
+<a name="driver">
+<h2>2. Driver Options</h2>
+
+<p>
+There are several different driver modes that Mesa can use. These are
+described in more detail in the <a href="install.html">basic
+installation instructions</a>. The Mesa driver is controlled through the
+configure option --with-driver. There are currently three supported
+options in the configure script.
+</p>
+
+<ul>
+
+<a name="xlib">
+<li><b><em>Xlib</em></b> - This is the default mode for building Mesa.
+It uses Xlib as a software renderer to do all rendering. It corresponds
+to the option <code>--with-driver=xlib</code>. The libX11 and libXext
+libraries, as well as the X11 development headers, will be need to
+support the Xlib driver.
+</li>
+
+<a name="dri">
+<li><b><em>DRI</em></b> - This mode uses the DRI hardware drivers for
+accelerated OpenGL rendering. Enable the DRI drivers with the option
+<code>--with-driver=dri</code>. See the <a href="install.html">basic
+installation instructions</a> for details on prerequisites for the DRI
+drivers.
+</li>
+
+<!-- DRI specific options -->
+<p>
+<ul>
+<li><code>--with-dri-driverdir=DIR</code> - This option specifies the
+location the DRI drivers will be installed to and the location libGL
+will search for DRI drivers. The default is <code>${libdir}/dri</code>.
+</li>
+<li><code>--with-dri-drivers=DRIVER,DRIVER,...</code> - This option
+allows a specific set of DRI drivers to be built. For example,
+<code>--with-dri-drivers="swrast,i965,radeon,nouveau"</code>. By
+default, the drivers will be chosen depending on the target platform.
+See the directory <code>src/mesa/drivers/dri</code> in the source tree
+for available drivers. Beware that the swrast DRI driver is used by both
+libGL and the X.Org xserver GLX module to do software rendering, so you
+may run into problems if it is not available.</li>
+<!-- This explanation might be totally bogus. Kristian? -->
+<li><code>--disable-driglx-direct</code> - Disable direct rendering in
+GLX. Normally, direct hardware rendering through the DRI drivers and
+indirect software rendering are enabled in GLX. This option disables
+direct rendering entirely. It can be useful on architectures where
+kernel DRM modules are not available.
+</li>
+<li><code>--enable-glx-tls</code> - Enable Thread Local Storage (TLS) in
+GLX.
+</li>
+<li><code>--with-expat=DIR</code> - The DRI-enabled libGL uses expat to
+parse the DRI configuration files in <code>/etc/drirc</code> and
+<code>~/.drirc</code>. This option allows a specific expat installation
+to be used. For example, <code>--with-expat=/usr/local</code> will
+search for expat headers and libraries in <code>/usr/local/include</code>
+and <code>/usr/local/lib</code>, respectively.
+</li>
+</ul>
+</p>
+
+<a name="osmesa">
+<li><b><em>OSMesa</em></b> - No libGL is built in this
+mode. Instead, the driver code is built into the Off-Screen Mesa
+(OSMesa) library. See the <a href="osmesa.html">Off-Screen Rendering</a>
+page for more details.
+</li>
+
+<!-- OSMesa specific options -->
+<p>
+<ul>
+<li><code>--with-osmesa-bits=BITS</code> - This option allows the size
+of the color channel in bits to be specified. By default, an 8-bit
+channel will be used, and the driver will be named libOSMesa. Other
+options are 16- and 32-bit color channels, which will add the bit size
+to the library name. For example, <code>--with-osmesa-bits=16</code>
+will create the libOSMesa16 library with a 16-bit color channel.
+</li>
+</ul>
+</p>
+
+</ul>
+
+
+<a name="library">
+<h2>3. Library Options</h2>
+
+<p>
+The configure script provides more fine grained control over the GL
+libraries that will be built. More details on the specific GL libraries
+can be found in the <a href="install.html">basic installation
+instructions</a>.
+
+<ul>
+<a name="glu">
+<li><b><em>GLU</em></b> - The libGLU library will be built by default
+on all drivers. This can be disable with the option
+<code>--disable-glu</code>.
+</li>
+
+<a name="glw">
+<li><b><em>GLw</em></b> - The libGLw library will be built by default
+if libGLU has been enabled. This can be disable with the option
+<code>--disable-glw</code>.
+</li>
+
+<a name="glut">
+<li><b><em>GLUT</em></b> - The libglut library will be built by default
+if libGLU has been enabled and the glut source code from the MesaGLUT
+tarball is available. This can be disable with the option
+<code>--disable-glut</code>.
+</li>
+</ul>
+</p>
+
+
+<a name="demos">
+<h2>4. Demo Program Options</h2>
+
+<p>
+There are many demonstration programs in the MesaDemos tarball. If the
+programs are available when <code>./configure</code> is run, a subset of
+the programs will be built depending on the driver and library options
+chosen. See the directory <code>progs</code> for the full set of demos.
+
+<ul>
+<li><code>--with-demos=DEMOS,DEMOS,...</code> - This option allows a
+specific set of demo programs to be built. For example,
+<code>--with-demos="xdemos,slang"</code>. Beware that if this option is
+used, it will not be ensured that the necessary GL libraries will be
+available.
+</li>
+<li><code>--without-demos</code> - This completely disables building the
+demo programs. It is equivalent to <code>--with-demos=no</code>.
+</li>
+</ul>
+</p>
+
+</body>
+</html>
index d255f4292c9d4d88c983d67165f270cf69ea95b1..4397339e968d422717c9a3cd9c905b801a22b2f5 100644 (file)
@@ -9,9 +9,9 @@
 <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.
+The Mesa bug database is hosted on
+<a href="http://freedesktop.org" target="_parent">freedesktop.org</a>.
+The old bug database on SourceForge is no longer used.
 </p>
 
 <p>
@@ -26,16 +26,20 @@ 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>Check if a new version of Mesa is available which might have fixed
+the problem.
+<li>Check if your bug is already reported in the database.
+<li>Monitor your bug report for requests for additional information, etc.
+<li>If you're reporting a crash, try to use your debugger (gdb) to get a stack
+trace. Also, recompile Mesa in debug mode to get more detailed information.
+<li>Describe in detail how to reproduce the bug, especially with games
+and applications that the Mesa developers might not be familiar with.
 <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.
+Bug reports will automatically be forwarded by bugzilla to the Mesa
+developer's mailing list.
 </p>
 
 <p>
diff --git a/docs/cell.html b/docs/cell.html
new file mode 100644 (file)
index 0000000..34d9a92
--- /dev/null
@@ -0,0 +1,137 @@
+<HTML>
+
+<TITLE>Cell Driver</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Mesa/Gallium Cell Driver</H1>
+
+<p>
+The Mesa
+<a href="http://en.wikipedia.org/wiki/Cell_%28microprocessor%29" target="_parent">Cell</a>
+driver is part of the 
+<a href="http://www.tungstengraphics.com/wiki/index.php/Gallium3D" target="_parent">Gallium3D</a>
+architecture.
+</p>
+
+<p>
+<a href="http://www.tungstengraphics.com/" target="_parent">Tungsten Graphics</a>
+is leading the project.
+Two phases are planned.
+First, to implement the framework for parallel rasterization using the Cell
+SPEs, including texture mapping.
+Second, to implement a full-featured OpenGL driver with support for GLSL, etc.
+The second phase is now underway.
+</p>
+
+
+<H2>Source Code</H2>
+
+<p>
+The latest Cell driver source code is on the <code>gallium-0.2</code> branch
+of the Mesa git repository.
+After you've cloned the repository, check out the branch with:
+</p>
+<pre>
+   git-checkout -b gallium-0.2 origin/gallium-0.2
+</pre>
+<p>
+To build the driver you'll need the IBM Cell SDK (version 2.1 or 3.0).
+To use the driver you'll need a Cell system, such as a PS3 running Linux,
+or the Cell Simulator (untested, though).
+</p>
+
+<p>
+If using Cell SDK 2.1, see the configs/linux-cell file for some
+special changes.
+</p>
+
+<p>
+To compile the code, run <code>make linux-cell</code>.
+To build in debug mode, run <code>make linux-cell-debug</code>.
+</p>
+
+<p>
+To use the library, make sure <code>LD_LIBRARY_PATH</code> points the Mesa/lib/
+directory that contains <code>libGL.so</code>.
+</p>
+
+<p>
+Verify that the Cell driver is being used by running <code>glxinfo</code>
+and looking for:
+<pre>
+  OpenGL renderer string: Gallium 0.2, Cell on Xlib
+</pre>
+
+
+<H2>Driver Implementation Summary</H2>
+
+<p>
+Rasterization is parallelized across the SPUs in a tiled-based manner.
+Batches of transformed triangles are sent to the SPUs (actually, pulled by from
+main memory by the SPUs).
+Each SPU loops over a set of 32x32-pixel screen tiles, rendering the triangles
+into each tile.
+Because of the limited SPU memory, framebuffer tiles are paged in/out of
+SPU local store as needed.
+Similarly, textures are tiled and brought into local store as needed.
+</p>
+
+
+<H2>Status</H2>
+
+<p>
+As of September 2008, the driver supports smooth/flat shaded triangle rendering
+with Z testing and simple texture mapping.
+Simple demos like gears run successfully.
+To test texture mapping, try progs/demos/texcyl (press right mouse button for
+rendering options).
+</p>
+<p>
+Runtime/dynamic code generation is being done for per-fragment
+operations (Z test, blend, etc) and for fragment programs (though only a
+few opcodes are implemented now).
+</p>
+<p>
+In general, however, the driver is rather slow because all vertex
+transformation is being done by an interpreter running on the PPU.
+Programs with many vertices or complex vertex shaders will run especially
+slow.
+This will be addressed in the future.
+</p>
+
+
+
+<H2>Debug Options</H2>
+
+<p>
+The CELL_DEBUG env var can be set to a comma-separated list of one or
+more of the following debug options:
+</p>
+<ul>
+<li><b>checker</b> - use a different background clear color for each SPU.
+   This lets you see which SPU is rendering which screen tiles.
+<li><b>sync</b> - wait/synchronize after each DMA transfer
+</ul>
+
+<p>
+If the GALLIUM_NOCELL env var is set, the softpipe driver will be used
+intead of the Cell driver.
+This is useful for comparison/validation.
+</p>
+
+
+
+<H2>Contributing</H2>
+
+<p>
+If you're interested in contributing to the effort, familiarize yourself
+with the code, join the <a href="lists.html">mesa3d-dev mailing list</a>,
+and describe what you'd like to do.
+</p>
+
+
+</BODY>
+</HTML>
index a21341a589128a75481e2e6c99a2881395ab0c10..257b13f68a732e8dac531fb799faa20079975a8d 100644 (file)
@@ -48,6 +48,7 @@ a:visited {
 <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>
+<li><a href="http://dri.freedesktop.org/" target="MainFrame">Wiki</a>
 </ul>
 
 <b>User Topics</b>
@@ -75,6 +76,7 @@ a:visited {
 <li><a href="subset.html" target="MainFrame">Mesa Subset Driver</a>
 <li><a href="glfbdev-driver.html" target="MainFrame">glFBDev Driver</a>
 <LI><A HREF="dispatch.html" target="MainFrame">GL Dispatch</A>
+<li><a href="cell.html" target="MainFrame">Cell Driver</A>
 </ul>
 
 <b>Links</b>
index cce14d73a365e40627e2966c1ca8fa063e6f0268..3cebf5f36db006ec50191c975030a7d1fd104f8d 100644 (file)
@@ -135,12 +135,12 @@ Update the docs/VERSIONS file too.
 </p>
 
 <p>
-Edit configs/default and change the MESA_MAJOR, MESA_MINOR and MESA_TINY
-version numbers.
+Edit the MESA_MAJOR, MESA_MINOR and MESA_TINY version numbers in
+configs/default.
 </p>
 
 <p>
-Make sure the values in src/mesa/main/version.h is correct.
+Make sure the values in src/mesa/main/version.h are correct.
 </p>
 
 <p>
index 90f566351e8b00402f337118be805056e2ae979b..2d587f35f9f344910fca128968808fb393b801b1 100644 (file)
@@ -9,7 +9,9 @@
 <H1>Downloading</H1>
 
 <p>
-Last stable release: <b>7.0</b>
+Current development release: <b>7.1</b>
+<br>
+Last stable release: <b>7.0.4</b>
 </p>
 
 <p>
@@ -18,6 +20,11 @@ Primary download site:
 target="_parent">SourceForge</a>
 </p>
 
+<p>
+When a new release is coming, release candidates (betas) can be found
+<a href="http://www.mesa3d.org/beta/">here</a>.
+</p>
+
 
 <p>
 Mesa is distributed in several parts:
index 89496c8404d4f6bd75ada643f17e470cdef2410a..11b5d4325585815a9a22697182cbe3fa0fee6061 100644 (file)
@@ -187,24 +187,7 @@ 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>
+<h2><a name="part2">2.2 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)
@@ -213,7 +196,7 @@ Mesa's not the solution.
 </a></p>
 
 
-<h2><a name="part2">2.4 Where is the GLUT library?</a></h2>
+<h2><a name="part2">2.3 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
@@ -222,7 +205,7 @@ package and compile it with the rest of Mesa.
 
 
 
-<h2><a name="part2">2.5 What's the proper place for the libraries and headers?</a></h2>
+<h2><a name="part2">2.4 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"
@@ -342,12 +325,12 @@ will fix the problem.
 
 <h2>4.1 How can I contribute?</a></h2>
 <p>
-First, join the <a href="http://www.mesa3d.org/lists.html>Mesa3d-dev
+First, join the <a href="http://www.mesa3d.org/lists.html">Mesa3d-dev
 mailing list</a>.
 That's where Mesa development is discussed.
-</a></p>
+</p>
 <p>
-The </a><a href="http://www.opengl.org/documentation" target="_parent">
+The <a href="http://www.opengl.org/documentation" target="_parent">
 OpenGL Specification</a> is the bible for OpenGL implemention work.
 You should read it.
 </p>
index c7f59bb0c2f59da2755a1d20709f3e554fa78d6d..e941b1679ed78c7349242d97ca763dcca1b39e92 100644 (file)
@@ -1,15 +1,15 @@
-<html>
+<html><head><title>Mesa fbdev/DRI Environment</title>
 
-<TITLE>Mesa fbdev/DRI Environment</TITLE>
 
-<link rel="stylesheet" type="text/css" href="mesa.css"></head>
 
-<BODY>
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
 
-<center><H1>Mesa fbdev/DRI Drivers</H1></center>
+<body>
 
+<center><h1>Mesa fbdev/DRI Drivers</h1></center>
+<br>
 
-<H1>1. Introduction</H1>
+<h1>1. Introduction</h1>
 
 <p>
 The fbdev/DRI environment supports hardware-accelerated 3D rendering without
@@ -22,48 +22,131 @@ Contributors to this project include Jon Smirl, Keith Whitwell and Dave Airlie.
 
 <p>
 Applications in the fbdev/DRI environment use
-the <a href="MiniGXL.html"> MiniGLX</a> interface to choose pixel
+the <a href="http://www.nabble.com/file/p15480666/MiniGXL.html"> MiniGLX</a> interface to choose pixel
 formats, create rendering contexts, etc.  It's a subset of the GLX and
 Xlib interfaces allowing some degree of application portability between
 the X and X-less environments.
 </p>
 
+<p>
+Note that this environment is not well-supported and these instructions
+may not be completely up to date.
+</p>
+<br>
+
+
 
 <h1>2. Compilation</h1>
+<p>
 
+<h2>2.1 glxproto</h2>
+
+Get <a href="http://cvsweb.xfree86.org/cvsweb/*checkout*/xc/include/GL/glxproto.h?rev=1.9">glxproto.h</a>. Copy it to the /mesa/include/GL/ directory.
+</p>
+
+<h2>2.2 libpciaccess</h2>
 <p>
-You'll need the DRM and pciaccess libraries.  Check with:
+Check if you have libpciaccess installed:
 </p>
-<pre>
-   pkg-config --modversion libdrm
-   pkg-config --modversion pciaccess
-</pre>
 
+<pre>pkg-config --modversion pciaccess
+</pre>
 <p>
-You can get them from the git repository with:
+If not you can download the latest code from:
 </p>
-<pre>
-   git clone git://anongit.freedesktop.org/git/mesa/drm
-   git clone git://anongit.freedesktop.org/git/xorg/lib/libpciaccess
+<pre>   git clone git://anongit.freedesktop.org/git/xorg/lib/libpciaccess
 </pre>
-
 <p>
-See the README files in those projects for build/install instructions.
+Run autogen.sh to generate a configure file. autogen.sh uses autoconf
+utility. This utility may not be installed with your linux distro,
+check if it is available. if not you can use your package manager or
+type:
 </p>
+<pre>sudo apt-get install autoconf
+</pre>
+The next step is to install the libpciaccess library. 
+<pre>make
+make install
+</pre>
+<p> Now your libpciaccess.a file is saved into /usr/local/lib
+directory. If you have a libpciaccess.a in /usr/lib you may simply copy
+and overwrite these files. Don't forget to copy libpciaccess.pc file to
+/usr/lib/pkgconfig, which is also located in /usr/local/lib/pkgconfig/.
+Or you may use the following system variables:
+</p>
+<pre>export LD_LIBRARY_PATH=/usr/local/lib
+export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
+</pre>
 
+<h2>2.3 drm</h2>
+
+<p>The next step is to compile the drm. DRM consists of two seperate parts,
+the DRM client library(lindrm.so) and kernel device module(such as
+radeon.ko). We need to make a small change in kernel device module. So
+you need to download the kernel source. You may choose the nearest
+mirror from www.kernel.org, or you are using Fedora Core 5, for
+example, you may need to install RPMs such as:
+kernel-smp-devel-2.16.15-1.2054_FC5.i686.rpm
+kernel-devel-2.6.15-1.2054_FC5.i686.rpm
+etc. You can find a detailed information <a href="http://www.howtoforge.com/kernel_compilation_fedora">here.</a>
+</p>
 
-<p>
+<p>You will find drm_drv.c at /usr/src/LINUX-VERSION/drivers/char/drm/. Edit this code and comment out the following part:
+</p>
+
+<pre>
+   /* ||
+   ((ioctl-&gt;flags &amp; DRM_MASTER) &amp;&amp; !priv-&gt;master)*/
+</pre>
+Now you are ready to compile your kernel. If your kernel version is
+identical to the version you have compiled, you can simply over write
+your new "ko" files over older ones. If you have compiled a different
+kernel, you must configure your grub or lilo to be able to boot your
+new kernel. <p>
 You'll need fbdev header files.  Check with:
 </p>
 <pre>
-   ls -l /usr/include/linux/fb.h
+   ls -l /usr/include/linux/fb.
 </pre>
+<p>This file may be missing if you have not installed linux header files.
 
-<p>
-Compile Mesa with the 'linux-solo' configuration:
+
+<h2>2.4 Mesa</h2>
+
+</p><p>Get latest development Mesa sources from git repository
+(currently 7.1-prerelease)
+</p>
+<pre>
+   git clone git://anongit.freedesktop.org/git/mesa/mesa
+</pre>
+
+<p>You will need the makedepend utility which is a part of mesa project
+to build your linux-solo. You probably wont have this utility. You can
+download its source from following git repulsitory:
 </p>
 <pre>
-   make linux-solo
+   git clone git://anongit.freedesktop.org/git/xorg/util/makedepend
+</pre>
+
+<p>Get the latest stable mesa version from SourceForge (currently 7.0.3)
+<a href="http://sourceforge.net/project/showfiles.php?group_id=3">http://sourceforge.net/project/showfiles.php?group_id=3</a>
+</p>
+
+<p>Copy the miniglx folder from 7.1-prerelease to 7.0.3.
+You may also extract GLUT to 7.0.3 version at this step. 
+</p>
+
+<p>Edit linux-solo.conf at /conf directory, just only compile the
+graphics driver you need, delete the unwanted drivers names from the
+list(some drivers are causing problems...)
+</p>
+<pre>
+   while(build==0)
+   {
+     make linux-solo
+
+     There will be some missing header files, copy them from 7.1-prerelease
+   }
 </pre>
 
 <p>
@@ -71,22 +154,40 @@ When complete you should have the following:
 </p>
 <ul>
 <li>lib/libGL.so - the GL library which applications link with
-<li>lib/*_dri_so - DRI drivers
-<li>lib/miniglx.conf - sample MiniGLX config file
-<li>progs/miniglx/* - several MiniGLX sample programs
-</ul>
+</li><li>lib/*_dri_so - DRI drivers
+</li><li>lib/miniglx.conf - sample MiniGLX config file
+</li><li>progs/miniglx/* - several MiniGLX sample programs
+</li></ul>
+
+To install these files into appropriate locations in system:
+<pre>
+   make install
+</pre>
 
+Now your openGL libraries are copied to /usr/local/lib and
+miniglx.conf is copied to /etc. You may copy them to /usr/lib and
+overwrite your old GL libraries. Or you may export following variable:
+
+<pre>
+   export LIBGL_DRIVERS_PATH=/usr/local/lib
+</pre>
+<br>
 
 
 <h1>3. Using fbdev/DRI</h1>
 
 <p>
 If an X server currently running, exit/stop it so you're working from
-the console.
+the console. Following command shuts down the x window and also the multi user support.
 </p>
+<pre>
+   init 1
+</pre>
 
-
-<h2>3.1 Load Kernel Modules</h2>
+<p>Also you may define the runlevel as 1 in "/etc/inittab". Your system
+will always start in single user mode and without x-window with this
+option set.
+</p><h2>3.1 Load Kernel Modules</h2>
 
 <p>
 You'll need to load the kernel modules specific to your graphics hardware.
@@ -100,8 +201,7 @@ As root, the kernel modules can be loaded as follows:
 <p>
 If you have Intel i915/i945 hardware:
 </p>
-<pre>
-   modprobe agpgart            # the AGP GART module
+<pre>   modprobe agpgart            # the AGP GART module
    modprobe intelfb            # the Intel fbdev driver
    modprobe i915               # the i915/945 DRI kernel module
 </pre>
@@ -109,8 +209,7 @@ If you have Intel i915/i945 hardware:
 <p>
 If you have ATI Radeon/R200 hardware:
 </p>
-<pre>
-   modprobe agpgart            # the AGP GART module
+<pre>   modprobe agpgart            # the AGP GART module
    modprobe radeonfb           # the Radeon fbdev driver
    modprobe radeon             # the Radeon DRI kernel module
 </pre>
@@ -118,8 +217,7 @@ If you have ATI Radeon/R200 hardware:
 <p>
 If you have ATI Rage 128 hardware:
 </p>
-<pre>
-   modprobe agpgart            # the AGP GART module
+<pre>   modprobe agpgart            # the AGP GART module
    modprobe aty128fb           # the Rage 128 fbdev driver
    modprobe r128               # the Rage 128 DRI kernel module
 </pre>
@@ -127,8 +225,7 @@ If you have ATI Rage 128 hardware:
 <p>
 If you have Matrox G200/G400 hardware:
 </p>
-<pre>
-   modprobe agpgart            # the AGP GART module
+<pre>   modprobe agpgart            # the AGP GART module
    modprobe mgafb              # the Matrox fbdev driver
    modprobe mga                # the Matrox DRI kernel module
 </pre>
@@ -136,8 +233,7 @@ If you have Matrox G200/G400 hardware:
 <p>
 To verify that the agpgart, fbdev and drm modules are loaded:
 </p>
-<pre>
-   ls -l /dev/agpgart /dev/fb* /dev/dri
+<pre>   ls -l /dev/agpgart /dev/fb* /dev/dri
 </pre>
 <p>
 Alternately, use lsmod to inspect the currently installed modules.
@@ -148,16 +244,15 @@ If you have problems, look at the output of dmesg.
 <h2>3.2 Configuration File</h2>
 
 <p>
-Copy the sample miniglx.conf to /etc/miniglx.conf and review/edit its contents.
+review/edit /etc/miniglx.conf.
 Alternately, the MINIGLX_CONF environment variable can be used to
 indicate the location of miniglx.conf
 </p>
 
 To determine the pciBusID value, run lspci and examine the output.
 For example:
-</p>
-<pre>
-   /sbin/lspci:
+<p></p>
+<pre>   /sbin/lspci:
    00:02.0 VGA compatible controller: Intel Corporation 82915G/GV/910GL Express Chipset Family Graphics Controller (rev 04)
 </pre>
 <p>
@@ -180,15 +275,13 @@ for example.
 Change to the <code>Mesa/progs/miniglx/</code> directory and
 start the sample_server program in the background:
 </p>
-<pre>
-   ./sample_server &amp;
+<pre>   ./sample_server &amp;
 </pre>
 
 <p>
 Then try running the <code>miniglxtest</code> program:
 </p>
-<pre>
-   ./miniglxtest
+<pre>   ./miniglxtest
 </pre>
 <p>
 You should see a rotating quadrilateral which changes color as it rotates.
@@ -199,7 +292,7 @@ It will exit automatically after a bit.
 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>
-
+<br>
 
 
 <h1>4.0 Troubleshooting</h1>
@@ -208,8 +301,7 @@ them from a remote shell so that you can stop them with ctrl-C.
 <li>
 If you try to run miniglxtest and get the following:
 <br>
-<pre>
-   [miniglx] failed to probe chipset
+<pre>   [miniglx] failed to probe chipset
    connect: Connection refused
    server connection lost
 </pre>
@@ -223,7 +315,7 @@ It means that the sample_server process is not running.
 <h1>5.0 Programming Information</h1>
 
 <p>
-OpenGL/Mesa is interfaced to fbdev via the <a href="MiniGLX.html">MiniGLX</a>
+OpenGL/Mesa is interfaced to fbdev via the <a href="http://www.nabble.com/file/p15480666/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
@@ -244,5 +336,6 @@ See the <code>GL/miniglx.h</code> header file for details.
 </p>
 
 
+
 </body>
 </html>
index 346f093d64352ded15b97fa7de414ae269db02e3..4cd92b97a95225a53cbde798200361f77c7cd974 100644 (file)
@@ -6,7 +6,7 @@
 
 <BODY>
 
-<H1>Help Wanted</H1>
+<H1>Help Wanted / To-Do List</H1>
 
 <p>
 We can always use more help with the Mesa project.
@@ -14,36 +14,13 @@ 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>
+<li>
+Enable -Wstrict-aliasing=2 -fstrict-aliasing and track down aliasing
+issues in the code.
+<li>
+Windows 98/NT driver building, maintenance and testing
+<li>
+Maintenance and testing of lesser-used drivers, such as DOS/DJGPP, GGI, etc.
 </ol>
 
 
index 804dee59b5ab3b58684b03c74213dc4b4b53104f..16ef013688aaa3a04b8a9e3b87229142b25159d8 100644 (file)
 <a name="unix-x11">
 <H2>1. Unix/X11 Compilation and Installation</H1>
 
-<h3>1.1 Compilation</h3>
 
+<h3>1.1 Prerequisites for DRI and Hardware Acceleration</h3>
+
+<p>
+To build Mesa 7.1 with DRI-based hardware acceleration you must first have
+the <a href="http://dri.freedesktop.org/libdrm/" target="_parent">DRM version 2.3.1</a>.
+</p>
+
+<p>
+You should also be using the Xorg server version 1.4 or 1.5.
+</p>
+
+
+
+<h3>1.2 Autoconf Compilation</h3>
+
+<p>
+Mesa may be <a href="autoconf.html">built using autoconf</a>.
+This should work well on most GNU-based systems.
+When that fails, the traditional Mesa build system is available.
+
+
+
+<h3>1.3 Traditional Compilation</h3>
+
+<p>
+The traditional Mesa build system is based on a collection of pre-defined
+system configurations.
+</p>
 <p>
-Mesa may be compiled in several different ways:
+To see the list of configurations, type <b>make</b> alone.
+Then choose a configuration from the list and type <b>make configname</b>.
+</p>
+
+<p>
+Mesa may be built in several different ways using the predefined configurations:
 </p>
 <ul>
 <li><b><em>Stand-alone/Xlib mode</em></b> - Mesa will be compiled as
@@ -49,62 +81,6 @@ accelerated OpenGL rendering (for ATI, Intel, Matrox, etc) will be built.
 The libGL.so library will support the GLX extension and will load/use
 the DRI hardware drivers.
 
-<p>
-<b>Prerequisites:</b>
-</p>
-
-<ol>
-
-<li>
-<p>
-DRM kernel modules and header files from the
-<a href="http://dri.sf.net/" target="_parent">DRI</a> project.
-</p>
-
-<p>
-If you don't already have the DRM file, you can get the sources from
-CVS by doing:
-<pre>
-cvs -z3 -d:pserver:anonymous@anoncvs.freedesktop.org:/cvs/dri co drm
-</pre>
-<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.  Mesa
-6.5 requires at least libdrm 2.0.1 or greater.
-</p>
-<p>
-You can verify that the DRM files have been properly installed by
-running <code>pkg-config --modversion libdrm</code>
-
-</li>
-
-<li>
-Recent /usr/include/GL/glxproto.h file.
-<p>You'll need this if you get any errors about _GLXvop_BindTexImageEXT
-being undefined.
-</p>
-<p>
-Download/install the
-<a href="http://gitweb.freedesktop.org/?p=xorg/proto/glproto.git">glproto</a>
-module from X.org git, or grab the
-<A href="http://webcvs.freedesktop.org/*checkout*/xorg/proto/GL/glxproto.h?rev=1.9&content-type=text%2Fplain">glxproto.h file</a> and put it in the
-Mesa/include/GL/ directory.
-</p>
-
-</li>
-
-<li>DRI-enabled X server.
-<p>Visit
-<a href="http://www.xfree86.org" target="_parent">XFree86</a>
-or
-<a href="http://freedesktop.org/wiki/Software_2fXserver" target="_parent">
-X.org</a>
-for more information.
-</p>
-</li>
-
-</ol>
-
 
 <p>
 Build Mesa and the DRI hardware drivers by running
@@ -117,8 +93,13 @@ There are also <code>linux-dri-x86</code>, <code>linux-dri-x86-64</code>,
 and <code>linux-ppc</code> configurations which are optimized for those
 architectures.
 </p>
+<p>
+Make sure you have the prerequisite versions of DRM and Xserver mentioned
+above.
+</p>
 
 </li>
+
 </ul>
 
 
@@ -128,7 +109,7 @@ Later, if you want to rebuild for a different configuration run
 </p>
 
 
-<h3>1.2 The libraries</h3>
+<h3>1.4 The libraries</h3>
 
 <p>
 When compilation has finished, look in the top-level <code>lib/</code>
@@ -169,15 +150,15 @@ lrwxrwxrwx    1 brian    users          23 Mar 26 07:53 libOSMesa.so.6 -> libOSM
 If you built the DRI hardware drivers, you'll also see the DRI drivers:
 </p>
 <pre>
--rwxr-xr-x   1 brian users 15607851 Jul 21 12:11 ffb_dri.so*
--rwxr-xr-x   1 brian users 15148747 Jul 21 12:11 i810_dri.so*
--rwxr-xr-x   1 brian users 14497814 Jul 21 12:11 i830_dri.so*
--rwxr-xr-x   1 brian users 16895413 Jul 21 12:11 i915_dri.so*
+-rwxr-xr-x   1 brian users 15607851 Jul 21 12:11 ffb_dri.so
+-rwxr-xr-x   1 brian users 15148747 Jul 21 12:11 i810_dri.so
+-rwxr-xr-x   1 brian users 14497814 Jul 21 12:11 i830_dri.so
+-rwxr-xr-x   1 brian users 16895413 Jul 21 12:11 i915_dri.so
 -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 16050488 Jul 21 12:11 r300_dri.so*
+-rwxr-xr-x   1 brian users 16050488 Jul 21 12:11 r300_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
@@ -188,7 +169,7 @@ If you built the DRI hardware drivers, you'll also see the DRI drivers:
 </pre>
 
 
-<h3>1.3 Running the demos</h3>
+<h3>1.5 Running the demos</h3>
 
 <p>
 If you downloaded/unpacked the MesaDemos-x.y.z.tar.gz archive or
@@ -197,18 +178,15 @@ 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:
+Before running a demo, you'll probably have to set two environment variables
+to indicate where the libraries are located.  For example:
 <p>
 <blockquote>
-<b>cd</b> into the Mesa <b>lib/</b> directory.
+<b>cd lib/</b>
 <br>
-<b>setenv LD_LIBRARY_PATH ${cwd}</b>   (if using csh or tcsh shell)
+<b>export LD_LIBRARY_PATH=${PWD}</b>
 <br>
-or,
-<br>
-<b>export LD_LIBRARY_PATH=${PWD}</b>   (if using bash or sh shell)
+<b>export LIBGL_DRIVERS_PATH=${PWD}</b> (if using DRI drivers)
 </blockquote>
 
 <p>
@@ -266,7 +244,7 @@ Retrace your steps if this doesn't look right.
 </p>
 
 
-<H3>1.4 Installing the header and library files</H3>
+<H3>1.6 Installing the header and library files</H3>
 
 <p>
 The standard location for the OpenGL header files on Unix-type systems is
@@ -287,7 +265,15 @@ already installed, you'll have to choose different directories, like
 To install Mesa's headers and libraries, run <code>make install</code>.
 But first, check the Mesa/configs/default file and examine the values
 of the <b>INSTALL_DIR</b> and <b>DRI_DRIVER_INSTALL_DIR</b> variables.
-Change them if needed, then run <code>make install</code>
+Change them if needed, then run <code>make install</code>.
+</p>
+
+<p>
+The variable
+<b>DESTDIR</b> may also be used to install the contents to a temporary
+staging directory.
+This can be useful for package management.
+For example: <code>make install DESTDIR=/somepath/</code>
 </p>
 
 <p>
@@ -298,6 +284,26 @@ This is a handy way to compare multiple OpenGL implementations.
 </p>
 
 
+<H3>1.7 Building OpenGL Programs With pkg-config</H3>
+
+<p>
+Running <code>make install</code> will install package configuration files
+for the pkg-config utility.
+</p>
+
+<p>
+When compiling your OpenGL application you can use pkg-config to determine
+the proper compiler and linker flags.
+</p>
+
+<p>
+For example, compiling and linking a GLUT application can be done with:
+</p>
+<pre>
+   gcc `pkg-config --cflags --libs glut` mydemo.c -o mydemo
+</pre>
+
+<br>
 
 <a name="windows">
 <H2>2. Windows Compilation and Installation</H1>
index 0e37322823b4d54cb3ed2411f691e3f5fd6eafec..aae2e6e1928b2dde5302dc09752b6b81a63ea554 100644 (file)
@@ -22,9 +22,10 @@ for modern GPUs.
 
 <p>
 Mesa ties into several other open-source projects: the 
-<a href="http://dri.sf.net/" target="_parent">Direct Rendering Infrastructure</a>
-and <a href="http://x.org" target="_parent">X.org</a> to provide OpenGL
-support to users of X on Linux, FreeBSD and other operating systems.
+<a href="http://dri.freedesktop.org/" target="_parent">Direct Rendering 
+Infrastructure</a> and <a href="http://x.org" target="_parent">X.org</a> to 
+provide OpenGL support to users of X on Linux, FreeBSD and other operating 
+systems.
 </p>
 
 
index 944a5ddf00c82d0d2c2b9e642e67696f52dfcf16..44b980d93da9d4edeb84bba92abf18b6e13de273 100644 (file)
@@ -86,29 +86,32 @@ and their respective licenses.
 <H1>Mesa Component Licenses</H1>
 
 <pre>
-Component         Location               Primary Author      License
-----------------------------------------------------------------------------
-Main Mesa code    src/mesa/              Brian Paul          Mesa (MIT)
+Component         Location               License
+------------------------------------------------------------------
+Main Mesa code    src/mesa/              Mesa (MIT)
 
-Device drivers    src/mesa/drivers/*     See drivers         See drivers
+Device drivers    src/mesa/drivers/*     MIT, generally
 
-Ext headers       include/GL/glext.h     SGI                 SGI Free B
+Ext headers       include/GL/glext.h     Khronos
                   include/GL/glxext.h
 
-GLUT              src/glut/              Mark Kilgard        Mark's copyright
+GLUT              src/glut/              Mark Kilgard's copyright
 
-Mesa GLU library  src/glu/mesa/          Brian Paul          GNU-LGPL
+SGI GLU library   src/glu/sgi/           SGI Free B
 
-SGI GLU library   src/glu/sgi/           SGI                 SGI Free B
+demo programs     progs/demos/           see source files
 
-demo programs     progs/demos/           various             see source files
+X demos           progs/xdemos/          see source files
 
-X demos           progs/xdemos/          Brian Paul          see source files
+SGI demos         progs/samples/         SGI license
 
-SGI demos         progs/samples/         SGI                 SGI copyright
-
-RedBook demos     progs/redbook/         SGI                 SGI copyright
+RedBook demos     progs/redbook/         SGI license
 </pre>
 
+<p>
+In general, consult the source files for license terms.
+</p>
+
+
 </body>
 </html>
index a2cad129cfd85c626b425b2d994bd1126441f404..5227fbd055b2d9392eeeac2e83525245aa0d2f20 100644 (file)
@@ -9,7 +9,7 @@
 <H1>Mailing Lists</H1>
 
 
-<p>There are four Mesa mailing lists:
+<p>There are four Mesa 3D / DRI mailing lists:
 </p>
 
 <ul>
@@ -19,14 +19,14 @@ versions are sent to this list.
 </li>
 <br>
 <li><a href="https://lists.sourceforge.net/lists/listinfo/mesa3d-users"
-target="_parent">mesa3d-users</a> - intended for users of the Mesa library.
+target="_parent">mesa3d-users</a> - intended for users of the Mesa and DRI.
 Newbie questions are appropriate, but please try the general OpenGL
-resources and Mesa documentation first.
+resources and Mesa/DRI documentation first.
 </li>
 <br>
 <li><a href="https://lists.sourceforge.net/lists/listinfo/mesa3d-dev"
-target="_parent">mesa3d-dev</a> - for discussion of Mesa development.
-Not for beginners.
+target="_parent">mesa3d-dev</a> - for discussion of Mesa and Direct Rendering 
+Infrastructure development. Not for beginners.
 </li>
 <br>
 <li><a href="http://lists.freedesktop.org/mailman/listinfo/mesa-commit"
@@ -37,6 +37,9 @@ Note: the old mesa3d-cvs list is no longer in use.
 </li>
 </ul>
 
+<p>For mailing lists about Direct Rendering Modules (drm) in Linux/BSD 
+kernels, see <a href="http://dri.freedesktop.org/wiki/MailingLists">wiki</a>.
+
 <p>
 <b>Notice</b>: non-member posts to any of these lists will be automatically
 rejected.
index b93f4d8b76013faaa0bb04c6d859b53f0c1e1712..aae968695940ea9c83f4e8332e106c7a53454538 100644 (file)
@@ -28,7 +28,7 @@
        </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>
+       </li><li><a href="http://www.openvrml.org/" 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
index b766ce7c75146b6d165dd7d32718b4de4d4edba2..6d0d83659b84574dc73a296ba2535a0f78bcbaa3 100644 (file)
 <H1>News</H1>
 
 
+<h2>August 26, 2008</h2>
+<p>
+<a href="relnotes-7.1.html">Mesa 7.1</a> is released.
+This is a new development release.
+It should be relatively stable, but those especially concerned about
+stability should wait for the 7.2 release or use Mesa 7.0.4 (the
+previous stable release).
+</p>
+
+
+<h2>August 16, 2008</h2>
+<p>
+<a href="relnotes-7.0.4.html">Mesa 7.0.4</a> is released.
+This is a bug-fix release.
+</p>
+
+
+<h2>April 4, 2008</h2>
+<p>
+<a href="relnotes-7.0.3.html">Mesa 7.0.3</a> is released.
+This is a bug-fix release.
+</p>
+
+
+<h2>January 24, 2008</h2>
+
+<p>
+Added a new page describing the <a href="cell.html">Mesa Cell driver</a>.
+</p>
+
+
+
+<h2>November 13, 2007</h2>
+
+<p>
+Gallium3D is the codename for the new Mesa device driver architecture
+which is currently under development.
+A <a href="http://www.tungstengraphics.com/wiki/index.php/Gallium3D"
+target="_parent"> summary</a> of the architecture can be found on the
+Tungsten Graphics website.
+</p>
+<p>
+Gallium3D development is taking place on the <em>gallium-0.1</em> branch
+of the git repository.
+Currently, there's only a software-only driver and an Intel i915/945 driver
+but other drivers will be coming...
+</p>
+
+
+<h2>November 10, 2007</h2>
+<p>
+<a href="relnotes-7.0.2.html">Mesa 7.0.2</a> is released.
+This is a bug-fix release.
+</p>
+
+
+<h2>August 3, 2007</h2>
+<p>
+<a href="relnotes-7.0.1.html">Mesa 7.0.1</a> is released.
+This is a bug-fix release.
+</p>
+
+
 <h2>June 22, 2007</h2>
 <p>
 <a href="relnotes-7.0.html">Mesa 7.0</a> is released.
diff --git a/docs/relnotes-7.0.1.html b/docs/relnotes-7.0.1.html
new file mode 100644 (file)
index 0000000..02713ad
--- /dev/null
@@ -0,0 +1,101 @@
+<HTML>
+
+<TITLE>Mesa Release Notes</TITLE>
+
+<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<body bgcolor="#eeeeee">
+
+<H1>Mesa 7.0.1 Release Notes / August 3, 2007</H1>
+
+<p>
+Mesa 7.0.1 is a stable release with bug fixes since version 7.0.
+</p>
+
+
+<h2>MD5 checksums</h2>
+<pre>
+db55141a44b902fcc61d9265b7862c06  MesaLib-7.0.1.tar.gz
+c056abd763e899114bf745c9eedbf9ad  MesaLib-7.0.1.tar.bz2
+ecc2637547fae2b38271ae362d013afa  MesaLib-7.0.1.zip
+b85a4a5be4e829f4a1165e4514b13183  MesaDemos-7.0.1.tar.gz
+3b66b3268df12ca8a6c4e0c4c457912c  MesaDemos-7.0.1.tar.bz2
+b1c18006f16e44e80fea66774c59b391  MesaDemos-7.0.1.zip
+b87a69986839ae43ce12fc8e3dc1ebb4  MesaGLUT-7.0.1.tar.gz
+25f30d0c1651997b4412366ba0572f7f  MesaGLUT-7.0.1.tar.bz2
+676ee6682a6ce78a5540554fd975c03e  MesaGLUT-7.0.1.zip
+</pre>
+
+
+<h2>New features</h2>
+<ul>
+<li>Added a bluegene-osmesa build config
+</ul>
+
+<h2>Bug fixes</h2>
+<ul>
+<li>Fixed some MingW build issues
+<li>Added a few missing OpenGL 2.0 API entrypoints:
+  <ul>
+  <li>glVertexAttrib4bv
+  <li>glVertexAttrib4iv
+  <li>glVertexAttrib4ubv
+  <li>glVertexAttrib4uiv
+  <li>glVertexAttrib4usv
+  </ul>
+<li>Fixed glDrawPixels(GL_STENCIL_INDEX) pixel transfer bug 11457
+<li>GLSL bug fix: added vec2(vec4) constructor
+<li>GLSL bug fix: .strq and .rgba writemasks didn't always work
+<li>Stencil pixel map didn't always work for glDrawPixels (bug 11475)
+<li>Fixed polygon stipple bug in i915 driver
+<li>Binding a zero-sized texture didn't disable texturing (bug 11309)
+<li>Queries of GL_INFO_LOG_LENGTH, GL_SHADER_SOURCE_LENGTH didn't include
+the terminating zero (bug 11588)
+<li>glXChooseFBConfig() in Xlib driver didn't handle GLX_STEREO flag properly
+<li>Fixed a GLSL function call bug (#11731)
+<li>glPointParameteriv(GL_DISTANCE_ATTENUATION_EXT) didn't work (bug 11754)
+<li>glGetAttribLocation() always returned 1 (bug 11774)
+<li>Fixed a few memory-related bugs in GLU library
+</ul>
+
+
+<h2>Changes</h2>
+<ul>
+<li>The libOSMesa library version has been reverted to 6.5.3 (soname=6)
+in order to avoid application linking issues.  Otherwise, applications
+previously linked with libOSMesa.so.6 would no longer link with libOSMesa.so.7
+<li>Dropped obsolete, unmaintained Windows project files for VC6 and VC7.
+</ul>
+
+
+<h2>To Do (someday) items</h2>
+<ul>
+<li>Switch to freeglut
+<li>Fix linux-glide target/driver.
+<li>Improved lambda and derivative calculation for frag progs.
+</ul>
+
+
+<h2>Driver Status</h2>
+
+<pre>
+Driver                 Status
+---------------------- ----------------------
+DRI drivers            varies with the driver
+XMesa/GLX (on Xlib)    implements OpenGL 2.1
+OSMesa (off-screen)    implements OpenGL 2.1
+Windows/Win32          implements OpenGL 2.1
+Glide (3dfx Voodoo1/2) implements OpenGL 1.3
+SVGA                   unsupported
+Wind River UGL         unsupported
+DJGPP                  unsupported
+GGI                    unsupported
+BeOS                   unsupported
+Allegro                        unsupported
+D3D                    unsupported
+</pre>
+
+</body>
+</html>
diff --git a/docs/relnotes-7.0.2.html b/docs/relnotes-7.0.2.html
new file mode 100644 (file)
index 0000000..7a7c70f
--- /dev/null
@@ -0,0 +1,88 @@
+<HTML>
+
+<TITLE>Mesa Release Notes</TITLE>
+
+<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<body bgcolor="#eeeeee">
+
+<H1>Mesa 7.0.2 Release Notes / November 10, 2007</H1>
+
+<p>
+Mesa 7.0.2 is a stable release with bug fixes since version 7.0.
+</p>
+
+
+<h2>MD5 checksums</h2>
+<pre>
+c9cf607f36e7e50172f5f9c7d552c34e  MesaLib-7.0.2.tar.gz
+93e6ed7924ff069a4f883b4fce5349dc  MesaLib-7.0.2.tar.bz2
+10c324c3613f90f059cb8429f700f300  MesaLib-7.0.2.zip
+aa8b1244a5de1d23e5814bf9b67f1435  MesaDemos-7.0.2.tar.gz
+11a10410bae7be85cf25bc7119966468  MesaDemos-7.0.2.tar.bz2
+1dd0b5fd6d69430a2fd76a6adbfd8fff  MesaDemos-7.0.2.zip
+a7dbf25c025955858bd2d89a6eb6db4c  MesaGLUT-7.0.2.tar.gz
+3a33f8efc8c58a592a854cfc7a643286  MesaGLUT-7.0.2.tar.bz2
+eba4ef2aa8c362ead81b54357f1903a3  MesaGLUT-7.0.2.zip
+</pre>
+
+
+<h2>New features</h2>
+<ul>
+<li>Updated Windows VC7 project files
+<li>Added DESTDIR variable for 'make install'
+<li>Added pkg-config files for gl, glu, glut and glw libraries
+<li>Added bluegene-xlc-osmesa and catamount-osmesa-pgi configs
+<li>Support for Intel G33/Q33/Q35 graphics chipsets
+</ul>
+
+<h2>Bug fixes</h2>
+<ul>
+<li>Fixed a vertex buffer wrapping issue (bug 9962)
+<li>Added mutex protection around texture object reference counters
+<li>Added checking/support for additional chips in the i915/i945 family
+(see 11978)
+<li>Fixed a blending/banding issue (bug 11931)
+<li>Fixed a GLU matrix inversion bug (#6748)
+<li>Fixed problem with large glDrawArrays calls and indirect rendering (bug 12141)
+<li>Fixed an assortment of i965 driver bugs
+<li>Fixed x86-64 vertex transformation bug (12216)
+<li>Fixed X server crash caused by multiple indirect rendering clients
+<li>Parsing of state.texgen in ARB vertex/fragment programs didn't work (bug 12313)
+<li>Fixed a glCopyPixels/glPixelZoom bug (12417)
+<li>Fixed a bug when using glMaterial in display lists (bug 10604)
+<li>Fixed a few GLUT/Fortran issues (Bill Mitchell)
+<li>Fixed Blender crash bug (12164)
+<li>Fixed some issues preventing cross-compiling
+<li>Fixed up broken GL_ATI_separate_stencil extension
+<li>glDrawArrays(count=0) led to a crash
+<li>Fix SSE code gen memory leak, possible crash
+<li>Fixed MMX 565 rgb conversion problem (bug 12614)
+<li>Added -fno-strict-aliasing and -fPIC flags for gcc
+<li>Fixed Blender crash in Unichrome driver (bug 13142)
+</ul>
+
+
+<h2>Driver Status</h2>
+
+<pre>
+Driver                 Status
+---------------------- ----------------------
+DRI drivers            varies with the driver
+XMesa/GLX (on Xlib)    implements OpenGL 2.1
+OSMesa (off-screen)    implements OpenGL 2.1
+Windows/Win32          implements OpenGL 2.1
+Glide (3dfx Voodoo1/2) implements OpenGL 1.3
+SVGA                   unsupported
+Wind River UGL         unsupported
+DJGPP                  unsupported
+GGI                    unsupported
+BeOS                   unsupported
+Allegro                        unsupported
+D3D                    unsupported
+</pre>
+
+</body>
+</html>
diff --git a/docs/relnotes-7.0.3.html b/docs/relnotes-7.0.3.html
new file mode 100644 (file)
index 0000000..5c8efc7
--- /dev/null
@@ -0,0 +1,84 @@
+<HTML>
+
+<TITLE>Mesa Release Notes</TITLE>
+
+<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<body bgcolor="#eeeeee">
+
+<H1>Mesa 7.0.3 Release Notes / April 4, 2008</H1>
+
+<p>
+Mesa 7.0.3 is a stable release with bug fixes since version 7.0.2.
+</p>
+
+
+<h2>MD5 checksums</h2>
+<pre>
+3fd1cb76531b2515ef7db92d9a93dbf8  MesaLib-7.0.3.tar.gz
+e6e6379d7793af40a6bc3ce1bace572e  MesaLib-7.0.3.tar.bz2
+97882bac195229ee0b78cab82e0e3be1  MesaLib-7.0.3.zip
+8abf6bbcb1661e7dd4ce73b3fbb85898  MesaDemos-7.0.3.tar.gz
+47fd6863621d3c9c7dbb870ab7f0c303  MesaDemos-7.0.3.tar.bz2
+99e442e14da1928f76a7297bb421a3af  MesaDemos-7.0.3.zip
+2b50fe9fadc4709b57c52adef09fce3c  MesaGLUT-7.0.3.tar.gz
+0ff23c4e91b238abae63a5fc9fa003e7  MesaGLUT-7.0.3.tar.bz2
+70e83554a4462dad28e0d6e20f79aada  MesaGLUT-7.0.3.zip
+</pre>
+
+
+<h2>Bug fixes</h2>
+<ul>
+<li>Added missing glw.pc.in file to release tarball
+<li>Fix GLUT/Fortran issues
+<li>GLSL gl_FrontLightModelProduct.sceneColor variable wasn't defined
+<li>Fix crash upon GLSL variable array indexes (not yet supported)
+<li>Two-sided stencil test didn't work in software rendering
+<li>Fix two-sided lighting bugs/crashes (bug 13368)
+<li>GLSL gl_FrontFacing didn't work properly
+<li>glGetActiveUniform returned incorrect sizes (bug 13751)
+<li>Fix several bugs relating to uniforms and attributes in GLSL API (Bruce Merry, bug 13753)
+<li>glTexImage3D(GL_PROXY_TEXTURE_3D) mis-set teximage depth field
+<li>Fixed GLX indirect vertex array rendering bug (14197)
+<li>Fixed crash when deleting framebuffer objects (bugs 13507, 14293)
+<li>User-defined clip planes enabled for R300 (bug 9871)
+<li>Fixed glBindTexture() crash upon bad target (bug 14514)
+<li>Fixed potential crash in glDrawPixels(GL_DEPTH_COMPONENT) (bug 13915)
+<li>Bad strings given to glProgramStringARB() didn't generate GL_INVALID_OPERATION
+<li>Fixed minor point rasterization regression (bug 11016)
+<li>state.texenv.color state var didn't work in GL_ARB_fragment_program (bug 14931)
+<li>glBitmap from a PBO didn't always work
+<li>glGetTexImage into a PBO didn't always work
+<li>Comments at the end of ARB vertex/fragment programs crashed the parser
+</ul>
+
+<h2>Changes</h2>
+<ul>
+<li>Updated glext.h to version 40
+</ul>
+
+
+
+<h2>Driver Status</h2>
+
+<pre>
+Driver                 Status
+---------------------- ----------------------
+DRI drivers            varies with the driver
+XMesa/GLX (on Xlib)    implements OpenGL 2.1
+OSMesa (off-screen)    implements OpenGL 2.1
+Windows/Win32          implements OpenGL 2.1
+Glide (3dfx Voodoo1/2) implements OpenGL 1.3
+SVGA                   unsupported
+Wind River UGL         unsupported
+DJGPP                  unsupported
+GGI                    unsupported
+BeOS                   unsupported
+Allegro                        unsupported
+D3D                    unsupported
+</pre>
+
+</body>
+</html>
diff --git a/docs/relnotes-7.0.4.html b/docs/relnotes-7.0.4.html
new file mode 100644 (file)
index 0000000..f100d99
--- /dev/null
@@ -0,0 +1,80 @@
+<HTML>
+
+<TITLE>Mesa Release Notes</TITLE>
+
+<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<body bgcolor="#eeeeee">
+
+<H1>Mesa 7.0.4 Release Notes / August 16, 2008</H1>
+
+<p>
+Mesa 7.0.4 is a stable release with bug fixes since version 7.0.3.
+</p>
+
+
+<h2>MD5 checksums</h2>
+<pre>
+909afa3a01ae31478d363837681415ac  MesaLib-7.0.4.tar.gz
+8d7bacbe0234742a5d08c8088c4619e9  MesaLib-7.0.4.tar.bz2
+5e44261ef85b049a868e1785d9adc276  MesaLib-7.0.4.zip
+53dcd77d37a819feaf50b5fcdd0a6e0f  MesaDemos-7.0.4.tar.gz
+c1215b31c5f7b85f81eed3bfba07d556  MesaDemos-7.0.4.tar.bz2
+b1825a7361f116b28d82d328077630b4  MesaDemos-7.0.4.zip
+d7677d015f52602d1bf8b837fb717848  MesaGLUT-7.0.4.tar.gz
+f5f8b46f7e763d9f7b7d1d115c1c44ee  MesaGLUT-7.0.4.tar.bz2
+a786775271a02c62a3370b13b26bf48d  MesaGLUT-7.0.4.zip
+</pre>
+
+
+<h2>Bug fixes</h2>
+<ul>
+<li>define #extension GL_ARB_texture_rectangle in shading language
+<li>fixed WIN32 compile problem in libGLU
+<li>Fixed a per-vertex glMaterial bug which could cause bad lighting
+<li>Fixed potential crash in AA/smoothed triangle rendering when using a fragment shader
+<li>Fixed glDrawElement + VBO segfault (bug 16156)
+<li>Fixed GLSL linker bug causing generic vertex attributes to get aliased
+<li>Fixed stack overflow when using glPixelZoom on Windows
+<li>Fixed broken all(bvec2) GLSL function, added misc missing bvec constructors
+<li>ARB program "state.clip[n].plane" didn't parse correctly
+<li>Fixed broken glGetUniformiv() (bug 13774)
+</ul>
+
+<h2>Changes</h2>
+<ul>
+<li>Including the latest glext.h and glxext.h header files from Khronos
+<li>Added support for DragonFly OS
+<li>Added a build config for FreeBSD static libs (Anatolij Shkodin)
+<li>Enabled GL_EXT_multi_draw_arrays extension in R200/R300 drivers
+<li>Enabled GL_ARB_point_sprite extension in I965 driver
+<li>Enabled GL_EXT_texture_sRGB extension in I965 driver
+<li>Added support for GL shading language in I965 driver
+</ul>
+
+
+
+
+<h2>Driver Status</h2>
+
+<pre>
+Driver                 Status
+---------------------- ----------------------
+DRI drivers            varies with the driver
+XMesa/GLX (on Xlib)    implements OpenGL 2.1
+OSMesa (off-screen)    implements OpenGL 2.1
+Windows/Win32          implements OpenGL 2.1
+Glide (3dfx Voodoo1/2) implements OpenGL 1.3
+SVGA                   unsupported
+Wind River UGL         unsupported
+DJGPP                  unsupported
+GGI                    unsupported
+BeOS                   unsupported
+Allegro                        unsupported
+D3D                    unsupported
+</pre>
+
+</body>
+</html>
index d5d285803e8b52ee8071b367308c169860313a01..e8a39c8d34bd0c5f2f113026522039f65fd0abbf 100644 (file)
@@ -8,32 +8,54 @@
 
 <body bgcolor="#eeeeee">
 
-<H1>Mesa 7.1 Release Notes / (<em>in progress</em>)</H1>
+<H1>Mesa 7.1 Release Notes / August 26, 2008</H1>
 
 <p>
 Mesa 7.1 is a new development release.
+There have been many internal code changes since Mesa 7.0.x.
+It should be relatively stable, but those who are especially concerned about
+stability should wait for Mesa 7.2 or use Mesa 7.0.4 (the previous stable
+release).
+</p>
+</>
+Note that this version of Mesa does not use the GEM memory manager.
+The master branch of git uses GEM.
+</p>
+<p>
+DRM version 2.3.1 should be used with Mesa 7.1
 </p>
 
 
 <h2>MD5 checksums</h2>
 <pre>
-TBD
+971c2fe6e6949dc5ba200a6f97a6dc81  MesaLib-7.1.tar.gz
+6bff7f532d16f90f944a400c8bd7074d  MesaLib-7.1.tar.bz2
+d48224bf9d54c3da6776adb4869ba024  MesaLib-7.1.zip
+3de268420efca43e9a19ab506cdfc993  MesaDemos-7.1.tar.gz
+abfc9775e1462363af8ec160d1feb01f  MesaDemos-7.1.tar.bz2
+f7b3623387c4036e9895cd9ac0dfad99  MesaDemos-7.1.zip
+fdf348f78cd09304b6ff801ef8acc8eb  MesaGLUT-7.1.tar.gz
+f6d88a4eeb02e98c7e92f1c895d3c76b  MesaGLUT-7.1.tar.bz2
+4dc102a5ca51e1c41dde87d3f8c7b22a  MesaGLUT-7.1.zip
 </pre>
 
 
 <h2>New features</h2>
 <ul>
+<li>autoconf-based configuration (and clean-up of Makefiles)
+<li>Assorted DRI driver enhancements
+<li>Reduced dependencies between X server and Mesa
 <li>GL_EXT_texture_from_pixmap extension for Xlib driver
+<li>Support for the GL shading language with i965 driver (implemented by Intel)
+<li>ATI R500 series support (Radeon X1300&#8211;X1950) in r300 DRI driver
 </ul>
 
 
 <h2>Bug fixes</h2>
 <ul>
-</ul>
-
-
-<h2>Internal code changes</h2>
-<ul>
+<li>Numerous GLSL fixes
+<li>Fixed some error code/detection bugs in the GLSL-related API functions
+<li>Lots of DRI driver fixes.
 </ul>
 
 
index 73bae8590f8c9cdb8cddcb0f09ea68b3d9e59157..e305977163841dff0bbcec2485008c29d6a2221e 100644 (file)
@@ -21,6 +21,10 @@ The release notes summarize what's new or changed in each Mesa release.
 
 <UL>
 <LI><A HREF="relnotes-7.1.html">7.1 release notes</A>
+<LI><A HREF="relnotes-7.0.4.html">7.0.4 release notes</A>
+<LI><A HREF="relnotes-7.0.3.html">7.0.3 release notes</A>
+<LI><A HREF="relnotes-7.0.2.html">7.0.2 release notes</A>
+<LI><A HREF="relnotes-7.0.1.html">7.0.1 release notes</A>
 <LI><A HREF="relnotes-7.0.html">7.0 release notes</A>
 <LI><A HREF="relnotes-6.5.3.html">6.5.3 release notes</A>
 <LI><A HREF="relnotes-6.5.2.html">6.5.2 release notes</A>
index 39f5da4bbe7a84a55bb5bb95a4b54489d654f80c..ed385288eab51da475e4af44b11a818a6b3ea2fa 100644 (file)
@@ -85,6 +85,27 @@ Once your account is established:
 </ol>
 
 
+<H2>Windows Users</H2>
+
+<p>
+If you're <a href="http://git.or.cz/gitwiki/WindowsInstall" target="_parent">
+using git on Windows</a> you'll want to enable automatic CR/LF conversion in
+your local copy of the repository:
+</p>
+<pre>
+   git config --global core.autocrlf true
+</pre>
+
+<p>
+This will cause git to convert all text files to CR+LF on checkout,
+and to LF on commit.
+</p>
+<p>
+Unix users don't need to set this option.
+</p>
+<br>
+
+
 <a name="developer">
 <H2>Development Branches</H2>
 
index 0e1a5e1a7bcec5e639fc2bcdd59a980df976f2d2..2cd17c76ac927fede0709978942559766d26ed6a 100644 (file)
@@ -25,9 +25,10 @@ Contents
 <li><a href="#unsup">Unsupported Features</a>
 <li><a href="#notes">Implementation Notes</a>
 <li><a href="#hints">Programming Hints</a>
-<li><a href="#standalone">Stand-alone Compiler</a>
+<li><a href="#standalone">Stand-alone GLSL Compiler</a>
 <li><a href="#implementation">Compiler Implementation</a>
 <li><a href="#validation">Compiler Validation</a>
+<li><a href="#120">GLSL 1.20 support</a>
 </ul>
 
 
@@ -48,6 +49,7 @@ in Mesa:
 <li>The inverse trig functions asin(), acos(), and atan() are not implemented
 <li>The gl_Color and gl_SecondaryColor varying vars are interpolated
     without perspective correction
+<li>Floating point literal suffixes 'f' and 'F' aren't allowed.
 </ul>
 
 <p>
@@ -132,7 +134,7 @@ These issues will be addressed/resolved in the future.
 
 
 <a name="standalone">
-<h2>Stand-alone Compiler</h2>
+<h2>Stand-alone GLSL Compiler</h2>
 
 <p>
 A unique stand-alone GLSL compiler driver has been added to Mesa.
@@ -154,12 +156,10 @@ This tool is useful for:
 </ul>
 
 <p>
-To build the glslcompiler program (this will be improved someday):
+After building Mesa, the glslcompiler can be built by manually running:
 </p>
 <pre>
-    cd src/mesa
-    make libmesa.a
-    cd drivers/glslcompiler
+    cd src/mesa/drivers/glslcompiler
     make
 </pre>
 
@@ -169,20 +169,31 @@ Here's an example of using the compiler to compile a vertex shader and
 emit GL_ARB_vertex_program-style instructions:
 </p>
 <pre>
-    glslcompiler --arb --linenumbers --vs vertshader.txt
+    bin/glslcompiler --debug --numbers --fs progs/glsl/CH06-brick.frag.txt
 </pre>
 <p>
-The output may look similar to this:
+results in:
 </p>
 <pre>
-!!ARBvp1.0
-  0: MOV result.texcoord[0], vertex.texcoord[0];
-  1: DP4 temp0.x, state.matrix.mvp.row[0], vertex.position;
-  2: DP4 temp0.y, state.matrix.mvp.row[1], vertex.position;
-  3: DP4 temp0.z, state.matrix.mvp.row[2], vertex.position;
-  4: DP4 temp0.w, state.matrix.mvp.row[3], vertex.position;
-  5: MOV result.position, temp0;
-  6: END
+# Fragment Program/Shader
+  0: RCP TEMP[4].x, UNIFORM[2].xxxx;
+  1: RCP TEMP[4].y, UNIFORM[2].yyyy;
+  2: MUL TEMP[3].xy, VARYING[0], TEMP[4];
+  3: MOV TEMP[1], TEMP[3];
+  4: MUL TEMP[0].w, TEMP[1].yyyy, CONST[4].xxxx;
+  5: FRC TEMP[1].z, TEMP[0].wwww;
+  6: SGT.C TEMP[0].w, TEMP[1].zzzz, CONST[4].xxxx;
+  7: IF (NE.wwww); # (if false, goto 9);
+  8:    ADD TEMP[1].x, TEMP[1].xxxx, CONST[4].xxxx;
+  9: ENDIF;
+ 10: FRC TEMP[1].xy, TEMP[1];
+ 11: SGT TEMP[2].xy, UNIFORM[3], TEMP[1];
+ 12: MUL TEMP[1].z, TEMP[2].xxxx, TEMP[2].yyyy;
+ 13: LRP TEMP[0], TEMP[1].zzzz, UNIFORM[0], UNIFORM[1];
+ 14: MUL TEMP[0].xyz, TEMP[0], VARYING[1].xxxx;
+ 15: MOV OUTPUT[0].xyz, TEMP[0];
+ 16: MOV OUTPUT[0].w, CONST[4].yyyy;
+ 17: END
 </pre>
 
 <p>
@@ -308,5 +319,39 @@ should be added.
 </p>
 
 
+
+<a name="120">
+<h2>GLSL 1.20 support</h2>
+
+<p>
+Support for GLSL version 1.20 is underway.  Status as follows.
+</p>
+
+<h3>Supported</h3>
+<ul>
+<li><code>mat2x3, mat2x4</code>, etc. types and functions
+<li><code>transpose(), outerProduct(), matrixCompMult()</code> functions
+(but untested)
+<li>precision qualifiers (lowp, mediump, highp)
+</ul>
+
+<h3>Partially Complete</h3>
+<ul>
+<li><code>invariant</code> qualifier
+</ul>
+
+<h3>Not Completed</h3>
+<ul>
+<li><code>array.length()</code> method
+<li><code>float[5] a;</code> array syntax
+<li><code>centroid</code> qualifier
+<li>unsized array constructors
+<li>initializers for uniforms
+<li>const initializers calling built-in functions
+</ul>
+
+
+
+
 </BODY>
 </HTML>
index d8dd555b05efd58405ae728ad8e0b476ac5f720f..15ade4043b8a9c8d99df66de99871fa0fcf55b9f 100644 (file)
@@ -29,5 +29,5 @@ subset: $(SUBSET:.doxy=.tag)
        $(foreach FILE,$(SUBSET),doxygen $(FILE);)
 
 clean:
-       rm -rf $(FULL:.doxy=) $(SUBSET:.doxy=)
-       rm -rf *.tag
+       -rm -rf $(FULL:.doxy=) $(SUBSET:.doxy=)
+       -rm -rf *.tag
diff --git a/include/GL/foomesa.h b/include/GL/foomesa.h
deleted file mode 100644 (file)
index 8517d88..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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
index d82103d141ac94322efd5ec2a6627139d6147796..7db4b707b51c0d882fba22b4b8decbe1dbcb13a8 100644 (file)
 #define GLAPIENTRYP GLAPIENTRY *
 #endif
 
-#ifdef GLAPI
-#undef GLAPI
-#endif
-
-#  if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GLU32)
-#    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 */
-
-
-#ifndef GLAPI
-#define GLAPI
-#endif
+#if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GLU32)
+# undef GLAPI
+# define GLAPI __declspec(dllexport)
+#elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL)
+/* tag specifying we're building for DLL runtime support */
+# undef GLAPI
+# define GLAPI __declspec(dllimport)
+#elif !defined(GLAPI)
+/* for use with static link lib build of Win32 edition only */
+# define GLAPI extern
+#endif /* _STATIC_MESA support */
 
 #ifdef __cplusplus
 extern "C" {
index e286349f9b01c3903b4f9104c9aaf36ba1531661..137b8efa13aa2a6dfc285dcca1ea0ff020a66c8d 100644 (file)
@@ -112,7 +112,7 @@ extern _CRTIMP void __cdecl exit(int);
    and redifinition of Windows system defs, also removes requirement of
    pretty much any standard windows header from this file */
 
-#if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__CYGWIN32__)
+#if (_MSC_VER >= 800) || defined(__MINGW32__) || defined(_STDCALL_SUPPORTED) || defined(__CYGWIN32__)
 #      define GLUTAPIENTRY __stdcall
 #else
 #      define GLUTAPIENTRY
index 7ba3e19ef9e0c216275e9efb07451bbccaf9e311..8a3a86727cf2251ab13fd21f2a502e3d400d897f 100644 (file)
@@ -75,7 +75,7 @@ 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);
+GLUTAPI GLUTproc APIENTRY __glutGetFCB(int which);
+GLUTAPI void APIENTRY __glutSetFCB(int which, GLUTproc func);
 
 #endif  /* __glutf90_h__ */
index 8d24e311f848d0dbaa42f82f2087ef1b80acbaf2..e4cc16b8660824e3bcb7afe6836bdf5c5ab84857 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2007-2008 Red Hat, Inc.
  * (C) Copyright IBM Corporation 2004
  * All Rights Reserved.
  *
  * 
  * \author Kevin E. Martin <kevin@precisioninsight.com>
  * \author Ian Romanick <idr@us.ibm.com>
+ * \author Kristian Høgsberg <krh@redhat.com>
  */
 
 #ifndef DRI_INTERFACE_H
 #define DRI_INTERFACE_H
 
-#include <GL/internal/glcore.h>
+/* Make this something other than __APPLE__ for other arcs with no drm.h */
+#ifndef __APPLE__
 #include <drm.h>
+#else
+typedef unsigned int drm_context_t;
+typedef unsigned int drm_drawable_t;
+typedef struct drm_clip_rect drm_clip_rect_t;
+#endif
 
 /**
  * \name DRI interface structures
  * 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;
+typedef struct __DRIdisplayRec         __DRIdisplay;
+typedef struct __DRIscreenRec          __DRIscreen;
+typedef struct __DRIcontextRec         __DRIcontext;
+typedef struct __DRIdrawableRec                __DRIdrawable;
+typedef struct __DRIconfigRec          __DRIconfig;
+typedef struct __DRIframebufferRec     __DRIframebuffer;
+typedef struct __DRIversionRec         __DRIversion;
+
+typedef struct __DRIcoreExtensionRec           __DRIcoreExtension;
+typedef struct __DRIextensionRec               __DRIextension;
+typedef struct __DRIcopySubBufferExtensionRec  __DRIcopySubBufferExtension;
+typedef struct __DRIswapControlExtensionRec    __DRIswapControlExtension;
+typedef struct __DRIallocateExtensionRec       __DRIallocateExtension;
+typedef struct __DRIframeTrackingExtensionRec  __DRIframeTrackingExtension;
+typedef struct __DRImediaStreamCounterExtensionRec     __DRImediaStreamCounterExtension;
+typedef struct __DRItexOffsetExtensionRec      __DRItexOffsetExtension;
+typedef struct __DRItexBufferExtensionRec      __DRItexBufferExtension;
+typedef struct __DRIlegacyExtensionRec         __DRIlegacyExtension;
+typedef struct __DRIswrastExtensionRec         __DRIswrastExtension;
+typedef struct __DRIbufferRec                  __DRIbuffer;
+typedef struct __DRIdri2ExtensionRec           __DRIdri2Extension;
+typedef struct __DRIdri2LoaderExtensionRec     __DRIdri2LoaderExtension;
+
 /*@}*/
 
 
 /**
- * \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.
+ * Extension struct.  Drivers 'inherit' from this struct by embedding
+ * it as the first element in the extension struct.
  *
- * \sa glXGetScreenDriver, glXGetProcAddress, glXGetDriverConfig
+ * We never break API in for a DRI extension.  If we need to change
+ * the way things work in a non-backwards compatible manner, we
+ * introduce a new extension.  During a transition period, we can
+ * leave both the old and the new extension in the driver, which
+ * allows us to move to the new interface without having to update the
+ * loader(s) in lock step.
+ *
+ * However, we can add entry points to an extension over time as long
+ * as we don't break the old ones.  As we add entry points to an
+ * extension, we increase the version number.  The corresponding
+ * #define can be used to guard code that accesses the new entry
+ * points at compile time and the version field in the extension
+ * struct can be used at run-time to determine how to use the
+ * extension.
  */
-typedef const char * (* PFNGLXGETSCREENDRIVERPROC) (__DRInativeDisplay *dpy, int scrNum);
+struct __DRIextensionRec {
+    const char *name;
+    int version;
+};
 
 /**
- * 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
+ * The first set of extension are the screen extensions, returned by
+ * __DRIcore::getExtensions().  This entry point will return a list of
+ * extensions and the loader can use the ones it knows about by
+ * casting them to more specific extensions and advertising any GLX
+ * extensions the DRI extensions enables.
  */
-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.
+ * Used by drivers to indicate support for setting the read drawable.
  */
-typedef void (* PFNGLXSCRENABLEEXTENSIONPROC) ( void *psc, const char * name );
-/*@}*/
-
+#define __DRI_READ_DRAWABLE "DRI_ReadDrawable"
+#define __DRI_READ_DRAWABLE_VERSION 1
 
 /**
- * \name Functions and data provided by the driver.
+ * Used by drivers that implement the GLX_MESA_copy_sub_buffer extension.
  */
-/*@{*/
-
-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;
-
+#define __DRI_COPY_SUB_BUFFER "DRI_CopySubBuffer"
+#define __DRI_COPY_SUB_BUFFER_VERSION 1
+struct __DRIcopySubBufferExtensionRec {
+    __DRIextension base;
+    void (*copySubBuffer)(__DRIdrawable *drawable, int x, int y, int w, int h);
+};
 
 /**
- * XML document describing the configuration options supported by the
- * driver.
+ * Used by drivers that implement the GLX_SGI_swap_control or
+ * GLX_MESA_swap_control extension.
  */
-extern const char __driConfigOptions[];
-
-/*@}*/
-
+#define __DRI_SWAP_CONTROL "DRI_SwapControl"
+#define __DRI_SWAP_CONTROL_VERSION 1
+struct __DRIswapControlExtensionRec {
+    __DRIextension base;
+    void (*setSwapInterval)(__DRIdrawable *drawable, unsigned int inteval);
+    unsigned int (*getSwapInterval)(__DRIdrawable *drawable);
+};
 
 /**
- * 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.
+ * Used by drivers that implement the GLX_MESA_allocate_memory.
  */
-struct __DRIversionRec {
-    int    major;        /**< Major version number. */
-    int    minor;        /**< Minor version number. */
-    int    patch;        /**< Patch-level. */
-};
+#define __DRI_ALLOCATE "DRI_Allocate"
+#define __DRI_ALLOCATE_VERSION 1
+struct __DRIallocateExtensionRec {
+    __DRIextension base;
 
+    void *(*allocateMemory)(__DRIscreen *screen, GLsizei size,
+                           GLfloat readfreq, GLfloat writefreq,
+                           GLfloat priority);
+   
+    void (*freeMemory)(__DRIscreen *screen, GLvoid *pointer);
+   
+    GLuint (*memoryOffset)(__DRIscreen *screen, const GLvoid *pointer);
+};
 
-typedef void (*__DRIfuncPtr)(void);
+/**
+ * Used by drivers that implement the GLX_MESA_swap_frame_usage extension.
+ */
+#define __DRI_FRAME_TRACKING "DRI_FrameTracking"
+#define __DRI_FRAME_TRACKING_VERSION 1
+struct __DRIframeTrackingExtensionRec {
+    __DRIextension base;
 
-struct __DRIinterfaceMethodsRec {
     /**
-     * Get pointer to named function.
+     * Enable or disable frame usage tracking.
+     * 
+     * \since Internal API version 20030317.
      */
-    __DRIfuncPtr (*getProcAddress)( const char * proc_name );
+    int (*frameTracking)(__DRIdrawable *drawable, GLboolean enable);
 
     /**
-     * Create a list of \c __GLcontextModes structures.
+     * Retrieve frame usage information.
+     * 
+     * \since Internal API version 20030317.
      */
-    __GLcontextModes * (*createContextModes)(unsigned count,
-        size_t minimum_bytes_per_struct);
+    int (*queryFrameTracking)(__DRIdrawable *drawable,
+                             int64_t * sbc, int64_t * missedFrames,
+                             float * lastMissedUsage, float * usage);
+};
+
+
+/**
+ * Used by drivers that implement the GLX_SGI_video_sync extension.
+ */
+#define __DRI_MEDIA_STREAM_COUNTER "DRI_MediaStreamCounter"
+#define __DRI_MEDIA_STREAM_COUNTER_VERSION 1
+struct __DRImediaStreamCounterExtensionRec {
+    __DRIextension base;
 
     /**
-     * Destroy a list of \c __GLcontextModes structures.
-     *
-     * \todo
-     * Determine if the drivers actually need to call this.
+     * 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.
      */
-    void (*destroyContextModes)( __GLcontextModes * modes );
+    int (*waitForMSC)(__DRIdrawable *drawable,
+                     int64_t target_msc, int64_t divisor, int64_t remainder,
+                     int64_t * msc, int64_t * sbc);
 
     /**
-     * Get the \c __DRIscreen for a given display and screen number.
+     * Get the number of vertical refreshes since some point in time before
+     * this function was first called (i.e., system start up).
      */
-    __DRIscreen *(*getScreen)(__DRInativeDisplay *dpy, int screenNum);
+    int (*getDrawableMSC)(__DRIscreen *screen, __DRIdrawable *drawable,
+                         int64_t *msc);
+};
+
 
+#define __DRI_TEX_OFFSET "DRI_TexOffset"
+#define __DRI_TEX_OFFSET_VERSION 1
+struct __DRItexOffsetExtensionRec {
+    __DRIextension base;
 
     /**
-     * \name Client/server protocol functions.
+     * Method to override base texture image with a driver specific 'offset'.
+     * The depth passed in allows e.g. to ignore the alpha channel of texture
+     * images where the non-alpha components don't occupy a whole texel.
      *
-     * 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.
+     * For GLX_EXT_texture_from_pixmap with AIGLX.
      */
-    GLboolean (*windowExists)(__DRInativeDisplay *dpy, __DRIid draw);
+    void (*setTexOffset)(__DRIcontext *pDRICtx, GLint texname,
+                        unsigned long long offset, GLint depth, GLuint pitch);
+};
 
-    /**
-     * 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 );
+#define __DRI_TEX_BUFFER "DRI_TexBuffer"
+#define __DRI_TEX_BUFFER_VERSION 1
+struct __DRItexBufferExtensionRec {
+    __DRIextension base;
 
     /**
-     * Create the server-side portion of the drawable.
+     * Method to override base texture image with the contents of a
+     * __DRIdrawable. 
+     *
+     * For GLX_EXT_texture_from_pixmap with AIGLX.
      */
-    GLboolean (*createDrawable)( __DRInativeDisplay * ndpy, int screen,
-        __DRIid drawable, drm_drawable_t * hHWDrawable );
+    void (*setTexBuffer)(__DRIcontext *pDRICtx,
+                        GLint target,
+                        __DRIdrawable *pDraw);
+};
+
+
+/**
+ * XML document describing the configuration options supported by the
+ * driver.
+ */
+extern const char __driConfigOptions[];
+
+/*@}*/
+
+/**
+ * The following extensions describe loader features that the DRI
+ * driver can make use of.  Some of these are mandatory, such as the
+ * getDrawableInfo extension for DRI and the DRI Loader extensions for
+ * DRI2, while others are optional, and if present allow the driver to
+ * expose certain features.  The loader pass in a NULL terminated
+ * array of these extensions to the driver in the createNewScreen
+ * constructor.
+ */
+
+typedef struct __DRIgetDrawableInfoExtensionRec __DRIgetDrawableInfoExtension;
+typedef struct __DRIsystemTimeExtensionRec __DRIsystemTimeExtension;
+typedef struct __DRIdamageExtensionRec __DRIdamageExtension;
+typedef struct __DRIloaderExtensionRec __DRIloaderExtension;
+typedef struct __DRIswrastLoaderExtensionRec __DRIswrastLoaderExtension;
 
-    /**
-     * Destroy the server-side portion of the drawable.
-     */
-    GLboolean (*destroyDrawable)( __DRInativeDisplay * ndpy, int screen,
-        __DRIid drawable );
+
+/**
+ * Callback to getDrawableInfo protocol
+ */
+#define __DRI_GET_DRAWABLE_INFO "DRI_GetDrawableInfo"
+#define __DRI_GET_DRAWABLE_INFO_VERSION 1
+struct __DRIgetDrawableInfoExtensionRec {
+    __DRIextension base;
 
     /**
      * 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,
+    GLboolean (* getDrawableInfo) ( __DRIdrawable *drawable,
+       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 );
-    /*@}*/
+       int * numBackClipRects, drm_clip_rect_t ** pBackClipRects,
+       void *loaderPrivate);
+};
 
+/**
+ * Callback to get system time for media stream counter extensions.
+ */
+#define __DRI_SYSTEM_TIME "DRI_SystemTime"
+#define __DRI_SYSTEM_TIME_VERSION 1
+struct __DRIsystemTimeExtensionRec {
+    __DRIextension base;
 
-    /**
-     * \name Timing related functions.
-     */
-    /*@{*/
     /**
      * Get the 64-bit unadjusted system time (UST).
      */
@@ -234,9 +312,18 @@ struct __DRIinterfaceMethodsRec {
      * 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);
-    /*@}*/
+    GLboolean (*getMSCRate)(__DRIdrawable *draw,
+                           int32_t * numerator, int32_t * denominator,
+                           void *loaderPrivate);
+};
+
+/**
+ * Damage reporting
+ */
+#define __DRI_DAMAGE "DRI_Damage"
+#define __DRI_DAMAGE_VERSION 1
+struct __DRIdamageExtensionRec {
+    __DRIextension base;
 
     /**
      * Reports areas of the given drawable which have been modified by the
@@ -251,15 +338,198 @@ struct __DRIinterfaceMethodsRec {
      * \param front_buffer boolean flag for whether the drawing to the
      *               drawable was actually done directly to the front buffer (instead
      *       of backing storage, for example)
+     * \param loaderPrivate the data passed in at createNewDrawable time
      */
-    void (*reportDamage)(__DRInativeDisplay * dpy, int screen,
-                        __DRIid drawable,
+    void (*reportDamage)(__DRIdrawable *draw,
                         int x, int y,
                         drm_clip_rect_t *rects, int num_rects,
-                        int front_buffer);
+                        GLboolean front_buffer,
+                        void *loaderPrivate);
+};
+
+#define __DRI_SWRAST_IMAGE_OP_DRAW     1
+#define __DRI_SWRAST_IMAGE_OP_CLEAR    2
+#define __DRI_SWRAST_IMAGE_OP_SWAP     3
+
+/**
+ * SWRast Loader extension.
+ */
+#define __DRI_SWRAST_LOADER "DRI_SWRastLoader"
+#define __DRI_SWRAST_LOADER_VERSION 1
+struct __DRIswrastLoaderExtensionRec {
+    __DRIextension base;
+
+    /*
+     * Drawable position and size
+     */
+    void (*getDrawableInfo)(__DRIdrawable *drawable,
+                           int *x, int *y, int *width, int *height,
+                           void *loaderPrivate);
+
+    /**
+     * Put image to drawable
+     */
+    void (*putImage)(__DRIdrawable *drawable, int op,
+                    int x, int y, int width, int height, char *data,
+                    void *loaderPrivate);
+
+    /**
+     * Get image from drawable
+     */
+    void (*getImage)(__DRIdrawable *drawable,
+                    int x, int y, int width, int height, char *data,
+                    void *loaderPrivate);
+};
+
+/**
+ * The remaining extensions describe driver extensions, immediately
+ * available interfaces provided by the driver.  To start using the
+ * driver, dlsym() for the __DRI_DRIVER_EXTENSIONS symbol and look for
+ * the extension you need in the array.
+ */
+#define __DRI_DRIVER_EXTENSIONS "__driDriverExtensions"
+
+/**
+ * Tokens for __DRIconfig attribs.  A number of attributes defined by
+ * GLX or EGL standards are not in the table, as they must be provided
+ * by the loader.  For example, FBConfig ID or visual ID, drawable type.
+ */
+
+#define __DRI_ATTRIB_BUFFER_SIZE                1
+#define __DRI_ATTRIB_LEVEL                      2
+#define __DRI_ATTRIB_RED_SIZE                   3
+#define __DRI_ATTRIB_GREEN_SIZE                         4
+#define __DRI_ATTRIB_BLUE_SIZE                  5
+#define __DRI_ATTRIB_LUMINANCE_SIZE             6
+#define __DRI_ATTRIB_ALPHA_SIZE                         7
+#define __DRI_ATTRIB_ALPHA_MASK_SIZE            8
+#define __DRI_ATTRIB_DEPTH_SIZE                         9
+#define __DRI_ATTRIB_STENCIL_SIZE              10
+#define __DRI_ATTRIB_ACCUM_RED_SIZE            11
+#define __DRI_ATTRIB_ACCUM_GREEN_SIZE          12
+#define __DRI_ATTRIB_ACCUM_BLUE_SIZE           13
+#define __DRI_ATTRIB_ACCUM_ALPHA_SIZE          14
+#define __DRI_ATTRIB_SAMPLE_BUFFERS            15
+#define __DRI_ATTRIB_SAMPLES                   16
+#define __DRI_ATTRIB_RENDER_TYPE               17
+#define __DRI_ATTRIB_CONFIG_CAVEAT             18
+#define __DRI_ATTRIB_CONFORMANT                        19
+#define __DRI_ATTRIB_DOUBLE_BUFFER             20
+#define __DRI_ATTRIB_STEREO                    21
+#define __DRI_ATTRIB_AUX_BUFFERS               22
+#define __DRI_ATTRIB_TRANSPARENT_TYPE          23
+#define __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE   24
+#define __DRI_ATTRIB_TRANSPARENT_RED_VALUE     25
+#define __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE   26
+#define __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE    27
+#define __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE   28
+#define __DRI_ATTRIB_FLOAT_MODE                        29
+#define __DRI_ATTRIB_RED_MASK                  30
+#define __DRI_ATTRIB_GREEN_MASK                        31
+#define __DRI_ATTRIB_BLUE_MASK                 32
+#define __DRI_ATTRIB_ALPHA_MASK                        33
+#define __DRI_ATTRIB_MAX_PBUFFER_WIDTH         34
+#define __DRI_ATTRIB_MAX_PBUFFER_HEIGHT                35
+#define __DRI_ATTRIB_MAX_PBUFFER_PIXELS                36
+#define __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH     37
+#define __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT    38
+#define __DRI_ATTRIB_VISUAL_SELECT_GROUP       39
+#define __DRI_ATTRIB_SWAP_METHOD               40
+#define __DRI_ATTRIB_MAX_SWAP_INTERVAL         41
+#define __DRI_ATTRIB_MIN_SWAP_INTERVAL         42
+#define __DRI_ATTRIB_BIND_TO_TEXTURE_RGB       43
+#define __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA      44
+#define __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE    45
+#define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS   46
+#define __DRI_ATTRIB_YINVERTED                 47
+
+/* __DRI_ATTRIB_RENDER_TYPE */
+#define __DRI_ATTRIB_RGBA_BIT                  0x01    
+#define __DRI_ATTRIB_COLOR_INDEX_BIT           0x02
+#define __DRI_ATTRIB_LUMINANCE_BIT             0x04
+
+/* __DRI_ATTRIB_CONFIG_CAVEAT */
+#define __DRI_ATTRIB_SLOW_BIT                  0x01
+#define __DRI_ATTRIB_NON_CONFORMANT_CONFIG     0x02
+
+/* __DRI_ATTRIB_TRANSPARENT_TYPE */
+#define __DRI_ATTRIB_TRANSPARENT_RGB           0x00
+#define __DRI_ATTRIB_TRANSPARENT_INDEX         0x01
+
+/* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS         */
+#define __DRI_ATTRIB_TEXTURE_1D_BIT            0x01
+#define __DRI_ATTRIB_TEXTURE_2D_BIT            0x02
+#define __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT     0x04
+
+/**
+ * This extension defines the core DRI functionality.
+ */
+#define __DRI_CORE "DRI_Core"
+#define __DRI_CORE_VERSION 1
+
+struct __DRIcoreExtensionRec {
+    __DRIextension base;
+
+    __DRIscreen *(*createNewScreen)(int screen, int fd,
+                                   unsigned int sarea_handle,
+                                   const __DRIextension **extensions,
+                                   const __DRIconfig ***driverConfigs,
+                                   void *loaderPrivate);
+
+    void (*destroyScreen)(__DRIscreen *screen);
+
+    const __DRIextension **(*getExtensions)(__DRIscreen *screen);
+
+    int (*getConfigAttrib)(const __DRIconfig *config,
+                          unsigned int attrib,
+                          unsigned int *value);
+
+    int (*indexConfigAttrib)(const __DRIconfig *config, int index,
+                            unsigned int *attrib, unsigned int *value);
+
+    __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
+                                       const __DRIconfig *config,
+                                       unsigned int drawable_id,
+                                       unsigned int head,
+                                       void *loaderPrivate);
+
+    void (*destroyDrawable)(__DRIdrawable *drawable);
+
+    void (*swapBuffers)(__DRIdrawable *drawable);
+
+    __DRIcontext *(*createNewContext)(__DRIscreen *screen,
+                                     const __DRIconfig *config,
+                                     __DRIcontext *shared,
+                                     void *loaderPrivate);
+
+    int (*copyContext)(__DRIcontext *dest,
+                      __DRIcontext *src,
+                      unsigned long mask);
+
+    void (*destroyContext)(__DRIcontext *context);
+
+    int (*bindContext)(__DRIcontext *ctx,
+                      __DRIdrawable *pdraw,
+                      __DRIdrawable *pread);
+
+    int (*unbindContext)(__DRIcontext *ctx);
+};
+
+/**
+ * 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. */
 };
 
-   
 /**
  * Framebuffer information record.  Used by libGL to communicate information
  * about the framebuffer to the driver's \c __driCreateNewScreen function.
@@ -289,229 +559,115 @@ struct __DRIframebufferRec {
 
 
 /**
- * Screen dependent methods.  This structure is initialized during the
- * \c __DRIdisplayRec::createScreen call.
+ * This extension provides alternative screen, drawable and context
+ * constructors for legacy DRI functionality.  This is used in
+ * conjunction with the core extension.
  */
-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);
-
-    /**
-     * Method to override base texture image with a driver specific 'offset'.
-     * The depth passed in allows e.g. to ignore the alpha channel of texture
-     * images where the non-alpha components don't occupy a whole texel.
-     *
-     * For GLX_EXT_texture_from_pixmap with AIGLX.
-     *
-     * \since Internal API version 20070121.
-     */
-    void (*setTexOffset)(__DRIcontext *pDRICtx, GLint texname,
-                        unsigned long long offset, GLint depth, GLuint pitch);
+#define __DRI_LEGACY "DRI_Legacy"
+#define __DRI_LEGACY_VERSION 1
+
+struct __DRIlegacyExtensionRec {
+    __DRIextension base;
+
+    __DRIscreen *(*createNewScreen)(int screen,
+                                   const __DRIversion *ddx_version,
+                                   const __DRIversion *dri_version,
+                                   const __DRIversion *drm_version,
+                                   const __DRIframebuffer *frame_buffer,
+                                   void *pSAREA, int fd, 
+                                   const __DRIextension **extensions,
+                                   const __DRIconfig ***driver_configs,
+                                   void *loaderPrivate);
+
+    __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
+                                       const __DRIconfig *config,
+                                       drm_drawable_t hwDrawable,
+                                       int renderType, const int *attrs,
+                                       void *loaderPrivate);
+
+    __DRIcontext *(*createNewContext)(__DRIscreen *screen,
+                                     const __DRIconfig *config,
+                                     int render_type,
+                                     __DRIcontext *shared,
+                                     drm_context_t hwContext,
+                                     void *loaderPrivate);
 };
 
 /**
- * Context dependent methods.  This structure is initialized during the
- * \c __DRIscreenRec::createContext call.
+ * This extension provides alternative screen, drawable and context
+ * constructors for swrast DRI functionality.  This is used in
+ * conjunction with the core extension.
  */
-struct __DRIcontextRec {
-    /**
-     * Method to destroy the private DRI context data.
-     */
-    void (*destroyContext)(__DRInativeDisplay *dpy, int scrn, void *contextPrivate);
+#define __DRI_SWRAST "DRI_SWRast"
+#define __DRI_SWRAST_VERSION 1
 
-    /**
-     * 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;
+struct __DRIswrastExtensionRec {
+    __DRIextension base;
 
-    /**
-     * 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);
+    __DRIscreen *(*createNewScreen)(int screen,
+                                   const __DRIextension **extensions,
+                                   const __DRIconfig ***driver_configs,
+                                   void *loaderPrivate);
 
-    /**
-     * 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);
+    __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
+                                       const __DRIconfig *config,
+                                       void *loaderPrivate);
 };
 
 /**
- * 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.
+ * DRI2 Loader extension.
  */
-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);
+#define __DRI_BUFFER_FRONT_LEFT                0
+#define __DRI_BUFFER_BACK_LEFT         1
+#define __DRI_BUFFER_FRONT_RIGHT       2
+#define __DRI_BUFFER_BACK_RIGHT                3
+#define __DRI_BUFFER_DEPTH             4
+#define __DRI_BUFFER_STENCIL           5
+#define __DRI_BUFFER_ACCUM             6
+
+struct __DRIbufferRec {
+    unsigned int attachment;
+    unsigned int name;
+    unsigned int pitch;
+    unsigned int cpp;
+    unsigned int flags;
+};
 
-    /**
-     * 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;
+#define __DRI_DRI2_LOADER "DRI_DRI2Loader"
+#define __DRI_DRI2_LOADER_VERSION 1
+struct __DRIdri2LoaderExtensionRec {
+    __DRIextension base;
 
-    /**
-     * 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 );
+    __DRIbuffer *(*getBuffers)(__DRIdrawable *driDrawable,
+                              int *width, int *height,
+                              unsigned int *attachments, int count,
+                              int *out_count, void *loaderPrivate);
+};
 
-    /**
-     * 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 );
+/**
+ * This extension provides alternative screen, drawable and context
+ * constructors for DRI2.
+ */
+#define __DRI_DRI2 "DRI_DRI2"
+#define __DRI_DRI2_VERSION 1
 
-    /**
-     * 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);
+struct __DRIdri2ExtensionRec {
+    __DRIextension base;
 
-    /**
-     * Enable or disable frame usage tracking.
-     * 
-     * \since Internal API version 20030317.
-     */
-    int (*frameTracking)(__DRInativeDisplay *dpy, void *drawablePrivate, GLboolean enable);
+    __DRIscreen *(*createNewScreen)(int screen, int fd,
+                                   const __DRIextension **extensions,
+                                   const __DRIconfig ***driver_configs,
+                                   void *loaderPrivate);
 
-    /**
-     * 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 );
+    __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
+                                       const __DRIconfig *config,
+                                       void *loaderPrivate);
 
-    /**
-     * Used by drivers that implement the GLX_SGI_swap_control or
-     * GLX_MESA_swap_control extension.
-     *
-     * \since Internal API version 20030317.
-     */
-    unsigned swap_interval;
+    __DRIcontext *(*createNewContext)(__DRIscreen *screen,
+                                     const __DRIconfig *config,
+                                     __DRIcontext *shared,
+                                     void *loaderPrivate);
 
-    /**
-     * Used by drivers that implement the GLX_MESA_copy_sub_buffer extension.
-     *
-     * \since Internal API version 20060314.
-     */
-    void (*copySubBuffer)(__DRInativeDisplay *dpy, void *drawablePrivate,
-                         int x, int y, int w, int h);
 };
 
 #endif
index d62f31bb290b4756155da12b33f025f9bf7bf517..a3af3b5a34e0d0915b9ef8b1cc668274c049939b 100644 (file)
@@ -43,6 +43,7 @@
 #define GL_CORE_SGI  1
 #define GL_CORE_MESA 2
 #define GL_CORE_APPLE 4
+#define GL_CORE_WINDOWS 8
 
 typedef struct __GLcontextRec __GLcontext;
 
index 1d774571d94db40dfb08160961a83df01a9d5795..57147232b7f599b762e0e84b76b946121ff73513 100644 (file)
@@ -81,8 +81,6 @@ WGLAPI int   GLAPIENTRY wglChoosePixelFormat(HDC, const PIXELFORMATDESCRIPTOR *)
 WGLAPI int   GLAPIENTRY wglDescribePixelFormat(HDC,int, unsigned int, LPPIXELFORMATDESCRIPTOR);
 WGLAPI int   GLAPIENTRY wglGetPixelFormat(HDC hdc);
 
-
-#if defined(GL_NO_STDCALL) || !defined(__MINGW32__)
 WGLAPI int   GLAPIENTRY wglCopyContext(HGLRC, HGLRC, unsigned int);
 WGLAPI HGLRC GLAPIENTRY wglCreateContext(HDC);
 WGLAPI HGLRC GLAPIENTRY wglCreateLayerContext(HDC,int);
@@ -101,7 +99,6 @@ WGLAPI int   GLAPIENTRY wglUseFontBitmapsA(HDC, unsigned long, unsigned long, un
 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);
-#endif
 
 #ifndef __MINGW32__
 WGLAPI int   GLAPIENTRY SwapBuffers(HDC);
index 1c959a6792c6cb02f5336f36eef68c9a1955ebeb..f5f4f273ba9483c42ec7942b414e8e095e619189 100644 (file)
@@ -130,7 +130,7 @@ extern void WMesaPaletteChange(HPALETTE Pal);
 
 extern void WMesaMove(void);
 
-
+void WMesaShareLists(WMesaContext ctx_to_share, WMesaContext ctx);
 
 #ifdef __cplusplus
 }
index 4d69d4d930d1ffa53e897518a13ddfb3a18e3f24..10f93c3ab6276905f288cdfc70e48b4d85646d72 100644 (file)
@@ -169,8 +169,13 @@ do { \
 
 
 /* CreatePixmap returns a PixmapPtr; so, it cannot be inside braces */
+#ifdef CREATE_PIXMAP_USAGE_SCRATCH
+#define XMesaCreatePixmap(__d,__b,__w,__h,__depth) \
+  (*__d->CreatePixmap)(__d, __w, __h, __depth, 0)
+#else
 #define XMesaCreatePixmap(__d,__b,__w,__h,__depth) \
     (*__d->CreatePixmap)(__d, __w, __h, __depth)
+#endif
 
 #define XMesaFreePixmap(__d,__b) \
     (*__d->DestroyPixmap)(__b)
index 5e705efa7eee2edc7d5706f35eac3062d48d0326..c99f4eebcc1be56d27de779c55efab1c72acddef 100644 (file)
@@ -25,7 +25,7 @@ subdirs:
 install:
 
 clean:
-       @for dir in $(SUBDIRS) tests ; do \
+       -@for dir in $(SUBDIRS) tests ; do \
                if [ -d $$dir ] ; then \
                        (cd $$dir && $(MAKE) clean) ; \
                fi \
index 45782fb3cf7c8f2009e9b33cbe05722ca0b0053e..0dc4cdce632b064bd87953bdae83c67416891014 100644 (file)
@@ -10,24 +10,26 @@ include $(TOP)/configs/current
 #
 # Modified by Philippe Houdoin
 
-LDFLAGS += -soname=_APP_ $(APP_LIB_DEPS)
+LDFLAGS += -soname=_APP_
+
+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
 
 INCLUDES = -I. -I- -I../../include
 
 default: demo sample GLInfo
 
 clean:
-       rm -f demo sample GLInfo
-       rm -f *.o
+       -rm -f demo sample GLInfo
+       -rm -f *.o
 
 demo: demo.o
-       $(LD) demo.o $(LDFLAGS) -o $@
+       $(LD) demo.o $(LDFLAGS) $(LIBS) -o $@
 
 sample: sample.o
-       $(LD) sample.o $(LDFLAGS) -o $@
+       $(LD) sample.o $(LDFLAGS) $(LIBS) -o $@
 
 GTLInfo: GLInfo.o
-       $(LD) GLInfo.o $(INCLUDES) $(LDFLAGS) -o $@
+       $(LD) GLInfo.o $(INCLUDES) $(LDFLAGS) $(LIBS) -o $@
 
 .cpp.o:
        $(CC) -c $< $(INCLUDES) $(CFLAGS) -o $@
index d9e488189b06b4bcd07c1e9395726d587fcff152..3693fafd4ee3b9b77fa619e68996429ac644ba9a 100644 (file)
@@ -3,6 +3,7 @@ arbfslight
 arbocclude
 bounce
 clearspd
+copypix
 cubemap
 drawpix
 engine
@@ -30,6 +31,7 @@ osdemo
 paltex
 pixeltex
 pointblast
+rain
 ray
 readpix
 readtex.c
index fe0e0fbd91bf5609b31d73d52114710525afd9a4..123d1e59e976f8aebd1a94d8418473805b0a92ed 100644 (file)
@@ -11,7 +11,11 @@ OSMESA16_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lOSMesa16 -lGLU -lGL $(APP_LIB_DEPS)
 
 OSMESA32_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lOSMesa32 -lGLU -lGL $(APP_LIB_DEPS)
 
-LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
+LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
+       $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
+
+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) \
+       $(APP_LIB_DEPS)
 
 PROGS = \
        arbfplight \
@@ -19,9 +23,11 @@ PROGS = \
        arbocclude \
        bounce \
        clearspd \
+       copypix \
        cubemap \
        drawpix \
        engine \
+       fbo_firecube \
        fire \
        fogcoord \
        fplight \
@@ -42,6 +48,7 @@ PROGS = \
        multiarb \
        paltex \
        pointblast \
+       rain \
        ray \
        readpix \
        reflect \
@@ -70,11 +77,11 @@ PROGS = \
 
 .SUFFIXES:
 .SUFFIXES: .c
-
+.SUFFIXES: .cxx
 
 # make executable from .c file:
 .c: $(LIB_DEP) readtex.o
-       $(APP_CC) -I$(INCDIR) $(CFLAGS) $< readtex.o $(APP_LIB_DEPS) -o $@
+       $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< readtex.o $(LIBS) -o $@
 
 
 ##### TARGETS #####
@@ -118,39 +125,51 @@ extfuncs.h:  $(TOP)/progs/util/extfuncs.h
 
 
 reflect: reflect.o showbuffer.o readtex.o
-       $(APP_CC) reflect.o showbuffer.o readtex.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@
+       $(APP_CC) $(CFLAGS) $(LDFLAGS) reflect.o showbuffer.o readtex.o $(LIBS) -o $@
 
 reflect.o: reflect.c showbuffer.h
        $(APP_CC) -c -I$(INCDIR) $(CFLAGS) reflect.c
 
 
 shadowtex: shadowtex.o showbuffer.o
-       $(APP_CC) shadowtex.o showbuffer.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@
+       $(APP_CC) $(CFLAGS) $(LDFLAGS) shadowtex.o showbuffer.o $(LIBS) -o $@
 
 shadowtex.o: shadowtex.c showbuffer.h
        $(APP_CC) -c -I$(INCDIR) $(CFLAGS) shadowtex.c
 
 
 gloss: gloss.o trackball.o readtex.o
-       $(APP_CC) gloss.o trackball.o readtex.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@
+       $(APP_CC) $(CFLAGS) $(LDFLAGS) gloss.o trackball.o readtex.o $(LIBS) -o $@
 
 gloss.o: gloss.c trackball.h
        $(APP_CC) -c -I$(INCDIR) $(CFLAGS) gloss.c
 
 
 engine: engine.o trackball.o readtex.o
-       $(APP_CC) engine.o trackball.o readtex.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@
+       $(APP_CC) $(CFLAGS) $(LDFLAGS) engine.o trackball.o readtex.o $(LIBS) -o $@
 
 engine.o: engine.c trackball.h
        $(APP_CC) -c -I$(INCDIR) $(CFLAGS) engine.c
 
 
 fslight: fslight.o
-       $(APP_CC) fslight.o $(APP_LIB_DEPS) $(ARCH_FLAGS) -o $@
+       $(APP_CC) $(CFLAGS) $(LDFLAGS) fslight.o $(LIBS) -o $@
 
 fslight.o: fslight.c extfuncs.h
        $(APP_CC) -c -I$(INCDIR) $(CFLAGS) fslight.c
 
+rain: particles.o rain.o readtex.o
+       $(CXX) $(CXXFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@
+
+rain.o: rain.cxx readtex.h
+       $(CXX) -c -I$(INCDIR) $(CXXFLAGS) $<
+
+particles.o: particles.cxx
+       $(CXX) -c -I$(INCDIR) $(CXXFLAGS) $<
+
+
+viewdds: viewdds.c
+       $(CC) -I$(INCDIR) $(CFLAGS) $< readtex.o $(LIBS) -L. -lgltc -o $@
 
 
 clean:
diff --git a/progs/demos/copypix.c b/progs/demos/copypix.c
new file mode 100644 (file)
index 0000000..15001e8
--- /dev/null
@@ -0,0 +1,248 @@
+/**
+ * glCopyPixels test
+ * 
+ * Brian Paul
+ * 14 Sep 2007
+ */
+
+
+#define GL_GLEXT_PROTOTYPES
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <GL/glut.h>
+
+#include "readtex.h"
+
+#define IMAGE_FILE "../images/arch.rgb"
+
+static int ImgWidth, ImgHeight;
+static GLenum ImgFormat;
+static GLubyte *Image = NULL;
+
+static int WinWidth = 800, WinHeight = 800;
+static int Xpos, Ypos;
+static int Scissor = 0;
+static float Xzoom, Yzoom;
+static GLboolean DrawFront = GL_FALSE;
+static GLboolean Dither = GL_TRUE;
+
+
+static void Reset( void )
+{
+   Xpos = Ypos = 20;
+   Scissor = 0;
+   Xzoom = Yzoom = 1.0;
+}
+
+
+static void Display( void )
+{
+   const int dx = (WinWidth - ImgWidth) / 2;
+   const int dy = (WinHeight - ImgHeight) / 2;
+
+   if (DrawFront) {
+      glDrawBuffer(GL_FRONT);
+      glReadBuffer(GL_FRONT);
+   }
+   else {
+      glDrawBuffer(GL_BACK);
+      glReadBuffer(GL_BACK);
+   }
+
+   glClear( GL_COLOR_BUFFER_BIT );
+
+   /* draw original image */
+   glWindowPos2iARB(dx, dy);                    
+   glDrawPixels(ImgWidth, ImgHeight, ImgFormat, GL_UNSIGNED_BYTE, Image);
+
+   if (Scissor)
+      glEnable(GL_SCISSOR_TEST);
+
+   /* draw copy */
+   glPixelZoom(Xzoom, Yzoom);
+   glWindowPos2iARB(Xpos, Ypos);
+   glCopyPixels(dx, dy, ImgWidth, ImgHeight, GL_COLOR);
+   glPixelZoom(1, 1);
+
+   glDisable(GL_SCISSOR_TEST);
+
+   if (DrawFront)
+      glFinish();
+   else
+      glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+   WinWidth = width;
+   WinHeight = height;
+
+   glViewport( 0, 0, width, height );
+   glMatrixMode( GL_PROJECTION );
+   glLoadIdentity();
+   glOrtho( 0.0, width, 0.0, height, 0.0, 2.0 );
+   glMatrixMode( GL_MODELVIEW );
+   glLoadIdentity();
+
+   glScissor(width/4, height/4, width/2, height/2);
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+   (void) x;
+   (void) y;
+   switch (key) {
+      case ' ':
+         Reset();
+         break;
+      case 'd':
+         Dither = !Dither;
+         if (Dither)
+            glEnable(GL_DITHER);
+         else
+            glDisable(GL_DITHER);
+         break;
+      case 's':
+         Scissor = !Scissor;
+         break;
+      case 'x':
+         Xzoom -= 0.1;
+         break;
+      case 'X':
+         Xzoom += 0.1;
+         break;
+      case 'y':
+         Yzoom -= 0.1;
+         break;
+      case 'Y':
+         Yzoom += 0.1;
+         break;
+      case 'f':
+         DrawFront = !DrawFront;
+         printf("glDrawBuffer(%s)\n", DrawFront ? "GL_FRONT" : "GL_BACK");
+         break;
+      case 27:
+         exit(0);
+         break;
+   }
+   glutPostRedisplay();
+}
+
+
+static void SpecialKey( int key, int x, int y )
+{
+   const int step = (glutGetModifiers() & GLUT_ACTIVE_SHIFT) ? 10 : 1;
+   (void) x;
+   (void) y;
+   switch (key) {
+      case GLUT_KEY_UP:
+         Ypos += step;
+         break;
+      case GLUT_KEY_DOWN:
+         Ypos -= step;
+         break;
+      case GLUT_KEY_LEFT:
+         Xpos -= step;
+         break;
+      case GLUT_KEY_RIGHT:
+         Xpos += step;
+         break;
+   }
+   glutPostRedisplay();
+}
+
+
+static void Init( GLboolean ciMode, const char *filename )
+{
+   printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+   printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+
+   Image = LoadRGBImage( filename, &ImgWidth, &ImgHeight, &ImgFormat );
+   if (!Image) {
+      printf("Couldn't read %s\n", filename);
+      exit(0);
+   }
+
+   if (ciMode) {
+      /* Convert RGB image to grayscale */
+      GLubyte *indexImage = (GLubyte *) malloc( ImgWidth * ImgHeight );
+      GLint i;
+      for (i=0; i<ImgWidth*ImgHeight; i++) {
+         int gray = Image[i*3] + Image[i*3+1] + Image[i*3+2];
+         indexImage[i] = gray / 3;
+      }
+      free(Image);
+      Image = indexImage;
+      ImgFormat = GL_COLOR_INDEX;
+
+      for (i=0;i<255;i++) {
+         float g = i / 255.0;
+         glutSetColor(i, g, g, g);
+      }
+   }
+
+   printf("Loaded %d by %d image\n", ImgWidth, ImgHeight );
+
+   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+   glPixelStorei(GL_UNPACK_ROW_LENGTH, ImgWidth);
+
+   Reset();
+}
+
+
+static void Usage(void)
+{
+   printf("Keys:\n");
+   printf("       SPACE  Reset Parameters\n");
+   printf("     Up/Down  Move image up/down (SHIFT for large step)\n");
+   printf("  Left/Right  Move image left/right (SHIFT for large step)\n");
+   printf("           x  Decrease X-axis PixelZoom\n");
+   printf("           X  Increase X-axis PixelZoom\n");
+   printf("           y  Decrease Y-axis PixelZoom\n");
+   printf("           Y  Increase Y-axis PixelZoom\n");
+   printf("           s  Toggle GL_SCISSOR_TEST\n");
+   printf("           f  Toggle front/back buffer drawing\n");
+   printf("         ESC  Exit\n");
+}
+
+
+int main( int argc, char *argv[] )
+{
+   GLboolean ciMode = GL_FALSE;
+   const char *filename = IMAGE_FILE;
+   int i = 1;
+
+   if (argc > i && strcmp(argv[i], "-ci")==0) {
+      ciMode = GL_TRUE;
+      i++;
+   }
+   if (argc > i) {
+      filename = argv[i];
+   }
+
+   glutInit( &argc, argv );
+   glutInitWindowPosition( 0, 0 );
+   glutInitWindowSize( WinWidth, WinHeight );
+
+   if (ciMode)
+      glutInitDisplayMode( GLUT_INDEX | GLUT_DOUBLE );
+   else
+      glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE);
+
+   glutCreateWindow(argv[0]);
+
+   Init(ciMode, filename);
+   Usage();
+
+   glutReshapeFunc( Reshape );
+   glutKeyboardFunc( Key );
+   glutSpecialFunc( SpecialKey );
+   glutDisplayFunc( Display );
+
+   glutMainLoop();
+   return 0;
+}
index ef5d23555096b6b00add0c23015e1fc63f38ca87..b3bdd64f68da6d4b4a438beac721739ba0f23cb5 100644 (file)
@@ -47,6 +47,8 @@ static GLfloat Xrot = 0, Yrot = 0;
 static GLfloat EyeDist = 10;
 static GLboolean use_vertex_arrays = GL_FALSE;
 static GLboolean anim = GL_TRUE;
+static GLboolean NoClear = GL_FALSE;
+static GLint FrameParity = 0;
 
 #define eps1 0.99
 #define br   20.0  /* box radius */
@@ -156,7 +158,30 @@ static void draw_skybox( void )
 
 static void draw( void )
 {
-   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+   if (NoClear) {
+      /* This demonstrates how we can avoid calling glClear.
+       * This method only works if every pixel in the window is painted for
+       * every frame.
+       * We can simply skip clearing of the color buffer in this case.
+       * For the depth buffer, we alternately use a different subrange of
+       * the depth buffer for each frame.  For the odd frame use the range
+       * [0, 0.5] with GL_LESS.  For the even frames, use the range [1, 0.5]
+       * with GL_GREATER.
+       */
+      FrameParity = 1 - FrameParity;
+      if (FrameParity) {
+         glDepthRange(0.0, 0.5);
+         glDepthFunc(GL_LESS);
+      }
+      else {
+         glDepthRange(1.0, 0.5);
+         glDepthFunc(GL_GREATER);
+      }      
+   }
+   else {
+      /* ordinary clearing */
+      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+   }
 
    glPushMatrix(); /*MODELVIEW*/
       glTranslatef( 0.0, 0.0, -EyeDist );
@@ -452,6 +477,24 @@ static void usage(void)
 }
 
 
+static void parse_args(int argc, char *argv[])
+{
+   int initFlag = 0;
+   int i;
+
+   for (i = 1; i < argc; i++) {
+      if (strcmp(argv[i], "-i") == 0)
+         initFlag = 1;
+      else if (strcmp(argv[i], "--noclear") == 0)
+         NoClear = GL_TRUE;
+      else {
+         fprintf(stderr, "Bad option: %s\n", argv[i]);
+         exit(1);
+      }
+   }
+   init (initFlag);
+}
+
 int main( int argc, char *argv[] )
 {
    glutInit(&argc, argv);
@@ -459,17 +502,13 @@ int main( int argc, char *argv[] )
    glutInitWindowSize(600, 500);
    glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
    glutCreateWindow("Texture Cube Mapping");
-
-   if (argc > 1 && strcmp(argv[1] , "-i") == 0)
-      init( 1 );
-   else
-      init( 0 );
    glutReshapeFunc( reshape );
    glutKeyboardFunc( key );
    glutSpecialFunc( specialkey );
    glutDisplayFunc( draw );
    if (anim)
       glutIdleFunc(idle);
+   parse_args(argc, argv);
    usage();
    glutMainLoop();
    return 0;
diff --git a/progs/demos/descrip.mms b/progs/demos/descrip.mms
new file mode 100644 (file)
index 0000000..d7a9121
--- /dev/null
@@ -0,0 +1,90 @@
+# Makefile for GLUT-based demo programs for VMS
+# contributed by Jouk Jansen  joukj@hrem.nano.tudelft.nl
+# Last update : 30 November 2007
+
+.first
+       define gl [--.include.gl]
+
+.include [--]mms-config.
+
+##### MACROS #####
+
+INCDIR = ([--.include],[-.util])
+CFLAGS =/include=$(INCDIR)/prefix=all/name=(as_is,short)/float=ieee/ieee=denorm
+
+.ifdef SHARE
+GL_LIBS = $(XLIBS)
+LIB_DEP = [--.lib]$(GL_SHAR) [--.lib]$(GLU_SHAR) [--.lib]$(GLUT_SHAR)
+.else
+GL_LIBS = [--.lib]libGLUT/l,libMesaGLU/l,libMesaGL/l,$(XLIBS)
+LIB_DEP = [--.lib]$(GL_LIB) [--.lib]$(GLU_LIB) [--.lib]$(GLUT_LIB)
+.endif
+
+
+PROGS = bounce.exe,clearspd.exe,drawpix.exe,gamma.exe,gears.exe,\
+       glinfo.exe,glutfx.exe,isosurf.exe,morph3d.exe,\
+       paltex.exe,pointblast.exe,reflect.exe,spectex.exe,stex3d.exe,\
+       tessdemo.exe,texcyl.exe,texobj.exe,trispd.exe,winpos.exe
+
+
+##### RULES #####
+.obj.exe :
+       cxxlink $(MMS$TARGET_NAME),$(GL_LIBS)
+
+##### TARGETS #####
+default :
+       $(MMS)$(MMSQUALIFIERS) $(PROGS)
+
+clean :
+       delete *.obj;*
+
+realclean :
+       delete *.exe;*
+       delete *.obj;*
+
+bounce.exe : bounce.obj $(LIB_DEP)
+clearspd.exe : clearspd.obj $(LIB_DEP)
+drawpix.exe : drawpix.obj $(LIB_DEP) [-.util]readtex.obj
+       cxxlink $(MMS$TARGET_NAME),[-.util]readtex.obj,$(GL_LIBS)
+gamma.exe : gamma.obj $(LIB_DEP)
+gears.exe : gears.obj $(LIB_DEP)
+glinfo.exe : glinfo.obj $(LIB_DEP)
+glutfx.exe : glutfx.obj $(LIB_DEP)
+isosurf.exe : isosurf.obj $(LIB_DEP) [-.util]readtex.obj
+       cxxlink $(MMS$TARGET_NAME),[-.util]readtex.obj,$(GL_LIBS)
+morph3d.exe : morph3d.obj $(LIB_DEP)
+paltex.exe : paltex.obj $(LIB_DEP)
+pointblast.exe : pointblast.obj $(LIB_DEP)
+reflect.exe : reflect.obj [-.util]readtex.obj [-.util]showbuffer.obj\
+       $(LIB_DEP)
+       cxxlink $(MMS$TARGET_NAME),[-.util]readtex,showbuffer,$(GL_LIBS)
+spectex.exe : spectex.obj $(LIB_DEP)
+stex3d.exe : stex3d.obj $(LIB_DEP)
+tessdemo.exe : tessdemo.obj $(LIB_DEP)
+texcyl.exe : texcyl.obj [-.util]readtex.obj $(LIB_DEP)
+       cxxlink $(MMS$TARGET_NAME),[-.util]readtex.obj,$(GL_LIBS)
+texobj.exe : texobj.obj $(LIB_DEP)
+trispd.exe : trispd.obj $(LIB_DEP)
+winpos.exe : winpos.obj [-.util]readtex.obj $(LIB_DEP)
+       cxxlink $(MMS$TARGET_NAME),[-.util]readtex.obj,$(GL_LIBS)
+
+
+bounce.obj : bounce.c
+clearspd.obj : clearspd.c
+drawpix.obj : drawpix.c
+gamma.obj : gamma.c
+gears.obj : gears.c
+glinfo.obj : glinfo.c
+glutfx.obj : glutfx.c
+isosurf.obj : isosurf.c
+morph3d.obj : morph3d.c
+paltex.obj : paltex.c
+pointblast.obj : pointblast.c
+reflect.obj : reflect.c
+spectex.obj : spectex.c
+stex3d.obj : stex3d.c
+tessdemo.obj : tessdemo.c
+texcyl.obj : texcyl.c
+texobj.obj : texobj.c
+trispd.obj : trispd.c
+winpos.obj : winpos.c
index 143b02a8894fc9686c0f6b8ac120fb0e87b292fd..6040a2f1030dad433aed4d8e28ff65205710df57 100644 (file)
 #include "trackball.h"
 
 
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
 #define DEG_TO_RAD(DEG)  ((DEG) * M_PI / 180.0)
 
 #define TEXTURE_FILE "../images/reflect.rgb"
@@ -441,8 +445,8 @@ DrawConnector(float length, float thickness,
    for (i = 0; i <= 36; i++) {
       const int j = i % 36;
       glNormal3f(normals[j][0], normals[j][1], 0);
-      glVertex3f(points[j][0], points[j][1], z0);
       glVertex3f(points[j][0], points[j][1], z1);
+      glVertex3f(points[j][0], points[j][1], z0);
    }
    glEnd();
 }
@@ -741,7 +745,7 @@ DrawEngine(const Engine *eng, float crankAngle)
    glTranslatef(0, 0, -0.5 * crankLen);
 
    /* crankshaft */
-   glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, CrankshaftColor);
+   glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, CrankshaftColor);
    glColor4fv(CrankshaftColor);
    DrawPositionedCrankshaft(eng, crankAngle);
 
@@ -760,12 +764,12 @@ DrawEngine(const Engine *eng, float crankAngle)
          rot += k * eng->V_Angle;
 
          /* piston */
-         glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, PistonColor);
+         glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, PistonColor);
          glColor4fv(PistonColor);
          DrawPositionedPiston(eng, rot);
 
          /* connecting rod */
-         glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, ConnRodColor);
+         glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, ConnRodColor);
          glColor4fv(ConnRodColor);
          DrawPositionedConnectingRod(eng, rot);
       glPopMatrix();
@@ -780,7 +784,7 @@ DrawEngine(const Engine *eng, float crankAngle)
       }
       glEnable(GL_CULL_FACE);
 
-      glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, BlockColor);
+      glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, BlockColor);
       glColor4fv(BlockColor);
       if (eng->CrankList)
          glCallList(eng->BlockList);
@@ -1250,6 +1254,7 @@ Init(void)
 {
    const GLfloat lightColor[4] = { 0.7, 0.7, 0.7, 1.0 };
    const GLfloat specular[4] = { 0.8, 0.8, 0.8, 1.0 };
+   const GLfloat backColor[4] = { 1, 1, 0, 0 };
 
    Q = gluNewQuadric();
    gluQuadricNormals(Q, GLU_SMOOTH);
@@ -1261,10 +1266,14 @@ Init(void)
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor);
-   glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 40);
-   glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular);
+   glMaterialf(GL_FRONT, GL_SHININESS, 40);
+   glMaterialfv(GL_FRONT, GL_SPECULAR, specular);
    glEnable(GL_NORMALIZE);
 
+   glMaterialfv(GL_BACK, GL_DIFFUSE, backColor);
+#if 0
+   glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1);
+#endif
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
    InitViewInfo(&View);
diff --git a/progs/demos/fbo_firecube.c b/progs/demos/fbo_firecube.c
new file mode 100644 (file)
index 0000000..ed87dd1
--- /dev/null
@@ -0,0 +1,1041 @@
+/*
+ * Draw the "fire" test program on the six faces of a cube using
+ * fbo render-to-texture.
+ * 
+ * Much of the code comes from David Bucciarelli's "fire" 
+ * test program. The rest basically from Brian Paul's "gearbox" and
+ * fbotexture programs.
+ *
+ * By pressing the 'q' key, you can make the driver choose different
+ * internal texture RGBA formats by giving it different "format" and "type"
+ * arguments to the glTexImage2D function that creates the texture
+ * image being rendered to. If the driver doesn't support a texture image
+ * format as a render target, it will usually fall back to software when
+ * drawing the "fire" image, and frame-rate should drop considerably.
+ *
+ * Performance: 
+ * The rendering speed of this program is usually dictated by fill rate
+ * and the fact that software fallbacks for glBitMap makes the driver
+ * operate synchronously. Low-end UMA hardware will probably see around
+ * 35 fps with the help screen disabled and 32bpp window- and user
+ * frame-buffers (2008).
+ *
+ * This program is released under GPL, following the "fire" licensing.
+ *
+ * Authors:
+ *   David Bucciarelli ("fire")
+ *   Brian Paul ("gearbox", "fbotexture")
+ *   Thomas Hellstrom (Putting it together)
+ *
+ */
+
+#define GL_GLEXT_PROTOTYPES
+#include <math.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <GL/glut.h>
+#include "readtex.h"
+
+
+/*
+ * Format of texture we render to.
+ */
+
+#define TEXINTFORMAT GL_RGBA
+
+static GLuint texTypes[] = 
+   {GL_UNSIGNED_BYTE,
+    GL_UNSIGNED_INT_8_8_8_8_REV,
+    GL_UNSIGNED_SHORT_1_5_5_5_REV,
+    GL_UNSIGNED_SHORT_4_4_4_4_REV,
+    GL_UNSIGNED_INT_8_8_8_8,
+    GL_UNSIGNED_SHORT_5_5_5_1,
+    GL_UNSIGNED_SHORT_4_4_4_4,
+    GL_UNSIGNED_INT_8_8_8_8_REV,
+    GL_UNSIGNED_SHORT_1_5_5_5_REV,
+    GL_UNSIGNED_SHORT_4_4_4_4_REV,
+    GL_UNSIGNED_INT_8_8_8_8,
+    GL_UNSIGNED_SHORT_5_5_5_1,
+    GL_UNSIGNED_SHORT_4_4_4_4,
+    GL_UNSIGNED_SHORT_5_6_5,
+    GL_UNSIGNED_SHORT_5_6_5_REV,
+    GL_UNSIGNED_SHORT_5_6_5,
+    GL_UNSIGNED_SHORT_5_6_5_REV};
+
+static GLuint texFormats[] = 
+   {GL_RGBA,
+    GL_RGBA,
+    GL_RGBA,
+    GL_RGBA,
+    GL_RGBA,
+    GL_RGBA,
+    GL_RGBA,
+    GL_BGRA,
+    GL_BGRA,
+    GL_BGRA,
+    GL_BGRA,
+    GL_BGRA,
+    GL_BGRA,
+    GL_RGB,
+    GL_RGB,
+    GL_BGR,
+    GL_BGR};
+
+static const char *texNames[] = 
+   {"GL_RGBA GL_UNSIGNED_BYTE",
+    "GL_RGBA GL_UNSIGNED_INT_8_8_8_8_REV",
+    "GL_RGBA GL_UNSIGNED_SHORT_1_5_5_5_REV",
+    "GL_RGBA GL_UNSIGNED_SHORT_4_4_4_4_REV",
+    "GL_RGBA GL_UNSIGNED_INT_8_8_8_8",
+    "GL_RGBA GL_UNSIGNED_INT_5_5_5_1",
+    "GL_RGBA GL_UNSIGNED_INT_4_4_4_4",
+    "GL_BGRA GL_UNSIGNED_INT_8_8_8_8_REV",
+    "GL_BGRA GL_UNSIGNED_SHORT_1_5_5_5_REV",
+    "GL_BGRA GL_UNSIGNED_SHORT_4_4_4_4_REV",
+    "GL_BGRA GL_UNSIGNED_INT_8_8_8_8",
+    "GL_BGRA GL_UNSIGNED_INT_5_5_5_1",
+    "GL_BGRA GL_UNSIGNED_INT_4_4_4_4",
+    "GL_RGB GL_UNSIGNED_INT_5_6_5",
+    "GL_RGB GL_UNSIGNED_INT_5_6_5_REV",
+    "GL_BGR GL_UNSIGNED_INT_5_6_5",
+    "GL_BGR GL_UNSIGNED_INT_5_6_5_REV"};
+
+
+
+
+#ifndef M_PI
+#define M_PI 3.1415926535
+#endif
+
+#define vinit(a,i,j,k) {                       \
+      (a)[0]=i;                                        \
+      (a)[1]=j;                                        \
+      (a)[2]=k;                                        \
+   }
+
+#define vinit4(a,i,j,k,w) {                    \
+      (a)[0]=i;                                        \
+      (a)[1]=j;                                        \
+      (a)[2]=k;                                        \
+      (a)[3]=w;                                        \
+   }
+
+
+#define vadds(a,dt,b) {                                \
+      (a)[0]+=(dt)*(b)[0];                     \
+      (a)[1]+=(dt)*(b)[1];                     \
+      (a)[2]+=(dt)*(b)[2];                     \
+   }
+
+#define vequ(a,b) {                            \
+      (a)[0]=(b)[0];                           \
+      (a)[1]=(b)[1];                           \
+      (a)[2]=(b)[2];                           \
+   }
+
+#define vinter(a,dt,b,c) {                     \
+      (a)[0]=(dt)*(b)[0]+(1.0-dt)*(c)[0];      \
+      (a)[1]=(dt)*(b)[1]+(1.0-dt)*(c)[1];      \
+      (a)[2]=(dt)*(b)[2]+(1.0-dt)*(c)[2];      \
+   }
+
+#define clamp(a)        ((a) < 0.0 ? 0.0 : ((a) < 1.0 ? (a) : 1.0))
+
+#define vclamp(v) {                            \
+      (v)[0]=clamp((v)[0]);                    \
+      (v)[1]=clamp((v)[1]);                    \
+      (v)[2]=clamp((v)[2]);                    \
+   }
+
+static GLint WinWidth = 800, WinHeight = 800;
+static GLint TexWidth, TexHeight;
+static GLuint TexObj;
+static GLuint MyFB;
+static GLuint DepthRB;
+static GLboolean WireFrame = GL_FALSE;
+static GLint texType = 0;
+
+static GLint T0 = 0;
+static GLint Frames = 0;
+static GLint Win = 0;
+
+static GLfloat ViewRotX = 20.0, ViewRotY = 30.0, ViewRotZ = 0.0;
+static GLfloat CubeRot = 0.0;
+
+static void
+CheckError(int line)
+{
+   GLenum err = glGetError();
+   if (err) {
+      printf("GL Error 0x%x at line %d\n", (int) err, line);
+      exit(1);
+   }
+}
+
+
+static void
+cleanup(void)
+{
+   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+   glDeleteFramebuffersEXT(1, &MyFB);
+   glDeleteRenderbuffersEXT(1, &DepthRB);
+   glDeleteTextures(1, &TexObj);
+   glutDestroyWindow(Win);
+}
+
+static GLint NiceFog = 1;
+
+#define DIMP 20.0
+#define DIMTP 16.0
+
+#define RIDCOL 0.4
+
+#define NUMTREE 50
+#define TREEINR 2.5
+#define TREEOUTR 8.0
+
+#define AGRAV -9.8
+
+typedef struct
+{
+   int age;
+   float p[3][3];
+   float v[3];
+   float c[3][4];
+}
+   part;
+
+static float treepos[NUMTREE][3];
+
+static float black[3] = { 0.0, 0.0, 0.0 };
+static float blu[3] = { 1.0, 0.2, 0.0 };
+static float blu2[3] = { 1.0, 1.0, 0.0 };
+
+static float fogcolor[4] = { 1.0, 1.0, 1.0, 1.0 };
+
+static float q[4][3] = {
+   {-DIMP, 0.0, -DIMP},
+   {DIMP, 0.0, -DIMP},
+   {DIMP, 0.0, DIMP},
+   {-DIMP, 0.0, DIMP}
+};
+
+static float qt[4][2] = {
+   {-DIMTP, -DIMTP},
+   {DIMTP, -DIMTP},
+   {DIMTP, DIMTP},
+   {-DIMTP, DIMTP}
+};
+
+static int np;
+static float eject_r, dt, maxage, eject_vy, eject_vl;
+static short shadows;
+static float ridtri;
+static int fog = 0;
+static int help = 1;
+
+static part *p;
+
+static GLuint groundid;
+static GLuint treeid;
+
+static float obs[3] = { 2.0, 1.0, 0.0 };
+static float dir[3];
+static float v = 0.0;
+static float alpha = -84.0;
+static float beta = 90.0;
+
+static float
+vrnd(void)
+{
+   return (((float) rand()) / RAND_MAX);
+}
+
+static void
+setnewpart(part * p)
+{
+   float a, v[3], *c;
+
+   p->age = 0;
+
+   a = vrnd() * 3.14159265359 * 2.0;
+
+   vinit(v, sin(a) * eject_r * vrnd(), 0.15, cos(a) * eject_r * vrnd());
+   vinit(p->p[0], v[0] + vrnd() * ridtri, v[1] + vrnd() * ridtri,
+        v[2] + vrnd() * ridtri);
+   vinit(p->p[1], v[0] + vrnd() * ridtri, v[1] + vrnd() * ridtri,
+        v[2] + vrnd() * ridtri);
+   vinit(p->p[2], v[0] + vrnd() * ridtri, v[1] + vrnd() * ridtri,
+        v[2] + vrnd() * ridtri);
+
+   vinit(p->v, v[0] * eject_vl / (eject_r / 2),
+        vrnd() * eject_vy + eject_vy / 2, v[2] * eject_vl / (eject_r / 2));
+
+   c = blu;
+
+   vinit4(p->c[0], c[0] * ((1.0 - RIDCOL) + vrnd() * RIDCOL),
+         c[1] * ((1.0 - RIDCOL) + vrnd() * RIDCOL),
+         c[2] * ((1.0 - RIDCOL) + vrnd() * RIDCOL), 1.0);
+   vinit4(p->c[1], c[0] * ((1.0 - RIDCOL) + vrnd() * RIDCOL),
+         c[1] * ((1.0 - RIDCOL) + vrnd() * RIDCOL),
+         c[2] * ((1.0 - RIDCOL) + vrnd() * RIDCOL), 1.0);
+   vinit4(p->c[2], c[0] * ((1.0 - RIDCOL) + vrnd() * RIDCOL),
+         c[1] * ((1.0 - RIDCOL) + vrnd() * RIDCOL),
+         c[2] * ((1.0 - RIDCOL) + vrnd() * RIDCOL), 1.0);
+}
+
+static void
+setpart(part * p)
+{
+   float fact;
+
+   if (p->p[0][1] < 0.1) {
+      setnewpart(p);
+      return;
+   }
+
+   p->v[1] += AGRAV * dt;
+
+   vadds(p->p[0], dt, p->v);
+   vadds(p->p[1], dt, p->v);
+   vadds(p->p[2], dt, p->v);
+
+   p->age++;
+
+   if ((p->age) > maxage) {
+      vequ(p->c[0], blu2);
+      vequ(p->c[1], blu2);
+      vequ(p->c[2], blu2);
+   }
+   else {
+      fact = 1.0 / maxage;
+      vadds(p->c[0], fact, blu2);
+      vclamp(p->c[0]);
+      p->c[0][3] = fact * (maxage - p->age);
+
+      vadds(p->c[1], fact, blu2);
+      vclamp(p->c[1]);
+      p->c[1][3] = fact * (maxage - p->age);
+
+      vadds(p->c[2], fact, blu2);
+      vclamp(p->c[2]);
+      p->c[2][3] = fact * (maxage - p->age);
+   }
+}
+
+static void
+drawtree(float x, float y, float z)
+{
+   glBegin(GL_QUADS);
+   glTexCoord2f(0.0, 0.0);
+   glVertex3f(x - 1.5, y + 0.0, z);
+
+   glTexCoord2f(1.0, 0.0);
+   glVertex3f(x + 1.5, y + 0.0, z);
+
+   glTexCoord2f(1.0, 1.0);
+   glVertex3f(x + 1.5, y + 3.0, z);
+
+   glTexCoord2f(0.0, 1.0);
+   glVertex3f(x - 1.5, y + 3.0, z);
+
+
+   glTexCoord2f(0.0, 0.0);
+   glVertex3f(x, y + 0.0, z - 1.5);
+
+   glTexCoord2f(1.0, 0.0);
+   glVertex3f(x, y + 0.0, z + 1.5);
+
+   glTexCoord2f(1.0, 1.0);
+   glVertex3f(x, y + 3.0, z + 1.5);
+
+   glTexCoord2f(0.0, 1.0);
+   glVertex3f(x, y + 3.0, z - 1.5);
+
+   glEnd();
+
+}
+
+static void
+calcposobs(void)
+{
+   dir[0] = sin(alpha * M_PI / 180.0);
+   dir[2] = cos(alpha * M_PI / 180.0) * sin(beta * M_PI / 180.0);
+   dir[1] = cos(beta * M_PI / 180.0);
+
+   if (dir[0] < 1.0e-5 && dir[0] > -1.0e-5)
+      dir[0] = 0;
+   if (dir[1] < 1.0e-5 && dir[1] > -1.0e-5)
+      dir[1] = 0;
+   if (dir[2] < 1.0e-5 && dir[2] > -1.0e-5)
+      dir[2] = 0;
+
+   obs[0] += v * dir[0];
+   obs[1] += v * dir[1];
+   obs[2] += v * dir[2];
+}
+
+static void
+printstring(void *font, const char *string)
+{
+   int len, i;
+
+   len = (int) strlen(string);
+   for (i = 0; i < len; i++)
+      glutBitmapCharacter(font, string[i]);
+}
+
+
+static void
+printhelp(void)
+{
+   glColor4f(0.0, 0.0, 0.0, 0.5);
+   glRecti(40, 40, 600, 440);
+
+   glColor3f(1.0, 0.0, 0.0);
+   glRasterPos2i(300, 420);
+   printstring(GLUT_BITMAP_TIMES_ROMAN_24, "Help");
+
+   glRasterPos2i(60, 390);
+   printstring(GLUT_BITMAP_TIMES_ROMAN_24, "h - Toggle Help");
+
+   glRasterPos2i(60, 360);
+   printstring(GLUT_BITMAP_TIMES_ROMAN_24, "t - Increase particle size");
+   glRasterPos2i(60, 330);
+   printstring(GLUT_BITMAP_TIMES_ROMAN_24, "T - Decrease particle size");
+
+   glRasterPos2i(60, 300);
+   printstring(GLUT_BITMAP_TIMES_ROMAN_24, "r - Increase emission radius");
+   glRasterPos2i(60, 270);
+   printstring(GLUT_BITMAP_TIMES_ROMAN_24, "R - Decrease emission radius");
+
+   glRasterPos2i(60, 240);
+   printstring(GLUT_BITMAP_TIMES_ROMAN_24, "f - Toggle Fog");
+   glRasterPos2i(60, 210);
+   printstring(GLUT_BITMAP_TIMES_ROMAN_24, "s - Toggle shadows");
+   glRasterPos2i(60, 180);
+   printstring(GLUT_BITMAP_TIMES_ROMAN_24, "q - Toggle texture format & type");
+   glRasterPos2i(60, 150);
+   printstring(GLUT_BITMAP_TIMES_ROMAN_24, "a - Increase velocity");
+   glRasterPos2i(60, 120);
+   printstring(GLUT_BITMAP_TIMES_ROMAN_24, "z - Decrease velocity");
+   glRasterPos2i(60, 90);
+   printstring(GLUT_BITMAP_TIMES_ROMAN_24,  "Arrow Keys - Rotate");
+}
+
+
+static void
+drawfire(void)
+{
+   static char frbuf[80] = "";
+   int j;
+   static double t0 = -1.;
+   double t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
+   if (t0 < 0.0)
+      t0 = t;
+   dt = (t - t0) * 1.0;
+   t0 = t;
+
+   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
+
+   glDisable(GL_LIGHTING);
+
+   glShadeModel(GL_FLAT);
+
+   glEnable(GL_BLEND);
+   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+   glEnable(GL_FOG);
+   glFogi(GL_FOG_MODE, GL_EXP);
+   glFogfv(GL_FOG_COLOR, fogcolor);
+   glFogf(GL_FOG_DENSITY, 0.1);
+
+
+   glViewport(0, 0, (GLint) TexWidth, (GLint) TexHeight);
+   glMatrixMode(GL_PROJECTION);
+   glLoadIdentity();
+   gluPerspective(70.0, TexWidth/ (float) TexHeight, 0.1, 30.0);
+
+   glMatrixMode(GL_MODELVIEW);
+   glLoadIdentity();
+
+   if (NiceFog)
+      glHint(GL_FOG_HINT, GL_NICEST);
+   else
+      glHint(GL_FOG_HINT, GL_DONT_CARE);
+
+   glEnable(GL_DEPTH_TEST);
+
+   if (fog)
+      glEnable(GL_FOG);
+   else
+      glDisable(GL_FOG);
+
+   glDepthMask(GL_TRUE);
+   glClearColor(1.0, 1.0, 1.0, 1.0);
+   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+
+   glPushMatrix();
+   calcposobs();
+   gluLookAt(obs[0], obs[1], obs[2],
+            obs[0] + dir[0], obs[1] + dir[1], obs[2] + dir[2],
+            0.0, 1.0, 0.0);
+
+   glColor4f(1.0, 1.0, 1.0, 1.0);
+
+   glEnable(GL_TEXTURE_2D);
+
+   glBindTexture(GL_TEXTURE_2D, groundid);
+   glBegin(GL_QUADS);
+   glTexCoord2fv(qt[0]);
+   glVertex3fv(q[0]);
+   glTexCoord2fv(qt[1]);
+   glVertex3fv(q[1]);
+   glTexCoord2fv(qt[2]);
+   glVertex3fv(q[2]);
+   glTexCoord2fv(qt[3]);
+   glVertex3fv(q[3]);
+   glEnd();
+
+   glEnable(GL_ALPHA_TEST);
+   glAlphaFunc(GL_GEQUAL, 0.9);
+
+   glBindTexture(GL_TEXTURE_2D, treeid);
+   for (j = 0; j < NUMTREE; j++)
+      drawtree(treepos[j][0], treepos[j][1], treepos[j][2]);
+
+   glDisable(GL_TEXTURE_2D);
+   glDepthMask(GL_FALSE);
+   glDisable(GL_ALPHA_TEST);
+
+   if (shadows) {
+      glBegin(GL_TRIANGLES);
+      for (j = 0; j < np; j++) {
+        glColor4f(black[0], black[1], black[2], p[j].c[0][3]);
+        glVertex3f(p[j].p[0][0], 0.1, p[j].p[0][2]);
+
+        glColor4f(black[0], black[1], black[2], p[j].c[1][3]);
+        glVertex3f(p[j].p[1][0], 0.1, p[j].p[1][2]);
+
+        glColor4f(black[0], black[1], black[2], p[j].c[2][3]);
+        glVertex3f(p[j].p[2][0], 0.1, p[j].p[2][2]);
+      }
+      glEnd();
+   }
+
+   glBegin(GL_TRIANGLES);
+   for (j = 0; j < np; j++) {
+      glColor4fv(p[j].c[0]);
+      glVertex3fv(p[j].p[0]);
+
+      glColor4fv(p[j].c[1]);
+      glVertex3fv(p[j].p[1]);
+
+      glColor4fv(p[j].c[2]);
+      glVertex3fv(p[j].p[2]);
+
+      setpart(&p[j]);
+   }
+   glEnd();
+
+
+   glDisable(GL_TEXTURE_2D);
+   glDisable(GL_ALPHA_TEST);
+   glDisable(GL_DEPTH_TEST);
+   glDisable(GL_FOG);
+
+   glMatrixMode(GL_PROJECTION);
+   glLoadIdentity();
+   glOrtho(-0.5, 639.5, -0.5, 479.5
+          , -1.0, 1.0);
+   glMatrixMode(GL_MODELVIEW);
+   glLoadIdentity();
+
+   glColor3f(1.0, 0.0, 0.0);
+   glRasterPos2i(10, 10);
+   printstring(GLUT_BITMAP_HELVETICA_18, frbuf);
+   glColor3f(0.0, 0.0, 1.0);
+   glRasterPos2i(10, 450);
+   printstring(GLUT_BITMAP_HELVETICA_18, texNames[texType]);
+   glColor3f(1.0, 0.0, 0.0);
+   glRasterPos2i(10, 470);
+   printstring(GLUT_BITMAP_HELVETICA_10,
+              "Fire V1.5 Written by David Bucciarelli (tech.hmw@plus.it)");
+
+   if (help)
+      printhelp();
+
+   glPopMatrix();
+   glDepthMask(GL_TRUE);
+   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);   
+   Frames++;
+
+   {
+      GLint t = glutGet(GLUT_ELAPSED_TIME);
+      if (t - T0 >= 2000) {
+        GLfloat seconds = (t - T0) / 1000.0;
+        GLfloat fps = Frames / seconds;
+        sprintf(frbuf, "Frame rate: %f", fps);
+        T0 = t;
+        Frames = 0;
+      }
+   }
+   
+}
+
+static void
+regen_texImage(void)
+{
+   glBindTexture(GL_TEXTURE_2D, TexObj);
+   glTexImage2D(GL_TEXTURE_2D, 0, TEXINTFORMAT, TexWidth, TexHeight, 0,
+               texFormats[texType], texTypes[texType], NULL);
+   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
+   glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+                            GL_TEXTURE_2D, TexObj, 0);
+   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+}
+
+static void
+key(unsigned char key, int x, int y)
+{
+   switch (key) {
+   case 27:
+      cleanup();
+      exit(0);
+      break;
+
+   case 'a':
+      v += 0.0005;
+      break;
+   case 'z':
+      v -= 0.0005;
+      break;
+   case 'h':
+      help = (!help);
+      break;
+   case 'f':
+      fog = (!fog);
+      break;
+   case 's':
+      shadows = !shadows;
+      break;
+   case 'R':
+      eject_r -= 0.03;
+      break;
+   case 'r':
+      eject_r += 0.03;
+      break;
+   case 't':
+      ridtri += 0.005;
+      break;
+   case 'T':
+      ridtri -= 0.005;
+      break;
+   case 'v':
+      ViewRotZ += 5.0;
+      break;
+   case 'V':
+      ViewRotZ -= 5.0;
+      break;
+   case 'w':
+      WireFrame = !WireFrame;
+      break;
+   case 'q':
+      if (++texType > 16)
+        texType = 0;
+      regen_texImage();
+      break;
+   case 'n':
+      NiceFog = !NiceFog;
+      printf("NiceFog %d\n", NiceFog);
+      break;
+   }
+   glutPostRedisplay();
+}
+
+static void
+inittextures(void)
+{
+   GLenum gluerr;
+   GLubyte tex[128][128][4];
+
+   glGenTextures(1, &groundid);
+   glBindTexture(GL_TEXTURE_2D, groundid);
+
+   glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+   if (!LoadRGBMipmaps("../images/s128.rgb", GL_RGB)) {
+      fprintf(stderr, "Error reading a texture.\n");
+      exit(-1);
+   }
+
+   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+
+   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+                  GL_LINEAR_MIPMAP_LINEAR);
+   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
+
+   glGenTextures(1, &treeid);
+   glBindTexture(GL_TEXTURE_2D, treeid);
+
+   if (1)
+      {
+        int w, h;
+        GLenum format;
+        int x, y;
+        GLubyte *image = LoadRGBImage("../images/tree3.rgb", &w, &h, &format);
+
+        if (!image) {
+           fprintf(stderr, "Error reading a texture.\n");
+           exit(-1);
+        }
+
+        for (y = 0; y < 128; y++)
+           for (x = 0; x < 128; x++) {
+              tex[x][y][0] = image[(y + x * 128) * 3];
+              tex[x][y][1] = image[(y + x * 128) * 3 + 1];
+              tex[x][y][2] = image[(y + x * 128) * 3 + 2];
+              if ((tex[x][y][0] == tex[x][y][1]) &&
+                  (tex[x][y][1] == tex[x][y][2]) && (tex[x][y][2] == 255))
+                 tex[x][y][3] = 0;
+              else
+                 tex[x][y][3] = 255;
+           }
+
+        if ((gluerr = gluBuild2DMipmaps(GL_TEXTURE_2D, 4, 128, 128, GL_RGBA,
+                                        GL_UNSIGNED_BYTE, (GLvoid *) (tex)))) {
+           fprintf(stderr, "GLULib%s\n", (char *) gluErrorString(gluerr));
+           exit(-1);
+        }
+      }
+   else {
+      if (!LoadRGBMipmaps("../images/tree2.rgba", GL_RGBA)) {
+        fprintf(stderr, "Error reading a texture.\n");
+        exit(-1);
+      }
+   }
+
+   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+
+   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+                  GL_LINEAR_MIPMAP_LINEAR);
+   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+}
+
+static void
+inittree(void)
+{
+   int i;
+   float dist;
+
+   for (i = 0; i < NUMTREE; i++)
+      do {
+        treepos[i][0] = vrnd() * TREEOUTR * 2.0 - TREEOUTR;
+        treepos[i][1] = 0.0;
+        treepos[i][2] = vrnd() * TREEOUTR * 2.0 - TREEOUTR;
+        dist =
+           sqrt(treepos[i][0] * treepos[i][0] +
+                treepos[i][2] * treepos[i][2]);
+      } while ((dist < TREEINR) || (dist > TREEOUTR));
+}
+
+static int 
+init_fire(int ac, char *av[])
+{
+   int i;
+
+   np = 800;
+   eject_r = -0.65;
+   dt = 0.015;
+   eject_vy = 4;
+   eject_vl = 1;
+   shadows = 1;
+   ridtri = 0.25;
+
+   maxage = 1.0 / dt;
+
+   if (ac == 2)
+      np = atoi(av[1]);
+
+
+   inittextures();
+
+   p = (part *) malloc(sizeof(part) * np);
+
+   for (i = 0; i < np; i++)
+      setnewpart(&p[i]);
+
+   inittree();
+
+   return (0);
+}
+
+
+
+
+
+
+static void
+DrawCube(void)
+{
+   static const GLfloat texcoords[4][2] = {
+      { 0, 0 }, { 1, 0 }, { 1, 1 }, { 0, 1 }
+   };
+   static const GLfloat vertices[4][2] = {
+      { -1, -1 }, { 1, -1 }, { 1, 1 }, { -1, 1 }
+   };
+   static const GLfloat xforms[6][4] = {
+      {   0, 0, 1, 0 },
+      {  90, 0, 1, 0 },
+      { 180, 0, 1, 0 },
+      { 270, 0, 1, 0 },
+      {  90, 1, 0, 0 },
+      { -90, 1, 0, 0 }
+   };
+   static const GLfloat mat[4] = { 1.0, 1.0, 0.5, 1.0 };
+   GLint i, j;
+
+   glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat);
+   glEnable(GL_TEXTURE_2D);
+
+   glPushMatrix();
+   glRotatef(ViewRotX, 1.0, 0.0, 0.0);
+   glRotatef(15, 1, 0, 0);
+   glRotatef(CubeRot, 0, 1, 0);
+   glScalef(4, 4, 4);
+
+   for (i = 0; i < 6; i++) {
+      glPushMatrix();
+      glRotatef(xforms[i][0], xforms[i][1], xforms[i][2], xforms[i][3]);
+      glTranslatef(0, 0, 1.1);
+      glBegin(GL_POLYGON);
+      glNormal3f(0, 0, 1);
+      for (j = 0; j < 4; j++) {
+        glTexCoord2fv(texcoords[j]);
+        glVertex2fv(vertices[j]);
+      }
+      glEnd();
+      glPopMatrix();
+   }
+   glPopMatrix();
+
+   glDisable(GL_TEXTURE_2D);
+}
+
+
+static void
+draw(void)
+{
+   float ar;
+   static GLfloat pos[4] = {5.0, 5.0, 10.0, 0.0};
+
+   drawfire();
+
+   glLightfv(GL_LIGHT0, GL_POSITION, pos);
+   glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,
+                GL_SEPARATE_SPECULAR_COLOR);
+
+   glEnable(GL_LIGHTING);
+   glEnable(GL_LIGHT0);
+   glEnable(GL_DEPTH_TEST);
+   glEnable(GL_NORMALIZE);
+   glDisable(GL_BLEND);
+   glDisable(GL_FOG);
+
+   glMatrixMode(GL_MODELVIEW);
+   glLoadIdentity();
+   glTranslatef(0.0, 0.0, -40.0);
+
+   glClear(GL_DEPTH_BUFFER_BIT);
+
+   /* draw textured cube */
+
+   glViewport(0, 0, WinWidth, WinHeight);
+   glClearColor(0.5, 0.5, 0.8, 0.0);
+   glClear(GL_COLOR_BUFFER_BIT);
+
+   ar = (float) (WinWidth) / WinHeight;
+   glMatrixMode(GL_PROJECTION);
+   glLoadIdentity();
+   glFrustum(-ar, ar, -1.0, 1.0, 5.0, 60.0);
+   glMatrixMode(GL_MODELVIEW);
+   glBindTexture(GL_TEXTURE_2D, TexObj);
+
+   DrawCube();
+
+   /* finish up */
+   glutSwapBuffers();
+}
+
+
+static void
+idle(void)
+{
+   static double t0 = -1.;
+   double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
+   if (t0 < 0.0)
+      t0 = t;
+   dt = t - t0;
+   t0 = t;
+
+   CubeRot = fmod(CubeRot + 15.0 * dt, 360.0);  /* 15 deg/sec */
+
+   glutPostRedisplay();
+}
+
+
+/* change view angle */
+static void
+special(int k, int x, int y)
+{
+   (void) x;
+   (void) y;
+   switch (k) {
+   case GLUT_KEY_UP:
+      ViewRotX += 5.0;
+      break;
+   case GLUT_KEY_DOWN:
+      ViewRotX -= 5.0;
+      break;
+   case GLUT_KEY_LEFT:
+      ViewRotY += 5.0;
+      break;
+   case GLUT_KEY_RIGHT:
+      ViewRotY -= 5.0;
+      break;
+   default:
+      return;
+   }
+   glutPostRedisplay();
+}
+
+
+/* new window size or exposure */
+static void
+reshape(int width, int height)
+{
+   WinWidth = width;
+   WinHeight = height;
+}
+
+
+static void 
+init_fbotexture()
+{
+   GLint i;
+
+   /* gen framebuffer id, delete it, do some assertions, just for testing */
+   glGenFramebuffersEXT(1, &MyFB);
+   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
+   glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &i);
+
+   /* Make texture object/image */
+   glGenTextures(1, &TexObj);
+   glBindTexture(GL_TEXTURE_2D, TexObj);
+   /* make one image level. */
+   glTexImage2D(GL_TEXTURE_2D, 0, TEXINTFORMAT, TexWidth, TexHeight, 0,
+               texFormats[texType], texTypes[texType], NULL);
+
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+   glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
+
+   CheckError(__LINE__);
+
+   /* Render color to texture */
+   glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+                            GL_TEXTURE_2D, TexObj, 0);
+   CheckError(__LINE__);
+
+
+   /* make depth renderbuffer */
+   glGenRenderbuffersEXT(1, &DepthRB);
+   glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, DepthRB);
+   glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16,
+                           TexWidth, TexHeight);
+   CheckError(__LINE__);
+   glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
+                                  GL_RENDERBUFFER_DEPTH_SIZE_EXT, &i);
+   CheckError(__LINE__);
+   printf("Depth renderbuffer size = %d bits\n", i);
+
+   /* attach DepthRB to MyFB */
+   glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
+                               GL_RENDERBUFFER_EXT, DepthRB);
+   CheckError(__LINE__);
+   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+
+   /*
+    * Check for completeness.
+    */
+
+}
+
+
+static void
+init(int argc, char *argv[])
+{
+   GLint i;
+
+   if (!glutExtensionSupported("GL_EXT_framebuffer_object")) {
+      fprintf(stderr, "Sorry, GL_EXT_framebuffer_object is required!\n");
+      exit(1);
+   }
+
+   TexWidth = 512;
+   TexHeight = 512;
+
+   init_fbotexture();
+   init_fire(argc, argv);
+
+
+   for ( i=1; i<argc; i++ ) {
+      if (strcmp(argv[i], "-info")==0) {
+        printf("GL_RENDERER   = %s\n", (char *) glGetString(GL_RENDERER));
+        printf("GL_VERSION    = %s\n", (char *) glGetString(GL_VERSION));
+        printf("GL_VENDOR     = %s\n", (char *) glGetString(GL_VENDOR));
+        printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
+      }
+   }
+}
+
+
+static void 
+visible(int vis)
+{
+   if (vis == GLUT_VISIBLE)
+      glutIdleFunc(idle);
+   else
+      glutIdleFunc(NULL);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+   glutInit(&argc, argv);
+
+   glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
+
+   glutInitWindowSize(WinWidth, WinHeight);
+   Win = glutCreateWindow("fbo_firecube");
+   init(argc, argv);
+
+   glutDisplayFunc(draw);
+   glutReshapeFunc(reshape);
+   glutKeyboardFunc(key);
+   glutSpecialFunc(special);
+   glutVisibilityFunc(visible);
+
+   glutMainLoop();
+   return 0;             /* ANSI C requires main to return int. */
+}
index e79b5cc1970c1e802c2b42f647c436451113726f..c7931f4697ef723a891648d3a674019a03a8c266 100644 (file)
@@ -45,7 +45,7 @@ static GLint uTexture;
 
 static GLuint SphereList, RectList, CurList;
 static GLint win = 0;
-static GLboolean anim = GL_TRUE;
+static GLboolean anim = 0*GL_TRUE;
 static GLboolean wire = GL_FALSE;
 static GLboolean pixelLight = GL_TRUE;
 
index 3a1662cd6251c9a3a3e9449c0523cba01bde3391..35bde04417b17f3526907f442fb0a3bf6ccd2f23 100644 (file)
@@ -264,38 +264,44 @@ draw(void)
    glLoadIdentity();
    glTranslatef(0.0, 0.0, -40.0);
 
+   /* clear whole depth buffer */
    glDisable(GL_SCISSOR_TEST);
    glClear(GL_DEPTH_BUFFER_BIT);
    glEnable(GL_SCISSOR_TEST);
 
-   /* draw gears */
+   /* clear upper-left corner of color buffer (unused space) */
+   glScissor(0, TexHeight, TexWidth, WinHeight - TexHeight);
+   glClearColor(0.0, 0.0, 0.0, 0.0);
+   glClear(GL_COLOR_BUFFER_BIT);
+
+   /* clear lower-left corner of color buffer */
    glViewport(0, 0, TexWidth, TexHeight);
    glScissor(0, 0, TexWidth, TexHeight);
-   glClearColor(0.5, 0.5, 0.8, 0.0);
    glClearColor(1, 1, 1, 0);
    glClear(GL_COLOR_BUFFER_BIT);
 
+   /* draw gears in lower-left corner */
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 60.0);
    glMatrixMode(GL_MODELVIEW);
-
    DrawGears();
 
+   /* copy color buffer to texture */
    glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, TexWidth, TexHeight);
    
-   /* draw textured cube */
+   /* clear right half of color buffer */
    glViewport(TexWidth, 0, WinWidth - TexWidth, WinHeight);
    glScissor(TexWidth, 0, WinWidth - TexWidth, WinHeight);
    glClearColor(0.5, 0.5, 0.8, 0.0);
    glClear(GL_COLOR_BUFFER_BIT);
 
+   /* draw textured cube in right half of window */
    ar = (float) (WinWidth - TexWidth) / WinHeight;
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glFrustum(-ar, ar, -1.0, 1.0, 5.0, 60.0);
    glMatrixMode(GL_MODELVIEW);
-
    DrawCube();
 
    /* finish up */
old mode 100755 (executable)
new mode 100644 (file)
index d963985c69de0012520a52de4a8eb2fb5e922a37..451fd11efe12c68fc973b9eef4d42603639f04d3 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * GL_ARB_multitexture demo
  *
@@ -32,7 +31,6 @@ static GLint NumUnits = 1;
 static GLboolean TexEnabled[8];
 
 static GLfloat Drift = 0.0;
-static GLfloat drift_increment = 0.005;
 static GLfloat Xrot = 20.0, Yrot = 30.0, Zrot = 0.0;
 
 
@@ -41,9 +39,7 @@ static void Idle( void )
    if (Animate) {
       GLint i;
 
-      Drift += drift_increment;
-      if (Drift >= 1.0)
-         Drift = 0.0;
+      Drift = glutGet(GLUT_ELAPSED_TIME) * 0.001;
 
       for (i = 0; i < NumUnits; i++) {
          glActiveTextureARB(GL_TEXTURE0_ARB + i);
@@ -57,10 +53,11 @@ static void Idle( void )
             glTranslatef(0.0, Drift, 0.0);
          }
          else {
-            glTranslatef(0.5, 0.5, 0.0);
+            float tx = 0.5, ty = 0.5;
+            glTranslatef(tx, ty, 0.0);
             glRotatef(180.0 * Drift, 0, 0, 1);
             glScalef(1.0/i, 1.0/i, 1.0/i);
-            glTranslatef(-0.5, -0.5, 0.0);
+            glTranslatef(-tx, -ty + i * 0.1, 0.0);
          }
       }
       glMatrixMode(GL_MODELVIEW);
@@ -72,10 +69,9 @@ static void Idle( void )
 
 static void DrawObject(void)
 {
-   GLint i;
-   GLint j;
-   static const GLfloat   tex_coords[] = {  0.0,  0.0,  1.0,  1.0,  0.0 };
-   static const GLfloat   vtx_coords[] = { -1.0, -1.0,  1.0,  1.0, -1.0 };
+   static const GLfloat tex_coords[] = {  0.0,  0.0,  1.0,  1.0,  0.0 };
+   static const GLfloat vtx_coords[] = { -1.0, -1.0,  1.0,  1.0, -1.0 };
+   GLint i, j;
 
    if (!TexEnabled[0] && !TexEnabled[1])
       glColor3f(0.1, 0.1, 0.1);  /* add onto this */
@@ -83,37 +79,20 @@ static void DrawObject(void)
       glColor3f(1, 1, 1);  /* modulate this */
 
    glBegin(GL_QUADS);
-
-   /* Toggle between the vector and scalar entry points.  This is done purely
-    * to hit multiple paths in the driver.
-    */
-   if ( Drift > 0.49 ) {
-      for (j = 0; j < 4; j++ ) {
-        for (i = 0; i < NumUnits; i++)
-           glMultiTexCoord2fARB(GL_TEXTURE0_ARB + i, 
-                                tex_coords[j], tex_coords[j+1]);
-        glVertex2f( vtx_coords[j], vtx_coords[j+1] );
-      }
-   }
-   else {
-      for (j = 0; j < 4; j++ ) {
-        for (i = 0; i < NumUnits; i++)
-           glMultiTexCoord2fvARB(GL_TEXTURE0_ARB + i, & tex_coords[j]);
-        glVertex2fv( & vtx_coords[j] );
+   for (j = 0; j < 4; j++ ) {
+      for (i = 0; i < NumUnits; i++) {
+         if (TexEnabled[i])
+            glMultiTexCoord2fARB(GL_TEXTURE0_ARB + i, 
+                                 tex_coords[j], tex_coords[j+1]);
       }
+      glVertex2f( vtx_coords[j], vtx_coords[j+1] );
    }
-
    glEnd();
 }
 
 
-
 static void Display( void )
 {
-   static GLint T0 = 0;
-   static GLint Frames = 0;
-   GLint t;
-
    glClear( GL_COLOR_BUFFER_BIT );
 
    glPushMatrix();
@@ -125,16 +104,6 @@ static void Display( void )
    glPopMatrix();
 
    glutSwapBuffers();
-
-   Frames++;
-
-   t = glutGet(GLUT_ELAPSED_TIME);
-   if (t - T0 >= 250) {
-      GLfloat seconds = (t - T0) / 1000.0;
-      drift_increment = 2.2 * seconds / Frames;
-      T0 = t;
-      Frames = 0;
-   }
 }
 
 
@@ -151,24 +120,34 @@ static void Reshape( int width, int height )
 }
 
 
+static void ToggleUnit(int unit)
+{
+   TexEnabled[unit] = !TexEnabled[unit];
+   glActiveTextureARB(GL_TEXTURE0_ARB + unit);
+   if (TexEnabled[unit])
+      glEnable(GL_TEXTURE_2D);
+   else
+      glDisable(GL_TEXTURE_2D);
+   printf("Enabled: ");
+   for (unit = 0; unit < NumUnits; unit++)
+      printf("%d ", (int) TexEnabled[unit]);
+   printf("\n");
+}
+
+
 static void ModeMenu(int entry)
 {
    if (entry >= TEX0 && entry <= TEX7) {
       /* toggle */
       GLint i = entry - TEX0;
-      TexEnabled[i] = !TexEnabled[i];
-      glActiveTextureARB(GL_TEXTURE0_ARB + i);
-      if (TexEnabled[i])
-         glEnable(GL_TEXTURE_2D);
-      else
-         glDisable(GL_TEXTURE_2D);
-      printf("Enabled: ");
-      for (i = 0; i < NumUnits; i++)
-         printf("%d ", (int) TexEnabled[i]);
-      printf("\n");
+      ToggleUnit(i);
    }
    else if (entry==ANIMATE) {
       Animate = !Animate;
+      if (Animate)
+         glutIdleFunc(Idle);
+      else
+         glutIdleFunc(NULL);
    }
    else if (entry==QUIT) {
       exit(0);
@@ -183,9 +162,36 @@ static void Key( unsigned char key, int x, int y )
    (void) x;
    (void) y;
    switch (key) {
-      case 27:
-         exit(0);
-         break;
+   case 'a':
+      Animate = !Animate;
+      break;
+   case '0':
+      ToggleUnit(0);
+      break;
+   case '1':
+      ToggleUnit(1);
+      break;
+   case '2':
+      ToggleUnit(2);
+      break;
+   case '3':
+      ToggleUnit(3);
+      break;
+   case '4':
+      ToggleUnit(4);
+      break;
+   case '5':
+      ToggleUnit(5);
+      break;
+   case '6':
+      ToggleUnit(6);
+      break;
+   case '7':
+      ToggleUnit(7);
+      break;
+   case 27:
+      exit(0);
+      break;
    }
    glutPostRedisplay();
 }
@@ -327,7 +333,8 @@ int main( int argc, char *argv[] )
    glutKeyboardFunc( Key );
    glutSpecialFunc( SpecialKey );
    glutDisplayFunc( Display );
-   glutIdleFunc( Idle );
+   if (Animate)
+      glutIdleFunc(Idle);
 
    glutCreateMenu(ModeMenu);
 
index d19f049c5f3fadef39c0c023e4ebfa0689b1dcff..59b6471ef8fa19792686e4615819172534762759 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <math.h>
 #include <time.h>
 #include <GL/glut.h>
@@ -113,7 +114,7 @@ static void calcposobs(void)
   rainParticle::setRainingArea(obs[0]-7.0f,-0.2f,obs[2]-7.0f,obs[0]+7.0f,8.0f,obs[2]+7.0f);
 }
 
-static void printstring(void *font, char *string)
+static void printstring(void *font, const char *string)
 {
   int len,i;
 
index 05741759354fecd01cb9a28b7afaefd84427294c..4787f0f29d2aa6b86e597ffe970e51cf2bfba71f 100644 (file)
@@ -84,6 +84,7 @@ static const char *FragProgNames[] = {
    "program with \"OPTION ARB_fragment_program_shadow\"",
 };
 
+static GLboolean HaveShadow = GL_FALSE;
 static GLboolean HaveFBO = GL_FALSE;
 static GLboolean UseFBO = GL_FALSE;
 static GLboolean HaveVP = GL_FALSE;
@@ -529,7 +530,10 @@ ShowShadowMap(void)
    DisableTexgen();
 
    /* interpret texture's depth values as luminance values */
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
+   if (HaveShadow) {
+      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
+   }
+
    glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE);
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
 
@@ -596,7 +600,9 @@ Display(void)
       }
 
       if (DisplayMode == SHOW_DEPTH_MAPPING) {
-         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
+         if (HaveShadow) {
+            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
+         }
          glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
          glEnable(GL_TEXTURE_2D);
 
@@ -614,8 +620,10 @@ Display(void)
       }
       else {
          assert(DisplayMode == SHOW_SHADOWS);
-         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB,
-                         GL_COMPARE_R_TO_TEXTURE_ARB);
+         if (HaveShadow) {
+            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB,
+                            GL_COMPARE_R_TO_TEXTURE_ARB);
+         }
 
          if (curr_frag > 0) {
             glEnable(GL_FRAGMENT_PROGRAM_ARB);
@@ -724,6 +732,10 @@ Key(unsigned char key, int x, int y)
          break;
       case 'M':
          curr_frag = (1 + curr_frag) % max_frag;
+         if (!HaveShadow && (curr_frag == 0)) {
+            curr_frag = 1;
+         }
+
          printf("Using fragment %s\n", FragProgNames[curr_frag]);
 
          if (HaveFP) {
@@ -741,8 +753,10 @@ Key(unsigned char key, int x, int y)
             if (Operator >= 8)
                Operator = 0;
             printf("Operator: %s\n", OperatorName[Operator]);
-            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB,
-                            OperatorFunc[Operator]);
+            if (HaveShadow) {
+               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB,
+                               OperatorFunc[Operator]);
+            }
          }
          break;
       case 'p':
@@ -859,17 +873,31 @@ Init(void)
 {
    static const GLfloat borderColor[4] = {1.0, 0.0, 0.0, 0.0};
 
-   if (!glutExtensionSupported("GL_ARB_depth_texture") ||
-       !glutExtensionSupported("GL_ARB_shadow")) {
-      printf("Sorry, this demo requires the GL_ARB_depth_texture and GL_ARB_shadow extensions\n");
+   if (!glutExtensionSupported("GL_ARB_depth_texture")) {
+      printf("Sorry, this demo requires the GL_ARB_depth_texture extension\n");
       exit(1);
    }
-   printf("Using GL_ARB_depth_texture and GL_ARB_shadow\n");
 
+   HaveShadow = glutExtensionSupported("GL_ARB_shadow");
    HaveVP = glutExtensionSupported("GL_ARB_vertex_program");
    HaveFP = glutExtensionSupported("GL_ARB_fragment_program");
    HaveFP_Shadow = glutExtensionSupported("GL_ARB_fragment_program_shadow");
 
+   if (!HaveShadow && !HaveFP) {
+      printf("Sorry, this demo requires either the GL_ARB_shadow extension "
+            "or the GL_ARB_fragment_program extension\n");
+      exit(1);
+   }
+
+   printf("Using GL_ARB_depth_texture\n");
+   if (HaveShadow) {
+      printf("and GL_ARB_shadow\n");
+   }
+
+   if (HaveFP) {
+      printf("and GL_ARB_fragment_program\n");
+   }
+
    HaveShadowAmbient = glutExtensionSupported("GL_ARB_shadow_ambient");
    if (HaveShadowAmbient) {
       printf("and GL_ARB_shadow_ambient\n");
@@ -896,9 +924,12 @@ Init(void)
    glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB,
-                   GL_COMPARE_R_TO_TEXTURE_ARB);
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);
+
+   if (HaveShadow) {
+      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB,
+                      GL_COMPARE_R_TO_TEXTURE_ARB);
+      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);
+   }
 
    if (HaveShadowAmbient) {
       glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FAIL_VALUE_ARB, 0.3);
@@ -924,7 +955,6 @@ Init(void)
    glGenTextures(1, &GrayTexture);
    glBindTexture(GL_TEXTURE_1D, GrayTexture);
    glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP);
-   glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    {
@@ -955,6 +985,11 @@ Init(void)
       max_frag = 3;
    }
 
+   if (!HaveShadow) {
+      curr_frag = 1;
+      glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, frag_progs[curr_frag]);
+   }
+
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
index 53b100a18d9ec776027eeebe1c5e66c72d79c163..93c2a7df14bd2e1982936e67e831bca4ac529538 100644 (file)
@@ -11,6 +11,8 @@ LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME)
 CFLAGS += $(shell pkg-config --cflags directfb)
 APP_LIB_DEPS += $(shell pkg-config --libs directfb)
 
+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
+
 PROGS = df_gears \
           df_reflect \
           df_morph3d \
@@ -22,7 +24,7 @@ PROGS = df_gears \
 .SUFFIXES: .c
 
 .c: $(LIB_DEP)
-       $(CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@
+       $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
 
 
 ##### TARGETS #####
index 948d7356098ea29eceb0084e938509aad2836126..75cd411d93dc372cfaff9889e03b3c1337ec5e27 100644 (file)
@@ -29,42 +29,42 @@ default: $(PROGRAMS)
 
 
 demo1: demo1.o $(TOP)/$(LIB_DIR)/libEGL.so
-       $(CC) $(CFLAGS) demo1.o -L$(TOP)/$(LIB_DIR) -lEGL $(LIBDRM_LIB) -o $@
+       $(CC) $(CFLAGS) $(LDFLAGS) demo1.o -L$(TOP)/$(LIB_DIR) -lEGL $(LIBDRM_LIB) -o $@
 
 demo1.o: demo1.c $(HEADERS)
        $(CC) -c $(CFLAGS) -I$(TOP)/include demo1.c
 
 
 demo2: demo2.o $(TOP)/$(LIB_DIR)/libEGL.so
-       $(CC) $(CFLAGS) demo2.o -L$(TOP)/$(LIB_DIR) -lEGL $(LIBDRM_LIB) $(APP_LIB_DEPS) -o $@
+       $(CC) $(CFLAGS) $(LDFLAGS) demo2.o -L$(TOP)/$(LIB_DIR) -lEGL $(LIBDRM_LIB) $(APP_LIB_DEPS) -o $@
 
 demo2.o: demo2.c $(HEADERS)
        $(CC) -c $(CFLAGS) -I$(TOP)/include demo2.c
 
 
 demo3: demo3.o $(TOP)/$(LIB_DIR)/libEGL.so
-       $(CC) $(CFLAGS) demo3.o -L$(TOP)/$(LIB_DIR) -lEGL $(LIBDRM_LIB) $(APP_LIB_DEPS) -o $@
+       $(CC) $(CFLAGS) $(LDFLAGS) demo3.o -L$(TOP)/$(LIB_DIR) -lEGL $(LIBDRM_LIB) $(APP_LIB_DEPS) -o $@
 
 demo3.o: demo3.c $(HEADERS)
        $(CC) -c $(CFLAGS) -I$(TOP)/include demo3.c
 
 
 egltri: egltri.o $(TOP)/$(LIB_DIR)/libEGL.so
-       $(CC) $(CFLAGS) egltri.o -L$(TOP)/$(LIB_DIR) -lGL -lEGL $(LIBDRM_LIB) -o $@
+       $(CC) $(CFLAGS) egltri.o -L$(TOP)/$(LIB_DIR) -lEGL $(LIBDRM_LIB) -o $@
 
 egltri.o: egltri.c $(HEADERS)
        $(CC) -c $(CFLAGS) -I$(TOP)/include egltri.c
 
 
 eglinfo: eglinfo.o $(TOP)/$(LIB_DIR)/libEGL.so
-       $(CC) $(CFLAGS) eglinfo.o -L$(TOP)/$(LIB_DIR) -lGL -lEGL $(LIBDRM_LIB) -o $@
+       $(CC) $(CFLAGS) $(LDFLAGS) eglinfo.o -L$(TOP)/$(LIB_DIR) -lEGL $(LIBDRM_LIB) -o $@
 
 eglinfo.o: eglinfo.c $(HEADERS)
        $(CC) -c $(CFLAGS) -I$(TOP)/include eglinfo.c
 
 
 eglgears: eglgears.o $(TOP)/$(LIB_DIR)/libEGL.so
-       $(CC) $(CFLAGS) eglgears.o -L$(TOP)/$(LIB_DIR) -lEGL $(LIBDRM_LIB) $(APP_LIB_DEPS) -o $@
+       $(CC) $(CFLAGS) $(LDFLAGS) eglgears.o -L$(TOP)/$(LIB_DIR) -lEGL $(LIBDRM_LIB) $(APP_LIB_DEPS) -o $@
 
 eglgears.o: eglgears.c $(HEADERS)
        $(CC) -c $(CFLAGS) -I$(TOP)/include eglgears.c
@@ -92,12 +92,7 @@ xegl_tri.o: xegl_tri.c $(HEADERS)
 
 
 clean:
-       rm -f *.o *~
-       rm -f *.so
-       rm -f $(PROGRAMS)
+       -rm -f *.o *~
+       -rm -f *.so
+       -rm -f $(PROGRAMS)
 
-run:
-       LD_LIBRARY_PATH=$(TOP)/lib ./egltri
-
-debug:
-       LD_LIBRARY_PATH=$(TOP)/lib gdb ./eglgears
index 178020e2b3fa3f290fa9eb03c7279dcc50282f29..e935a519c36a769af59ae1794634678e112d1730 100644 (file)
@@ -15,6 +15,7 @@ INCLUDES = \
        -I. \
        -I$(TOP)/include
 
+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
 
 ##### RULES #####
 
@@ -22,7 +23,7 @@ INCLUDES = \
 .SUFFIXES: .c
 
 .c:
-       $(CC) $(INCLUDES) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@
+       $(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
 
 .c.o:
        $(CC) -c $(INCLUDES) $(CFLAGS) $< -o $@
@@ -36,8 +37,8 @@ INCLUDES = \
 default:  depend $(PROGS)
 
 clean:
-       rm -f $(PROGS)
-       rm -f *.o
+       -rm -f $(PROGS)
+       -rm -f *.o
 
 
 depend: $(SOURCES)
old mode 100644 (file)
new mode 100755 (executable)
index 65b2cc1..ef6644c
@@ -8,7 +8,7 @@ TOP = ../..
 include $(TOP)/configs/current
 
 
-LIBS = $(APP_LIB_DEPS)
+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
 
 SOURCES = \
        tri-tex.c \
@@ -40,7 +40,7 @@ UTIL_FILES = readtex.h readtex.c
 .SUFFIXES: .c
 
 .c:
-       $(APP_CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@
+       $(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
 
 .c.o:
        $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
@@ -54,9 +54,9 @@ UTIL_FILES = readtex.h readtex.c
 default: $(UTIL_FILES) $(PROGS)
 
 clean:
-       rm -f $(PROGS)
-       rm -f *.o
-       rm -f getproclist.h
+       -rm -f $(PROGS)
+       -rm -f *.o
+       -rm -f getproclist.h
 
 
 # auto code generation
@@ -67,13 +67,15 @@ getproclist.h: $(TOP)/src/mesa/glapi/gl_API.xml getprocaddress.c getprocaddress.
 
 
 texrect: texrect.o readtex.o
-       $(APP_CC) texrect.o readtex.o $(LIBS) -o $@
+       $(CC) $(CFLAGS) $(LDFLAGS) texrect.o readtex.o $(LIBS) -o $@
+#      $(APP_CC) texrect.o readtex.o $(LIBS) -o $@
 
 texrect.o: texrect.c readtex.h
        $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
 
 invert: invert.o readtex.o
-       $(APP_CC) invert.o readtex.o $(LIBS) -o $@
+       $(CC) $(CFLAGS) $(LDFLAGS) invert.o readtex.o $(LIBS) -o $@
+#      $(APP_CC) invert.o readtex.o $(LIBS) -o $@
 
 invert.o: invert.c readtex.h
        $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
diff --git a/progs/fp/add-swz.txt b/progs/fp/add-swz.txt
new file mode 100644 (file)
index 0000000..5ec51bc
--- /dev/null
@@ -0,0 +1,5 @@
+!!ARBfp1.0
+TEMP R0;
+ADD R0, fragment.color, fragment.color;
+ADD result.color, R0.xxxx, R0;
+END
index 2512e824ee75516d4fd233bdb54df6e5a1fa8038..843f897871b4f865a652499ab2ddc014955ed342 100644 (file)
@@ -156,11 +156,11 @@ int main(int argc, char **argv)
    glutInitWindowPosition(0, 0);
    glutInitWindowSize(250, 250);
    glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH);
-   glutCreateWindow(argv[0]);
+   args(argc, argv);
+   glutCreateWindow(filename);
    glutReshapeFunc(Reshape);
    glutKeyboardFunc(Key);
    glutDisplayFunc(Display);
-   args(argc, argv);
    Init();
    if (show_fps) {
       signal(SIGALRM, alarmhandler);
diff --git a/progs/fp/mul-swz.txt b/progs/fp/mul-swz.txt
new file mode 100644 (file)
index 0000000..7ef2f58
--- /dev/null
@@ -0,0 +1,3 @@
+!!ARBfp1.0
+MUL result.color, fragment.color.zyxw, fragment.color;
+END
diff --git a/progs/fp/negate.txt b/progs/fp/negate.txt
new file mode 100644 (file)
index 0000000..3d00a04
--- /dev/null
@@ -0,0 +1,6 @@
+!!ARBfp1.0
+# this should result in fragment color passing through unchanged
+TEMP R0;
+ADD R0, fragment.color, fragment.color;
+ADD result.color, R0, -fragment.color;
+END
diff --git a/progs/fp/run.sh b/progs/fp/run.sh
new file mode 100755 (executable)
index 0000000..480f810
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+for i in *.txt ; do
+echo $i
+./fp-tri $i
+done
+
index 81ecf5bdd5e92976377e4e68ac703fe7d3884f1d..09340ff2adb3f55797eef5cb9575fd2e2293c11f 100644 (file)
@@ -1,11 +1,18 @@
+bitmap
 brick
 bump
 convolutions
 deriv
 extfuncs.h
 mandelbrot
+multitex
 noise
+points
 readtex.c
 readtex.h
+shaderutil.c
+shaderutil.h
 texdemo1
 toyball
+trirast
+twoside
diff --git a/progs/glsl/CH06-brick.frag b/progs/glsl/CH06-brick.frag
new file mode 100644 (file)
index 0000000..06ef04e
--- /dev/null
@@ -0,0 +1,36 @@
+//
+// Fragment shader for procedural bricks
+//
+// Authors: Dave Baldwin, Steve Koren, Randi Rost
+//          based on a shader by Darwyn Peachey
+//
+// Copyright (c) 2002-2006 3Dlabs Inc. Ltd. 
+//
+// See 3Dlabs-License.txt for license information
+//
+
+uniform vec3  BrickColor, MortarColor;
+uniform vec2  BrickSize;
+uniform vec2  BrickPct;
+
+varying vec2  MCposition;
+varying float LightIntensity;
+
+void main()
+{
+    vec3  color;
+    vec2  position, useBrick;
+    
+    position = MCposition / BrickSize;
+
+    if (fract(position.y * 0.5) > 0.5)
+        position.x += 0.5;
+
+    position = fract(position);
+
+    useBrick = step(position, BrickPct);
+
+    color  = mix(MortarColor, BrickColor, useBrick.x * useBrick.y);
+    color *= LightIntensity;
+    gl_FragColor = vec4(color, 1.0);
+}
diff --git a/progs/glsl/CH06-brick.frag.txt b/progs/glsl/CH06-brick.frag.txt
deleted file mode 100644 (file)
index 06ef04e..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-// Fragment shader for procedural bricks
-//
-// Authors: Dave Baldwin, Steve Koren, Randi Rost
-//          based on a shader by Darwyn Peachey
-//
-// Copyright (c) 2002-2006 3Dlabs Inc. Ltd. 
-//
-// See 3Dlabs-License.txt for license information
-//
-
-uniform vec3  BrickColor, MortarColor;
-uniform vec2  BrickSize;
-uniform vec2  BrickPct;
-
-varying vec2  MCposition;
-varying float LightIntensity;
-
-void main()
-{
-    vec3  color;
-    vec2  position, useBrick;
-    
-    position = MCposition / BrickSize;
-
-    if (fract(position.y * 0.5) > 0.5)
-        position.x += 0.5;
-
-    position = fract(position);
-
-    useBrick = step(position, BrickPct);
-
-    color  = mix(MortarColor, BrickColor, useBrick.x * useBrick.y);
-    color *= LightIntensity;
-    gl_FragColor = vec4(color, 1.0);
-}
diff --git a/progs/glsl/CH06-brick.vert b/progs/glsl/CH06-brick.vert
new file mode 100644 (file)
index 0000000..e95e6f4
--- /dev/null
@@ -0,0 +1,41 @@
+//
+// Vertex shader for procedural bricks
+//
+// Authors: Dave Baldwin, Steve Koren, Randi Rost
+//          based on a shader by Darwyn Peachey
+//
+// Copyright (c) 2002-2006 3Dlabs Inc. Ltd. 
+//
+// See 3Dlabs-License.txt for license information
+//
+
+uniform vec3 LightPosition;
+
+const float SpecularContribution = 0.3;
+const float DiffuseContribution  = 1.0 - SpecularContribution;
+
+varying float LightIntensity;
+varying vec2  MCposition;
+
+void main()
+{
+    vec3 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex);
+    vec3 tnorm      = normalize(gl_NormalMatrix * gl_Normal);
+    vec3 lightVec   = normalize(LightPosition - ecPosition);
+    vec3 reflectVec = reflect(-lightVec, tnorm);
+    vec3 viewVec    = normalize(-ecPosition);
+    float diffuse   = max(dot(lightVec, tnorm), 0.0);
+    float spec      = 0.0;
+
+    if (diffuse > 0.0)
+    {
+        spec = max(dot(reflectVec, viewVec), 0.0);
+        spec = pow(spec, 16.0);
+    }
+
+    LightIntensity  = DiffuseContribution * diffuse +
+                      SpecularContribution * spec;
+
+    MCposition      = gl_Vertex.xy;
+    gl_Position     = ftransform();
+}
diff --git a/progs/glsl/CH06-brick.vert.txt b/progs/glsl/CH06-brick.vert.txt
deleted file mode 100644 (file)
index e95e6f4..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// Vertex shader for procedural bricks
-//
-// Authors: Dave Baldwin, Steve Koren, Randi Rost
-//          based on a shader by Darwyn Peachey
-//
-// Copyright (c) 2002-2006 3Dlabs Inc. Ltd. 
-//
-// See 3Dlabs-License.txt for license information
-//
-
-uniform vec3 LightPosition;
-
-const float SpecularContribution = 0.3;
-const float DiffuseContribution  = 1.0 - SpecularContribution;
-
-varying float LightIntensity;
-varying vec2  MCposition;
-
-void main()
-{
-    vec3 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex);
-    vec3 tnorm      = normalize(gl_NormalMatrix * gl_Normal);
-    vec3 lightVec   = normalize(LightPosition - ecPosition);
-    vec3 reflectVec = reflect(-lightVec, tnorm);
-    vec3 viewVec    = normalize(-ecPosition);
-    float diffuse   = max(dot(lightVec, tnorm), 0.0);
-    float spec      = 0.0;
-
-    if (diffuse > 0.0)
-    {
-        spec = max(dot(reflectVec, viewVec), 0.0);
-        spec = pow(spec, 16.0);
-    }
-
-    LightIntensity  = DiffuseContribution * diffuse +
-                      SpecularContribution * spec;
-
-    MCposition      = gl_Vertex.xy;
-    gl_Position     = ftransform();
-}
diff --git a/progs/glsl/CH11-bumpmap.frag b/progs/glsl/CH11-bumpmap.frag
new file mode 100644 (file)
index 0000000..063576f
--- /dev/null
@@ -0,0 +1,41 @@
+//
+// Fragment shader for procedural bumps
+//
+// Authors: John Kessenich, Randi Rost
+//
+// Copyright (c) 2002-2006 3Dlabs Inc. Ltd. 
+//
+// See 3Dlabs-License.txt for license information
+//
+
+varying vec3 LightDir;
+varying vec3 EyeDir;
+
+uniform vec3  SurfaceColor;    // = (0.7, 0.6, 0.18)
+uniform float BumpDensity;     // = 16.0
+uniform float BumpSize;        // = 0.15
+uniform float SpecularFactor;  // = 0.5
+
+void main()
+{
+    vec3 litColor;
+    vec2 c = BumpDensity * gl_TexCoord[0].st;
+    vec2 p = fract(c) - vec2(0.5);
+
+    float d, f;
+    d = p.x * p.x + p.y * p.y;
+    f = 1.0 / sqrt(d + 1.0);
+
+    if (d >= BumpSize)
+        { p = vec2(0.0); f = 1.0; }
+
+    vec3 normDelta = vec3(p.x, p.y, 1.0) * f;
+    litColor = SurfaceColor * max(dot(normDelta, LightDir), 0.0);
+    vec3 reflectDir = reflect(LightDir, normDelta);
+    
+    float spec = max(dot(EyeDir, reflectDir), 0.0);
+    spec *= SpecularFactor;
+    litColor = min(litColor + spec, vec3(1.0));
+
+    gl_FragColor = vec4(litColor, 1.0);
+}
diff --git a/progs/glsl/CH11-bumpmap.frag.txt b/progs/glsl/CH11-bumpmap.frag.txt
deleted file mode 100644 (file)
index 063576f..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// Fragment shader for procedural bumps
-//
-// Authors: John Kessenich, Randi Rost
-//
-// Copyright (c) 2002-2006 3Dlabs Inc. Ltd. 
-//
-// See 3Dlabs-License.txt for license information
-//
-
-varying vec3 LightDir;
-varying vec3 EyeDir;
-
-uniform vec3  SurfaceColor;    // = (0.7, 0.6, 0.18)
-uniform float BumpDensity;     // = 16.0
-uniform float BumpSize;        // = 0.15
-uniform float SpecularFactor;  // = 0.5
-
-void main()
-{
-    vec3 litColor;
-    vec2 c = BumpDensity * gl_TexCoord[0].st;
-    vec2 p = fract(c) - vec2(0.5);
-
-    float d, f;
-    d = p.x * p.x + p.y * p.y;
-    f = 1.0 / sqrt(d + 1.0);
-
-    if (d >= BumpSize)
-        { p = vec2(0.0); f = 1.0; }
-
-    vec3 normDelta = vec3(p.x, p.y, 1.0) * f;
-    litColor = SurfaceColor * max(dot(normDelta, LightDir), 0.0);
-    vec3 reflectDir = reflect(LightDir, normDelta);
-    
-    float spec = max(dot(EyeDir, reflectDir), 0.0);
-    spec *= SpecularFactor;
-    litColor = min(litColor + spec, vec3(1.0));
-
-    gl_FragColor = vec4(litColor, 1.0);
-}
diff --git a/progs/glsl/CH11-bumpmap.vert b/progs/glsl/CH11-bumpmap.vert
new file mode 100644 (file)
index 0000000..d3d19f6
--- /dev/null
@@ -0,0 +1,38 @@
+//
+// Vertex shader for procedural bumps
+//
+// Authors: Randi Rost, John Kessenich
+//
+// Copyright (c) 2002-2006 3Dlabs Inc. Ltd. 
+//
+// See 3Dlabs-License.txt for license information
+//
+
+varying vec3 LightDir;
+varying vec3 EyeDir;
+
+uniform vec3 LightPosition;
+
+attribute vec3 Tangent;
+
+void main() 
+{
+    EyeDir         = vec3(gl_ModelViewMatrix * gl_Vertex);
+    gl_Position    = ftransform();
+    gl_TexCoord[0] = gl_MultiTexCoord0;
+
+    vec3 n = normalize(gl_NormalMatrix * gl_Normal);
+    vec3 t = normalize(gl_NormalMatrix * Tangent);
+    vec3 b = cross(n, t);
+
+    vec3 v;
+    v.x = dot(LightPosition, t);
+    v.y = dot(LightPosition, b);
+    v.z = dot(LightPosition, n);
+    LightDir = normalize(v);
+
+    v.x = dot(EyeDir, t);
+    v.y = dot(EyeDir, b);
+    v.z = dot(EyeDir, n);
+    EyeDir = normalize(v);
+}
diff --git a/progs/glsl/CH11-bumpmap.vert.txt b/progs/glsl/CH11-bumpmap.vert.txt
deleted file mode 100644 (file)
index d3d19f6..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// Vertex shader for procedural bumps
-//
-// Authors: Randi Rost, John Kessenich
-//
-// Copyright (c) 2002-2006 3Dlabs Inc. Ltd. 
-//
-// See 3Dlabs-License.txt for license information
-//
-
-varying vec3 LightDir;
-varying vec3 EyeDir;
-
-uniform vec3 LightPosition;
-
-attribute vec3 Tangent;
-
-void main() 
-{
-    EyeDir         = vec3(gl_ModelViewMatrix * gl_Vertex);
-    gl_Position    = ftransform();
-    gl_TexCoord[0] = gl_MultiTexCoord0;
-
-    vec3 n = normalize(gl_NormalMatrix * gl_Normal);
-    vec3 t = normalize(gl_NormalMatrix * Tangent);
-    vec3 b = cross(n, t);
-
-    vec3 v;
-    v.x = dot(LightPosition, t);
-    v.y = dot(LightPosition, b);
-    v.z = dot(LightPosition, n);
-    LightDir = normalize(v);
-
-    v.x = dot(EyeDir, t);
-    v.y = dot(EyeDir, b);
-    v.z = dot(EyeDir, n);
-    EyeDir = normalize(v);
-}
diff --git a/progs/glsl/CH11-toyball.frag b/progs/glsl/CH11-toyball.frag
new file mode 100644 (file)
index 0000000..90ec1c2
--- /dev/null
@@ -0,0 +1,75 @@
+//
+// Fragment shader for procedurally generated toy ball
+//
+// Author: Bill Licea-Kane
+//
+// Copyright (c) 2002-2003 ATI Research 
+//
+// See ATI-License.txt for license information
+//
+
+varying vec4 ECposition;   // surface position in eye coordinates
+varying vec4 ECballCenter; // ball center in eye coordinates
+
+uniform vec4  LightDir;     // light direction, should be normalized
+uniform vec4  HVector;      // reflection vector for infinite light source
+uniform vec4  SpecularColor;
+uniform vec4  Red, Yellow, Blue;
+
+uniform vec4  HalfSpace0;   // half-spaces used to define star pattern
+uniform vec4  HalfSpace1;
+uniform vec4  HalfSpace2;
+uniform vec4  HalfSpace3;
+uniform vec4  HalfSpace4;
+
+uniform float InOrOutInit;  // = -3
+uniform float StripeWidth;  // = 0.3
+uniform float FWidth;       // = 0.005
+
+void main()
+{
+    vec4  normal;              // Analytically computed normal
+    vec4  p;                   // Point in shader space
+    vec4  surfColor;           // Computed color of the surface
+    float intensity;           // Computed light intensity
+    vec4  distance;            // Computed distance values
+    float inorout;             // Counter for computing star pattern
+
+    p.xyz = normalize(ECposition.xyz - ECballCenter.xyz);    // Calculate p
+    p.w   = 1.0;
+
+    inorout = InOrOutInit;     // initialize inorout to -3
+
+    distance[0] = dot(p, HalfSpace0);
+    distance[1] = dot(p, HalfSpace1);
+    distance[2] = dot(p, HalfSpace2);
+    distance[3] = dot(p, HalfSpace3);
+
+    distance = smoothstep(-FWidth, FWidth, distance);
+    inorout += dot(distance, vec4(1.0));
+
+    distance.x = dot(p, HalfSpace4);
+    distance.y = StripeWidth - abs(p.z);
+    distance = smoothstep(-FWidth, FWidth, distance);
+    inorout += distance.x;
+
+    inorout = clamp(inorout, 0.0, 1.0);
+
+    surfColor = mix(Yellow, Red, inorout);
+    surfColor = mix(surfColor, Blue, distance.y);
+
+    // normal = point on surface for sphere at (0,0,0)
+    normal = p;
+
+    // Per fragment diffuse lighting
+    intensity  = 0.2; // ambient
+    intensity += 0.8 * clamp(dot(LightDir, normal), 0.0, 1.0);
+    surfColor *= intensity;
+
+    // Per fragment specular lighting
+    intensity  = clamp(dot(HVector, normal), 0.0, 1.0);
+    intensity  = pow(intensity, SpecularColor.a);
+    surfColor += SpecularColor * intensity;
+
+    gl_FragColor = surfColor;
+}
diff --git a/progs/glsl/CH11-toyball.frag.txt b/progs/glsl/CH11-toyball.frag.txt
deleted file mode 100644 (file)
index 90ec1c2..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-//
-// Fragment shader for procedurally generated toy ball
-//
-// Author: Bill Licea-Kane
-//
-// Copyright (c) 2002-2003 ATI Research 
-//
-// See ATI-License.txt for license information
-//
-
-varying vec4 ECposition;   // surface position in eye coordinates
-varying vec4 ECballCenter; // ball center in eye coordinates
-
-uniform vec4  LightDir;     // light direction, should be normalized
-uniform vec4  HVector;      // reflection vector for infinite light source
-uniform vec4  SpecularColor;
-uniform vec4  Red, Yellow, Blue;
-
-uniform vec4  HalfSpace0;   // half-spaces used to define star pattern
-uniform vec4  HalfSpace1;
-uniform vec4  HalfSpace2;
-uniform vec4  HalfSpace3;
-uniform vec4  HalfSpace4;
-
-uniform float InOrOutInit;  // = -3
-uniform float StripeWidth;  // = 0.3
-uniform float FWidth;       // = 0.005
-
-void main()
-{
-    vec4  normal;              // Analytically computed normal
-    vec4  p;                   // Point in shader space
-    vec4  surfColor;           // Computed color of the surface
-    float intensity;           // Computed light intensity
-    vec4  distance;            // Computed distance values
-    float inorout;             // Counter for computing star pattern
-
-    p.xyz = normalize(ECposition.xyz - ECballCenter.xyz);    // Calculate p
-    p.w   = 1.0;
-
-    inorout = InOrOutInit;     // initialize inorout to -3
-
-    distance[0] = dot(p, HalfSpace0);
-    distance[1] = dot(p, HalfSpace1);
-    distance[2] = dot(p, HalfSpace2);
-    distance[3] = dot(p, HalfSpace3);
-
-    distance = smoothstep(-FWidth, FWidth, distance);
-    inorout += dot(distance, vec4(1.0));
-
-    distance.x = dot(p, HalfSpace4);
-    distance.y = StripeWidth - abs(p.z);
-    distance = smoothstep(-FWidth, FWidth, distance);
-    inorout += distance.x;
-
-    inorout = clamp(inorout, 0.0, 1.0);
-
-    surfColor = mix(Yellow, Red, inorout);
-    surfColor = mix(surfColor, Blue, distance.y);
-
-    // normal = point on surface for sphere at (0,0,0)
-    normal = p;
-
-    // Per fragment diffuse lighting
-    intensity  = 0.2; // ambient
-    intensity += 0.8 * clamp(dot(LightDir, normal), 0.0, 1.0);
-    surfColor *= intensity;
-
-    // Per fragment specular lighting
-    intensity  = clamp(dot(HVector, normal), 0.0, 1.0);
-    intensity  = pow(intensity, SpecularColor.a);
-    surfColor += SpecularColor * intensity;
-
-    gl_FragColor = surfColor;
-}
diff --git a/progs/glsl/CH11-toyball.vert b/progs/glsl/CH11-toyball.vert
new file mode 100644 (file)
index 0000000..b7da3ac
--- /dev/null
@@ -0,0 +1,24 @@
+//
+// Fragment shader for procedurally generated toy ball
+//
+// Author: Bill Licea-Kane
+//
+// Copyright (c) 2002-2003 ATI Research 
+//
+// See ATI-License.txt for license information
+//
+
+varying vec4 ECposition;   // surface position in eye coordinates
+varying vec4 ECballCenter; // ball center in eye coordinates
+uniform vec4 BallCenter;   // ball center in modelling coordinates
+
+void main()
+{ 
+//orig:    ECposition   = gl_ModelViewMatrix * gl_Vertex;
+
+    ECposition = gl_TextureMatrix[0] * gl_Vertex;
+    ECposition = gl_ModelViewMatrix * ECposition;
+
+    ECballCenter = gl_ModelViewMatrix * BallCenter;
+    gl_Position  = ftransform();
+}
diff --git a/progs/glsl/CH11-toyball.vert.txt b/progs/glsl/CH11-toyball.vert.txt
deleted file mode 100644 (file)
index b7da3ac..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-//
-// Fragment shader for procedurally generated toy ball
-//
-// Author: Bill Licea-Kane
-//
-// Copyright (c) 2002-2003 ATI Research 
-//
-// See ATI-License.txt for license information
-//
-
-varying vec4 ECposition;   // surface position in eye coordinates
-varying vec4 ECballCenter; // ball center in eye coordinates
-uniform vec4 BallCenter;   // ball center in modelling coordinates
-
-void main()
-{ 
-//orig:    ECposition   = gl_ModelViewMatrix * gl_Vertex;
-
-    ECposition = gl_TextureMatrix[0] * gl_Vertex;
-    ECposition = gl_ModelViewMatrix * ECposition;
-
-    ECballCenter = gl_ModelViewMatrix * BallCenter;
-    gl_Position  = ftransform();
-}
diff --git a/progs/glsl/CH18-mandel.frag b/progs/glsl/CH18-mandel.frag
new file mode 100644 (file)
index 0000000..a472d81
--- /dev/null
@@ -0,0 +1,55 @@
+//
+// Fragment shader for drawing the Mandelbrot set
+//
+// Authors: Dave Baldwin, Steve Koren, Randi Rost
+//          based on a shader by Michael Rivero
+//
+// Copyright (c) 2002-2005: 3Dlabs, Inc.
+//
+// See 3Dlabs-License.txt for license information
+//
+
+varying vec3  Position;
+varying float LightIntensity;
+
+uniform float MaxIterations;
+uniform float Zoom;
+uniform float Xcenter;
+uniform float Ycenter;
+uniform vec3  InnerColor;
+uniform vec3  OuterColor1;
+uniform vec3  OuterColor2;
+
+void main()
+{
+    float   real  = Position.x * Zoom + Xcenter;
+    float   imag  = Position.y * Zoom + Ycenter;
+    float   Creal = real;   // Change this line...
+    float   Cimag = imag;   // ...and this one to get a Julia set
+
+    float r2 = 0.0;
+    float iter;
+
+//    for (iter = 0.0; iter < MaxIterations && r2 < 4.0; ++iter)
+    for (iter = 0.0; iter < 12 && r2 < 4.0; ++iter)
+    {
+        float tempreal = real;
+
+        real = (tempreal * tempreal) - (imag * imag) + Creal;
+        imag = 2.0 * tempreal * imag + Cimag;
+        r2   = (real * real) + (imag * imag);
+    }
+
+    // Base the color on the number of iterations
+
+    vec3 color;
+
+    if (r2 < 4.0)
+        color = InnerColor;
+    else
+        color = mix(OuterColor1, OuterColor2, fract(iter * 0.05));
+
+    color *= LightIntensity;
+
+    gl_FragColor = vec4(color, 1.0);
+}
diff --git a/progs/glsl/CH18-mandel.frag.txt b/progs/glsl/CH18-mandel.frag.txt
deleted file mode 100644 (file)
index a472d81..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-//
-// Fragment shader for drawing the Mandelbrot set
-//
-// Authors: Dave Baldwin, Steve Koren, Randi Rost
-//          based on a shader by Michael Rivero
-//
-// Copyright (c) 2002-2005: 3Dlabs, Inc.
-//
-// See 3Dlabs-License.txt for license information
-//
-
-varying vec3  Position;
-varying float LightIntensity;
-
-uniform float MaxIterations;
-uniform float Zoom;
-uniform float Xcenter;
-uniform float Ycenter;
-uniform vec3  InnerColor;
-uniform vec3  OuterColor1;
-uniform vec3  OuterColor2;
-
-void main()
-{
-    float   real  = Position.x * Zoom + Xcenter;
-    float   imag  = Position.y * Zoom + Ycenter;
-    float   Creal = real;   // Change this line...
-    float   Cimag = imag;   // ...and this one to get a Julia set
-
-    float r2 = 0.0;
-    float iter;
-
-//    for (iter = 0.0; iter < MaxIterations && r2 < 4.0; ++iter)
-    for (iter = 0.0; iter < 12 && r2 < 4.0; ++iter)
-    {
-        float tempreal = real;
-
-        real = (tempreal * tempreal) - (imag * imag) + Creal;
-        imag = 2.0 * tempreal * imag + Cimag;
-        r2   = (real * real) + (imag * imag);
-    }
-
-    // Base the color on the number of iterations
-
-    vec3 color;
-
-    if (r2 < 4.0)
-        color = InnerColor;
-    else
-        color = mix(OuterColor1, OuterColor2, fract(iter * 0.05));
-
-    color *= LightIntensity;
-
-    gl_FragColor = vec4(color, 1.0);
-}
diff --git a/progs/glsl/CH18-mandel.vert b/progs/glsl/CH18-mandel.vert
new file mode 100644 (file)
index 0000000..c4ca664
--- /dev/null
@@ -0,0 +1,35 @@
+//
+// Vertex shader for drawing the Mandelbrot set
+//
+// Authors: Dave Baldwin, Steve Koren, Randi Rost
+//          based on a shader by Michael Rivero
+//
+// Copyright (c) 2002-2005: 3Dlabs, Inc.
+//
+// See 3Dlabs-License.txt for license information
+//
+
+uniform vec3 LightPosition;
+uniform float SpecularContribution;
+uniform float DiffuseContribution;
+uniform float Shininess;
+
+varying float LightIntensity;
+varying vec3  Position;
+
+void main()
+{
+    vec3 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex);
+    vec3 tnorm      = normalize(gl_NormalMatrix * gl_Normal);
+    vec3 lightVec   = normalize(LightPosition - ecPosition);
+    vec3 reflectVec = reflect(-lightVec, tnorm);
+    vec3 viewVec    = normalize(-ecPosition);
+    float spec      = max(dot(reflectVec, viewVec), 0.0);
+    spec            = pow(spec, Shininess);
+    LightIntensity  = DiffuseContribution * 
+                          max(dot(lightVec, tnorm), 0.0) +
+                          SpecularContribution * spec;
+    Position        = vec3(gl_MultiTexCoord0 - 0.5) * 5.0;
+    gl_Position     = ftransform();
+
+}
\ No newline at end of file
diff --git a/progs/glsl/CH18-mandel.vert.txt b/progs/glsl/CH18-mandel.vert.txt
deleted file mode 100644 (file)
index c4ca664..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// Vertex shader for drawing the Mandelbrot set
-//
-// Authors: Dave Baldwin, Steve Koren, Randi Rost
-//          based on a shader by Michael Rivero
-//
-// Copyright (c) 2002-2005: 3Dlabs, Inc.
-//
-// See 3Dlabs-License.txt for license information
-//
-
-uniform vec3 LightPosition;
-uniform float SpecularContribution;
-uniform float DiffuseContribution;
-uniform float Shininess;
-
-varying float LightIntensity;
-varying vec3  Position;
-
-void main()
-{
-    vec3 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex);
-    vec3 tnorm      = normalize(gl_NormalMatrix * gl_Normal);
-    vec3 lightVec   = normalize(LightPosition - ecPosition);
-    vec3 reflectVec = reflect(-lightVec, tnorm);
-    vec3 viewVec    = normalize(-ecPosition);
-    float spec      = max(dot(reflectVec, viewVec), 0.0);
-    spec            = pow(spec, Shininess);
-    LightIntensity  = DiffuseContribution * 
-                          max(dot(lightVec, tnorm), 0.0) +
-                          SpecularContribution * spec;
-    Position        = vec3(gl_MultiTexCoord0 - 0.5) * 5.0;
-    gl_Position     = ftransform();
-
-}
\ No newline at end of file
index 9c1d3f8126bc9ddcf11b32d4ebd4a05562ed3418..9999d6c08ab2309ece69ee0912770326c47b509a 100644 (file)
@@ -7,15 +7,24 @@ INCDIR = $(TOP)/include
 
 LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
 
+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
+
 PROGS = \
+       bitmap \
        brick \
        bump \
+       convolutions \
        deriv \
        mandelbrot \
+       multitex \
        noise \
-       toyball \
+       points \
+       pointcoord \
        texdemo1 \
-        convolutions
+       toyball \
+       twoside \
+       trirast \
+       texdemo1 
 
 
 ##### RULES #####
@@ -26,7 +35,7 @@ PROGS = \
 
 # make executable from .c file:
 .c: $(LIB_DEP)
-       $(APP_CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@
+       $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
 
 
 ##### TARGETS #####
@@ -40,6 +49,7 @@ default: $(PROGS)
 extfuncs.h:  $(TOP)/progs/util/extfuncs.h
        cp $< .
 
+
 readtex.c: $(TOP)/progs/util/readtex.c
        cp $< .
 
@@ -49,28 +59,118 @@ readtex.h: $(TOP)/progs/util/readtex.h
 readtex.o: readtex.c readtex.h
        $(APP_CC) -c -I$(INCDIR) $(CFLAGS) readtex.c
 
-brick.c: extfuncs.h
 
-bump.c: extfuncs.h
+shaderutil.c: $(TOP)/progs/util/shaderutil.c
+       cp $< .
 
-mandelbrot.c: extfuncs.h
+shaderutil.h: $(TOP)/progs/util/shaderutil.h
+       cp $< .
 
-toyball.c: extfuncs.h
+shaderutil.o: shaderutil.c shaderutil.h
+       $(APP_CC) -c -I$(INCDIR) $(CFLAGS) shaderutil.c
 
-texdemo1: texdemo1.o readtex.o
-       $(APP_CC) -I$(INCDIR) $(CFLAGS) texdemo1.o readtex.o $(APP_LIB_DEPS) -o $@
 
-texdemo1.o: texdemo1.c readtex.h extfuncs.h
-       $(APP_CC) -c -I$(INCDIR) $(CFLAGS) texdemo1.c
 
-convolutions: convolutions.o readtex.o
-       $(APP_CC) -I$(INCDIR) $(CFLAGS) convolutions.o readtex.o $(APP_LIB_DEPS) -o $@
+bitmap.o: bitmap.c extfuncs.h shaderutil.h
+       $(APP_CC) -c -I$(INCDIR) $(CFLAGS) bitmap.c
+
+bitmap: bitmap.o shaderutil.o
+       $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) bitmap.o shaderutil.o $(LIBS) -o $@
+
+
+brick.o: brick.c extfuncs.h shaderutil.h
+       $(APP_CC) -c -I$(INCDIR) $(CFLAGS) brick.c
+
+brick: brick.o shaderutil.o
+       $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) brick.o shaderutil.o $(LIBS) -o $@
+
+
+bump.o: bump.c extfuncs.h shaderutil.h
+       $(APP_CC) -c -I$(INCDIR) $(CFLAGS) bump.c
+
+bump: bump.o shaderutil.o
+       $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) bump.o shaderutil.o $(LIBS) -o $@
+
 
 convolutions.o: convolutions.c readtex.h
        $(APP_CC) -c -I$(INCDIR) $(CFLAGS) convolutions.c
 
+convolutions: convolutions.o readtex.o
+       $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) convolutions.o readtex.o $(LIBS) -o $@
+
+
+deriv.o: deriv.c extfuncs.h shaderutil.h
+       $(APP_CC) -c -I$(INCDIR) $(CFLAGS) deriv.c
+
+deriv: deriv.o shaderutil.o
+       $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) deriv.o shaderutil.o $(LIBS) -o $@
+
+
+mandelbrot.o: mandelbrot.c extfuncs.h shaderutil.h
+       $(APP_CC) -c -I$(INCDIR) $(CFLAGS) mandelbrot.c
+
+mandelbrot: mandelbrot.o shaderutil.o
+       $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) mandelbrot.o shaderutil.o $(LIBS) -o $@
+
+multitex.o: multitex.c extfuncs.h readtex.h shaderutil.h
+       $(APP_CC) -c -I$(INCDIR) $(CFLAGS) multitex.c
+
+multitex: multitex.o readtex.o shaderutil.o
+       $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) multitex.o readtex.o shaderutil.o $(LIBS) -o $@
+
+
+noise.o: noise.c extfuncs.h shaderutil.h
+       $(APP_CC) -c -I$(INCDIR) $(CFLAGS) noise.c
+
+noise: noise.o shaderutil.o
+       $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) noise.o shaderutil.o $(LIBS) -o $@
+
+
+points.o: points.c extfuncs.h shaderutil.h
+       $(APP_CC) -c -I$(INCDIR) $(CFLAGS) points.c
+
+points: points.o shaderutil.o
+       $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) points.o shaderutil.o $(LIBS) -o $@
+
+
+pointcoord.o: pointcoord.c readtex.h extfuncs.h shaderutil.h
+       $(APP_CC) -c -I$(INCDIR) $(CFLAGS) pointcoord.c
+
+pointcoord: pointcoord.o readtex.o shaderutil.o
+       $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) pointcoord.o readtex.o shaderutil.o $(LIBS) -o $@
+
+
+texdemo1.o: texdemo1.c readtex.h extfuncs.h shaderutil.h
+       $(APP_CC) -c -I$(INCDIR) $(CFLAGS) texdemo1.c
+
+texdemo1: texdemo1.o readtex.o shaderutil.o
+       $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) texdemo1.o readtex.o shaderutil.o $(LIBS) -o $@
+
+
+toyball.o: toyball.c extfuncs.h shaderutil.h
+       $(APP_CC) -c -I$(INCDIR) $(CFLAGS) toyball.c
+
+toyball: toyball.o shaderutil.o
+       $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) toyball.o shaderutil.o $(LIBS) -o $@
+
+
+twoside.o: twoside.c extfuncs.h shaderutil.h
+       $(APP_CC) -c -I$(INCDIR) $(CFLAGS) twoside.c
+
+twoside: twoside.o shaderutil.o
+       $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) twoside.o shaderutil.o $(LIBS) -o $@
+
+
+trirast.o: trirast.c extfuncs.h shaderutil.h
+       $(APP_CC) -c -I$(INCDIR) $(CFLAGS) trirast.c
+
+trirast: trirast.o shaderutil.o
+       $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) trirast.o shaderutil.o $(LIBS) -o $@
+
+
 
 clean:
        -rm -f $(PROGS)
        -rm -f *.o *~
        -rm -f extfuncs.h
+       -rm -f shaderutil.*
diff --git a/progs/glsl/bitmap.c b/progs/glsl/bitmap.c
new file mode 100644 (file)
index 0000000..d488ec6
--- /dev/null
@@ -0,0 +1,323 @@
+/**
+ * Implement glRasterPos + glBitmap with textures + shaders.
+ * Brian Paul
+ * 14 May 2007
+ */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/gl.h>
+#include <GL/glut.h>
+#include <GL/glext.h>
+#include "extfuncs.h"
+#include "shaderutil.h"
+
+
+static GLuint FragShader;
+static GLuint VertShader;
+static GLuint Program;
+
+static GLint Win = 0;
+static GLint WinWidth = 500, WinHeight = 500;
+static GLboolean Anim = GL_TRUE;
+static GLboolean Bitmap = GL_FALSE;
+static GLfloat Xrot = 20.0f, Yrot = 70.0f;
+static GLint uTex, uScale;
+static GLuint Textures[2];
+
+#define TEX_WIDTH 16
+#define TEX_HEIGHT 8
+
+
+static void
+BitmapText(const char *s)
+{
+   while (*s) {
+      glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int) *s);
+      s++;
+   }
+}
+
+
+static void
+Redisplay(void)
+{
+   static const GLfloat px[3] = { 1.2, 0, 0};
+   static const GLfloat nx[3] = {-1.2, 0, 0};
+
+   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+   glPushMatrix();
+   glRotatef(Xrot, 1.0f, 0.0f, 0.0f);
+   glRotatef(Yrot, 0.0f, 1.0f, 0.0f);
+
+   glEnable(GL_LIGHTING);
+
+   glPushMatrix();
+   glScalef(0.5, 0.5, 0.5);
+   glutSolidDodecahedron();
+   glPopMatrix();
+
+   glDisable(GL_LIGHTING);
+
+   glColor3f(0, 1, 0);
+   glBegin(GL_LINES);
+   glVertex3f(-1, 0, 0);
+   glVertex3f( 1, 0, 0);
+   glEnd();
+
+   glColor3f(1, 1, 0);
+
+   if (Bitmap) {
+      glRasterPos3fv(px);
+      BitmapText("+X");
+      glRasterPos3fv(nx);
+      BitmapText("-X");
+   }
+   else {
+      glUseProgram_func(Program);
+
+      /* vertex positions (deltas) depend on texture size and window size */
+      if (uScale != -1) {
+         glUniform2f_func(uScale,
+                          2.0 * TEX_WIDTH / WinWidth,
+                          2.0 * TEX_HEIGHT / WinHeight);
+      }
+
+      /* draw +X */
+      glBindTexture(GL_TEXTURE_2D, Textures[0]);
+      glBegin(GL_QUADS);
+      glTexCoord2f(0, 0);  glVertex3fv(px);
+      glTexCoord2f(1, 0);  glVertex3fv(px);
+      glTexCoord2f(1, 1);  glVertex3fv(px);
+      glTexCoord2f(0, 1);  glVertex3fv(px);
+      glEnd();
+
+      /* draw -X */
+      glBindTexture(GL_TEXTURE_2D, Textures[1]);
+      glBegin(GL_QUADS);
+      glTexCoord2f(0, 0);  glVertex3fv(nx);
+      glTexCoord2f(1, 0);  glVertex3fv(nx);
+      glTexCoord2f(1, 1);  glVertex3fv(nx);
+      glTexCoord2f(0, 1);  glVertex3fv(nx);
+      glEnd();
+
+      glUseProgram_func(0);
+   }
+
+   glPopMatrix();
+
+   glutSwapBuffers();
+}
+
+
+static void
+Idle(void)
+{
+   Yrot = glutGet(GLUT_ELAPSED_TIME) * 0.01;
+   glutPostRedisplay();
+}
+
+
+static void
+Reshape(int width, int height)
+{
+   WinWidth = width;
+   WinHeight = height;
+   glViewport(0, 0, width, height);
+   glMatrixMode(GL_PROJECTION);
+   glLoadIdentity();
+   glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
+   glMatrixMode(GL_MODELVIEW);
+   glLoadIdentity();
+   glTranslatef(0.0f, 0.0f, -10.0f);
+}
+
+
+static void
+Key(unsigned char key, int x, int y)
+{
+  (void) x;
+  (void) y;
+
+   switch(key) {
+   case ' ':
+   case 'a':
+      Anim = !Anim;
+      if (Anim)
+         glutIdleFunc(Idle);
+      else
+         glutIdleFunc(NULL);
+      break;
+   case 'b':
+      Bitmap = !Bitmap;
+      if (Bitmap)
+         printf("Using glBitmap\n");
+      else
+         printf("Using billboard texture\n");
+      break;
+   case 27:
+      glDeleteShader_func(FragShader);
+      glDeleteShader_func(VertShader);
+      glDeleteProgram_func(Program);
+      glutDestroyWindow(Win);
+      exit(0);
+   }
+   glutPostRedisplay();
+}
+
+
+static void
+SpecialKey(int key, int x, int y)
+{
+   const GLfloat step = 0.125f;
+   switch(key) {
+   case GLUT_KEY_UP:
+      Xrot -= step;
+      break;
+   case GLUT_KEY_DOWN:
+      Xrot += step;
+      break;
+   case GLUT_KEY_LEFT:
+      Yrot -= step;
+      break;
+   case GLUT_KEY_RIGHT:
+      Yrot += step;
+      break;
+   }
+   /*printf("Xrot: %f  Yrot: %f\n", Xrot, Yrot);*/
+   glutPostRedisplay();
+}
+
+
+static void
+MakeTexImage(const char *p, GLuint texobj)
+{
+   GLubyte image[TEX_HEIGHT][TEX_WIDTH];
+   GLuint i, j, k;
+
+   for (i = 0; i < TEX_HEIGHT; i++) {
+      for (j = 0; j < TEX_WIDTH; j++) {
+         k = i * TEX_WIDTH + j;
+         if (p[k] == ' ') {
+            image[i][j] = 0;
+         }
+         else {
+            image[i][j] = 255;
+         }
+      }
+   }
+
+   glBindTexture(GL_TEXTURE_2D, texobj);
+   glTexImage2D(GL_TEXTURE_2D, 0, GL_INTENSITY, TEX_WIDTH, TEX_HEIGHT, 0,
+                GL_RED, GL_UNSIGNED_BYTE, image);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+}
+
+
+static void
+MakeBitmapTextures(void)
+{
+   const char *px =
+      "        X     X "
+      "   X     X   X  "
+      "   X      X X   "
+      " XXXXX     X    "
+      "   X      X X   "
+      "   X     X   X  "
+      "        X     X "
+      "        X     X ";
+   const char *nx =
+      "        X     X "
+      "         X   X  "
+      "          X X   "
+      " XXXXX     X    "
+      "          X X   "
+      "         X   X  "
+      "        X     X "
+      "        X     X ";
+   glGenTextures(2, Textures);
+   MakeTexImage(px, Textures[0]);
+   MakeTexImage(nx, Textures[1]);
+}
+
+
+static void
+Init(void)
+{
+   /* Fragment shader: modulate raster color by texture, discard fragments
+    * with alpha < 1.0
+    */
+   static const char *fragShaderText =
+      "uniform sampler2D tex2d; \n"
+      "void main() {\n"
+      "   vec4 c = texture2D(tex2d, gl_TexCoord[0].xy); \n"
+      "   if (c.w < 1.0) \n"
+      "      discard; \n"
+      "   gl_FragColor = c * gl_Color; \n"
+      "}\n";
+   /* Vertex shader: compute new vertex position based on incoming vertex pos,
+    * texcoords and special scale factor.
+    */
+   static const char *vertShaderText =
+      "uniform vec2 scale; \n"
+      "void main() {\n"
+      "   vec4 p = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
+      "   gl_Position.xy = p.xy + gl_MultiTexCoord0.xy * scale * p.w; \n"
+      "   gl_Position.zw = p.zw; \n"
+      "   gl_TexCoord[0] = gl_MultiTexCoord0; \n"
+      "   gl_FrontColor = gl_Color; \n"
+      "}\n";
+
+   if (!ShadersSupported())
+      exit(1);
+
+   GetExtensionFuncs();
+
+   VertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
+   FragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
+   Program = LinkShaders(VertShader, FragShader);
+
+   glUseProgram_func(Program);
+
+   uScale = glGetUniformLocation_func(Program, "scale");
+   uTex = glGetUniformLocation_func(Program, "tex2d");
+   if (uTex != -1) {
+      glUniform1i_func(uTex, 0);  /* tex unit 0 */
+   }
+
+   glUseProgram_func(0);
+
+   glClearColor(0.3f, 0.3f, 0.3f, 0.0f);
+   glEnable(GL_DEPTH_TEST);
+   glEnable(GL_NORMALIZE);
+   glEnable(GL_LIGHT0);
+
+   MakeBitmapTextures();
+}
+
+
+int
+main(int argc, char *argv[])
+{
+   glutInit(&argc, argv);
+   glutInitWindowSize(WinWidth, WinHeight);
+   glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+   Win = glutCreateWindow(argv[0]);
+   glutReshapeFunc(Reshape);
+   glutKeyboardFunc(Key);
+   glutSpecialFunc(SpecialKey);
+   glutDisplayFunc(Redisplay);
+   if (Anim)
+      glutIdleFunc(Idle);
+   Init();
+   glutMainLoop();
+   return 0;
+}
+
+
index 522698b5d433886635ed08598dd52a7ba33d540e..526ef0e2e3624f3fe3a40a5616318099f7e9659a 100644 (file)
 #include <GL/glut.h>
 #include <GL/glext.h>
 #include "extfuncs.h"
+#include "shaderutil.h"
 
 
-static char *FragProgFile = "CH06-brick.frag.txt";
-static char *VertProgFile = "CH06-brick.vert.txt";
+static char *FragProgFile = "CH06-brick.frag";
+static char *VertProgFile = "CH06-brick.vert";
 
 /* program/shader objects */
 static GLuint fragShader;
 static GLuint vertShader;
 static GLuint program;
 
-
-struct uniform_info {
-   const char *name;
-   GLuint size;
-   GLint location;
-   GLfloat value[4];
-};
-
 static struct uniform_info Uniforms[] = {
    /* vert */
-   { "LightPosition",     3, -1, { 0.1, 0.1, 9.0, 0} },
+   { "LightPosition",     3, GL_FLOAT, { 0.1, 0.1, 9.0, 0}, -1 },
    /* frag */
-   { "BrickColor",        3, -1, { 0.8, 0.2, 0.2, 0 } },
-   { "MortarColor",       3, -1, { 0.6, 0.6, 0.6, 0 } },
-   { "BrickSize",         2, -1, { 1.0, 0.3, 0, 0 } },
-   { "BrickPct",          2, -1, { 0.9, 0.8, 0, 0 } },
-   { NULL, 0, 0, { 0, 0, 0, 0 } }
+   { "BrickColor",        3, GL_FLOAT, { 0.8, 0.2, 0.2, 0 }, -1 },
+   { "MortarColor",       3, GL_FLOAT, { 0.6, 0.6, 0.6, 0 }, -1 },
+   { "BrickSize",         2, GL_FLOAT, { 1.0, 0.3, 0, 0 }, -1 },
+   { "BrickPct",          2, GL_FLOAT, { 0.9, 0.8, 0, 0 }, -1 },
+   END_OF_UNIFORMS
 };
 
 static GLint win = 0;
@@ -145,122 +138,21 @@ SpecialKey(int key, int x, int y)
 
 
 
-static void
-LoadAndCompileShader(GLuint shader, const char *text)
-{
-   GLint stat;
-
-   glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
-
-   glCompileShader_func(shader);
-
-   glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
-   if (!stat) {
-      GLchar log[1000];
-      GLsizei len;
-      glGetShaderInfoLog_func(shader, 1000, &len, log);
-      fprintf(stderr, "brick: problem compiling shader: %s\n", log);
-      exit(1);
-   }
-   else {
-      printf("Shader compiled OK\n");
-   }
-}
-
-
-/**
- * Read a shader from a file.
- */
-static void
-ReadShader(GLuint shader, const char *filename)
-{
-   const int max = 100*1000;
-   int n;
-   char *buffer = (char*) malloc(max);
-   FILE *f = fopen(filename, "r");
-   if (!f) {
-      fprintf(stderr, "brick: Unable to open shader file %s\n", filename);
-      exit(1);
-   }
-
-   n = fread(buffer, 1, max, f);
-   printf("brick: read %d bytes from shader file %s\n", n, filename);
-   if (n > 0) {
-      buffer[n] = 0;
-      LoadAndCompileShader(shader, buffer);
-   }
-
-   fclose(f);
-   free(buffer);
-}
-
-
-static void
-CheckLink(GLuint prog)
-{
-   GLint stat;
-   glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
-   if (!stat) {
-      GLchar log[1000];
-      GLsizei len;
-      glGetProgramInfoLog_func(prog, 1000, &len, log);
-      fprintf(stderr, "Linker error:\n%s\n", log);
-   }
-   else {
-      fprintf(stderr, "Link success!\n");
-   }
-}
-
-
 static void
 Init(void)
 {
-   const char *version;
-   GLint i;
-
-   version = (const char *) glGetString(GL_VERSION);
-   if (version[0] != '2' || version[1] != '.') {
-      printf("Warning: this program expects OpenGL 2.0\n");
-      /*exit(1);*/
-   }
+   if (!ShadersSupported())
+      exit(1);
 
    GetExtensionFuncs();
 
-   vertShader = glCreateShader_func(GL_VERTEX_SHADER);
-   ReadShader(vertShader, VertProgFile);
-
-   fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
-   ReadShader(fragShader, FragProgFile);
+   vertShader = CompileShaderFile(GL_VERTEX_SHADER, VertProgFile);
+   fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
+   program = LinkShaders(vertShader, fragShader);
 
-   program = glCreateProgram_func();
-   glAttachShader_func(program, fragShader);
-   glAttachShader_func(program, vertShader);
-   glLinkProgram_func(program);
-   CheckLink(program);
    glUseProgram_func(program);
 
-   for (i = 0; Uniforms[i].name; i++) {
-      Uniforms[i].location
-         = glGetUniformLocation_func(program, Uniforms[i].name);
-      printf("Uniform %s location: %d\n", Uniforms[i].name,
-             Uniforms[i].location);
-      switch (Uniforms[i].size) {
-      case 1:
-         glUniform1fv_func(Uniforms[i].location, 1, Uniforms[i].value);
-         break;
-      case 2:
-         glUniform2fv_func(Uniforms[i].location, 1, Uniforms[i].value);
-         break;
-      case 3:
-         glUniform3fv_func(Uniforms[i].location, 1, Uniforms[i].value);
-         break;
-      case 4:
-         glUniform4fv_func(Uniforms[i].location, 1, Uniforms[i].value);
-         break;
-      default:
-         abort();
-      }
-   }
+   InitUniforms(program, Uniforms);
 
    assert(glGetError() == 0);
 
index a6846acf7e4f0832fc7cdefebab321e92716ac34..a2e0916861cdd6e6d39e44a0fe609761353b10cd 100644 (file)
 #include <GL/glu.h>
 #include <GL/glext.h>
 #include "extfuncs.h"
+#include "shaderutil.h"
 
 
-static char *FragProgFile = "CH11-bumpmap.frag.txt";
-static char *VertProgFile = "CH11-bumpmap.vert.txt";
+static char *FragProgFile = "CH11-bumpmap.frag";
+static char *VertProgFile = "CH11-bumpmap.vert";
 
 /* program/shader objects */
 static GLuint fragShader;
@@ -24,20 +25,13 @@ static GLuint vertShader;
 static GLuint program;
 
 
-struct uniform_info {
-   const char *name;
-   GLuint size;
-   GLint location;
-   GLfloat value[4];
-};
-
 static struct uniform_info Uniforms[] = {
-   { "LightPosition",       3, -1, { 0.57737, 0.57735, 0.57735, 0.0 } },
-   { "SurfaceColor",        3, -1, { 0.8, 0.8, 0.2, 0 } },
-   { "BumpDensity",         1, -1, { 10.0, 0, 0, 0 } },
-   { "BumpSize",            1, -1, { 0.125, 0, 0, 0 } },
-   { "SpecularFactor",      1, -1, { 0.5, 0, 0, 0 } },
-   { NULL, 0, 0, { 0, 0, 0, 0 } }
+   { "LightPosition",    3, GL_FLOAT, { 0.57737, 0.57735, 0.57735, 0.0 }, -1 },
+   { "SurfaceColor",     3, GL_FLOAT, { 0.8, 0.8, 0.2, 0 }, -1 },
+   { "BumpDensity",      1, GL_FLOAT, { 10.0, 0, 0, 0 }, -1 },
+   { "BumpSize",         1, GL_FLOAT, { 0.125, 0, 0, 0 }, -1 },
+   { "SpecularFactor",   1, GL_FLOAT, { 0.5, 0, 0, 0 }, -1 },
+   END_OF_UNIFORMS
 };
 
 static GLint win = 0;
@@ -232,100 +226,18 @@ SpecialKey(int key, int x, int y)
 }
 
 
-
-static void
-LoadAndCompileShader(GLuint shader, const char *text)
-{
-   GLint stat;
-
-   glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
-
-   glCompileShader_func(shader);
-
-   glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
-   if (!stat) {
-      GLchar log[1000];
-      GLsizei len;
-      glGetShaderInfoLog_func(shader, 1000, &len, log);
-      fprintf(stderr, "brick: problem compiling shader: %s\n", log);
-      exit(1);
-   }
-   else {
-      printf("Shader compiled OK\n");
-   }
-}
-
-
-/**
- * Read a shader from a file.
- */
-static void
-ReadShader(GLuint shader, const char *filename)
-{
-   const int max = 100*1000;
-   int n;
-   char *buffer = (char*) malloc(max);
-   FILE *f = fopen(filename, "r");
-   if (!f) {
-      fprintf(stderr, "brick: Unable to open shader file %s\n", filename);
-      exit(1);
-   }
-
-   n = fread(buffer, 1, max, f);
-   printf("brick: read %d bytes from shader file %s\n", n, filename);
-   if (n > 0) {
-      buffer[n] = 0;
-      LoadAndCompileShader(shader, buffer);
-   }
-
-   fclose(f);
-   free(buffer);
-}
-
-
-static void
-CheckLink(GLuint prog)
-{
-   GLint stat;
-   glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
-   if (!stat) {
-      GLchar log[1000];
-      GLsizei len;
-      glGetProgramInfoLog_func(prog, 1000, &len, log);
-      fprintf(stderr, "Linker error:\n%s\n", log);
-   }
-   else {
-      fprintf(stderr, "Link success!\n");
-   }
-}
-
-
 static void
 Init(void)
 {
-   const char *version;
-   GLint i;
-
-   version = (const char *) glGetString(GL_VERSION);
-   if (version[0] != '2' || version[1] != '.') {
-      printf("Warning: this program expects OpenGL 2.0\n");
-      /*exit(1);*/
-   }
-   printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
+   if (!ShadersSupported())
+      exit(1);
 
    GetExtensionFuncs();
 
-   vertShader = glCreateShader_func(GL_VERTEX_SHADER);
-   ReadShader(vertShader, VertProgFile);
-
-   fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
-   ReadShader(fragShader, FragProgFile);
+   vertShader = CompileShaderFile(GL_VERTEX_SHADER, VertProgFile);
+   fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
+   program = LinkShaders(vertShader, fragShader);
 
-   program = glCreateProgram_func();
-   glAttachShader_func(program, fragShader);
-   glAttachShader_func(program, vertShader);
-   glLinkProgram_func(program);
-   CheckLink(program);
    glUseProgram_func(program);
 
    assert(glIsProgram_func(program));
@@ -336,28 +248,7 @@ Init(void)
 
    CheckError(__LINE__);
 
-   for (i = 0; Uniforms[i].name; i++) {
-      Uniforms[i].location
-         = glGetUniformLocation_func(program, Uniforms[i].name);
-      printf("Uniform %s location: %d\n", Uniforms[i].name,
-             Uniforms[i].location);
-      switch (Uniforms[i].size) {
-      case 1:
-         glUniform1fv_func(Uniforms[i].location, 1, Uniforms[i].value);
-         break;
-      case 2:
-         glUniform2fv_func(Uniforms[i].location, 1, Uniforms[i].value);
-         break;
-      case 3:
-         glUniform3fv_func(Uniforms[i].location, 1, Uniforms[i].value);
-         break;
-      case 4:
-         glUniform4fv_func(Uniforms[i].location, 1, Uniforms[i].value);
-         break;
-      default:
-         abort();
-      }
-   }
+   InitUniforms(program, Uniforms);
 
    CheckError(__LINE__);
 
index 9b9ee532453ff52a92afea68cab5851fc9ca66cc..a25dad5ba9279538d0d8836d066c79a000325f18 100644 (file)
@@ -1,3 +1,10 @@
+/**
+ * Convolution with GLSL.
+ * Note: uses GL_ARB_shader_objects, GL_ARB_vertex_shader, GL_ARB_fragment_shader,
+ * not the OpenGL 2.0 shader API.
+ * Author: Zack Rusin
+ */
+
 #define GL_GLEXT_PROTOTYPES
 #include "readtex.h"
 
@@ -227,9 +234,11 @@ static void createProgram(const char *vertProgFile,
 
    glUseProgram(program);
 
+   /*
    assert(glIsProgram(program));
    assert(glIsShader(fragShader));
    assert(glIsShader(vertShader));
+   */
 
    checkError(__LINE__);
    {/*texture*/
@@ -316,6 +325,13 @@ static void menuInit()
 
 static void init()
 {
+   if (!glutExtensionSupported("GL_ARB_shader_objects") ||
+       !glutExtensionSupported("GL_ARB_vertex_shader") ||
+       !glutExtensionSupported("GL_ARB_fragment_shader")) {
+      fprintf(stderr, "Sorry, this program requires GL_ARB_shader_objects, GL_ARB_vertex_shader, and GL_ARB_fragment_shader\n");
+      exit(1);
+   }
+
    fprintf(stderr, "GL_RENDERER   = %s\n", (char *) glGetString(GL_RENDERER));
    fprintf(stderr, "GL_VERSION    = %s\n", (char *) glGetString(GL_VERSION));
    fprintf(stderr, "GL_VENDOR     = %s\n", (char *) glGetString(GL_VENDOR));
diff --git a/progs/glsl/cubemap.frag b/progs/glsl/cubemap.frag
new file mode 100644 (file)
index 0000000..9c27648
--- /dev/null
@@ -0,0 +1,18 @@
+// Fragment shader for cube-texture reflection mapping
+// Brian Paul
+
+
+uniform samplerCube cubeTex;
+varying vec3 normal;
+uniform vec3 lightPos;
+
+void main()
+{
+   // simple diffuse, specular lighting:
+   vec3 lp = normalize(lightPos);
+   float dp = dot(lp, normalize(normal));
+   float spec = pow(dp, 5.0);
+
+   // final color:
+   gl_FragColor = dp * textureCube(cubeTex, gl_TexCoord[0].xyz, 0.0) + spec;
+}
diff --git a/progs/glsl/cubemap.frag.txt b/progs/glsl/cubemap.frag.txt
deleted file mode 100644 (file)
index 9c27648..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// Fragment shader for cube-texture reflection mapping
-// Brian Paul
-
-
-uniform samplerCube cubeTex;
-varying vec3 normal;
-uniform vec3 lightPos;
-
-void main()
-{
-   // simple diffuse, specular lighting:
-   vec3 lp = normalize(lightPos);
-   float dp = dot(lp, normalize(normal));
-   float spec = pow(dp, 5.0);
-
-   // final color:
-   gl_FragColor = dp * textureCube(cubeTex, gl_TexCoord[0].xyz, 0.0) + spec;
-}
index 8b652bc1e465b4591624a98a627c4cadddb73ae0..e69f0b82c45fbb0abeaf3596796b53869d1a2fa4 100644 (file)
@@ -17,6 +17,7 @@
 #include <GL/glut.h>
 #include <GL/glext.h>
 #include "extfuncs.h"
+#include "shaderutil.h"
 
 
 static char *FragProgFile = NULL;
@@ -159,68 +160,6 @@ MakeRect(void)
 }
 
 
-
-static void
-LoadAndCompileShader(GLuint shader, const char *text)
-{
-   GLint stat;
-
-   glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
-
-   glCompileShader_func(shader);
-
-   glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
-   if (!stat) {
-      GLchar log[1000];
-      GLsizei len;
-      glGetShaderInfoLog_func(shader, 1000, &len, log);
-      fprintf(stderr, "fslight: problem compiling shader:\n%s\n", log);
-      exit(1);
-   }
-}
-
-
-/**
- * Read a shader from a file.
- */
-static void
-ReadShader(GLuint shader, const char *filename)
-{
-   const int max = 100*1000;
-   int n;
-   char *buffer = (char*) malloc(max);
-   FILE *f = fopen(filename, "r");
-   if (!f) {
-      fprintf(stderr, "fslight: Unable to open shader file %s\n", filename);
-      exit(1);
-   }
-
-   n = fread(buffer, 1, max, f);
-   printf("fslight: read %d bytes from shader file %s\n", n, filename);
-   if (n > 0) {
-      buffer[n] = 0;
-      LoadAndCompileShader(shader, buffer);
-   }
-
-   fclose(f);
-   free(buffer);
-}
-
-
-static void
-CheckLink(GLuint prog)
-{
-   GLint stat;
-   glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
-   if (!stat) {
-      GLchar log[1000];
-      GLsizei len;
-      glGetProgramInfoLog_func(prog, 1000, &len, log);
-      fprintf(stderr, "Linker error:\n%s\n", log);
-   }
-}
-
-
 static void
 Init(void)
 {
@@ -234,33 +173,16 @@ Init(void)
       "   gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
       "   gl_TexCoord[0] = gl_MultiTexCoord0;\n"
       "}\n";
-   const char *version;
 
-   version = (const char *) glGetString(GL_VERSION);
-   if (version[0] != '2' || version[1] != '.') {
-      printf("This program requires OpenGL 2.x, found %s\n", version);
+   if (!ShadersSupported())
       exit(1);
-   }
 
    GetExtensionFuncs();
 
-   fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
-   if (FragProgFile)
-      ReadShader(fragShader, FragProgFile);
-   else
-      LoadAndCompileShader(fragShader, fragShaderText);
-
-   vertShader = glCreateShader_func(GL_VERTEX_SHADER);
-   if (VertProgFile)
-      ReadShader(vertShader, VertProgFile);
-   else
-      LoadAndCompileShader(vertShader, vertShaderText);
-
-   program = glCreateProgram_func();
-   glAttachShader_func(program, fragShader);
-   glAttachShader_func(program, vertShader);
-   glLinkProgram_func(program);
-   CheckLink(program);
+   vertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
+   fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
+   program = LinkShaders(vertShader, fragShader);
+
    glUseProgram_func(program);
 
    /*assert(glGetError() == 0);*/
index 7a2bad6dde31a514908c4b9d6a17c9b9c573a8c5..e6361b429b3eb7d5199f4422a0a19222a6b62685 100644 (file)
 #include <GL/glut.h>
 #include <GL/glext.h>
 #include "extfuncs.h"
+#include "shaderutil.h"
 
 
-static char *FragProgFile = "CH18-mandel.frag.txt";
-static char *VertProgFile = "CH18-mandel.vert.txt";
+static char *FragProgFile = "CH18-mandel.frag";
+static char *VertProgFile = "CH18-mandel.vert";
 
 /* program/shader objects */
 static GLuint fragShader;
@@ -24,28 +25,21 @@ static GLuint vertShader;
 static GLuint program;
 
 
-struct uniform_info {
-   const char *name;
-   GLuint size;
-   GLint location;
-   GLfloat value[4];
-};
-
 static struct uniform_info Uniforms[] = {
    /* vert */
-   { "LightPosition",        3, -1, { 0.1, 0.1, 9.0, 0} },
-   { "SpecularContribution", 1, -1, { 0.5, 0, 0, 0 } },
-   { "DiffuseContribution",  1, -1, { 0.5, 0, 0, 0 } },
-   { "Shininess",            1, -1, { 20.0, 0, 0, 0 } },
+   { "LightPosition",        3, GL_FLOAT, { 0.1, 0.1, 9.0, 0}, -1 },
+   { "SpecularContribution", 1, GL_FLOAT, { 0.5, 0, 0, 0 }, -1 },
+   { "DiffuseContribution",  1, GL_FLOAT, { 0.5, 0, 0, 0 }, -1 },
+   { "Shininess",            1, GL_FLOAT, { 20.0, 0, 0, 0 }, -1 },
    /* frag */
-   { "MaxIterations",        1, -1, { 12, 0, 0, 0 } },
-   { "Zoom",                 1, -1, { 0.125, 0, 0, 0 } },
-   { "Xcenter",              1, -1, { -1.5, 0, 0, 0 } },
-   { "Ycenter",              1, -1, { .005, 0, 0, 0 } },
-   { "InnerColor",           3, -1, { 1, 0, 0, 0 } },
-   { "OuterColor1",          3, -1, { 0, 1, 0, 0 } },
-   { "OuterColor2",          3, -1, { 0, 0, 1, 0 } },
-   { NULL, 0, 0, { 0, 0, 0, 0 } }
+   { "MaxIterations",        1, GL_FLOAT, { 12, 0, 0, 0 }, -1 },
+   { "Zoom",                 1, GL_FLOAT, { 0.125, 0, 0, 0 }, -1 },
+   { "Xcenter",              1, GL_FLOAT, { -1.5, 0, 0, 0 }, -1 },
+   { "Ycenter",              1, GL_FLOAT, { .005, 0, 0, 0 }, -1 },
+   { "InnerColor",           3, GL_FLOAT, { 1, 0, 0, 0 }, -1 },
+   { "OuterColor1",          3, GL_FLOAT, { 0, 1, 0, 0 }, -1 },
+   { "OuterColor2",          3, GL_FLOAT, { 0, 0, 1, 0 }, -1 },
+   END_OF_UNIFORMS
 };
 
 static GLint win = 0;
@@ -157,123 +151,21 @@ SpecialKey(int key, int x, int y)
 }
 
 
-
-static void
-LoadAndCompileShader(GLuint shader, const char *text)
-{
-   GLint stat;
-
-   glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
-
-   glCompileShader_func(shader);
-
-   glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
-   if (!stat) {
-      GLchar log[1000];
-      GLsizei len;
-      glGetShaderInfoLog_func(shader, 1000, &len, log);
-      fprintf(stderr, "brick: problem compiling shader: %s\n", log);
-      exit(1);
-   }
-   else {
-      printf("Shader compiled OK\n");
-   }
-}
-
-
-/**
- * Read a shader from a file.
- */
-static void
-ReadShader(GLuint shader, const char *filename)
-{
-   const int max = 100*1000;
-   int n;
-   char *buffer = (char*) malloc(max);
-   FILE *f = fopen(filename, "r");
-   if (!f) {
-      fprintf(stderr, "brick: Unable to open shader file %s\n", filename);
-      exit(1);
-   }
-
-   n = fread(buffer, 1, max, f);
-   printf("brick: read %d bytes from shader file %s\n", n, filename);
-   if (n > 0) {
-      buffer[n] = 0;
-      LoadAndCompileShader(shader, buffer);
-   }
-
-   fclose(f);
-   free(buffer);
-}
-
-
-static void
-CheckLink(GLuint prog)
-{
-   GLint stat;
-   glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
-   if (!stat) {
-      GLchar log[1000];
-      GLsizei len;
-      glGetProgramInfoLog_func(prog, 1000, &len, log);
-      fprintf(stderr, "Linker error:\n%s\n", log);
-   }
-   else {
-      fprintf(stderr, "Link success!\n");
-   }
-}
-
-
 static void
 Init(void)
 {
-   const char *version;
-   GLint i;
-
-   version = (const char *) glGetString(GL_VERSION);
-   if (version[0] != '2' || version[1] != '.') {
-      printf("Warning: this program expects OpenGL 2.0\n");
-      /*exit(1);*/
-   }
+   if (!ShadersSupported())
+      exit(1);
 
    GetExtensionFuncs();
 
-   vertShader = glCreateShader_func(GL_VERTEX_SHADER);
-   ReadShader(vertShader, VertProgFile);
-
-   fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
-   ReadShader(fragShader, FragProgFile);
+   vertShader = CompileShaderFile(GL_VERTEX_SHADER, VertProgFile);
+   fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
+   program = LinkShaders(vertShader, fragShader);
 
-   program = glCreateProgram_func();
-   glAttachShader_func(program, fragShader);
-   glAttachShader_func(program, vertShader);
-   glLinkProgram_func(program);
-   CheckLink(program);
    glUseProgram_func(program);
 
-   for (i = 0; Uniforms[i].name; i++) {
-      Uniforms[i].location
-         = glGetUniformLocation_func(program, Uniforms[i].name);
-      printf("Uniform %s location: %d\n", Uniforms[i].name,
-             Uniforms[i].location);
-      switch (Uniforms[i].size) {
-      case 1:
-         glUniform1fv_func(Uniforms[i].location, 1, Uniforms[i].value);
-         break;
-      case 2:
-         glUniform2fv_func(Uniforms[i].location, 1, Uniforms[i].value);
-         break;
-      case 3:
-         glUniform3fv_func(Uniforms[i].location, 1, Uniforms[i].value);
-         break;
-      case 4:
-         glUniform4fv_func(Uniforms[i].location, 1, Uniforms[i].value);
-         break;
-      default:
-         abort();
-      }
-   }
+   InitUniforms(program, Uniforms);
 
    uZoom = glGetUniformLocation_func(program, "Zoom");
    uXcenter = glGetUniformLocation_func(program, "Xcenter");
diff --git a/progs/glsl/multitex.c b/progs/glsl/multitex.c
new file mode 100644 (file)
index 0000000..096d40f
--- /dev/null
@@ -0,0 +1,285 @@
+/**
+ * Test multi-texturing with GL shading language.
+ *
+ * Copyright (C) 2008  Brian Paul   All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION 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 <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "GL/glut.h"
+#include "readtex.h"
+#include "extfuncs.h"
+#include "shaderutil.h"
+
+static const char *Demo = "multitex";
+
+static const char *VertFile = "multitex.vert";
+static const char *FragFile = "multitex.frag";
+
+static const char *TexFiles[2] = 
+   {
+      "../images/tile.rgb",
+      "../images/tree2.rgba"
+   };
+
+
+static GLuint Program;
+
+static GLfloat Xrot = -90.0, Yrot = .0, Zrot = 0.0;
+static GLfloat EyeDist = 10;
+static GLboolean Anim = GL_TRUE;
+
+
+/* value[0] = tex unit */
+static struct uniform_info Uniforms[] = {
+   { "tex1",  1, GL_INT, { 0, 0, 0, 0 }, -1 },
+   { "tex2",  1, GL_INT, { 1, 0, 0, 0 }, -1 },
+   END_OF_UNIFORMS
+};
+
+
+static void
+DrawPolygon(GLfloat size)
+{
+   glPushMatrix();
+   glRotatef(90, 1, 0, 0);
+   glNormal3f(0, 0, 1);
+   glBegin(GL_POLYGON);
+
+   glMultiTexCoord2f(GL_TEXTURE0, 0, 0);
+   glMultiTexCoord2f(GL_TEXTURE1, 0, 0);
+   glVertex2f(-size, -size);
+
+   glMultiTexCoord2f(GL_TEXTURE0, 2, 0);
+   glMultiTexCoord2f(GL_TEXTURE1, 1, 0);
+   glVertex2f( size, -size);
+
+   glMultiTexCoord2f(GL_TEXTURE0, 2, 2);
+   glMultiTexCoord2f(GL_TEXTURE1, 1, 1);
+   glVertex2f( size,  size);
+
+   glMultiTexCoord2f(GL_TEXTURE0, 0, 2);
+   glMultiTexCoord2f(GL_TEXTURE1, 0, 1);
+   glVertex2f(-size,  size);
+
+   glEnd();
+   glPopMatrix();
+}
+
+
+static void
+draw(void)
+{
+   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+   glPushMatrix(); /* modelview matrix */
+      glTranslatef(0.0, 0.0, -EyeDist);
+      glRotatef(Zrot, 0, 0, 1);
+      glRotatef(Yrot, 0, 1, 0);
+      glRotatef(Xrot, 1, 0, 0);
+
+      DrawPolygon(3.0);
+
+   glPopMatrix();
+
+   glutSwapBuffers();
+}
+
+
+static void
+idle(void)
+{
+   GLfloat t = 0.05 * glutGet(GLUT_ELAPSED_TIME);
+   Yrot = t;
+   glutPostRedisplay();
+}
+
+
+static void
+key(unsigned char k, int x, int y)
+{
+   (void) x;
+   (void) y;
+   switch (k) {
+   case ' ':
+   case 'a':
+      Anim = !Anim;
+      if (Anim)
+         glutIdleFunc(idle);
+      else
+         glutIdleFunc(NULL);
+      break;
+   case 'z':
+      EyeDist -= 0.5;
+      if (EyeDist < 3.0)
+         EyeDist = 3.0;
+      break;
+   case 'Z':
+      EyeDist += 0.5;
+      if (EyeDist > 90.0)
+         EyeDist = 90;
+      break;
+   case 27:
+      exit(0);
+   }
+   glutPostRedisplay();
+}
+
+
+static void
+specialkey(int key, int x, int y)
+{
+   GLfloat step = 2.0;
+   (void) x;
+   (void) y;
+   switch (key) {
+   case GLUT_KEY_UP:
+      Xrot += step;
+      break;
+   case GLUT_KEY_DOWN:
+      Xrot -= step;
+      break;
+   case GLUT_KEY_LEFT:
+      Yrot -= step;
+      break;
+   case GLUT_KEY_RIGHT:
+      Yrot += step;
+      break;
+   }
+   glutPostRedisplay();
+}
+
+
+/* new window size or exposure */
+static void
+Reshape(int width, int height)
+{
+   GLfloat ar = (float) width / (float) height;
+   glViewport(0, 0, (GLint)width, (GLint)height);
+   glMatrixMode(GL_PROJECTION);
+   glLoadIdentity();
+   glFrustum(-2.0*ar, 2.0*ar, -2.0, 2.0, 4.0, 100.0);
+   glMatrixMode(GL_MODELVIEW);
+   glLoadIdentity();
+}
+
+
+static void
+InitTextures(void)
+{
+   GLenum filter = GL_LINEAR;
+   int i;
+
+   for (i = 0; i < 2; i++) {
+      GLint imgWidth, imgHeight;
+      GLenum imgFormat;
+      GLubyte *image = NULL;
+
+      image = LoadRGBImage(TexFiles[i], &imgWidth, &imgHeight, &imgFormat);
+      if (!image) {
+         printf("Couldn't read %s\n", TexFiles[i]);
+         exit(0);
+      }
+
+      glActiveTexture(GL_TEXTURE0 + i);
+      glBindTexture(GL_TEXTURE_2D, 42 + i);
+      gluBuild2DMipmaps(GL_TEXTURE_2D, 4, imgWidth, imgHeight,
+                        imgFormat, GL_UNSIGNED_BYTE, image);
+      free(image);
+      
+      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
+      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
+   }
+}
+
+
+static GLuint
+CreateProgram(const char *vertProgFile, const char *fragProgFile,
+              struct uniform_info *uniforms)
+{
+   GLuint fragShader, vertShader, program;
+
+   vertShader = CompileShaderFile(GL_VERTEX_SHADER, vertProgFile);
+   fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, fragProgFile);
+   assert(vertShader);
+   program = LinkShaders(vertShader, fragShader);
+
+   glUseProgram_func(program);
+
+   InitUniforms(program, uniforms);
+
+   return program;
+}
+
+
+static void
+InitPrograms(void)
+{
+   Program = CreateProgram(VertFile, FragFile, Uniforms);
+}
+
+
+static void
+InitGL(void)
+{
+   const char *version = (const char *) glGetString(GL_VERSION);
+
+   if (version[0] != '2' || version[1] != '.') {
+      printf("Warning: this program expects OpenGL 2.0\n");
+      /*exit(1);*/
+   }
+   printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
+
+   GetExtensionFuncs();
+
+   InitTextures();
+   InitPrograms();
+
+   glEnable(GL_DEPTH_TEST);
+
+   glClearColor(.6, .6, .9, 0);
+   glColor3f(1.0, 1.0, 1.0);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+   glutInit(&argc, argv);
+   glutInitWindowSize(500, 400);
+   glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
+   glutCreateWindow(Demo);
+   glutReshapeFunc(Reshape);
+   glutKeyboardFunc(key);
+   glutSpecialFunc(specialkey);
+   glutDisplayFunc(draw);
+   if (Anim)
+      glutIdleFunc(idle);
+   InitGL();
+   glutMainLoop();
+   return 0;
+}
diff --git a/progs/glsl/multitex.frag b/progs/glsl/multitex.frag
new file mode 100644 (file)
index 0000000..a2633ce
--- /dev/null
@@ -0,0 +1,15 @@
+// Multi-texture fragment shader
+// Brian Paul
+
+// Composite second texture over first.
+// We're assuming the 2nd texture has a meaningful alpha channel.
+
+uniform sampler2D tex1;
+uniform sampler2D tex2;
+
+void main()
+{
+   vec4 t1 = texture2D(tex1, gl_TexCoord[0].xy);
+   vec4 t2 = texture2D(tex2, gl_TexCoord[1].xy);
+   gl_FragColor = mix(t1, t2, t2.w);
+}
diff --git a/progs/glsl/multitex.vert b/progs/glsl/multitex.vert
new file mode 100644 (file)
index 0000000..5518ca1
--- /dev/null
@@ -0,0 +1,10 @@
+// Multi-texture vertex shader
+// Brian Paul
+
+
+void main() 
+{
+   gl_TexCoord[0] = gl_MultiTexCoord0;
+   gl_TexCoord[1] = gl_MultiTexCoord1;
+   gl_Position = ftransform();
+}
index a26a8059449506b20d271ba7a400f49efec41677..9da71ac775eaa140da9818ab559c2dfa57b3fae5 100644 (file)
@@ -12,6 +12,7 @@
 #include <GL/glut.h>
 #include <GL/glext.h>
 #include "extfuncs.h"
+#include "shaderutil.h"
 
 
 static const char *VertShaderText =
@@ -34,18 +35,11 @@ static const char *FragShaderText =
    "}\n";
 
 
-struct uniform_info {
-   const char *name;
-   GLuint size;
-   GLint location;
-   GLfloat value[4];
-};
-
 static struct uniform_info Uniforms[] = {
-   { "Scale",          4, -1, { 0.5, 0.4, 0.0, 0} },
-   { "Bias",           4, -1, { 0.5, 0.3, 0.0, 0} },
-   { "Slice",          1, -1, { 0.5, 0, 0, 0} },
-   { NULL, 0, 0, { 0, 0, 0, 0 } }
+   { "Scale",    4, GL_FLOAT, { 0.5, 0.4, 0.0, 0}, -1 },
+   { "Bias",     4, GL_FLOAT, { 0.5, 0.3, 0.0, 0}, -1 },
+   { "Slice",    1, GL_FLOAT, { 0.5, 0, 0, 0}, -1 },
+   END_OF_UNIFORMS
 };
 
 /* program/shader objects */
@@ -174,95 +168,21 @@ SpecialKey(int key, int x, int y)
 
 
 
-static void
-LoadAndCompileShader(GLuint shader, const char *text)
-{
-   GLint stat;
-
-   glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
-
-   glCompileShader_func(shader);
-
-   glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
-   if (!stat) {
-      GLchar log[1000];
-      GLsizei len;
-      glGetShaderInfoLog_func(shader, 1000, &len, log);
-      fprintf(stderr, "brick: problem compiling shader: %s\n", log);
-      exit(1);
-   }
-   else {
-      printf("Shader compiled OK\n");
-   }
-}
-
-
-static void
-CheckLink(GLuint prog)
-{
-   GLint stat;
-   glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
-   if (!stat) {
-      GLchar log[1000];
-      GLsizei len;
-      glGetProgramInfoLog_func(prog, 1000, &len, log);
-      fprintf(stderr, "Linker error:\n%s\n", log);
-   }
-   else {
-      fprintf(stderr, "Link success!\n");
-   }
-}
-
-
 static void
 Init(void)
 {
-   const char *version;
-   GLint i;
-
-   version = (const char *) glGetString(GL_VERSION);
-   if (version[0] != '2' || version[1] != '.') {
-      printf("Warning: this program expects OpenGL 2.0\n");
-      /*exit(1);*/
-   }
+   if (!ShadersSupported())
+      exit(1);
 
    GetExtensionFuncs();
 
-   vertShader = glCreateShader_func(GL_VERTEX_SHADER);
-   LoadAndCompileShader(vertShader, VertShaderText);
-
-   fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
-   LoadAndCompileShader(fragShader, FragShaderText);
+   vertShader = CompileShaderText(GL_VERTEX_SHADER, VertShaderText);
+   fragShader = CompileShaderText(GL_FRAGMENT_SHADER, FragShaderText);
+   program = LinkShaders(vertShader, fragShader);
 
-   program = glCreateProgram_func();
-   glAttachShader_func(program, fragShader);
-   glAttachShader_func(program, vertShader);
-   glLinkProgram_func(program);
-   CheckLink(program);
    glUseProgram_func(program);
 
-   for (i = 0; Uniforms[i].name; i++) {
-      Uniforms[i].location
-         = glGetUniformLocation_func(program, Uniforms[i].name);
-      printf("Uniform %s location: %d\n", Uniforms[i].name,
-             Uniforms[i].location);
-      switch (Uniforms[i].size) {
-      case 1:
-         glUniform1fv_func(Uniforms[i].location, 1, Uniforms[i].value);
-         break;
-      case 2:
-         glUniform2fv_func(Uniforms[i].location, 1, Uniforms[i].value);
-         break;
-      case 3:
-         glUniform3fv_func(Uniforms[i].location, 1, Uniforms[i].value);
-         break;
-      case 4:
-         glUniform4fv_func(Uniforms[i].location, 1, Uniforms[i].value);
-         break;
-      default:
-         abort();
-      }
-   }
+   InitUniforms(program, Uniforms);
 
    assert(glGetError() == 0);
 
diff --git a/progs/glsl/pointcoord.c b/progs/glsl/pointcoord.c
new file mode 100644 (file)
index 0000000..b240077
--- /dev/null
@@ -0,0 +1,205 @@
+/**
+ * Test GLSL 1.20 gl_PointCoord fragment program attribute.
+ * Brian Paul
+ * 11 Aug 2007
+ */
+
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/gl.h>
+#include <GL/glut.h>
+#include <GL/glext.h>
+#include "extfuncs.h"
+#include "shaderutil.h"
+
+
+static GLint WinWidth = 300, WinHeight = 300;
+static char *FragProgFile = NULL;
+static char *VertProgFile = NULL;
+static GLuint fragShader;
+static GLuint vertShader;
+static GLuint program;
+static GLint win = 0;
+static GLint tex0;
+static GLenum Filter = GL_NEAREST;
+
+
+static void
+Redisplay(void)
+{
+   glClear(GL_COLOR_BUFFER_BIT);
+
+   /* draw one point/sprite */
+   glPushMatrix();
+   glPointSize(60);
+   glBegin(GL_POINTS);
+   glVertex2f(WinWidth / 2.0f, WinHeight / 2.0f);
+   glEnd();
+   glPopMatrix();
+
+   glutSwapBuffers();
+}
+
+
+static void
+Reshape(int width, int height)
+{
+   glViewport(0, 0, width, height);
+   glMatrixMode(GL_PROJECTION);
+   glLoadIdentity();
+   glOrtho(0, width, 0, height, -1, 1);
+
+   glMatrixMode(GL_MODELVIEW);
+   glLoadIdentity();
+
+   WinWidth = width;
+   WinHeight = height;
+}
+
+
+static void
+CleanUp(void)
+{
+   glDeleteShader_func(fragShader);
+   glDeleteShader_func(vertShader);
+   glDeleteProgram_func(program);
+   glutDestroyWindow(win);
+}
+
+
+static void
+Key(unsigned char key, int x, int y)
+{
+  (void) x;
+  (void) y;
+
+   switch(key) {
+   case 27:
+      CleanUp();
+      exit(0);
+      break;
+   }
+   glutPostRedisplay();
+}
+
+
+
+static void
+MakeTexture(void)
+{
+#define SZ 16
+   GLubyte image[SZ][SZ][4];
+   GLuint i, j;
+
+   for (i = 0; i < SZ; i++) {
+      for (j = 0; j < SZ; j++) {
+         if ((i + j) & 1) {
+            image[i][j][0] = 0;
+            image[i][j][1] = 0;
+            image[i][j][2] = 0;
+            image[i][j][3] = 255;
+         }
+         else {
+            image[i][j][0] = j * 255 / (SZ-1);
+            image[i][j][1] = i * 255 / (SZ-1);
+            image[i][j][2] = 0;
+            image[i][j][3] = 255;
+         }
+      }
+   }
+
+   glActiveTexture(GL_TEXTURE0); /* unit 0 */
+   glBindTexture(GL_TEXTURE_2D, 42);
+   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SZ, SZ, 0,
+                GL_RGBA, GL_UNSIGNED_BYTE, image);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, Filter);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, Filter);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+#undef SZ
+}
+
+
+static void
+Init(void)
+{
+   static const char *fragShaderText =
+      "#version 120 \n"
+      "uniform sampler2D tex0; \n"
+      "void main() { \n"
+      "   gl_FragColor = texture2D(tex0, gl_PointCoord.xy, 0.0); \n"
+      "}\n";
+   static const char *vertShaderText =
+      "void main() {\n"
+      "   gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
+      "}\n";
+
+   if (!ShadersSupported())
+      exit(1);
+
+   GetExtensionFuncs();
+
+   vertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
+   fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
+   program = LinkShaders(vertShader, fragShader);
+
+   glUseProgram_func(program);
+
+   tex0 = glGetUniformLocation_func(program, "tex0");
+   printf("Uniforms: tex0: %d\n", tex0);
+
+   glUniform1i_func(tex0, 0); /* tex unit 0 */
+
+   /*assert(glGetError() == 0);*/
+
+   glClearColor(0.3f, 0.3f, 0.3f, 0.0f);
+
+   printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
+
+   assert(glIsProgram_func(program));
+   assert(glIsShader_func(fragShader));
+   assert(glIsShader_func(vertShader));
+
+   MakeTexture();
+
+   glEnable(GL_POINT_SPRITE);
+
+   glColor3f(1, 0, 0);
+}
+
+
+static void
+ParseOptions(int argc, char *argv[])
+{
+   int i;
+   for (i = 1; i < argc; i++) {
+      if (strcmp(argv[i], "-fs") == 0) {
+         FragProgFile = argv[i+1];
+      }
+      else if (strcmp(argv[i], "-vs") == 0) {
+         VertProgFile = argv[i+1];
+      }
+   }
+}
+
+
+int
+main(int argc, char *argv[])
+{
+   glutInit(&argc, argv);
+   glutInitWindowPosition( 0, 0);
+   glutInitWindowSize(WinWidth, WinHeight);
+   glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
+   win = glutCreateWindow(argv[0]);
+   glutReshapeFunc(Reshape);
+   glutKeyboardFunc(Key);
+   glutDisplayFunc(Redisplay);
+   ParseOptions(argc, argv);
+   Init();
+   glutMainLoop();
+   return 0;
+}
diff --git a/progs/glsl/points.c b/progs/glsl/points.c
new file mode 100644 (file)
index 0000000..392dc4d
--- /dev/null
@@ -0,0 +1,260 @@
+/**
+ * Implement smooth (AA) points with shaders.
+ * A simple variation could be used for sprite points.
+ * Brian Paul
+ * 29 July 2007
+ */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/gl.h>
+#include <GL/glut.h>
+#include <GL/glext.h>
+#include "extfuncs.h"
+#include "shaderutil.h"
+
+
+static GLuint FragShader;
+static GLuint VertShader;
+static GLuint Program;
+
+static GLint Win = 0;
+static GLint WinWidth = 500, WinHeight = 200;
+static GLfloat Xpos = 0.0f, Ypos = 0.0f;
+static GLint uViewportInv;
+static GLboolean Smooth = GL_TRUE, Blend = GL_TRUE;
+
+
+/**
+ * Issue vertices for a "shader point".
+ * The position is duplicated, only texcoords (or other vertex attrib) change.
+ * The vertex program will compute the "real" quad corners.
+ */
+static void
+PointVertex3f(GLfloat x, GLfloat y, GLfloat z)
+{
+   glTexCoord2f(-1, -1);
+   glVertex3f(x, y, z);
+
+   glTexCoord2f( 1, -1);
+   glVertex3f(x, y, z);
+
+   glTexCoord2f( 1,  1);
+   glVertex3f(x, y, z);
+
+   glTexCoord2f(-1,  1);
+   glVertex3f(x, y, z);
+}
+
+
+static void
+DrawPoints(GLboolean shaderPoints)
+{
+   int i;
+   for (i = 0; i < 9; i++) {
+      GLfloat x = i - 4, y = 0, z = 0;
+      /* note: can't call glPointSize inside Begin/End :( */
+      glPointSize( 2 + i * 5 );
+      if (shaderPoints) {
+         glBegin(GL_QUADS);
+         PointVertex3f(x, y, z);
+         glEnd();
+      }
+      else {
+         glBegin(GL_POINTS);
+         glVertex3f(x, y, z);
+         glEnd();
+      }
+   }
+}
+
+
+/**
+ * Top row of points rendered convetionally,
+ * bottom row rendered with shaders.
+ */
+static void
+Redisplay(void)
+{
+   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+   if (Smooth)
+      glEnable(GL_POINT_SMOOTH);
+   else
+      glDisable(GL_POINT_SMOOTH);
+
+   if (Blend)
+      glEnable(GL_BLEND);
+   else
+      glDisable(GL_BLEND);
+
+   glPushMatrix();
+   glTranslatef(Xpos, Ypos, 0);
+
+   /*
+    * regular points
+    */
+   glPushMatrix();
+   glTranslatef(0, 1.2, 0);
+   glUseProgram_func(0);
+   DrawPoints(GL_FALSE);
+   glPopMatrix();
+
+   /*
+    * shader points
+    */
+   glPushMatrix();
+   glTranslatef(0, -1.2, 0);
+   glUseProgram_func(Program);
+   if (uViewportInv != -1) {
+      glUniform2f_func(uViewportInv, 1.0 / WinWidth, 1.0 / WinHeight);
+   }
+   DrawPoints(GL_TRUE);
+   glPopMatrix();
+
+   glPopMatrix();
+
+   glutSwapBuffers();
+}
+
+
+static void
+Reshape(int width, int height)
+{
+   WinWidth = width;
+   WinHeight = height;
+   glViewport(0, 0, width, height);
+   glMatrixMode(GL_PROJECTION);
+   glLoadIdentity();
+   glFrustum(-1.0, 1.0, -1.0, 1.0, 4.0, 30.0);
+   glMatrixMode(GL_MODELVIEW);
+   glLoadIdentity();
+   glTranslatef(0.0f, 0.0f, -20.0f);
+}
+
+
+static void
+Key(unsigned char key, int x, int y)
+{
+  (void) x;
+  (void) y;
+
+   switch(key) {
+   case 'b':
+      Blend = !Blend;
+      break;
+   case 's':
+      Smooth = !Smooth;
+      break;
+   case 27:
+      glDeleteShader_func(FragShader);
+      glDeleteShader_func(VertShader);
+      glDeleteProgram_func(Program);
+      glutDestroyWindow(Win);
+      exit(0);
+   }
+   glutPostRedisplay();
+}
+
+
+static void
+SpecialKey(int key, int x, int y)
+{
+   const GLfloat step = 1/100.0;
+   switch(key) {
+   case GLUT_KEY_UP:
+      Ypos += step;
+      break;
+   case GLUT_KEY_DOWN:
+      Ypos -= step;
+      break;
+   case GLUT_KEY_LEFT:
+      Xpos -= step;
+      break;
+   case GLUT_KEY_RIGHT:
+      Xpos += step;
+      break;
+   }
+   glutPostRedisplay();
+}
+
+
+static void
+Init(void)
+{
+   /* Fragment shader: compute distance of fragment from center of point
+    * (we're using texcoords but another varying could be used).
+    *   if dist > 1, discard (coverage==0)
+    *   if dist < k, coverage = 1
+    *   else, coverage = func(dist)
+    * Note: length() uses sqrt() and may be expensive.  The distance could
+    * be squared instead (with adjustments to the threshold (k) test)
+    */
+   static const char *fragShaderText =
+      "void main() {\n"
+      "   float cover; \n"
+      "   float k = 2.0 / gl_Point.size; \n"
+      "   float d = length(gl_TexCoord[0].xy); \n"
+      "   if (d >= 1.0) \n"
+      "      discard; \n"
+      "   if (d < 1.0 - k) \n"
+      "      cover = 1.0; \n"
+      "   else \n"
+      "      cover = (1.0 - d) * 0.5 * gl_Point.size; \n"
+      "   gl_FragColor.rgb = gl_Color.rgb; \n"
+      "   gl_FragColor.a = cover; \n"
+      "}\n";
+   /* Vertex shader: compute new vertex position based on incoming vertex pos,
+    * texcoords, point size, and inverse viewport scale factor.
+    * Note: should compute point size attenuation here too.
+    */
+   static const char *vertShaderText =
+      "uniform vec2 viewportInv; \n"
+      "void main() {\n"
+      "   vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
+      "   gl_Position.xy = pos.xy + gl_MultiTexCoord0.xy * viewportInv \n"
+      "                    * gl_Point.size * pos.w; \n"
+      "   gl_Position.zw = pos.zw; \n"
+      "   gl_TexCoord[0] = gl_MultiTexCoord0; \n"
+      "   gl_FrontColor = gl_Color; \n"
+      "}\n";
+
+   if (!ShadersSupported())
+      exit(1);
+
+   GetExtensionFuncs();
+
+   VertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
+   FragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
+   Program = LinkShaders(VertShader, FragShader);
+
+   glUseProgram_func(Program);
+
+   uViewportInv = glGetUniformLocation_func(Program, "viewportInv");
+
+   glUseProgram_func(0);
+
+   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+   glutInit(&argc, argv);
+   glutInitWindowSize(WinWidth, WinHeight);
+   glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+   Win = glutCreateWindow(argv[0]);
+   glutReshapeFunc(Reshape);
+   glutKeyboardFunc(Key);
+   glutSpecialFunc(SpecialKey);
+   glutDisplayFunc(Redisplay);
+   Init();
+   glutMainLoop();
+   return 0;
+}
+
+
diff --git a/progs/glsl/reflect.vert b/progs/glsl/reflect.vert
new file mode 100644 (file)
index 0000000..402be38
--- /dev/null
@@ -0,0 +1,19 @@
+// Vertex shader for cube-texture reflection mapping
+// Brian Paul
+
+
+varying vec3 normal;
+
+void main() 
+{
+   vec3 n = gl_NormalMatrix * gl_Normal;
+   vec3 u = normalize(vec3(gl_ModelViewMatrix * gl_Vertex));
+   float two_n_dot_u = 2.0 * dot(n, u);
+   vec4 f;
+   f.xyz = u - n * two_n_dot_u;
+
+   // outputs
+   normal = n;
+   gl_TexCoord[0] = gl_TextureMatrix[0] * f;
+   gl_Position = ftransform();
+}
diff --git a/progs/glsl/reflect.vert.txt b/progs/glsl/reflect.vert.txt
deleted file mode 100644 (file)
index 402be38..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// Vertex shader for cube-texture reflection mapping
-// Brian Paul
-
-
-varying vec3 normal;
-
-void main() 
-{
-   vec3 n = gl_NormalMatrix * gl_Normal;
-   vec3 u = normalize(vec3(gl_ModelViewMatrix * gl_Vertex));
-   float two_n_dot_u = 2.0 * dot(n, u);
-   vec4 f;
-   f.xyz = u - n * two_n_dot_u;
-
-   // outputs
-   normal = n;
-   gl_TexCoord[0] = gl_TextureMatrix[0] * f;
-   gl_Position = ftransform();
-}
diff --git a/progs/glsl/shadowtex.frag b/progs/glsl/shadowtex.frag
new file mode 100644 (file)
index 0000000..a6a80da
--- /dev/null
@@ -0,0 +1,21 @@
+// Fragment shader for 2D texture with shadow attenuation
+// Brian Paul
+
+
+uniform sampler2D tex2d;
+uniform vec3 lightPos;
+
+void main()
+{
+   // XXX should compute this from lightPos
+   vec2 shadowCenter = vec2(-0.25, -0.25);
+
+   // d = distance from center
+   float d = distance(gl_TexCoord[0].xy, shadowCenter);
+
+   // attenuate and clamp
+   d = clamp(d * d * d, 0.0, 2.0);
+
+   // modulate texture by d for shadow effect
+   gl_FragColor = d * texture2D(tex2d, gl_TexCoord[0].xy, 0.0);
+}
diff --git a/progs/glsl/shadowtex.frag.txt b/progs/glsl/shadowtex.frag.txt
deleted file mode 100644 (file)
index a6a80da..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// Fragment shader for 2D texture with shadow attenuation
-// Brian Paul
-
-
-uniform sampler2D tex2d;
-uniform vec3 lightPos;
-
-void main()
-{
-   // XXX should compute this from lightPos
-   vec2 shadowCenter = vec2(-0.25, -0.25);
-
-   // d = distance from center
-   float d = distance(gl_TexCoord[0].xy, shadowCenter);
-
-   // attenuate and clamp
-   d = clamp(d * d * d, 0.0, 2.0);
-
-   // modulate texture by d for shadow effect
-   gl_FragColor = d * texture2D(tex2d, gl_TexCoord[0].xy, 0.0);
-}
diff --git a/progs/glsl/simple.vert b/progs/glsl/simple.vert
new file mode 100644 (file)
index 0000000..a0abe0d
--- /dev/null
@@ -0,0 +1,9 @@
+// Simple vertex shader
+// Brian Paul
+
+
+void main() 
+{
+   gl_TexCoord[0] = gl_MultiTexCoord0;
+   gl_Position = ftransform();
+}
diff --git a/progs/glsl/simple.vert.txt b/progs/glsl/simple.vert.txt
deleted file mode 100644 (file)
index a0abe0d..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-// Simple vertex shader
-// Brian Paul
-
-
-void main() 
-{
-   gl_TexCoord[0] = gl_MultiTexCoord0;
-   gl_Position = ftransform();
-}
index 3ceae14b96bb50c08cd6b7f73ab0b83dcff67f08..96ddca1f32d2a6a5eb02b6e58b5cf3f5bea3655f 100644 (file)
 #include "GL/glut.h"
 #include "readtex.h"
 #include "extfuncs.h"
+#include "shaderutil.h"
 
 static const char *Demo = "texdemo1";
 
-static const char *ReflectVertFile = "reflect.vert.txt";
-static const char *CubeFragFile = "cubemap.frag.txt";
+static const char *ReflectVertFile = "reflect.vert";
+static const char *CubeFragFile = "cubemap.frag";
 
-static const char *SimpleVertFile = "simple.vert.txt";
-static const char *SimpleTexFragFile = "shadowtex.frag.txt";
+static const char *SimpleVertFile = "simple.vert";
+static const char *SimpleTexFragFile = "shadowtex.frag";
 
 static const char *GroundImage = "../images/tile.rgb";
 
@@ -51,38 +52,19 @@ static GLboolean Anim = GL_TRUE;
 static int win = 0;
 
 
-struct uniform_info {
-   const char *name;
-   GLuint size;
-   GLint location;
-   GLenum type;  /**< GL_FLOAT or GL_INT */
-   GLfloat value[4];
-};
-
 static struct uniform_info ReflectUniforms[] = {
-   { "cubeTex",  1, -1, GL_INT, { 0, 0, 0, 0 } },
-   { "lightPos", 3, -1, GL_FLOAT, { 10, 10, 20, 0 } },
-   { NULL, 0, 0, 0, { 0, 0, 0, 0 } }
+   { "cubeTex",  1, GL_INT, { 0, 0, 0, 0 }, -1 },
+   { "lightPos", 3, GL_FLOAT, { 10, 10, 20, 0 }, -1 },
+   END_OF_UNIFORMS
 };
 
 static struct uniform_info SimpleUniforms[] = {
-   { "tex2d",    1, -1, GL_INT,   { 1, 0, 0, 0 } },
-   { "lightPos", 3, -1, GL_FLOAT, { 10, 10, 20, 0 } },
-   { NULL, 0, 0, 0, { 0, 0, 0, 0 } }
+   { "tex2d",    1, GL_INT,   { 1, 0, 0, 0 }, -1 },
+   { "lightPos", 3, GL_FLOAT, { 10, 10, 20, 0 }, -1 },
+   END_OF_UNIFORMS
 };
 
 
-static void
-CheckError(int line)
-{
-   GLenum err = glGetError();
-   if (err) {
-      printf("GL Error %s (0x%x) at line %d\n",
-             gluErrorString(err), (int) err, line);
-   }
-}
-
-
 static void
 DrawGround(GLfloat size)
 {
@@ -388,132 +370,19 @@ InitTextures(GLboolean useImageFiles)
 }
 
 
-static void
-LoadAndCompileShader(GLuint shader, const char *text)
-{
-   GLint stat;
-
-   glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
-
-   glCompileShader_func(shader);
-
-   glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
-   if (!stat) {
-      GLchar log[1000];
-      GLsizei len;
-      glGetShaderInfoLog_func(shader, 1000, &len, log);
-      fprintf(stderr, "%s: problem compiling shader: %s\n", Demo, log);
-      exit(1);
-   }
-   else {
-      printf("Shader compiled OK\n");
-   }
-}
-
-
-/**
- * Read a shader from a file.
- */
-static void
-ReadShader(GLuint shader, const char *filename)
-{
-   const int max = 100*1000;
-   int n;
-   char *buffer = (char*) malloc(max);
-   FILE *f = fopen(filename, "r");
-   if (!f) {
-      fprintf(stderr, "%s: Unable to open shader file %s\n", Demo, filename);
-      exit(1);
-   }
-
-   n = fread(buffer, 1, max, f);
-   printf("%s: read %d bytes from shader file %s\n", Demo, n, filename);
-   if (n > 0) {
-      buffer[n] = 0;
-      LoadAndCompileShader(shader, buffer);
-   }
-
-   fclose(f);
-   free(buffer);
-}
-
-
-static void
-CheckLink(GLuint prog)
-{
-   GLint stat;
-   glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
-   if (!stat) {
-      GLchar log[1000];
-      GLsizei len;
-      glGetProgramInfoLog_func(prog, 1000, &len, log);
-      fprintf(stderr, "Linker error:\n%s\n", log);
-   }
-   else {
-      fprintf(stderr, "Link success!\n");
-   }
-}
-
-
 static GLuint
 CreateProgram(const char *vertProgFile, const char *fragProgFile,
               struct uniform_info *uniforms)
 {
-   GLuint fragShader = 0, vertShader = 0, program = 0;
-   GLint i;
-
-   program = glCreateProgram_func();
-   if (vertProgFile) {
-      vertShader = glCreateShader_func(GL_VERTEX_SHADER);
-      ReadShader(vertShader, vertProgFile);
-      glAttachShader_func(program, vertShader);
-   }
+   GLuint fragShader, vertShader, program;
 
-   if (fragProgFile) {
-      fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
-      ReadShader(fragShader, fragProgFile);
-      glAttachShader_func(program, fragShader);
-   }
-
-   glLinkProgram_func(program);
-   CheckLink(program);
+   vertShader = CompileShaderFile(GL_VERTEX_SHADER, vertProgFile);
+   fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, fragProgFile);
+   program = LinkShaders(vertShader, fragShader);
 
    glUseProgram_func(program);
 
-   assert(glIsProgram_func(program));
-   assert(glIsShader_func(fragShader));
-   assert(glIsShader_func(vertShader));
-
-   CheckError(__LINE__);
-   for (i = 0; uniforms[i].name; i++) {
-      uniforms[i].location
-         = glGetUniformLocation_func(program, uniforms[i].name);
-      printf("Uniform %s location: %d\n", uniforms[i].name,
-             uniforms[i].location);
-
-      switch (uniforms[i].size) {
-      case 1:
-         if (uniforms[i].type == GL_INT)
-            glUniform1i_func(uniforms[i].location,
-                             (GLint) uniforms[i].value[0]);
-         else
-            glUniform1fv_func(uniforms[i].location, 1, uniforms[i].value);
-         break;
-      case 2:
-         glUniform2fv_func(uniforms[i].location, 1, uniforms[i].value);
-         break;
-      case 3:
-         glUniform3fv_func(uniforms[i].location, 1, uniforms[i].value);
-         break;
-      case 4:
-         glUniform4fv_func(uniforms[i].location, 1, uniforms[i].value);
-         break;
-      default:
-         abort();
-      }
-   }
-
-   CheckError(__LINE__);
+   InitUniforms(program, uniforms);
 
    return program;
 }
index cef52c04a6cc790e93799c41a048f237cdc36c26..2daaedd6df811fe6bc3ee60bb9f2f63a747c1e2a 100644 (file)
 #include <GL/glut.h>
 #include <GL/glext.h>
 #include "extfuncs.h"
+#include "shaderutil.h"
 
 
-static char *FragProgFile = "CH11-toyball.frag.txt";
-static char *VertProgFile = "CH11-toyball.vert.txt";
+static char *FragProgFile = "CH11-toyball.frag";
+static char *VertProgFile = "CH11-toyball.vert";
 
 /* program/shader objects */
 static GLuint fragShader;
@@ -24,30 +25,23 @@ static GLuint vertShader;
 static GLuint program;
 
 
-struct uniform_info {
-   const char *name;
-   GLuint size;
-   GLint location;
-   GLfloat value[4];
-};
-
 static struct uniform_info Uniforms[] = {
-   { "LightDir",       4, -1, { 0.57737, 0.57735, 0.57735, 0.0 } },
-   { "HVector",        4, -1, { 0.32506, 0.32506, 0.88808, 0.0 } },
-   { "BallCenter",     4, -1, { 0.0, 0.0, 0.0, 1.0 } },
-   { "SpecularColor",  4, -1, { 0.4, 0.4, 0.4, 60.0 } },
-   { "Red",            4, -1, { 0.6, 0.0, 0.0, 1.0 } },
-   { "Blue",           4, -1, { 0.0, 0.3, 0.6, 1.0 } },
-   { "Yellow",         4, -1, { 0.6, 0.5, 0.0, 1.0 } },
-   { "HalfSpace0",     4, -1, { 1.0, 0.0, 0.0, 0.2 } },
-   { "HalfSpace1",     4, -1, { 0.309016994, 0.951056516, 0.0, 0.2 } },
-   { "HalfSpace2",     4, -1, { -0.809016994, 0.587785252, 0.0, 0.2 } },
-   { "HalfSpace3",     4, -1, { -0.809016994, -0.587785252, 0.0, 0.2 } },
-   { "HalfSpace4",     4, -1, { 0.309116994, -0.951056516, 0.0, 0.2 } },
-   { "InOrOutInit",    1, -1, { -3.0, 0, 0, 0 } },
-   { "StripeWidth",    1, -1, {  0.3, 0, 0, 0 } },
-   { "FWidth",         1, -1, { 0.005, 0, 0, 0 } },
-   { NULL, 0, 0, { 0, 0, 0, 0 } }
+   { "LightDir",       4, GL_FLOAT, { 0.57737, 0.57735, 0.57735, 0.0 }, -1 },
+   { "HVector",        4, GL_FLOAT, { 0.32506, 0.32506, 0.88808, 0.0 }, -1 },
+   { "BallCenter",     4, GL_FLOAT, { 0.0, 0.0, 0.0, 1.0 }, -1 },
+   { "SpecularColor",  4, GL_FLOAT, { 0.4, 0.4, 0.4, 60.0 }, -1 },
+   { "Red",         4, GL_FLOAT, { 0.6, 0.0, 0.0, 1.0 }, -1 },
+   { "Blue",        4, GL_FLOAT, { 0.0, 0.3, 0.6, 1.0 }, -1 },
+   { "Yellow",      4, GL_FLOAT, { 0.6, 0.5, 0.0, 1.0 }, -1 },
+   { "HalfSpace0",  4, GL_FLOAT, { 1.0, 0.0, 0.0, 0.2 }, -1 },
+   { "HalfSpace1",  4, GL_FLOAT, { 0.309016994, 0.951056516, 0.0, 0.2 }, -1 },
+   { "HalfSpace2",  4, GL_FLOAT, { -0.809016994, 0.587785252, 0.0, 0.2 }, -1 },
+   { "HalfSpace3",  4, GL_FLOAT, { -0.809016994, -0.587785252, 0.0, 0.2 }, -1 },
+   { "HalfSpace4",  4, GL_FLOAT, { 0.309116994, -0.951056516, 0.0, 0.2 }, -1 },
+   { "InOrOutInit", 1, GL_FLOAT, { -3.0, 0, 0, 0 }, -1 },
+   { "StripeWidth", 1, GL_FLOAT, {  0.3, 0, 0, 0 }, -1 },
+   { "FWidth",      1, GL_FLOAT, { 0.005, 0, 0, 0 }, -1 },
+   END_OF_UNIFORMS
 };
 
 static GLint win = 0;
@@ -171,128 +165,21 @@ SpecialKey(int key, int x, int y)
 
 
 
-static void
-LoadAndCompileShader(GLuint shader, const char *text)
-{
-   GLint stat;
-
-   glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
-
-   glCompileShader_func(shader);
-
-   glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
-   if (!stat) {
-      GLchar log[1000];
-      GLsizei len;
-      glGetShaderInfoLog_func(shader, 1000, &len, log);
-      fprintf(stderr, "brick: problem compiling shader: %s\n", log);
-      exit(1);
-   }
-   else {
-      printf("Shader compiled OK\n");
-   }
-}
-
-
-/**
- * Read a shader from a file.
- */
-static void
-ReadShader(GLuint shader, const char *filename)
-{
-   const int max = 100*1000;
-   int n;
-   char *buffer = (char*) malloc(max);
-   FILE *f = fopen(filename, "r");
-   if (!f) {
-      fprintf(stderr, "brick: Unable to open shader file %s\n", filename);
-      exit(1);
-   }
-
-   n = fread(buffer, 1, max, f);
-   printf("brick: read %d bytes from shader file %s\n", n, filename);
-   if (n > 0) {
-      buffer[n] = 0;
-      LoadAndCompileShader(shader, buffer);
-   }
-
-   fclose(f);
-   free(buffer);
-}
-
-
-static void
-CheckLink(GLuint prog)
-{
-   GLint stat;
-   glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
-   if (!stat) {
-      GLchar log[1000];
-      GLsizei len;
-      glGetProgramInfoLog_func(prog, 1000, &len, log);
-      fprintf(stderr, "Linker error:\n%s\n", log);
-   }
-   else {
-      fprintf(stderr, "Link success!\n");
-   }
-}
-
-
 static void
 Init(void)
 {
-   const char *version;
-   GLint i;
-
-   version = (const char *) glGetString(GL_VERSION);
-   if (version[0] != '2' || version[1] != '.') {
-      printf("Warning: this program expects OpenGL 2.0\n");
-      /*exit(1);*/
-   }
-   printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
+   if (!ShadersSupported())
+      exit(1);
 
    GetExtensionFuncs();
 
-   vertShader = glCreateShader_func(GL_VERTEX_SHADER);
-   ReadShader(vertShader, VertProgFile);
-
-   fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
-   ReadShader(fragShader, FragProgFile);
+   vertShader = CompileShaderFile(GL_VERTEX_SHADER, VertProgFile);
+   fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
+   program = LinkShaders(vertShader, fragShader);
 
-   program = glCreateProgram_func();
-   glAttachShader_func(program, fragShader);
-   glAttachShader_func(program, vertShader);
-   glLinkProgram_func(program);
-   CheckLink(program);
    glUseProgram_func(program);
 
-   assert(glIsProgram_func(program));
-   assert(glIsShader_func(fragShader));
-   assert(glIsShader_func(vertShader));
-
-
-   for (i = 0; Uniforms[i].name; i++) {
-      Uniforms[i].location
-         = glGetUniformLocation_func(program, Uniforms[i].name);
-      printf("Uniform %s location: %d\n", Uniforms[i].name,
-             Uniforms[i].location);
-      switch (Uniforms[i].size) {
-      case 1:
-         glUniform1fv_func(Uniforms[i].location, 1, Uniforms[i].value);
-         break;
-      case 2:
-         glUniform2fv_func(Uniforms[i].location, 1, Uniforms[i].value);
-         break;
-      case 3:
-         glUniform3fv_func(Uniforms[i].location, 1, Uniforms[i].value);
-         break;
-      case 4:
-         glUniform4fv_func(Uniforms[i].location, 1, Uniforms[i].value);
-         break;
-      default:
-         abort();
-      }
-   }
+   InitUniforms(program, Uniforms);
 
    assert(glGetError() == 0);
 
diff --git a/progs/glsl/trirast.c b/progs/glsl/trirast.c
new file mode 100644 (file)
index 0000000..89df64f
--- /dev/null
@@ -0,0 +1,259 @@
+/**
+ * Demonstration of doing triangle rasterization with a fragment program.
+ * Basic idea:
+ *   1. Draw screen-aligned quad / bounding box around the triangle verts.
+ *   2. For each pixel in the quad, determine if pixel is inside/outside
+ *      the triangle edges.
+ *
+ * Brian Paul
+ * 1 Aug 2007
+ */
+
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/gl.h>
+#include <GL/glut.h>
+#include <GL/glext.h>
+#include "extfuncs.h"
+#include "shaderutil.h"
+
+
+static GLint WinWidth = 300, WinHeight = 300;
+static char *FragProgFile = NULL;
+static char *VertProgFile = NULL;
+static GLuint fragShader;
+static GLuint vertShader;
+static GLuint program;
+static GLint win = 0;
+static GLboolean anim = GL_TRUE;
+static GLfloat Zrot = 0.0f;
+static GLint uv0, uv1, uv2;
+
+
+static const GLfloat TriVerts[3][2] = {
+   { 50,  50 },
+   { 250, 50 },
+   { 150, 250 }
+};
+
+
+static void
+RotateVerts(GLfloat a,
+            GLuint n, const GLfloat vertsIn[][2], GLfloat vertsOut[][2])
+{
+   GLuint i;
+   GLfloat cx = WinWidth / 2, cy = WinHeight / 2;
+   for (i = 0; i < n; i++) {
+      float x = vertsIn[i][0] - cx;
+      float y = vertsIn[i][1] - cy;
+      
+      vertsOut[i][0] =  x * cos(a) + y * sin(a)  + cx;
+      vertsOut[i][1] = -x * sin(a) + y * cos(a)  + cy;
+   }
+}
+
+static void
+ComputeBounds(GLuint n, GLfloat vertsIn[][2],
+              GLfloat *xmin, GLfloat *ymin,
+              GLfloat *xmax, GLfloat *ymax)
+{
+   GLuint i;
+   *xmin = *xmax = vertsIn[0][0];
+   *ymin = *ymax = vertsIn[0][1];
+   for (i = 1; i < n; i++) {
+      if (vertsIn[i][0] < *xmin)
+         *xmin = vertsIn[i][0];
+      else if (vertsIn[i][0] > *xmax)
+         *xmax = vertsIn[i][0];
+      if (vertsIn[i][1] < *ymin)
+         *ymin = vertsIn[i][1];
+      else if (vertsIn[i][1] > *ymax)
+         *ymax = vertsIn[i][1];
+   }
+}
+
+
+static void
+Redisplay(void)
+{
+   GLfloat v[3][2], xmin, ymin, xmax, ymax;
+
+   RotateVerts(Zrot, 3, TriVerts, v);
+   ComputeBounds(3, v, &xmin, &ymin, &xmax, &ymax);
+
+   glUniform2fv_func(uv0, 1, v[0]);
+   glUniform2fv_func(uv1, 1, v[1]);
+   glUniform2fv_func(uv2, 1, v[2]);
+
+   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+   glPushMatrix();
+   glBegin(GL_POLYGON);
+   glVertex2f(xmin, ymin);
+   glVertex2f(xmax, ymin);
+   glVertex2f(xmax, ymax);
+   glVertex2f(xmin, ymax);
+   glEnd();
+   glPopMatrix();
+
+   glutSwapBuffers();
+}
+
+
+static void
+Idle(void)
+{
+   if (anim) {
+      Zrot = glutGet(GLUT_ELAPSED_TIME) * 0.0005;
+      glutPostRedisplay();
+   }
+   else
+      abort();
+}
+
+
+static void
+Reshape(int width, int height)
+{
+   glViewport(0, 0, width, height);
+   glMatrixMode(GL_PROJECTION);
+   glLoadIdentity();
+   glOrtho(0, width, 0, height, -1, 1);
+
+   glMatrixMode(GL_MODELVIEW);
+   glLoadIdentity();
+}
+
+
+static void
+CleanUp(void)
+{
+   glDeleteShader_func(fragShader);
+   glDeleteShader_func(vertShader);
+   glDeleteProgram_func(program);
+   glutDestroyWindow(win);
+}
+
+
+static void
+Key(unsigned char key, int x, int y)
+{
+  (void) x;
+  (void) y;
+
+   switch(key) {
+   case ' ':
+   case 'a':
+      anim = !anim;
+      if (anim)
+         glutIdleFunc(Idle);
+      else
+         glutIdleFunc(NULL);
+      break;
+   case 'z':
+      Zrot = 0;
+      break;
+   case 's':
+      Zrot += 0.05;
+      break;
+   case 27:
+      CleanUp();
+      exit(0);
+      break;
+   }
+   glutPostRedisplay();
+}
+
+
+static void
+Init(void)
+{
+   static const char *fragShaderText =
+      "uniform vec2 v0, v1, v2; \n"
+      "float crs(const vec2 u, const vec2 v) \n"
+      "{ \n"
+      "   return u.x * v.y - u.y * v.x; \n"
+      "} \n"
+      "\n"
+      "void main() {\n"
+      "   vec2 p = gl_FragCoord.xy; \n"
+      "   if (crs(v1 - v0, p - v0) >= 0 && \n"
+      "       crs(v2 - v1, p - v1) >= 0 && \n"
+      "       crs(v0 - v2, p - v2) >= 0) \n"
+      "      gl_FragColor = vec4(1.0); \n"
+      "   else \n"
+      "      gl_FragColor = vec4(0.5); \n"
+      "}\n";
+   static const char *vertShaderText =
+      "void main() {\n"
+      "   gl_Position = ftransform(); \n"
+      "}\n";
+
+   if (!ShadersSupported())
+      exit(1);
+
+   GetExtensionFuncs();
+
+   vertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
+   fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
+   program = LinkShaders(vertShader, fragShader);
+
+   glUseProgram_func(program);
+
+   uv0 = glGetUniformLocation_func(program, "v0");
+   uv1 = glGetUniformLocation_func(program, "v1");
+   uv2 = glGetUniformLocation_func(program, "v2");
+   printf("Uniforms: %d %d %d\n", uv0, uv1, uv2);
+
+   /*assert(glGetError() == 0);*/
+
+   glClearColor(0.3f, 0.3f, 0.3f, 0.0f);
+   glEnable(GL_DEPTH_TEST);
+
+   printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
+
+   assert(glIsProgram_func(program));
+   assert(glIsShader_func(fragShader));
+   assert(glIsShader_func(vertShader));
+
+   glColor3f(1, 0, 0);
+}
+
+
+static void
+ParseOptions(int argc, char *argv[])
+{
+   int i;
+   for (i = 1; i < argc; i++) {
+      if (strcmp(argv[i], "-fs") == 0) {
+         FragProgFile = argv[i+1];
+      }
+      else if (strcmp(argv[i], "-vs") == 0) {
+         VertProgFile = argv[i+1];
+      }
+   }
+}
+
+
+int
+main(int argc, char *argv[])
+{
+   glutInit(&argc, argv);
+   glutInitWindowPosition( 0, 0);
+   glutInitWindowSize(WinWidth, WinHeight);
+   glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+   win = glutCreateWindow(argv[0]);
+   glutReshapeFunc(Reshape);
+   glutKeyboardFunc(Key);
+   glutDisplayFunc(Redisplay);
+   if (anim)
+      glutIdleFunc(Idle);
+   ParseOptions(argc, argv);
+   Init();
+   glutMainLoop();
+   return 0;
+}
diff --git a/progs/glsl/twoside.c b/progs/glsl/twoside.c
new file mode 100644 (file)
index 0000000..672a004
--- /dev/null
@@ -0,0 +1,294 @@
+/**
+ * Test two-sided lighting with shaders.
+ * Both GL_VERTEX_PROGRAM_TWO_SIDE and gl_FrontFacing can be tested
+ * (see keys below).
+ *
+ * Brian Paul
+ * 18 Dec 2007
+ */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/gl.h>
+#include <GL/glut.h>
+#include <GL/glext.h>
+#include "extfuncs.h"
+#include "shaderutil.h"
+
+
+static GLint WinWidth = 300, WinHeight = 300;
+static char *FragProgFile = NULL;
+static char *VertProgFile = NULL;
+static GLuint fragShader;
+static GLuint vertShader;
+static GLuint program;
+static GLint win = 0;
+static GLboolean anim = 0*GL_TRUE;
+static GLboolean DetermineInFragProg = GL_TRUE;
+static GLfloat Xrot = 30.0f;
+static GLint u_fragface;
+static GLenum FrontWinding = GL_CCW;
+static int prevTime = 0;
+
+
+static const GLfloat Red[4] = {1, 0, 0, 0};
+static const GLfloat Green[4] = {0, 1, 0, 0};
+
+
+static void
+Redisplay(void)
+{
+   int i;
+   float radius = 2;
+
+   glFrontFace(FrontWinding);
+
+   if (DetermineInFragProg) {
+      glUniform1i_func(u_fragface, 1);
+      glDisable(GL_VERTEX_PROGRAM_TWO_SIDE);
+   }
+   else {
+      glUniform1i_func(u_fragface, 0);
+      glEnable(GL_VERTEX_PROGRAM_TWO_SIDE);
+   }
+
+   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+   glPushMatrix();
+   glRotatef(Xrot, 1, 0, 0);
+
+   /* Draw a tristrip ring */
+   glBegin(GL_TRIANGLE_STRIP);
+   glColor4fv(Red);
+   glSecondaryColor3fv_func(Green);
+   for (i = 0; i < 20; i++) {
+      float a = i / 19.0 * M_PI * 2.0;
+      float x = radius * cos(a);
+      float y = radius * sin(a);
+      glVertex3f(x, -1, y);
+      glVertex3f(x, +1, y);
+   }
+   glEnd();
+
+   glPopMatrix();
+
+   glutSwapBuffers();
+}
+
+
+static void
+Idle(void)
+{
+   int curTime = glutGet(GLUT_ELAPSED_TIME);
+   int dt = curTime - prevTime;
+
+   if (prevTime == 0) {
+      prevTime = curTime;
+      return;
+   }
+   prevTime = curTime;
+
+   Xrot += dt * 0.1;
+   glutPostRedisplay();
+}
+
+
+static void
+Reshape(int width, int height)
+{
+   float ar = (float) width / height;
+   glViewport(0, 0, width, height);
+   glMatrixMode(GL_PROJECTION);
+   glLoadIdentity();
+   glFrustum(-ar, ar, -1, 1, 3, 25);
+   glMatrixMode(GL_MODELVIEW);
+   glLoadIdentity();
+   glTranslatef(0, 0, -10);
+}
+
+
+static void
+CleanUp(void)
+{
+   glDeleteShader_func(fragShader);
+   glDeleteShader_func(vertShader);
+   glDeleteProgram_func(program);
+   glutDestroyWindow(win);
+}
+
+
+static void
+Key(unsigned char key, int x, int y)
+{
+  (void) x;
+  (void) y;
+
+   switch(key) {
+   case ' ':
+   case 'a':
+      anim = !anim;
+      if (anim) {
+         prevTime = glutGet(GLUT_ELAPSED_TIME);
+         glutIdleFunc(Idle);
+      }
+      else
+         glutIdleFunc(NULL);
+      break;
+   case 'f':
+      printf("Using frag shader gl_FrontFacing\n");
+      DetermineInFragProg = GL_TRUE;
+      break;
+   case 'v':
+      printf("Using vert shader Two-sided lighting\n");
+      DetermineInFragProg = GL_FALSE;
+      break;
+   case 'r':
+      /* reset */
+      Xrot = 30;
+      anim = 0;
+      glutIdleFunc(NULL);
+      break;
+   case 's':
+      Xrot += 5;
+      break;
+   case 'S':
+      Xrot -= 5;
+      break;
+   case 'w':
+      if (FrontWinding == GL_CCW) {
+         FrontWinding = GL_CW;
+         printf("FrontFace = GL_CW\n");
+      }
+      else {
+         FrontWinding = GL_CCW;
+         printf("FrontFace = GL_CCW\n");
+      }
+      break;
+   case 27:
+      CleanUp();
+      exit(0);
+      break;
+   }
+   glutPostRedisplay();
+}
+
+
+static void
+Init(void)
+{
+   static const char *fragShaderText =
+      "uniform bool fragface; \n"
+      "void main() { \n"
+#if 0
+      "   if (!fragface || gl_FrontFacing) { \n"
+      "      gl_FragColor = gl_Color; \n"
+      "   } \n"
+      "   else { \n"
+      "      gl_FragColor = 0.8 * gl_SecondaryColor; \n"
+      "   } \n"
+#else
+      "   bool f = gl_FrontFacing; \n"
+      "   if (f) { \n"
+      "      gl_FragColor = vec4(1.0, 0.0, 0.0, 0.0); \n"
+      "   } \n"
+      "   else { \n"
+      "      gl_FragColor = vec4(0.0, 1.0, 0.0, 0.0); \n"
+      "   } \n"
+      "   //float g = float(gl_FrontFacing) * 0.5 + 0.5; \n"
+      "   //gl_FragColor = vec4(g); \n"
+#endif
+      "} \n";
+   static const char *vertShaderText =
+      "uniform bool fragface; \n"
+      "void main() { \n"
+      "   gl_FrontColor = gl_Color; \n"
+      "   if (fragface) { \n"
+      "      // front/back chosen in frag prog \n"
+      "      gl_FrontSecondaryColor = gl_SecondaryColor; \n"
+      "   } \n"
+      "   else { \n"
+      "      // front/back chosen in prim setup \n"
+      "      gl_BackColor = gl_SecondaryColor; \n"
+      "   } \n"
+      "   gl_Position = ftransform(); \n"
+      "} \n";
+
+   if (!ShadersSupported())
+      exit(1);
+
+   GetExtensionFuncs();
+
+   vertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
+   fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
+   program = LinkShaders(vertShader, fragShader);
+
+   glUseProgram_func(program);
+
+   u_fragface = glGetUniformLocation_func(program, "fragface");
+   printf("Uniforms: %d\n", u_fragface);
+
+   /*assert(glGetError() == 0);*/
+
+   glClearColor(0.3f, 0.3f, 0.3f, 0.0f);
+
+   printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
+
+   assert(glIsProgram_func(program));
+   assert(glIsShader_func(fragShader));
+   assert(glIsShader_func(vertShader));
+
+   glEnable(GL_DEPTH_TEST);
+}
+
+
+static void
+ParseOptions(int argc, char *argv[])
+{
+   int i;
+   for (i = 1; i < argc; i++) {
+      if (strcmp(argv[i], "-fs") == 0) {
+         FragProgFile = argv[i+1];
+      }
+      else if (strcmp(argv[i], "-vs") == 0) {
+         VertProgFile = argv[i+1];
+      }
+   }
+}
+
+
+static void
+Usage(void)
+{
+   printf("Keys:\n");
+   printf("   f - do front/back determination in fragment shader\n");
+   printf("   v - do front/back determination in vertex shader\n");
+   printf("   r - reset, show front\n");
+   printf("   a - toggle animation\n");
+   printf("   s - step rotation\n");
+   printf("   w - toggle CW, CCW front-face winding\n");
+   printf("NOTE: red = front face, green = back face.\n");
+}
+
+
+int
+main(int argc, char *argv[])
+{
+   glutInit(&argc, argv);
+   glutInitWindowPosition( 0, 0);
+   glutInitWindowSize(WinWidth, WinHeight);
+   glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
+   win = glutCreateWindow(argv[0]);
+   glutReshapeFunc(Reshape);
+   glutKeyboardFunc(Key);
+   glutDisplayFunc(Redisplay);
+   if (anim)
+      glutIdleFunc(Idle);
+   ParseOptions(argc, argv);
+   Init();
+   Usage();
+   glutMainLoop();
+   return 0;
+}
index cc27024b568c94319fc54bbaaac9befd2c7caf36..e6f5fa558e9cd9711eabd17e52f82506824b0889 100644 (file)
@@ -20,6 +20,8 @@ INCLUDES = \
        -I. \
        -I$(TOP)/include
 
+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
+
 
 ##### RULES #####
 
@@ -27,7 +29,7 @@ INCLUDES = \
 .SUFFIXES: .c
 
 .c:
-       $(CC) $(INCLUDES) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@
+       $(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
 
 .c.o:
        $(CC) -c $(INCLUDES) $(CFLAGS) $< -o $@
@@ -41,8 +43,8 @@ INCLUDES = \
 default:  depend $(PROGS)
 
 clean:
-       rm -f $(PROGS)
-       rm -f *.o
+       -rm -f $(PROGS)
+       -rm -f *.o
 
 
 depend: $(SOURCES)
index f8cba9ee99a285c76d5386727f642a06568ae6e9..023ea02ae27021abbf97d81fda0556ac8d73beb9 100644 (file)
@@ -5,13 +5,19 @@ include $(TOP)/configs/current
 
 INCDIR = $(TOP)/include
 
-OSMESA_LIBS = -L$(TOP)/$(LIB_DIR) -lOSMesa $(APP_LIB_DEPS)
+OSMESA_LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(OSMESA_LIB) $(APP_LIB_DEPS)
 
-OSMESA16_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lOSMesa16 -lGLU -lGL $(APP_LIB_DEPS)
+OSMESA16_LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -lOSMesa16 -l$(GLU_LIB) \
+       -l$(GL_LIB) $(APP_LIB_DEPS)
 
-OSMESA32_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lOSMesa32 -lGLU -lGL $(APP_LIB_DEPS)
+OSMESA32_LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -lOSMesa32 -l$(GLU_LIB) \
+       -l$(GL_LIB) $(APP_LIB_DEPS)
 
-LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
+LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
+       $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
+
+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) \
+       $(APP_LIB_DEPS)
 
 PROGS = \
        osdemo \
@@ -26,7 +32,7 @@ PROGS = \
 
 # make executable from .c file:
 .c: $(LIB_DEP) readtex.o
-       $(CC) -I$(INCDIR) $(CFLAGS) $< readtex.o $(APP_LIB_DEPS) -o $@
+       $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< readtex.o $(LIBS) -o $@
 
 
 ##### TARGETS #####
@@ -56,19 +62,19 @@ showbuffer.o: showbuffer.c showbuffer.h
 
 # special case: need the -lOSMesa library:
 osdemo: osdemo.c
-       $(CC) -I$(INCDIR) $(CFLAGS) osdemo.c $(OSMESA_LIBS) -o $@
+       $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) osdemo.c $(OSMESA_LIBS) -o $@
 
 # special case: need the -lOSMesa library:
 ostest1: ostest1.c
-       $(CC) -I$(INCDIR) $(CFLAGS) ostest1.c $(OSMESA_LIBS) -o $@
+       $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) ostest1.c $(OSMESA_LIBS) -o $@
 
 # another special case: need the -lOSMesa16 library:
 osdemo16: osdemo16.c
-       $(CC) -I$(INCDIR) $(CFLAGS) osdemo16.c $(OSMESA16_LIBS) -o $@
+       $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) osdemo16.c $(OSMESA16_LIBS) -o $@
 
 # another special case: need the -lOSMesa32 library:
 osdemo32: osdemo32.c
-       $(CC) -I$(INCDIR) $(CFLAGS) osdemo32.c $(OSMESA32_LIBS) -o $@
+       $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) osdemo32.c $(OSMESA32_LIBS) -o $@
 
 
 
index 2c7adfc3537aeb8d0a422e462c892e8d61333db6..000b8c4a78150c79584a04f3887735ba9b732deb 100644 (file)
@@ -407,7 +407,10 @@ test(GLenum type, GLint bits, const char *filename)
    glGetIntegerv(GL_ALPHA_BITS, &cBits);
    assert(cBits == bits);
 
-   printf("Rendering %d bit/channel image: %s\n", bits, filename);
+   if (WriteFiles)
+      printf("Rendering %d bit/channel image: %s\n", bits, filename);
+   else
+      printf("Rendering %d bit/channel image\n", bits);
 
    OSMesaColorClamp(GL_TRUE);
 
@@ -458,6 +461,8 @@ main( int argc, char *argv[] )
 {
    int i;
 
+   printf("Use -f to write image files\n");
+
    for (i = 1; i < argc; i++) {
       if (strcmp(argv[i], "-f") == 0)
          WriteFiles = GL_TRUE;
index 956c398873a196665c84447754df3f0852835f25..0ba5fbbb986ed91d106427e47daca7e23c6bdb3f 100644 (file)
@@ -7,6 +7,8 @@ INCDIR = $(TOP)/include
 
 LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
 
+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
+
 PROGS = aaindex aapoly aargb accanti accpersp alpha alpha3D anti \
        bezcurve bezmesh checker clip colormat cube depthcue dof \
        double drawf feedback fog fogindex font hello image light \
@@ -24,7 +26,7 @@ PROGS = aaindex aapoly aargb accanti accpersp alpha alpha3D anti \
 .SUFFIXES: .c
 
 .c: $(LIB_DEP)
-       $(APP_CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@
+       $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
 
 
 
index 25ce14740a844535577aa127617712ea7ebf25dd..63dca07d2e851b19c51b97b1e06ac46ff5412ded 100644 (file)
@@ -7,6 +7,8 @@ INCDIR = $(TOP)/include
 
 LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
 
+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
+
 PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \
        font line logo nurb olympic overlay point prim quad select \
        shape sphere star stencil stretch texture tri wave
@@ -18,7 +20,7 @@ PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \
 .SUFFIXES: .c
 
 .c: $(LIB_DEP)
-       $(APP_CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@
+       $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
 
 
 ##### TARGETS #####
@@ -27,7 +29,7 @@ default: $(PROGS)
 
 
 sphere: sphere.o readtex.o
-       $(APP_CC) -I$(INCDIR) $(CFLAGS) sphere.o readtex.o $(APP_LIB_DEPS) -o $@
+       $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) sphere.o readtex.o $(LIBS) -o $@
 
 sphere.o: sphere.c readtex.h
        $(APP_CC) -c -I$(INCDIR) $(CFLAGS) sphere.c
diff --git a/progs/samples/Makefile.mgw b/progs/samples/Makefile.mgw
new file mode 100644 (file)
index 0000000..8bb975b
--- /dev/null
@@ -0,0 +1,78 @@
+# 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 samples makefile v1.2 for Mesa
+#
+#  Copyright (C) 2002 - Daniel Borca
+#  Email : dborca@users.sourceforge.net
+#  Web   : http://www.geocities.com/dborca
+
+# MinGW samples makefile updated for Mesa 7.0
+#
+#  Updated : by Heromyth, on 2007-7-21
+#  Email   : zxpmyth@yahoo.com.cn
+#  Bugs    : 1) All the default settings work fine. But the setting X86=1 can't work. 
+#            The others havn't been tested yet.
+#            2) The generated DLLs are *not* compatible with the ones built
+#            with the other compilers like VC8, especially for GLUT. 
+#            3) Although more tests are needed, it can be used individually!
+
+#
+#  Available options:
+#
+#    Environment variables:
+#
+#    Targets:
+#      <file.exe>      build a specific file
+#
+
+
+
+.PHONY: all
+.SUFFIXES: .c .o .exe
+.SECONDARY: ../util/readtex.o ../util/showbuffer.o
+
+TOP = ../..
+
+CC = mingw32-gcc
+CFLAGS = -Wall -pedantic
+CFLAGS += -O2 -ffast-math -D_DLL
+CFLAGS += -I$(TOP)/include -I../util
+ifeq ($(FX),1)
+  CFLAGS += -DFX
+endif
+
+CFLAGS += -DGLUT_DISABLE_ATEXIT_HACK
+
+LD = mingw32-g++
+LDFLAGS = -s -L$(TOP)/lib
+
+LDLIBS = -lglut32 -lglu32 -lopengl32
+
+.c.o:
+       $(CC) -o $@ $(CFLAGS) -c $<
+%.exe: ../util/readtex.o ../util/showbuffer.o %.o
+       $(LD) -o $@ $(LDFLAGS) $(LDLIBS) $^
+
+
+all:
+       $(error Must specify <filename.exe> to build)
index f78afd303815bf20b4a5af7bbf79e46918e8d604..d5143ecdf5c7491f1bac58986afa0a12fc5e6336 100644 (file)
@@ -25,6 +25,27 @@ static int doPrint = 1;
 static int deltaY;
 GLint windW, windH;
 
+static const struct {
+   GLenum mode;
+   const char *name;
+} LogicOpModes[] = {
+   { GL_SET, "GL_SET" },
+   { GL_COPY, "GL_COPY" },
+   { GL_NOOP, "GL_NOOP" },
+   { GL_AND, "GL_AND" },
+   { GL_INVERT, "GL_INVERT" },
+   { GL_OR, "GL_OR" },
+   { GL_XOR, "GL_XOR" },
+   { GL_NOR, "GL_NOR" },
+   { GL_NAND, "GL_NAND" },
+   { GL_OR_REVERSE, "GL_OR_REVERSE" },
+   { GL_OR_INVERTED, "GL_OR_INVERTED" },
+   { GL_AND_INVERTED, "GL_AND_INVERTED" },
+   { 0, NULL }
+};
+
+
+
 static void DrawString(const char *string)
 {
     int i;
@@ -47,7 +68,7 @@ static void Reshape(int width, int height)
     windH = (GLint)height;
 
     glViewport(0, 0, (GLint)width, (GLint)height);
-    deltaY = windH /16;
+    deltaY = windH /20;
 
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
@@ -105,7 +126,7 @@ static void Draw(void)
 {
     int stringOffset = 5, stringx = 8;
     int x1, x2, xleft, xright;
-    int i;
+    int i, k;
 
     (dithering) ? glEnable(GL_DITHER) : glDisable(GL_DITHER);
     glDisable(GL_BLEND);
@@ -122,6 +143,7 @@ static void Draw(void)
     /* Draw labels */
     glColor3f(0.8, 0.8, 0.0);
     i = windH - deltaY + stringOffset;
+
     glRasterPos2f(stringx, i); i -= deltaY;
     DrawString("SOURCE");
     glRasterPos2f(stringx, i); i -= deltaY;
@@ -136,21 +158,12 @@ static void Draw(void)
     DrawString("reverse_subtract");
     glRasterPos2f(stringx, i); i -= deltaY;
     DrawString("clear");
-    glRasterPos2f(stringx, i); i -= deltaY;
-    DrawString("set");
-    glRasterPos2f(stringx, i); i -= deltaY;
-    DrawString("copy");
-    glRasterPos2f(stringx, i); i -= deltaY;
-    DrawString("noop");
-    glRasterPos2f(stringx, i); i -= deltaY;
-    DrawString("and");
-    glRasterPos2f(stringx, i); i -= deltaY;
-    DrawString("invert");
-    glRasterPos2f(stringx, i); i -= deltaY;
-    DrawString("or");
-    glRasterPos2f(stringx, i); i -= deltaY;
-    DrawString("xor");
 
+    for (k = 0; LogicOpModes[k].name; k++) {
+       glRasterPos2f(stringx, i);
+       i -= deltaY;
+       DrawString(LogicOpModes[k].name);
+    }
 
     i = windH - deltaY;
     x1 = windW/4;
@@ -193,43 +206,23 @@ static void Draw(void)
     glLogicOp(GL_CLEAR);
     glRectf(x1, i, x2, i+deltaY);
 
-    i -= deltaY;
-    glLogicOp(GL_SET);
-    glRectf(x1, i, x2, i+deltaY);
-
-    i -= deltaY;
-    glLogicOp(GL_COPY);
-    glRectf(x1, i, x2, i+deltaY);
-
-    i -= deltaY;
-    glLogicOp(GL_NOOP);
-    glRectf(x1, i, x2, i+deltaY);
-
-    i -= deltaY;
-    glLogicOp(GL_AND);
-    glRectf(x1, i, x2, i+deltaY);
-
-    i -= deltaY;
-    glLogicOp(GL_INVERT);
-    glRectf(x1, i, x2, i+deltaY);
-
-    i -= deltaY;
-    glLogicOp(GL_OR);
-    glRectf(x1, i, x2, i+deltaY);
-
-    i -= deltaY;
-    glLogicOp(GL_XOR);
-    glRectf(x1, i, x2, i+deltaY);
-    glRectf(x1, i+10, x2, i+5);
+    for (k = 0; LogicOpModes[k].name; k++) {
+       i -= deltaY;
+       glLogicOp(LogicOpModes[k].mode);
+       glRectf(x1, i, x2, i+deltaY);
+       if (LogicOpModes[k].mode == GL_XOR) {
+          glRectf(x1, i+10, x2, i+5);
+       }
+    }
 
-  if (doPrint) {
-      glDisable(GL_BLEND);
-      if (supportlogops & 2)
+    if (doPrint) {
+       glDisable(GL_BLEND);
+       if (supportlogops & 2)
           glDisable(GL_COLOR_LOGIC_OP);
-      glColor3f(1.0, 1.0, 1.0);
-      PrintColorStrings();
-  }
-  glFlush();
+       glColor3f(1.0, 1.0, 1.0);
+       PrintColorStrings();
+    }
+    glFlush();
 
     if (doubleBuffer) {
        glutSwapBuffers();
@@ -271,7 +264,7 @@ int main(int argc, char **argv)
        exit(1);
     }
 
-    glutInitWindowPosition(0, 0); glutInitWindowSize( 800, 400);
+    glutInitWindowPosition(0, 0); glutInitWindowSize( 800, 520);
 
     type = GLUT_RGB;
     type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
index 1c602ce49c510f897411b39938bd380698b63a81..f6f34fcd25f11b3531703f3c3e3e94a3fde2df23 100644 (file)
@@ -8,6 +8,8 @@ INCDIR = $(TOP)/include
 
 LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
 
+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
+
 #
 # targets
 #
@@ -22,34 +24,34 @@ tests: default
        ! ./cltest 2> /dev/null | (grep -e ^[*][*][*])
 
 clean:
-       rm -f cltest.o sotest.o vstest.o framework.o cltest sotest vstest
+       -rm -f cltest.o sotest.o vstest.o framework.o cltest sotest vstest
 
 #
 # executables
 #
 
 cltest: cltest.o framework.o $(LIB_DEP)
-       $(CC) cltest.o framework.o $(APP_LIB_DEPS) -o cltest
+       $(CC) $(CFLAGS) $(LDFLAGS) cltest.o framework.o $(LIBS) -o cltest
 
 sotest: sotest.o framework.o $(LIB_DEP)
-       $(CC) sotest.o framework.o $(APP_LIB_DEPS) -o sotest
+       $(CC) $(CFLAGS) $(LDFLAGS) sotest.o framework.o $(LIBS) -o sotest
 
 vstest: vstest.o framework.o $(LIB_DEP)
-       $(CC) vstest.o framework.o $(APP_LIB_DEPS) -o vstest
+       $(CC) $(CFLAGS) $(LDFLAGS) vstest.o framework.o $(LIBS) -o vstest
 
 #
 # objects
 #
 
 framework.o: framework.c framework.h
-       $(CC) -c -I$(INCDIR) framework.c -o framework.o
+       $(CC) -c -I$(INCDIR) $(CFLAGS) framework.c -o framework.o
 
 cltest.o: cltest.c framework.h
-       $(CC) -c -I$(INCDIR) cltest.c -o cltest.o
+       $(CC) -c -I$(INCDIR) $(CFLAGS) cltest.c -o cltest.o
 
 sotest.o: sotest.c framework.h
-       $(CC) -c -I$(INCDIR) sotest.c -o sotest.o
+       $(CC) -c -I$(INCDIR) $(CFLAGS) sotest.c -o sotest.o
 
 vstest.o: vstest.c framework.h
-       $(CC) -c -I$(INCDIR) vstest.c -o vstest.o
+       $(CC) -c -I$(INCDIR) $(CFLAGS) vstest.c -o vstest.o
 
index 40cb6850fb9b52e8b015441e8349255f6b2944ad..c5b9e28dab14d91b5c6c2247e1678fc733435a3e 100644 (file)
@@ -26,6 +26,7 @@ cva
 dinoshade
 drawbuffers
 extfuncs.h
+exactrast
 fbotest1
 fbotest2
 fbotexture
@@ -40,6 +41,7 @@ getproclist.h
 interleave
 invert
 jkrahntest
+lineclip
 manytex
 minmag
 mipmap_limits
@@ -56,6 +58,9 @@ readtex.c
 readtex.h
 seccolor
 sharedtex
+shader_api
+stencil_twoside
+stencil_wrap
 stencilwrap
 stencil_wrap
 subtex
@@ -69,6 +74,7 @@ texline
 texobjshare
 texrect
 texwrap
+unfilledclip
 vao-01
 vao-02
 vparray
index 9c81f870d88504b391f2da8033f4b03169adaac4..94473fc59d1d5296e120f6cda8778495ab763896 100644 (file)
@@ -8,7 +8,7 @@ TOP = ../..
 include $(TOP)/configs/current
 
 
-LIBS = $(APP_LIB_DEPS)
+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
 
 SOURCES = \
        afsmultiarb.c \
@@ -37,6 +37,7 @@ SOURCES = \
        cva.c \
        dinoshade.c \
        drawbuffers.c \
+       exactrast.c \
        floattex.c \
        fbotest1.c \
        fbotest2.c \
@@ -50,6 +51,7 @@ SOURCES = \
        interleave.c \
        invert.c \
        jkrahntest.c \
+       lineclip.c \
        manytex.c \
        minmag.c \
        mipmap_limits.c \
@@ -64,7 +66,9 @@ SOURCES = \
        random.c \
        readrate.c \
        seccolor.c \
+       shader_api.c \
        sharedtex.c \
+       stencil_twoside.c \
        stencilwrap.c \
        stencil_wrap.c \
        subtex \
@@ -76,6 +80,7 @@ SOURCES = \
        texobjshare.c \
        texrect.c \
        texwrap.c \
+       unfilledclip.c \
        vao-01.c \
        vao-02.c \
        vparray.c \
@@ -97,13 +102,22 @@ INCLUDES = -I. -I$(TOP)/include
 UTIL_FILES = readtex.h readtex.c
 
 
+##### TARGETS #####
+
+default: $(UTIL_FILES) $(PROGS)
+
+clean:
+       -rm -f $(PROGS)
+       -rm -f *.o
+       -rm -f getproclist.h
+
 ##### RULES #####
 
 .SUFFIXES:
 .SUFFIXES: .c
 
 .c:
-       $(APP_CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@
+       $(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
 
 .c.o:
        $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
@@ -111,17 +125,6 @@ UTIL_FILES = readtex.h readtex.c
 .S.o:
        $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES)  $< -o $@
 
-
-##### TARGETS #####
-
-default: $(UTIL_FILES) $(PROGS)
-
-clean:
-       rm -f $(PROGS)
-       rm -f *.o
-       rm -f getproclist.h
-
-
 # auto code generation
 getprocaddress: getprocaddress.c getproclist.h
 
@@ -132,37 +135,37 @@ arraytexture: arraytexture.o readtex.o
        $(APP_CC) $(CFLAGS) arraytexture.o readtex.o $(LIBS) -o $@
 
 arraytexture.o: arraytexture.c readtex.h
-       $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+       $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) arraytexture.c -o $@
 
 afsmultiarb: afsmultiarb.o readtex.o
-       $(APP_CC) $(CFLAGS) afsmultiarb.o readtex.o $(LIBS) -o $@
+       $(APP_CC) $(CFLAGS) $(LDFLAGS) afsmultiarb.o readtex.o $(LIBS) -o $@
 
 afsmultiarb.o: afsmultiarb.c readtex.h
-       $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+       $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) afsmultiarb.c -o $@
 
 drawbuffers: drawbuffers.o
-       $(APP_CC) $(CFLAGS) drawbuffers.o $(LIBS) -o $@
+       $(APP_CC) $(CFLAGS) $(LDFLAGS) drawbuffers.o $(LIBS) -o $@
 
 drawbuffers.o: drawbuffers.c extfuncs.h
-       $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+       $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) drawbuffers.c -o $@
 
 texrect: texrect.o readtex.o
-       $(APP_CC) $(CFLAGS) texrect.o readtex.o $(LIBS) -o $@
+       $(APP_CC) $(CFLAGS) $(LDFLAGS) texrect.o readtex.o $(LIBS) -o $@
 
 texrect.o: texrect.c readtex.h
-       $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+       $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) texrect.c -o $@
 
 bug_3195: bug_3195.o readtex.o
-       $(APP_CC) $(CFLAGS) bug_3195.o readtex.o $(LIBS) -o $@
+       $(APP_CC) $(CFLAGS) $(LDFLAGS) bug_3195.o readtex.o $(LIBS) -o $@
 
 bug_3195.o: bug_3195.c readtex.h
-       $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+       $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) bug_3195.c -o $@
 
 invert: invert.o readtex.o
-       $(APP_CC) $(CFLAGS) invert.o readtex.o $(LIBS) -o $@
+       $(APP_CC) $(CFLAGS) $(LDFLAGS) invert.o readtex.o $(LIBS) -o $@
 
 invert.o: invert.c readtex.h
-       $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+       $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) invert.c -o $@
 
 mipmap_view: mipmap_view.o readtex.o
        $(APP_CC) $(CFLAGS) mipmap_view.o readtex.o $(LIBS) -o $@
@@ -180,7 +183,7 @@ fillrate.o: fillrate.c readtex.h
 
 
 readtex.o: readtex.c
-       $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+       $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) readtex.c -o $@
 
 
 readtex.h: $(TOP)/progs/util/readtex.h
index 3a83c34b8d085f89b083eb84c03b74a70722789e..f23b5aff3248e2fa822743da46e5bb4b87aa9c92 100644 (file)
@@ -15,6 +15,7 @@
 static GLfloat Zrot = 0;
 static GLboolean Anim = GL_TRUE;
 static GLboolean HaveMultisample = GL_TRUE;
+static GLboolean DoMultisample = GL_TRUE;
 
 
 static void
@@ -85,7 +86,10 @@ Display( void )
    glColor3f(1, 1, 1);
    if (HaveMultisample) {
       glRasterPos2f(-3.1, -1.6);
-      PrintString("MULTISAMPLE");
+      if (DoMultisample)
+         PrintString("MULTISAMPLE");
+      else
+         PrintString("MULTISAMPLE (off)");
    }
    glRasterPos2f(-0.8, -1.6);
    PrintString("No antialiasing");
@@ -95,7 +99,8 @@ Display( void )
    /* multisample */
    if (HaveMultisample) {
       glEnable(GL_DEPTH_TEST);
-      glEnable(GL_MULTISAMPLE_ARB);
+      if (DoMultisample)
+         glEnable(GL_MULTISAMPLE_ARB);
       glPushMatrix();
       glTranslatef(-2.5, 0, 0);
       glPushMatrix();
@@ -172,6 +177,9 @@ Key( unsigned char key, int x, int y )
          else
             glutIdleFunc(NULL);
          break;
+      case 'm':
+         DoMultisample = !DoMultisample;
+         break;
       case 'z':
          Zrot = (int) (Zrot - step);
          break;
index a47b2a9319a3f6f09975d7360e58ec2760c70c74..a9393aef0ca5fcf1b959111fc2b1144e04efd32a 100644 (file)
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#ifdef __VMS
-# include <stddef.h>   /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
-#else
-# include <malloc.h>   /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
-#endif
+#include <stddef.h>    /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
 #ifdef _WIN32
 #include <windows.h>
 #endif
 #define GL_GLEXT_LEGACY
 #include <GL/glut.h>
-
+#include <GL/glext.h>
 
 GLfloat verts[][4] = {
    { -0.5, -0.5, -2.0, 0.0 },
index ed7b879bc719ba13a1271272dc9dbe4b6f58de1e..504b4af526a2f63899c54a339d83f0a012cc3e39 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 #include <math.h>       /* for cos(), sin(), and sqrt() */
-#ifdef __VMS
-# include <stddef.h>   /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
-#else
-# include <malloc.h>   /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
-#endif
+#include <stddef.h>    /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
 #ifdef _WIN32
 #include <windows.h>
 #endif
diff --git a/progs/tests/exactrast.c b/progs/tests/exactrast.c
new file mode 100644 (file)
index 0000000..56c0c79
--- /dev/null
@@ -0,0 +1,200 @@
+/**
+ * Test for exact point/line/polygon rasterization, or at least rasterization
+ * that fits the tolerance of the OpenGL spec.
+ *
+ * Brian Paul
+ * 9 Nov 2007
+ */
+
+/*
+ * Notes:
+ * - 'm' to cycle through point, hline, vline and quad drawing
+ * - Use cursor keys to translate coordinates (z to reset)
+ * - Resize window to check for proper rasterization
+ * - Make sure your LCD is running in its native resolution
+ *   
+ * If translation is (0,0):
+ *  a point will be drawn where x%2==0 and y%2==0,
+ *  a horizontal line will be drawn where x%2==0,
+ *  a vertical line will be drawn where y%2==0,
+ *  for quads, pixels will be set where (x%4)!=3 and (y%4)!=3
+ *
+ * XXX todo: do glReadPixels and test that the results are what's expected.
+ * Upon failure, iterate over sub-pixel translations to find the ideal offset.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+static int Width = 400, Height = 400;
+static int Win;
+static float Xtrans = 0, Ytrans = 0;
+static float Step = 0.125;
+
+enum {
+   POINTS,
+   HLINES,
+   VLINES,
+   QUADS,
+   NUM_MODES
+};
+
+static int Mode = POINTS;
+
+
+static void
+Draw(void)
+{
+   /* See the OpenGL Programming Guide, Appendix H, "OpenGL Correctness Tips"
+    * for information about the 0.375 translation factor.
+    */
+   float tx = 0.375, ty = 0.375;
+   int i, j;
+
+   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+   glPushMatrix();
+   glTranslatef(tx + Xtrans, ty + Ytrans, 0);
+
+   if (Mode == POINTS) {
+      glBegin(GL_POINTS);
+      for (j = 0; j < Height; j += 2) {
+         for (i = 0; i < Width; i += 2) {
+            glVertex2f(i, j);
+         }
+      }
+      glEnd();
+   }
+   else if (Mode == HLINES) {
+      glBegin(GL_LINES);
+      for (i = 0; i < Height; i += 2) {
+         glVertex2f(0,     i);
+         glVertex2f(Width, i);
+      }
+      glEnd();
+   }
+   else if (Mode == VLINES) {
+      glBegin(GL_LINES);
+      for (i = 0; i < Width; i += 2) {
+         glVertex2f(i, 0     );
+         glVertex2f(i, Height);
+      }
+      glEnd();
+   }
+   else if (Mode == QUADS) {
+      glBegin(GL_QUADS);
+      for (j = 0; j < Height; j += 4) {
+         for (i = 0; i < Width; i += 4) {
+            glVertex2f(i,     j    );
+            glVertex2f(i + 3, j    );
+            glVertex2f(i + 3, j + 3);
+            glVertex2f(i,     j + 3);
+         }
+      }
+      glEnd();
+   }
+
+   glPopMatrix();
+
+   glutSwapBuffers();
+}
+
+
+static void
+Reshape(int width, int height)
+{
+   Width = width;
+   Height = height;
+   glViewport(0, 0, width, height);
+   glMatrixMode(GL_PROJECTION);
+   glLoadIdentity();
+   glOrtho(0, width, 0, height, -1, 1);
+   glMatrixMode(GL_MODELVIEW);
+   glLoadIdentity();
+}
+
+
+static void
+Key(unsigned char key, int x, int y)
+{
+   (void) x;
+   (void) y;
+   switch (key) {
+   case 'm':
+   case 'M':
+      Mode = (Mode + 1) % NUM_MODES;
+      break;
+   case 'z':
+   case 'Z':
+      Xtrans = Ytrans = 0;
+      printf("Translation: %f, %f\n", Xtrans, Ytrans);
+      break;
+   case 27:
+      glutDestroyWindow(Win);
+      exit(0);
+      break;
+   }
+   glutPostRedisplay();
+}
+
+
+static void
+SpecialKey(int key, int x, int y)
+{
+   (void) x;
+   (void) y;
+   switch (key) {
+   case GLUT_KEY_UP:
+      Ytrans += Step;
+      break;
+   case GLUT_KEY_DOWN:
+      Ytrans -= Step;
+      break;
+   case GLUT_KEY_LEFT:
+      Xtrans -= Step;
+      break;
+   case GLUT_KEY_RIGHT:
+      Xtrans += Step;
+      break;
+   }
+   glutPostRedisplay();
+   printf("Translation: %f, %f\n", Xtrans, Ytrans);
+}
+
+
+static void
+Init(void)
+{
+}
+
+
+static void
+Usage(void)
+{
+   printf("Keys:\n");
+   printf("  up/down/left/right - translate by %f\n", Step);
+   printf("  z - reset translation to zero\n");
+   printf("  m - change rendering mode (points, hlines, vlines, quads)\n");
+   printf("  Esc - exit\n");
+}
+
+
+int
+main(int argc, char *argv[])
+{
+   glutInit(&argc, argv);
+   glutInitWindowPosition(0, 0);
+   glutInitWindowSize(Width, Height);
+   glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
+   Win = glutCreateWindow(argv[0]);
+   glutReshapeFunc(Reshape);
+   glutKeyboardFunc(Key);
+   glutSpecialFunc(SpecialKey);
+   glutDisplayFunc(Draw);
+   Init();
+   Usage();
+   glutMainLoop();
+   return 0;
+}
index aa9f6171221ce5950b7d60e22dc38166f06a9d0d..88d0549c8081721cc90886efcee7f08ddca124d2 100644 (file)
@@ -38,6 +38,8 @@ static GLfloat Rot = 0.0;
 static GLboolean UsePackedDepthStencil = GL_FALSE;
 static GLuint TextureLevel = 1;  /* which texture level to render to */
 static GLenum TexIntFormat = GL_RGB; /* either GL_RGB or GL_RGBA */
+static GLboolean Cull = GL_FALSE;
+static GLboolean Wireframe = GL_FALSE;
 
 
 static void
@@ -115,6 +117,22 @@ RenderTexture(void)
 
    CheckError(__LINE__);
 
+   if (Wireframe) {
+      glPolygonMode(GL_FRONT, GL_LINE);
+   }
+   else {
+      glPolygonMode(GL_FRONT, GL_FILL);
+   }
+
+   if (Cull) {
+      /* cull back */
+      glCullFace(GL_BACK);
+      glEnable(GL_CULL_FACE);
+   }
+   else {
+      glDisable(GL_CULL_FACE);
+   }
+
 #if 0
    glBegin(GL_POLYGON);
    glColor3f(1, 0, 0);
@@ -129,7 +147,9 @@ RenderTexture(void)
    glEnable(GL_LIGHT0);
    glPushMatrix();
    glRotatef(0.5 * Rot, 1.0, 0.0, 0.0);
+   glFrontFace(GL_CW); /* Teapot patches backward */
    glutSolidTeapot(0.5);
+   glFrontFace(GL_CCW);
    glPopMatrix();
    glDisable(GL_LIGHTING);
    /*
@@ -139,6 +159,8 @@ RenderTexture(void)
 
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_STENCIL_TEST);
+   glDisable(GL_CULL_FACE);
+   glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
 
 #if DRAW
    /* Bind normal framebuffer */
@@ -245,24 +267,45 @@ Key(unsigned char key, int x, int y)
    (void) x;
    (void) y;
    switch (key) {
-      case 'a':
-         Anim = !Anim;
-         if (Anim)
-            glutIdleFunc(Idle);
-         else
-            glutIdleFunc(NULL);
-         break;
-      case 's':
-         Rot += 2.0;
-         break;
-      case 27:
-         CleanUp();
-         break;
+   case 'a':
+      Anim = !Anim;
+      if (Anim)
+         glutIdleFunc(Idle);
+      else
+         glutIdleFunc(NULL);
+      break;
+   case 'c':
+      Cull = !Cull;
+      break;
+   case 'w':
+      Wireframe = !Wireframe;
+      break;
+   case 's':
+      Rot += 2.0;
+      break;
+   case 'S':
+      Rot -= 2.0;
+      break;
+   case 27:
+      CleanUp();
+      break;
    }
    glutPostRedisplay();
 }
 
 
+static void
+Usage(void)
+{
+   printf("Usage:\n");
+   printf("  a    Toggle animation\n");
+   printf("  s/s  Step/rotate\n");
+   printf("  c    Toggle back-face culling\n");
+   printf("  w    Toggle wireframe mode (front-face only)\n");
+   printf("  Esc  Exit\n");
+}
+
+
 static void
 Init(int argc, char *argv[])
 {
@@ -402,6 +445,7 @@ main(int argc, char *argv[])
    if (Anim)
       glutIdleFunc(Idle);
    Init(argc, argv);
+   Usage();
    glutMainLoop();
    return 0;
 }
diff --git a/progs/tests/lineclip.c b/progs/tests/lineclip.c
new file mode 100644 (file)
index 0000000..098f5e9
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ * Copyright Â© 2008 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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:
+ *    Eric Anholt <eric@anholt.net>
+ *
+ */
+
+#include <stdlib.h>
+#include <GL/glut.h>
+
+static int win_width, win_height;
+
+static void
+line(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
+{
+       glBegin(GL_LINES);
+       glVertex2f(x1, y1);
+       glVertex2f(x2, y2);
+       glEnd();
+}
+
+static void
+line3(GLfloat x1, GLfloat y1, GLfloat z1, GLfloat x2, GLfloat y2, GLfloat z2)
+{
+       glBegin(GL_LINES);
+       glVertex3f(x1, y1, z1);
+       glVertex3f(x2, y2, z2);
+       glEnd();
+}
+
+static void
+display(void)
+{
+       glClearColor(0.0, 0.0, 0.0, 0.0);
+       glClear(GL_COLOR_BUFFER_BIT);
+
+       glColor3f(1.0, 0.0, 0.0);
+       /* 2 lines clipped along xmin */
+       line(-20, win_height / 2 - 20,
+             20, win_height / 2 - 20);
+       line( 20, win_height / 2 + 20,
+            -20, win_height / 2 + 20);
+
+       glColor3f(0.0, 1.0, 0.0);
+       /* 2 lines clipped along ymax */
+       line(win_width / 2 - 20, win_height + 20,
+            win_width / 2 - 20, win_height - 20);
+       line(win_width / 2 + 20, win_height - 20,
+            win_width / 2 + 20, win_height + 20);
+
+       glColor3f(0.0, 0.0, 1.0);
+       /* 2 lines clipped along xmax */
+       line(win_width - 20, win_height / 2 - 20,
+            win_width + 20, win_height / 2 - 20);
+       line(win_width + 20, win_height / 2 + 20,
+            win_width - 20, win_height / 2 + 20);
+
+       glColor3f(1.0, 1.0, 1.0);
+       /* 2 lines clipped along ymin */
+       line(win_width / 2 - 20,  20,
+            win_width / 2 - 20, -20);
+       line(win_width / 2 + 20, -20,
+            win_width / 2 + 20,  20);
+
+       /* 2 lines clipped along near */
+       glColor3f(1.0, 0.0, 1.0);
+       line3(win_width / 2 - 20 - 20, win_height / 2,       0.5,
+             win_width / 2 - 20 + 20, win_height / 2,      -0.5);
+       line3(win_width / 2 - 20,      win_height / 2 - 20, -0.5,
+             win_width / 2 - 20,      win_height / 2 + 20,  0.5);
+
+       /* 2 lines clipped along far */
+       glColor3f(0.0, 1.0, 1.0);
+       line3(win_width / 2 + 20 - 20, win_height / 2,      1.5,
+             win_width / 2 + 20 + 20, win_height / 2,      0.5);
+       line3(win_width / 2 + 20,      win_height / 2 - 20, 0.5,
+             win_width / 2 + 20,      win_height / 2 + 20, 1.5);
+
+       /* entirely clipped along near/far */
+       glColor3f(.5, .5, .5);
+       line3(win_width / 2, win_height / 2 - 20, -0.5,
+             win_width / 2, win_height / 2 + 20, -0.5);
+       glColor3f(.5, .5, .5);
+       line3(win_width / 2, win_height / 2 - 20, 1.5,
+             win_width / 2, win_height / 2 + 20, 1.5);
+
+       glColor3f(1.0, 1.0, 0.0);
+       /* lines clipped along both x and y limits */
+       line(-5, 20,
+            20, -5); /* xmin, ymin */
+       line(-5, win_height - 20,
+            20, win_height + 5); /* xmin, ymax */
+       line(win_width - 20, -5,
+            win_width + 5,  20); /* xmax, ymin */
+       line(win_width - 20, win_height + 5,
+            win_width + 5,  win_height - 20); /* xmax, ymax */
+
+       glutSwapBuffers();
+}
+
+static void
+reshape(int width, int height)
+{
+       win_width = width;
+       win_height = height;
+       glViewport(0, 0, width, height);
+
+       glMatrixMode(GL_PROJECTION);
+       glLoadIdentity();
+       glOrtho(0, win_width, 0, win_height, 0.0, -1.0);
+
+       glMatrixMode(GL_MODELVIEW);
+       glLoadIdentity();
+       glTranslatef(.25, .25, 0);
+}
+
+static void key( unsigned char key, int x, int y )
+{
+       (void) x;
+       (void) y;
+
+       switch (key) {
+       case 27: /* esc */
+               exit(0);
+               break;
+       }
+
+       glutPostRedisplay();
+}
+
+static void
+init(void)
+{
+}
+
+int
+main(int argc, char *argv[])
+{
+       win_width = 200;
+       win_height = 200;
+
+       glutInit(&argc, argv);
+       glutInitWindowPosition(0, 0);
+       glutInitWindowSize(win_width, win_height);
+       glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+       glutCreateWindow(argv[0]);
+       glutReshapeFunc(reshape);
+       glutKeyboardFunc(key);
+       glutDisplayFunc(display);
+
+       init();
+
+       glutMainLoop();
+       return 0;
+}
index 52818fca7eea1ccbe96d6c878a077155732f15d6..7bd44735659b4f4819a927ce750e74442667d138 100644 (file)
@@ -8,11 +8,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#ifdef __VMS
-# include <stddef.h>   /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
-#else
-# include <malloc.h>   /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
-#endif
+#include <stddef.h>    /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */
 #ifdef _WIN32
 #include <windows.h>
 #endif
diff --git a/progs/tests/shader_api.c b/progs/tests/shader_api.c
new file mode 100644 (file)
index 0000000..598f029
--- /dev/null
@@ -0,0 +1,337 @@
+/* Tests to validate fixes to various bugs in src/mesa/shader/shader_api.c
+ *
+ * Written by Bruce Merry
+ */
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+static void assert_test(const char *file, int line, int cond, const char *msg)
+{
+   if (!cond)
+      fprintf(stderr, "%s:%d assertion \"%s\" failed\n", file, line, msg);
+}
+
+#undef assert
+#define assert(x) assert_test(__FILE__, __LINE__, (x), #x)
+
+static void assert_no_error_test(const char *file, int line)
+{
+   GLenum err;
+
+   err = glGetError();
+   if (err != GL_NO_ERROR)
+      fprintf(stderr, "%s:%d received error %s\n",
+              file, line, gluErrorString(err));
+}
+
+#define assert_no_error() assert_no_error_test(__FILE__, __LINE__)
+
+static void assert_error_test(const char *file, int line, GLenum expect)
+{
+   GLenum err;
+
+   err = glGetError();
+   if (err != expect)
+      fprintf(stderr, "%s:%d expected %s but received %s\n",
+              file, line, gluErrorString(expect), gluErrorString(err));
+   while (glGetError()); /* consume any following errors */
+}
+
+#define assert_error(err) assert_error_test(__FILE__, __LINE__, (err))
+
+static void check_status(GLuint id, GLenum pname, void (*query)(GLuint, GLenum, GLint *))
+{
+    GLint status;
+
+    query(id, pname, &status);
+    if (!status)
+    {
+        char info[65536];
+
+        fprintf(stderr, "Compilation/link failure:\n");
+        glGetInfoLogARB(id, sizeof(info), NULL, info);
+        fprintf(stderr, "%s\n", info);
+        exit(1);
+    }
+}
+
+static void check_compile_status(GLuint id)
+{
+   check_status(id, GL_COMPILE_STATUS, glGetShaderiv);
+}
+
+static void check_link_status(GLuint id)
+{
+   check_status(id, GL_LINK_STATUS, glGetProgramiv);
+}
+
+static GLuint make_shader(GLenum type, const char *src)
+{
+   GLuint id;
+
+   assert_no_error();
+   id = glCreateShader(type);
+   glShaderSource(id, 1, &src, NULL);
+   glCompileShader(id);
+   check_compile_status(id);
+   assert_no_error();
+   return id;
+}
+
+static GLuint make_program(const char *vs_src, const char *fs_src)
+{
+   GLuint id, vs, fs;
+
+   assert_no_error();
+   id = glCreateProgram();
+   if (vs_src) {
+      vs = make_shader(GL_VERTEX_SHADER, vs_src);
+      glAttachShader(id, vs);
+      glDeleteShader(vs);
+   }
+   if (fs_src) {
+      fs = make_shader(GL_FRAGMENT_SHADER, fs_src);
+      glAttachShader(id, fs);
+      glDeleteShader(fs);
+   }
+   glLinkProgram(id);
+   check_link_status(id);
+   glUseProgram(id);
+   glDeleteProgram(id);
+   assert_no_error();
+   return id;
+}
+
+static void test_uniform_size_type1(const char *glslType, GLenum glType, const char *el)
+{
+   char buffer[1024];
+   GLuint program;
+   GLint active, i;
+   GLenum type;
+   GLint size;
+
+   printf("  Running subtest %s\n", glslType); fflush(stdout);
+   sprintf(buffer, "#version 120\nuniform %s m[60];\nvoid main() { gl_Position[0] = m[59]%s; }\n",
+           glslType, el);
+
+   program = make_program(buffer, NULL);
+   glGetProgramiv(program, GL_ACTIVE_UNIFORMS, &active);
+   assert_no_error();
+   for (i = 0; i < active; i++) {
+      size = -1;
+      type = 0;
+      glGetActiveUniform(program, i, sizeof(buffer), NULL, &size, &type, buffer);
+      assert_no_error();
+      if (strncmp(buffer, "m", 1) == 0)
+         break;
+   }
+   assert(i < active); /* Otherwise the compiler optimised it out */
+   assert(type == glType);
+   assert(size == 60);
+}
+
+static void test_uniform_size_type(void)
+{
+   test_uniform_size_type1("float", GL_FLOAT, "");
+   test_uniform_size_type1("vec2", GL_FLOAT_VEC2, "[0]");
+   test_uniform_size_type1("vec3", GL_FLOAT_VEC3, "[0]");
+   test_uniform_size_type1("vec4", GL_FLOAT_VEC4, "[0]");
+
+   test_uniform_size_type1("bool", GL_BOOL, " ? 1.0 : 0.0");
+   test_uniform_size_type1("bvec2", GL_BOOL_VEC2, "[0] ? 1.0 : 0.0");
+   test_uniform_size_type1("bvec3", GL_BOOL_VEC3, "[0] ? 1.0 : 0.0");
+   test_uniform_size_type1("bvec4", GL_BOOL_VEC4, "[0] ? 1.0 : 0.0");
+
+   test_uniform_size_type1("int", GL_INT, "");
+   test_uniform_size_type1("ivec2", GL_INT_VEC2, "[0]");
+   test_uniform_size_type1("ivec3", GL_INT_VEC3, "[0]");
+   test_uniform_size_type1("ivec4", GL_INT_VEC4, "[0]");
+
+   test_uniform_size_type1("mat2", GL_FLOAT_MAT2, "[0][0]");
+   test_uniform_size_type1("mat3", GL_FLOAT_MAT3, "[0][0]");
+   test_uniform_size_type1("mat4", GL_FLOAT_MAT4, "[0][0]");
+   test_uniform_size_type1("mat2x3", GL_FLOAT_MAT2x3, "[0][0]");
+   test_uniform_size_type1("mat2x4", GL_FLOAT_MAT2x4, "[0][0]");
+   test_uniform_size_type1("mat3x2", GL_FLOAT_MAT3x2, "[0][0]");
+   test_uniform_size_type1("mat3x4", GL_FLOAT_MAT3x4, "[0][0]");
+   test_uniform_size_type1("mat4x2", GL_FLOAT_MAT4x2, "[0][0]");
+   test_uniform_size_type1("mat4x3", GL_FLOAT_MAT4x3, "[0][0]");
+}
+
+static void test_attrib_size_type1(const char *glslType, GLenum glType, const char *el)
+{
+   char buffer[1024];
+   GLuint program;
+   GLint active, i;
+   GLenum type;
+   GLint size;
+
+   printf("  Running subtest %s\n", glslType); fflush(stdout);
+   sprintf(buffer, "#version 120\nattribute %s m;\nvoid main() { gl_Position[0] = m%s; }\n",
+           glslType, el);
+
+   program = make_program(buffer, NULL);
+   glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &active);
+   assert_no_error();
+   for (i = 0; i < active; i++) {
+      size = -1;
+      type = -1;
+      glGetActiveAttrib(program, i, sizeof(buffer), NULL, &size, &type, buffer);
+      assert_no_error();
+      if (strncmp(buffer, "m", 1) == 0)
+         break;
+   }
+   assert(i < active); /* Otherwise the compiler optimised it out */
+   assert(type == glType);
+   assert(size == 1);
+}
+
+static void test_attrib_size_type(void)
+{
+   test_attrib_size_type1("float", GL_FLOAT, "");
+   test_attrib_size_type1("vec2", GL_FLOAT_VEC2, "[0]");
+   test_attrib_size_type1("vec3", GL_FLOAT_VEC3, "[0]");
+   test_attrib_size_type1("vec4", GL_FLOAT_VEC4, "[0]");
+
+   test_attrib_size_type1("mat2", GL_FLOAT_MAT2, "[0][0]");
+   test_attrib_size_type1("mat3", GL_FLOAT_MAT3, "[0][0]");
+   test_attrib_size_type1("mat4", GL_FLOAT_MAT4, "[0][0]");
+   test_attrib_size_type1("mat2x3", GL_FLOAT_MAT2x3, "[0][0]");
+   test_attrib_size_type1("mat2x4", GL_FLOAT_MAT2x4, "[0][0]");
+   test_attrib_size_type1("mat3x2", GL_FLOAT_MAT3x2, "[0][0]");
+   test_attrib_size_type1("mat3x4", GL_FLOAT_MAT3x4, "[0][0]");
+   test_attrib_size_type1("mat4x2", GL_FLOAT_MAT4x2, "[0][0]");
+   test_attrib_size_type1("mat4x3", GL_FLOAT_MAT4x3, "[0][0]");
+}
+
+static void test_uniform_array_overflow(void)
+{
+   GLuint program;
+   GLint location;
+   GLfloat data[128];
+
+   program = make_program("#version 120\nuniform vec2 x[10];\nvoid main() { gl_Position.xy = x[9]; }\n", NULL);
+   location = glGetUniformLocation(program, "x");
+   assert_no_error();
+   glUniform2fv(location, 64, data);
+   assert_no_error();
+}
+
+static void test_uniform_scalar_count(void)
+{
+   GLuint program;
+   GLint location;
+   GLfloat data[128];
+
+   program = make_program("#version 110\nuniform vec2 x;\nvoid main() { gl_Position.xy = x; }\n", NULL);
+   location = glGetUniformLocation(program, "x");
+   assert_no_error();
+   glUniform2fv(location, 64, data);
+   assert_error(GL_INVALID_OPERATION);
+}
+
+static void test_uniform_query_matrix(void)
+{
+   GLuint program;
+   GLfloat data[18];
+   GLint i, r, c;
+   GLint location;
+
+   program = make_program("#version 110\nuniform mat3 m[2];\nvoid main() { gl_Position.xyz = m[1][2]; }\n", NULL);
+   location = glGetUniformLocation(program, "m");
+   for (i = 0; i < 9; i++)
+      data[i] = i;
+   for (i = 9; i < 18; i++)
+      data[i] = 321.0;
+   glUniformMatrix3fv(location, 1, GL_TRUE, data);
+
+   for (i = 0; i < 18; i++)
+      data[i] = 123.0;
+   glGetUniformfv(program, location, data);
+   for (c = 0; c < 3; c++)
+      for (r = 0; r < 3; r++)
+         assert(data[c * 3 + r] == r * 3 + c);
+   for (i = 9; i < 18; i++)
+      assert(data[i] == 123.0);
+}
+
+static void test_uniform_neg_location(void)
+{
+   GLuint program;
+   GLfloat data[4];
+
+   program = make_program("#version 110\nvoid main() { gl_Position = vec4(1.0, 1.0, 1.0, 1.0); }\n", NULL);
+   assert_no_error();
+   glUniform1i(-1, 1);
+   assert_no_error();
+   glUniform1i(-200, 1);
+   assert_error(GL_INVALID_OPERATION);
+   glUniformMatrix2fv(-1, 1, GL_FALSE, data);
+   assert_no_error();
+   glUniformMatrix2fv(-200, 1, GL_FALSE, data);
+   assert_error(GL_INVALID_OPERATION);
+}
+
+static void test_uniform_bool_conversion(void)
+{
+    GLuint program;
+    GLint location;
+    GLint value[16];  /* in case glGetUniformiv goes nuts on the stack */
+
+    assert_no_error();
+    program = make_program("uniform bool b;\nvoid main() { gl_Position.x = b ? 1.5 : 0.5; }\n", NULL);
+    location = glGetUniformLocation(program, "b");
+    assert(location != -1);
+    assert_no_error();
+    glUniform1i(location, 5);
+    assert_no_error();
+    glGetUniformiv(program, location, &value[0]);
+    assert_no_error();
+    assert(value[0] == 1);
+}
+
+static void test_uniform_multiple_samplers(void)
+{
+   GLuint program;
+   GLint location;
+   GLint values[2] = {0, 1};
+
+   assert_no_error();
+   program = make_program(NULL, "uniform sampler2D s[2];\nvoid main() { gl_FragColor = texture2D(s[1], vec2(0.0, 0.0)); }\n");
+   location = glGetUniformLocation(program, "s[0]");
+   if (location == -1)  /* Mesa doesn't currently support indexing */
+      location = glGetUniformLocation(program, "s");
+   assert(location != -1);
+   assert_no_error();
+   glUniform1iv(location, 2, values);
+   assert_no_error();
+}
+
+static void run_test(const char *name, void (*callback)(void))
+{
+   printf("Running %s\n", name);
+   fflush(stdout);
+   callback();
+}
+
+#define RUN_TEST(name) run_test(#name, (name))
+
+int main(int argc, char **argv)
+{
+   glutInit(&argc, argv);
+   glutCreateWindow("Mesa bug demo");
+
+   RUN_TEST(test_uniform_size_type);
+   RUN_TEST(test_attrib_size_type);
+   RUN_TEST(test_uniform_array_overflow);
+   RUN_TEST(test_uniform_scalar_count);
+   RUN_TEST(test_uniform_query_matrix);
+   RUN_TEST(test_uniform_neg_location);
+   RUN_TEST(test_uniform_bool_conversion);
+   /* Leave this one at the end, since it crashes Mesa's shader compiler */
+   RUN_TEST(test_uniform_multiple_samplers);
+   return 0;
+}
diff --git a/progs/tests/stencil_twoside.c b/progs/tests/stencil_twoside.c
new file mode 100644 (file)
index 0000000..be9d9a7
--- /dev/null
@@ -0,0 +1,299 @@
+/*
+ * (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 stencil_twoside.c
+ * 
+ * Simple test of GL_ATI_separate_stencil (or the OGL 2.0 equivalent) functionality.
+ * Four squares are drawn
+ * with different stencil modes, but all should be rendered with the same
+ * final color.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+static int use20syntax = 1;
+static int Width = 550;
+static int Height = 200;
+static const GLfloat Near = 5.0, Far = 25.0;
+
+
+static PFNGLSTENCILFUNCSEPARATEPROC stencil_func_separate = NULL;
+static PFNGLSTENCILFUNCSEPARATEATIPROC stencil_func_separate_ati = NULL;
+static PFNGLSTENCILOPSEPARATEPROC stencil_op_separate = NULL;
+
+static void Display( void )
+{
+   GLint  max_stencil;
+   GLint  stencil_bits;
+   unsigned i;
+
+
+   glGetIntegerv( GL_STENCIL_BITS, & stencil_bits );
+   max_stencil = (1U << stencil_bits) - 1;
+   printf( "Stencil bits = %u, maximum stencil value = 0x%08x\n",
+          stencil_bits, max_stencil );
+
+   glClearStencil( 1 );
+   glClearColor( 0.2, 0.2, 0.8, 0 );
+   glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT 
+           | GL_STENCIL_BUFFER_BIT );
+
+
+   glPushMatrix();
+
+   /* This is the "reference" square.
+    */
+
+   glDisable(GL_STENCIL_TEST);
+   glTranslatef(-6.0, 0, 0);
+   glBegin(GL_QUADS);
+   glColor3f( 0.5, 0.5, 0.5 );
+   glVertex2f(-1, -1);
+   glVertex2f( 1, -1);
+   glVertex2f( 1,  1);
+   glVertex2f(-1,  1);
+   glEnd();
+
+
+   glEnable(GL_STENCIL_TEST);
+
+   /* Draw the first two squares using incr for the affected face
+    */
+
+   if (use20syntax) {
+      stencil_func_separate(GL_FRONT, GL_ALWAYS, 0, ~0);
+      stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0);
+   }
+   else {
+      stencil_func_separate_ati(GL_ALWAYS, GL_ALWAYS, 0, ~0);
+   }
+   stencil_op_separate(GL_FRONT, GL_KEEP, GL_KEEP, GL_INCR);
+   stencil_op_separate(GL_BACK, GL_KEEP, GL_KEEP, GL_DECR);
+
+   glTranslatef(3.0, 0, 0);
+   glBegin(GL_QUADS);
+   glColor3f( 0.9, 0.9, 0.9 );
+   /* this should be front facing */
+   for ( i = 0 ; i < (max_stencil + 5) ; i++ ) {
+      glVertex2f(-1, -1);
+      glVertex2f( 1, -1);
+      glVertex2f( 1,  1);
+      glVertex2f(-1,  1);
+   }
+   glEnd();
+
+   glStencilFunc(GL_EQUAL, max_stencil, ~0);
+   glBegin(GL_QUADS);
+   glColor3f( 0.5, 0.5, 0.5 );
+   glVertex2f(-1, -1);
+   glVertex2f( 1, -1);
+   glVertex2f( 1,  1);
+   glVertex2f(-1,  1);
+   glEnd();
+
+
+   if (use20syntax) {
+      stencil_func_separate(GL_FRONT, GL_ALWAYS, 0, ~0);
+      stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0);
+   }
+   else {
+      stencil_func_separate_ati(GL_ALWAYS, GL_ALWAYS, 0, ~0);
+   }
+   stencil_op_separate(GL_FRONT, GL_KEEP, GL_KEEP, GL_DECR);
+   stencil_op_separate(GL_BACK, GL_KEEP, GL_KEEP, GL_INCR);
+
+   glTranslatef(3.0, 0, 0);
+   glBegin(GL_QUADS);
+   glColor3f( 0.9, 0.9, 0.9 );
+
+   /* this should be back facing */
+   for ( i = 0 ; i < (max_stencil + 5) ; i++ ) {
+      glVertex2f(-1, -1);
+      glVertex2f(-1,  1);
+      glVertex2f( 1,  1);
+      glVertex2f( 1, -1);
+   }
+   glEnd();
+
+   glStencilFunc(GL_EQUAL, max_stencil, ~0);
+   glBegin(GL_QUADS);
+   glColor3f( 0.5, 0.5, 0.5 );
+   glVertex2f(-1, -1);
+   glVertex2f( 1, -1);
+   glVertex2f( 1,  1);
+   glVertex2f(-1,  1);
+   glEnd();
+
+   if (use20syntax) {
+      stencil_func_separate(GL_FRONT, GL_NEVER, 0, ~0);
+      stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0);
+   }
+   else {
+      stencil_func_separate_ati(GL_NEVER, GL_ALWAYS, 0, ~0);
+   }
+   stencil_op_separate(GL_FRONT, GL_KEEP, GL_KEEP, GL_DECR);
+   stencil_op_separate(GL_BACK, GL_KEEP, GL_KEEP, GL_INCR);
+
+   glTranslatef(3.0, 0, 0);
+   glBegin(GL_QUADS);
+   glColor3f( 0.9, 0.9, 0.9 );
+
+   /* this should be back facing */
+   for ( i = 0 ; i < (max_stencil + 5) ; i++ ) {
+   /* this should be back facing */
+      glVertex2f(-1, -1);
+      glVertex2f(-1,  1);
+      glVertex2f( 1,  1);
+      glVertex2f( 1, -1);
+   /* this should be front facing */
+      glVertex2f(-1, -1);
+      glVertex2f( 1, -1);
+      glVertex2f( 1,  1);
+      glVertex2f(-1,  1);
+   }
+   glEnd();
+
+   glStencilFunc(GL_EQUAL, max_stencil, ~0);
+   glBegin(GL_QUADS);
+   glColor3f( 0.5, 0.5, 0.5 );
+   glVertex2f(-1, -1);
+   glVertex2f( 1, -1);
+   glVertex2f( 1,  1);
+   glVertex2f(-1,  1);
+   glEnd();
+
+   if (use20syntax) {
+      stencil_func_separate(GL_FRONT, GL_ALWAYS, 0, ~0);
+      stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0);
+   }
+   else {
+      stencil_func_separate_ati(GL_ALWAYS, GL_ALWAYS, 0, ~0);
+   }
+   stencil_op_separate(GL_FRONT, GL_KEEP, GL_KEEP, GL_DECR);
+   stencil_op_separate(GL_BACK, GL_KEEP, GL_KEEP, GL_INCR);
+
+   glTranslatef(3.0, 0, 0);
+   glBegin(GL_QUADS);
+   glColor3f( 0.9, 0.9, 0.9 );
+
+   /* this should be back facing */
+   for ( i = 0 ; i < (max_stencil + 5) ; i++ ) {
+   /* this should be back facing */
+      glVertex2f(-1, -1);
+      glVertex2f(-1,  1);
+      glVertex2f( 1,  1);
+      glVertex2f( 1, -1);
+   /* this should be front facing */
+      glVertex2f(-1, -1);
+      glVertex2f( 1, -1);
+      glVertex2f( 1,  1);
+      glVertex2f(-1,  1);
+   }
+   glEnd();
+
+   glStencilFunc(GL_EQUAL, 1, ~0);
+   glBegin(GL_QUADS);
+   glColor3f( 0.5, 0.5, 0.5 );
+   glVertex2f(-1, -1);
+   glVertex2f( 1, -1);
+   glVertex2f( 1,  1);
+   glVertex2f(-1,  1);
+   glEnd();
+
+   glPopMatrix();
+
+   glutSwapBuffers();
+}
+
+
+static void Reshape( int width, int height )
+{
+   GLfloat ar = (float) width / (float) height;
+   Width = width;
+   Height = height;
+   glViewport( 0, 0, width, height );
+   glMatrixMode( GL_PROJECTION );
+   glLoadIdentity();
+   glFrustum( -ar, ar, -1.0, 1.0, Near, Far );
+   glMatrixMode( GL_MODELVIEW );
+   glLoadIdentity();
+   glTranslatef( 0.0, 0.0, -15.0 );
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+   (void) x;
+   (void) y;
+   switch (key) {
+      case 27:
+         exit(0);
+         break;
+   }
+   glutPostRedisplay();
+}
+
+
+static void Init( void )
+{
+   const char * const ver_string = (const char * const)
+       glGetString( GL_VERSION );
+
+   printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+   printf("GL_VERSION = %s\n", ver_string);
+
+   if ( !glutExtensionSupported("GL_ATI_separate_stencil") 
+       && (atof( ver_string ) < 2.0) ) {
+      printf("Sorry, this program requires either GL_ATI_separate_stencil or OpenGL 2.0.\n");
+      exit(1);
+   }
+   if (atof( ver_string ) < 2.0) {
+      use20syntax = 0;
+   }
+   stencil_func_separate = glutGetProcAddress( "glStencilFuncSeparate" );
+   stencil_func_separate_ati = glutGetProcAddress( "glStencilFuncSeparateATI" );
+   stencil_op_separate = glutGetProcAddress( "glStencilOpSeparate" );
+
+   printf("\nAll 5 squares should be the same color.\n");
+   glEnable( GL_BLEND );
+}
+
+
+int main( int argc, char *argv[] )
+{
+   glutInit( &argc, argv );
+   glutInitWindowPosition( 0, 0 );
+   glutInitWindowSize( Width, Height );
+   glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL );
+   glutCreateWindow( "GL_ATI_separate_stencil test" );
+   glutReshapeFunc( Reshape );
+   glutKeyboardFunc( Key );
+   glutDisplayFunc( Display );
+   Init();
+   glutMainLoop();
+   return 0;
+}
index ee16ed40df216b508f43422e999c188ba67319f4..76dfccd9b1ac5e4b0a8557417b796191722614ce 100644 (file)
@@ -6,7 +6,6 @@
  * September 2000
  */
 
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <math.h>
@@ -210,7 +209,9 @@ static void SpecialKey( int key, int x, int y )
 
 static void Init( int argc, char *argv[] )
 {
+   GLfloat r[2];
    GLuint u;
+
    for (u = 0; u < 2; u++) {
       glActiveTextureARB(GL_TEXTURE0_ARB + u);
       glBindTexture(GL_TEXTURE_2D, 10+u);
@@ -241,6 +242,15 @@ static void Init( int argc, char *argv[] )
       printf("GL_VENDOR     = %s\n", (char *) glGetString(GL_VENDOR));
       printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
    }
+
+   glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, r);
+   printf("Non-smooth point size range: %g .. %g\n", r[0], r[1]);
+   glGetFloatv(GL_POINT_SIZE_RANGE, r);
+   printf("Smoothed point size range: %g .. %g\n", r[0], r[1]);
+   glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, r);
+   printf("Non-smooth line width range: %g .. %g\n", r[0], r[1]);
+   glGetFloatv(GL_LINE_WIDTH_RANGE, r);
+   printf("Smoothed line width range: %g .. %g\n", r[0], r[1]);
 }
 
 
diff --git a/progs/tests/unfilledclip.c b/progs/tests/unfilledclip.c
new file mode 100644 (file)
index 0000000..f25e526
--- /dev/null
@@ -0,0 +1,205 @@
+/*
+ * Copyright Â© 2008 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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:
+ *    Eric Anholt <eric@anholt.net>
+ *
+ */
+
+#include <stdlib.h>
+#include <GL/glut.h>
+
+static int win_width, win_height;
+
+static void
+line(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
+{
+       glBegin(GL_LINES);
+       glVertex2f(x1, y1);
+       glVertex2f(x2, y2);
+       glEnd();
+}
+
+static void
+line3(GLfloat x1, GLfloat y1, GLfloat z1, GLfloat x2, GLfloat y2, GLfloat z2)
+{
+       glBegin(GL_LINES);
+       glVertex3f(x1, y1, z1);
+       glVertex3f(x2, y2, z2);
+       glEnd();
+}
+
+static void
+display(void)
+{
+       glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+
+       glClearColor(0.0, 0.0, 0.0, 0.0);
+       glClear(GL_COLOR_BUFFER_BIT);
+
+       glColor3f(1.0, 0.0, 0.0);
+       /* clipped along xmin */
+       glBegin(GL_TRIANGLES);
+       glVertex2f(-20, win_height / 2 - 20);
+       glVertex2f(20, win_height / 2);
+       glVertex2f(-20, win_height / 2 + 20);
+       glEnd();
+
+       glColor3f(0.0, 1.0, 0.0);
+       /* clipped along ymax */
+       glBegin(GL_TRIANGLES);
+       glVertex2f(win_height / 2 - 20, win_height + 20);
+       glVertex2f(win_height / 2,      win_height - 20);
+       glVertex2f(win_height / 2 + 20, win_height + 20);
+       glEnd();
+
+       glColor3f(0.0, 0.0, 1.0);
+       /* clipped along xmax */
+       glBegin(GL_TRIANGLES);
+       glVertex2f(win_height + 20, win_height / 2 - 20);
+       glVertex2f(win_height - 20, win_height / 2);
+       glVertex2f(win_height + 20, win_height / 2 + 20);
+       glEnd();
+
+       glColor3f(1.0, 1.0, 1.0);
+       /* clipped along ymin */
+       glBegin(GL_TRIANGLES);
+       glVertex2f(win_height / 2 - 20, -20);
+       glVertex2f(win_height / 2,       20);
+       glVertex2f(win_height / 2 + 20, -20);
+       glEnd();
+
+       /* clipped along near */
+       glColor3f(1.0, 0.0, 1.0);
+       glBegin(GL_TRIANGLES);
+       glVertex3f(win_width / 2 - 20, win_height / 2 - 20,  0.5);
+       glVertex3f(win_width / 2 - 40, win_height / 2,      -0.5);
+       glVertex3f(win_width / 2 - 20, win_height / 2 + 20,  0.5);
+       glEnd();
+
+       /* clipped along far */
+       glColor3f(0.0, 1.0, 1.0);
+       glBegin(GL_TRIANGLES);
+       glVertex3f(win_width / 2 + 20, win_height / 2 - 20, 0.5);
+       glVertex3f(win_width / 2 + 40, win_height / 2,      1.5);
+       glVertex3f(win_width / 2 + 20, win_height / 2 + 20, 0.5);
+       glEnd();
+
+       /* entirely clipped along near/far */
+       glColor3f(.5, .5, .5);
+       glBegin(GL_TRIANGLES);
+       glVertex3f(win_width / 2 - 20, win_height / 2 + 20, -0.5);
+       glVertex3f(win_width / 2,      win_height / 2 + 40, -0.5);
+       glVertex3f(win_width / 2 + 20, win_height / 2 + 20, -0.5);
+       glEnd();
+
+       glBegin(GL_TRIANGLES);
+       glVertex3f(win_width / 2 - 20, win_height / 2 - 20, 1.5);
+       glVertex3f(win_width / 2,      win_height / 2 - 40, 1.5);
+       glVertex3f(win_width / 2 + 20, win_height / 2 - 20, 1.5);
+       glEnd();
+
+       glColor3f(.5, .5, .5);
+       line3(win_width / 2, win_height / 2 - 20, 1.5,
+             win_width / 2, win_height / 2 + 20, 1.5);
+
+       glColor3f(1.0, 1.0, 0.0);
+       /* clipped along both x and y limits */
+       glBegin(GL_TRIANGLES); /* xmin, ymin */
+       glVertex2f(-5, 20);
+       glVertex2f(20, 20);
+       glVertex2f(20, -5);
+       glEnd();
+       glBegin(GL_TRIANGLES); /* xmin, ymax */
+       glVertex2f(-5, win_height - 20);
+       glVertex2f(20, win_height - 20);
+       glVertex2f(20, win_height + 5);
+       glEnd();
+       glBegin(GL_TRIANGLES); /* xmax, ymax */
+       glVertex2f(win_width - 20, win_height + 5);
+       glVertex2f(win_width - 20, win_height - 20);
+       glVertex2f(win_width + 5,  win_height - 20);
+       glEnd();
+       glBegin(GL_TRIANGLES); /* xmax, ymin */
+       glVertex2f(win_width + 5, 20);
+       glVertex2f(win_width - 20, 20);
+       glVertex2f(win_width - 20, -5);
+       glEnd();
+
+       glutSwapBuffers();
+}
+
+static void
+reshape(int width, int height)
+{
+       win_width = width;
+       win_height = height;
+       glViewport(0, 0, width, height);
+
+       glMatrixMode(GL_PROJECTION);
+       glLoadIdentity();
+       glOrtho(0, win_width, 0, win_height, 0.0, -1.0);
+
+       glMatrixMode(GL_MODELVIEW);
+       glLoadIdentity();
+       glTranslatef(.25, .25, 0);
+}
+
+static void key( unsigned char key, int x, int y )
+{
+       (void) x;
+       (void) y;
+
+       switch (key) {
+       case 27: /* esc */
+               exit(0);
+               break;
+       }
+
+       glutPostRedisplay();
+}
+
+static void
+init(void)
+{
+}
+
+int
+main(int argc, char *argv[])
+{
+       win_width = 200;
+       win_height = 200;
+
+       glutInit(&argc, argv);
+       glutInitWindowPosition(0, 0);
+       glutInitWindowSize(win_width, win_height);
+       glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+       glutCreateWindow(argv[0]);
+       glutReshapeFunc(reshape);
+       glutKeyboardFunc(key);
+       glutDisplayFunc(display);
+
+       init();
+
+       glutMainLoop();
+       return 0;
+}
index 3f7bdcbc93581654613a435ae32e4b252faaa64b..822e466ad1b517afa9b20e38fea6cc65d50f7583 100644 (file)
@@ -16,8 +16,8 @@ TRACER = gltrace.so
 default: $(TRACER)
 
 $(TRACER): $(OBJECTS)
-       $(TOP)/bin/mklib -o $(TRACER) -noprefix -cplusplus \
-               $(MKLIB_OPTIONS) $(OBJECTS)
+       $(MKLIB) -o $(TRACER) -noprefix -cplusplus -linker '$(CXX)' \
+               -ldflags '$(LDFLAGS)' $(MKLIB_OPTIONS) $(OBJECTS)
 
 gltrace.cc: gltrace.py
        PYTHONPATH=$(TOP)/src/mesa/glapi python gltrace.py -f $(TOP)/src/mesa/glapi/gl_API.xml  > gltrace.cc
index b188e73f29ef09d0a006d07e08e760eb1efb3ae0..0b76d3247d762fd642a4e3556ad960382e068d4a 100644 (file)
@@ -20,6 +20,8 @@
  */
 
 #include "gltrace_support.h"
+#include <cstdlib>
+#include <cstring>
 #include <assert.h>
 #include <sstream>
 #include <fstream>
@@ -136,7 +138,7 @@ namespace gltrace {
 
     struct timeval now;
     struct tm t;
-    static char *months[12] = 
+    static char const *months[12] = 
       { 
        "Jan", "Feb", "Mar", "Apr", "May", "Jun", 
        "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" 
index c868ab6e6ffc6d4c51df52ebbc9bb4b0b0378cef..28c0b12fa4d50cc7246ca809733669623ebfe0df 100644 (file)
@@ -8,7 +8,7 @@ TOP = ../..
 include $(TOP)/configs/current
 
 
-LIBS = $(APP_LIB_DEPS)
+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
 
 SOURCES = \
        clear-fbo-tex.c \
@@ -19,6 +19,7 @@ SOURCES = \
        dlist-dangling.c \
        dlist-edgeflag-dangling.c \
        dlist-edgeflag.c \
+       dlist-degenerate.c \
        drawarrays.c \
        drawelements.c \
        drawrange.c \
@@ -74,7 +75,6 @@ SOURCES = \
        quadstrip-cont.c \
        quadstrip-flat.c \
        quadstrip.c \
-       tri-orig.c \
        tri-alpha.c \
        tri-blend-color.c \
        tri-blend-max.c \
@@ -93,6 +93,7 @@ SOURCES = \
        tri-flat.c \
        tri-fog.c \
        tri-mask-tri.c \
+       tri-orig.c \
        tri-query.c \
        tri-scissor-tri.c \
        tri-stencil.c \
@@ -139,7 +140,7 @@ UTIL_FILES = readtex.h readtex.c
 .SUFFIXES: .c
 
 .c:
-       $(APP_CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@
+       $(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
 
 .c.o:
        $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
@@ -153,9 +154,9 @@ UTIL_FILES = readtex.h readtex.c
 default: $(UTIL_FILES) $(PROGS)
 
 clean:
-       rm -f $(PROGS)
-       rm -f *.o
-       rm -f getproclist.h
+       -rm -f $(PROGS)
+       -rm -f *.o
+       -rm -f getproclist.h
 
 
 # auto code generation
@@ -166,13 +167,13 @@ getproclist.h: $(TOP)/src/mesa/glapi/gl_API.xml getprocaddress.c getprocaddress.
 
 
 texrect: texrect.o readtex.o
-       $(APP_CC) texrect.o readtex.o $(LIBS) -o $@
+       $(APP_CC) $(CFLAGS) $(LDFLAGS) texrect.o readtex.o $(LIBS) -o $@
 
 texrect.o: texrect.c readtex.h
        $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
 
 invert: invert.o readtex.o
-       $(APP_CC) invert.o readtex.o $(LIBS) -o $@
+       $(APP_CC) $(CFLAGS) $(LDFLAGS) invert.o readtex.o $(LIBS) -o $@
 
 invert.o: invert.c readtex.h
        $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
diff --git a/progs/trivial/dlist-degenerate.c b/progs/trivial/dlist-degenerate.c
new file mode 100644 (file)
index 0000000..c7f2d2a
--- /dev/null
@@ -0,0 +1,153 @@
+/**
+ * Test display list corner cases.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+
+static int Win;
+static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
+static GLboolean Anim = GL_FALSE;
+static GLuint List1 = 0, List2 = 0;
+
+
+static void
+Idle(void)
+{
+   Xrot += 3.0;
+   Yrot += 4.0;
+   Zrot += 2.0;
+   glutPostRedisplay();
+}
+
+
+static void
+Draw(void)
+{
+   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+   glPushMatrix();
+   glRotatef(Xrot, 1, 0, 0);
+   glRotatef(Yrot, 0, 1, 0);
+   glRotatef(Zrot, 0, 0, 1);
+
+   glCallList(List1);
+   glCallList(List2);
+
+   glPopMatrix();
+
+   glutSwapBuffers();
+}
+
+
+static void
+Reshape(int width, int height)
+{
+   glViewport(0, 0, width, height);
+   glMatrixMode(GL_PROJECTION);
+   glLoadIdentity();
+   glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
+   glMatrixMode(GL_MODELVIEW);
+   glLoadIdentity();
+   glTranslatef(0.0, 0.0, -15.0);
+}
+
+
+static void
+Key(unsigned char key, int x, int y)
+{
+   const GLfloat step = 3.0;
+   (void) x;
+   (void) y;
+   switch (key) {
+      case 'a':
+         Anim = !Anim;
+         if (Anim)
+            glutIdleFunc(Idle);
+         else
+            glutIdleFunc(NULL);
+         break;
+      case 'z':
+         Zrot -= step;
+         break;
+      case 'Z':
+         Zrot += step;
+         break;
+      case 27:
+         glutDestroyWindow(Win);
+         exit(0);
+         break;
+   }
+   glutPostRedisplay();
+}
+
+
+static void
+SpecialKey(int key, int x, int y)
+{
+   const GLfloat step = 3.0;
+   (void) x;
+   (void) y;
+   switch (key) {
+      case GLUT_KEY_UP:
+         Xrot -= step;
+         break;
+      case GLUT_KEY_DOWN:
+         Xrot += step;
+         break;
+      case GLUT_KEY_LEFT:
+         Yrot -= step;
+         break;
+      case GLUT_KEY_RIGHT:
+         Yrot += step;
+         break;
+   }
+   glutPostRedisplay();
+}
+
+
+static void
+Init(void)
+{
+   /* List1: start of primitive */
+   List1 = glGenLists(1);
+   glNewList(List1, GL_COMPILE);
+     glBegin(GL_POLYGON);
+     glVertex2f(-1, -1);
+     glVertex2f( 1, -1);
+   glEndList();
+
+   /* List2: end of primitive */
+   List2 = glGenLists(1);
+   glNewList(List2, GL_COMPILE);
+     glVertex2f( 1, 1);
+     glVertex2f(-1, 1);
+     glEnd();
+   glEndList();
+
+   glEnable(GL_DEPTH_TEST);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+   glutInit(&argc, argv);
+   glutInitWindowPosition(0, 0);
+   glutInitWindowSize(400, 400);
+   glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+   Win = glutCreateWindow(argv[0]);
+   glutReshapeFunc(Reshape);
+   glutKeyboardFunc(Key);
+   glutSpecialFunc(SpecialKey);
+   glutDisplayFunc(Draw);
+   if (Anim)
+      glutIdleFunc(Idle);
+   Init();
+   glutMainLoop();
+   return 0;
+}
index be4328d99953049cd4b155d44d7d3231554bcb58..96544a05255dee00c192e2c415052dc9fa4bd82f 100644 (file)
  * OF THIS SOFTWARE.
  */
 
+#define GL_GLEXT_PROTOTYPES
+#include <math.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 #include <GL/glut.h>
 
 
-#define CI_OFFSET_1 16
-#define CI_OFFSET_2 32
-
 
 GLenum doubleBuffer;
 
@@ -40,53 +39,63 @@ static void Init(void)
    fprintf(stderr, "GL_VERSION    = %s\n", (char *) glGetString(GL_VERSION));
    fprintf(stderr, "GL_VENDOR     = %s\n", (char *) glGetString(GL_VENDOR));
 
-    glClearColor(0.0, 0.0, 1.0, 0.0);
+   glClearColor(0.0, 0.0, 1.0, 0.0);
 }
 
 static void Reshape(int width, int height)
 {
-
     glViewport(0, 0, (GLint)width, (GLint)height);
 
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
-    glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+    glOrtho(-1.0, 1.0, -1.0, 1.0, 0, 100.0);
     glMatrixMode(GL_MODELVIEW);
 }
 
 static void Key(unsigned char key, int x, int y)
 {
-
     switch (key) {
-      case 27:
+    case 27:
        exit(1);
-      default:
+    default:
        return;
     }
-
     glutPostRedisplay();
 }
 
+
+static float
+expected(float z, float size, const float atten[3])
+{
+   float dist = fabs(z);
+   const GLfloat q = atten[0] + dist * (atten[1] + dist * atten[2]);
+   const GLfloat a = sqrt(1.0 / q);
+   return size * a;
+}
+
+
 static void Draw(void)
 {
-   static GLfloat theQuad[3] = { 0.25, 0.0, 1/60.0 };
+   static GLfloat atten[3] = { 0.0, 0.1, .01 };
+   float size = 40.0;
+   int i;
 
    glClear(GL_COLOR_BUFFER_BIT); 
 
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-   glPointSize(8.0);
-   glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, theQuad); 
+   glPointSize(size);
+   glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, atten); 
 
+   glColor3f(1,0,0); 
 
+   printf("Expected point sizes:\n");
    glBegin(GL_POINTS);
-   glColor3f(1,0,0); 
-   glVertex3f( 0.9, -0.9, -10.0);
-   glColor3f(1,1,0); 
-   glVertex3f( 0.9,  0.9, -5.0);
-   glColor3f(1,0,1); 
-   glVertex3f(-0.9,  0.9, -30.0);
-   glColor3f(0,1,1); 
-   glVertex3f(-0.9,  -0.9, -20.0);
+   for (i = 0; i < 5; i++) {
+      float x = -0.8 + i * 0.4;
+      float z = -i * 20 - 10;
+      glVertex3f( x, 0.0, z);
+      printf(" %f\n", expected(z, size, atten));
+   }
    glEnd();
 
    glFlush();
@@ -96,6 +105,7 @@ static void Draw(void)
    }
 }
 
+
 static GLenum Args(int argc, char **argv)
 {
     GLint i;
@@ -115,6 +125,7 @@ static GLenum Args(int argc, char **argv)
     return GL_TRUE;
 }
 
+
 int main(int argc, char **argv)
 {
     GLenum type;
@@ -131,7 +142,7 @@ int main(int argc, char **argv)
     type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
     glutInitDisplayMode(type);
 
-    if (glutCreateWindow("First Tri") == GL_FALSE) {
+    if (glutCreateWindow(argv[0]) == GL_FALSE) {
        exit(1);
     }
 
@@ -141,5 +152,5 @@ int main(int argc, char **argv)
     glutKeyboardFunc(Key);
     glutDisplayFunc(Draw);
     glutMainLoop();
-       return 0;
+    return 0;
 }
index e76eb29f890b4729ec252e8706f87946738c2885..1e8056c474b5d525977d965c573c1bb28072323c 100644 (file)
@@ -33,6 +33,7 @@
 
 
 GLenum doubleBuffer;
+float Z = -6;
 
 static void Init(void)
 {
@@ -40,30 +41,36 @@ static void Init(void)
    fprintf(stderr, "GL_VERSION    = %s\n", (char *) glGetString(GL_VERSION));
    fprintf(stderr, "GL_VENDOR     = %s\n", (char *) glGetString(GL_VENDOR));
 
-    glClearColor(0.0, 0.0, 1.0, 0.0);
+   fprintf(stderr, "Press z/Z to translate quad\n");
+
+   glClearColor(0.0, 0.0, 1.0, 0.0);
 }
 
 static void Reshape(int width, int height)
 {
-
     glViewport(0, 0, (GLint)width, (GLint)height);
 
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
-    glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+    glFrustum(-1.0, 1.0, -1.0, 1.0, 5, 100.0);
     glMatrixMode(GL_MODELVIEW);
 }
 
 static void Key(unsigned char key, int x, int y)
 {
-
     switch (key) {
-      case 27:
-       exit(1);
-      default:
-       return;
+    case 'z':
+       Z += 0.5;
+       break;
+    case 'Z':
+       Z -= 0.5;
+       break;
+    case 27:
+       exit(1);
+    default:
+       return;
     }
-
+    printf("Z = %f\n", Z);
     glutPostRedisplay();
 }
 
@@ -71,17 +78,22 @@ static void Draw(void)
 {
    glClear(GL_COLOR_BUFFER_BIT); 
 
+   glPushMatrix();
+   glTranslatef(0, -0.5, Z);
+
    glBegin(GL_QUADS);
    glColor3f(1,0,0); 
-   glVertex3f( 0.9, -0.9, 30.0);
+   glVertex3f( -0.8, 0, -4.0);
    glColor3f(1,1,0); 
-   glVertex3f( 0.9,  0.9, 30.0);
+   glVertex3f(  0.8, 0, -4.0);
    glColor3f(1,0,1); 
-   glVertex3f(-1.9,  0.9, 30.0);
+   glVertex3f(  0.8, 0,  4.0);
    glColor3f(0,1,1); 
-   glVertex3f(-1.9,  -0.9, -30.0);
+   glVertex3f( -0.8, 0,  4.0);
    glEnd();
 
+   glPopMatrix();
+
    glFlush();
 
    if (doubleBuffer) {
@@ -118,7 +130,8 @@ int main(int argc, char **argv)
        exit(1);
     }
 
-    glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+    glutInitWindowPosition(0, 0);
+    glutInitWindowSize( 250, 250);
 
     type = GLUT_RGB | GLUT_ALPHA;
     type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
@@ -134,5 +147,5 @@ int main(int argc, char **argv)
     glutKeyboardFunc(Key);
     glutDisplayFunc(Draw);
     glutMainLoop();
-       return 0;
+    return 0;
 }
index 12fa8d11b6166708eab8075f4327e5c5eb1cf6d9..aa45adb6c2901e4500e1926bf6a1319cd800a030 100644 (file)
@@ -33,6 +33,7 @@
 
 
 GLenum doubleBuffer = 1;
+int win;
 
 static void Init(void)
 {
@@ -59,6 +60,7 @@ static void Key(unsigned char key, int x, int y)
 
     switch (key) {
       case 27:
+         glutDestroyWindow(win);
        exit(0);
       default:
        return;
@@ -120,7 +122,8 @@ int main(int argc, char **argv)
     type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
     glutInitDisplayMode(type);
 
-    if (glutCreateWindow("First Tri") == GL_FALSE) {
+    win = glutCreateWindow("First Tri");
+    if (!win) {
        exit(1);
     }
 
diff --git a/progs/util/shaderutil.c b/progs/util/shaderutil.c
new file mode 100644 (file)
index 0000000..4f17dd7
--- /dev/null
@@ -0,0 +1,162 @@
+/**
+ * Utilities for OpenGL shading language
+ *
+ * Brian Paul
+ * 9 April 2008
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+#include "extfuncs.h"
+#include "shaderutil.h"
+
+
+static void
+Init(void)
+{
+   static GLboolean firstCall = GL_TRUE;
+   if (firstCall) {
+      GetExtensionFuncs();
+      firstCall = GL_FALSE;
+   }
+}
+
+
+GLboolean
+ShadersSupported(void)
+{
+   const char *version = (const char *) glGetString(GL_VERSION);
+   if (version[0] == '2' && version[1] == '.') {
+      return GL_TRUE;
+   }
+   else if (glutExtensionSupported("GL_ARB_vertex_shader")
+            && glutExtensionSupported("GL_ARB_fragment_shader")
+            && glutExtensionSupported("GL_ARB_shader_objects")) {
+      fprintf(stderr, "Warning: Trying ARB GLSL instead of OpenGL 2.x.  This may not work.\n");
+      return GL_TRUE;
+   }
+   return GL_TRUE;
+}
+
+
+GLuint
+CompileShaderText(GLenum shaderType, const char *text)
+{
+   GLuint shader;
+   GLint stat;
+
+   Init();
+
+   shader = glCreateShader_func(shaderType);
+   glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
+   glCompileShader_func(shader);
+   glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
+   if (!stat) {
+      GLchar log[1000];
+      GLsizei len;
+      glGetShaderInfoLog_func(shader, 1000, &len, log);
+      fprintf(stderr, "Error: problem compiling shader: %s\n", log);
+      exit(1);
+   }
+   else {
+      /*printf("Shader compiled OK\n");*/
+   }
+   return shader;
+}
+
+
+/**
+ * Read a shader from a file.
+ */
+GLuint
+CompileShaderFile(GLenum shaderType, const char *filename)
+{
+   const int max = 100*1000;
+   int n;
+   char *buffer = (char*) malloc(max);
+   GLuint shader;
+
+   FILE *f = fopen(filename, "r");
+   if (!f) {
+      return 0;
+   }
+
+   n = fread(buffer, 1, max, f);
+   /*printf("read %d bytes from shader file %s\n", n, filename);*/
+   if (n > 0) {
+      buffer[n] = 0;
+      shader = CompileShaderText(shaderType, buffer);
+   }
+   else {
+      return 0;
+   }
+
+   fclose(f);
+   free(buffer);
+
+   return shader;
+}
+
+
+GLuint
+LinkShaders(GLuint vertShader, GLuint fragShader)
+{
+   GLuint program = glCreateProgram_func();
+
+   glAttachShader_func(program, fragShader);
+   glAttachShader_func(program, vertShader);
+   glLinkProgram_func(program);
+
+   /* check link */
+   {
+      GLint stat;
+      glGetProgramiv_func(program, GL_LINK_STATUS, &stat);
+      if (!stat) {
+         GLchar log[1000];
+         GLsizei len;
+         glGetProgramInfoLog_func(program, 1000, &len, log);
+         fprintf(stderr, "Shader link error:\n%s\n", log);
+         return 0;
+      }
+   }
+
+   return program;
+}
+
+
+void
+InitUniforms(GLuint program, struct uniform_info uniforms[])
+{
+   GLuint i;
+
+   for (i = 0; uniforms[i].name; i++) {
+      uniforms[i].location
+         = glGetUniformLocation_func(program, uniforms[i].name);
+
+      printf("Uniform %s location: %d\n", uniforms[i].name,
+             uniforms[i].location);
+
+      switch (uniforms[i].size) {
+      case 1:
+         if (uniforms[i].type == GL_INT)
+            glUniform1i_func(uniforms[i].location,
+                             (GLint) uniforms[i].value[0]);
+         else
+            glUniform1fv_func(uniforms[i].location, 1, uniforms[i].value);
+         break;
+      case 2:
+         glUniform2fv_func(uniforms[i].location, 1, uniforms[i].value);
+         break;
+      case 3:
+         glUniform3fv_func(uniforms[i].location, 1, uniforms[i].value);
+         break;
+      case 4:
+         glUniform4fv_func(uniforms[i].location, 1, uniforms[i].value);
+         break;
+      default:
+         abort();
+      }
+   }
+}
diff --git a/progs/util/shaderutil.h b/progs/util/shaderutil.h
new file mode 100644 (file)
index 0000000..cfb8c1f
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef SHADER_UTIL_H
+#define SHADER_UTIL_H
+
+
+
+struct uniform_info
+{
+   const char *name;
+   GLuint size;
+   GLenum type;  /**< GL_FLOAT or GL_INT */
+   GLfloat value[4];
+   GLint location;  /**< filled in by InitUniforms() */
+};
+
+#define END_OF_UNIFORMS   { NULL, 0, GL_NONE, { 0, 0, 0, 0 }, -1 }
+
+
+extern GLboolean
+ShadersSupported(void);
+
+extern GLuint
+CompileShaderText(GLenum shaderType, const char *text);
+
+extern GLuint
+CompileShaderFile(GLenum shaderType, const char *filename);
+
+extern GLuint
+LinkShaders(GLuint vertShader, GLuint fragShader);
+
+extern void
+InitUniforms(GLuint program, struct uniform_info uniforms[]);
+
+
+#endif /* SHADER_UTIL_H */
index c3faeb5b6028257d817296ea9833f50e4fc44dc5..28d63237a453767da98fae7216d75b2d7e88ab89 100644 (file)
@@ -8,7 +8,7 @@ TOP = ../..
 include $(TOP)/configs/current
 
 
-LIBS = $(APP_LIB_DEPS)
+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
 
 SOURCES = \
        vp-tris.c
@@ -26,7 +26,7 @@ INCLUDES = -I. -I$(TOP)/include -I../samples
 .SUFFIXES: .c
 
 .c:
-       $(CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@
+       $(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
 
 .c.o:
        $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
@@ -40,9 +40,9 @@ INCLUDES = -I. -I$(TOP)/include -I../samples
 default: $(PROGS)
 
 clean:
-       rm -f $(PROGS)
-       rm -f *.o
-       rm -f getproclist.h
+       -rm -f $(PROGS)
+       -rm -f *.o
+       -rm -f getproclist.h
 
 
 
diff --git a/progs/vp/run.sh b/progs/vp/run.sh
new file mode 100755 (executable)
index 0000000..fdd43d4
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+for i in *.txt ; do
+echo $i
+./vp-tris $i
+done
+
index 34551101cb9080222ca38ebae575031d1e45665d..868249db88459ddfef0711fc5da1e89c34a02252 100644 (file)
@@ -1,12 +1,15 @@
+corender
 glthreads
 glxcontexts
 glxdemo
 glxgears
 glxgears_fbconfig
+glxgears_pixmap
 glxheads
 glxinfo
 glxpbdemo
 glxpixmap
+glxsnoop
 glxswapcontrol
 manywin
 offset
index 38f3884d589f3a81d2a8b1ffd343e716b779cc7a..b314324fc10f1567ff8586fdba4e29f62f0a7899 100644 (file)
@@ -6,17 +6,23 @@ include $(TOP)/configs/current
 
 INCDIR = $(TOP)/include
 
-LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME)
+LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
 
-PROGS = glthreads \
+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(APP_LIB_DEPS)
+
+PROGS = \
+       corender \
+       glthreads \
        glxdemo \
        glxgears \
        glxgears_fbconfig \
+       glxgears_pixmap \
        glxcontexts \
        glxheads \
        glxinfo \
        glxpixmap \
        glxpbdemo \
+       glxsnoop \
        glxswapcontrol \
        manywin \
        offset \
@@ -27,10 +33,14 @@ PROGS = glthreads \
        texture_from_pixmap \
        wincopy \
        xfont \
-       xrotfontdemo \
-       yuvrect_client
+       xrotfontdemo
+
+# Don't build these by default because of extra library dependencies
+EXTRA_PROGS = \
+       shape \
+       yuvrect_client \
+       xdemo
 
-# omit this XMesa API demo:    xdemo
 
 
 ##### RULES #####
@@ -39,7 +49,7 @@ PROGS = glthreads \
 .SUFFIXES: .c
 
 .c: $(LIB_DEP)
-       $(APP_CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@
+       $(APP_CC) -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
 
 
 ##### TARGETS #####
@@ -47,39 +57,54 @@ PROGS = glthreads \
 default: $(PROGS)
 
 
+extra: $(EXTRA_PROGS)
+
+
 clean:
-       -rm -f $(PROGS)
+       -rm -f $(PROGS) $(EXTRA_PROGS)
        -rm -f *.o *~
 
 
 # special cases
 pbinfo: pbinfo.o pbutil.o
-       $(APP_CC) -I$(INCDIR) $(CFLAGS) pbinfo.o pbutil.o $(APP_LIB_DEPS) -o $@
+       $(APP_CC) $(CFLAGS) $(LDFLAGS) pbinfo.o pbutil.o $(LIBS) -o $@
 
 pbdemo: pbdemo.o pbutil.o
-       $(APP_CC) -I$(INCDIR) $(CFLAGS) pbdemo.o pbutil.o $(APP_LIB_DEPS) -o $@
+       $(APP_CC) $(CFLAGS) $(LDFLAGS) pbdemo.o pbutil.o $(LIBS) -o $@
 
 pbinfo.o: pbinfo.c pbutil.h
-       $(APP_CC) -c -I. -I$(INCDIR) $(CFLAGS) pbinfo.c
+       $(APP_CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) pbinfo.c
 
 pbdemo.o: pbdemo.c pbutil.h
-       $(APP_CC) -c -I. -I$(INCDIR) $(CFLAGS) pbdemo.c
+       $(APP_CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) pbdemo.c
 
 pbutil.o: pbutil.c pbutil.h
-       $(APP_CC) -c -I. -I$(INCDIR) $(CFLAGS) pbutil.c
+       $(APP_CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) pbutil.c
 
 glxgears_fbconfig: glxgears_fbconfig.o pbutil.o
-       $(APP_CC) -I$(INCDIR) $(CFLAGS) glxgears_fbconfig.o pbutil.o $(APP_LIB_DEPS) -o $@
+       $(APP_CC) $(CFLAGS) $(LDFLAGS) glxgears_fbconfig.o pbutil.o $(LIBS) -o $@
 
 glxgears_fbconfig.o: glxgears_fbconfig.c pbutil.h
-       $(APP_CC) -I$(INCDIR) $(CFLAGS) -c -I. $(CFLAGS) glxgears_fbconfig.c
+       $(APP_CC) -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) -c -I. $(CFLAGS) glxgears_fbconfig.c
 
 xrotfontdemo: xrotfontdemo.o xuserotfont.o
-       $(APP_CC) -I$(INCDIR) $(CFLAGS) xrotfontdemo.o xuserotfont.o $(APP_LIB_DEPS) -o $@
+       $(APP_CC) $(CFLAGS) $(LDFLAGS) xrotfontdemo.o xuserotfont.o $(LIBS) -o $@
 
 xuserotfont.o: xuserotfont.c xuserotfont.h
-       $(APP_CC) -c -I. -I$(INCDIR) $(CFLAGS) xuserotfont.c
+       $(APP_CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) xuserotfont.c
 
 xrotfontdemo.o: xrotfontdemo.c xuserotfont.h
-       $(APP_CC) -c -I. -I$(INCDIR) $(CFLAGS) xrotfontdemo.c
+       $(APP_CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) xrotfontdemo.c
+
+corender: corender.o ipc.o
+       $(APP_CC) $(CFLAGS) corender.o ipc.o $(LIBS) -o $@
+
+corender.o: corender.c ipc.h
+       $(APP_CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) corender.c
+
+ipc.o: ipc.c ipc.h
+       $(APP_CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) ipc.c
+
+yuvrect_client: yuvrect_client.c
+       $(APP_CC) -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) $< $(LDFLAGS) $(LIBS) -l$(GLU_LIB) -o $@
 
diff --git a/progs/xdemos/corender.c b/progs/xdemos/corender.c
new file mode 100644 (file)
index 0000000..f2b8145
--- /dev/null
@@ -0,0 +1,400 @@
+/**
+ * Example of cooperative rendering into one window by two processes.
+ * The first instance of the program creates the GLX window.
+ * The second instance of the program gets the window ID from the first
+ * and draws into it.
+ * Socket IPC is used for synchronization.
+ *
+ * Usage:
+ * 1. run 'corender &'
+ * 2. run 'corender 2'  (any arg will do)
+ *
+ * Brian Paul
+ * 11 Oct 2007
+ */
+
+
+#include <GL/gl.h>
+#include <GL/glx.h>
+#include <assert.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <X11/keysym.h>
+#include <unistd.h>
+#include "ipc.h"
+
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+static int MyID = 0;  /* 0 or 1 */
+static int WindowID = 0;
+static GLXContext Context = 0;
+static int Width = 700, Height = 350;
+static int Rot = 0;
+static int Sock = 0;
+
+static GLfloat Red[4] = {1.0, 0.2, 0.2, 1.0};
+static GLfloat Blue[4] = {0.2, 0.2, 1.0, 1.0};
+
+static int Sync = 1;  /** synchronized rendering? */
+
+
+static void
+setup_ipc(void)
+{
+   int k, port = 10001;
+
+   if (MyID == 0) {
+      /* I'm the first one, wait for connection from second */
+      k = CreatePort(&port);
+      assert(k != -1);
+
+      printf("Waiting for connection from another 'corender'\n");
+      Sock = AcceptConnection(k);
+
+      printf("Got connection, sending windowID\n");
+
+      /* send windowID */
+      SendData(Sock, &WindowID, sizeof(WindowID));
+   }
+   else {
+      /* I'm the second one, connect to first */
+      char hostname[1000];
+
+      MyHostName(hostname, 1000);
+      Sock = Connect(hostname, port);
+      assert(Sock != -1);
+
+      /* get windowID */
+      ReceiveData(Sock, &WindowID, sizeof(WindowID));
+      printf("Contacted first 'corender', getting WindowID\n");
+   }
+}
+
+
+
+/** from GLUT */
+static void
+doughnut(GLfloat r, GLfloat R, GLint nsides, GLint rings)
+{
+  int i, j;
+  GLfloat theta, phi, theta1;
+  GLfloat cosTheta, sinTheta;
+  GLfloat cosTheta1, sinTheta1;
+  GLfloat ringDelta, sideDelta;
+
+  ringDelta = 2.0 * M_PI / rings;
+  sideDelta = 2.0 * M_PI / nsides;
+
+  theta = 0.0;
+  cosTheta = 1.0;
+  sinTheta = 0.0;
+  for (i = rings - 1; i >= 0; i--) {
+    theta1 = theta + ringDelta;
+    cosTheta1 = cos(theta1);
+    sinTheta1 = sin(theta1);
+    glBegin(GL_QUAD_STRIP);
+    phi = 0.0;
+    for (j = nsides; j >= 0; j--) {
+      GLfloat cosPhi, sinPhi, dist;
+
+      phi += sideDelta;
+      cosPhi = cos(phi);
+      sinPhi = sin(phi);
+      dist = R + r * cosPhi;
+
+      glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
+      glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
+      glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
+      glVertex3f(cosTheta * dist, -sinTheta * dist,  r * sinPhi);
+    }
+    glEnd();
+    theta = theta1;
+    cosTheta = cosTheta1;
+    sinTheta = sinTheta1;
+  }
+}
+
+
+static void
+redraw(Display *dpy)
+{
+   int dbg = 0;
+
+   glXMakeCurrent(dpy, WindowID, Context);
+   glEnable(GL_LIGHTING);
+   glEnable(GL_LIGHT0);
+   glEnable(GL_DEPTH_TEST);
+   glClearColor(0.5, 0.5, 0.5, 0.0);
+
+   if (MyID == 0) {
+      /* First process */
+
+      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+      glPushMatrix();
+      glTranslatef(-1, 0, 0);
+      glRotatef(Rot, 1, 0, 0);
+      glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Red);
+      doughnut(0.5, 2.0, 20, 30);
+      glPopMatrix();
+
+      glFinish();
+      if (!Sync) {
+         usleep(1000*10);
+      }
+
+      /* signal second process to render */
+      if (Sync) {
+         int code = 1;
+         if (dbg) printf("0: send signal\n");
+         SendData(Sock, &code, sizeof(code));
+         SendData(Sock, &Rot, sizeof(Rot));
+      }
+
+      /* wait for second process to finish rendering */
+      if (Sync) {
+         int code = 0;
+         if (dbg) printf("0: wait signal\n");
+         ReceiveData(Sock, &code, sizeof(code));
+         if (dbg) printf("0: got signal\n");
+         assert(code == 2);
+      }
+
+   }
+   else {
+      /* Second process */
+
+      /* wait for first process's signal for me to render */
+      if (Sync) {
+         int code = 0;
+         if (dbg) printf("1: wait signal\n");
+         ReceiveData(Sock, &code, sizeof(code));
+         ReceiveData(Sock, &Rot, sizeof(Rot));
+
+         if (dbg) printf("1: got signal\n");
+         assert(code == 1);
+      }
+
+      /* XXX this clear should not be here, but for some reason, it
+       * makes things _mostly_ work correctly w/ NVIDIA's driver.
+       * There's only occasional glitches.
+       * Without this glClear(), depth buffer for the second process
+       * is pretty much broken.
+       */
+      //glClear(GL_DEPTH_BUFFER_BIT);
+
+      glPushMatrix();
+      glTranslatef(1, 0, 0);
+      glRotatef(Rot + 90 , 1, 0, 0);
+      glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Blue);
+      doughnut(0.5, 2.0, 20, 30);
+      glPopMatrix();
+      glFinish();
+
+      glXSwapBuffers(dpy, WindowID);
+      usleep(1000*10);
+
+      /* signal first process that I'm done rendering */
+      if (Sync) {
+         int code = 2;
+         if (dbg) printf("1: send signal\n");
+         SendData(Sock, &code, sizeof(code));
+      }
+   }
+}
+
+
+static void
+resize(Display *dpy, int width, int height)
+{
+   float ar = (float) width / height;
+
+   glXMakeCurrent(dpy, WindowID, Context);
+
+   glViewport(0, 0, width, height);
+   glMatrixMode(GL_PROJECTION);
+   glLoadIdentity();
+   glFrustum(-ar, ar, 1.0, -1.0, 5.0, 200.0);
+   glMatrixMode(GL_MODELVIEW);
+   glLoadIdentity();
+   glTranslatef(0, 0, -15);
+
+   Width = width;
+   Height = height;
+}
+
+
+
+static void
+set_window_title(Display *dpy, Window win, const char *title)
+{
+   XSizeHints sizehints;
+   sizehints.flags = 0;
+   XSetStandardProperties(dpy, win, title, title,
+                          None, (char **)NULL, 0, &sizehints);
+}
+
+
+static Window
+make_gl_window(Display *dpy, XVisualInfo *visinfo, int width, int height)
+{
+   int scrnum;
+   XSetWindowAttributes attr;
+   unsigned long mask;
+   Window root;
+   Window win;
+   int x = 0, y = 0;
+   char *name = NULL;
+
+   scrnum = DefaultScreen( dpy );
+   root = RootWindow( dpy, scrnum );
+
+   /* window attributes */
+   attr.background_pixel = 0;
+   attr.border_pixel = 0;
+   attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
+   attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
+   mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
+
+   win = XCreateWindow( dpy, root, x, y, width, height,
+                       0, visinfo->depth, InputOutput,
+                       visinfo->visual, mask, &attr );
+
+   /* set hints and properties */
+   {
+      XSizeHints sizehints;
+      sizehints.x = x;
+      sizehints.y = y;
+      sizehints.width  = width;
+      sizehints.height = height;
+      sizehints.flags = USSize | USPosition;
+      XSetNormalHints(dpy, win, &sizehints);
+      XSetStandardProperties(dpy, win, name, name,
+                              None, (char **)NULL, 0, &sizehints);
+   }
+
+   return win;
+}
+
+
+static void
+set_event_mask(Display *dpy, Window win)
+{
+   XSetWindowAttributes attr;
+   attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
+   XChangeWindowAttributes(dpy, win, CWEventMask, &attr);
+}
+
+
+static void
+event_loop(Display *dpy)
+{
+   while (1) {
+      while (XPending(dpy) > 0) {
+         XEvent event;
+         XNextEvent(dpy, &event);
+
+         switch (event.type) {
+         case Expose:
+            redraw(dpy);
+            break;
+         case ConfigureNotify:
+            resize(dpy, event.xconfigure.width, event.xconfigure.height);
+            break;
+         case KeyPress:
+            {
+               char buffer[10];
+               int r, code;
+               code = XLookupKeysym(&event.xkey, 0);
+               if (code == XK_Left) {
+               }
+               else {
+                  r = XLookupString(&event.xkey, buffer, sizeof(buffer),
+                                    NULL, NULL);
+                  if (buffer[0] == 27) {
+                     exit(0);
+                  }
+               }
+            }
+         default:
+            /* nothing */
+            ;
+         }
+      }
+
+      if (MyID == 0 || !Sync)
+         Rot += 1;
+      redraw(dpy);
+   }
+}
+
+
+static XVisualInfo *
+choose_visual(Display *dpy)
+{
+   int attribs[] = { GLX_RGBA,
+                     GLX_RED_SIZE, 1,
+                     GLX_GREEN_SIZE, 1,
+                     GLX_BLUE_SIZE, 1,
+                     GLX_DOUBLEBUFFER,
+                     GLX_DEPTH_SIZE, 1,
+                     None };
+   int scrnum = DefaultScreen( dpy );
+   return glXChooseVisual(dpy, scrnum, attribs);
+}
+
+
+static void
+parse_opts(int argc, char *argv[])
+{
+   if (argc > 1) {
+      MyID = 1;
+   }
+}
+
+
+int
+main( int argc, char *argv[] )
+{
+   Display *dpy;
+   XVisualInfo *visinfo;
+
+   parse_opts(argc, argv);
+
+   dpy = XOpenDisplay(NULL);
+
+   visinfo = choose_visual(dpy);
+
+   Context = glXCreateContext( dpy, visinfo, NULL, True );
+   if (!Context) {
+      printf("Error: glXCreateContext failed\n");
+      exit(1);
+   }
+
+   if (MyID == 0) {
+      WindowID = make_gl_window(dpy, visinfo, Width, Height);
+      set_window_title(dpy, WindowID, "corender");
+      XMapWindow(dpy, WindowID);
+      /*printf("WindowID 0x%x\n", (int) WindowID);*/
+   }
+
+   /* do ipc hand-shake here */
+   setup_ipc();
+   assert(Sock);
+   assert(WindowID);
+
+   if (MyID == 1) {
+      set_event_mask(dpy, WindowID);
+   }
+
+   resize(dpy, Width, Height);
+
+   event_loop(dpy);
+
+   return 0;
+}
diff --git a/progs/xdemos/glxgears_pixmap.c b/progs/xdemos/glxgears_pixmap.c
new file mode 100644 (file)
index 0000000..661d130
--- /dev/null
@@ -0,0 +1,547 @@
+/*
+ * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
+ * Copyright (C) 2008  Red Hat, 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, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION 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 glxgears_pixmap.c
+ * Yet-another-version of gears.  Originally ported to GLX by Brian Paul on
+ * 23 March 2001.  Modified to use fbconfigs by Ian Romanick on 10 Feb 2004.
+ *
+ * Command line options:
+ *    -info      print GL implementation information
+ *
+ * \author Brian Paul
+ * \author Ian Romanick <idr@us.ibm.com>
+ * \author Kristian Hoegsberg <krh@redhat.com>
+ */
+
+
+#define GLX_GLXEXT_PROTOTYPES
+
+#include <math.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <X11/Xlib.h>
+#include <X11/keysym.h>
+#include <GL/gl.h>
+#include <GL/glx.h>
+#include <GL/glxext.h>
+#include <assert.h>
+#include "pbutil.h"
+
+#define BENCHMARK
+
+#ifdef BENCHMARK
+
+/* XXX this probably isn't very portable */
+
+#include <sys/time.h>
+#include <unistd.h>
+
+/* return current time (in seconds) */
+static int
+current_time(void)
+{
+   struct timeval tv;
+#ifdef __VMS
+   (void) gettimeofday(&tv, NULL );
+#else
+   struct timezone tz;
+   (void) gettimeofday(&tv, &tz);
+#endif
+   return (int) tv.tv_sec;
+}
+
+#else /*BENCHMARK*/
+
+/* dummy */
+static int
+current_time(void)
+{
+   return 0;
+}
+
+#endif /*BENCHMARK*/
+
+
+
+#ifndef M_PI
+#define M_PI 3.14159265
+#endif
+
+
+static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
+static GLint gear1, gear2, gear3;
+static GLfloat angle = 0.0;
+
+
+/*
+ *
+ *  Draw a gear wheel.  You'll probably want to call this function when
+ *  building a display list since we do a lot of trig here.
+ * 
+ *  Input:  inner_radius - radius of hole at center
+ *          outer_radius - radius at center of teeth
+ *          width - width of gear
+ *          teeth - number of teeth
+ *          tooth_depth - depth of tooth
+ */
+static void
+gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
+     GLint teeth, GLfloat tooth_depth)
+{
+   GLint i;
+   GLfloat r0, r1, r2;
+   GLfloat angle, da;
+   GLfloat u, v, len;
+
+   r0 = inner_radius;
+   r1 = outer_radius - tooth_depth / 2.0;
+   r2 = outer_radius + tooth_depth / 2.0;
+
+   da = 2.0 * M_PI / teeth / 4.0;
+
+   glShadeModel(GL_FLAT);
+
+   glNormal3f(0.0, 0.0, 1.0);
+
+   /* draw front face */
+   glBegin(GL_QUAD_STRIP);
+   for (i = 0; i <= teeth; i++) {
+      angle = i * 2.0 * M_PI / teeth;
+      glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
+      glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
+      if (i < teeth) {
+        glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
+        glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
+                   width * 0.5);
+      }
+   }
+   glEnd();
+
+   /* draw front sides of teeth */
+   glBegin(GL_QUADS);
+   da = 2.0 * M_PI / teeth / 4.0;
+   for (i = 0; i < teeth; i++) {
+      angle = i * 2.0 * M_PI / teeth;
+
+      glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
+      glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
+      glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
+                width * 0.5);
+      glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
+                width * 0.5);
+   }
+   glEnd();
+
+   glNormal3f(0.0, 0.0, -1.0);
+
+   /* draw back face */
+   glBegin(GL_QUAD_STRIP);
+   for (i = 0; i <= teeth; i++) {
+      angle = i * 2.0 * M_PI / teeth;
+      glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
+      glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
+      if (i < teeth) {
+        glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
+                   -width * 0.5);
+        glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
+      }
+   }
+   glEnd();
+
+   /* draw back sides of teeth */
+   glBegin(GL_QUADS);
+   da = 2.0 * M_PI / teeth / 4.0;
+   for (i = 0; i < teeth; i++) {
+      angle = i * 2.0 * M_PI / teeth;
+
+      glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
+                -width * 0.5);
+      glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
+                -width * 0.5);
+      glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
+      glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
+   }
+   glEnd();
+
+   /* draw outward faces of teeth */
+   glBegin(GL_QUAD_STRIP);
+   for (i = 0; i < teeth; i++) {
+      angle = i * 2.0 * M_PI / teeth;
+
+      glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
+      glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
+      u = r2 * cos(angle + da) - r1 * cos(angle);
+      v = r2 * sin(angle + da) - r1 * sin(angle);
+      len = sqrt(u * u + v * v);
+      u /= len;
+      v /= len;
+      glNormal3f(v, -u, 0.0);
+      glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
+      glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
+      glNormal3f(cos(angle), sin(angle), 0.0);
+      glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
+                width * 0.5);
+      glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
+                -width * 0.5);
+      u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da);
+      v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da);
+      glNormal3f(v, -u, 0.0);
+      glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
+                width * 0.5);
+      glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
+                -width * 0.5);
+      glNormal3f(cos(angle), sin(angle), 0.0);
+   }
+
+   glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5);
+   glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5);
+
+   glEnd();
+
+   glShadeModel(GL_SMOOTH);
+
+   /* draw inside radius cylinder */
+   glBegin(GL_QUAD_STRIP);
+   for (i = 0; i <= teeth; i++) {
+      angle = i * 2.0 * M_PI / teeth;
+      glNormal3f(-cos(angle), -sin(angle), 0.0);
+      glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
+      glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
+   }
+   glEnd();
+}
+
+
+static void
+draw(void)
+{
+   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+   glPushMatrix();
+   glRotatef(view_rotx, 1.0, 0.0, 0.0);
+   glRotatef(view_roty, 0.0, 1.0, 0.0);
+   glRotatef(view_rotz, 0.0, 0.0, 1.0);
+
+   glPushMatrix();
+   glTranslatef(-3.0, -2.0, 0.0);
+   glRotatef(angle, 0.0, 0.0, 1.0);
+   glCallList(gear1);
+   glPopMatrix();
+
+   glPushMatrix();
+   glTranslatef(3.1, -2.0, 0.0);
+   glRotatef(-2.0 * angle - 9.0, 0.0, 0.0, 1.0);
+   glCallList(gear2);
+   glPopMatrix();
+
+   glPushMatrix();
+   glTranslatef(-3.1, 4.2, 0.0);
+   glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0);
+   glCallList(gear3);
+   glPopMatrix();
+
+   glPopMatrix();
+}
+
+
+struct gears {
+   Window win;
+   GLXContext ctx;
+   Pixmap pixmap;
+   GLXPixmap glxpixmap;
+   GC gc;
+   int width, height;
+};
+
+
+/* new window size or exposure */
+static void
+reshape(struct gears *gears, int width, int height)
+{
+   gears->width = width;
+   gears->height = height;
+}
+
+
+static void
+init(int width, int height)
+{
+   static GLfloat pos[4] = { 5.0, 5.0, 10.0, 0.0 };
+   static GLfloat red[4] = { 0.8, 0.1, 0.0, 1.0 };
+   static GLfloat green[4] = { 0.0, 0.8, 0.2, 1.0 };
+   static GLfloat blue[4] = { 0.2, 0.2, 1.0, 1.0 };
+   GLfloat h = (GLfloat) height / (GLfloat) width;
+
+   glLightfv(GL_LIGHT0, GL_POSITION, pos);
+   glEnable(GL_CULL_FACE);
+   glEnable(GL_LIGHTING);
+   glEnable(GL_LIGHT0);
+   glEnable(GL_DEPTH_TEST);
+
+   /* make the gears */
+   gear1 = glGenLists(1);
+   glNewList(gear1, GL_COMPILE);
+   glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
+   gear(1.0, 4.0, 1.0, 20, 0.7);
+   glEndList();
+
+   gear2 = glGenLists(1);
+   glNewList(gear2, GL_COMPILE);
+   glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
+   gear(0.5, 2.0, 2.0, 10, 0.7);
+   glEndList();
+
+   gear3 = glGenLists(1);
+   glNewList(gear3, GL_COMPILE);
+   glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
+   gear(1.3, 2.0, 0.5, 10, 0.7);
+   glEndList();
+
+   glEnable(GL_NORMALIZE);
+
+   glViewport(0, 0, (GLint) width, (GLint) height);
+   glMatrixMode(GL_PROJECTION);
+   glLoadIdentity();
+   glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0);
+   glMatrixMode(GL_MODELVIEW);
+   glLoadIdentity();
+   glTranslatef(0.0, 0.0, -40.0);
+}
+
+/*
+ * Create an RGB, double-buffered window.
+ * Return the window and context handles.
+ */
+static void
+make_window( Display *dpy, const char *name,
+             int x, int y, int width, int height, struct gears *gears)
+{
+   int attrib[] = { GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
+                   GLX_RENDER_TYPE,   GLX_RGBA_BIT,
+                   GLX_RED_SIZE,      1,
+                   GLX_GREEN_SIZE,    1,
+                   GLX_BLUE_SIZE,     1,
+                   GLX_DOUBLEBUFFER,  GL_FALSE,
+                   GLX_DEPTH_SIZE,    1,
+                   None };
+   GLXFBConfig * fbconfig;
+   int num_configs;
+   int scrnum;
+   XSetWindowAttributes attr;
+   unsigned long mask;
+   Window root;
+   XVisualInfo *visinfo;
+
+   gears->width = width;
+   gears->height = height;
+
+   scrnum = DefaultScreen( dpy );
+   root = RootWindow( dpy, scrnum );
+
+   fbconfig = glXChooseFBConfig(dpy, scrnum, attrib, & num_configs);
+   if (fbconfig == NULL) {
+      printf("Error: couldn't get an RGB, Double-buffered visual\n");
+      exit(1);
+   }
+
+   /* window attributes */
+   visinfo = glXGetVisualFromFBConfig(dpy, fbconfig[0]);
+   assert(visinfo != NULL);
+   attr.background_pixel = 0;
+   attr.border_pixel = 0;
+   attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
+   attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
+   mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
+
+   gears->win = XCreateWindow( dpy, root, 0, 0, width, height,
+                              0, visinfo->depth, InputOutput,
+                              visinfo->visual, mask, &attr );
+
+   /* set hints and properties */
+   {
+      XSizeHints sizehints;
+      sizehints.x = x;
+      sizehints.y = y;
+      sizehints.width  = width;
+      sizehints.height = height;
+      sizehints.flags = USSize | USPosition;
+      XSetNormalHints(dpy, gears->win, &sizehints);
+      XSetStandardProperties(dpy, gears->win, name, name,
+                              None, (char **)NULL, 0, &sizehints);
+   }
+
+   gears->gc = XCreateGC(dpy, gears->win, 0, NULL);
+
+   gears->pixmap = XCreatePixmap(dpy, gears->win,
+                                width, height, visinfo->depth);
+   if (!gears->pixmap) {
+      printf("Error: XCreatePixmap failed\n");
+      exit(-1);
+   }
+
+   gears->glxpixmap = glXCreatePixmap(dpy, fbconfig[0], gears->pixmap, NULL);
+   if (!gears->glxpixmap) {
+      printf("Error: glXCreatePixmap failed\n");
+      exit(-1);
+   }
+
+   gears->ctx = glXCreateNewContext(dpy, fbconfig[0],
+                                   GLX_RGBA_TYPE, NULL, GL_TRUE);
+   if (!gears->ctx) {
+      printf("Error: glXCreateNewContext failed\n");
+      exit(1);
+   }
+
+   XFree(fbconfig);
+}
+
+
+static void
+event_loop(Display *dpy, struct gears *gears)
+{
+   int x, y;
+
+   while (1) {
+      while (XPending(dpy) > 0) {
+         XEvent event;
+         XNextEvent(dpy, &event);
+         switch (event.type) {
+        case Expose:
+            /* we'll redraw below */
+           break;
+        case ConfigureNotify:
+           reshape(gears, event.xconfigure.width, event.xconfigure.height);
+           break;
+         case KeyPress:
+            {
+               char buffer[10];
+               int r, code;
+               code = XLookupKeysym(&event.xkey, 0);
+               if (code == XK_Left) {
+                  view_roty += 5.0;
+               }
+               else if (code == XK_Right) {
+                  view_roty -= 5.0;
+               }
+               else if (code == XK_Up) {
+                  view_rotx += 5.0;
+               }
+               else if (code == XK_Down) {
+                  view_rotx -= 5.0;
+               }
+               else {
+                  r = XLookupString(&event.xkey, buffer, sizeof(buffer),
+                                    NULL, NULL);
+                  if (buffer[0] == 27) {
+                     /* escape */
+                     return;
+                  }
+               }
+            }
+         }
+      }
+
+      /* next frame */
+      angle += 2.0;
+
+      draw();
+      glFinish();
+
+      for (x = 0; x < gears->width; x += 100)
+         for (y = 0; y < gears->width; y += 100)
+            XCopyArea(dpy, gears->pixmap, gears->win, gears->gc,
+                     50, 50, 100, 100, x, y);
+
+      /* calc framerate */
+      {
+         static int t0 = -1;
+         static int frames = 0;
+         int t = current_time();
+
+         if (t0 < 0)
+            t0 = t;
+
+         frames++;
+
+         if (t - t0 >= 5.0) {
+            GLfloat seconds = t - t0;
+            GLfloat fps = frames / seconds;
+            printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds,
+                   fps);
+            t0 = t;
+            frames = 0;
+         }
+      }
+   }
+}
+
+
+int
+main(int argc, char *argv[])
+{
+   Display *dpy;
+   const char *dpyName = NULL;
+   GLboolean printInfo = GL_FALSE;
+   struct gears gears;
+   int i, width = 200, height = 200;
+
+   for (i = 1; i < argc; i++) {
+      if (strcmp(argv[i], "-display") == 0) {
+         dpyName = argv[i+1];
+         i++;
+      }
+      else if (strcmp(argv[i], "-info") == 0) {
+         printInfo = GL_TRUE;
+      }
+   }
+
+   dpy = XOpenDisplay(dpyName);
+   if (!dpy) {
+      printf("Error: couldn't open display %s\n", XDisplayName(dpyName));
+      return -1;
+   }
+
+   make_window(dpy, "glxgears", 0, 0, width, height, &gears);
+   XMapWindow(dpy, gears.win);
+   glXMakeCurrent(dpy, gears.glxpixmap, gears.ctx);
+
+   if (printInfo) {
+      printf("GL_RENDERER   = %s\n", (char *) glGetString(GL_RENDERER));
+      printf("GL_VERSION    = %s\n", (char *) glGetString(GL_VERSION));
+      printf("GL_VENDOR     = %s\n", (char *) glGetString(GL_VENDOR));
+      printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
+   }
+
+   init(width, height);
+
+   event_loop(dpy, &gears);
+
+   glXDestroyContext(dpy, gears.ctx);
+   XDestroyWindow(dpy, gears.win);
+   glXDestroyPixmap(dpy, gears.pixmap);
+   XFreePixmap(dpy, gears.pixmap);
+   XCloseDisplay(dpy);
+
+   return 0;
+}
index 3e8e0be52031c67ab88a63ae2bf51f923d635e58..445d3ea94b6d851d9a7de65a17242c039155cbb1 100644 (file)
 #define GLX_TRANSPARENT_RGB 0x8008
 #endif
 
+#ifndef GLX_RGBA_BIT
+#define GLX_RGBA_BIT                   0x00000001
+#endif
+
+#ifndef GLX_COLOR_INDEX_BIT
+#define GLX_COLOR_INDEX_BIT            0x00000002
+#endif
 
 typedef enum
 {
@@ -81,7 +88,7 @@ struct visual_attribs
    int transparentIndexValue;
    int bufferSize;
    int level;
-   int rgba;
+   int render_type;
    int doubleBuffer;
    int stereo;
    int auxBuffers;
@@ -388,20 +395,60 @@ print_screen_info(Display *dpy, int scrnum, Bool allowDirect, GLboolean limits)
    XSetWindowAttributes attr;
    unsigned long mask;
    Window root;
-   GLXContext ctx;
+   GLXContext ctx = NULL;
    XVisualInfo *visinfo;
    int width = 100, height = 100;
 
    root = RootWindow(dpy, scrnum);
 
    visinfo = glXChooseVisual(dpy, scrnum, attribSingle);
-   if (!visinfo) {
+   if (!visinfo)
       visinfo = glXChooseVisual(dpy, scrnum, attribDouble);
-      if (!visinfo) {
-         fprintf(stderr, "Error: couldn't find RGB GLX visual\n");
-         return;
+
+   if (visinfo)
+      ctx = glXCreateContext( dpy, visinfo, NULL, allowDirect );
+
+#ifdef GLX_VERSION_1_3
+   {
+      int fbAttribSingle[] = {
+        GLX_RENDER_TYPE,   GLX_RGBA_BIT,
+        GLX_RED_SIZE,      1,
+        GLX_GREEN_SIZE,    1,
+        GLX_BLUE_SIZE,     1,
+        GLX_DOUBLEBUFFER,  GL_TRUE,
+        None };
+      int fbAttribDouble[] = {
+        GLX_RENDER_TYPE,   GLX_RGBA_BIT,
+        GLX_RED_SIZE,      1,
+        GLX_GREEN_SIZE,    1,
+        GLX_BLUE_SIZE,     1,
+        None };
+      GLXFBConfig *configs = NULL;
+      int nConfigs;
+
+      if (!visinfo)
+        configs = glXChooseFBConfig(dpy, scrnum, fbAttribSingle, &nConfigs);
+      if (!visinfo)
+        configs = glXChooseFBConfig(dpy, scrnum, fbAttribDouble, &nConfigs);
+
+      if (configs) {
+        visinfo = glXGetVisualFromFBConfig(dpy, configs[0]);
+        ctx = glXCreateNewContext(dpy, configs[0], GLX_RGBA_TYPE, NULL, allowDirect);
+        XFree(configs);
       }
    }
+#endif
+
+   if (!visinfo) {
+      fprintf(stderr, "Error: couldn't find RGB GLX visual or fbconfig\n");
+      return;
+   }
+
+   if (!ctx) {
+      fprintf(stderr, "Error: glXCreateContext failed\n");
+      XFree(visinfo);
+      return;
+   }
 
    attr.background_pixel = 0;
    attr.border_pixel = 0;
@@ -412,14 +459,6 @@ print_screen_info(Display *dpy, int scrnum, Bool allowDirect, GLboolean limits)
                       0, visinfo->depth, InputOutput,
                       visinfo->visual, mask, &attr);
 
-   ctx = glXCreateContext( dpy, visinfo, NULL, allowDirect );
-   if (!ctx) {
-      fprintf(stderr, "Error: glXCreateContext failed\n");
-      XFree(visinfo);
-      XDestroyWindow(dpy, win);
-      return;
-   }
-
    if (glXMakeCurrent(dpy, win, ctx)) {
       const char *serverVendor = glXQueryServerString(dpy, scrnum, GLX_VENDOR);
       const char *serverVersion = glXQueryServerString(dpy, scrnum, GLX_VERSION);
@@ -483,6 +522,13 @@ print_screen_info(Display *dpy, int scrnum, Bool allowDirect, GLboolean limits)
       printf("OpenGL vendor string: %s\n", glVendor);
       printf("OpenGL renderer string: %s\n", glRenderer);
       printf("OpenGL version string: %s\n", glVersion);
+#ifdef GL_VERSION_2_0
+      if (glVersion[0] >= '2' && glVersion[1] == '.') {
+         char *v = (char *) glGetString(GL_SHADING_LANGUAGE_VERSION);
+         printf("OpenGL shading language version string: %s\n", v);
+      }
+#endif
+
       printf("OpenGL extensions:\n");
       print_extension_list(glExtensions);
       if (limits)
@@ -541,12 +587,27 @@ visual_class_abbrev(int cls)
    }
 }
 
+static const char *
+visual_render_type_name(int type)
+{
+   switch (type) {
+      case GLX_RGBA_BIT:
+         return "rgba";
+      case GLX_COLOR_INDEX_BIT:
+         return "ci";
+      case GLX_RGBA_BIT | GLX_COLOR_INDEX_BIT:
+         return "rgba|ci";
+      default:
+         return "";
+      }
+}
 
-static void
+static GLboolean
 get_visual_attribs(Display *dpy, XVisualInfo *vInfo,
                    struct visual_attribs *attribs)
 {
    const char *ext = glXQueryExtensionsString(dpy, vInfo->screen);
+   int rgba;
 
    memset(attribs, 0, sizeof(struct visual_attribs));
 
@@ -563,11 +624,17 @@ get_visual_attribs(Display *dpy, XVisualInfo *vInfo,
    attribs->colormapSize = vInfo->colormap_size;
    attribs->bitsPerRGB = vInfo->bits_per_rgb;
 
-   if (glXGetConfig(dpy, vInfo, GLX_USE_GL, &attribs->supportsGL) != 0)
-      return;
+   if (glXGetConfig(dpy, vInfo, GLX_USE_GL, &attribs->supportsGL) != 0 ||
+       !attribs->supportsGL)
+      return GL_FALSE;
    glXGetConfig(dpy, vInfo, GLX_BUFFER_SIZE, &attribs->bufferSize);
    glXGetConfig(dpy, vInfo, GLX_LEVEL, &attribs->level);
-   glXGetConfig(dpy, vInfo, GLX_RGBA, &attribs->rgba);
+   glXGetConfig(dpy, vInfo, GLX_RGBA, &rgba);
+   if (rgba)
+      attribs->render_type = GLX_RGBA_BIT;
+   else
+      attribs->render_type = GLX_COLOR_INDEX_BIT;
+   
    glXGetConfig(dpy, vInfo, GLX_DOUBLEBUFFER, &attribs->doubleBuffer);
    glXGetConfig(dpy, vInfo, GLX_STEREO, &attribs->stereo);
    glXGetConfig(dpy, vInfo, GLX_AUX_BUFFERS, &attribs->auxBuffers);
@@ -596,7 +663,7 @@ get_visual_attribs(Display *dpy, XVisualInfo *vInfo,
 
    /* multisample attribs */
 #ifdef GLX_ARB_multisample
-   if (ext && strstr(ext, "GLX_ARB_multisample") == 0) {
+   if (ext && strstr(ext, "GLX_ARB_multisample")) {
       glXGetConfig(dpy, vInfo, GLX_SAMPLE_BUFFERS_ARB, &attribs->numMultisample);
       glXGetConfig(dpy, vInfo, GLX_SAMPLES_ARB, &attribs->numSamples);
    }
@@ -616,8 +683,97 @@ get_visual_attribs(Display *dpy, XVisualInfo *vInfo,
 #else
    attribs->visualCaveat = 0;
 #endif
+
+   return GL_TRUE;
+}
+
+#ifdef GLX_VERSION_1_3
+
+static int
+glx_token_to_visual_class(int visual_type)
+{
+   switch (visual_type) {
+   case GLX_TRUE_COLOR:
+      return TrueColor;
+   case GLX_DIRECT_COLOR:
+      return DirectColor;
+   case GLX_PSEUDO_COLOR:
+      return PseudoColor;
+   case GLX_STATIC_COLOR:
+      return StaticColor;
+   case GLX_GRAY_SCALE:
+      return GrayScale;
+   case GLX_STATIC_GRAY:
+      return StaticGray;
+   case GLX_NONE:
+   default:
+      return None;
+   }
+}
+
+static GLboolean
+get_fbconfig_attribs(Display *dpy, GLXFBConfig fbconfig,
+                    struct visual_attribs *attribs)
+{
+   int visual_type;
+
+   memset(attribs, 0, sizeof(struct visual_attribs));
+
+   glXGetFBConfigAttrib(dpy, fbconfig, GLX_FBCONFIG_ID, &attribs->id);
+
+#if 0
+   attribs->depth = vInfo->depth;
+   attribs->redMask = vInfo->red_mask;
+   attribs->greenMask = vInfo->green_mask;
+   attribs->blueMask = vInfo->blue_mask;
+   attribs->colormapSize = vInfo->colormap_size;
+   attribs->bitsPerRGB = vInfo->bits_per_rgb;
+#endif
+
+   glXGetFBConfigAttrib(dpy, fbconfig, GLX_X_VISUAL_TYPE, &visual_type);
+   attribs->klass = glx_token_to_visual_class(visual_type);
+
+   glXGetFBConfigAttrib(dpy, fbconfig, GLX_BUFFER_SIZE, &attribs->bufferSize);
+   glXGetFBConfigAttrib(dpy, fbconfig, GLX_LEVEL, &attribs->level);
+   glXGetFBConfigAttrib(dpy, fbconfig, GLX_RENDER_TYPE, &attribs->render_type);
+   glXGetFBConfigAttrib(dpy, fbconfig, GLX_DOUBLEBUFFER, &attribs->doubleBuffer);
+   glXGetFBConfigAttrib(dpy, fbconfig, GLX_STEREO, &attribs->stereo);
+   glXGetFBConfigAttrib(dpy, fbconfig, GLX_AUX_BUFFERS, &attribs->auxBuffers);
+
+   glXGetFBConfigAttrib(dpy, fbconfig, GLX_RED_SIZE, &attribs->redSize);
+   glXGetFBConfigAttrib(dpy, fbconfig, GLX_GREEN_SIZE, &attribs->greenSize);
+   glXGetFBConfigAttrib(dpy, fbconfig, GLX_BLUE_SIZE, &attribs->blueSize);
+   glXGetFBConfigAttrib(dpy, fbconfig, GLX_ALPHA_SIZE, &attribs->alphaSize);
+   glXGetFBConfigAttrib(dpy, fbconfig, GLX_DEPTH_SIZE, &attribs->depthSize);
+   glXGetFBConfigAttrib(dpy, fbconfig, GLX_STENCIL_SIZE, &attribs->stencilSize);
+
+   glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_RED_SIZE, &attribs->accumRedSize);
+   glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_GREEN_SIZE, &attribs->accumGreenSize);
+   glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_BLUE_SIZE, &attribs->accumBlueSize);
+   glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_ALPHA_SIZE, &attribs->accumAlphaSize);
+
+   /* get transparent pixel stuff */
+   glXGetFBConfigAttrib(dpy, fbconfig,GLX_TRANSPARENT_TYPE, &attribs->transparentType);
+   if (attribs->transparentType == GLX_TRANSPARENT_RGB) {
+     glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_RED_VALUE, &attribs->transparentRedValue);
+     glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_GREEN_VALUE, &attribs->transparentGreenValue);
+     glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_BLUE_VALUE, &attribs->transparentBlueValue);
+     glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_ALPHA_VALUE, &attribs->transparentAlphaValue);
+   }
+   else if (attribs->transparentType == GLX_TRANSPARENT_INDEX) {
+     glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_INDEX_VALUE, &attribs->transparentIndexValue);
+   }
+
+   glXGetFBConfigAttrib(dpy, fbconfig, GLX_SAMPLE_BUFFERS, &attribs->numMultisample);
+   glXGetFBConfigAttrib(dpy, fbconfig, GLX_SAMPLES, &attribs->numSamples);
+   glXGetFBConfigAttrib(dpy, fbconfig, GLX_CONFIG_CAVEAT, &attribs->visualCaveat);
+
+   return GL_TRUE;
 }
 
+#endif
+
+
 
 static void
 print_visual_attribs_verbose(const struct visual_attribs *attribs)
@@ -625,7 +781,8 @@ print_visual_attribs_verbose(const struct visual_attribs *attribs)
    printf("Visual ID: %x  depth=%d  class=%s\n",
           attribs->id, attribs->depth, visual_class_name(attribs->klass));
    printf("    bufferSize=%d level=%d renderType=%s doubleBuffer=%d stereo=%d\n",
-          attribs->bufferSize, attribs->level, attribs->rgba ? "rgba" : "ci",
+          attribs->bufferSize, attribs->level,
+         visual_render_type_name(attribs->render_type),
           attribs->doubleBuffer, attribs->stereo);
    printf("    rgba: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\n",
           attribs->redSize, attribs->greenSize,
@@ -683,16 +840,17 @@ print_visual_attribs_short(const struct visual_attribs *attribs)
    caveat = "None";
 #endif 
 
-   printf("0x%2x %2d %2s %2d %2d %2d %1s %2s %2s %2d %2d %2d %2d %2d %2d %2d",
+   printf("0x%02x %2d %2s %2d %2d %2d %c%c %c  %c %2d %2d %2d %2d %2d %2d %2d",
           attribs->id,
           attribs->depth,
           visual_class_abbrev(attribs->klass),
           attribs->transparentType != GLX_NONE,
           attribs->bufferSize,
           attribs->level,
-          attribs->rgba ? "r" : "c",
-          attribs->doubleBuffer ? "y" : ".",
-          attribs->stereo ? "y" : ".",
+          (attribs->render_type & GLX_RGBA_BIT) ? 'r' : ' ',
+          (attribs->render_type & GLX_COLOR_INDEX_BIT) ? 'c' : ' ',
+          attribs->doubleBuffer ? 'y' : '.',
+          attribs->stereo ? 'y' : '.',
           attribs->redSize, attribs->greenSize,
           attribs->blueSize, attribs->alphaSize,
           attribs->auxBuffers,
@@ -728,7 +886,7 @@ print_visual_attribs_long(const struct visual_attribs *attribs)
           attribs->transparentType != GLX_NONE,
           attribs->bufferSize,
           attribs->level,
-          attribs->rgba ? "rgba" : "ci  ",
+          visual_render_type_name(attribs->render_type),
           attribs->doubleBuffer,
           attribs->stereo,
           attribs->redSize, attribs->greenSize,
@@ -751,42 +909,86 @@ print_visual_info(Display *dpy, int scrnum, InfoMode mode)
 {
    XVisualInfo theTemplate;
    XVisualInfo *visuals;
-   int numVisuals;
+   int numVisuals, numGlxVisuals;
    long mask;
    int i;
+   struct visual_attribs attribs;
 
    /* get list of all visuals on this screen */
    theTemplate.screen = scrnum;
    mask = VisualScreenMask;
    visuals = XGetVisualInfo(dpy, mask, &theTemplate, &numVisuals);
 
-   if (mode == Verbose) {
-      for (i = 0; i < numVisuals; i++) {
-         struct visual_attribs attribs;
-         get_visual_attribs(dpy, &visuals[i], &attribs);
-         print_visual_attribs_verbose(&attribs);
-      }
+   numGlxVisuals = 0;
+   for (i = 0; i < numVisuals; i++) {
+      if (get_visual_attribs(dpy, &visuals[i], &attribs))
+        numGlxVisuals++;
    }
-   else if (mode == Normal) {
+
+   if (numGlxVisuals == 0)
+      return;
+
+   printf("%d GLX Visuals\n", numGlxVisuals);
+
+   if (mode == Normal)
       print_visual_attribs_short_header();
-      for (i = 0; i < numVisuals; i++) {
-         struct visual_attribs attribs;
-         get_visual_attribs(dpy, &visuals[i], &attribs);
+   else if (mode == Wide)
+      print_visual_attribs_long_header();
+
+   for (i = 0; i < numVisuals; i++) {
+      if (!get_visual_attribs(dpy, &visuals[i], &attribs))
+        continue;
+
+      if (mode == Verbose)
+        print_visual_attribs_verbose(&attribs);
+      else if (mode == Normal)
          print_visual_attribs_short(&attribs);
-      }
+      else if (mode == Wide) 
+         print_visual_attribs_long(&attribs);
    }
-   else if (mode == Wide) {
+   printf("\n");
+
+   XFree(visuals);
+}
+
+#ifdef GLX_VERSION_1_3
+
+static void
+print_fbconfig_info(Display *dpy, int scrnum, InfoMode mode)
+{
+   int numFBConfigs;
+   struct visual_attribs attribs;
+   GLXFBConfig *fbconfigs;
+   int i;
+
+   /* get list of all fbconfigs on this screen */
+   fbconfigs = glXGetFBConfigs(dpy, scrnum, &numFBConfigs);
+
+   if (numFBConfigs == 0)
+      return;
+
+   printf("%d GLXFBConfigs:\n", numFBConfigs);
+   if (mode == Normal)
+      print_visual_attribs_short_header();
+   else if (mode == Wide)
       print_visual_attribs_long_header();
-      for (i = 0; i < numVisuals; i++) {
-         struct visual_attribs attribs;
-         get_visual_attribs(dpy, &visuals[i], &attribs);
+
+   for (i = 0; i < numFBConfigs; i++) {
+      get_fbconfig_attribs(dpy, fbconfigs[i], &attribs);
+
+      if (mode == Verbose) 
+         print_visual_attribs_verbose(&attribs);
+      else if (mode == Normal)
+        print_visual_attribs_short(&attribs);
+      else if (mode == Wide)
          print_visual_attribs_long(&attribs);
-      }
    }
+   printf("\n");
 
-   XFree(visuals);
+   XFree(fbconfigs);
 }
 
+#endif
 
 /*
  * Stand-alone Mesa doesn't really implement the GLX protocol so it
@@ -860,7 +1062,7 @@ find_best_visual(Display *dpy, int scrnum)
       /* see if this vis is better than bestVis */
       if ((!bestVis.supportsGL && vis.supportsGL) ||
           (bestVis.visualCaveat != GLX_NONE_EXT) ||
-          (!bestVis.rgba && vis.rgba) ||
+          (!(bestVis.render_type & GLX_RGBA_BIT) && (vis.render_type & GLX_RGBA_BIT)) ||
           (!bestVis.doubleBuffer && vis.doubleBuffer) ||
           (bestVis.redSize < vis.redSize) ||
           (bestVis.greenSize < vis.greenSize) ||
@@ -957,6 +1159,9 @@ main(int argc, char *argv[])
          print_screen_info(dpy, scrnum, allowDirect, limits);
          printf("\n");
          print_visual_info(dpy, scrnum, mode);
+#ifdef GLX_VERSION_1_3
+         print_fbconfig_info(dpy, scrnum, mode);
+#endif
          if (scrnum + 1 < numScreens)
             printf("\n\n");
       }
diff --git a/progs/xdemos/glxsnoop.c b/progs/xdemos/glxsnoop.c
new file mode 100644 (file)
index 0000000..2e95134
--- /dev/null
@@ -0,0 +1,377 @@
+/**
+ * Display/snoop the z/stencil/back/front buffers of another app's window.
+ * Also, an example of the need for shared ancillary renderbuffers.
+ *
+ * Hint: use 'xwininfo' to get a window's ID.
+ *
+ * Brian Paul
+ * 11 Oct 2007
+ */
+
+#define GL_GLEXT_PROTOTYPES
+
+#include <GL/gl.h>
+#include <GL/glx.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <X11/keysym.h>
+
+
+#define Z_BUFFER 1
+#define STENCIL_BUFFER 2
+#define BACK_BUFFER 3
+#define FRONT_BUFFER 4
+
+
+static int Buffer = BACK_BUFFER;
+static int WindowID = 0;
+static const char *DisplayName = NULL;
+static GLXContext Context = 0;
+static int Width, Height;
+
+
+/**
+ * Grab the z/stencil/back/front image from the srcWin and display it
+ * (possibly converted to grayscale) in the dstWin.
+ */
+static void
+redraw(Display *dpy, Window srcWin, Window dstWin )
+{
+   GLubyte *image = malloc(Width * Height * 4);
+
+   glXMakeCurrent(dpy, srcWin, Context);
+   glPixelStorei(GL_PACK_ALIGNMENT, 1);
+   if (Buffer == BACK_BUFFER) {
+      glReadBuffer(GL_BACK);
+      glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, image);
+   }
+   else if (Buffer == FRONT_BUFFER) {
+      glReadBuffer(GL_FRONT);
+      glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, image);
+   }
+   else if (Buffer == Z_BUFFER) {
+      GLfloat *z = malloc(Width * Height * sizeof(GLfloat));
+      int i;
+      glReadPixels(0, 0, Width, Height, GL_DEPTH_COMPONENT, GL_FLOAT, z);
+      for (i = 0; i < Width * Height; i++) {
+         image[i*4+0] =
+         image[i*4+1] =
+         image[i*4+2] = (GLint) (255.0 * z[i]);
+         image[i*4+3] = 255;
+      }
+      free(z);
+   }
+   else if (Buffer == STENCIL_BUFFER) {
+      GLubyte *sten = malloc(Width * Height * sizeof(GLubyte));
+      int i, min = 100, max = -1;
+      float step;
+      int sz;
+      glGetIntegerv(GL_STENCIL_BITS, &sz);
+      glReadPixels(0, 0, Width, Height,
+                   GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, sten);
+      /* find min/max for converting stencil to grayscale */
+      for (i = 0; i < Width * Height; i++) {
+         if (sten[i] < min)
+            min = sten[i];
+         if (sten[i] > max)
+            max = sten[i];
+      }
+      if (min == max)
+         step = 0;
+      else
+         step = 255.0 / (float) (max - min);
+      for (i = 0; i < Width * Height; i++) {
+         image[i*4+0] =
+         image[i*4+1] =
+         image[i*4+2] = (GLint) ((sten[i] - min) * step);
+         image[i*4+3] = 255;
+      }
+      free(sten);
+   }
+
+   glXMakeCurrent(dpy, dstWin, Context);
+   glWindowPos2iARB(0, 0);
+   glDrawBuffer(GL_FRONT);
+   glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, image);
+   glFlush();
+
+   free(image);
+}
+
+
+static void
+set_window_title(Display *dpy, Window win, const char *title)
+{
+   XSizeHints sizehints;
+   sizehints.flags = 0;
+   XSetStandardProperties(dpy, win, title, title,
+                          None, (char **)NULL, 0, &sizehints);
+}
+
+
+static Window
+make_gl_window(Display *dpy, XVisualInfo *visinfo, int width, int height)
+{
+   int scrnum;
+   XSetWindowAttributes attr;
+   unsigned long mask;
+   Window root;
+   Window win;
+   int x = 0, y = 0;
+   char *name = NULL;
+
+   scrnum = DefaultScreen( dpy );
+   root = RootWindow( dpy, scrnum );
+
+   /* window attributes */
+   attr.background_pixel = 0;
+   attr.border_pixel = 0;
+   attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
+   attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
+   mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
+
+   win = XCreateWindow( dpy, root, x, y, width, height,
+                       0, visinfo->depth, InputOutput,
+                       visinfo->visual, mask, &attr );
+
+   /* set hints and properties */
+   {
+      XSizeHints sizehints;
+      sizehints.x = x;
+      sizehints.y = y;
+      sizehints.width  = width;
+      sizehints.height = height;
+      sizehints.flags = USSize | USPosition;
+      XSetNormalHints(dpy, win, &sizehints);
+      XSetStandardProperties(dpy, win, name, name,
+                              None, (char **)NULL, 0, &sizehints);
+   }
+
+   return win;
+}
+
+
+static void
+update_window_title(Display *dpy, Window win)
+{
+   char title[1000], *buf;
+
+   switch (Buffer) {
+   case Z_BUFFER:
+      buf = "Z";
+      break;
+   case STENCIL_BUFFER:
+      buf = "Stencil";
+      break;
+   case BACK_BUFFER:
+      buf = "Back";
+      break;
+   case FRONT_BUFFER:
+      buf = "Front";
+      break;
+   default:
+      buf = "";
+   }
+
+   sprintf(title, "glxsnoop window 0x%x (%s buffer)", (int) WindowID, buf);
+
+   set_window_title(dpy, win, title);
+}
+
+
+static void
+keypress(Display *dpy, Window win, char key)
+{
+   switch (key) {
+   case 27:
+      /* escape */
+      exit(0);
+      break;
+   case 's':
+      Buffer = STENCIL_BUFFER;
+      break;
+   case 'z':
+      Buffer = Z_BUFFER;
+      break;
+   case 'f':
+      Buffer = FRONT_BUFFER;
+      break;
+   case 'b':
+      Buffer = BACK_BUFFER;
+      break;
+   default:
+      return;
+   }
+
+   update_window_title(dpy, win);
+   redraw(dpy, WindowID, win);
+}
+
+
+static void
+event_loop(Display *dpy, Window win)
+{
+   XEvent event;
+
+   while (1) {
+      XNextEvent( dpy, &event );
+
+      switch (event.type) {
+      case Expose:
+         redraw(dpy, WindowID, win);
+         break;
+      case ConfigureNotify:
+         /*resize( event.xconfigure.width, event.xconfigure.height );*/
+         break;
+      case KeyPress:
+         {
+            char buffer[10];
+            int r, code;
+            code = XLookupKeysym(&event.xkey, 0);
+            if (code == XK_Left) {
+            }
+            else {
+               r = XLookupString(&event.xkey, buffer, sizeof(buffer),
+                                 NULL, NULL);
+               keypress(dpy, win, buffer[0]);
+            }
+         }
+      default:
+         /* nothing */
+         ;
+      }
+   }
+}
+
+
+static VisualID
+get_window_visualid(Display *dpy, Window win)
+{
+   XWindowAttributes attr;
+
+   if (XGetWindowAttributes(dpy, win, &attr)) {
+      return attr.visual->visualid;
+   }
+   else {
+      return 0;
+   }
+}
+
+
+static void
+get_window_size(Display *dpy, Window win, int *w, int *h)
+{
+   XWindowAttributes attr;
+
+   if (XGetWindowAttributes(dpy, win, &attr)) {
+      *w = attr.width;
+      *h = attr.height;
+   }
+   else {
+      *w = *h = 0;
+   }
+}
+
+
+static XVisualInfo *
+visualid_to_visualinfo(Display *dpy, VisualID vid)
+{
+   XVisualInfo *vinfo, templ;
+   long mask;
+   int n;
+
+   templ.visualid = vid;
+   mask = VisualIDMask;
+
+   vinfo = XGetVisualInfo(dpy, mask, &templ, &n);
+   return vinfo;
+}
+
+
+static void
+key_usage(void)
+{
+   printf("Keyboard:\n");
+   printf("  z - display Z buffer\n");
+   printf("  s - display stencil buffer\n");
+   printf("  f - display front color buffer\n");
+   printf("  b - display back buffer\n");
+}
+
+
+static void
+usage(void)
+{
+   printf("Usage: glxsnoop [-display dpy] windowID\n");
+   key_usage();
+}
+
+
+static void
+parse_opts(int argc, char *argv[])
+{
+   int i;
+
+   for (i = 1; i < argc; i++) {
+      if (strcmp(argv[i], "-h") == 0) {
+         usage();
+         exit(0);
+      }
+      else if (strcmp(argv[i], "-display") == 0) {
+         DisplayName = argv[i + 1];
+         i++;
+      }
+      else {
+         if (argv[i][0] == '0' && argv[i][1] == 'x') {
+            /* hex */
+            WindowID = strtol(argv[i], NULL, 16);
+         }
+         else {
+            WindowID = atoi(argv[i]);
+         }
+         break;
+      }
+   }
+
+   if (!WindowID) {
+      usage();
+      exit(0);
+   }
+}
+
+
+int
+main( int argc, char *argv[] )
+{
+   Display *dpy;
+   VisualID vid;
+   XVisualInfo *visinfo;
+   Window win;
+
+   parse_opts(argc, argv);
+
+   key_usage();
+
+   dpy = XOpenDisplay(DisplayName);
+
+   /* find the VisualID for the named window */
+   vid = get_window_visualid(dpy, WindowID);
+   get_window_size(dpy, WindowID, &Width, &Height);
+
+   visinfo = visualid_to_visualinfo(dpy, vid);
+
+   Context = glXCreateContext( dpy, visinfo, NULL, True );
+   if (!Context) {
+      printf("Error: glXCreateContext failed\n");
+      exit(1);
+   }
+
+   win = make_gl_window(dpy, visinfo, Width, Height);
+   XMapWindow(dpy, win);
+   update_window_title(dpy, win);
+
+   event_loop( dpy, win );
+
+   return 0;
+}
index d9be984be57be77e8dba3f532b31a5a4810ff574..e429d58ecc46fb5e827c49085c09ad21cb3d70a5 100644 (file)
@@ -814,6 +814,11 @@ main(int argc, char *argv[])
 
    init();
 
+   /* Set initial projection/viewing transformation.
+    * same as glxgears.c
+    */
+   reshape(300, 300);
+
    event_loop(dpy, win);
 
    glXDestroyContext(dpy, ctx);
diff --git a/progs/xdemos/ipc.c b/progs/xdemos/ipc.c
new file mode 100644 (file)
index 0000000..c872d16
--- /dev/null
@@ -0,0 +1,264 @@
+/* Copyright (c) 2003 Tungsten Graphics, Inc.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files ("the
+ * Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:  The above copyright notice, the Tungsten
+ * Graphics splash screen, and this permission notice shall be included
+ * in all copies or substantial portions of the Software.  THE SOFTWARE
+ * IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ */
+
+/*
+ * Simple IPC API
+ * Brian Paul
+ */
+
+
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <unistd.h>
+#include <sys/socket.h>
+#include "ipc.h"
+
+#if defined(IRIX) || defined(irix)
+typedef int socklen_t;
+#endif
+
+#define NO_DELAY 1
+
+#define DEFAULT_MASTER_PORT 7011
+
+
+/*
+ * Return my hostname in <nameOut>.
+ * Return 1 for success, 0 for error.
+ */
+int
+MyHostName(char *nameOut, int maxNameLength)
+{
+    int k = gethostname(nameOut, maxNameLength);
+    return k==0;
+}
+
+
+/*
+ * Create a socket attached to a port.  Later, we can call AcceptConnection
+ * on the socket returned from this function.
+ * Return the new socket number or -1 if error.
+ */
+int
+CreatePort(int *port)
+{
+    char hostname[1000];
+    struct sockaddr_in servaddr;
+    struct hostent *hp;
+    int so_reuseaddr = 1;
+    int tcp_nodelay = 1;
+    int sock, k;
+
+    /* create socket */
+    sock = socket(AF_INET, SOCK_STREAM, 0);
+    assert(sock > 2);
+
+    /* get my host name */
+    k = gethostname(hostname, 1000);
+    assert(k == 0);
+
+    /* get hostent info */
+    hp = gethostbyname(hostname);
+    assert(hp);
+
+    /* initialize the servaddr struct */
+    memset(&servaddr, 0, sizeof(servaddr) );
+    servaddr.sin_family = AF_INET;
+    servaddr.sin_port = htons((unsigned short) (*port));
+    memcpy((char *) &servaddr.sin_addr, hp->h_addr,
+          sizeof(servaddr.sin_addr));
+
+    /* deallocate when we exit */
+    k = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
+                  (char *) &so_reuseaddr, sizeof(so_reuseaddr));
+    assert(k==0);
+
+    /* send packets immediately */
+#if NO_DELAY
+    k = setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
+                  (char *) &tcp_nodelay, sizeof(tcp_nodelay));
+    assert(k==0);
+#endif
+
+    if (*port == 0)
+        *port = DEFAULT_MASTER_PORT;
+
+    k = 1;
+    while (k && (*port < 65534)) {
+       /* bind our address to the socket */
+       servaddr.sin_port = htons((unsigned short) (*port));
+       k = bind(sock, (struct sockaddr *) &servaddr, sizeof(servaddr));
+        if (k)
+           *port = *port + 1;
+    }
+
+#if 0
+    printf("###### Real Port: %d\n", *port);
+#endif
+
+    /* listen for connections */
+    k = listen(sock, 100);
+    assert(k == 0);
+
+    return sock;
+}
+
+
+/*
+ * Accept a connection on the named socket.
+ * Return a new socket for the new connection, or -1 if error.
+ */
+int
+AcceptConnection(int socket)
+{
+    struct sockaddr addr;
+    socklen_t addrLen;
+    int newSock;
+
+    addrLen = sizeof(addr);
+    newSock = accept(socket, &addr, &addrLen);
+    if (newSock == 1)
+       return -1;
+    else
+       return newSock;
+}
+
+
+/*
+ * Contact the server running on the given host on the named port.
+ * Return socket number or -1 if error.
+ */
+int
+Connect(const char *hostname, int port)
+{
+    struct sockaddr_in servaddr;
+    struct hostent *hp;
+    int sock, k;
+    int tcp_nodelay = 1;
+
+    assert(port);
+
+    sock = socket(AF_INET, SOCK_STREAM, 0);
+    assert(sock >= 0);
+
+    hp = gethostbyname(hostname);
+    assert(hp);
+
+    memset(&servaddr, 0, sizeof(servaddr));
+    servaddr.sin_family = AF_INET;
+    servaddr.sin_port = htons((unsigned short) port);
+    memcpy((char *) &servaddr.sin_addr, hp->h_addr, sizeof(servaddr.sin_addr));
+
+    k = connect(sock, (struct sockaddr *) &servaddr, sizeof(servaddr));
+    if (k != 0) {
+       perror("Connect:");
+       return -1;
+    }
+
+#if NO_DELAY
+    /* send packets immediately */
+    k = setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
+                  (char *) &tcp_nodelay, sizeof(tcp_nodelay));
+    assert(k==0);
+#endif
+
+    return sock;
+}
+
+
+void
+CloseSocket(int socket)
+{
+    close(socket);
+}
+
+
+int
+SendData(int socket, const void *data, int bytes)
+{
+    int sent = 0;
+    int b;
+
+    while (sent < bytes) {
+        b = write(socket, (char *) data + sent, bytes - sent);
+        if (b <= 0)
+            return -1; /* something broke */
+        sent += b;
+    }
+    return sent;
+}
+
+
+int
+ReceiveData(int socket, void *data, int bytes)
+{
+    int received = 0, b;
+
+    while (received < bytes) {
+        b = read(socket, (char *) data + received, bytes - received);
+        if (b <= 0)
+            return -1;
+        received += b;
+    }
+    return received;
+}
+
+
+int
+SendString(int socket, const char *str)
+{
+    const int len = strlen(str);
+    int sent, b;
+
+    /* first, send a 4-byte length indicator */
+    b = write(socket, &len, sizeof(len));
+    if (b <= 0)
+       return -1;
+
+    sent = SendData(socket, str, len);
+    assert(sent == len);
+    return sent;
+}
+
+
+int
+ReceiveString(int socket, char *str, int maxLen)
+{
+    int len, received, b;
+
+    /* first, read 4 bytes to see how long of string to receive */
+    b = read(socket, &len, sizeof(len));
+    if (b <= 0)
+       return -1;
+
+    assert(len <= maxLen);  /* XXX fix someday */
+    assert(len >= 0);
+    received = ReceiveData(socket, str, len);
+    assert(received != -1);
+    assert(received == len);
+    str[len] = 0;
+    return received;
+}
diff --git a/progs/xdemos/ipc.h b/progs/xdemos/ipc.h
new file mode 100644 (file)
index 0000000..3f43445
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef IPC_H
+#define IPC_H
+
+
+extern int MyHostName(char *nameOut, int maxNameLength);
+extern int CreatePort(int *port);
+extern int AcceptConnection(int socket);
+extern int Connect(const char *hostname, int port);
+extern void CloseSocket(int socket);
+extern int SendData(int socket, const void *data, int bytes);
+extern int ReceiveData(int socket, void *data, int bytes);
+extern int SendString(int socket, const char *str);
+extern int ReceiveString(int socket, char *str, int maxLen);
+
+
+#endif /* IPC_H */
index 0ad9147aea6d9be65775353a652189cf4198752e..6c5abf383be7640ccd460077e0e1bb9f08f6c229 100644 (file)
@@ -47,7 +47,6 @@ PERFORMANCE OF THIS SOFTWARE.
 
 
 #include <GL/glx.h>
-#include <GL/glu.h>
 #include <X11/keysym.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -135,7 +134,7 @@ int main(int argc, char** argv) {
 
     /* set up viewing parameters */
     glMatrixMode(GL_PROJECTION);
-    gluPerspective(20, 1, 10, 20);
+    glFrustum(-1, 1, -1, 1, 6, 20);
     glMatrixMode(GL_MODELVIEW);
     glTranslatef(0, 0, -15);
 
index d0bbd1b0fce56a9df74a0df29eaa1a18d0969508..ce133d012dc6193de7b82dc4d676065e6c3d1715 100644 (file)
  * Test if we pixel buffers are available for a particular X screen.
  * Input:  dpy - the X display
  *         screen - screen number
- * Return:  0 = pixel buffers not available.
- *          1 = pixel buffers are available via GLX 1.3.
- *          2 = pixel buffers are available via GLX_SGIX_fbconfig/pbuffer.
+ * Return:  0 = fbconfigs not available.
+ *          1 = fbconfigs are available via GLX 1.3.
+ *          2 = fbconfigs and pbuffers are available via GLX_SGIX_fbconfig
  */
 int
-QueryPbuffers(Display *dpy, int screen)
+QueryFBConfig(Display *dpy, int screen)
 {
 #if defined(GLX_VERSION_1_3)
    {
@@ -40,36 +40,55 @@ QueryPbuffers(Display *dpy, int screen)
    }
 #endif
 
-#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer)
    /* Try the SGIX extensions */
    {
       char *extensions;
       extensions = (char *) glXQueryServerString(dpy, screen, GLX_EXTENSIONS);
-      if (!extensions ||
-          !strstr(extensions,"GLX_SGIX_fbconfig") ||
-          !strstr(extensions,"GLX_SGIX_pbuffer")) {
-         return 0;
+      if (extensions && strstr(extensions,"GLX_SGIX_fbconfig")) {
+        return 2;
       }
-      return 2;
    }
-#endif
 
    return 0;
 }
 
+/**
+ * Test if we pixel buffers are available for a particular X screen.
+ * Input:  dpy - the X display
+ *         screen - screen number
+ * Return:  0 = pixel buffers not available.
+ *          1 = pixel buffers are available via GLX 1.3.
+ *          2 = pixel buffers are available via GLX_SGIX_fbconfig/pbuffer.
+ */
+int
+QueryPbuffers(Display *dpy, int screen)
+{
+   int ret;
 
+   ret = QueryFBConfig(dpy, screen);
+   if (ret == 2) {
+      char *extensions;
+      extensions = (char *) glXQueryServerString(dpy, screen, GLX_EXTENSIONS);
+      if (extensions && strstr(extensions, "GLX_SGIX_pbuffer"))
+        return 2;
+      else
+        return 0;
+   }
+   else
+      return ret;
+}
 
 FBCONFIG *
 ChooseFBConfig(Display *dpy, int screen, const int attribs[], int *nConfigs)
 {
-   int pbSupport = QueryPbuffers(dpy, screen);
+   int fbcSupport = QueryPbuffers(dpy, screen);
 #if defined(GLX_VERSION_1_3)
-   if (pbSupport == 1) {
+   if (fbcSupport == 1) {
       return glXChooseFBConfig(dpy, screen, attribs, nConfigs);
    }
 #endif
 #if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer)
-   if (pbSupport == 2) {
+   if (fbcSupport == 2) {
       return glXChooseFBConfigSGIX(dpy, screen, (int *) attribs, nConfigs);
    }
 #endif
@@ -80,14 +99,14 @@ ChooseFBConfig(Display *dpy, int screen, const int attribs[], int *nConfigs)
 FBCONFIG *
 GetAllFBConfigs(Display *dpy, int screen, int *nConfigs)
 {
-   int pbSupport = QueryPbuffers(dpy, screen);
+   int fbcSupport = QueryFBConfig(dpy, screen);
 #if defined(GLX_VERSION_1_3)
-   if (pbSupport == 1) {
+   if (fbcSupport == 1) {
       return glXGetFBConfigs(dpy, screen, nConfigs);
    }
 #endif
 #if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer)
-   if (pbSupport == 2) {
+   if (fbcSupport == 2) {
       /* The GLX_SGIX_fbconfig extensions says to pass NULL to get list
        * of all available configurations.
        */
@@ -101,14 +120,14 @@ GetAllFBConfigs(Display *dpy, int screen, int *nConfigs)
 XVisualInfo *
 GetVisualFromFBConfig(Display *dpy, int screen, FBCONFIG config)
 {
-   int pbSupport = QueryPbuffers(dpy, screen);
+   int fbcSupport = QueryFBConfig(dpy, screen);
 #if defined(GLX_VERSION_1_3)
-   if (pbSupport == 1) {
+   if (fbcSupport == 1) {
       return glXGetVisualFromFBConfig(dpy, config);
    }
 #endif
 #if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer)
-   if (pbSupport == 2) {
+   if (fbcSupport == 2) {
       return glXGetVisualFromFBConfigSGIX(dpy, config);
    }
 #endif
@@ -130,11 +149,11 @@ GetFBConfigAttrib(Display *dpy, int screen,
                   int attrib
                   )
 {
-   int pbSupport = QueryPbuffers(dpy, screen);
+   int fbcSupport = QueryFBConfig(dpy, screen);
    int value = 0;
 
 #if defined(GLX_VERSION_1_3)
-   if (pbSupport == 1) {
+   if (fbcSupport == 1) {
       /* ok */
       if (glXGetFBConfigAttrib(dpy, config, attrib, &value) != 0) {
          value = 0;
@@ -145,7 +164,7 @@ GetFBConfigAttrib(Display *dpy, int screen,
 #endif
 
 #if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer)
-   if (pbSupport == 2) {
+   if (fbcSupport == 2) {
       if (glXGetFBConfigAttribSGIX(dpy, config, attrib, &value) != 0) {
          value = 0;
       }
@@ -295,9 +314,9 @@ PrintFBConfigInfo(Display *dpy, int screen, FBCONFIG config, Bool horizFormat)
 GLXContext
 CreateContext(Display *dpy, int screen, FBCONFIG config)
 {
-   int pbSupport = QueryPbuffers(dpy, screen);
+   int fbcSupport = QueryFBConfig(dpy, screen);
 #if defined(GLX_VERSION_1_3)
-   if (pbSupport == 1) {
+   if (fbcSupport == 1) {
       /* GLX 1.3 */
       GLXContext c;
       c = glXCreateNewContext(dpy, config, GLX_RGBA_TYPE, NULL, True);
@@ -309,7 +328,7 @@ CreateContext(Display *dpy, int screen, FBCONFIG config)
    }
 #endif
 #if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer)
-   if (pbSupport == 2) {
+   if (fbcSupport == 2) {
       GLXContext c;
       c = glXCreateContextWithConfigSGIX(dpy, config, GLX_RGBA_TYPE_SGIX, NULL, True);
       if (!c) {
@@ -393,6 +412,7 @@ CreatePbuffer(Display *dpy, int screen, FBCONFIG config,
       pBuffer = None;
    }
 
+   XSync(dpy, False);
    /* Restore original X error handler */
    (void) XSetErrorHandler(oldHandler);
 
index e95b2565a23172d883b2e5ea09d0eb1e3bdb3081..d420522ff0132dce784373d7ea608ac9f5afdf2d 100644 (file)
@@ -26,6 +26,9 @@
 #endif
 
 
+extern int
+QueryFBConfig(Display *dpy, int screen);
+
 extern int
 QueryPbuffers(Display *dpy, int screen);
 
index dbbc0b4ff72720a585e04845650a4e5c84e2b7b2..5ff09708be6b71091430ac4b1f2c49255ab7b5e9 100644 (file)
@@ -34,7 +34,6 @@
 static int Width=500, Height=500;
 
 static float Xangle = 0.0, Yangle = 0.0;
-static int Redraw = 0;
 static int Sides = 5;
 static int MinSides = 3;
 static int MaxSides = 20;
index fab0069a716c49c95a9cd9ec511defd5ec581cd5..4f65da0e3b73acf2f3b10ff82633597d843df252 100644 (file)
@@ -33,7 +33,7 @@ $(TOP)/$(LIB_DIR):
 
 
 clean:
-       @for dir in $(SUBDIRS) ; do \
+       -@for dir in $(SUBDIRS) ; do \
                if [ -d $$dir ] ; then \
                        (cd $$dir && $(MAKE) clean) ; \
                fi \
index 082d762183862eb6d677f299276c4ba44341d618..024453f8bb1cec9a872371e7508d02aa98522384 100644 (file)
@@ -11,14 +11,14 @@ default: subdirs
 subdirs:
        @for dir in $(SUBDIRS) ; do \
                if [ -d $$dir ] ; then \
-                       (cd $$dir ; $(MAKE)) || exit 1 ; \
+                       (cd $$dir && $(MAKE)) || exit 1 ; \
                fi \
        done
 
 
 clean:
-       @for dir in $(SUBDIRS) ; do \
+       -@for dir in $(SUBDIRS) ; do \
                if [ -d $$dir ] ; then \
-                       (cd $$dir ; $(MAKE) clean) ; \
+                       (cd $$dir && $(MAKE) clean) ; \
                fi \
        done
index e5a7be2438177668a4f091a2968319ad96de3588..6ca25aa5d656a60abfe9efc447cfc35dc4b632fa 100644 (file)
@@ -21,10 +21,12 @@ default: $(TOP)/$(LIB_DIR)/demodriver.so
 
 
 $(TOP)/$(LIB_DIR)/demodriver.so: $(OBJECTS)
-       $(TOP)/bin/mklib -o demodriver.so -noprefix $(OBJECTS)
+       $(MKLIB) -o demodriver.so -noprefix -linker '$(CC)' \
+               -ldflags '$(LDFLAGS)' -install $(TOP)/$(LIB_DIR) \
+               $(OBJECTS)
 
 
 
 clean:
-       rm -f *.o
-       rm -f *.so
+       -rm -f *.o
+       -rm -f *.so
index a41aca43709ff4a40c0b16f3ff56e53c4c293cc5..d7eba653b2d6919c61e283d33a1a96aa490ba73e 100644 (file)
@@ -44,13 +44,14 @@ default: depend library Makefile
 library: $(TOP)/$(LIB_DIR)/libEGLdri.so
 
 $(TOP)/$(LIB_DIR)/libEGLdri.so: $(OBJECTS)
-       $(TOP)/bin/mklib -o EGLdri -major 1 -minor 0 \
-               -install $(TOP)/$(LIB_DIR) -ldl $(OBJECTS) $(DRM_LIB)
+       $(MKLIB) -o EGLdri -linker '$(CC)' -ldflags '$(LDFLAGS)' \
+               -major 1 -minor 0 \
+               -install $(TOP)/$(LIB_DIR) -ldl $(OBJECTS) $(LIBS)
 
 
 clean:
-       rm -f *.o
-       rm -f *.so
+       -rm -f *.o
+       -rm -f *.so
 
 depend: $(SOURCES) $(HEADERS)
        @ echo "running $(MKDEP)"
index 96742bb4bc65b2ded4602a4378e7bfd161e70083..8ea60c0199df8e095e476036e112c12b031bc5fe 100644 (file)
@@ -61,14 +61,15 @@ default: depend library
 library: $(TOP)/$(LIB_DIR)/libEGL.so
 
 $(TOP)/$(LIB_DIR)/libEGL.so: $(OBJECTS)
-       $(TOP)/bin/mklib -o EGL -major 1 -minor 0 \
+       $(MKLIB) -o EGL -linker '$(CC)' -ldflags '$(LDFLAGS)' \
+               -major 1 -minor 0 \
                -install $(TOP)/$(LIB_DIR) -ldl $(OBJECTS) $(LIBS)
 
 
 
 clean:
-       rm -f *.o *.so*
-       rm -f core.*
+       -rm -f *.o *.so*
+       -rm -f core.*
 
 
 depend: $(SOURCES) $(HEADERS)
index aa77021daf34146cbffa8aaf66e93fd9c3764066..36bd3623e7fecbbd7b86d0dcab321617857eb088 100644 (file)
@@ -3,6 +3,7 @@ include $(TOP)/configs/current
 
 
 SUBDIRS = auxiliary drivers
+# Note winsys/ needs to be built after src/mesa
 
 
 default: subdirs
index 44563803f90ff5bfdd4d6cf1a5c8b769008bca15..79a19d6be2bb543e9c980f8e1cf850d438b13c77 100644 (file)
@@ -46,6 +46,7 @@
 struct exec_vertex_shader {
    struct draw_vertex_shader base;
    struct tgsi_exec_machine *machine;
+   const struct tgsi_token *machine_tokens;
 };
 
 static struct exec_vertex_shader *exec_vertex_shader( struct draw_vertex_shader *vs )
@@ -62,12 +63,16 @@ vs_exec_prepare( struct draw_vertex_shader *shader,
 {
    struct exec_vertex_shader *evs = exec_vertex_shader(shader);
 
-   /* specify the vertex program to interpret/execute */
-   tgsi_exec_machine_bind_shader(evs->machine,
-                                shader->state.tokens,
-                                PIPE_MAX_SAMPLERS,
-                                NULL /*samplers*/ );
-
+   /* Specify the vertex program to interpret/execute.
+    * Avoid rebinding when possible.
+    */
+   if (evs->machine_tokens != shader->state.tokens) {
+      tgsi_exec_machine_bind_shader(evs->machine,
+                                    shader->state.tokens,
+                                    PIPE_MAX_SAMPLERS,
+                                    NULL /*samplers*/ );
+      evs->machine_tokens = shader->state.tokens;
+   }
 }
 
 
diff --git a/src/gallium/auxiliary/rtasm/rtasm_ppc.c b/src/gallium/auxiliary/rtasm/rtasm_ppc.c
new file mode 100644 (file)
index 0000000..534a235
--- /dev/null
@@ -0,0 +1,365 @@
+/**************************************************************************
+ *
+ * Copyright (C) 2008 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
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * PPC code generation.
+ * \author Brian Paul
+ */
+
+
+#include "util/u_memory.h"
+#include "pipe/p_debug.h"
+#include "rtasm_ppc.h"
+
+
+void
+ppc_init_func(struct ppc_function *p, unsigned max_inst)
+{
+    p->store = align_malloc(max_inst * PPC_INST_SIZE, 16);
+    p->num_inst = 0;
+    p->max_inst = max_inst;
+    p->vec_used = ~0;
+}
+
+
+void
+ppc_release_func(struct ppc_function *p)
+{
+    assert(p->num_inst <= p->max_inst);
+    if (p->store != NULL) {
+        align_free(p->store);
+    }
+    p->store = NULL;
+}
+
+
+/**
+ * Alloate a vector register.
+ * \return register index or -1 if none left.
+ */
+int
+ppc_allocate_vec_register(struct ppc_function *p, int reg)
+{
+   unsigned i;
+   for (i = 0; i < PPC_NUM_VEC_REGS; i++) {
+      const uint64_t mask = 1 << i;
+      if ((p->vec_used & mask) != 0) {
+         p->vec_used &= ~mask;
+         return i;
+      }
+   }
+
+   return -1;
+}
+
+
+/**
+ * Mark the given vector register as "unallocated".
+ */
+void
+ppc_release_vec_register(struct ppc_function *p, int reg)
+{
+   assert(reg < PPC_NUM_VEC_REGS);
+   assert((p->vec_used & (1 << reg)) == 0);
+
+   p->vec_used |= (1 << reg);
+}
+
+
+
+union vx_inst {
+   uint32_t bits;
+   struct {
+      unsigned op:6;
+      unsigned vD:5;
+      unsigned vA:5;
+      unsigned vB:5;
+      unsigned op2:11;
+   } inst;
+};
+
+union vxr_inst {
+   uint32_t bits;
+   struct {
+      unsigned op:6;
+      unsigned vD:5;
+      unsigned vA:5;
+      unsigned vB:5;
+      unsigned rC:1;
+      unsigned op2:10;
+   } inst;
+};
+
+union va_inst {
+   uint32_t bits;
+   struct {
+      unsigned op:6;
+      unsigned vD:5;
+      unsigned vA:5;
+      unsigned vB:5;
+      unsigned vC:5;
+      unsigned op2:6;
+   } inst;
+};
+
+
+static inline void
+emit_vx(struct ppc_function *p, uint op2, uint vD, uint vA, uint vB)
+{
+   union vx_inst inst;
+   inst.inst.op = 4;
+   inst.inst.vD = vD;
+   inst.inst.vA = vA;
+   inst.inst.vB = vB;
+   inst.inst.op2 = op2;
+   p->store[p->num_inst++] = inst.bits;
+   assert(p->num_inst <= p->max_inst);
+};
+
+static inline void
+emit_vxr(struct ppc_function *p, uint op2, uint vD, uint vA, uint vB)
+{
+   union vxr_inst inst;
+   inst.inst.op = 4;
+   inst.inst.vD = vD;
+   inst.inst.vA = vA;
+   inst.inst.vB = vB;
+   inst.inst.rC = 0;
+   inst.inst.op2 = op2;
+   p->store[p->num_inst++] = inst.bits;
+   assert(p->num_inst <= p->max_inst);
+};
+
+static inline void
+emit_va(struct ppc_function *p, uint op2, uint vD, uint vA, uint vB, uint vC)
+{
+   union va_inst inst;
+   inst.inst.op = 4;
+   inst.inst.vD = vD;
+   inst.inst.vA = vA;
+   inst.inst.vB = vB;
+   inst.inst.vC = vC;
+   inst.inst.op2 = op2;
+   p->store[p->num_inst++] = inst.bits;
+   assert(p->num_inst <= p->max_inst);
+};
+
+
+
+/**
+ ** float vector arithmetic
+ **/
+
+/** vector float add */
+void
+ppc_vaddfp(struct ppc_function *p,uint vD, uint vA, uint vB)
+{
+   emit_vx(p, 10, vD, vA, vB);
+}
+
+/** vector float substract */
+void
+ppc_vsubfp(struct ppc_function *p, uint vD, uint vA, uint vB)
+{
+   emit_vx(p, 74, vD, vA, vB);
+}
+
+/** vector float min */
+void
+ppc_vminfp(struct ppc_function *p, uint vD, uint vA, uint vB)
+{
+   emit_vx(p, 1098, vD, vA, vB);
+}
+
+/** vector float max */
+void
+ppc_vmaxfp(struct ppc_function *p, uint vD, uint vA, uint vB)
+{
+   emit_vx(p, 1034, vD, vA, vB);
+}
+
+/** vector float mult add */
+void
+ppc_vmaddfp(struct ppc_function *p, uint vD, uint vA, uint vB, uint vC)
+{
+   emit_va(p, 46, vD, vA, vB, vC);
+}
+
+/** vector float compare greater than */
+void
+ppc_vcmpgtfpx(struct ppc_function *p, uint vD, uint vA, uint vB)
+{
+   emit_vxr(p, 710, vD, vA, vB);
+}
+
+/** vector float compare greater than or equal to */
+void
+ppc_vcmpgefpx(struct ppc_function *p, uint vD, uint vA, uint vB)
+{
+   emit_vxr(p, 454, vD, vA, vB);
+}
+
+/** vector float compare equal */
+void
+ppc_vcmpeqfpx(struct ppc_function *p, uint vD, uint vA, uint vB)
+{
+   emit_vxr(p, 198, vD, vA, vB);
+}
+
+/** vector float 2^x */
+void
+ppc_vexptefp(struct ppc_function *p, uint vD, uint vB)
+{
+   emit_vx(p, 394, vD, 0, vB);
+}
+
+/** vector float log2(x) */
+void
+ppc_vlogefp(struct ppc_function *p, uint vD, uint vB)
+{
+   emit_vx(p, 458, vD, 0, vB);
+}
+
+/** vector float reciprocol */
+void
+ppc_vrefp(struct ppc_function *p, uint vD, uint vB)
+{
+   emit_vx(p, 266, vD, 0, vB);
+}
+
+/** vector float reciprocol sqrt estimate */
+void
+ppc_vrsqrtefp(struct ppc_function *p, uint vD, uint vB)
+{
+   emit_vx(p, 330, vD, 0, vB);
+}
+
+/** vector float round to negative infinity */
+void
+ppc_vrfim(struct ppc_function *p, uint vD, uint vB)
+{
+   emit_vx(p, 714, vD, 0, vB);
+}
+
+/** vector float round to positive infinity */
+void
+ppc_vrfip(struct ppc_function *p, uint vD, uint vB)
+{
+   emit_vx(p, 650, vD, 0, vB);
+}
+
+/** vector float round to nearest int */
+void
+ppc_vrfin(struct ppc_function *p, uint vD, uint vB)
+{
+   emit_vx(p, 522, vD, 0, vB);
+}
+
+/** vector float round to int toward zero */
+void
+ppc_vrfiz(struct ppc_function *p, uint vD, uint vB)
+{
+   emit_vx(p, 586, vD, 0, vB);
+}
+
+
+
+/**
+ ** bitwise operations
+ **/
+
+
+/** vector and */
+void
+ppc_vand(struct ppc_function *p, uint vD, uint vA, uint vB)
+{
+   emit_vx(p, 1028, vD, vA, vB);
+}
+
+/** vector and complement */
+void
+ppc_vandc(struct ppc_function *p, uint vD, uint vA, uint vB)
+{
+   emit_vx(p, 1092, vD, vA, vB);
+}
+
+/** vector or */
+void
+ppc_vor(struct ppc_function *p, uint vD, uint vA, uint vB)
+{
+   emit_vx(p, 1156, vD, vA, vB);
+}
+
+/** vector nor */
+void
+ppc_vnor(struct ppc_function *p, uint vD, uint vA, uint vB)
+{
+   emit_vx(p, 1284, vD, vA, vB);
+}
+
+/** vector xor */
+void
+ppc_vxor(struct ppc_function *p, uint vD, uint vA, uint vB)
+{
+   emit_vx(p, 1220, vD, vA, vB);
+}
+
+
+/**
+ ** Vector shuffle / select / splat / etc
+ **/
+
+/** vector permute */
+void
+ppc_vperm(struct ppc_function *p, uint vD, uint vA, uint vB, uint vC)
+{
+   emit_va(p, 43, vD, vA, vB, vC);
+}
+
+/** vector select */
+void
+ppc_vsel(struct ppc_function *p, uint vD, uint vA, uint vB, uint vC)
+{
+   emit_va(p, 42, vD, vA, vB, vC);
+}
+
+/** vector splat byte */
+void
+ppc_vspltb(struct ppc_function *p, uint vD, uint vB, uint imm)
+{
+   emit_vx(p, 42, vD, imm, vB);
+}
+
+/** vector splat half word */
+void
+ppc_vsplthw(struct ppc_function *p, uint vD, uint vB, uint imm)
+{
+   emit_vx(p, 588, vD, imm, vB);
+}
+
+/** vector splat word */
+void
+ppc_vspltw(struct ppc_function *p, uint vD, uint vB, uint imm)
+{
+   emit_vx(p, 652, vD, imm, vB);
+}
diff --git a/src/gallium/auxiliary/rtasm/rtasm_ppc.h b/src/gallium/auxiliary/rtasm/rtasm_ppc.h
new file mode 100644 (file)
index 0000000..ed14e94
--- /dev/null
@@ -0,0 +1,181 @@
+/**************************************************************************
+ *
+ * Copyright (C) 2008 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
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * PPC code generation.
+ * \author Brian Paul
+ */
+
+
+#ifndef RTASM_PPC_H
+#define RTASM_PPC_H
+
+
+#include "pipe/p_compiler.h"
+
+
+#define PPC_INST_SIZE 4  /**< 4 bytes / instruction */
+
+#define PPC_NUM_VEC_REGS 32
+
+
+struct ppc_function
+{
+   uint32_t *store;  /**< instruction buffer */
+   uint num_inst;
+   uint max_inst;
+   uint32_t vec_used;   /** used/free vector registers bitmask */
+   uint32_t reg_used;   /** used/free general-purpose registers bitmask */
+};
+
+
+
+extern void ppc_init_func(struct ppc_function *p, unsigned max_inst);
+extern void ppc_release_func(struct ppc_function *p);
+
+extern int ppc_allocate_vec_register(struct ppc_function *p, int reg);
+extern void ppc_release_vec_register(struct ppc_function *p, int reg);
+
+
+/**
+ ** float vector arithmetic
+ **/
+
+/** vector float add */
+extern void
+ppc_vaddfp(struct ppc_function *p,uint vD, uint vA, uint vB);
+
+/** vector float substract */
+extern void
+ppc_vsubfp(struct ppc_function *p, uint vD, uint vA, uint vB);
+
+/** vector float min */
+extern void
+ppc_vminfp(struct ppc_function *p, uint vD, uint vA, uint vB);
+
+/** vector float max */
+extern void
+ppc_vmaxfp(struct ppc_function *p, uint vD, uint vA, uint vB);
+
+/** vector float mult add */
+extern void
+ppc_vmaddfp(struct ppc_function *p, uint vD, uint vA, uint vB, uint vC);
+
+/** vector float compare greater than */
+extern void
+ppc_vcmpgtfpx(struct ppc_function *p, uint vD, uint vA, uint vB);
+
+/** vector float compare greater than or equal to */
+extern void
+ppc_vcmpgefpx(struct ppc_function *p, uint vD, uint vA, uint vB);
+
+/** vector float compare equal */
+extern void
+ppc_vcmpeqfpx(struct ppc_function *p, uint vD, uint vA, uint vB);
+
+/** vector float 2^x */
+extern void
+ppc_vexptefp(struct ppc_function *p, uint vD, uint vB);
+
+/** vector float log2(x) */
+extern void
+ppc_vlogefp(struct ppc_function *p, uint vD, uint vB);
+
+/** vector float reciprocol */
+extern void
+ppc_vrefp(struct ppc_function *p, uint vD, uint vB);
+
+/** vector float reciprocol sqrt estimate */
+extern void
+ppc_vrsqrtefp(struct ppc_function *p, uint vD, uint vB);
+
+/** vector float round to negative infinity */
+extern void
+ppc_vrfim(struct ppc_function *p, uint vD, uint vB);
+
+/** vector float round to positive infinity */
+extern void
+ppc_vrfip(struct ppc_function *p, uint vD, uint vB);
+
+/** vector float round to nearest int */
+extern void
+ppc_vrfin(struct ppc_function *p, uint vD, uint vB);
+
+/** vector float round to int toward zero */
+extern void
+ppc_vrfiz(struct ppc_function *p, uint vD, uint vB);
+
+
+
+/**
+ ** bitwise operations
+ **/
+
+
+/** vector and */
+extern void
+ppc_vand(struct ppc_function *p, uint vD, uint vA, uint vB);
+
+/** vector and complement */
+extern void
+ppc_vandc(struct ppc_function *p, uint vD, uint vA, uint vB);
+
+/** vector or */
+extern void
+ppc_vor(struct ppc_function *p, uint vD, uint vA, uint vB);
+
+/** vector nor */
+extern void
+ppc_vnor(struct ppc_function *p, uint vD, uint vA, uint vB);
+
+/** vector xor */
+extern void
+ppc_vxor(struct ppc_function *p, uint vD, uint vA, uint vB);
+
+
+/**
+ ** Vector shuffle / select / splat / etc
+ **/
+
+/** vector permute */
+extern void
+ppc_vperm(struct ppc_function *p, uint vD, uint vA, uint vB, uint vC);
+
+/** vector select */
+extern void
+ppc_vsel(struct ppc_function *p, uint vD, uint vA, uint vB, uint vC);
+
+/** vector splat byte */
+extern void
+ppc_vspltb(struct ppc_function *p, uint vD, uint vB, uint imm);
+
+/** vector splat half word */
+extern void
+ppc_vsplthw(struct ppc_function *p, uint vD, uint vB, uint imm);
+
+/** vector splat word */
+extern void
+ppc_vspltw(struct ppc_function *p, uint vD, uint vB, uint imm);
+
+
+#endif /* RTASM_PPC_H */
index a04cc6c4ff7821ef3473e74bb201624ec66051b4..12e0826fb9b3545338b3febc30a383c80827b30a 100644 (file)
  * Real-time assembly generation interface for Cell B.E. SPEs.
  *
  * \author Ian Romanick <idr@us.ibm.com>
+ * \author Brian Paul
  */
 
+
+#include <stdio.h>
 #include "pipe/p_compiler.h"
 #include "util/u_memory.h"
 #include "rtasm_ppc_spe.h"
 
+
 #ifdef GALLIUM_CELL
 /**
  * SPE instruction types
@@ -143,8 +147,25 @@ union spe_inst_RI18 {
 /*@}*/
 
 
+static void
+indent(const struct spe_function *p)
+{
+   int i;
+   for (i = 0; i < p->indent; i++) {
+      putchar(' ');
+   }
+}
+
+
+static const char *
+rem_prefix(const char *longname)
+{
+   return longname + 4;
+}
+
+
 static void emit_RR(struct spe_function *p, unsigned op, unsigned rT,
-                   unsigned rA, unsigned rB)
+                   unsigned rA, unsigned rB, const char *name)
 {
     union spe_inst_RR inst;
     inst.inst.op = op;
@@ -153,11 +174,15 @@ static void emit_RR(struct spe_function *p, unsigned op, unsigned rT,
     inst.inst.rT = rT;
     p->store[p->num_inst++] = inst.bits;
     assert(p->num_inst <= p->max_inst);
+    if (p->print) {
+       indent(p);
+       printf("%s\t$%d, $%d, $%d\n", rem_prefix(name), rT, rA, rB);
+    }
 }
 
 
 static void emit_RRR(struct spe_function *p, unsigned op, unsigned rT,
-                   unsigned rA, unsigned rB, unsigned rC)
+                     unsigned rA, unsigned rB, unsigned rC, const char *name)
 {
     union spe_inst_RRR inst;
     inst.inst.op = op;
@@ -167,11 +192,15 @@ static void emit_RRR(struct spe_function *p, unsigned op, unsigned rT,
     inst.inst.rC = rC;
     p->store[p->num_inst++] = inst.bits;
     assert(p->num_inst <= p->max_inst);
+    if (p->print) {
+       indent(p);
+       printf("%s\t$%d, $%d, $%d, $%d\n", rem_prefix(name), rT, rA, rB, rC);
+    }
 }
 
 
 static void emit_RI7(struct spe_function *p, unsigned op, unsigned rT,
-                    unsigned rA, int imm)
+                    unsigned rA, int imm, const char *name)
 {
     union spe_inst_RI7 inst;
     inst.inst.op = op;
@@ -180,12 +209,16 @@ static void emit_RI7(struct spe_function *p, unsigned op, unsigned rT,
     inst.inst.rT = rT;
     p->store[p->num_inst++] = inst.bits;
     assert(p->num_inst <= p->max_inst);
+    if (p->print) {
+       indent(p);
+       printf("%s\t$%d, $%d, 0x%x\n", rem_prefix(name), rT, rA, imm);
+    }
 }
 
 
 
 static void emit_RI8(struct spe_function *p, unsigned op, unsigned rT,
-                    unsigned rA, int imm)
+                    unsigned rA, int imm, const char *name)
 {
     union spe_inst_RI8 inst;
     inst.inst.op = op;
@@ -194,12 +227,16 @@ static void emit_RI8(struct spe_function *p, unsigned op, unsigned rT,
     inst.inst.rT = rT;
     p->store[p->num_inst++] = inst.bits;
     assert(p->num_inst <= p->max_inst);
+    if (p->print) {
+       indent(p);
+       printf("%s\t$%d, $%d, 0x%x\n", rem_prefix(name), rT, rA, imm);
+    }
 }
 
 
 
 static void emit_RI10(struct spe_function *p, unsigned op, unsigned rT,
-                     unsigned rA, int imm)
+                     unsigned rA, int imm, const char *name)
 {
     union spe_inst_RI10 inst;
     inst.inst.op = op;
@@ -208,11 +245,19 @@ static void emit_RI10(struct spe_function *p, unsigned op, unsigned rT,
     inst.inst.rT = rT;
     p->store[p->num_inst++] = inst.bits;
     assert(p->num_inst <= p->max_inst);
+    if (p->print) {
+       indent(p);
+       if (strcmp(name, "spe_lqd") == 0 ||
+           strcmp(name, "spe_stqd") == 0)
+          printf("%s\t$%d, 0x%x($%d)\n", rem_prefix(name), rT, imm, rA);
+       else
+          printf("%s\t$%d, $%d, 0x%x\n", rem_prefix(name), rT, rA, imm);
+    }
 }
 
 
 static void emit_RI16(struct spe_function *p, unsigned op, unsigned rT,
-                     int imm)
+                     int imm, const char *name)
 {
     union spe_inst_RI16 inst;
     inst.inst.op = op;
@@ -220,11 +265,15 @@ static void emit_RI16(struct spe_function *p, unsigned op, unsigned rT,
     inst.inst.rT = rT;
     p->store[p->num_inst++] = inst.bits;
     assert(p->num_inst <= p->max_inst);
+    if (p->print) {
+       indent(p);
+       printf("%s\t$%d, 0x%x\n", rem_prefix(name), rT, imm);
+    }
 }
 
 
 static void emit_RI18(struct spe_function *p, unsigned op, unsigned rT,
-                     int imm)
+                     int imm, const char *name)
 {
     union spe_inst_RI18 inst;
     inst.inst.op = op;
@@ -232,6 +281,10 @@ static void emit_RI18(struct spe_function *p, unsigned op, unsigned rT,
     inst.inst.rT = rT;
     p->store[p->num_inst++] = inst.bits;
     assert(p->num_inst <= p->max_inst);
+    if (p->print) {
+       indent(p);
+       printf("%s\t$%d, 0x%x\n", rem_prefix(name), rT, imm);
+    }
 }
 
 
@@ -240,61 +293,61 @@ static void emit_RI18(struct spe_function *p, unsigned op, unsigned rT,
 #define EMIT_(_name, _op) \
 void _name (struct spe_function *p, unsigned rT) \
 { \
-    emit_RR(p, _op, rT, 0, 0); \
+   emit_RR(p, _op, rT, 0, 0, __FUNCTION__); \
 }
 
 #define EMIT_R(_name, _op) \
 void _name (struct spe_function *p, unsigned rT, unsigned rA) \
 { \
-    emit_RR(p, _op, rT, rA, 0); \
+   emit_RR(p, _op, rT, rA, 0, __FUNCTION__);                 \
 }
 
 #define EMIT_RR(_name, _op) \
 void _name (struct spe_function *p, unsigned rT, unsigned rA, unsigned rB) \
 { \
-    emit_RR(p, _op, rT, rA, rB); \
+   emit_RR(p, _op, rT, rA, rB, __FUNCTION__);                \
 }
 
 #define EMIT_RRR(_name, _op) \
 void _name (struct spe_function *p, unsigned rT, unsigned rA, unsigned rB, unsigned rC) \
 { \
-    emit_RRR(p, _op, rT, rA, rB, rC); \
+   emit_RRR(p, _op, rT, rA, rB, rC, __FUNCTION__);           \
 }
 
 #define EMIT_RI7(_name, _op) \
 void _name (struct spe_function *p, unsigned rT, unsigned rA, int imm) \
 { \
-    emit_RI7(p, _op, rT, rA, imm); \
+   emit_RI7(p, _op, rT, rA, imm, __FUNCTION__);              \
 }
 
 #define EMIT_RI8(_name, _op, bias) \
 void _name (struct spe_function *p, unsigned rT, unsigned rA, int imm) \
 { \
-    emit_RI8(p, _op, rT, rA, bias - imm); \
+   emit_RI8(p, _op, rT, rA, bias - imm, __FUNCTION__);       \
 }
 
 #define EMIT_RI10(_name, _op) \
 void _name (struct spe_function *p, unsigned rT, unsigned rA, int imm) \
 { \
-    emit_RI10(p, _op, rT, rA, imm); \
+   emit_RI10(p, _op, rT, rA, imm, __FUNCTION__);             \
 }
 
 #define EMIT_RI16(_name, _op) \
 void _name (struct spe_function *p, unsigned rT, int imm) \
 { \
-    emit_RI16(p, _op, rT, imm); \
+   emit_RI16(p, _op, rT, imm, __FUNCTION__);                 \
 }
 
 #define EMIT_RI18(_name, _op) \
 void _name (struct spe_function *p, unsigned rT, int imm) \
 { \
-    emit_RI18(p, _op, rT, imm); \
+   emit_RI18(p, _op, rT, imm, __FUNCTION__);                 \
 }
 
 #define EMIT_I16(_name, _op) \
 void _name (struct spe_function *p, int imm) \
 { \
-    emit_RI16(p, _op, 0, imm); \
+   emit_RI16(p, _op, 0, imm, __FUNCTION__);                  \
 }
 
 #include "rtasm_ppc_spe.h"
@@ -314,6 +367,9 @@ void spe_init_func(struct spe_function *p, unsigned code_size)
      */
     p->regs[0] = ~7;
     p->regs[1] = (1U << (80 - 64)) - 1;
+
+    p->print = false;
+    p->indent = 0;
 }
 
 
@@ -328,7 +384,7 @@ void spe_release_func(struct spe_function *p)
 
 
 /**
- * Alloate a SPE register.
+ * Allocate a SPE register.
  * \return register index or -1 if none left.
  */
 int spe_allocate_available_register(struct spe_function *p)
@@ -382,6 +438,32 @@ void spe_release_register(struct spe_function *p, int reg)
 }
 
 
+void
+spe_print_code(struct spe_function *p, boolean enable)
+{
+   p->print = enable;
+}
+
+
+void
+spe_indent(struct spe_function *p, int spaces)
+{
+   p->indent += spaces;
+}
+
+
+extern void
+spe_comment(struct spe_function *p, int rel_indent, const char *s)
+{
+   if (p->print) {
+      p->indent += rel_indent;
+      indent(p);
+      p->indent -= rel_indent;
+      printf("# %s\n", s);
+   }
+}
+
+
 /**
  * For branch instructions:
  * \param d  if 1, disable interupts if branch is taken
@@ -392,51 +474,51 @@ void spe_release_register(struct spe_function *p, int reg)
 /** Branch Indirect to address in rA */
 void spe_bi(struct spe_function *p, unsigned rA, int d, int e)
 {
-    emit_RI7(p, 0x1a8, 0, rA, (d << 5) | (e << 4));
+   emit_RI7(p, 0x1a8, 0, rA, (d << 5) | (e << 4), __FUNCTION__);
 }
 
 /** Interupt Return */
 void spe_iret(struct spe_function *p, unsigned rA, int d, int e)
 {
-    emit_RI7(p, 0x1aa, 0, rA, (d << 5) | (e << 4));
+   emit_RI7(p, 0x1aa, 0, rA, (d << 5) | (e << 4), __FUNCTION__);
 }
 
 /** Branch indirect and set link on external data */
 void spe_bisled(struct spe_function *p, unsigned rT, unsigned rA, int d,
                int e)
 {
-    emit_RI7(p, 0x1ab, rT, rA, (d << 5) | (e << 4));
+   emit_RI7(p, 0x1ab, rT, rA, (d << 5) | (e << 4), __FUNCTION__);
 }
 
 /** Branch indirect and set link.  Save PC in rT, jump to rA. */
 void spe_bisl(struct spe_function *p, unsigned rT, unsigned rA, int d,
                int e)
 {
-    emit_RI7(p, 0x1a9, rT, rA, (d << 5) | (e << 4));
+   emit_RI7(p, 0x1a9, rT, rA, (d << 5) | (e << 4), __FUNCTION__);
 }
 
 /** Branch indirect if zero word.  If rT.word[0]==0, jump to rA. */
 void spe_biz(struct spe_function *p, unsigned rT, unsigned rA, int d, int e)
 {
-    emit_RI7(p, 0x128, rT, rA, (d << 5) | (e << 4));
+   emit_RI7(p, 0x128, rT, rA, (d << 5) | (e << 4), __FUNCTION__);
 }
 
 /** Branch indirect if non-zero word.  If rT.word[0]!=0, jump to rA. */
 void spe_binz(struct spe_function *p, unsigned rT, unsigned rA, int d, int e)
 {
-    emit_RI7(p, 0x129, rT, rA, (d << 5) | (e << 4));
+   emit_RI7(p, 0x129, rT, rA, (d << 5) | (e << 4), __FUNCTION__);
 }
 
 /** Branch indirect if zero halfword.  If rT.halfword[1]==0, jump to rA. */
 void spe_bihz(struct spe_function *p, unsigned rT, unsigned rA, int d, int e)
 {
-    emit_RI7(p, 0x12a, rT, rA, (d << 5) | (e << 4));
+   emit_RI7(p, 0x12a, rT, rA, (d << 5) | (e << 4), __FUNCTION__);
 }
 
 /** Branch indirect if non-zero halfword.  If rT.halfword[1]!=0, jump to rA. */
 void spe_bihnz(struct spe_function *p, unsigned rT, unsigned rA, int d, int e)
 {
-    emit_RI7(p, 0x12b, rT, rA, (d << 5) | (e << 4));
+   emit_RI7(p, 0x12b, rT, rA, (d << 5) | (e << 4), __FUNCTION__);
 }
 
 
@@ -505,7 +587,8 @@ spe_load_int(struct spe_function *p, unsigned rT, int i)
    }
    else {
       spe_ilhu(p, rT, i >> 16);
-      spe_iohl(p, rT, i & 0xffff);
+      if (i & 0xffff)
+         spe_iohl(p, rT, i & 0xffff);
    }
 }
 
@@ -539,4 +622,68 @@ spe_zero(struct spe_function *p, unsigned rT)
 }
 
 
+void
+spe_splat_word(struct spe_function *p, unsigned rT, unsigned rA, int word)
+{
+   assert(word >= 0);
+   assert(word <= 3);
+
+   if (word == 0) {
+      int tmp1 = rT;
+      spe_ila(p, tmp1, 66051);
+      spe_shufb(p, rT, rA, rA, tmp1);
+   }
+   else {
+      /* XXX review this, we may not need the rotqbyi instruction */
+      int tmp1 = rT;
+      int tmp2 = spe_allocate_available_register(p);
+
+      spe_ila(p, tmp1, 66051);
+      spe_rotqbyi(p, tmp2, rA, 4 * word);
+      spe_shufb(p, rT, tmp2, tmp2, tmp1);
+
+      spe_release_register(p, tmp2);
+   }
+}
+
+/* For each 32-bit float element of rA and rB, choose the smaller of the
+ * two, compositing them into the rT register.
+ * 
+ * The Float Compare Greater Than (fcgt) instruction will put 1s into
+ * compare_reg where rA > rB, and 0s where rA <= rB.
+ *
+ * Then the Select Bits (selb) instruction will take bits from rA where
+ * compare_reg is 0, and from rB where compare_reg is 1; i.e., from rA
+ * where rA <= rB and from rB where rB > rA, which is exactly the
+ * "min" operation.
+ *
+ * The compare_reg could in many cases be the same as rT, unless
+ * rT == rA || rt == rB.  But since this is common in constructions
+ * like "x = min(x, a)", we always allocate a new register to be safe.
+ */
+void 
+spe_float_min(struct spe_function *p, unsigned int rT, unsigned int rA, unsigned int rB)
+{
+   unsigned int compare_reg = spe_allocate_available_register(p);
+   spe_fcgt(p, compare_reg, rA, rB);
+   spe_selb(p, rT, rA, rB, compare_reg);
+   spe_release_register(p, compare_reg);
+}
+
+/* For each 32-bit float element of rA and rB, choose the greater of the
+ * two, compositing them into the rT register.
+ * 
+ * The logic is similar to that of spe_float_min() above; the only
+ * difference is that the registers on spe_selb() have been reversed,
+ * so that the larger of the two is selected instead of the smaller.
+ */
+void 
+spe_float_max(struct spe_function *p, unsigned int rT, unsigned int rA, unsigned int rB)
+{
+   unsigned int compare_reg = spe_allocate_available_register(p);
+   spe_fcgt(p, compare_reg, rA, rB);
+   spe_selb(p, rT, rB, rA, compare_reg);
+   spe_release_register(p, compare_reg);
+}
+
 #endif /* GALLIUM_CELL */
index d95e5aace34d4f9df20cf9e56b281ee351a32fa2..4ef05ea27d1a10560a024c5fe6f4b548fc516d6f 100644 (file)
@@ -28,6 +28,7 @@
  * For details, see /opt/cell/sdk/docs/arch/SPU_ISA_v1.2_27Jan2007_pub.pdf
  *
  * \author Ian Romanick <idr@us.ibm.com>
+ * \author Brian Paul
  */
 
 #ifndef RTASM_PPC_SPE_H
@@ -63,8 +64,12 @@ struct spe_function
      * spe_release_register
      */
     uint64_t regs[SPE_NUM_REGS / 64];
+
+    boolean print; /**< print/dump instructions as they're emitted? */
+    int indent;    /**< number of spaces to indent */
 };
 
+
 extern void spe_init_func(struct spe_function *p, unsigned code_size);
 extern void spe_release_func(struct spe_function *p);
 
@@ -72,6 +77,11 @@ extern int spe_allocate_available_register(struct spe_function *p);
 extern int spe_allocate_register(struct spe_function *p, int reg);
 extern void spe_release_register(struct spe_function *p, int reg);
 
+extern void spe_print_code(struct spe_function *p, boolean enable);
+extern void spe_indent(struct spe_function *p, int spaces);
+extern void spe_comment(struct spe_function *p, int rel_indent, const char *s);
+
+
 #endif /* RTASM_PPC_SPE_H */
 
 #ifndef EMIT_
@@ -308,6 +318,18 @@ spe_move(struct spe_function *p, unsigned rT, unsigned rA);
 extern void
 spe_zero(struct spe_function *p, unsigned rT);
 
+/** rT = splat(rA, word) */
+extern void
+spe_splat_word(struct spe_function *p, unsigned rT, unsigned rA, int word);
+
+/** rT = float min(rA, rB) */
+extern void
+spe_float_min(struct spe_function *p, unsigned rT, unsigned rA, unsigned rB);
+
+/** rT = float max(rA, rB) */
+extern void
+spe_float_max(struct spe_function *p, unsigned rT, unsigned rA, unsigned rB);
+
 
 /* Floating-point instructions
  */
index 74614d368843f2195a5621898bb44daf26025810..38fcaf88293eeb751c77b8352b08372c5e7be283 100644 (file)
@@ -793,10 +793,14 @@ tgsi_default_instruction_ext_nv( void )
    return instruction_ext_nv;
 }
 
-union token_u32
+
+/** test for inequality of 32-bit values pointed to by a and b */
+static INLINE boolean
+compare32(const void *a, const void *b)
 {
-   unsigned u32;
-};
+   return *((uint32_t *) a) != *((uint32_t *) b);
+}
+
 
 unsigned
 tgsi_compare_instruction_ext_nv(
@@ -805,7 +809,7 @@ tgsi_compare_instruction_ext_nv(
 {
    a.Padding = b.Padding = 0;
    a.Extended = b.Extended = 0;
-   return ((union token_u32 *) &a)->u32 != ((union token_u32 *) &b)->u32;
+   return compare32(&a, &b);
 }
 
 struct tgsi_instruction_ext_nv
@@ -864,7 +868,7 @@ tgsi_compare_instruction_ext_label(
 {
    a.Padding = b.Padding = 0;
    a.Extended = b.Extended = 0;
-   return ((union token_u32 *) &a)->u32 != ((union token_u32 *) &b)->u32;
+   return compare32(&a, &b);
 }
 
 struct tgsi_instruction_ext_label
@@ -905,7 +909,7 @@ tgsi_compare_instruction_ext_texture(
 {
    a.Padding = b.Padding = 0;
    a.Extended = b.Extended = 0;
-   return ((union token_u32 *) &a)->u32 != ((union token_u32 *) &b)->u32;
+   return compare32(&a, &b);
 }
 
 struct tgsi_instruction_ext_texture
@@ -1027,7 +1031,7 @@ tgsi_compare_src_register_ext_swz(
 {
    a.Padding = b.Padding = 0;
    a.Extended = b.Extended = 0;
-   return ((union token_u32 *) &a)->u32 != ((union token_u32 *) &b)->u32;
+   return compare32(&a, &b);
 }
 
 struct tgsi_src_register_ext_swz
@@ -1095,7 +1099,7 @@ tgsi_compare_src_register_ext_mod(
 {
    a.Padding = b.Padding = 0;
    a.Extended = b.Extended = 0;
-   return ((union token_u32 *) &a)->u32 != ((union token_u32 *) &b)->u32;
+   return compare32(&a, &b);
 }
 
 struct tgsi_src_register_ext_mod
@@ -1241,7 +1245,7 @@ tgsi_compare_dst_register_ext_concode(
 {
    a.Padding = b.Padding = 0;
    a.Extended = b.Extended = 0;
-   return ((union token_u32 *) &a)->u32 != ((union token_u32 *) &b)->u32;
+   return compare32(&a, &b);
 }
 
 struct tgsi_dst_register_ext_concode
@@ -1299,7 +1303,7 @@ tgsi_compare_dst_register_ext_modulate(
 {
    a.Padding = b.Padding = 0;
    a.Extended = b.Extended = 0;
-   return ((union token_u32 *) &a)->u32 != ((union token_u32 *) &b)->u32;
+   return compare32(&a, &b);
 }
 
 struct tgsi_dst_register_ext_modulate
index df002939c6bd0d5806d95da79614c7f030633ba6..1a5294eabc31ba89e85cd5f827ffd512a272093f 100644 (file)
@@ -1674,6 +1674,7 @@ exec_declaration(
             break;
 
          default:
+            eval = NULL;
             assert( 0 );
          }
 
index 3757486ba9be16034a01d9a9ca1c3ba46bcb4658..2cd56e413a540ecb5e1ac7b74b03d75a917dc84e 100644 (file)
@@ -88,16 +88,33 @@ tgsi_parse_end_of_tokens(
       1 + ctx->FullHeader.Header.HeaderSize + ctx->FullHeader.Header.BodySize;
 }
 
+
+/**
+ * This function is used to avoid and work-around type punning/aliasing
+ * warnings.  The warnings seem harmless on x86 but on PPC they cause
+ * real failures.
+ */
+static INLINE void
+copy_token(void *dst, const void *src)
+{
+   memcpy(dst, src, 4);
+}
+
+
+/**
+ * Get next 4-byte token, return it at address specified by 'token'
+ */
 static void
 next_token(
    struct tgsi_parse_context *ctx,
    void *token )
 {
    assert( !tgsi_parse_end_of_tokens( ctx ) );
-
-   *(struct tgsi_token *) token = ctx->Tokens[ctx->Position++];
+   copy_token(token, &ctx->Tokens[ctx->Position]);
+   ctx->Position++;
 }
 
+
 void
 tgsi_parse_token(
    struct tgsi_parse_context *ctx )
@@ -116,7 +133,7 @@ tgsi_parse_token(
       struct tgsi_full_declaration *decl = &ctx->FullToken.FullDeclaration;
 
       *decl = tgsi_default_full_declaration();
-      decl->Declaration = *(struct tgsi_declaration *) &token;
+      copy_token(&decl->Declaration, &token);
 
       next_token( ctx, &decl->DeclarationRange );
 
@@ -132,8 +149,7 @@ tgsi_parse_token(
       struct tgsi_full_immediate *imm = &ctx->FullToken.FullImmediate;
 
       *imm = tgsi_default_full_immediate();
-      imm->Immediate = *(struct tgsi_immediate *) &token;
-
+      copy_token(&imm->Immediate, &token);
       assert( !imm->Immediate.Extended );
 
       switch (imm->Immediate.DataType) {
@@ -158,8 +174,7 @@ tgsi_parse_token(
       unsigned extended;
 
       *inst = tgsi_default_full_instruction();
-      inst->Instruction = *(struct tgsi_instruction *) &token;
-
+      copy_token(&inst->Instruction, &token);
       extended = inst->Instruction.Extended;
 
       while( extended ) {
@@ -169,18 +184,15 @@ tgsi_parse_token(
 
          switch( token.Type ) {
          case TGSI_INSTRUCTION_EXT_TYPE_NV:
-            inst->InstructionExtNv =
-               *(struct tgsi_instruction_ext_nv *) &token;
+            copy_token(&inst->InstructionExtNv, &token);
             break;
 
          case TGSI_INSTRUCTION_EXT_TYPE_LABEL:
-            inst->InstructionExtLabel =
-               *(struct tgsi_instruction_ext_label *) &token;
+            copy_token(&inst->InstructionExtLabel, &token);
             break;
 
          case TGSI_INSTRUCTION_EXT_TYPE_TEXTURE:
-            inst->InstructionExtTexture =
-               *(struct tgsi_instruction_ext_texture *) &token;
+            copy_token(&inst->InstructionExtTexture, &token);
             break;
 
          default:
@@ -212,13 +224,13 @@ tgsi_parse_token(
 
             switch( token.Type ) {
             case TGSI_DST_REGISTER_EXT_TYPE_CONDCODE:
-               inst->FullDstRegisters[i].DstRegisterExtConcode =
-                  *(struct tgsi_dst_register_ext_concode *) &token;
+               copy_token(&inst->FullDstRegisters[i].DstRegisterExtConcode,
+                          &token);
                break;
 
             case TGSI_DST_REGISTER_EXT_TYPE_MODULATE:
-               inst->FullDstRegisters[i].DstRegisterExtModulate =
-                  *(struct tgsi_dst_register_ext_modulate *) &token;
+               copy_token(&inst->FullDstRegisters[i].DstRegisterExtModulate,
+                          &token);
                break;
 
             default:
@@ -245,13 +257,13 @@ tgsi_parse_token(
 
             switch( token.Type ) {
             case TGSI_SRC_REGISTER_EXT_TYPE_SWZ:
-               inst->FullSrcRegisters[i].SrcRegisterExtSwz =
-                  *(struct tgsi_src_register_ext_swz *) &token;
+               copy_token(&inst->FullSrcRegisters[i].SrcRegisterExtSwz,
+                          &token);
                break;
 
             case TGSI_SRC_REGISTER_EXT_TYPE_MOD:
-               inst->FullSrcRegisters[i].SrcRegisterExtMod =
-                  *(struct tgsi_src_register_ext_mod *) &token;
+               copy_token(&inst->FullSrcRegisters[i].SrcRegisterExtMod,
+                          &token);
                break;
 
             default:
index cb0631baf5210d4cea596d7fcefddcc033369e4f..f0ff96eb4780ae4043d70a9500cab9e806a208b6 100644 (file)
 #define CELL_BUFFER_STATUS_FREE 10
 #define CELL_BUFFER_STATUS_USED 20
 
-
-#define CELL_DEBUG_CHECKER  (1 << 0)
-#define CELL_DEBUG_SYNC     (1 << 1)
-
-
+#define CELL_DEBUG_CHECKER              (1 << 0)
+#define CELL_DEBUG_ASM                  (1 << 1)
+#define CELL_DEBUG_SYNC                 (1 << 2)
+#define CELL_DEBUG_FRAGMENT_OPS         (1 << 3)
+#define CELL_DEBUG_FRAGMENT_OP_FALLBACK (1 << 4)
 
 /** Max instructions for doing per-fragment operations */
 #define SPU_MAX_FRAGMENT_OPS_INSTS 64
index 71f1a3049d1b1e66117f5f840a6816c9f2ae4631..62e213ea354c32c81281ad738149d42379aec7e1 100644 (file)
@@ -85,13 +85,14 @@ cell_draw_create(struct cell_context *cell)
 }
 
 
-#ifdef DEBUG
 static const struct debug_named_value cell_debug_flags[] = {
    {"checker", CELL_DEBUG_CHECKER},/**< modulate tile clear color by SPU ID */
+   {"asm", CELL_DEBUG_ASM},        /**< dump SPU asm code */
    {"sync", CELL_DEBUG_SYNC},      /**< SPUs do synchronous DMA */
+   {"fragops", CELL_DEBUG_FRAGMENT_OPS}, /**< SPUs emit fragment ops debug messages*/
+   {"fragopfallback", CELL_DEBUG_FRAGMENT_OP_FALLBACK}, /**< SPUs use reference implementation for fragment ops*/
    {NULL, 0}
 };
-#endif
 
 
 struct pipe_context *
index 6ffe94eb14a005268e9715874d097547a4e372a7..4f01897199c53e8f83612f80c172e5e9e2160d7d 100644 (file)
 #include "cell_gen_fp.h"
 
 
-/** Set to 1 to enable debug/disassembly printfs */
-#define DISASSEM 01
+#define MAX_TEMPS 16
+#define MAX_IMMED  8
 
+#define CHAN_X  0
+#define CHAN_Y  1
+#define CHAN_Z  2
+#define CHAN_W  3
 
 /**
  * Context needed during code generation.
@@ -63,13 +67,21 @@ struct codegen
    int inputs_reg;      /**< 1st function parameter */
    int outputs_reg;     /**< 2nd function parameter */
    int constants_reg;   /**< 3rd function parameter */
-   int temp_regs[8][4]; /**< maps TGSI temps to SPE registers */
+   int temp_regs[MAX_TEMPS][4]; /**< maps TGSI temps to SPE registers */
+   int imm_regs[MAX_IMMED][4];  /**< maps TGSI immediates to SPE registers */
+
+   int num_imm;  /**< number of immediates */
 
    int one_reg;         /**< register containing {1.0, 1.0, 1.0, 1.0} */
 
    /** Per-instruction temps / intermediate temps */
    int num_itemps;
-   int itemps[3];
+   int itemps[4];
+
+   /** Current IF/ELSE/ENDIF nesting level */
+   int if_nesting;
+   /** Index of execution mask register */
+   int exec_mask_reg;
 
    struct spe_function *f;
    boolean error;
@@ -112,18 +124,46 @@ get_const_one_reg(struct codegen *gen)
 {
    if (gen->one_reg <= 0) {
       gen->one_reg = spe_allocate_available_register(gen->f);
-   }
 
-   /* one = {1.0, 1.0, 1.0, 1.0} */
-   spe_load_float(gen->f, gen->one_reg, 1.0f);
-#if DISASSEM
-   printf("il\tr%d, 1.0f\n", gen->one_reg);
-#endif
+      spe_indent(gen->f, 4);
+      spe_comment(gen->f, -4, "INIT CONSTANT 1.0:");
+
+      /* one = {1.0, 1.0, 1.0, 1.0} */
+      spe_load_float(gen->f, gen->one_reg, 1.0f);
+
+      spe_indent(gen->f, -4);
+   }
 
    return gen->one_reg;
 }
 
 
+/**
+ * Return index of the pixel execution mask.
+ * The register is allocated an initialized upon the first call.
+ *
+ * The pixel execution mask controls which pixels in a quad are
+ * modified, according to surrounding conditionals, loops, etc.
+ */
+static int
+get_exec_mask_reg(struct codegen *gen)
+{
+   if (gen->exec_mask_reg <= 0) {
+      gen->exec_mask_reg = spe_allocate_available_register(gen->f);
+
+      spe_indent(gen->f, 4);
+      spe_comment(gen->f, -4, "INIT EXEC MASK = ~0:");
+
+      /* exec_mask = {~0, ~0, ~0, ~0} */
+      spe_load_int(gen->f, gen->exec_mask_reg, ~0);
+
+      spe_indent(gen->f, -4);
+   }
+
+   return gen->exec_mask_reg;
+}
+
+
 /**
  * Return the index of the SPU temporary containing the named TGSI
  * source register.  If the TGSI register is a TGSI_FILE_TEMPORARY we
@@ -136,12 +176,15 @@ get_src_reg(struct codegen *gen,
             int channel,
             const struct tgsi_full_src_register *src)
 {
-   int reg;
+   int reg = -1;
+   int swizzle = tgsi_util_get_full_src_register_extswizzle(src, channel);
+   boolean reg_is_itemp = FALSE;
+   uint sign_op;
 
-   /* XXX need to examine src swizzle info here.
-    * That will involve changing the channel var...
-    */
+   assert(swizzle >= 0);
+   assert(swizzle <= 3);
 
+   channel = swizzle;
 
    switch (src->SrcRegister.File) {
    case TGSI_FILE_TEMPORARY:
@@ -152,21 +195,57 @@ get_src_reg(struct codegen *gen,
          /* offset is measured in quadwords, not bytes */
          int offset = src->SrcRegister.Index * 4 + channel;
          reg = get_itemp(gen);
+         reg_is_itemp = TRUE;
          /* Load:  reg = memory[(machine_reg) + offset] */
          spe_lqd(gen->f, reg, gen->inputs_reg, offset);
-#if DISASSEM
-         printf("lqd\tr%d, r%d + %d\n", reg, gen->inputs_reg, offset);
-#endif
       }
       break;
    case TGSI_FILE_IMMEDIATE:
-      /* xxx fall-through for now / fix */
+      reg = gen->imm_regs[src->SrcRegister.Index][channel];
+      break;
    case TGSI_FILE_CONSTANT:
       /* xxx fall-through for now / fix */
    default:
       assert(0);
    }
 
+   /*
+    * Handle absolute value, negate or set-negative of src register.
+    */
+   sign_op = tgsi_util_get_full_src_register_sign_mode(src, channel);
+   if (sign_op != TGSI_UTIL_SIGN_KEEP) {
+      /*
+       * All sign ops are done by manipulating bit 31, the IEEE float sign bit.
+       */
+      const int bit31mask_reg = get_itemp(gen);
+      int result_reg;
+
+      if (reg_is_itemp) {
+         /* re-use 'reg' for the result */
+         result_reg = reg;
+      }
+      else {
+         /* alloc a new reg for the result */
+         result_reg = get_itemp(gen);
+      }
+
+      /* mask with bit 31 set, the rest cleared */
+      spe_load_int(gen->f, bit31mask_reg, (1 << 31));
+
+      if (sign_op == TGSI_UTIL_SIGN_CLEAR) {
+         spe_andc(gen->f, result_reg, reg, bit31mask_reg);
+      }
+      else if (sign_op == TGSI_UTIL_SIGN_SET) {
+         spe_and(gen->f, result_reg, reg, bit31mask_reg);
+      }
+      else {
+         assert(sign_op == TGSI_UTIL_SIGN_TOGGLE);
+         spe_xor(gen->f, result_reg, reg, bit31mask_reg);
+      }
+
+      reg = result_reg;
+   }
+
    return reg;
 }
 
@@ -183,11 +262,14 @@ get_dst_reg(struct codegen *gen,
             int channel,
             const struct tgsi_full_dst_register *dest)
 {
-   int reg;
+   int reg = -1;
 
    switch (dest->DstRegister.File) {
    case TGSI_FILE_TEMPORARY:
-      reg = gen->temp_regs[dest->DstRegister.Index][channel];
+      if (gen->if_nesting > 0)
+         reg = get_itemp(gen);
+      else
+         reg = gen->temp_regs[dest->DstRegister.Index][channel];
       break;
    case TGSI_FILE_OUTPUT:
       reg = get_itemp(gen);
@@ -213,17 +295,40 @@ store_dest_reg(struct codegen *gen,
 {
    switch (dest->DstRegister.File) {
    case TGSI_FILE_TEMPORARY:
-      /* no-op */
+      if (gen->if_nesting > 0) {
+         int d_reg = gen->temp_regs[dest->DstRegister.Index][channel];
+         int exec_reg = get_exec_mask_reg(gen);
+         /* Mix d with new value according to exec mask:
+          * d[i] = mask_reg[i] ? value_reg : d_reg
+          */
+         spe_selb(gen->f, d_reg, d_reg, value_reg, exec_reg);
+      }
+      else {
+         /* we're not inside a condition or loop: do nothing special */
+      }
       break;
    case TGSI_FILE_OUTPUT:
       {
          /* offset is measured in quadwords, not bytes */
          int offset = dest->DstRegister.Index * 4 + channel;
-         /* Store: memory[(machine_reg) + offset] = reg */
-         spe_stqd(gen->f, value_reg, gen->outputs_reg, offset);
-#if DISASSEM
-         printf("stqd\tr%d, r%d + %d\n", value_reg, gen->outputs_reg, offset);
-#endif
+         if (gen->if_nesting > 0) {
+            int exec_reg = get_exec_mask_reg(gen);
+            int curval_reg = get_itemp(gen);
+            /* First read the current value from memory:
+             * Load:  curval = memory[(machine_reg) + offset]
+             */
+            spe_lqd(gen->f, curval_reg, gen->outputs_reg, offset);
+            /* Mix curval with newvalue according to exec mask:
+             * d[i] = mask_reg[i] ? value_reg : d_reg
+             */
+            spe_selb(gen->f, curval_reg, curval_reg, value_reg, exec_reg);
+            /* Store: memory[(machine_reg) + offset] = curval */
+            spe_stqd(gen->f, curval_reg, gen->outputs_reg, offset);
+         }
+         else {
+            /* Store: memory[(machine_reg) + offset] = reg */
+            spe_stqd(gen->f, value_reg, gen->outputs_reg, offset);
+         }
       }
       break;
    default:
@@ -236,15 +341,13 @@ static boolean
 emit_MOV(struct codegen *gen, const struct tgsi_full_instruction *inst)
 {
    int ch;
+   spe_comment(gen->f, -4, "MOV:");
    for (ch = 0; ch < 4; ch++) {
       if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << ch)) {
          int src_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
          int dst_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
          /* XXX we don't always need to actually emit a mov instruction here */
          spe_move(gen->f, dst_reg, src_reg);
-#if DISASSEM
-         printf("mov\tr%d, r%d\n", dst_reg, src_reg);
-#endif
          store_dest_reg(gen, dst_reg, ch, &inst->FullDstRegisters[0]);
          free_itemps(gen);
       }
@@ -253,6 +356,7 @@ emit_MOV(struct codegen *gen, const struct tgsi_full_instruction *inst)
 }
 
 
+
 /**
  * Emit addition instructions.  Recall that a single TGSI_OPCODE_ADD
  * becomes (up to) four SPU "fa" instructions because we're doing SOA
@@ -262,6 +366,7 @@ static boolean
 emit_ADD(struct codegen *gen, const struct tgsi_full_instruction *inst)
 {
    int ch;
+   spe_comment(gen->f, -4, "ADD:");
    /* Loop over Red/Green/Blue/Alpha channels */
    for (ch = 0; ch < 4; ch++) {
       /* If the dest R, G, B or A writemask is enabled... */
@@ -273,9 +378,6 @@ emit_ADD(struct codegen *gen, const struct tgsi_full_instruction *inst)
 
          /* Emit actual SPE instruction: d = s1 + s2 */
          spe_fa(gen->f, d_reg, s1_reg, s2_reg);
-#if DISASSEM
-         printf("fa\tr%d, r%d, r%d\n", d_reg, s1_reg, s2_reg);
-#endif
 
          /* Store the result (a no-op for TGSI_FILE_TEMPORARY dests) */
          store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
@@ -286,6 +388,82 @@ emit_ADD(struct codegen *gen, const struct tgsi_full_instruction *inst)
    return true;
 }
 
+/**
+ * Emit subtract.  See emit_ADD for comments.
+ */
+static boolean
+emit_SUB(struct codegen *gen, const struct tgsi_full_instruction *inst)
+{
+   int ch;
+   spe_comment(gen->f, -4, "SUB:");
+   /* Loop over Red/Green/Blue/Alpha channels */
+   for (ch = 0; ch < 4; ch++) {
+      /* If the dest R, G, B or A writemask is enabled... */
+      if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << ch)) {
+         /* get indexes of the two src, one dest SPE registers */
+         int s1_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
+         int s2_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[1]);
+         int d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+
+         /* Emit actual SPE instruction: d = s1 - s2 */
+         spe_fs(gen->f, d_reg, s1_reg, s2_reg);
+
+         /* Store the result (a no-op for TGSI_FILE_TEMPORARY dests) */
+         store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
+         /* Free any intermediate temps we allocated */
+         free_itemps(gen);
+      }
+   }
+   return true;
+}
+
+/**
+ * Emit multiply add.  See emit_ADD for comments.
+ */
+static boolean
+emit_MAD(struct codegen *gen, const struct tgsi_full_instruction *inst)
+{
+   int ch;
+   spe_comment(gen->f, -4, "MAD:");
+   for (ch = 0; ch < 4; ch++) {
+      if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << ch)) {
+         int s1_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
+         int s2_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[1]);
+         int s3_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[2]);
+         int d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+         /* d = s1 * s2 + s3 */
+         spe_fma(gen->f, d_reg, s1_reg, s2_reg, s3_reg);
+         store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
+         free_itemps(gen);
+      }
+   }
+   return true;
+}
+
+
+/**
+ * Emit linear interpolate.  See emit_ADD for comments.
+ */
+static boolean
+emit_LERP(struct codegen *gen, const struct tgsi_full_instruction *inst)
+{
+   int ch;
+   spe_comment(gen->f, -4, "LERP:");
+   for (ch = 0; ch < 4; ch++) {
+      if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << ch)) {
+         int s1_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
+         int s2_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[1]);
+         int s3_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[2]);
+         int d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+         /* d = s3 + s1(s2 - s3) */
+         spe_fs(gen->f, d_reg, s2_reg, s3_reg);
+         spe_fma(gen->f, d_reg, d_reg, s1_reg, s3_reg);
+         store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
+         free_itemps(gen);
+      }
+   }
+   return true;
+}
 
 /**
  * Emit multiply.  See emit_ADD for comments.
@@ -294,6 +472,7 @@ static boolean
 emit_MUL(struct codegen *gen, const struct tgsi_full_instruction *inst)
 {
    int ch;
+   spe_comment(gen->f, -4, "MUL:");
    for (ch = 0; ch < 4; ch++) {
       if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << ch)) {
          int s1_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
@@ -301,9 +480,6 @@ emit_MUL(struct codegen *gen, const struct tgsi_full_instruction *inst)
          int d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
          /* d = s1 * s2 */
          spe_fm(gen->f, d_reg, s1_reg, s2_reg);
-#if DISASSEM
-         printf("fm\tr%d, r%d, r%d\n", d_reg, s1_reg, s2_reg);
-#endif
          store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
          free_itemps(gen);
       }
@@ -311,6 +487,149 @@ emit_MUL(struct codegen *gen, const struct tgsi_full_instruction *inst)
    return true;
 }
 
+/**
+ * Emit reciprocal.  See emit_ADD for comments.
+ */
+static boolean
+emit_RCP(struct codegen *gen, const struct tgsi_full_instruction *inst)
+{
+   int ch;
+   spe_comment(gen->f, -4, "RCP:");
+   for (ch = 0; ch < 4; ch++) {
+      if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << ch)) {
+         int s1_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
+         int d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+         /* d = 1/s1 */
+         spe_frest(gen->f, d_reg, s1_reg);
+         spe_fi(gen->f, d_reg, s1_reg, d_reg);
+         store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
+         free_itemps(gen);
+      }
+   }
+   return true;
+}
+
+/**
+ * Emit reciprocal sqrt.  See emit_ADD for comments.
+ */
+static boolean
+emit_RSQ(struct codegen *gen, const struct tgsi_full_instruction *inst)
+{
+   int ch;
+   spe_comment(gen->f, -4, "RSQ:");
+   for (ch = 0; ch < 4; ch++) {
+      if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << ch)) {
+         int s1_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
+         int d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+         /* d = 1/s1 */
+         spe_frsqest(gen->f, d_reg, s1_reg);
+         spe_fi(gen->f, d_reg, s1_reg, d_reg);
+         store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
+         free_itemps(gen);
+      }
+   }
+   return true;
+}
+
+/**
+ * Emit absolute value.  See emit_ADD for comments.
+ */
+static boolean
+emit_ABS(struct codegen *gen, const struct tgsi_full_instruction *inst)
+{
+   int ch;
+   spe_comment(gen->f, -4, "ABS:");
+   for (ch = 0; ch < 4; ch++) {
+      if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << ch)) {
+         int s1_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
+         int d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+         const int bit31mask_reg = get_itemp(gen);
+
+         /* mask with bit 31 set, the rest cleared */  
+         spe_load_int(gen->f, bit31mask_reg, (1 << 31));
+
+         /* d = sign bit cleared in s1 */
+         spe_andc(gen->f, d_reg, s1_reg, bit31mask_reg);
+
+         store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
+         free_itemps(gen);
+      }
+   }
+   return true;
+}
+
+/**
+ * Emit 3 component dot product.  See emit_ADD for comments.
+ */
+static boolean
+emit_DP3(struct codegen *gen, const struct tgsi_full_instruction *inst)
+{
+   int ch;
+   spe_comment(gen->f, -4, "DP3:");
+
+   int s1_reg = get_src_reg(gen, CHAN_X, &inst->FullSrcRegisters[0]);
+   int s2_reg = get_src_reg(gen, CHAN_X, &inst->FullSrcRegisters[1]);
+   int d_reg = get_dst_reg(gen, CHAN_X, &inst->FullDstRegisters[0]);
+   /* d = x * x */
+   spe_fm(gen->f, d_reg, s1_reg, s2_reg);
+
+   s1_reg = get_src_reg(gen, CHAN_Y, &inst->FullSrcRegisters[0]);
+   s2_reg = get_src_reg(gen, CHAN_Y, &inst->FullSrcRegisters[1]);
+   /* d = y * y + d */
+   spe_fma(gen->f, d_reg, s1_reg, s2_reg, d_reg);
+
+   s1_reg = get_src_reg(gen, CHAN_Z, &inst->FullSrcRegisters[0]);
+   s2_reg = get_src_reg(gen, CHAN_Z, &inst->FullSrcRegisters[1]);
+   /* d = z * z + d */
+   spe_fma(gen->f, d_reg, s1_reg, s2_reg, d_reg);
+
+   for (ch = 0; ch < 4; ch++) {
+      if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << ch)) {
+         store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
+         free_itemps(gen);
+      }
+   }
+   return true;
+}
+
+/**
+ * Emit 4 component dot product.  See emit_ADD for comments.
+ */
+static boolean
+emit_DP4(struct codegen *gen, const struct tgsi_full_instruction *inst)
+{
+   int ch;
+   spe_comment(gen->f, -4, "DP3:");
+
+   int s1_reg = get_src_reg(gen, CHAN_X, &inst->FullSrcRegisters[0]);
+   int s2_reg = get_src_reg(gen, CHAN_X, &inst->FullSrcRegisters[1]);
+   int d_reg = get_dst_reg(gen, CHAN_X, &inst->FullDstRegisters[0]);
+   /* d = x * x */
+   spe_fm(gen->f, d_reg, s1_reg, s2_reg);
+
+   s1_reg = get_src_reg(gen, CHAN_Y, &inst->FullSrcRegisters[0]);
+   s2_reg = get_src_reg(gen, CHAN_Y, &inst->FullSrcRegisters[1]);
+   /* d = y * y + d */
+   spe_fma(gen->f, d_reg, s1_reg, s2_reg, d_reg);
+
+   s1_reg = get_src_reg(gen, CHAN_Z, &inst->FullSrcRegisters[0]);
+   s2_reg = get_src_reg(gen, CHAN_Z, &inst->FullSrcRegisters[1]);
+   /* d = z * z + d */
+   spe_fma(gen->f, d_reg, s1_reg, s2_reg, d_reg);
+
+   s1_reg = get_src_reg(gen, CHAN_W, &inst->FullSrcRegisters[0]);
+   s2_reg = get_src_reg(gen, CHAN_W, &inst->FullSrcRegisters[1]);
+   /* d = w * w + d */
+   spe_fma(gen->f, d_reg, s1_reg, s2_reg, d_reg);
+
+   for (ch = 0; ch < 4; ch++) {
+      if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << ch)) {
+         store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
+         free_itemps(gen);
+      }
+   }
+   return true;
+}
 
 /**
  * Emit set-if-greater-than.
@@ -323,6 +642,8 @@ emit_SGT(struct codegen *gen, const struct tgsi_full_instruction *inst)
 {
    int ch;
 
+   spe_comment(gen->f, -4, "SGT:");
+
    for (ch = 0; ch < 4; ch++) {
       if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << ch)) {
          int s1_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
@@ -331,16 +652,10 @@ emit_SGT(struct codegen *gen, const struct tgsi_full_instruction *inst)
 
          /* d = (s1 > s2) */
          spe_fcgt(gen->f, d_reg, s1_reg, s2_reg);
-#if DISASSEM
-         printf("fcgt\tr%d, r%d, r%d\n", d_reg, s1_reg, s2_reg);
-#endif
 
          /* convert d from 0x0/0xffffffff to 0.0/1.0 */
          /* d = d & one_reg */
          spe_and(gen->f, d_reg, d_reg, get_const_one_reg(gen));
-#if DISASSEM
-         printf("and\tr%d, r%d, r%d\n", d_reg, d_reg, get_const_one_reg(gen));
-#endif
 
          store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
          free_itemps(gen);
@@ -350,6 +665,341 @@ emit_SGT(struct codegen *gen, const struct tgsi_full_instruction *inst)
    return true;
 }
 
+/**
+ * Emit set-if_less-then.  See emit_SGT for comments.
+ */
+static boolean
+emit_SLT(struct codegen *gen, const struct tgsi_full_instruction *inst)
+{
+   int ch;
+
+   spe_comment(gen->f, -4, "SLT:");
+
+   for (ch = 0; ch < 4; ch++) {
+      if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << ch)) {
+         int s1_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
+         int s2_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[1]);
+         int d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+
+         /* d = (s1 < s2) */
+         spe_fcgt(gen->f, d_reg, s2_reg, s1_reg);
+
+         /* convert d from 0x0/0xffffffff to 0.0/1.0 */
+         /* d = d & one_reg */
+         spe_and(gen->f, d_reg, d_reg, get_const_one_reg(gen));
+
+         store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
+         free_itemps(gen);
+      }
+   }
+
+   return true;
+}
+
+/**
+ * Emit set-if_greater-then-or-equal.  See emit_SGT for comments.
+ */
+static boolean
+emit_SGE(struct codegen *gen, const struct tgsi_full_instruction *inst)
+{
+   int ch;
+
+   spe_comment(gen->f, -4, "SGE:");
+
+   for (ch = 0; ch < 4; ch++) {
+      if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << ch)) {
+         int s1_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
+         int s2_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[1]);
+         int d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+
+         /* d = (s1 >= s2) */
+         spe_fcgt(gen->f, d_reg, s2_reg, s1_reg);
+
+         /* convert d from 0x0/0xffffffff to 0.0/1.0 */
+         /* d = ~d & one_reg */
+         spe_andc(gen->f, d_reg, get_const_one_reg(gen), d_reg);
+
+         store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
+         free_itemps(gen);
+      }
+   }
+
+   return true;
+}
+
+/**
+ * Emit set-if_less-then-or-equal.  See emit_SGT for comments.
+ */
+static boolean
+emit_SLE(struct codegen *gen, const struct tgsi_full_instruction *inst)
+{
+   int ch;
+
+   spe_comment(gen->f, -4, "SLE:");
+
+   for (ch = 0; ch < 4; ch++) {
+      if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << ch)) {
+         int s1_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
+         int s2_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[1]);
+         int d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+
+         /* d = (s1 <= s2) */
+         spe_fcgt(gen->f, d_reg, s1_reg, s2_reg);
+
+         /* convert d from 0x0/0xffffffff to 0.0/1.0 */
+         /* d = ~d & one_reg */
+         spe_andc(gen->f, d_reg, get_const_one_reg(gen), d_reg);
+
+         store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
+         free_itemps(gen);
+      }
+   }
+
+   return true;
+}
+
+/**
+ * Emit set-if_equal.  See emit_SGT for comments.
+ */
+static boolean
+emit_SEQ(struct codegen *gen, const struct tgsi_full_instruction *inst)
+{
+   int ch;
+
+   spe_comment(gen->f, -4, "SEQ:");
+
+   for (ch = 0; ch < 4; ch++) {
+      if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << ch)) {
+         int s1_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
+         int s2_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[1]);
+         int d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+
+         /* d = (s1 == s2) */
+         spe_fceq(gen->f, d_reg, s1_reg, s2_reg);
+
+         /* convert d from 0x0/0xffffffff to 0.0/1.0 */
+         /* d = d & one_reg */
+         spe_and(gen->f, d_reg, d_reg, get_const_one_reg(gen));
+
+         store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
+         free_itemps(gen);
+      }
+   }
+
+   return true;
+}
+
+/**
+ * Emit set-if_not_equal.  See emit_SGT for comments.
+ */
+static boolean
+emit_SNE(struct codegen *gen, const struct tgsi_full_instruction *inst)
+{
+   int ch;
+
+   spe_comment(gen->f, -4, "SNE:");
+
+   for (ch = 0; ch < 4; ch++) {
+      if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << ch)) {
+         int s1_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
+         int s2_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[1]);
+         int d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+
+         /* d = (s1 != s2) */
+         spe_fceq(gen->f, d_reg, s1_reg, s2_reg);
+         spe_nor(gen->f, d_reg, d_reg, d_reg);
+
+         /* convert d from 0x0/0xffffffff to 0.0/1.0 */
+         /* d = d & one_reg */
+         spe_and(gen->f, d_reg, d_reg, get_const_one_reg(gen));
+
+         store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
+         free_itemps(gen);
+      }
+   }
+
+   return true;
+}
+
+/**
+ * Emit compare.  See emit_SGT for comments.
+ */
+static boolean
+emit_CMP(struct codegen *gen, const struct tgsi_full_instruction *inst)
+{
+   int ch;
+
+   spe_comment(gen->f, -4, "CMP:");
+
+   for (ch = 0; ch < 4; ch++) {
+      if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << ch)) {
+         int s1_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
+         int s2_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[1]);
+         int d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+
+         /* d = (s1 != s2) */
+         spe_fceq(gen->f, d_reg, s1_reg, s2_reg);
+         spe_nor(gen->f, d_reg, d_reg, d_reg);
+
+         /* convert d from 0x0/0xffffffff to 0.0/1.0 */
+         /* d = d & one_reg */
+         spe_and(gen->f, d_reg, d_reg, get_const_one_reg(gen));
+
+         store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
+         free_itemps(gen);
+      }
+   }
+
+   return true;
+}
+
+/**
+ * Emit max.  See emit_SGT for comments.
+ */
+static boolean
+emit_MAX(struct codegen *gen, const struct tgsi_full_instruction *inst)
+{
+   int ch;
+
+   spe_comment(gen->f, -4, "MAX:");
+
+   for (ch = 0; ch < 4; ch++) {
+      if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << ch)) {
+         int s1_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
+         int s2_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[1]);
+         int d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+
+         /* d = (s1 > s2) ? s1 : s2 */
+         spe_fcgt(gen->f, d_reg, s1_reg, s2_reg);
+         spe_selb(gen->f, d_reg, s2_reg, s1_reg, d_reg);
+
+         store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
+         free_itemps(gen);
+      }
+   }
+
+   return true;
+}
+
+/**
+ * Emit max.  See emit_SGT for comments.
+ */
+static boolean
+emit_MIN(struct codegen *gen, const struct tgsi_full_instruction *inst)
+{
+   int ch;
+
+   spe_comment(gen->f, -4, "MIN:");
+
+   for (ch = 0; ch < 4; ch++) {
+      if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << ch)) {
+         int s1_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
+         int s2_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[1]);
+         int d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+
+         /* d = (s2 > s1) ? s1 : s2 */
+         spe_fcgt(gen->f, d_reg, s2_reg, s1_reg);
+         spe_selb(gen->f, d_reg, s2_reg, s1_reg, d_reg);
+
+         store_dest_reg(gen, d_reg, ch, &inst->FullDstRegisters[0]);
+         free_itemps(gen);
+      }
+   }
+
+   return true;
+}
+
+static boolean
+emit_IF(struct codegen *gen, const struct tgsi_full_instruction *inst)
+{
+   const int channel = 0;
+   const int exec_reg = get_exec_mask_reg(gen);
+
+   spe_comment(gen->f, -4, "IF:");
+
+   /* update execution mask with the predicate register */
+   int tmp_reg = get_itemp(gen);
+   int s1_reg = get_src_reg(gen, channel, &inst->FullSrcRegisters[0]);
+
+   /* tmp = (s1_reg == 0) */
+   spe_ceqi(gen->f, tmp_reg, s1_reg, 0);
+   /* tmp = !tmp */
+   spe_complement(gen->f, tmp_reg);
+   /* exec_mask = exec_mask & tmp */
+   spe_and(gen->f, exec_reg, exec_reg, tmp_reg);
+
+   gen->if_nesting++;
+
+   free_itemps(gen);
+
+   return true;
+}
+
+
+static boolean
+emit_ELSE(struct codegen *gen, const struct tgsi_full_instruction *inst)
+{
+   const int exec_reg = get_exec_mask_reg(gen);
+
+   spe_comment(gen->f, -4, "ELSE:");
+
+   /* exec_mask = !exec_mask */
+   spe_complement(gen->f, exec_reg);
+
+   return true;
+}
+
+
+static boolean
+emit_ENDIF(struct codegen *gen, const struct tgsi_full_instruction *inst)
+{
+   const int exec_reg = get_exec_mask_reg(gen);
+
+   spe_comment(gen->f, -4, "ENDIF:");
+
+   /* XXX todo: pop execution mask */
+
+   spe_load_int(gen->f, exec_reg, ~0x0);
+
+   gen->if_nesting--;
+   return true;
+}
+
+
+static boolean
+emit_DDX_DDY(struct codegen *gen, const struct tgsi_full_instruction *inst,
+             boolean ddx)
+{
+   int ch;
+
+   spe_comment(gen->f, -4, ddx ? "DDX:" : "DDY:");
+
+   for (ch = 0; ch < 4; ch++) {
+      if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << ch)) {
+         int s_reg = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
+         int d_reg = get_dst_reg(gen, ch, &inst->FullDstRegisters[0]);
+
+         int t1_reg = get_itemp(gen);
+         int t2_reg = get_itemp(gen);
+
+         spe_splat_word(gen->f, t1_reg, s_reg, 0); /* upper-left pixel */
+         if (ddx) {
+            spe_splat_word(gen->f, t2_reg, s_reg, 1); /* upper-right pixel */
+         }
+         else {
+            spe_splat_word(gen->f, t2_reg, s_reg, 2); /* lower-left pixel */
+         }
+         spe_fs(gen->f, d_reg, t2_reg, t1_reg);
+
+         free_itemps(gen);
+      }
+   }
+
+   return true;
+}
+
+
+
 
 /**
  * Emit END instruction.
@@ -361,11 +1011,9 @@ emit_SGT(struct codegen *gen, const struct tgsi_full_instruction *inst)
 static boolean
 emit_END(struct codegen *gen)
 {
+   spe_comment(gen->f, -4, "END:");
    /* return from function call */
    spe_bi(gen->f, SPE_REG_RA, 0, 0);
-#if DISASSEM
-   printf("bi\trRA\n");
-#endif
    return true;
 }
 
@@ -384,14 +1032,60 @@ emit_instruction(struct codegen *gen,
       return emit_MUL(gen, inst);
    case TGSI_OPCODE_ADD:
       return emit_ADD(gen, inst);
+   case TGSI_OPCODE_SUB:
+      return emit_SUB(gen, inst);
+   case TGSI_OPCODE_MAD:
+      return emit_MAD(gen, inst);
+   case TGSI_OPCODE_LERP:
+      return emit_LERP(gen, inst);
+   case TGSI_OPCODE_DP3:
+      return emit_DP3(gen, inst);
+   case TGSI_OPCODE_DP4:
+      return emit_DP4(gen, inst);
+   case TGSI_OPCODE_RCP:
+      return emit_RCP(gen, inst);
+   case TGSI_OPCODE_RSQ:
+      return emit_RSQ(gen, inst);
+   case TGSI_OPCODE_ABS:
+      return emit_ABS(gen, inst);
    case TGSI_OPCODE_SGT:
       return emit_SGT(gen, inst);
+   case TGSI_OPCODE_SLT:
+      return emit_SLT(gen, inst);
+   case TGSI_OPCODE_SGE:
+      return emit_SGE(gen, inst);
+   case TGSI_OPCODE_SLE:
+      return emit_SLE(gen, inst);
+   case TGSI_OPCODE_SEQ:
+      return emit_SEQ(gen, inst);
+   case TGSI_OPCODE_SNE:
+      return emit_SNE(gen, inst);
+   case TGSI_OPCODE_CMP:
+      return emit_CMP(gen, inst);
+   case TGSI_OPCODE_MAX:
+      return emit_MAX(gen, inst);
+   case TGSI_OPCODE_MIN:
+      return emit_MIN(gen, inst);
    case TGSI_OPCODE_END:
       return emit_END(gen);
 
+   case TGSI_OPCODE_IF:
+      return emit_IF(gen, inst);
+   case TGSI_OPCODE_ELSE:
+      return emit_ELSE(gen, inst);
+   case TGSI_OPCODE_ENDIF:
+      return emit_ENDIF(gen, inst);
+
+   case TGSI_OPCODE_DDX:
+      return emit_DDX_DDY(gen, inst, true);
+   case TGSI_OPCODE_DDY:
+      return emit_DDX_DDY(gen, inst, false);
+
    /* XXX lots more cases to do... */
 
    default:
+      fprintf(stderr, "Cell: unimplemented TGSI instruction %d!\n",
+              inst->Instruction.Opcode);
       return false;
    }
 
@@ -400,46 +1094,89 @@ emit_instruction(struct codegen *gen,
 
 
 
+/**
+ * Emit code for a TGSI immediate value (vector of four floats).
+ * This involves register allocation and initialization.
+ * XXX the initialization should be done by a "prepare" stage, not
+ * per quad execution!
+ */
+static boolean
+emit_immediate(struct codegen *gen, const struct tgsi_full_immediate *immed)
+{
+   int ch;
+
+   assert(gen->num_imm < MAX_TEMPS);
+
+   spe_comment(gen->f, -4, "IMMEDIATE:");
+
+   for (ch = 0; ch < 4; ch++) {
+      float val = immed->u.ImmediateFloat32[ch].Float;
+      int reg = spe_allocate_available_register(gen->f);
+
+      if (reg < 0)
+         return false;
+
+      /* update immediate map */
+      gen->imm_regs[gen->num_imm][ch] = reg;
+
+      /* emit initializer instruction */
+      spe_load_float(gen->f, reg, val);
+   }
+
+   gen->num_imm++;
+
+   return true;
+}
+
+
+
 /**
  * Emit "code" for a TGSI declaration.
  * We only care about TGSI TEMPORARY register declarations at this time.
  * For each TGSI TEMPORARY we allocate four SPE registers.
  */
-static void
-emit_declaration(struct codegen *gen, const struct tgsi_full_declaration *decl)
+static boolean
+emit_declaration(struct cell_context *cell,
+                 struct codegen *gen, const struct tgsi_full_declaration *decl)
 {
    int i, ch;
 
    switch (decl->Declaration.File) {
    case TGSI_FILE_TEMPORARY:
-#if DISASSEM
-      printf("Declare temp reg %d .. %d\n",
-             decl->DeclarationRange.First,
-             decl->DeclarationRange.Last);
-#endif
+      if (cell->debug_flags & CELL_DEBUG_ASM) {
+         printf("Declare temp reg %d .. %d\n",
+                decl->DeclarationRange.First,
+                decl->DeclarationRange.Last);
+      }
+
       for (i = decl->DeclarationRange.First;
            i <= decl->DeclarationRange.Last;
            i++) {
+         assert(i < MAX_TEMPS);
          for (ch = 0; ch < 4; ch++) {
             gen->temp_regs[i][ch] = spe_allocate_available_register(gen->f);
+            if (gen->temp_regs[i][ch] < 0)
+               return false; /* out of regs */
          }
 
          /* XXX if we run out of SPE registers, we need to spill
           * to SPU memory.  someday...
           */
 
-#if DISASSEM
-         printf("  SPE regs: %d %d %d %d\n",
-                gen->temp_regs[i][0],
-                gen->temp_regs[i][1],
-                gen->temp_regs[i][2],
-                gen->temp_regs[i][3]);
-#endif
+         if (cell->debug_flags & CELL_DEBUG_ASM) {
+            printf("  SPE regs: %d %d %d %d\n",
+                   gen->temp_regs[i][0],
+                   gen->temp_regs[i][1],
+                   gen->temp_regs[i][2],
+                   gen->temp_regs[i][3]);
+         }
       }
       break;
    default:
       ; /* ignore */
    }
+
+   return true;
 }
 
 
@@ -472,10 +1209,12 @@ cell_gen_fragment_program(struct cell_context *cell,
    spe_allocate_register(f, gen.outputs_reg);
    spe_allocate_register(f, gen.constants_reg);
 
-#if DISASSEM
-   printf("Begin %s\n", __FUNCTION__);
-   tgsi_dump(tokens, 0);
-#endif
+   if (cell->debug_flags & CELL_DEBUG_ASM) {
+      spe_print_code(f, true);
+      spe_indent(f, 8);
+      printf("Begin %s\n", __FUNCTION__);
+      tgsi_dump(tokens, 0);
+   }
 
    tgsi_parse_init(&parse, tokens);
 
@@ -484,25 +1223,22 @@ cell_gen_fragment_program(struct cell_context *cell,
 
       switch (parse.FullToken.Token.Type) {
       case TGSI_TOKEN_TYPE_IMMEDIATE:
-#if 0
-         if (!note_immediate(&gen, &parse.FullToken.FullImmediate ))
-            goto fail;
-#endif
+         if (!emit_immediate(&gen,  &parse.FullToken.FullImmediate))
+            gen.error = true;
          break;
 
       case TGSI_TOKEN_TYPE_DECLARATION:
-         emit_declaration(&gen, &parse.FullToken.FullDeclaration);
+         if (!emit_declaration(cell, &gen, &parse.FullToken.FullDeclaration))
+            gen.error = true;
          break;
 
       case TGSI_TOKEN_TYPE_INSTRUCTION:
-         if (!emit_instruction(&gen, &parse.FullToken.FullInstruction )) {
+         if (!emit_instruction(&gen, &parse.FullToken.FullInstruction))
             gen.error = true;
-         }
          break;
 
       default:
          assert(0);
-
       }
    }
 
@@ -512,10 +1248,10 @@ cell_gen_fragment_program(struct cell_context *cell,
       return emit_END(&gen);
    }
 
-#if DISASSEM
-   printf("cell_gen_fragment_program nr instructions: %d\n", f->num_inst);
-   printf("End %s\n", __FUNCTION__);
-#endif
+   if (cell->debug_flags & CELL_DEBUG_ASM) {
+      printf("cell_gen_fragment_program nr instructions: %d\n", f->num_inst);
+      printf("End %s\n", __FUNCTION__);
+   }
 
    tgsi_parse_free( &parse );
 
index 06219d4e98097ee35e46edab2537f6d0f8a8f941..9d25e820ad9a0cdc551d4e58bdab64219102a712 100644 (file)
@@ -229,7 +229,27 @@ gen_alpha_test(const struct pipe_depth_stencil_alpha_state *dsa,
    spe_release_register(f, amask_reg);
 }
 
+/* This pair of functions is used inline to allocate and deallocate
+ * optional constant registers.  Once a constant is discovered to be 
+ * needed, we will likely need it again, so we don't want to deallocate
+ * it and have to allocate and load it again unnecessarily.
+ */
+static inline void
+setup_const_register(struct spe_function *f, boolean *is_already_set, unsigned int *r, float value)
+{
+   if (*is_already_set) return;
+   *r = spe_allocate_available_register(f);
+   spe_load_float(f, *r, value);
+   *is_already_set = true;
+}
 
+static inline void
+release_const_register(struct spe_function *f, boolean *is_already_set, unsigned int r)
+{
+    if (!*is_already_set) return;
+    spe_release_register(f, r);
+    *is_already_set = false;
+}
 
 /**
  * Generate SPE code to implement the given blend mode for a quad of pixels.
@@ -242,6 +262,7 @@ gen_alpha_test(const struct pipe_depth_stencil_alpha_state *dsa,
  */
 static void
 gen_blend(const struct pipe_blend_state *blend,
+          const struct pipe_blend_color *blend_color,
           struct spe_function *f,
           enum pipe_format color_format,
           int fragR_reg, int fragG_reg, int fragB_reg, int fragA_reg,
@@ -262,10 +283,17 @@ gen_blend(const struct pipe_blend_state *blend,
    int fbB_reg = spe_allocate_available_register(f);
    int fbA_reg = spe_allocate_available_register(f);
 
-   int one_reg = spe_allocate_available_register(f);
    int tmp_reg = spe_allocate_available_register(f);
 
-   boolean one_reg_set = false; /* avoid setting one_reg more than once */
+   /* Optional constant registers we might or might not end up using;
+    * if we do use them, make sure we only allocate them once by
+    * keeping a flag on each one.
+    */
+   boolean one_reg_set = false;
+   unsigned int one_reg;
+   boolean constR_reg_set = false, constG_reg_set = false, 
+      constB_reg_set = false, constA_reg_set = false;
+   unsigned int constR_reg, constG_reg, constB_reg, constA_reg;
 
    ASSERT(blend->blend_enable);
 
@@ -346,127 +374,449 @@ gen_blend(const struct pipe_blend_state *blend,
       spe_release_register(f, mask_reg);
    }
 
-
    /*
-    * Compute Src RGB terms
+    * Compute Src RGB terms.  We're actually looking for the value
+    * of (the appropriate RGB factors) * (the incoming source RGB color),
+    * because in some cases (like PIPE_BLENDFACTOR_ONE and 
+    * PIPE_BLENDFACTOR_ZERO) we can avoid doing unnecessary math.
     */
    switch (blend->rgb_src_factor) {
    case PIPE_BLENDFACTOR_ONE:
+      /* factors = (1,1,1), so term = (R,G,B) */
       spe_move(f, term1R_reg, fragR_reg);
       spe_move(f, term1G_reg, fragG_reg);
       spe_move(f, term1B_reg, fragB_reg);
       break;
    case PIPE_BLENDFACTOR_ZERO:
-      spe_zero(f, term1R_reg);
-      spe_zero(f, term1G_reg);
-      spe_zero(f, term1B_reg);
+      /* factors = (0,0,0), so term = (0,0,0) */
+      spe_load_float(f, term1R_reg, 0.0f);
+      spe_load_float(f, term1G_reg, 0.0f);
+      spe_load_float(f, term1B_reg, 0.0f);
       break;
    case PIPE_BLENDFACTOR_SRC_COLOR:
+      /* factors = (R,G,B), so term = (R*R, G*G, B*B) */
       spe_fm(f, term1R_reg, fragR_reg, fragR_reg);
       spe_fm(f, term1G_reg, fragG_reg, fragG_reg);
       spe_fm(f, term1B_reg, fragB_reg, fragB_reg);
       break;
    case PIPE_BLENDFACTOR_SRC_ALPHA:
+      /* factors = (A,A,A), so term = (R*A, G*A, B*A) */
       spe_fm(f, term1R_reg, fragR_reg, fragA_reg);
       spe_fm(f, term1G_reg, fragG_reg, fragA_reg);
       spe_fm(f, term1B_reg, fragB_reg, fragA_reg);
       break;
-      /* XXX more cases */
+   case PIPE_BLENDFACTOR_INV_SRC_COLOR:
+      /* factors = (1-R,1-G,1-B), so term = (R*(1-R), G*(1-G), B*(1-B)) 
+       * or in other words term = (R-R*R, G-G*G, B-B*B)
+       * fnms(a,b,c,d) computes a = d - b*c
+       */
+      spe_fnms(f, term1R_reg, fragR_reg, fragR_reg, fragR_reg);
+      spe_fnms(f, term1G_reg, fragG_reg, fragG_reg, fragG_reg);
+      spe_fnms(f, term1B_reg, fragB_reg, fragB_reg, fragB_reg);
+      break;
+   case PIPE_BLENDFACTOR_DST_COLOR:
+      /* factors = (Rfb,Gfb,Bfb), so term = (R*Rfb, G*Gfb, B*Bfb) */
+      spe_fm(f, term1R_reg, fragR_reg, fbR_reg);
+      spe_fm(f, term1G_reg, fragG_reg, fbG_reg);
+      spe_fm(f, term1B_reg, fragB_reg, fbB_reg);
+      break;
+   case PIPE_BLENDFACTOR_INV_DST_COLOR:
+      /* factors = (1-Rfb,1-Gfb,1-Bfb), so term = (R*(1-Rfb),G*(1-Gfb),B*(1-Bfb))
+       * or term = (R-R*Rfb, G-G*Gfb, B-B*Bfb)
+       * fnms(a,b,c,d) computes a = d - b*c
+       */
+      spe_fnms(f, term1R_reg, fragR_reg, fbR_reg, fragR_reg);
+      spe_fnms(f, term1G_reg, fragG_reg, fbG_reg, fragG_reg);
+      spe_fnms(f, term1B_reg, fragB_reg, fbB_reg, fragB_reg);
+      break;
+   case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
+      /* factors = (1-A,1-A,1-A), so term = (R*(1-A),G*(1-A),B*(1-A))
+       * or term = (R-R*A,G-G*A,B-B*A)
+       * fnms(a,b,c,d) computes a = d - b*c
+       */
+      spe_fnms(f, term1R_reg, fragR_reg, fragA_reg, fragR_reg);
+      spe_fnms(f, term1G_reg, fragG_reg, fragA_reg, fragG_reg);
+      spe_fnms(f, term1B_reg, fragB_reg, fragA_reg, fragB_reg);
+      break;
+   case PIPE_BLENDFACTOR_DST_ALPHA:
+      /* factors = (Afb, Afb, Afb), so term = (R*Afb, G*Afb, B*Afb) */
+      spe_fm(f, term1R_reg, fragR_reg, fbA_reg);
+      spe_fm(f, term1G_reg, fragG_reg, fbA_reg);
+      spe_fm(f, term1B_reg, fragB_reg, fbA_reg);
+      break;
+   case PIPE_BLENDFACTOR_INV_DST_ALPHA:
+      /* factors = (1-Afb, 1-Afb, 1-Afb), so term = (R*(1-Afb),G*(1-Afb),B*(1-Afb)) 
+       * or term = (R-R*Afb,G-G*Afb,b-B*Afb)
+       * fnms(a,b,c,d) computes a = d - b*c
+       */
+      spe_fnms(f, term1R_reg, fragR_reg, fbA_reg, fragR_reg);
+      spe_fnms(f, term1G_reg, fragG_reg, fbA_reg, fragG_reg);
+      spe_fnms(f, term1B_reg, fragB_reg, fbA_reg, fragB_reg);
+      break;
+   case PIPE_BLENDFACTOR_CONST_COLOR:
+      /* We need the optional constant color registers */
+      setup_const_register(f, &constR_reg_set, &constR_reg, blend_color->color[0]);
+      setup_const_register(f, &constG_reg_set, &constG_reg, blend_color->color[1]);
+      setup_const_register(f, &constB_reg_set, &constB_reg, blend_color->color[2]);
+      /* now, factor = (Rc,Gc,Bc), so term = (R*Rc,G*Gc,B*Bc) */
+      spe_fm(f, term1R_reg, fragR_reg, constR_reg);
+      spe_fm(f, term1G_reg, fragG_reg, constG_reg);
+      spe_fm(f, term1B_reg, fragB_reg, constB_reg);
+      break;
+   case PIPE_BLENDFACTOR_CONST_ALPHA:
+      /* we'll need the optional constant alpha register */
+      setup_const_register(f, &constA_reg_set, &constA_reg, blend_color->color[3]);
+      /* factor = (Ac,Ac,Ac), so term = (R*Ac,G*Ac,B*Ac) */
+      spe_fm(f, term1R_reg, fragR_reg, constA_reg);
+      spe_fm(f, term1G_reg, fragG_reg, constA_reg);
+      spe_fm(f, term1B_reg, fragB_reg, constA_reg);
+      break;
+   case PIPE_BLENDFACTOR_INV_CONST_COLOR:
+      /* We need the optional constant color registers */
+      setup_const_register(f, &constR_reg_set, &constR_reg, blend_color->color[0]);
+      setup_const_register(f, &constG_reg_set, &constG_reg, blend_color->color[1]);
+      setup_const_register(f, &constB_reg_set, &constB_reg, blend_color->color[2]);
+      /* factor = (1-Rc,1-Gc,1-Bc), so term = (R*(1-Rc),G*(1-Gc),B*(1-Bc)) 
+       * or term = (R-R*Rc, G-G*Gc, B-B*Bc)
+       * fnms(a,b,c,d) computes a = d - b*c
+       */
+      spe_fnms(f, term1R_reg, fragR_reg, constR_reg, fragR_reg);
+      spe_fnms(f, term1G_reg, fragG_reg, constG_reg, fragG_reg);
+      spe_fnms(f, term1B_reg, fragB_reg, constB_reg, fragB_reg);
+      break;
+   case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
+      /* We need the optional constant color registers */
+      setup_const_register(f, &constR_reg_set, &constR_reg, blend_color->color[0]);
+      setup_const_register(f, &constG_reg_set, &constG_reg, blend_color->color[1]);
+      setup_const_register(f, &constB_reg_set, &constB_reg, blend_color->color[2]);
+      /* factor = (1-Ac,1-Ac,1-Ac), so term = (R*(1-Ac),G*(1-Ac),B*(1-Ac))
+       * or term = (R-R*Ac,G-G*Ac,B-B*Ac)
+       * fnms(a,b,c,d) computes a = d - b*c
+       */
+      spe_fnms(f, term1R_reg, fragR_reg, constA_reg, fragR_reg);
+      spe_fnms(f, term1G_reg, fragG_reg, constA_reg, fragG_reg);
+      spe_fnms(f, term1B_reg, fragB_reg, constA_reg, fragB_reg);
+      break;
+   case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
+      /* We'll need the optional {1,1,1,1} register */
+      setup_const_register(f, &one_reg_set, &one_reg, 1.0f);
+      /* factor = (min(A,1-Afb),min(A,1-Afb),min(A,1-Afb)), so 
+       * term = (R*min(A,1-Afb), G*min(A,1-Afb), B*min(A,1-Afb))
+       * We could expand the term (as a*min(b,c) == min(a*b,a*c)
+       * as long as a is positive), but then we'd have to do three
+       * spe_float_min() functions instead of one, so this is simpler.
+       */
+      /* tmp = 1 - Afb */
+      spe_fs(f, tmp_reg, one_reg, fbA_reg);
+      /* tmp = min(A,tmp) */
+      spe_float_min(f, tmp_reg, fragA_reg, tmp_reg);
+      /* term = R*tmp */
+      spe_fm(f, term1R_reg, fragR_reg, tmp_reg);
+      spe_fm(f, term1G_reg, fragG_reg, tmp_reg);
+      spe_fm(f, term1B_reg, fragB_reg, tmp_reg);
+      break;
+
+      /* These are special D3D cases involving a second color output
+       * from the fragment shader.  I'm not sure we can support them
+       * yet... XXX
+       */
+   case PIPE_BLENDFACTOR_SRC1_COLOR:
+   case PIPE_BLENDFACTOR_SRC1_ALPHA:
+   case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
+   case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
+
    default:
       ASSERT(0);
    }
 
    /*
-    * Compute Src Alpha term
+    * Compute Src Alpha term.  Like the above, we're looking for
+    * the full term A*factor, not just the factor itself, because
+    * in many cases we can avoid doing unnecessary multiplies.
     */
    switch (blend->alpha_src_factor) {
+   case PIPE_BLENDFACTOR_ZERO:
+      /* factor = 0, so term = 0 */
+      spe_load_float(f, term1A_reg, 0.0f);
+      break;
+
+   case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE: /* fall through */
    case PIPE_BLENDFACTOR_ONE:
+      /* factor = 1, so term = A */
       spe_move(f, term1A_reg, fragA_reg);
       break;
+
    case PIPE_BLENDFACTOR_SRC_COLOR:
+      /* factor = A, so term = A*A */
       spe_fm(f, term1A_reg, fragA_reg, fragA_reg);
       break;
    case PIPE_BLENDFACTOR_SRC_ALPHA:
       spe_fm(f, term1A_reg, fragA_reg, fragA_reg);
       break;
-      /* XXX more cases */
+
+   case PIPE_BLENDFACTOR_INV_SRC_ALPHA: /* fall through */
+   case PIPE_BLENDFACTOR_INV_SRC_COLOR:
+      /* factor = 1-A, so term = A*(1-A) = A-A*A */
+      /* fnms(a,b,c,d) computes a = d - b*c */
+      spe_fnms(f, term1A_reg, fragA_reg, fragA_reg, fragA_reg);
+      break;
+
+   case PIPE_BLENDFACTOR_DST_ALPHA: /* fall through */
+   case PIPE_BLENDFACTOR_DST_COLOR:
+      /* factor = Afb, so term = A*Afb */
+      spe_fm(f, term1A_reg, fragA_reg, fbA_reg);
+      break;
+
+   case PIPE_BLENDFACTOR_INV_DST_ALPHA: /* fall through */
+   case PIPE_BLENDFACTOR_INV_DST_COLOR:
+      /* factor = 1-Afb, so term = A*(1-Afb) = A - A*Afb */
+      /* fnms(a,b,c,d) computes a = d - b*c */
+      spe_fnms(f, term1A_reg, fragA_reg, fbA_reg, fragA_reg);
+      break;
+
+   case PIPE_BLENDFACTOR_CONST_ALPHA: /* fall through */
+   case PIPE_BLENDFACTOR_CONST_COLOR:
+      /* We need the optional constA_reg register */
+      setup_const_register(f, &constA_reg_set, &constA_reg, blend_color->color[3]);
+      /* factor = Ac, so term = A*Ac */
+      spe_fm(f, term1A_reg, fragA_reg, constA_reg);
+      break;
+
+   case PIPE_BLENDFACTOR_INV_CONST_ALPHA: /* fall through */
+   case PIPE_BLENDFACTOR_INV_CONST_COLOR:
+      /* We need the optional constA_reg register */
+      setup_const_register(f, &constA_reg_set, &constA_reg, blend_color->color[3]);
+      /* factor = 1-Ac, so term = A*(1-Ac) = A-A*Ac */
+      /* fnms(a,b,c,d) computes a = d - b*c */
+      spe_fnms(f, term1A_reg, fragA_reg, constA_reg, fragA_reg);
+      break;
+
+      /* These are special D3D cases involving a second color output
+       * from the fragment shader.  I'm not sure we can support them
+       * yet... XXX
+       */
+   case PIPE_BLENDFACTOR_SRC1_COLOR:
+   case PIPE_BLENDFACTOR_SRC1_ALPHA:
+   case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
+   case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
    default:
       ASSERT(0);
    }
 
    /*
-    * Compute Dest RGB terms
+    * Compute Dest RGB term.  Like the above, we're looking for
+    * the full term (Rfb,Gfb,Bfb)*(factor), not just the factor itself, because
+    * in many cases we can avoid doing unnecessary multiplies.
     */
    switch (blend->rgb_dst_factor) {
    case PIPE_BLENDFACTOR_ONE:
+      /* factors = (1,1,1), so term = (Rfb,Gfb,Bfb) */
       spe_move(f, term2R_reg, fbR_reg);
       spe_move(f, term2G_reg, fbG_reg);
       spe_move(f, term2B_reg, fbB_reg);
       break;
    case PIPE_BLENDFACTOR_ZERO:
-      spe_zero(f, term2R_reg);
-      spe_zero(f, term2G_reg);
-      spe_zero(f, term2B_reg);
+      /* factor s= (0,0,0), so term = (0,0,0) */
+      spe_load_float(f, term2R_reg, 0.0f);
+      spe_load_float(f, term2G_reg, 0.0f);
+      spe_load_float(f, term2B_reg, 0.0f);
       break;
    case PIPE_BLENDFACTOR_SRC_COLOR:
+      /* factors = (R,G,B), so term = (R*Rfb, G*Gfb, B*Bfb) */
       spe_fm(f, term2R_reg, fbR_reg, fragR_reg);
       spe_fm(f, term2G_reg, fbG_reg, fragG_reg);
       spe_fm(f, term2B_reg, fbB_reg, fragB_reg);
       break;
+   case PIPE_BLENDFACTOR_INV_SRC_COLOR:
+      /* factors = (1-R,1-G,1-B), so term = (Rfb*(1-R), Gfb*(1-G), Bfb*(1-B)) 
+       * or in other words term = (Rfb-Rfb*R, Gfb-Gfb*G, Bfb-Bfb*B)
+       * fnms(a,b,c,d) computes a = d - b*c
+       */
+      spe_fnms(f, term2R_reg, fragR_reg, fbR_reg, fbR_reg);
+      spe_fnms(f, term2G_reg, fragG_reg, fbG_reg, fbG_reg);
+      spe_fnms(f, term2B_reg, fragB_reg, fbB_reg, fbB_reg);
+      break;
    case PIPE_BLENDFACTOR_SRC_ALPHA:
+      /* factors = (A,A,A), so term = (Rfb*A, Gfb*A, Bfb*A) */
       spe_fm(f, term2R_reg, fbR_reg, fragA_reg);
       spe_fm(f, term2G_reg, fbG_reg, fragA_reg);
       spe_fm(f, term2B_reg, fbB_reg, fragA_reg);
       break;
    case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
-      /* one = {1.0, 1.0, 1.0, 1.0} */
-      if (!one_reg_set) {
-         spe_load_float(f, one_reg, 1.0f);
-         one_reg_set = true;
-      }
-      /* tmp = one - fragA */
-      spe_fs(f, tmp_reg, one_reg, fragA_reg);
-      /* term = fb * tmp */
-      spe_fm(f, term2R_reg, fbR_reg, tmp_reg);
-      spe_fm(f, term2G_reg, fbG_reg, tmp_reg);
-      spe_fm(f, term2B_reg, fbB_reg, tmp_reg);
-      break;
-      /* XXX more cases */
+      /* factors = (1-A,1-A,1-A) so term = (Rfb-Rfb*A,Gfb-Gfb*A,Bfb-Bfb*A) */
+      /* fnms(a,b,c,d) computes a = d - b*c */
+      spe_fnms(f, term2R_reg, fbR_reg, fragA_reg, fbR_reg);
+      spe_fnms(f, term2G_reg, fbG_reg, fragA_reg, fbG_reg);
+      spe_fnms(f, term2B_reg, fbB_reg, fragA_reg, fbB_reg);
+      break;
+   case PIPE_BLENDFACTOR_DST_COLOR:
+      /* factors = (Rfb,Gfb,Bfb), so term = (Rfb*Rfb, Gfb*Gfb, Bfb*Bfb) */
+      spe_fm(f, term2R_reg, fbR_reg, fbR_reg);
+      spe_fm(f, term2G_reg, fbG_reg, fbG_reg);
+      spe_fm(f, term2B_reg, fbB_reg, fbB_reg);
+      break;
+   case PIPE_BLENDFACTOR_INV_DST_COLOR:
+      /* factors = (1-Rfb,1-Gfb,1-Bfb), so term = (Rfb*(1-Rfb),Gfb*(1-Gfb),Bfb*(1-Bfb))
+       * or term = (Rfb-Rfb*Rfb, Gfb-Gfb*Gfb, Bfb-Bfb*Bfb)
+       * fnms(a,b,c,d) computes a = d - b*c
+       */
+      spe_fnms(f, term2R_reg, fbR_reg, fbR_reg, fbR_reg);
+      spe_fnms(f, term2G_reg, fbG_reg, fbG_reg, fbG_reg);
+      spe_fnms(f, term2B_reg, fbB_reg, fbB_reg, fbB_reg);
+      break;
+
+   case PIPE_BLENDFACTOR_DST_ALPHA:
+      /* factors = (Afb, Afb, Afb), so term = (Rfb*Afb, Gfb*Afb, Bfb*Afb) */
+      spe_fm(f, term2R_reg, fbR_reg, fbA_reg);
+      spe_fm(f, term2G_reg, fbG_reg, fbA_reg);
+      spe_fm(f, term2B_reg, fbB_reg, fbA_reg);
+      break;
+   case PIPE_BLENDFACTOR_INV_DST_ALPHA:
+      /* factors = (1-Afb, 1-Afb, 1-Afb), so term = (Rfb*(1-Afb),Gfb*(1-Afb),Bfb*(1-Afb)) 
+       * or term = (Rfb-Rfb*Afb,Gfb-Gfb*Afb,Bfb-Bfb*Afb)
+       * fnms(a,b,c,d) computes a = d - b*c
+       */
+      spe_fnms(f, term2R_reg, fbR_reg, fbA_reg, fbR_reg);
+      spe_fnms(f, term2G_reg, fbG_reg, fbA_reg, fbG_reg);
+      spe_fnms(f, term2B_reg, fbB_reg, fbA_reg, fbB_reg);
+      break;
+   case PIPE_BLENDFACTOR_CONST_COLOR:
+      /* We need the optional constant color registers */
+      setup_const_register(f, &constR_reg_set, &constR_reg, blend_color->color[0]);
+      setup_const_register(f, &constG_reg_set, &constG_reg, blend_color->color[1]);
+      setup_const_register(f, &constB_reg_set, &constB_reg, blend_color->color[2]);
+      /* now, factor = (Rc,Gc,Bc), so term = (Rfb*Rc,Gfb*Gc,Bfb*Bc) */
+      spe_fm(f, term2R_reg, fbR_reg, constR_reg);
+      spe_fm(f, term2G_reg, fbG_reg, constG_reg);
+      spe_fm(f, term2B_reg, fbB_reg, constB_reg);
+      break;
+   case PIPE_BLENDFACTOR_CONST_ALPHA:
+      /* we'll need the optional constant alpha register */
+      setup_const_register(f, &constA_reg_set, &constA_reg, blend_color->color[3]);
+      /* factor = (Ac,Ac,Ac), so term = (Rfb*Ac,Gfb*Ac,Bfb*Ac) */
+      spe_fm(f, term2R_reg, fbR_reg, constA_reg);
+      spe_fm(f, term2G_reg, fbG_reg, constA_reg);
+      spe_fm(f, term2B_reg, fbB_reg, constA_reg);
+      break;
+   case PIPE_BLENDFACTOR_INV_CONST_COLOR:
+      /* We need the optional constant color registers */
+      setup_const_register(f, &constR_reg_set, &constR_reg, blend_color->color[0]);
+      setup_const_register(f, &constG_reg_set, &constG_reg, blend_color->color[1]);
+      setup_const_register(f, &constB_reg_set, &constB_reg, blend_color->color[2]);
+      /* factor = (1-Rc,1-Gc,1-Bc), so term = (Rfb*(1-Rc),Gfb*(1-Gc),Bfb*(1-Bc)) 
+       * or term = (Rfb-Rfb*Rc, Gfb-Gfb*Gc, Bfb-Bfb*Bc)
+       * fnms(a,b,c,d) computes a = d - b*c
+       */
+      spe_fnms(f, term2R_reg, fbR_reg, constR_reg, fbR_reg);
+      spe_fnms(f, term2G_reg, fbG_reg, constG_reg, fbG_reg);
+      spe_fnms(f, term2B_reg, fbB_reg, constB_reg, fbB_reg);
+      break;
+   case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
+      /* We need the optional constant color registers */
+      setup_const_register(f, &constR_reg_set, &constR_reg, blend_color->color[0]);
+      setup_const_register(f, &constG_reg_set, &constG_reg, blend_color->color[1]);
+      setup_const_register(f, &constB_reg_set, &constB_reg, blend_color->color[2]);
+      /* factor = (1-Ac,1-Ac,1-Ac), so term = (Rfb*(1-Ac),Gfb*(1-Ac),Bfb*(1-Ac))
+       * or term = (Rfb-Rfb*Ac,Gfb-Gfb*Ac,Bfb-Bfb*Ac)
+       * fnms(a,b,c,d) computes a = d - b*c
+       */
+      spe_fnms(f, term2R_reg, fbR_reg, constA_reg, fbR_reg);
+      spe_fnms(f, term2G_reg, fbG_reg, constA_reg, fbG_reg);
+      spe_fnms(f, term2B_reg, fbB_reg, constA_reg, fbB_reg);
+      break;
+   case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE: /* not supported for dest RGB */
+      ASSERT(0);
+      break;
+
+      /* These are special D3D cases involving a second color output
+       * from the fragment shader.  I'm not sure we can support them
+       * yet... XXX
+       */
+   case PIPE_BLENDFACTOR_SRC1_COLOR:
+   case PIPE_BLENDFACTOR_SRC1_ALPHA:
+   case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
+   case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
+
    default:
       ASSERT(0);
    }
 
    /*
-    * Compute Dest Alpha term
+    * Compute Dest Alpha term.  Like the above, we're looking for
+    * the full term Afb*factor, not just the factor itself, because
+    * in many cases we can avoid doing unnecessary multiplies.
     */
    switch (blend->alpha_dst_factor) {
    case PIPE_BLENDFACTOR_ONE:
+      /* factor = 1, so term = Afb */
       spe_move(f, term2A_reg, fbA_reg);
       break;
    case PIPE_BLENDFACTOR_ZERO:
-      spe_zero(f, term2A_reg);
+      /* factor = 0, so term = 0 */
+      spe_load_float(f, term2A_reg, 0.0f);
       break;
-   case PIPE_BLENDFACTOR_SRC_ALPHA:
+
+   case PIPE_BLENDFACTOR_SRC_ALPHA: /* fall through */
+   case PIPE_BLENDFACTOR_SRC_COLOR:
+      /* factor = A, so term = Afb*A */
       spe_fm(f, term2A_reg, fbA_reg, fragA_reg);
       break;
-   case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
-      /* one = {1.0, 1.0, 1.0, 1.0} */
-      if (!one_reg_set) {
-         spe_load_float(f, one_reg, 1.0f);
-         one_reg_set = true;
-      }
-      /* tmp = one - fragA */
-      spe_fs(f, tmp_reg, one_reg, fragA_reg);
-      /* termA = fbA * tmp */
-      spe_fm(f, term2A_reg, fbA_reg, tmp_reg);
+
+   case PIPE_BLENDFACTOR_INV_SRC_ALPHA: /* fall through */
+   case PIPE_BLENDFACTOR_INV_SRC_COLOR:
+      /* factor = 1-A, so term = Afb*(1-A) = Afb-Afb*A */
+      /* fnms(a,b,c,d) computes a = d - b*c */
+      spe_fnms(f, term2A_reg, fbA_reg, fragA_reg, fbA_reg);
+      break;
+
+   case PIPE_BLENDFACTOR_DST_ALPHA: /* fall through */
+   case PIPE_BLENDFACTOR_DST_COLOR:
+      /* factor = Afb, so term = Afb*Afb */
+      spe_fm(f, term2A_reg, fbA_reg, fbA_reg);
       break;
-      /* XXX more cases */
+
+   case PIPE_BLENDFACTOR_INV_DST_ALPHA: /* fall through */
+   case PIPE_BLENDFACTOR_INV_DST_COLOR:
+      /* factor = 1-Afb, so term = Afb*(1-Afb) = Afb - Afb*Afb */
+      /* fnms(a,b,c,d) computes a = d - b*c */
+      spe_fnms(f, term2A_reg, fbA_reg, fbA_reg, fbA_reg);
+      break;
+
+   case PIPE_BLENDFACTOR_CONST_ALPHA: /* fall through */
+   case PIPE_BLENDFACTOR_CONST_COLOR:
+      /* We need the optional constA_reg register */
+      setup_const_register(f, &constA_reg_set, &constA_reg, blend_color->color[3]);
+      /* factor = Ac, so term = Afb*Ac */
+      spe_fm(f, term2A_reg, fbA_reg, constA_reg);
+      break;
+
+   case PIPE_BLENDFACTOR_INV_CONST_ALPHA: /* fall through */
+   case PIPE_BLENDFACTOR_INV_CONST_COLOR:
+      /* We need the optional constA_reg register */
+      setup_const_register(f, &constA_reg_set, &constA_reg, blend_color->color[3]);
+      /* factor = 1-Ac, so term = Afb*(1-Ac) = Afb-Afb*Ac */
+      /* fnms(a,b,c,d) computes a = d - b*c */
+      spe_fnms(f, term2A_reg, fbA_reg, constA_reg, fbA_reg);
+      break;
+
+   case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE: /* not supported for dest alpha */
+      ASSERT(0);
+      break;
+
+      /* These are special D3D cases involving a second color output
+       * from the fragment shader.  I'm not sure we can support them
+       * yet... XXX
+       */
+   case PIPE_BLENDFACTOR_SRC1_COLOR:
+   case PIPE_BLENDFACTOR_SRC1_ALPHA:
+   case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
+   case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
    default:
       ASSERT(0);
    }
 
    /*
-    * Combine Src/Dest RGB terms
+    * Combine Src/Dest RGB terms as per the blend equation.
     */
    switch (blend->rgb_func) {
    case PIPE_BLEND_ADD:
@@ -479,7 +829,21 @@ gen_blend(const struct pipe_blend_state *blend,
       spe_fs(f, fragG_reg, term1G_reg, term2G_reg);
       spe_fs(f, fragB_reg, term1B_reg, term2B_reg);
       break;
-      /* XXX more cases */
+   case PIPE_BLEND_REVERSE_SUBTRACT:
+      spe_fs(f, fragR_reg, term2R_reg, term1R_reg);
+      spe_fs(f, fragG_reg, term2G_reg, term1G_reg);
+      spe_fs(f, fragB_reg, term2B_reg, term1B_reg);
+      break;
+   case PIPE_BLEND_MIN:
+      spe_float_min(f, fragR_reg, term1R_reg, term2R_reg);
+      spe_float_min(f, fragG_reg, term1G_reg, term2G_reg);
+      spe_float_min(f, fragB_reg, term1B_reg, term2B_reg);
+      break;
+   case PIPE_BLEND_MAX:
+      spe_float_max(f, fragR_reg, term1R_reg, term2R_reg);
+      spe_float_max(f, fragG_reg, term1G_reg, term2G_reg);
+      spe_float_max(f, fragB_reg, term1B_reg, term2B_reg);
+      break;
    default:
       ASSERT(0);
    }
@@ -494,7 +858,15 @@ gen_blend(const struct pipe_blend_state *blend,
    case PIPE_BLEND_SUBTRACT:
       spe_fs(f, fragA_reg, term1A_reg, term2A_reg);
       break;
-      /* XXX more cases */
+   case PIPE_BLEND_REVERSE_SUBTRACT:
+      spe_fs(f, fragA_reg, term2A_reg, term1A_reg);
+      break;
+   case PIPE_BLEND_MIN:
+      spe_float_min(f, fragA_reg, term1A_reg, term2A_reg);
+      break;
+   case PIPE_BLEND_MAX:
+      spe_float_max(f, fragA_reg, term1A_reg, term2A_reg);
+      break;
    default:
       ASSERT(0);
    }
@@ -514,8 +886,14 @@ gen_blend(const struct pipe_blend_state *blend,
    spe_release_register(f, fbB_reg);
    spe_release_register(f, fbA_reg);
 
-   spe_release_register(f, one_reg);
    spe_release_register(f, tmp_reg);
+
+   /* Free any optional registers that actually got used */
+   release_const_register(f, &one_reg_set, one_reg);
+   release_const_register(f, &constR_reg_set, constR_reg);
+   release_const_register(f, &constG_reg_set, constG_reg);
+   release_const_register(f, &constB_reg_set, constB_reg);
+   release_const_register(f, &constA_reg_set, constA_reg);
 }
 
 
@@ -629,6 +1007,7 @@ cell_gen_fragment_function(struct cell_context *cell, struct spe_function *f)
    const struct pipe_depth_stencil_alpha_state *dsa =
       &cell->depth_stencil->base;
    const struct pipe_blend_state *blend = &cell->blend->base;
+   const struct pipe_blend_color *blend_color = &cell->blend_color;
    const enum pipe_format color_format = cell->framebuffer.cbufs[0]->format;
 
    /* For SPE function calls: reg $3 = first param, $4 = second param, etc. */
@@ -652,6 +1031,13 @@ cell_gen_fragment_function(struct cell_context *cell, struct spe_function *f)
    int fbZS_reg;    /**< framebuffer's combined z/stencil values for quad */
 
    spe_init_func(f, SPU_MAX_FRAGMENT_OPS_INSTS * SPE_INST_SIZE);
+
+   if (cell->debug_flags & CELL_DEBUG_ASM) {
+      spe_print_code(f, true);
+      spe_indent(f, 8);
+      spe_comment(f, -4, "Begin per-fragment ops");
+   }
+
    spe_allocate_register(f, x_reg);
    spe_allocate_register(f, y_reg);
    spe_allocate_register(f, color_tile_reg);
@@ -816,7 +1202,7 @@ cell_gen_fragment_function(struct cell_context *cell, struct spe_function *f)
 
 
    if (blend->blend_enable) {
-      gen_blend(blend, f, color_format,
+      gen_blend(blend, blend_color, f, color_format,
                 fragR_reg, fragG_reg, fragB_reg, fragA_reg, fbRGBA_reg);
    }
 
@@ -866,5 +1252,8 @@ cell_gen_fragment_function(struct cell_context *cell, struct spe_function *f)
    spe_release_register(f, fbRGBA_reg);
    spe_release_register(f, fbZS_reg);
    spe_release_register(f, quad_offset_reg);
-}
 
+   if (cell->debug_flags & CELL_DEBUG_ASM) {
+      spe_comment(f, -4, "End per-fragment ops");
+   }
+}
index 475c6ef0ce645f06415a2102e903d0051c1ed974..ea820aca7443e856d8e6902e2f6652053702130a 100644 (file)
@@ -72,7 +72,9 @@ cell_delete_blend_state(struct pipe_context *pipe, void *blend)
 {
    struct cell_blend_state *cb = (struct cell_blend_state *) blend;
 
+#if 0
    spe_release_func(& cb->code);
+#endif
    FREE(cb);
 }
 
@@ -128,7 +130,9 @@ cell_delete_depth_stencil_alpha_state(struct pipe_context *pipe, void *depth)
    struct cell_depth_stencil_alpha_state *cdsa =
        (struct cell_depth_stencil_alpha_state *) depth;
 
+#if 0
    spe_release_func(& cdsa->code);
+#endif
    FREE(cdsa);
 }
 
index 139b3719b622bb33c9f23c39703071ebba4766cf..47ba6fa29097ceff058fdf1ea36aee1c3f480317 100644 (file)
@@ -58,9 +58,9 @@ cell_get_param(struct pipe_screen *screen, int param)
    case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
       return CELL_MAX_SAMPLERS;
    case PIPE_CAP_NPOT_TEXTURES:
-      return 0;
+      return 1;
    case PIPE_CAP_TWO_SIDED_STENCIL:
-      return 0;
+      return 1;
    case PIPE_CAP_GLSL:
       return 1;
    case PIPE_CAP_S3TC:
@@ -68,13 +68,13 @@ cell_get_param(struct pipe_screen *screen, int param)
    case PIPE_CAP_ANISOTROPIC_FILTER:
       return 0;
    case PIPE_CAP_POINT_SPRITE:
-      return 0;
+      return 1;
    case PIPE_CAP_MAX_RENDER_TARGETS:
       return 1;
    case PIPE_CAP_OCCLUSION_QUERY:
-      return 0;
+      return 1;
    case PIPE_CAP_TEXTURE_SHADOW_MAP:
-      return 0;
+      return 10;
    case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
       return 12; /* max 2Kx2K */
    case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
@@ -82,7 +82,7 @@ cell_get_param(struct pipe_screen *screen, int param)
    case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
       return 12; /* max 2Kx2K */
    default:
-      return 0;
+      return 10;
    }
 }
 
@@ -108,7 +108,7 @@ cell_get_paramf(struct pipe_screen *screen, int param)
       return 16.0; /* arbitrary */
 
    default:
-      return 0;
+      return 10;
    }
 }
 
index 2da3097983c113c7a732f3e36cb006b40b5202bd..8a389cd6aae1de3ef65619e3de9e98f4c5684e3f 100644 (file)
@@ -100,14 +100,19 @@ cell_emit_state(struct cell_context *cell)
             = cell_batch_alloc(cell, sizeof(*fops));
       struct spe_function spe_code;
 
+      /* Prepare the buffer that will hold the generated code. */
+      spe_init_func(&spe_code, SPU_MAX_FRAGMENT_OPS_INSTS * SPE_INST_SIZE);
+
       /* generate new code */
       cell_gen_fragment_function(cell, &spe_code);
+
       /* put the new code into the batch buffer */
       fops->opcode = CELL_CMD_STATE_FRAGMENT_OPS;
       memcpy(&fops->code, spe_code.store,
              SPU_MAX_FRAGMENT_OPS_INSTS * SPE_INST_SIZE);
       fops->dsa = cell->depth_stencil->base;
       fops->blend = cell->blend->base;
+
       /* free codegen buffer */
       spe_release_func(&spe_code);
    }
index 78260c4259cf35a88a8421f245776038e601484e..da2cb08972281cd2fda70fbdf28d27aecd6f16a5 100644 (file)
@@ -50,7 +50,31 @@ helpful headers:
 /opt/cell/sdk/usr/include/libmisc.h
 */
 
+/* Set to 0 to disable all extraneous debugging code */
+#define DEBUG 1
+
+#if DEBUG
 boolean Debug = FALSE;
+boolean force_fragment_ops_fallback = TRUE;
+
+/* These debug macros use the unusual construction ", ##__VA_ARGS__"
+ * which expands to the expected comma + args if variadic arguments
+ * are supplied, but swallows the comma if there are no variadic
+ * arguments (which avoids syntax errors that would otherwise occur).
+ */
+#define DEBUG_PRINTF(format,...) \
+   if (Debug) \
+      printf("SPU %u: " format, spu.init.id, ##__VA_ARGS__)
+#define D_PRINTF(flag, format,...) \
+   if (spu.init.debug_flags & (flag)) \
+      printf("SPU %u: " format, spu.init.id, ##__VA_ARGS__)
+
+#else
+
+#define DEBUG_PRINTF(...)
+#define D_PRINTF(...)
+
+#endif
 
 struct spu_global spu;
 
@@ -133,9 +157,7 @@ really_clear_tiles(uint surfaceIndex)
 static void
 cmd_clear_surface(const struct cell_command_clear_surface *clear)
 {
-   if (Debug)
-      printf("SPU %u: CLEAR SURF %u to 0x%08x\n", spu.init.id,
-             clear->surface, clear->value);
+   DEBUG_PRINTF("CLEAR SURF %u to 0x%08x\n", clear->surface, clear->value);
 
    if (clear->surface == 0) {
       spu.fb.color_clear_value = clear->value;
@@ -203,17 +225,14 @@ cmd_clear_surface(const struct cell_command_clear_surface *clear)
 
 #endif /* CLEAR_OPT */
 
-   if (Debug)
-      printf("SPU %u: CLEAR SURF done\n", spu.init.id);
+   DEBUG_PRINTF("CLEAR SURF done\n");
 }
 
 
 static void
 cmd_release_verts(const struct cell_command_release_verts *release)
 {
-   if (Debug)
-      printf("SPU %u: RELEASE VERTS %u\n",
-             spu.init.id, release->vertex_buf);
+   DEBUG_PRINTF("RELEASE VERTS %u\n", release->vertex_buf);
    ASSERT(release->vertex_buf != ~0U);
    release_buffer(release->vertex_buf);
 }
@@ -228,16 +247,30 @@ cmd_release_verts(const struct cell_command_release_verts *release)
 static void
 cmd_state_fragment_ops(const struct cell_command_fragment_ops *fops)
 {
-   if (Debug)
-      printf("SPU %u: CMD_STATE_FRAGMENT_OPS\n", spu.init.id);
+   DEBUG_PRINTF("CMD_STATE_FRAGMENT_OPS\n");
    /* Copy SPU code from batch buffer to spu buffer */
    memcpy(spu.fragment_ops_code, fops->code, SPU_MAX_FRAGMENT_OPS_INSTS * 4);
    /* Copy state info (for fallback case only) */
    memcpy(&spu.depth_stencil_alpha, &fops->dsa, sizeof(fops->dsa));
    memcpy(&spu.blend, &fops->blend, sizeof(fops->blend));
 
-   /* Point function pointer at new code */
-   spu.fragment_ops = (spu_fragment_ops_func) spu.fragment_ops_code;
+   /* Parity twist!  For now, always use the fallback code by default,
+    * only switching to codegen when specifically requested.  This
+    * allows us to develop freely without risking taking down the
+    * branch.
+    *
+    * Later, the parity of this check will be reversed, so that
+    * codegen is *always* used, unless we specifically indicate that
+    * we don't want it.
+    *
+    * Eventually, the option will be removed completely, because in
+    * final code we'll always use codegen and won't even provide the
+    * raw state records that the fallback code requires.
+    */
+   if (spu.init.debug_flags & CELL_DEBUG_FRAGMENT_OP_FALLBACK) {
+      spu.fragment_ops = (spu_fragment_ops_func) spu.fragment_ops_code;
+   }
+   /* otherwise, the default fallback code remains in place */
 
    spu.read_depth = spu.depth_stencil_alpha.depth.enabled;
    spu.read_stencil = spu.depth_stencil_alpha.stencil[0].enabled;
@@ -247,8 +280,7 @@ cmd_state_fragment_ops(const struct cell_command_fragment_ops *fops)
 static void
 cmd_state_fragment_program(const struct cell_command_fragment_program *fp)
 {
-   if (Debug)
-      printf("SPU %u: CMD_STATE_FRAGMENT_PROGRAM\n", spu.init.id);
+   DEBUG_PRINTF("CMD_STATE_FRAGMENT_PROGRAM\n");
    /* Copy SPU code from batch buffer to spu buffer */
    memcpy(spu.fragment_program_code, fp->code,
           SPU_MAX_FRAGMENT_PROGRAM_INSTS * 4);
@@ -262,9 +294,7 @@ cmd_state_fragment_program(const struct cell_command_fragment_program *fp)
 static void
 cmd_state_framebuffer(const struct cell_command_framebuffer *cmd)
 {
-   if (Debug)
-      printf("SPU %u: FRAMEBUFFER: %d x %d at %p, cformat 0x%x  zformat 0x%x\n",
-             spu.init.id,
+   DEBUG_PRINTF("FRAMEBUFFER: %d x %d at %p, cformat 0x%x  zformat 0x%x\n",
              cmd->width,
              cmd->height,
              cmd->color_start,
@@ -309,9 +339,7 @@ cmd_state_framebuffer(const struct cell_command_framebuffer *cmd)
 static void
 cmd_state_sampler(const struct cell_command_sampler *sampler)
 {
-   if (Debug)
-      printf("SPU %u: SAMPLER [%u]\n",
-             spu.init.id, sampler->unit);
+   DEBUG_PRINTF("SAMPLER [%u]\n", sampler->unit);
 
    spu.sampler[sampler->unit] = sampler->state;
    if (spu.sampler[sampler->unit].min_img_filter == PIPE_TEX_FILTER_LINEAR)
@@ -328,11 +356,9 @@ cmd_state_texture(const struct cell_command_texture *texture)
    const uint width = texture->width;
    const uint height = texture->height;
 
-   if (Debug) {
-      printf("SPU %u: TEXTURE [%u] at %p  size %u x %u\n", spu.init.id,
+   DEBUG_PRINTF("TEXTURE [%u] at %p  size %u x %u\n",
              texture->unit, texture->start,
              texture->width, texture->height);
-   }
 
    spu.texture[unit].start = texture->start;
    spu.texture[unit].width = width;
@@ -351,10 +377,7 @@ cmd_state_texture(const struct cell_command_texture *texture)
 static void
 cmd_state_vertex_info(const struct vertex_info *vinfo)
 {
-   if (Debug) {
-      printf("SPU %u: VERTEX_INFO num_attribs=%u\n", spu.init.id,
-             vinfo->num_attribs);
-   }
+   DEBUG_PRINTF("VERTEX_INFO num_attribs=%u\n", vinfo->num_attribs);
    ASSERT(vinfo->num_attribs >= 1);
    ASSERT(vinfo->num_attribs <= 8);
    memcpy(&spu.vertex_info, vinfo, sizeof(*vinfo));
@@ -393,8 +416,7 @@ cmd_state_attrib_fetch(const struct cell_attribute_fetch_code *code)
 static void
 cmd_finish(void)
 {
-   if (Debug)
-      printf("SPU %u: FINISH\n", spu.init.id);
+   DEBUG_PRINTF("FINISH\n");
    really_clear_tiles(0);
    /* wait for all outstanding DMAs to finish */
    mfc_write_tag_mask(~0);
@@ -419,9 +441,8 @@ cmd_batch(uint opcode)
    const unsigned usize = size / sizeof(buffer[0]);
    uint pos;
 
-   if (Debug)
-      printf("SPU %u: BATCH buffer %u, len %u, from %p\n",
-             spu.init.id, buf, size, spu.init.buffers[buf]);
+   DEBUG_PRINTF("BATCH buffer %u, len %u, from %p\n",
+             buf, size, spu.init.buffers[buf]);
 
    ASSERT((opcode & CELL_CMD_OPCODE_MASK) == CELL_CMD_BATCH);
 
@@ -440,8 +461,7 @@ cmd_batch(uint opcode)
    wait_on_mask(1 << TAG_BATCH_BUFFER);
 
    /* Tell PPU we're done copying the buffer to local store */
-   if (Debug)
-      printf("SPU %u: release batch buf %u\n", spu.init.id, buf);
+   DEBUG_PRINTF("release batch buf %u\n", buf);
    release_buffer(buf);
 
    /*
@@ -571,8 +591,7 @@ cmd_batch(uint opcode)
       }
    }
 
-   if (Debug)
-      printf("SPU %u: BATCH complete\n", spu.init.id);
+   DEBUG_PRINTF("BATCH complete\n");
 }
 
 
@@ -585,8 +604,7 @@ main_loop(void)
    struct cell_command cmd;
    int exitFlag = 0;
 
-   if (Debug)
-      printf("SPU %u: Enter main loop\n", spu.init.id);
+   DEBUG_PRINTF("Enter main loop\n");
 
    ASSERT((sizeof(struct cell_command) & 0xf) == 0);
    ASSERT_ALIGN16(&cmd);
@@ -595,14 +613,12 @@ main_loop(void)
       unsigned opcode;
       int tag = 0;
 
-      if (Debug)
-         printf("SPU %u: Wait for cmd...\n", spu.init.id);
+      DEBUG_PRINTF("Wait for cmd...\n");
 
       /* read/wait from mailbox */
       opcode = (unsigned int) spu_read_in_mbox();
 
-      if (Debug)
-         printf("SPU %u: got cmd 0x%x\n", spu.init.id, opcode);
+      DEBUG_PRINTF("got cmd 0x%x\n", opcode);
 
       /* command payload */
       mfc_get(&cmd,  /* dest */
@@ -619,8 +635,7 @@ main_loop(void)
 
       switch (opcode & CELL_CMD_OPCODE_MASK) {
       case CELL_CMD_EXIT:
-         if (Debug)
-            printf("SPU %u: EXIT\n", spu.init.id);
+         DEBUG_PRINTF("EXIT\n");
          exitFlag = 1;
          break;
       case CELL_CMD_VS_EXECUTE:
@@ -632,13 +647,12 @@ main_loop(void)
          cmd_batch(opcode);
          break;
       default:
-         printf("Bad opcode!\n");
+         printf("Bad opcode 0x%x!\n", opcode & CELL_CMD_OPCODE_MASK);
       }
 
    }
 
-   if (Debug)
-      printf("SPU %u: Exit main loop\n", spu.init.id);
+   DEBUG_PRINTF("Exit main loop\n");
 
    spu_dcache_report();
 }
@@ -653,7 +667,8 @@ one_time_init(void)
    invalidate_tex_cache();
 
    /* Install default/fallback fragment processing function.
-    * This will normally be overriden by a code-gen'd function.
+    * This will normally be overriden by a code-gen'd function
+    * unless CELL_FORCE_FRAGMENT_OPS_FALLBACK is set.
     */
    spu.fragment_ops = spu_fallback_fragment_ops;
 }
@@ -685,8 +700,8 @@ main(main_param_t speid, main_param_t argp)
 
    one_time_init();
 
-   if (Debug)
-      printf("SPU: main() speid=%lu\n", (unsigned long) speid);
+   DEBUG_PRINTF("main() speid=%lu\n", (unsigned long) speid);
+   D_PRINTF(CELL_DEBUG_FRAGMENT_OP_FALLBACK, "using fragment op fallback\n");
 
    mfc_get(&spu.init,  /* dest */
            (unsigned int) argp, /* src */
index 03dd547845ba81e0a9fdc69a6084f044b0ea3829..f107764fb28c199ce4f6f040e3fdd1710fbfcb2e 100644 (file)
@@ -60,9 +60,12 @@ spu_fallback_fragment_ops(uint x, uint y,
                           vector unsigned int mask)
 {
    vector float frag_aos[4];
-   unsigned int c0, c1, c2, c3;
+   unsigned int fbc0, fbc1, fbc2, fbc3 ; /* framebuffer/tile colors */
+   unsigned int fragc0, fragc1, fragc2, fragc3;  /* fragment colors */
 
-   /* do alpha test */
+   /*
+    * Do alpha test
+    */
    if (spu.depth_stencil_alpha.alpha.enabled) {
       vector float ref = spu_splats(spu.depth_stencil_alpha.alpha.ref);
       vector unsigned int amask;
@@ -102,7 +105,10 @@ spu_fallback_fragment_ops(uint x, uint y,
       mask = spu_and(mask, amask);
    }
 
-   /* Z and/or stencil testing... */
+
+   /*
+    * Z and/or stencil testing...
+    */
    if (spu.depth_stencil_alpha.depth.enabled ||
        spu.depth_stencil_alpha.stencil[0].enabled) {
 
@@ -178,6 +184,32 @@ spu_fallback_fragment_ops(uint x, uint y,
       }
    }
 
+
+   /*
+    * If we'll need the current framebuffer/tile colors for blending
+    * or logicop or colormask, fetch them now.
+    */
+   if (spu.blend.blend_enable ||
+       spu.blend.logicop_enable ||
+       spu.blend.colormask != 0xf) {
+
+#if LINEAR_QUAD_LAYOUT /* See comments/diagram below */
+      fbc0 = colorTile->ui[y][x*2+0];
+      fbc1 = colorTile->ui[y][x*2+1];
+      fbc2 = colorTile->ui[y][x*2+2];
+      fbc3 = colorTile->ui[y][x*2+3];
+#else
+      fbc0 = colorTile->ui[y+0][x+0];
+      fbc1 = colorTile->ui[y+0][x+1];
+      fbc2 = colorTile->ui[y+1][x+0];
+      fbc3 = colorTile->ui[y+1][x+1];
+#endif
+   }
+
+
+   /*
+    * Do blending
+    */
    if (spu.blend.blend_enable) {
       /* blending terms, misc regs */
       vector float term1r, term1g, term1b, term1a;
@@ -186,39 +218,26 @@ spu_fallback_fragment_ops(uint x, uint y,
 
       vector float fbRGBA[4];  /* current framebuffer colors */
 
-      /* get colors from framebuffer/tile */
+      /* convert framebuffer colors from packed int to vector float */
       {
-         vector float fc[4];
-         uint c0, c1, c2, c3;
-
-#if LINEAR_QUAD_LAYOUT /* See comments/diagram below */
-         c0 = colorTile->ui[y][x*2+0];
-         c1 = colorTile->ui[y][x*2+1];
-         c2 = colorTile->ui[y][x*2+2];
-         c3 = colorTile->ui[y][x*2+3];
-#else
-         c0 = colorTile->ui[y+0][x+0];
-         c1 = colorTile->ui[y+0][x+1];
-         c2 = colorTile->ui[y+1][x+0];
-         c3 = colorTile->ui[y+1][x+1];
-#endif
+         vector float temp[4]; /* float colors in AOS form */
          switch (spu.fb.color_format) {
          case PIPE_FORMAT_B8G8R8A8_UNORM:
-            fc[0] = spu_unpack_B8G8R8A8(c0);
-            fc[1] = spu_unpack_B8G8R8A8(c1);
-            fc[2] = spu_unpack_B8G8R8A8(c2);
-            fc[3] = spu_unpack_B8G8R8A8(c3);
+            temp[0] = spu_unpack_B8G8R8A8(fbc0);
+            temp[1] = spu_unpack_B8G8R8A8(fbc1);
+            temp[2] = spu_unpack_B8G8R8A8(fbc2);
+            temp[3] = spu_unpack_B8G8R8A8(fbc3);
             break;
          case PIPE_FORMAT_A8R8G8B8_UNORM:
-            fc[0] = spu_unpack_A8R8G8B8(c0);
-            fc[1] = spu_unpack_A8R8G8B8(c1);
-            fc[2] = spu_unpack_A8R8G8B8(c2);
-            fc[3] = spu_unpack_A8R8G8B8(c3);
+            temp[0] = spu_unpack_A8R8G8B8(fbc0);
+            temp[1] = spu_unpack_A8R8G8B8(fbc1);
+            temp[2] = spu_unpack_A8R8G8B8(fbc2);
+            temp[3] = spu_unpack_A8R8G8B8(fbc3);
             break;
          default:
             ASSERT(0);
          }
-         _transpose_matrix4x4(fbRGBA, fc);
+         _transpose_matrix4x4(fbRGBA, temp); /* fbRGBA = transpose(temp) */
       }
 
       /*
@@ -384,21 +403,20 @@ spu_fallback_fragment_ops(uint x, uint y,
 #endif
 
    /*
-    * Pack float colors into 32-bit RGBA words.
+    * Pack fragment float colors into 32-bit RGBA words.
     */
    switch (spu.fb.color_format) {
    case PIPE_FORMAT_A8R8G8B8_UNORM:
-      c0 = spu_pack_A8R8G8B8(frag_aos[0]);
-      c1 = spu_pack_A8R8G8B8(frag_aos[1]);
-      c2 = spu_pack_A8R8G8B8(frag_aos[2]);
-      c3 = spu_pack_A8R8G8B8(frag_aos[3]);
+      fragc0 = spu_pack_A8R8G8B8(frag_aos[0]);
+      fragc1 = spu_pack_A8R8G8B8(frag_aos[1]);
+      fragc2 = spu_pack_A8R8G8B8(frag_aos[2]);
+      fragc3 = spu_pack_A8R8G8B8(frag_aos[3]);
       break;
-
    case PIPE_FORMAT_B8G8R8A8_UNORM:
-      c0 = spu_pack_B8G8R8A8(frag_aos[0]);
-      c1 = spu_pack_B8G8R8A8(frag_aos[1]);
-      c2 = spu_pack_B8G8R8A8(frag_aos[2]);
-      c3 = spu_pack_B8G8R8A8(frag_aos[3]);
+      fragc0 = spu_pack_B8G8R8A8(frag_aos[0]);
+      fragc1 = spu_pack_B8G8R8A8(frag_aos[1]);
+      fragc2 = spu_pack_B8G8R8A8(frag_aos[2]);
+      fragc3 = spu_pack_B8G8R8A8(frag_aos[3]);
       break;
    default:
       fprintf(stderr, "SPU: Bad pixel format in spu_default_fragment_ops\n");
@@ -407,20 +425,57 @@ spu_fallback_fragment_ops(uint x, uint y,
 
 
    /*
-    * Color masking
+    * Do color masking
     */
    if (spu.blend.colormask != 0xf) {
-      /* XXX to do */
-      /* apply color mask to 32-bit packed colors */
+      uint cmask = 0x0; /* each byte corresponds to a color channel */
+
+      /* Form bitmask depending on color buffer format and colormask bits */
+      switch (spu.fb.color_format) {
+      case PIPE_FORMAT_A8R8G8B8_UNORM:
+         if (spu.blend.colormask & (1<<0))
+            cmask |= 0x00ff0000; /* red */
+         if (spu.blend.colormask & (1<<1))
+            cmask |= 0x0000ff00; /* green */
+         if (spu.blend.colormask & (1<<2))
+            cmask |= 0x000000ff; /* blue */
+         if (spu.blend.colormask & (1<<3))
+            cmask |= 0xff000000; /* alpha */
+         break;
+      case PIPE_FORMAT_B8G8R8A8_UNORM:
+         if (spu.blend.colormask & (1<<0))
+            cmask |= 0x0000ff00; /* red */
+         if (spu.blend.colormask & (1<<1))
+            cmask |= 0x00ff0000; /* green */
+         if (spu.blend.colormask & (1<<2))
+            cmask |= 0xff000000; /* blue */
+         if (spu.blend.colormask & (1<<3))
+            cmask |= 0x000000ff; /* alpha */
+         break;
+      default:
+         ASSERT(0);
+      }
+
+      /*
+       * Apply color mask to the 32-bit packed colors.
+       * if (cmask[i])
+       *    frag color[i] = frag color[i];
+       * else
+       *    frag color[i] = framebuffer color[i];
+       */
+      fragc0 = (fragc0 & cmask) | (fbc0 & ~cmask);
+      fragc1 = (fragc1 & cmask) | (fbc1 & ~cmask);
+      fragc2 = (fragc2 & cmask) | (fbc2 & ~cmask);
+      fragc3 = (fragc3 & cmask) | (fbc3 & ~cmask);
    }
 
 
    /*
-    * Logic Ops
+    * Do logic ops
     */
    if (spu.blend.logicop_enable) {
       /* XXX to do */
-      /* apply logicop to 32-bit packed colors */
+      /* apply logicop to 32-bit packed colors (fragcx and fbcx) */
    }
 
 
@@ -431,45 +486,46 @@ spu_fallback_fragment_ops(uint x, uint y,
       spu.cur_ctile_status = TILE_STATUS_DIRTY;
    }
    else {
+      /* write no fragments */
       return;
    }
 
 
    /*
-    * Write new quad colors to the framebuffer/tile.
+    * Write new fragment/quad colors to the framebuffer/tile.
     * Only write pixels where the corresponding mask word is set.
     */
 #if LINEAR_QUAD_LAYOUT
    /*
     * Quad layout:
     *  +--+--+--+--+
-    *  |p0|p1|p2|p3|
+    *  |p0|p1|p2|p3|...
     *  +--+--+--+--+
     */
    if (spu_extract(mask, 0))
-      colorTile->ui[y][x*2] = c0;
+      colorTile->ui[y][x*2] = fragc0;
    if (spu_extract(mask, 1))
-      colorTile->ui[y][x*2+1] = c1;
+      colorTile->ui[y][x*2+1] = fragc1;
    if (spu_extract(mask, 2))
-      colorTile->ui[y][x*2+2] = c2;
+      colorTile->ui[y][x*2+2] = fragc2;
    if (spu_extract(mask, 3))
-      colorTile->ui[y][x*2+3] = c3;
+      colorTile->ui[y][x*2+3] = fragc3;
 #else
    /*
     * Quad layout:
     *  +--+--+
-    *  |p0|p1|
+    *  |p0|p1|...
     *  +--+--+
-    *  |p2|p3|
+    *  |p2|p3|...
     *  +--+--+
     */
    if (spu_extract(mask, 0))
-      colorTile->ui[y+0][x+0] = c0;
+      colorTile->ui[y+0][x+0] = fragc0;
    if (spu_extract(mask, 1))
-      colorTile->ui[y+0][x+1] = c1;
+      colorTile->ui[y+0][x+1] = fragc1;
    if (spu_extract(mask, 2))
-      colorTile->ui[y+1][x+0] = c2;
+      colorTile->ui[y+1][x+0] = fragc2;
    if (spu_extract(mask, 3))
-      colorTile->ui[y+1][x+1] = c3;
+      colorTile->ui[y+1][x+1] = fragc3;
 #endif
 }
index 8b93878192013a78a6a87f2f3214786d1d63eaed..0a8fb56a62c25c9be6870bb995cd5ba298fd6bc0 100644 (file)
@@ -241,6 +241,19 @@ eval_coeff(uint slot, float x, float y, vector float result[4])
 }
 
 
+/**
+ * As above, but return 4 vectors in SOA format.
+ * XXX this will all be re-written someday.
+ */
+static INLINE void
+eval_coeff_soa(uint slot, float x, float y, vector float result[4])
+{
+   eval_coeff(slot, x, y, result);
+   _transpose_matrix4x4(result, result);
+}
+
+
+
 static INLINE vector float
 eval_z(float x, float y)
 {
@@ -267,14 +280,17 @@ emit_quad( int x, int y, mask_t mask )
    if (spu_extract(spu_orx(mask), 0)) {
       const int ix = x - setup.cliprect_minx;
       const int iy = y - setup.cliprect_miny;
-      vector float colors[4];
 
       spu.cur_ctile_status = TILE_STATUS_DIRTY;
       spu.cur_ztile_status = TILE_STATUS_DIRTY;
 
       if (spu.texture[0].start) {
-         /* texture mapping */
+         /*
+          * Temporary texture mapping path
+          * This will go away when fragment programs support TEX inst.
+          */
          const uint unit = 0;
+         vector float colors[4];
          vector float texcoords[4];
          eval_coeff(2, (float) x, (float) y, texcoords);
 
@@ -311,70 +327,60 @@ emit_quad( int x, int y, mask_t mask )
             colors[3] = spu_mul(colors[3], colors1[3]);
          }
 
+         {
+            /* Convert fragment data from AoS to SoA format.
+             * I.e. (RGBA,RGBA,RGBA,RGBA) -> (RRRR,GGGG,BBBB,AAAA)
+             * This is temporary!
+             */
+            vector float soa_frag[4];
+            _transpose_matrix4x4(soa_frag, colors);
+
+            vector float fragZ = eval_z((float) x, (float) y);
+
+            /* Do all per-fragment/quad operations here, including:
+             * alpha test, z test, stencil test, blend and framebuffer writing.
+             */
+            spu.fragment_ops(ix, iy, &spu.ctile, &spu.ztile,
+                             fragZ,
+                             soa_frag[0], soa_frag[1],
+                             soa_frag[2], soa_frag[3],
+                             mask);
+         }
+
       }
       else {
-         /* simple shading */
-#if 0
-         eval_coeff(1, (float) x, (float) y, colors);
+         /*
+          * Run fragment shader, execute per-fragment ops, update fb/tile.
+          */
+         vector float inputs[4*4], outputs[2*4];
+         vector float fragZ = eval_z((float) x, (float) y);
 
+         /* setup inputs */
+#if 0
+         eval_coeff_soa(1, (float) x, (float) y, inputs);
 #else
-         /* XXX new fragment program code */
-
-         if (spu.fragment_program) {
-            vector float inputs[4*4], outputs[2*4];
-
-            /* setup inputs */
-            eval_coeff(1, (float) x, (float) y, inputs);
-
-            /* Execute the current fragment program */
-            spu.fragment_program(inputs, outputs, spu.constants);
-
-            /* Copy outputs */
-            colors[0] = outputs[0*4+0];
-            colors[1] = outputs[0*4+1];
-            colors[2] = outputs[0*4+2];
-            colors[3] = outputs[0*4+3];
-
-            if (0 && spu.init.id==0 && y == 48) {
-               printf("colors[0] = %f %f %f %f\n",
-                      spu_extract(colors[0], 0),
-                      spu_extract(colors[0], 1),
-                      spu_extract(colors[0], 2),
-                      spu_extract(colors[0], 3));
-               printf("colors[1] = %f %f %f %f\n",
-                      spu_extract(colors[1], 0),
-                      spu_extract(colors[1], 1),
-                      spu_extract(colors[1], 2),
-                      spu_extract(colors[1], 3));
-            }
-
+         uint i;
+         for (i = 0; i < spu.vertex_info.num_attribs; i++) {
+            eval_coeff_soa(i+1, (float) x, (float) y, inputs + i * 4);
          }
 #endif
-      }
+         ASSERT(spu.fragment_program);
+         ASSERT(spu.fragment_ops);
 
+         /* Execute the current fragment program */
+         spu.fragment_program(inputs, outputs, spu.constants);
 
-      {
-         /* Convert fragment data from AoS to SoA format.
-          * I.e. (RGBA,RGBA,RGBA,RGBA) -> (RRRR,GGGG,BBBB,AAAA)
-          * This is temporary!
-          */
-         vector float soa_frag[4];
-         _transpose_matrix4x4(soa_frag, colors);
-
-         float4 fragZ;
-
-         fragZ.v = eval_z((float) x, (float) y);
-
-         /* Do all per-fragment/quad operations here, including:
-          *  alpha test, z test, stencil test, blend and framebuffer writing.
+         /* Execute per-fragment/quad operations, including:
+          * alpha test, z test, stencil test, blend and framebuffer writing.
           */
          spu.fragment_ops(ix, iy, &spu.ctile, &spu.ztile,
-                          fragZ.v,
-                          soa_frag[0], soa_frag[1],
-                          soa_frag[2], soa_frag[3],
+                          fragZ,
+                          outputs[0*4+0],
+                          outputs[0*4+1],
+                          outputs[0*4+2],
+                          outputs[0*4+3],
                           mask);
       }
-
    }
 }
 
index 701ee4c72f2c538f59de3f1db6a61e9169a62a14..ffc0c5e578e58418814ffc5f1ee2a77d66e9ac06 100644 (file)
 #include "tgsi/tgsi_exec.h"
 #include "tgsi/tgsi_parse.h"
 
-struct sp_exec_fragment_shader {
+struct sp_exec_fragment_shader
+{
    struct sp_fragment_shader base;
+   struct tgsi_token *machine_tokens;
 };
 
 
+/** cast wrapper */
+static INLINE struct sp_exec_fragment_shader *
+sp_exec_fragment_shader(struct sp_fragment_shader *base)
+{
+   return (struct sp_exec_fragment_shader *) base;
+}
+
 
 /**
  * Compute quad X,Y,Z,W for the four fragments in a quad.
@@ -86,10 +95,20 @@ exec_prepare( const struct sp_fragment_shader *base,
              struct tgsi_exec_machine *machine,
              struct tgsi_sampler *samplers )
 {
-   tgsi_exec_machine_bind_shader( machine,
-                                 base->shader.tokens,
-                                 PIPE_MAX_SAMPLERS,
-                                 samplers );
+   struct sp_exec_fragment_shader *spefs =
+      sp_exec_fragment_shader(base);
+
+   /*
+    * Bind tokens/shader to the interpreter's machine state.
+    * Avoid redundant binding.
+    */
+   if (spefs->machine_tokens != base->shader.tokens) {
+      tgsi_exec_machine_bind_shader( machine,
+                                     base->shader.tokens,
+                                     PIPE_MAX_SAMPLERS,
+                                     samplers );
+      spefs->machine_tokens = base->shader.tokens;
+   }
 }
 
 
index 3a486481f56d2ef4f55f1ab33d0196f4ffd8df33..3465f8a4d9f158733a3ea36b0182334edfe11476 100644 (file)
@@ -113,7 +113,118 @@ static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
 
 extern const struct dri_extension card_extensions[];
 
+static GLboolean
+intel_get_param(__DRIscreenPrivate *psp, int param, int *value)
+{
+   int ret;
+   struct drm_i915_getparam gp;
 
+   gp.param = param;
+   gp.value = value;
+
+   ret = drmCommandWriteRead(psp->fd, DRM_I915_GETPARAM, &gp, sizeof(gp));
+   if (ret) {
+      fprintf(stderr, "drm_i915_getparam: %d\n", ret);
+      return GL_FALSE;
+   }
+
+   return GL_TRUE;
+}
+
+static void
+intelSetTexOffset(__DRIcontext *pDRICtx, int texname,
+                 unsigned long long offset, int depth, uint pitch)
+{
+   abort();
+#if 0
+   struct intel_context *intel = (struct intel_context*)
+      ((__DRIcontextPrivate*)pDRICtx->private)->driverPrivate;
+   struct gl_texture_object *tObj = _mesa_lookup_texture(&intel->ctx, texname);
+   struct st_texture_object *stObj = st_texture_object(tObj);
+
+   if (!stObj)
+      return;
+
+   if (stObj->pt)
+      st->pipe->texture_release(intel->st->pipe, &stObj->pt);
+
+   stObj->imageOverride = GL_TRUE;
+   stObj->depthOverride = depth;
+   stObj->pitchOverride = pitch;
+
+   if (offset)
+      stObj->textureOffset = offset;
+#endif
+}
+
+
+#if 0
+static void
+intelHandleDrawableConfig(__DRIdrawablePrivate *dPriv,
+                         __DRIcontextPrivate *pcp,
+                         __DRIDrawableConfigEvent *event)
+{
+   (void) dPriv;
+   (void) pcp;
+   (void) event;
+}
+#endif
+
+#if 0
+static void
+intelHandleBufferAttach(__DRIdrawablePrivate *dPriv,
+                       __DRIcontextPrivate *pcp,
+                       __DRIBufferAttachEvent *ba)
+{
+   struct intel_screen *intelScreen = intel_screen(dPriv->driScreenPriv);
+
+   switch (ba->buffer.attachment) {
+   case DRI_DRAWABLE_BUFFER_FRONT_LEFT:
+      intelScreen->front.width = dPriv->w;
+      intelScreen->front.height = dPriv->h;
+      intelScreen->front.cpp = ba->buffer.cpp;
+      intelScreen->front.pitch = ba->buffer.pitch;
+      driGenBuffers(intelScreen->base.staticPool, "front", 1, &intelScreen->front.buffer, 0, 0, 0);
+      driBOSetReferenced(intelScreen->front.buffer, ba->buffer.handle);
+      break;
+
+   case DRI_DRAWABLE_BUFFER_BACK_LEFT:
+   case DRI_DRAWABLE_BUFFER_DEPTH:
+   case DRI_DRAWABLE_BUFFER_STENCIL:
+   case DRI_DRAWABLE_BUFFER_ACCUM:
+      /* anything ?? */
+      break;
+
+   default:
+      fprintf(stderr, "unhandled buffer attach event, attachment type %d\n",
+             ba->buffer.attachment);
+      return;
+   }
+}
+#endif
+
+static const __DRItexOffsetExtension intelTexOffsetExtension = {
+   { __DRI_TEX_OFFSET },
+   intelSetTexOffset,
+};
+
+#if 0
+static const __DRItexBufferExtension intelTexBufferExtension = {
+    { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION },
+   intelSetTexBuffer,
+};
+#endif
+
+static const __DRIextension *intelScreenExtensions[] = {
+    &driReadDrawableExtension,
+    &driCopySubBufferExtension.base,
+    &driSwapControlExtension.base,
+    &driFrameTrackingExtension.base,
+    &driMediaStreamCounterExtension.base,
+    &intelTexOffsetExtension.base,
+//    &intelTexBufferExtension.base,
+    NULL
+};
 
 
 static void
@@ -232,7 +343,8 @@ intelCreatePools(__DRIscreenPrivate * sPriv)
 
    intelScreen->havePools = GL_TRUE;
 
-   intelUpdateScreenRotation(sPriv, intelScreen->sarea);
+   if (intelScreen->sarea)
+       intelUpdateScreenRotation(sPriv, intelScreen->sarea);
 
    return GL_TRUE;
 }
@@ -253,10 +365,12 @@ intel_flush_frontbuffer( struct pipe_winsys *winsys,
                          struct pipe_surface *surf,
                          void *context_private)
 {
-   struct intel_context *intel = (struct intel_context *) context_private;
-   __DRIdrawablePrivate *dPriv = intel->driDrawable;
+   //struct intel_context *intel = (struct intel_context *) context_private;
+   //__DRIdrawablePrivate *dPriv = intel->driDrawable;
 
-   intelDisplaySurface(dPriv, surf, NULL);
+   //assert((int)"Doesn't work currently" & 0);
+
+   //intelDisplaySurface(dPriv, surf, NULL);
 }
 
 static boolean
@@ -265,11 +379,6 @@ intelInitDriver(__DRIscreenPrivate * sPriv)
    struct intel_screen *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");
@@ -286,28 +395,19 @@ intelInitDriver(__DRIscreenPrivate * sPriv)
                       __driConfigOptions, __driNConfigOptions);
 
    sPriv->private = (void *) intelScreen;
-
    intelScreen->sarea = (drmI830Sarea *) (((GLubyte *) sPriv->pSAREA) +
-                                         gDRIPriv->sarea_priv_offset);
-   intelScreen->deviceID = gDRIPriv->deviceID;
-   intelScreen->front.cpp = gDRIPriv->cpp;
-   intelScreen->drmMinor = sPriv->drmMinor;
+                                            gDRIPriv->sarea_priv_offset);
 
-   assert(gDRIPriv->bitsPerPixel == 16 ||
-         gDRIPriv->bitsPerPixel == 32);
+   intelScreen->deviceID = gDRIPriv->deviceID;
 
+   intelScreen->front.cpp = gDRIPriv->cpp;
+   intelScreen->drmMinor = sPriv->drm_version.minor;
    intelUpdateScreenRotation(sPriv, intelScreen->sarea);
 
    if (0)
       intelPrintDRIInfo(intelScreen, sPriv, gDRIPriv);
 
-   if (glx_enable_extension != NULL) {
-      (*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_SGI_make_current_read");
-   }
+   sPriv->extensions = intelScreenExtensions;
 
    intelScreen->base.base.flush_frontbuffer = intel_flush_frontbuffer;
    intelScreen->base.base.get_name = intel_get_name;
@@ -406,65 +506,19 @@ intelGetSwapInfo(__DRIdrawablePrivate * dPriv, __DRIswapInfo * sInfo)
    return 0;
 }
 
-
-static void
-intelSetTexOffset(__DRIcontext *pDRICtx, int texname,
-                 unsigned long long offset, int depth, uint pitch)
+static __DRIconfig **
+intelFillInModes(__DRIscreenPrivate *psp,
+                unsigned pixel_bits, unsigned depth_bits,
+                 unsigned stencil_bits, GLboolean have_back_buffer)
 {
-   abort();
-#if 0
-   struct intel_context *intel = (struct intel_context*)
-      ((__DRIcontextPrivate*)pDRICtx->private)->driverPrivate;
-   struct gl_texture_object *tObj = _mesa_lookup_texture(&intel->ctx, texname);
-   struct st_texture_object *stObj = st_texture_object(tObj);
-
-   if (!stObj)
-      return;
-
-   if (stObj->pt)
-      st->pipe->texture_release(intel->st->pipe, &stObj->pt);
-
-   stObj->imageOverride = GL_TRUE;
-   stObj->depthOverride = depth;
-   stObj->pitchOverride = pitch;
-
-   if (offset)
-      stObj->textureOffset = offset;
-#endif
-}
-
-
-static const struct __DriverAPIRec intelAPI = {
-   .InitDriver = intelInitDriver,
-   .DestroyScreen = intelDestroyScreen,
-   .CreateContext = intelCreateContext,
-   .DestroyContext = intelDestroyContext,
-   .CreateBuffer = intelCreateBuffer,
-   .DestroyBuffer = intelDestroyBuffer,
-   .SwapBuffers = intelSwapBuffers,
-   .MakeCurrent = intelMakeCurrent,
-   .UnbindContext = intelUnbindContext,
-   .GetSwapInfo = intelGetSwapInfo,
-   .GetMSC = driGetMSC32,
-   .WaitForMSC = driWaitForMSC32,
-   .WaitForSBC = NULL,
-   .SwapBuffersMSC = NULL,
-   .CopySubBuffer = intelCopySubBuffer,
-   .setTexOffset = intelSetTexOffset,
-};
-
-
-static __GLcontextModes *
-intelFillInModes(unsigned pixel_bits, unsigned depth_bits,
-                 unsigned stencil_bits, boolean have_back_buffer)
-{
-   __GLcontextModes *modes;
+   __DRIconfig **configs;
    __GLcontextModes *m;
    unsigned num_modes;
    unsigned depth_buffer_factor;
    unsigned back_buffer_factor;
    GLenum fb_format;
    GLenum fb_type;
+   int i;
 
    /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
     * support pageflipping at all.
@@ -508,100 +562,143 @@ intelFillInModes(unsigned pixel_bits, unsigned depth_bits,
       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, msaa_samples_array, 1, 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, msaa_samples_array, 1, GLX_DIRECT_COLOR)) {
-      fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
+   configs = driCreateConfigs(fb_format, fb_type,
+                             depth_bits_array, stencil_bits_array,
+                             depth_buffer_factor, back_buffer_modes,
+                             back_buffer_factor);
+   if (configs == NULL) {
+    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) {
+   for (i = 0; configs[i]; i++) {
+      m = &configs[i]->modes;
       if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
          m->visualRating = GLX_SLOW_CONFIG;
       }
    }
 
-   return modes;
+   return configs;
 }
 
-
 /**
- * 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.
+ * This is the driver specific part of the createNewScreen entry point.
+ * 
+ * \todo maybe fold this into intelInitDriver
  *
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
- *         failure.
+ * \return the __GLcontextModes supported by this driver
  */
-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)
+static const __DRIconfig **intelInitScreen(__DRIscreenPrivate *psp)
 {
-   __DRIscreenPrivate *psp;
-   static const __DRIversion ddx_expected = { 1, 7, 0 };
+#ifdef I915
+   static const __DRIversion ddx_expected = { 1, 5, 0 };
+#else
+   static const __DRIversion ddx_expected = { 1, 6, 0 };
+#endif
    static const __DRIversion dri_expected = { 4, 0, 0 };
-   static const __DRIversion drm_expected = { 1, 7, 0 };
-
-   dri_interface = interface;
+   static const __DRIversion drm_expected = { 1, 5, 0 };
+   I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv;
 
    if (!driCheckDriDdxDrmVersions2("i915",
-                                   dri_version, &dri_expected,
-                                   ddx_version, &ddx_expected,
-                                   drm_version, &drm_expected)) {
+                                   &psp->dri_version, &dri_expected,
+                                   &psp->ddx_version, &ddx_expected,
+                                   &psp->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, 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);
+   /* 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?
+    */
+   //intelInitExtensions(NULL, GL_TRUE);
+          
+   if (!intelInitDriver(psp))
+       return NULL;
+
+   psp->extensions = intelScreenExtensions;
+
+   return (const __DRIconfig **)
+       intelFillInModes(psp, dri_priv->cpp * 8,
+                       (dri_priv->cpp == 2) ? 16 : 24,
+                       (dri_priv->cpp == 2) ? 0  : 8, 1);
+}
+
+/**
+ * This is the driver specific part of the createNewScreen entry point.
+ * 
+ * \return the __GLcontextModes supported by this driver
+ */
+static const
+__DRIconfig **intelInitScreen2(__DRIscreenPrivate *psp)
+{
+   struct intel_screen *intelScreen;
+
+   /* 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?
+    */
+   //intelInitExtensions(NULL, GL_TRUE);
+
+   /* Allocate the private area */
+   intelScreen = CALLOC_STRUCT(intel_screen);
+   if (!intelScreen) {
+      fprintf(stderr, "\nERROR!  Allocating private area failed\n");
+      return GL_FALSE;
    }
+   /* parse information in __driConfigOptions */
+   driParseOptionInfo(&intelScreen->optionCache,
+                      __driConfigOptions, __driNConfigOptions);
+
+   psp->private = (void *) intelScreen;
 
-   return (void *) psp;
+   intelScreen->drmMinor = psp->drm_version.minor;
+
+   /* Determine chipset ID? */
+   if (!intel_get_param(psp, I915_PARAM_CHIPSET_ID,
+                       &intelScreen->deviceID))
+      return GL_FALSE;
+
+   psp->extensions = intelScreenExtensions;
+
+   intel_be_init_device(&intelScreen->base, psp->fd, intelScreen->deviceID);
+   intelScreen->base.base.flush_frontbuffer = intel_flush_frontbuffer;
+   intelScreen->base.base.get_name = intel_get_name;
+
+   return driConcatConfigs(intelFillInModes(psp, 16, 16, 0, 1),
+                          intelFillInModes(psp, 32, 24, 8, 1));
 }
 
+const struct __DriverAPIRec driDriverAPI = {
+   .InitScreen          = intelInitScreen,
+   .DestroyScreen       = intelDestroyScreen,
+   .CreateContext       = intelCreateContext,
+   .DestroyContext      = intelDestroyContext,
+   .CreateBuffer        = intelCreateBuffer,
+   .DestroyBuffer       = intelDestroyBuffer,
+   .SwapBuffers                 = intelSwapBuffers,
+   .MakeCurrent                 = intelMakeCurrent,
+   .UnbindContext       = intelUnbindContext,
+   .GetSwapInfo                 = intelGetSwapInfo,
+   .GetDrawableMSC      = driDrawableGetMSC32,
+   .WaitForMSC          = driWaitForMSC32,
+   .CopySubBuffer       = intelCopySubBuffer,
+
+   //.InitScreen2               = intelInitScreen2,
+   //.HandleDrawableConfig = intelHandleDrawableConfig,
+   //.HandleBufferAttach        = intelHandleBufferAttach,
+};
index 8a18bfd9a43f51d7ee729b7298e0b79f200225ce..34ad7eebe1c075203c9d226370795d940f1ec75e 100644 (file)
@@ -94,7 +94,6 @@ intelDisplaySurface(__DRIdrawablePrivate *dPriv,
       int i;
 
       ASSERT(surf->buffer);
-      ASSERT(surf->cpp == cpp);
 
       DBG(SWAP, "screen pitch %d  src surface pitch %d\n",
          pitch, surf->stride);
index b8c55db6d0aeab15bf766d559f94cfd814c00195..b025a90b675760ce1e44fd5ad8e51b1fbe52c93d 100644 (file)
@@ -10,14 +10,26 @@ SUBDIRS = $(GLU_DIRS)
 
 default: $(TOP)/configs/current
        @for dir in $(SUBDIRS) ; do \
-               (cd $$dir ; $(MAKE)) ; \
+               (cd $$dir && $(MAKE)) || exit 1 ; \
        done
 
-install:
-       $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
-       $(INSTALL) $(TOP)/$(LIB_DIR)/libGLU.* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
+# GLU pkg-config file
+pcedit = sed \
+       -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \
+       -e 's,@INSTALL_LIB_DIR@,$(INSTALL_LIB_DIR),' \
+       -e 's,@INSTALL_INC_DIR@,$(INSTALL_INC_DIR),' \
+       -e 's,@VERSION@,$(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY),'
+glu.pc: glu.pc.in
+       $(pcedit) $< > $@
+
+install: glu.pc
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
+       $(INSTALL) $(TOP)/$(LIB_DIR)/$(GLU_LIB_GLOB) $(DESTDIR)$(INSTALL_LIB_DIR)
+       $(INSTALL) -m 644 glu.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
 
 clean:
-       @for dir in $(SUBDIRS) ; do \
-               (cd $$dir ; $(MAKE) clean) ; \
+       -@for dir in $(SUBDIRS) ; do \
+               (cd $$dir && $(MAKE) clean) ; \
        done
+       -rm -f *.pc
diff --git a/src/glu/glu.pc.in b/src/glu/glu.pc.in
new file mode 100644 (file)
index 0000000..8606b9b
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@INSTALL_DIR@
+exec_prefix=${prefix}
+libdir=@INSTALL_LIB_DIR@
+includedir=@INSTALL_INC_DIR@
+
+Name: glu
+Description: Mesa OpenGL Utility library
+Requires: gl
+Version: @VERSION@
+Libs: -L${libdir} -lGLU
+Cflags: -I${includedir}
index 47f95ef024071756496fca20fca97b43a5d2614e..c468ce6210022b45516c4ac97f775ed5eb7a0cf5 100644 (file)
@@ -23,7 +23,7 @@ C_SOURCES = \
 
 OBJECTS = $(C_SOURCES:.c=.o)
 
-INCLUDES = -I. -I- -I$(TOP)/include
+INCLUDES = -I. -I$(TOP)/include
 
 ##### RULES #####
 
@@ -37,7 +37,7 @@ default:
                echo "$(GLU_LIB_NAME) not build under BeOS, but integrated into ${GL_LIB_NAME}." ; \
                exit 0 ; \
        else \
-               $(MAKE) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) ; \
+               $(MAKE) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) || exit 1 ; \
        fi
 
 $(TOP)/$(LIB_DIR):
@@ -45,7 +45,7 @@ $(TOP)/$(LIB_DIR):
 
 # Make the library:
 $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME): $(OBJECTS)
-       @ $(TOP)/bin/mklib -o $(GLU_LIB) -linker '$(CC)' \
+       @ $(MKLIB) -o $(GLU_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
                -major $(GLU_MAJOR) -minor $(GLU_MINOR) -patch $(GLU_TINY) \
                $(MKLIB_OPTIONS) -install $(TOP)/$(LIB_DIR) \
                $(GLU_LIB_DEPS) $(OBJECTS)
index 6fa03267e5394acab0cd0911106c910015f64986..2e79cdf0840477d24c87a886e9184cba34243803 100644 (file)
@@ -346,7 +346,8 @@ gluUnProject(GLdouble winx, GLdouble winy, GLdouble winz,
 
    /* calcul transformation inverse */
    matmul(A, proj, model);
-   invert_matrix(A, m);
+   if (!invert_matrix(A, m))
+      return GL_FALSE;
 
    /* d'ou les coordonnees objets */
    transform_point(out, m, in);
@@ -386,7 +387,8 @@ gluUnProject4(GLdouble winx, GLdouble winy, GLdouble winz, GLdouble clipw,
 
    /* calcul transformation inverse */
    matmul(A, projMatrix, modelMatrix);
-   invert_matrix(A, m);
+   if (!invert_matrix(A, m))
+      return GL_FALSE;
 
    /* d'ou les coordonnees objets */
    transform_point(out, m, in);
index 6fa03267e5394acab0cd0911106c910015f64986..2e79cdf0840477d24c87a886e9184cba34243803 100644 (file)
@@ -346,7 +346,8 @@ gluUnProject(GLdouble winx, GLdouble winy, GLdouble winz,
 
    /* calcul transformation inverse */
    matmul(A, proj, model);
-   invert_matrix(A, m);
+   if (!invert_matrix(A, m))
+      return GL_FALSE;
 
    /* d'ou les coordonnees objets */
    transform_point(out, m, in);
@@ -386,7 +387,8 @@ gluUnProject4(GLdouble winx, GLdouble winy, GLdouble winz, GLdouble clipw,
 
    /* calcul transformation inverse */
    matmul(A, projMatrix, modelMatrix);
-   invert_matrix(A, m);
+   if (!invert_matrix(A, m))
+      return GL_FALSE;
 
    /* d'ou les coordonnees objets */
    transform_point(out, m, in);
index cdd267a025cdb68e3b33bbf64d52436517495d7d..20c3bed0c9354ff4f9505c2f99f9f0b429f27e19 100644 (file)
@@ -128,7 +128,7 @@ default:
                echo "$(GLU_LIB_NAME) not build under BeOS, but integrated into ${GL_LIB_NAME}." ; \
                exit 0 ; \
        else \
-               $(MAKE) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) ; \
+               $(MAKE) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) || exit 1 ; \
        fi
 
 $(TOP)/$(LIB_DIR):
@@ -136,10 +136,10 @@ $(TOP)/$(LIB_DIR):
 
 # Make the library:
 $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME): $(OBJECTS)
-       $(TOP)/bin/mklib -o $(GLU_LIB) -linker '$(CXX)' \
+       $(MKLIB) -o $(GLU_LIB) -linker '$(CXX)' -ldflags '$(LDFLAGS)' \
                -major $(GLU_MAJOR) -minor $(GLU_MINOR) -patch $(GLU_TINY) \
                -cplusplus $(MKLIB_OPTIONS) -install $(TOP)/$(LIB_DIR) \
-               -exports glu.exports \
+               -exports glu.exports -id $(INSTALL_LIB_DIR)/lib$(GLU_LIB).$(GLU_MAJOR).dylib \
                $(GLU_LIB_DEPS) $(OBJECTS)
 
 
diff --git a/src/glu/sgi/Makefile.mgw b/src/glu/sgi/Makefile.mgw
new file mode 100644 (file)
index 0000000..d00d97a
--- /dev/null
@@ -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.
+
+# MinGW core makefile v1.4 for Mesa
+#
+#  Copyright (C) 2002 - Daniel Borca
+#  Email : dborca@users.sourceforge.net
+#  Web   : http://www.geocities.com/dborca
+
+# MinGW core-glu makefile updated for Mesa 7.0
+#
+#  Updated : by Heromyth, on 2007-7-21
+#  Email   : zxpmyth@yahoo.com.cn
+#  Bugs    : 1) All the default settings work fine. But the setting X86=1 can't work. 
+#            The others havn't been tested yet.
+#            2) The generated DLLs are *not* compatible with the ones built
+#            with the other compilers like VC8, especially for GLUT. 
+#            3) Although more tests are needed, it can be used individually!
+
+#
+#  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 = ../../..
+LIBDIR = $(TOP)/lib
+
+LIB_NAME = glu32
+DLL_EXT = .dll
+IMP_EXT = .a
+LIB_PRE = lib
+STRIP = -s
+
+AR = ar
+ARFLAGS = crus
+DLLTOOL = dlltool
+
+GLU_DLL = $(LIB_NAME)$(DLL_EXT)
+GLU_IMP = $(LIB_PRE)$(LIB_NAME)$(IMP_EXT)
+GLU_DEF = $(LIB_NAME).def
+
+LDLIBS = -L$(LIBDIR) -lopengl32
+LDFLAGS = $(STRIP) -shared -fPIC -Wl,--kill-at
+
+CFLAGS += -DBUILD_GLU32 -D_DLL
+
+
+CC = $(TOOLS_PREFIX)gcc
+CFLAGS += -DNDEBUG -DLIBRARYBUILD -I$(TOP)/include -Iinclude
+CXX = $(TOOLS_PREFIX)g++
+CXXFLAGS = $(CFLAGS) -Ilibnurbs/internals -Ilibnurbs/interface -Ilibnurbs/nurbtess
+
+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
+
+C_SOURCES = \
+       libutil/error.c \
+       libutil/glue.c \
+       libutil/mipmap.c \
+       libutil/project.c \
+       libutil/quad.c \
+       libutil/registry.c \
+       libtess/dict.c \
+       libtess/geom.c \
+       libtess/memalloc.c \
+       libtess/mesh.c \
+       libtess/normal.c \
+       libtess/priorityq.c \
+       libtess/render.c \
+       libtess/sweep.c \
+       libtess/tess.c \
+       libtess/tessmono.c
+
+CC_SOURCES = \
+       libnurbs/interface/bezierEval.cc \
+       libnurbs/interface/bezierPatch.cc \
+       libnurbs/interface/bezierPatchMesh.cc \
+       libnurbs/interface/glcurveval.cc \
+       libnurbs/interface/glinterface.cc \
+       libnurbs/interface/glrenderer.cc \
+       libnurbs/interface/glsurfeval.cc \
+       libnurbs/interface/incurveeval.cc \
+       libnurbs/interface/insurfeval.cc \
+       libnurbs/internals/arc.cc \
+       libnurbs/internals/arcsorter.cc \
+       libnurbs/internals/arctess.cc \
+       libnurbs/internals/backend.cc \
+       libnurbs/internals/basiccrveval.cc \
+       libnurbs/internals/basicsurfeval.cc \
+       libnurbs/internals/bin.cc \
+       libnurbs/internals/bufpool.cc \
+       libnurbs/internals/cachingeval.cc \
+       libnurbs/internals/ccw.cc \
+       libnurbs/internals/coveandtiler.cc \
+       libnurbs/internals/curve.cc \
+       libnurbs/internals/curvelist.cc \
+       libnurbs/internals/curvesub.cc \
+       libnurbs/internals/dataTransform.cc \
+       libnurbs/internals/displaylist.cc \
+       libnurbs/internals/flist.cc \
+       libnurbs/internals/flistsorter.cc \
+       libnurbs/internals/hull.cc \
+       libnurbs/internals/intersect.cc \
+       libnurbs/internals/knotvector.cc \
+       libnurbs/internals/mapdesc.cc \
+       libnurbs/internals/mapdescv.cc \
+       libnurbs/internals/maplist.cc \
+       libnurbs/internals/mesher.cc \
+       libnurbs/internals/monoTriangulationBackend.cc \
+       libnurbs/internals/monotonizer.cc \
+       libnurbs/internals/mycode.cc \
+       libnurbs/internals/nurbsinterfac.cc \
+       libnurbs/internals/nurbstess.cc \
+       libnurbs/internals/patch.cc \
+       libnurbs/internals/patchlist.cc \
+       libnurbs/internals/quilt.cc \
+       libnurbs/internals/reader.cc \
+       libnurbs/internals/renderhints.cc \
+       libnurbs/internals/slicer.cc \
+       libnurbs/internals/sorter.cc \
+       libnurbs/internals/splitarcs.cc \
+       libnurbs/internals/subdivider.cc \
+       libnurbs/internals/tobezier.cc \
+       libnurbs/internals/trimline.cc \
+       libnurbs/internals/trimregion.cc \
+       libnurbs/internals/trimvertpool.cc \
+       libnurbs/internals/uarray.cc \
+       libnurbs/internals/varray.cc \
+       libnurbs/nurbtess/directedLine.cc \
+       libnurbs/nurbtess/gridWrap.cc \
+       libnurbs/nurbtess/monoChain.cc \
+       libnurbs/nurbtess/monoPolyPart.cc \
+       libnurbs/nurbtess/monoTriangulation.cc \
+       libnurbs/nurbtess/partitionX.cc \
+       libnurbs/nurbtess/partitionY.cc \
+       libnurbs/nurbtess/polyDBG.cc \
+       libnurbs/nurbtess/polyUtil.cc \
+       libnurbs/nurbtess/primitiveStream.cc \
+       libnurbs/nurbtess/quicksort.cc \
+       libnurbs/nurbtess/rectBlock.cc \
+       libnurbs/nurbtess/sampleComp.cc \
+       libnurbs/nurbtess/sampleCompBot.cc \
+       libnurbs/nurbtess/sampleCompRight.cc \
+       libnurbs/nurbtess/sampleCompTop.cc \
+       libnurbs/nurbtess/sampleMonoPoly.cc \
+       libnurbs/nurbtess/sampledLine.cc \
+       libnurbs/nurbtess/searchTree.cc
+
+SOURCES = $(C_SOURCES) $(CC_SOURCES)
+
+OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
+
+.c.o:
+       $(CC) -o $@ $(CFLAGS) -c $<
+.cc.o:
+       $(CXX) -o $@ $(CXXFLAGS) -c $<
+
+
+all: $(LIBDIR) $(LIBDIR)/$(GLU_DLL) $(LIBDIR)/$(GLU_IMP)
+
+$(LIBDIR):
+       mkdir -p $(LIBDIR)
+
+$(LIBDIR)/$(GLU_DLL) $(LIBDIR)/$(GLU_IMP): $(OBJECTS)
+       $(CXX) $(LDFLAGS) -o $(LIBDIR)/$(GLU_DLL) $^ $(LDLIBS)
+       $(DLLTOOL) --as=as --dllname $(LIB_NAME) --output-def $(LIBDIR)/$(GLU_DEF) $^
+       $(DLLTOOL) --as=as -k --dllname $(LIB_NAME) --output-lib $(LIBDIR)/$(GLU_IMP) --def $(LIBDIR)/$(GLU_DEF)
+
+
+clean:
+       -$(call UNLINK,libutil/*.o)
+       -$(call UNLINK,libtess/*.o)
+       -$(call UNLINK,libnurbs/interface/*.o)
+       -$(call UNLINK,libnurbs/internals/*.o)
+       -$(call UNLINK,libnurbs/nurbtess/*.o)
diff --git a/src/glu/sgi/glu.exports.darwin b/src/glu/sgi/glu.exports.darwin
new file mode 100644 (file)
index 0000000..62d20ae
--- /dev/null
@@ -0,0 +1,59 @@
+_gluBeginCurve
+_gluBeginPolygon
+_gluBeginSurface
+_gluBeginTrim
+_gluBuild1DMipmapLevels
+_gluBuild1DMipmaps
+_gluBuild2DMipmapLevels
+_gluBuild2DMipmaps
+_gluBuild3DMipmapLevels
+_gluBuild3DMipmaps
+_gluCheckExtension
+_gluCylinder
+_gluDeleteNurbsRenderer
+_gluDeleteQuadric
+_gluDeleteTess
+_gluDisk
+_gluEndCurve
+_gluEndPolygon
+_gluEndSurface
+_gluEndTrim
+_gluErrorString
+_gluGetNurbsProperty
+_gluGetString
+_gluGetTessProperty
+_gluLoadSamplingMatrices
+_gluLookAt
+_gluNewNurbsRenderer
+_gluNewQuadric
+_gluNewTess
+_gluNextContour
+_gluNurbsCallback
+_gluNurbsCallbackData
+_gluNurbsCallbackDataEXT
+_gluNurbsCurve
+_gluNurbsProperty
+_gluNurbsSurface
+_gluOrtho2D
+_gluPartialDisk
+_gluPerspective
+_gluPickMatrix
+_gluProject
+_gluPwlCurve
+_gluQuadricCallback
+_gluQuadricDrawStyle
+_gluQuadricNormals
+_gluQuadricOrientation
+_gluQuadricTexture
+_gluScaleImage
+_gluSphere
+_gluTessBeginContour
+_gluTessBeginPolygon
+_gluTessCallback
+_gluTessEndContour
+_gluTessEndPolygon
+_gluTessNormal
+_gluTessProperty
+_gluTessVertex
+_gluUnProject
+_gluUnProject4
index fa1daed52e95ea768062e13cf888a3bd95dc4909..dbab3a1a2b7254eca1b3f248a531611c869320e8 100644 (file)
@@ -109,8 +109,11 @@ void bezierPatchDelete(bezierPatch *b)
 void bezierPatchDeleteList(bezierPatch *b)
 {
   bezierPatch *temp;
-  for(temp = b; temp != NULL; temp = temp->next)
-    bezierPatchDelete(temp);
+  while (b != NULL) {
+    temp = b;
+    b = b->next;
+    bezierPatchDelete(temp);    
+  }
 }
 
 bezierPatch* bezierPatchInsert(bezierPatch *list, bezierPatch *b)
index 78d8bece13e73974922a1f2b2212e7ff4eefcc05..9d0c82a91c051edc47ed23f43cac69d2cd7ac8ba 100644 (file)
@@ -1531,8 +1531,8 @@ void OpenGLSurfaceEvaluator::inEvalVStrip(int n_left, REAL u_left, REAL* left_va
     }
   //clean up 
   free(leftXYZ);
-  free(leftXYZ);
-  free(rightNormal);
+  free(rightXYZ);
+  free(leftNormal);
   free(rightNormal);
 }
 
index e9947ea39372b5a73ad58b301abdb4e4527b7efd..bf9ac302b6a0b9a954d7a67201291b7f9f37c472 100644 (file)
@@ -41,7 +41,7 @@
 #define __glumystdio_h_
 
 #ifdef STANDALONE
-inline void _glu_dprintf( char *, ... ) { }
+inline void _glu_dprintf( const char *, ... ) { }
 #endif
 
 #ifdef LIBRARYBUILD
@@ -49,12 +49,12 @@ inline void _glu_dprintf( char *, ... ) { }
 #include <stdio.h>
 #define _glu_dprintf printf
 #else
-inline void _glu_dprintf( char *, ... ) { }
+inline void _glu_dprintf( const char *, ... ) { }
 #endif
 #endif
 
 #ifdef GLBUILD
-inline void _glu_dprintf( char *, ... ) { }
+inline void _glu_dprintf( const char *, ... ) { }
 #endif
 
 #ifndef NULL
index 69c46b2d52a42100ccc427c13ce56edd4f419760..88dc3f516800e81fe289c6a66fae68fb34ca83ca 100644 (file)
@@ -244,7 +244,7 @@ Backend::evalVStrip(int n_left, REAL u_left, REAL* left_val,
  *-------------------------------------------------------------------------
  */
 void
-Backend::bgntmesh( char * )            
+Backend::bgntmesh( const char * )              
 {
 #ifndef NOWIREFRAME
 
index fb03859f2775ec01ab7e8ce70a1399bd0c2ed0b5..f7127e774633d3beebebc11d1892d1c3636a27e5 100644 (file)
@@ -63,7 +63,7 @@ public:
     void               surfbbox( long, REAL *, REAL * );
     void               surfgrid( REAL, REAL, long, REAL, REAL, long ); 
     void               surfmesh( long, long, long, long ); 
-    void               bgntmesh( char * );
+    void               bgntmesh( const char * );
     void               endtmesh( void );
     void               swaptmesh( void );
     void               tmeshvert( GridTrimVertex * );
index f60f7dc7b17bfc8956de5a0a3444bfa394d1b4a3..8cc847ab2259150f7ed7c20eebc2894a4141e8e9 100644 (file)
@@ -46,7 +46,7 @@
  * Pool - allocate a new pool of buffers
  *-----------------------------------------------------------------------------
  */
-Pool::Pool( int _buffersize, int initpoolsize, char *n )
+Pool::Pool( int _buffersize, int initpoolsize, const char *n )
 {
     if((unsigned)_buffersize < sizeof(Buffer))
         buffersize = sizeof(Buffer);
index 8eaafc4fd03f531616dfec9e768c184e2cba1010..5dd12d4ff25724b9e41e4827efe0a823e13ea7dd 100644 (file)
@@ -53,7 +53,7 @@ class Buffer {
 
 class Pool {
 public:
-                       Pool( int, int, char * );
+                       Pool( int, int, const char * );
                        ~Pool( void );
     inline void*       new_buffer( void );
     inline void                free_buffer( void * );
@@ -72,7 +72,7 @@ protected:
     int                        nextfree;               /* byte offset past next free buffer */
     int                        initsize;
     enum Magic { is_allocated = 0xf3a1, is_free = 0xf1a2 };
-    char               *name;                  /* name of the pool */
+    const char         *name;                  /* name of the pool */
     Magic              magic;                  /* marker for valid pool */
 };
 
index 610046674cd1adf3847aea92e950ada22c9f863d..9eb5cbace948e05a232aebac74ca54e37a9033b9 100644 (file)
@@ -126,7 +126,7 @@ int Knotvector::validate( void )
     return 0;
 }
 
-void Knotvector::show( char *msg )
+void Knotvector::show( const char *msg )
 {
 #ifndef NDEBUG
     _glu_dprintf( "%s\n", msg );
index 508fc4f3450f7765c9970516fb1065df0d6f6fc8..3f1d43c90c622e0165d15cde7d4afce3874c12ab 100644 (file)
@@ -47,7 +47,7 @@ struct Knotvector { /* a knot vector */
                        ~Knotvector( void );
     void               init( long, long, long, INREAL * );
     int                        validate( void );
-    void               show( char * );
+    void               show( const char * );
 
     long               order;          /* order of spline  */
     long               knotcount;      /* number of knots  */
index a5bd060fb0e1a79354538e78357632912f60b6b6..68dfd95f394fe3583cf74d5b02651801e74167dc 100644 (file)
@@ -675,7 +675,7 @@ NurbsTessellator::do_nurbserror( int msg )
 }
 
 int 
-NurbsTessellator::do_check_knots( Knotvector *knots, char *msg )
+NurbsTessellator::do_check_knots( Knotvector *knots, const char *msg )
 {
     int status = knots->validate();
     if( status ) {
index 3577088a9c23cec001263d0f33b4a391b6a19041..0e81facc0f36c9108514cbc4318f579b29892a88 100644 (file)
@@ -112,7 +112,7 @@ protected:
 private:
 
     void               resetObjects( void );
-    int                        do_check_knots( Knotvector *, char * );
+    int                        do_check_knots( Knotvector *, const char * );
     void               do_nurbserror( int );
     void               do_bgncurve( O_curve * );
     void               do_endcurve( void );
index 24d8b70f88c46152e26d5b397fe3f96a7aa92786..4e05f2a091ba34489c86d65ad4b8b0758d0794bc 100644 (file)
@@ -80,7 +80,7 @@ gluErrorString(GLenum errorCode)
     if ((errorCode >= GLU_NURBS_ERROR1) && (errorCode <= GLU_NURBS_ERROR37)) {
        return (const GLubyte *) __gluNURBSErrorString(errorCode - (GLU_NURBS_ERROR1 - 1));
     }
-    if ((errorCode >= GLU_TESS_ERROR1) && (errorCode <= GLU_TESS_ERROR8)) {
+    if ((errorCode >= GLU_TESS_ERROR1) && (errorCode <= GLU_TESS_ERROR6)) {
        return (const GLubyte *) __gluTessErrorString(errorCode - (GLU_TESS_ERROR1 - 1));
     }
     return (const GLubyte *) 0;
index 44f519a4e21a29da1afaf2986b6cd806bd1396f6..d65b7f689f52716fdb0d26e6131164e4199f12c6 100644 (file)
@@ -6627,7 +6627,7 @@ typedef void (GLAPIENTRY *TexImage3Dproc)( GLenum target, GLint level,
 
 static TexImage3Dproc pTexImage3D = 0;
 
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(__WIN32__)
 #  include <dlfcn.h>
 #  include <sys/types.h>
 #else
@@ -6642,7 +6642,7 @@ static void gluTexImage3D( GLenum target, GLint level,
                           const GLvoid *pixels )
 {
    if (!pTexImage3D) {
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__WIN32__)
       pTexImage3D = (TexImage3Dproc) wglGetProcAddress("glTexImage3D");
       if (!pTexImage3D)
         pTexImage3D = (TexImage3Dproc) wglGetProcAddress("glTexImage3DEXT");
index 5ba396ca1c012b7fc7fbbbcf64d63fd4184a1576..7d786036dfeaf1d7d47eaea837235a79c81bde9c 100644 (file)
@@ -166,74 +166,57 @@ static void __gluMultMatrixVecd(const GLdouble matrix[16], const GLdouble in[4],
 }
 
 /*
-** inverse = invert(src)
-** New, faster implementation by Shan Hao Bo, April 2006.
+** Invert 4x4 matrix.
+** Contributed by David Moore (See Mesa bug #6748)
 */
-static int __gluInvertMatrixd(const GLdouble src[16], GLdouble inverse[16])
+static int __gluInvertMatrixd(const GLdouble m[16], GLdouble invOut[16])
 {
-       int i, j, k;
-       double t;
-       GLdouble temp[4][4];
-        
-       for (i=0; i<4; i++) {
-               for (j=0; j<4; j++) {
-                   temp[i][j] = src[i*4+j];
-               }
-       }
-       __gluMakeIdentityd(inverse);
-       
-       for (i = 0; i < 4; i++) {
-               if (temp[i][i] == 0.0f) {
-                   /*
-                   ** Look for non-zero element in column
-                   */
-                   for (j = i + 1; j < 4; j++) {
-                               if (temp[j][i] != 0.0f) {
-                                   break;
-                               }
-                   }
-               
-                   if (j != 4) {
-                               /*
-                                ** Swap rows.
-                                */
-                               for (k = 0; k < 4; k++) {
-                                   t = temp[i][k];
-                                   temp[i][k] = temp[j][k];
-                                   temp[j][k] = t;
-                       
-                                   t = inverse[i*4+k];
-                                   inverse[i*4+k] = inverse[j*4+k];
-                                   inverse[j*4+k] = t;
-                               }
-                   }
-                   else {
-                               /*
-                               ** No non-zero pivot.  The matrix is singular, 
-which shouldn't
-                               ** happen.  This means the user gave us a bad 
-matrix.
-                               */
-                               return GL_FALSE;
-                   }
-               }
-               
-               t = 1.0f / temp[i][i];
-               for (k = 0; k < 4; k++) {
-                   temp[i][k] *= t;
-                   inverse[i*4+k] *= t;
-               }
-               for (j = 0; j < 4; j++) {
-                   if (j != i) {
-                               t = temp[j][i];
-                               for (k = 0; k < 4; k++) {
-                                           temp[j][k] -= temp[i][k]*t;
-                                           inverse[j*4+k] -= inverse[i*4+k]*t;
-                               }
-                   }
-               }
-       }
-       return GL_TRUE;
+    double inv[16], det;
+    int i;
+
+    inv[0] =   m[5]*m[10]*m[15] - m[5]*m[11]*m[14] - m[9]*m[6]*m[15]
+             + m[9]*m[7]*m[14] + m[13]*m[6]*m[11] - m[13]*m[7]*m[10];
+    inv[4] =  -m[4]*m[10]*m[15] + m[4]*m[11]*m[14] + m[8]*m[6]*m[15]
+             - m[8]*m[7]*m[14] - m[12]*m[6]*m[11] + m[12]*m[7]*m[10];
+    inv[8] =   m[4]*m[9]*m[15] - m[4]*m[11]*m[13] - m[8]*m[5]*m[15]
+             + m[8]*m[7]*m[13] + m[12]*m[5]*m[11] - m[12]*m[7]*m[9];
+    inv[12] = -m[4]*m[9]*m[14] + m[4]*m[10]*m[13] + m[8]*m[5]*m[14]
+             - m[8]*m[6]*m[13] - m[12]*m[5]*m[10] + m[12]*m[6]*m[9];
+    inv[1] =  -m[1]*m[10]*m[15] + m[1]*m[11]*m[14] + m[9]*m[2]*m[15]
+             - m[9]*m[3]*m[14] - m[13]*m[2]*m[11] + m[13]*m[3]*m[10];
+    inv[5] =   m[0]*m[10]*m[15] - m[0]*m[11]*m[14] - m[8]*m[2]*m[15]
+             + m[8]*m[3]*m[14] + m[12]*m[2]*m[11] - m[12]*m[3]*m[10];
+    inv[9] =  -m[0]*m[9]*m[15] + m[0]*m[11]*m[13] + m[8]*m[1]*m[15]
+             - m[8]*m[3]*m[13] - m[12]*m[1]*m[11] + m[12]*m[3]*m[9];
+    inv[13] =  m[0]*m[9]*m[14] - m[0]*m[10]*m[13] - m[8]*m[1]*m[14]
+             + m[8]*m[2]*m[13] + m[12]*m[1]*m[10] - m[12]*m[2]*m[9];
+    inv[2] =   m[1]*m[6]*m[15] - m[1]*m[7]*m[14] - m[5]*m[2]*m[15]
+             + m[5]*m[3]*m[14] + m[13]*m[2]*m[7] - m[13]*m[3]*m[6];
+    inv[6] =  -m[0]*m[6]*m[15] + m[0]*m[7]*m[14] + m[4]*m[2]*m[15]
+             - m[4]*m[3]*m[14] - m[12]*m[2]*m[7] + m[12]*m[3]*m[6];
+    inv[10] =  m[0]*m[5]*m[15] - m[0]*m[7]*m[13] - m[4]*m[1]*m[15]
+             + m[4]*m[3]*m[13] + m[12]*m[1]*m[7] - m[12]*m[3]*m[5];
+    inv[14] = -m[0]*m[5]*m[14] + m[0]*m[6]*m[13] + m[4]*m[1]*m[14]
+             - m[4]*m[2]*m[13] - m[12]*m[1]*m[6] + m[12]*m[2]*m[5];
+    inv[3] =  -m[1]*m[6]*m[11] + m[1]*m[7]*m[10] + m[5]*m[2]*m[11]
+             - m[5]*m[3]*m[10] - m[9]*m[2]*m[7] + m[9]*m[3]*m[6];
+    inv[7] =   m[0]*m[6]*m[11] - m[0]*m[7]*m[10] - m[4]*m[2]*m[11]
+             + m[4]*m[3]*m[10] + m[8]*m[2]*m[7] - m[8]*m[3]*m[6];
+    inv[11] = -m[0]*m[5]*m[11] + m[0]*m[7]*m[9] + m[4]*m[1]*m[11]
+             - m[4]*m[3]*m[9] - m[8]*m[1]*m[7] + m[8]*m[3]*m[5];
+    inv[15] =  m[0]*m[5]*m[10] - m[0]*m[6]*m[9] - m[4]*m[1]*m[10]
+             + m[4]*m[2]*m[9] + m[8]*m[1]*m[6] - m[8]*m[2]*m[5];
+
+    det = m[0]*inv[0] + m[1]*inv[4] + m[2]*inv[8] + m[3]*inv[12];
+    if (det == 0)
+        return GL_FALSE;
+
+    det = 1.0 / det;
+
+    for (i = 0; i < 16; i++)
+        invOut[i] = inv[i] * det;
+
+    return GL_TRUE;
 }
 
 static void __gluMultMatricesd(const GLdouble a[16], const GLdouble b[16],
index e604539c82fa82d38b8e9f7a26574109ab50cbc4..1ae7442c80a2bd32a8389ba837ebe3ca7f7a0d0a 100644 (file)
@@ -713,8 +713,8 @@ gluSphere(GLUquadric *qobj, GLdouble radius, GLint slices, GLint stacks)
     GLfloat cosCache3b[CACHE_SIZE];
     GLfloat angle;
     GLfloat zLow, zHigh;
-    GLfloat sintemp1, sintemp2, sintemp3 = 0.0, sintemp4 = 0.0;
-    GLfloat costemp1, costemp2 = 0.0, costemp3 = 0.0, costemp4 = 0.0;
+    GLfloat sintemp1 = 0.0, sintemp2 = 0.0, sintemp3 = 0.0, sintemp4 = 0.0;
+    GLfloat costemp1 = 0.0, costemp2 = 0.0, costemp3 = 0.0, costemp4 = 0.0;
     GLboolean needCache2, needCache3;
     GLint start, finish;
 
index a7ba512cb11c57d8e07de44519a0cbccb50cd791..a9f8684c9bd95eaa59a72b5aa5eb73c85434adbf 100644 (file)
@@ -83,9 +83,10 @@ $(TOP)/$(LIB_DIR):
 
 # Make the library
 $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS)
-       @$(TOP)/bin/mklib -o $(GLUT_LIB) -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \
-               -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) $(GLUT_LIB_DEPS) \
-               $(OBJECTS)
+       @$(MKLIB) -o $(GLUT_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
+               -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \
+               -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \
+               $(GLUT_LIB_DEPS) $(OBJECTS)
 
 clean:
        -rm -f *.o
index e881b8aacdda6bc27b15a16962f5d48e3bd40529..bf93d63e305a99c83cfe97859d00b39ca2d7222d 100644 (file)
@@ -61,7 +61,7 @@ default: depend $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
 
 # Make the library
 $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS)
-       $(TOP)/bin/mklib -o $(GLUT_LIB) -linker '$(CC)' \
+       $(MKLIB) -o $(GLUT_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
                -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \
                $(GLUT_LIB_DEPS) -install $(TOP)/$(LIB_DIR) \
                $(MKLIB_OPTIONS) $(OBJECTS)
@@ -81,7 +81,7 @@ tags:
 
 # Remove .o and backup files
 clean: depend
-       -rm -f depend
+       -rm -f depend depend.bak
        -rm -f *.o *~ *.o *~ *.so libglut.so.3.7
 
 include depend
index 4f23441167ae24626d75481bfc055cc08f3ec780..7c9768aac0adcab7fced6e00f7765f8480b5a55f 100644 (file)
@@ -278,7 +278,7 @@ __glutGetTimeout( int *ret_msec )
      gettimeofday( &now, NULL );
      
      *ret_msec = (time->tv_sec  - now.tv_sec) * 1000 +
-                 (time->tv_usec - now.tv_usec + 500) / 1000;
+                 (time->tv_usec - now.tv_usec + 999) / 1000;
                  
      return GL_TRUE;
 }
index 47311c9342bcd4dabb00f21ba40cafa9b56492c6..55c4b5ce2806d8436893e1e4ab64566ce4ae8164 100644 (file)
@@ -62,6 +62,9 @@ typedef struct __GlutWindow_s {
      IDirectFBSurface      *surface;
      IDirectFBGL           *gl;
 
+     /* display mode */
+     GLenum                 mode;
+
      /* cursor position in fullscreen mode */
      int                    cx;
      int                    cy;
index c8174d795e76489b1ef1e4b0fba6cd370047f45e..62cf8bb33e0dc84c2a4d21e35f31f4439b49f49c 100644 (file)
@@ -66,6 +66,9 @@ __glutCreateWindow( GLboolean fullscreen )
                     case 8:
                          config.pixelformat = DSPF_RGB332;
                          break;
+                    case 12:
+                         config.pixelformat = DSPF_ARGB4444;
+                         break;
                     case 15:
                          config.pixelformat = DSPF_ARGB1555;
                          break;
@@ -109,7 +112,7 @@ __glutCreateWindow( GLboolean fullscreen )
           if (joystick)
                joystick->AttachEventBuffer( joystick, events );
                
-          new->visible = GL_TRUE;        
+          new->visible = GL_TRUE;    
      }
      else {
           DFBWindowDescription dsc;
@@ -160,11 +163,12 @@ __glutCreateWindow( GLboolean fullscreen )
                                                   DWET_BUTTONDOWN | DWET_BUTTONUP |
                                                   DWET_ENTER      | DWET_LEAVE    |
                                                   DWET_MOTION     | DWET_SIZE );
-                                                  
           
           new->req.flags |= WINDOW_REQUEST_SHOW;
      }
 
+     new->mode = g_display_mode;
+     
      new->reshape    = GL_TRUE;
      new->visibility = GL_TRUE;
      new->redisplay  = GL_TRUE;
@@ -220,7 +224,8 @@ __glutHandleWindows( void )
      __GlutWindow *cur = g_stack;
      
      while (cur) {
-          __GlutWindow *next = cur->next;
+          __GlutWindow *next      = cur->next;
+          GLboolean     displayed = GL_FALSE;
           
           if (cur->window && cur->req.flags) {
                if (cur == g_current)
@@ -291,18 +296,29 @@ __glutHandleWindows( void )
                cur->surface->GetSize( cur->surface, &w, &h ); 
                __glutSetWindow( cur );
                reshape_func( w, h );
+               displayed = GL_TRUE;
           }
           
           if (cur->visibility && visibility_func) {
                g_idle = GL_FALSE;
                __glutSetWindow( cur );
                visibility_func( cur->visible ? GLUT_VISIBLE : GLUT_NOT_VISIBLE );
+               displayed = GL_TRUE;
           }
 
           if (cur->redisplay && display_func) {
                g_idle = GL_FALSE;
                __glutSetWindow( cur );
                display_func();
+               displayed = GL_TRUE;
+          }
+          
+          if (displayed && cur->window && cur->visible) {
+               if (!(cur->mode & GLUT_DOUBLE)) {
+                    cur->gl->Unlock( cur->gl );
+                    cur->surface->Flip( cur->surface, NULL, 0 );
+                    cur->gl->Lock( cur->gl );
+               }
           }
                
           cur->reshape    = GL_FALSE;
index b32b4141e8d306eb67e572e4d60af04e34539cd8..199d8c390a6398f3276cd099d1b5c766b4130e96 100644 (file)
@@ -63,16 +63,16 @@ default: depend $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
 
 # Make the library
 $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS)
-       $(TOP)/bin/mklib -o $(GLUT_LIB) -linker '$(CC)' \
+       $(MKLIB) -o $(GLUT_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
                -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \
                $(GLUT_LIB_DEPS) -install $(TOP)/$(LIB_DIR) \
                $(MKLIB_OPTIONS) $(OBJECTS)
 
 install:
-       $(INSTALL) -d $(INSTALL_DIR)/include/GL
-       $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
-       $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(INSTALL_DIR)/include/GL
-       $(INSTALL) $(TOP)/$(LIB_DIR)/libglut* $(INSTALL_DIR)/$(LIB_DIR)
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/GL
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
+       $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(DESTDIR)$(INSTALL_INC_DIR)/GL
+       $(INSTALL) $(TOP)/$(LIB_DIR)/libglut* $(DESTDIR)$(INSTALL_LIB_DIR)
 
 # Run 'make -f Makefile.solo dep' to update the dependencies if you change
 # what's included by any source file.
@@ -88,7 +88,7 @@ tags:
 
 # Remove .o and backup files
 clean: depend
-       -rm -f depend
+       -rm -f depend depend.bak
        -rm -f *.o *~ *.o *~ *.so libglut.so.3.7
 
 include depend
index 748c83c2286186f2b297665222929791269dc481..c23dfcac105b8f601ee88c48117231c4fd2ae1e4 100644 (file)
@@ -32,7 +32,7 @@ default: $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
 
 # Make the library
 $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS)
-       $(TOP)/bin/mklib -o $(GLUT_LIB) -linker '$(CC)' \
+       $(MKLIB) -o $(GLUT_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
                -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) \
                -patch $(GLUT_TINY) $(MKLIB_OPTIONS) -install $(TOP)/$(LIB_DIR) \
                $(GLUT_LIB_DEPS) $(OBJECTS)
index 910c6fa28a4adcf926d1c2357b2aa74d6ee8556e..b61d5b04789ddab13e905ca78cc4b9387690327a 100644 (file)
@@ -36,6 +36,7 @@ SOURCES = \
        glut_dstr.c \
        glut_event.c \
        glut_ext.c \
+       glut_fcb.c \
        glut_fullscrn.c \
        glut_gamemode.c \
        glut_get.c \
@@ -90,25 +91,38 @@ default: $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
 
 # Make the library
 $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS)
-       $(TOP)/bin/mklib -o $(GLUT_LIB) -linker '$(CC)' \
+       $(MKLIB) -o $(GLUT_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
                -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \
                $(MKLIB_OPTIONS) -install $(TOP)/$(LIB_DIR) \
+               -id $(INSTALL_LIB_DIR)/lib$(GLUT_LIB).$(GLUT_MAJOR).dylib \
                $(GLUT_LIB_DEPS) $(OBJECTS)
 
 
-install:
-       $(INSTALL) -d $(INSTALL_DIR)/include/GL
-       $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
-       $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(INSTALL_DIR)/include/GL
-       $(INSTALL) $(TOP)/$(LIB_DIR)/libglut* $(INSTALL_DIR)/$(LIB_DIR)
+# glut pkgconfig file
+pcedit = sed \
+       -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \
+       -e 's,@INSTALL_LIB_DIR@,$(INSTALL_LIB_DIR),' \
+       -e 's,@INSTALL_INC_DIR@,$(INSTALL_INC_DIR),' \
+       -e 's,@VERSION@,$(GLUT_MAJOR).$(GLUT_MINOR).$(GLUT_TINY),'
+glut.pc: glut.pc.in
+       $(pcedit) $< > $@
+
+install: glut.pc
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/GL
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
+       $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(DESTDIR)$(INSTALL_INC_DIR)/GL
+       $(INSTALL) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_GLOB) $(DESTDIR)$(INSTALL_LIB_DIR)
+       $(INSTALL) -m 644 glut.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
 
 
 clean:
        -rm -f *.o *~
        -rm -f *.lo
        -rm -f *.la
+       -rm -f *.pc
        -rm -rf .libs
-       -rm -rf depend depend.bak
+       -rm -f depend depend.bak
 
 
 depend: $(SOURCES)
@@ -116,6 +130,6 @@ depend: $(SOURCES)
        @ rm -f depend
        @ touch depend
        @ $(MKDEP) $(MKDEP_OPTIONS) -I$(TOP)/include $(SOURCES) \
-               > /dev/null 
+               $(X11_INCLUDES) > /dev/null 
 
 include depend
diff --git a/src/glut/glx/Makefile.mgw b/src/glut/glx/Makefile.mgw
new file mode 100644 (file)
index 0000000..5e1fde0
--- /dev/null
@@ -0,0 +1,191 @@
+# 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
+
+# MinGW core-glut makefile updated for Mesa 7.0
+#
+#  Updated : by Heromyth, on 2007-7-21
+#  Email   : zxpmyth@yahoo.com.cn
+#  Bugs    : 1) All the default settings work fine. But the setting X86=1 can't work. 
+#            The others havn't been tested yet.
+#            2) The generated DLLs are *not* compatible with the ones built
+#            with the other compilers like VC8, especially for GLUT. 
+#            3) Although more tests are needed, it can be used individually!
+
+
+#
+#  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 = ../../..
+
+LIBDIR = $(TOP)/lib
+
+LIB_NAME = glut32
+
+DLL_EXT = .dll
+IMP_EXT = .a
+LIB_PRE = lib
+STRIP = -s
+
+AR = ar
+ARFLAGS = crus
+DLLTOOL = dlltool
+
+GLUT_DLL = $(LIB_NAME)$(DLL_EXT)
+GLUT_IMP = $(LIB_PRE)$(LIB_NAME)$(IMP_EXT)
+GLUT_DEF = $(LIB_NAME).def
+
+LDLIBS = -L$(LIBDIR) -lwinmm -lgdi32 -luser32 -lopengl32 -lglu32 
+LDFLAGS = $(STRIP) -shared -fPIC -Wl,--kill-at
+
+CFLAGS += -DBUILD_GLUT32 -DGLUT_BUILDING_LIB -DMESA -D_DLL
+CFLAGS += -DNDEBUG -DLIBRARYBUILD -I$(TOP)/include 
+
+CC = $(TOOLS_PREFIX)gcc
+CXX = $(TOOLS_PREFIX)g++
+CXXFLAGS = $(CFLAGS)
+
+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
+
+HDRS = glutint.h glutstroke.h glutbitmap.h glutwin32.h stroke.h win32_glx.h win32_x11.h
+
+SRCS = \
+       glut_bitmap.c \
+       glut_bwidth.c \
+       glut_cindex.c \
+       glut_cmap.c \
+       glut_cursor.c \
+       glut_dials.c \
+       glut_dstr.c \
+       glut_event.c \
+       glut_ext.c \
+       glut_fcb.c \
+       glut_fullscrn.c \
+       glut_gamemode.c \
+       glut_get.c \
+       glut_init.c \
+       glut_input.c \
+       glut_joy.c \
+       glut_key.c \
+       glut_keyctrl.c \
+       glut_keyup.c \
+       glut_mesa.c \
+       glut_modifier.c \
+       glut_overlay.c \
+       glut_shapes.c \
+       glut_space.c \
+       glut_stroke.c \
+       glut_swap.c \
+       glut_swidth.c \
+       glut_tablet.c \
+       glut_teapot.c \
+       glut_util.c \
+       glut_vidresize.c \
+       glut_warp.c \
+       glut_win.c \
+       glut_winmisc.c \
+       win32_glx.c \
+       win32_menu.c \
+       win32_util.c \
+       win32_winproc.c \
+       win32_x11.c
+       
+
+SRCSSEMIGENS = \
+       glut_8x13.c \
+       glut_9x15.c \
+       glut_hel10.c \
+       glut_hel12.c \
+       glut_hel18.c \
+       glut_mroman.c \
+       glut_roman.c \
+       glut_tr10.c \
+       glut_tr24.c
+
+
+
+SOURCES = $(SRCS) $(SRCSSEMIGENS)
+
+OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
+
+.c.o:
+       $(CC) -o $@ $(CFLAGS) -c $<
+.cc.o:
+       $(CXX) -o $@ $(CXXFLAGS) -c $<
+
+
+all: $(LIBDIR) $(LIBDIR)/$(GLUT_DLL) $(LIBDIR)/$(GLUT_IMP)
+
+$(LIBDIR):
+       mkdir -p $(LIBDIR)
+
+$(LIBDIR)/$(GLUT_DLL) $(LIBDIR)/$(GLUT_IMP): $(OBJECTS)
+       $(CXX) $(LDFLAGS) -o $(LIBDIR)/$(GLUT_DLL) $^ $(LDLIBS)
+       $(DLLTOOL) --as=as --dllname $(LIB_NAME) --output-def $(LIBDIR)/$(GLUT_DEF) $^
+       $(DLLTOOL) --as=as -k --dllname $(LIB_NAME) --output-lib $(LIBDIR)/$(GLUT_IMP) --def $(LIBDIR)/$(GLUT_DEF) 
+
+clean:
+       -$(call UNLINK,*.o)
\ No newline at end of file
diff --git a/src/glut/glx/glut.pc.in b/src/glut/glx/glut.pc.in
new file mode 100644 (file)
index 0000000..e8638fe
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@INSTALL_DIR@
+exec_prefix=${prefix}
+libdir=@INSTALL_LIB_DIR@
+includedir=@INSTALL_INC_DIR@
+
+Name: glut
+Description: Mesa OpenGL Utility Toolkit library
+Requires: gl glu
+Version: @VERSION@
+Libs: -L${libdir} -lglut
+Cflags: -I${includedir}
index ec9386f3e504fb6cc9f5e15dedb39034784767cb..2513af45394c4801e9cf4771cd54a7da7009abb5 100644 (file)
@@ -291,6 +291,7 @@ loadVisuals(int *nitems_return)
   fbmodes = (FrameBufferMode *) malloc(n * sizeof(FrameBufferMode));
   if (fbmodes == NULL) {
     *nitems_return = -1;
+    free(vlist);
     return NULL;
   }
   for (i = 0; i < n; i++) {
index 443f9a85740c92ad2e7775aee76999520ead6bb5..cf34e05ca9858dfc2b764b1bcbf3b572f2bfd569 100644 (file)
@@ -24,7 +24,7 @@
 # ifdef __sgi
 #  include <bstring.h>    /* prototype for bzero used by FD_ZERO */
 # endif
-# if (defined(SVR4) || defined(CRAY) || defined(AIXV3)) && !defined(FD_SETSIZE)
+# if (defined(__FreeBSD__) || defined(SVR4) || defined(CRAY) || defined(AIXV3)) && !defined(FD_SETSIZE)
 #  include <sys/select.h> /* select system call interface */
 #  ifdef luna
 #   include <sysent.h>
@@ -172,10 +172,14 @@ handleTimeouts(void)
   GETTIMEOFDAY(&now);
   while (IS_AT_OR_AFTER(__glutTimerList->timeout, now)) {
     timer = __glutTimerList;
-    __glutTimerList = timer->next;
+    /* call the timer function */
     timer->func(timer->value);
+    /* remove from the linked list */
+    __glutTimerList = timer->next;
+    /* put this timer on the "free" list */
     timer->next = freeTimerList;
     freeTimerList = timer;
+
     if (!__glutTimerList)
       break;
   }
diff --git a/src/glut/glx/glut_fbc.c b/src/glut/glx/glut_fbc.c
deleted file mode 100644 (file)
index e93188b..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-
-/* Copyright (c) Mark J. Kilgard, 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. */
-
-/* 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 "glutint.h"
-
-/* FCB stands for Fortran CallBack. */
-
-/* There is only one idleFunc, menuStateFunc, and menuStatusFunc, so they
-   can be saved in the wrappers for Fortran rather than the C structures. */
-
-/* Set a Fortran callback function. */
-
-void APIENTRY
-__glutSetFCB(int which, void *func)
-{
-#ifdef SUPPORT_FORTRAN
-  switch (which) {
-  case GLUT_FCB_DISPLAY:
-    __glutCurrentWindow->fdisplay = (GLUTdisplayFCB) func;
-    break;
-  case GLUT_FCB_RESHAPE:
-    __glutCurrentWindow->freshape = (GLUTreshapeFCB) func;
-    break;
-  case GLUT_FCB_MOUSE:
-    __glutCurrentWindow->fmouse = (GLUTmouseFCB) func;
-    break;
-  case GLUT_FCB_MOTION:
-    __glutCurrentWindow->fmotion = (GLUTmotionFCB) func;
-    break;
-  case GLUT_FCB_PASSIVE:
-    __glutCurrentWindow->fpassive = (GLUTpassiveFCB) func;
-    break;
-  case GLUT_FCB_ENTRY:
-    __glutCurrentWindow->fentry = (GLUTentryFCB) func;
-    break;
-  case GLUT_FCB_KEYBOARD:
-    __glutCurrentWindow->fkeyboard = (GLUTkeyboardFCB) func;
-    break;
-  case GLUT_FCB_KEYBOARD_UP:
-    __glutCurrentWindow->fkeyboardUp = (GLUTkeyboardFCB) func;
-    break;
-  case GLUT_FCB_WINDOW_STATUS:
-    __glutCurrentWindow->fwindowStatus = (GLUTwindowStatusFCB) func;
-    break;
-  case GLUT_FCB_VISIBILITY:
-    __glutCurrentWindow->fvisibility = (GLUTvisibilityFCB) func;
-    break;
-  case GLUT_FCB_SPECIAL:
-    __glutCurrentWindow->fspecial = (GLUTspecialFCB) func;
-    break;
-  case GLUT_FCB_SPECIAL_UP:
-    __glutCurrentWindow->fspecialUp = (GLUTspecialFCB) func;
-    break;
-  case GLUT_FCB_BUTTON_BOX:
-    __glutCurrentWindow->fbuttonBox = (GLUTbuttonBoxFCB) func;
-    break;
-  case GLUT_FCB_DIALS:
-    __glutCurrentWindow->fdials = (GLUTdialsFCB) func;
-    break;
-  case GLUT_FCB_SPACE_MOTION:
-    __glutCurrentWindow->fspaceMotion = (GLUTspaceMotionFCB) func;
-    break;
-  case GLUT_FCB_SPACE_ROTATE:
-    __glutCurrentWindow->fspaceRotate = (GLUTspaceRotateFCB) func;
-    break;
-  case GLUT_FCB_SPACE_BUTTON:
-    __glutCurrentWindow->fspaceButton = (GLUTspaceButtonFCB) func;
-    break;
-  case GLUT_FCB_TABLET_MOTION:
-    __glutCurrentWindow->ftabletMotion = (GLUTtabletMotionFCB) func;
-    break;
-  case GLUT_FCB_TABLET_BUTTON:
-    __glutCurrentWindow->ftabletButton = (GLUTtabletButtonFCB) func;
-    break;
-#ifdef _WIN32
-  case GLUT_FCB_JOYSTICK:
-    __glutCurrentWindow->fjoystick = (GLUTjoystickFCB) func;
-    break;
-#endif
-  case GLUT_FCB_OVERLAY_DISPLAY:
-    __glutCurrentWindow->overlay->fdisplay = (GLUTdisplayFCB) func;
-    break;
-  case GLUT_FCB_SELECT:
-    __glutCurrentMenu->fselect = (GLUTselectFCB) func;
-    break;
-  case GLUT_FCB_TIMER:
-    __glutNewTimer->ffunc = (GLUTtimerFCB) func;
-    break;
-  }
-#endif
-}
-
-/* Get a Fortran callback function. */
-
-void* APIENTRY
-__glutGetFCB(int which)
-{
-#ifdef SUPPORT_FORTRAN
-  switch (which) {
-  case GLUT_FCB_DISPLAY:
-    return (void *) __glutCurrentWindow->fdisplay;
-  case GLUT_FCB_RESHAPE:
-    return (void *) __glutCurrentWindow->freshape;
-  case GLUT_FCB_MOUSE:
-    return (void *) __glutCurrentWindow->fmouse;
-  case GLUT_FCB_MOTION:
-    return (void *) __glutCurrentWindow->fmotion;
-  case GLUT_FCB_PASSIVE:
-    return (void *) __glutCurrentWindow->fpassive;
-  case GLUT_FCB_ENTRY:
-    return (void *) __glutCurrentWindow->fentry;
-  case GLUT_FCB_KEYBOARD:
-    return (void *) __glutCurrentWindow->fkeyboard;
-  case GLUT_FCB_KEYBOARD_UP:
-    return (void *) __glutCurrentWindow->fkeyboardUp;
-  case GLUT_FCB_WINDOW_STATUS:
-    return (void *) __glutCurrentWindow->fwindowStatus;
-  case GLUT_FCB_VISIBILITY:
-    return (void *) __glutCurrentWindow->fvisibility;
-  case GLUT_FCB_SPECIAL:
-    return (void *) __glutCurrentWindow->fspecial;
-  case GLUT_FCB_SPECIAL_UP:
-    return (void *) __glutCurrentWindow->fspecialUp;
-  case GLUT_FCB_BUTTON_BOX:
-    return (void *) __glutCurrentWindow->fbuttonBox;
-  case GLUT_FCB_DIALS:
-    return (void *) __glutCurrentWindow->fdials;
-  case GLUT_FCB_SPACE_MOTION:
-    return (void *) __glutCurrentWindow->fspaceMotion;
-  case GLUT_FCB_SPACE_ROTATE:
-    return (void *) __glutCurrentWindow->fspaceRotate;
-  case GLUT_FCB_SPACE_BUTTON:
-    return (void *) __glutCurrentWindow->fspaceButton;
-  case GLUT_FCB_TABLET_MOTION:
-    return (void *) __glutCurrentWindow->ftabletMotion;
-  case GLUT_FCB_TABLET_BUTTON:
-    return (void *) __glutCurrentWindow->ftabletButton;
-  case GLUT_FCB_JOYSTICK:
-#ifdef _WIN32
-    return (void *) __glutCurrentWindow->fjoystick;
-#else
-    return NULL;
-#endif
-  case GLUT_FCB_OVERLAY_DISPLAY:
-    return (void *) __glutCurrentWindow->overlay->fdisplay;
-  case GLUT_FCB_SELECT:
-    return (void *) __glutCurrentMenu->fselect;
-  case GLUT_FCB_TIMER:
-    return (void *) __glutTimerList->ffunc;
-  default:
-    return NULL;
-  }
-#else
-  return NULL;
-#endif
-}
diff --git a/src/glut/glx/glut_fcb.c b/src/glut/glx/glut_fcb.c
new file mode 100644 (file)
index 0000000..c8a3422
--- /dev/null
@@ -0,0 +1,164 @@
+
+/* Copyright (c) Mark J. Kilgard, 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. */
+
+/* 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 "glutint.h"
+
+/* FCB stands for Fortran CallBack. */
+
+/* There is only one idleFunc, menuStateFunc, and menuStatusFunc, so they
+   can be saved in the wrappers for Fortran rather than the C structures. */
+
+/* Set a Fortran callback function. */
+
+void APIENTRY
+__glutSetFCB(int which, GLUTproc func)
+{
+#ifdef SUPPORT_FORTRAN
+  switch (which) {
+  case GLUT_FCB_DISPLAY:
+    __glutCurrentWindow->fdisplay = (GLUTdisplayFCB) func;
+    break;
+  case GLUT_FCB_RESHAPE:
+    __glutCurrentWindow->freshape = (GLUTreshapeFCB) func;
+    break;
+  case GLUT_FCB_MOUSE:
+    __glutCurrentWindow->fmouse = (GLUTmouseFCB) func;
+    break;
+  case GLUT_FCB_MOTION:
+    __glutCurrentWindow->fmotion = (GLUTmotionFCB) func;
+    break;
+  case GLUT_FCB_PASSIVE:
+    __glutCurrentWindow->fpassive = (GLUTpassiveFCB) func;
+    break;
+  case GLUT_FCB_ENTRY:
+    __glutCurrentWindow->fentry = (GLUTentryFCB) func;
+    break;
+  case GLUT_FCB_KEYBOARD:
+    __glutCurrentWindow->fkeyboard = (GLUTkeyboardFCB) func;
+    break;
+  case GLUT_FCB_KEYBOARD_UP:
+    __glutCurrentWindow->fkeyboardUp = (GLUTkeyboardFCB) func;
+    break;
+  case GLUT_FCB_WINDOW_STATUS:
+    __glutCurrentWindow->fwindowStatus = (GLUTwindowStatusFCB) func;
+    break;
+  case GLUT_FCB_VISIBILITY:
+    __glutCurrentWindow->fvisibility = (GLUTvisibilityFCB) func;
+    break;
+  case GLUT_FCB_SPECIAL:
+    __glutCurrentWindow->fspecial = (GLUTspecialFCB) func;
+    break;
+  case GLUT_FCB_SPECIAL_UP:
+    __glutCurrentWindow->fspecialUp = (GLUTspecialFCB) func;
+    break;
+  case GLUT_FCB_BUTTON_BOX:
+    __glutCurrentWindow->fbuttonBox = (GLUTbuttonBoxFCB) func;
+    break;
+  case GLUT_FCB_DIALS:
+    __glutCurrentWindow->fdials = (GLUTdialsFCB) func;
+    break;
+  case GLUT_FCB_SPACE_MOTION:
+    __glutCurrentWindow->fspaceMotion = (GLUTspaceMotionFCB) func;
+    break;
+  case GLUT_FCB_SPACE_ROTATE:
+    __glutCurrentWindow->fspaceRotate = (GLUTspaceRotateFCB) func;
+    break;
+  case GLUT_FCB_SPACE_BUTTON:
+    __glutCurrentWindow->fspaceButton = (GLUTspaceButtonFCB) func;
+    break;
+  case GLUT_FCB_TABLET_MOTION:
+    __glutCurrentWindow->ftabletMotion = (GLUTtabletMotionFCB) func;
+    break;
+  case GLUT_FCB_TABLET_BUTTON:
+    __glutCurrentWindow->ftabletButton = (GLUTtabletButtonFCB) func;
+    break;
+#ifdef _WIN32
+  case GLUT_FCB_JOYSTICK:
+    __glutCurrentWindow->fjoystick = (GLUTjoystickFCB) func;
+    break;
+#endif
+  case GLUT_FCB_OVERLAY_DISPLAY:
+    __glutCurrentWindow->overlay->fdisplay = (GLUTdisplayFCB) func;
+    break;
+  case GLUT_FCB_SELECT:
+    __glutCurrentMenu->fselect = (GLUTselectFCB) func;
+    break;
+  case GLUT_FCB_TIMER:
+    __glutNewTimer->ffunc = (GLUTtimerFCB) func;
+    break;
+  }
+#endif
+}
+
+/* Get a Fortran callback function. */
+
+GLUTproc APIENTRY
+__glutGetFCB(int which)
+{
+#ifdef SUPPORT_FORTRAN
+  switch (which) {
+  case GLUT_FCB_DISPLAY:
+    return __glutCurrentWindow->fdisplay;
+  case GLUT_FCB_RESHAPE:
+    return __glutCurrentWindow->freshape;
+  case GLUT_FCB_MOUSE:
+    return __glutCurrentWindow->fmouse;
+  case GLUT_FCB_MOTION:
+    return __glutCurrentWindow->fmotion;
+  case GLUT_FCB_PASSIVE:
+    return __glutCurrentWindow->fpassive;
+  case GLUT_FCB_ENTRY:
+    return __glutCurrentWindow->fentry;
+  case GLUT_FCB_KEYBOARD:
+    return __glutCurrentWindow->fkeyboard;
+  case GLUT_FCB_KEYBOARD_UP:
+    return __glutCurrentWindow->fkeyboardUp;
+  case GLUT_FCB_WINDOW_STATUS:
+    return __glutCurrentWindow->fwindowStatus;
+  case GLUT_FCB_VISIBILITY:
+    return __glutCurrentWindow->fvisibility;
+  case GLUT_FCB_SPECIAL:
+    return __glutCurrentWindow->fspecial;
+  case GLUT_FCB_SPECIAL_UP:
+    return __glutCurrentWindow->fspecialUp;
+  case GLUT_FCB_BUTTON_BOX:
+    return __glutCurrentWindow->fbuttonBox;
+  case GLUT_FCB_DIALS:
+    return __glutCurrentWindow->fdials;
+  case GLUT_FCB_SPACE_MOTION:
+    return __glutCurrentWindow->fspaceMotion;
+  case GLUT_FCB_SPACE_ROTATE:
+    return __glutCurrentWindow->fspaceRotate;
+  case GLUT_FCB_SPACE_BUTTON:
+    return __glutCurrentWindow->fspaceButton;
+  case GLUT_FCB_TABLET_MOTION:
+    return __glutCurrentWindow->ftabletMotion;
+  case GLUT_FCB_TABLET_BUTTON:
+    return __glutCurrentWindow->ftabletButton;
+  case GLUT_FCB_JOYSTICK:
+#ifdef _WIN32
+    return __glutCurrentWindow->fjoystick;
+#else
+    return NULL;
+#endif
+  case GLUT_FCB_OVERLAY_DISPLAY:
+    return __glutCurrentWindow->overlay->fdisplay;
+  case GLUT_FCB_SELECT:
+    return __glutCurrentMenu->fselect;
+  case GLUT_FCB_TIMER:
+     return __glutTimerList ? __glutTimerList->ffunc : NULL;
+  default:
+    return NULL;
+  }
+#else
+  return NULL;
+#endif
+}
index 980306d0e28d041b4a6cc3a4a0eeffe9cd8f5330..7e7afc3533703d064cd822c6640a0cf3c7a79b3d 100644 (file)
@@ -55,7 +55,7 @@ default: depend $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
 
 # Make the library
 $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS)
-       $(TOP)/bin/mklib -o $(GLUT_LIB) -linker '$(CC)' \
+       $(MKLIB) -o $(GLUT_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
                -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \
                $(GLUT_LIB_DEPS) -install $(TOP)/$(LIB_DIR) \
                $(MKLIB_OPTIONS) $(OBJECTS)
@@ -73,9 +73,27 @@ tags:
        etags `find . -name \*.[ch]` `find ../include`
 
 
+# glut pkgconfig file
+pcedit = sed \
+       -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \
+       -e 's,@INSTALL_LIB_DIR@,$(INSTALL_LIB_DIR),' \
+       -e 's,@INSTALL_INC_DIR@,$(INSTALL_INC_DIR),' \
+       -e 's,@VERSION@,$(GLUT_MAJOR).$(GLUT_MINOR).$(GLUT_TINY),'
+glut.pc: glut.pc.in
+       $(pcedit) $< > $@
+
+install: glut.pc
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/GL
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
+       $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(DESTDIR)$(INSTALL_INC_DIR)/GL
+       $(INSTALL) $(TOP)/$(LIB_DIR)/libglut* $(DESTDIR)$(INSTALL_LIB_DIR)
+       $(INSTALL) -m 644 glut.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
+
+
 # Remove .o and backup files
 clean: depend
-       -rm -f depend
-       -rm -f *.o *~ *.o *~ *.so libglut.so.3.7
+       -rm -f depend depend.bak
+       -rm -f *.o *~ *.o *~ *.so *.pc libglut.so.3.7
 
 include depend
diff --git a/src/glut/mini/glut.pc.in b/src/glut/mini/glut.pc.in
new file mode 100644 (file)
index 0000000..e8638fe
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@INSTALL_DIR@
+exec_prefix=${prefix}
+libdir=@INSTALL_LIB_DIR@
+includedir=@INSTALL_INC_DIR@
+
+Name: glut
+Description: Mesa OpenGL Utility Toolkit library
+Requires: gl glu
+Version: @VERSION@
+Libs: -L${libdir} -lglut
+Cflags: -I${includedir}
index 86a0bbaeace071f2bb971771b7c825c7bd468fa8..c2e8e3046b541edf9de1328950f6b7a51fe5c05c 100644 (file)
@@ -7,7 +7,7 @@ MAJOR = 1
 MINOR = 0
 TINY = 0
 
-INCDIRS = -I$(TOP)/include -I/usr/include/Motif1.2 $(X11_INCLUDES)
+INCDIRS = -I$(TOP)/include $(MOTIF_CFLAGS) $(X11_INCLUDES)
 
 
 OBJECTS = $(GLW_SOURCES:.c=.o)
@@ -25,22 +25,34 @@ OBJECTS = $(GLW_SOURCES:.c=.o)
 
 default: $(TOP)/$(LIB_DIR)/$(GLW_LIB_NAME)
 
-install:
-       $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL
-       $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
-       $(INSTALL) -m 644 *.h $(DESTDIR)$(INSTALL_DIR)/include/GL
-       $(INSTALL) $(TOP)/$(LIB_DIR)/libGLw.* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
+# GLU pkg-config file
+pcedit = sed \
+       -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \
+       -e 's,@INSTALL_LIB_DIR@,$(INSTALL_LIB_DIR),' \
+       -e 's,@INSTALL_INC_DIR@,$(INSTALL_INC_DIR),' \
+       -e 's,@VERSION@,$(MAJOR).$(MINOR).$(TINY),'
+glw.pc: glw.pc.in
+       $(pcedit) $< > $@
+
+install: glw.pc
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/GL
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
+       $(INSTALL) -m 644 *.h $(DESTDIR)$(INSTALL_INC_DIR)/GL
+       $(INSTALL) $(TOP)/$(LIB_DIR)/$(GLW_LIB_GLOB) $(DESTDIR)$(INSTALL_LIB_DIR)
+       $(INSTALL) -m 644 glw.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
 
 clean:
-       -rm depend depend.bak
-       -rm -f *.o *~
+       -rm -f depend depend.bak
+       -rm -f *.o *.pc *~
 
 
 # Make the library
 $(TOP)/$(LIB_DIR)/$(GLW_LIB_NAME): $(OBJECTS)
-       $(TOP)/bin/mklib -o $(GLW_LIB) -linker '$(CC)' \
+       $(MKLIB) -o $(GLW_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
                -major $(MAJOR) -minor $(MINOR) -patch $(TINY) \
                $(MKLIB_OPTIONS) -install $(TOP)/$(LIB_DIR) \
+               -id $(INSTALL_LIB_DIR)/lib$(GLW_LIB).$(MAJOR).dylib \
                $(GLW_LIB_DEPS) $(OBJECTS)
 
 
@@ -52,7 +64,7 @@ depend: $(GLW_SOURCES)
        rm -f depend
        touch depend
        $(MKDEP) $(MKDEP_OPTIONS) -I$(TOP)/include $(GLW_SOURCES) \
-               > /dev/null 
+               $(X11_INCLUDES) > /dev/null
 
 
 include depend
diff --git a/src/glw/glw.pc.in b/src/glw/glw.pc.in
new file mode 100644 (file)
index 0000000..25f3f73
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@INSTALL_DIR@
+exec_prefix=${prefix}
+libdir=@INSTALL_LIB_DIR@
+includedir=@INSTALL_INC_DIR@
+
+Name: glw
+Description: Mesa OpenGL widget library
+Requires: gl
+Version: @VERSION@
+Libs: -L${libdir} -lGLw
+Cflags: -I${includedir}
index bd486cf81b333735529cf758d0d04c7a5e39ea55..e0ab4a024016bac5a609ad6442792242c546a6ab 100644 (file)
@@ -4,9 +4,9 @@ include $(TOP)/configs/current
 
 
 default:
-       cd mini ; $(MAKE)
+       cd mini && $(MAKE)
 
 
 clean:
-       cd mini ; $(MAKE) clean
+       -@cd mini && $(MAKE) clean
 
index 9545505cbff6b2b0d4dbf4d5e1efd31409f87b6f..6b5a3c76d74fd71fa96d5a82f58c72f741427b69 100644 (file)
@@ -49,7 +49,7 @@ default: depend $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/miniglx.conf
 
 # Make libGL
 $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME):  $(OBJECTS) Makefile
-       @ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' \
+       @ $(MKLIB) -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
                -major 1 -minor 2 $(MKLIB_OPTIONS) \
                -install $(TOP)/$(LIB_DIR) $(GL_LIB_DEPS) $(OBJECTS) \
                $(LIBDRM_LIB) $(PCIACCESS_LIB)
@@ -76,10 +76,14 @@ tags:
        etags `find . -name \*.[ch]` `find ../include`
 
 
+# Dummy install target
+install:
+
+
 # Remove .o and backup files
 clean:
        -rm -f drmtest $(TOP)/$(LIB_DIR)/libGL.so*
        -rm -f *.o *~
-       -rm -f depend
+       -rm -f depend depend.bak
 
 include depend
diff --git a/src/glx/x11/.gitignore b/src/glx/x11/.gitignore
deleted file mode 100644 (file)
index ffc14ab..0000000
+++ /dev/null
@@ -1 +0,0 @@
-glcontextmodes.c
index c99bcf26a901585e0873d8464bf42ec1824ec2fd..8d49a174e8f0412aef9f4a2eed955e0d96bc6b14 100644 (file)
@@ -10,12 +10,14 @@ SOURCES = \
          compsize.c \
          eval.c \
          glxcmds.c \
+         glxcurrent.c \
          glxext.c \
          glxextensions.c \
          indirect.c \
          indirect_init.c \
          indirect_size.c \
          indirect_window_pos.c \
+         indirect_texture_compression.c \
          indirect_transpose_matrix.c \
          indirect_vertex_array.c \
          indirect_vertex_program.c \
@@ -29,9 +31,13 @@ SOURCES = \
          xfont.c \
          glx_pbuffer.c \
          glx_query.c \
-         glx_texture_compression.c \
+         drisw_glx.c \
+         dri_common.c \
          dri_glx.c \
-         XF86dri.c
+         XF86dri.c \
+         glxhash.c \
+         dri2_glx.c \
+         dri2.c
 
 include $(TOP)/src/mesa/sources.mak
 
@@ -48,6 +54,7 @@ INCLUDES = -I. \
        -I$(TOP)/src/mesa/main \
        -I$(TOP)/src/mesa/glapi \
        $(LIBDRM_CFLAGS) \
+       $(DRI2PROTO_CFLAGS) \
        $(X11_INCLUDES)
 
 
@@ -65,9 +72,10 @@ default: depend $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
 
 # Make libGL
 $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME):  $(OBJECTS) Makefile
-       $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' \
+       $(MKLIB) -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
                -major 1 -minor 2 $(MKLIB_OPTIONS) \
-               -install $(TOP)/$(LIB_DIR) $(GL_LIB_DEPS) $(OBJECTS)
+               -install $(TOP)/$(LIB_DIR) -id $(INSTALL_LIB_DIR)/lib$(GL_LIB).1.dylib \
+               $(GL_LIB_DEPS) $(OBJECTS)
 
 
 depend: $(SOURCES) $(MESA_GLAPI_SOURCES) $(MESA_GLAPI_ASM_SOURCES) Makefile
@@ -81,13 +89,13 @@ depend: $(SOURCES) $(MESA_GLAPI_SOURCES) $(MESA_GLAPI_ASM_SOURCES) Makefile
 tags:
        etags `find . -name \*.[ch]` `find $(TOP)/include`
 
-# Dummy install target
-install:
+install: $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
+       $(MAKE) -C $(TOP)/src/mesa install-libgl
 
 # Remove .o and backup files
 clean:
        -rm -f $(TOP)/$(LIB_DIR)/libGL.so*
        -rm -f *.o *~
-       -rm -f depend
+       -rm -f depend depend.bak
 
-include depend
+-include depend
index 9919a40977153bf9613a3dcd3cee23dc772493e3..ba38949c0b40af2ed333f29641ee4484a6cc49c4 100644 (file)
@@ -374,10 +374,9 @@ PUBLIC Bool XF86DRICreateContext(dpy, screen, visual, context, hHWContext)
                                           context, hHWContext );
 }
 
-PUBLIC GLboolean XF86DRIDestroyContext( __DRInativeDisplay * ndpy, int screen, 
-    __DRIid context )
+PUBLIC GLboolean XF86DRIDestroyContext(Display *dpy, int screen, 
+    XID context )
 {
-    Display * const dpy = (Display *) ndpy;
     XExtDisplayInfo *info = find_display (dpy);
     xXF86DRIDestroyContextReq *req;
 
@@ -396,10 +395,9 @@ PUBLIC GLboolean XF86DRIDestroyContext( __DRInativeDisplay * ndpy, int screen,
     return True;
 }
 
-PUBLIC GLboolean XF86DRICreateDrawable( __DRInativeDisplay * ndpy, int screen, 
-    __DRIid drawable, drm_drawable_t * hHWDrawable )
+PUBLIC GLboolean XF86DRICreateDrawable(Display *dpy, int screen, 
+    XID drawable, drm_drawable_t * hHWDrawable )
 {
-    Display * const dpy = (Display *) ndpy;
     XExtDisplayInfo *info = find_display (dpy);
     xXF86DRICreateDrawableReply rep;
     xXF86DRICreateDrawableReq *req;
@@ -426,16 +424,36 @@ PUBLIC GLboolean XF86DRICreateDrawable( __DRInativeDisplay * ndpy, int screen,
     return True;
 }
 
-PUBLIC GLboolean XF86DRIDestroyDrawable( __DRInativeDisplay * ndpy, int screen,
-    __DRIid drawable )
+static int noopErrorHandler(Display *dpy, XErrorEvent *xerr)
+{
+    return 0;
+}
+
+PUBLIC GLboolean XF86DRIDestroyDrawable(Display *dpy, int screen,
+    XID drawable )
 {
-    Display * const dpy = (Display *) ndpy;
     XExtDisplayInfo *info = find_display (dpy);
     xXF86DRIDestroyDrawableReq *req;
+    int (*oldXErrorHandler)(Display *, XErrorEvent *);
 
     TRACE("DestroyDrawable...");
     XF86DRICheckExtension (dpy, info, False);
 
+    /* This is called from the DRI driver, which used call it like this
+     *
+     *   if (windowExists(drawable))
+     *     destroyDrawable(drawable);
+     *
+     * which is a textbook race condition - the window may disappear
+     * from the server between checking for its existance and
+     * destroying it.  Instead we change the semantics of
+     * __DRIinterfaceMethodsRec::destroyDrawable() to succeed even if
+     * the windows is gone, by wrapping the destroy call in an error
+     * handler. */
+
+    XSync(dpy, GL_FALSE);
+    oldXErrorHandler = XSetErrorHandler(noopErrorHandler);
+
     LockDisplay(dpy);
     GetReq(XF86DRIDestroyDrawable, req);
     req->reqType = info->codes->major_opcode;
@@ -444,6 +462,9 @@ PUBLIC GLboolean XF86DRIDestroyDrawable( __DRInativeDisplay * ndpy, int screen,
     req->drawable = drawable;
     UnlockDisplay(dpy);
     SyncHandle();
+
+    XSetErrorHandler(oldXErrorHandler);
+
     TRACE("DestroyDrawable... return True");
     return True;
 }
diff --git a/src/glx/x11/dri2.c b/src/glx/x11/dri2.c
new file mode 100644 (file)
index 0000000..dc60af9
--- /dev/null
@@ -0,0 +1,301 @@
+/*
+ * Copyright Â© 2008 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Soft-
+ * ware"), to deal in the Software without restriction, including without
+ * limitation the rights to use, copy, modify, merge, publish, distribute,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, provided that the above copyright
+ * notice(s) and this permission notice appear in all copies of the Soft-
+ * ware and that both the above copyright notice(s) and this permission
+ * notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+ * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
+ * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
+ * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
+ * QUENTIAL 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 PERFOR-
+ * MANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder shall
+ * not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization of
+ * the copyright holder.
+ *
+ * Authors:
+ *   Kristian Høgsberg (krh@redhat.com)
+ */
+
+
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <X11/extensions/dri2proto.h>
+#include "glheader.h"
+#include "xf86drm.h"
+#include "dri2.h"
+
+static char dri2ExtensionName[] = DRI2_NAME;
+static XExtensionInfo *dri2Info;
+static XEXT_GENERATE_CLOSE_DISPLAY (DRI2CloseDisplay, dri2Info)
+static /* const */ XExtensionHooks dri2ExtensionHooks = {
+    NULL,                              /* create_gc */
+    NULL,                              /* copy_gc */
+    NULL,                              /* flush_gc */
+    NULL,                              /* free_gc */
+    NULL,                              /* create_font */
+    NULL,                              /* free_font */
+    DRI2CloseDisplay,                  /* close_display */
+    NULL,                              /* wire_to_event */
+    NULL,                              /* event_to_wire */
+    NULL,                              /* error */
+    NULL,                              /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (DRI2FindDisplay, dri2Info, 
+                                  dri2ExtensionName, 
+                                  &dri2ExtensionHooks, 
+                                  0, NULL)
+
+Bool DRI2QueryExtension(Display *dpy, int *eventBase, int *errorBase)
+{
+    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+
+    if (XextHasExtension(info)) {
+       *eventBase = info->codes->first_event;
+       *errorBase = info->codes->first_error;
+       return True;
+    }
+
+    return False;
+}
+
+Bool DRI2QueryVersion(Display *dpy, int *major, int *minor)
+{
+    XExtDisplayInfo *info = DRI2FindDisplay (dpy);
+    xDRI2QueryVersionReply rep;
+    xDRI2QueryVersionReq *req;
+
+    XextCheckExtension (dpy, info, dri2ExtensionName, False);
+
+    LockDisplay(dpy);
+    GetReq(DRI2QueryVersion, req);
+    req->reqType = info->codes->major_opcode;
+    req->dri2ReqType = X_DRI2QueryVersion;
+    req->majorVersion = DRI2_MAJOR;
+    req->minorVersion = DRI2_MINOR;
+    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+       UnlockDisplay(dpy);
+       SyncHandle();
+       return False;
+    }
+    *major = rep.majorVersion;
+    *minor = rep.minorVersion;
+    UnlockDisplay(dpy);
+    SyncHandle();
+
+    return True;
+}
+
+Bool DRI2Connect(Display *dpy, int screen,
+                char **driverName, char **busId, unsigned int *sareaHandle)
+{
+    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+    xDRI2ConnectReply rep;
+    xDRI2ConnectReq *req;
+
+    XextCheckExtension (dpy, info, dri2ExtensionName, False);
+
+    LockDisplay(dpy);
+    GetReq(DRI2Connect, req);
+    req->reqType = info->codes->major_opcode;
+    req->dri2ReqType = X_DRI2Connect;
+    req->screen = screen;
+    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+       UnlockDisplay(dpy);
+       SyncHandle();
+       return False;
+    }
+
+    if (rep.driverNameLength == 0 && rep.busIdLength == 0) {
+       UnlockDisplay(dpy);
+       SyncHandle();
+       return False;
+    }
+
+    *driverName = Xmalloc(rep.driverNameLength + 1);
+    if (*driverName == NULL) {
+       _XEatData(dpy, 
+                 ((rep.driverNameLength + 3) & ~3) +
+                 ((rep.busIdLength + 3) & ~3));
+       UnlockDisplay(dpy);
+       SyncHandle();
+       return False;
+    }
+    _XReadPad(dpy, *driverName, rep.driverNameLength);
+    (*driverName)[rep.driverNameLength] = '\0';
+
+    *busId = Xmalloc(rep.busIdLength + 1);
+    if (*busId == NULL) {
+       Xfree(*driverName);
+       _XEatData(dpy, ((rep.busIdLength + 3) & ~3));
+       UnlockDisplay(dpy);
+       SyncHandle();
+       return False;
+    }
+    _XReadPad(dpy, *busId, rep.busIdLength);
+    (*busId)[rep.busIdLength] = '\0';
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+
+    return True;
+}
+
+Bool DRI2AuthConnection(Display *dpy, int screen, drm_magic_t magic)
+{
+    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+    xDRI2AuthConnectionReq *req;
+    xDRI2AuthConnectionReply rep;
+
+    XextCheckExtension (dpy, info, dri2ExtensionName, False);
+
+    LockDisplay(dpy);
+    GetReq(DRI2AuthConnection, req);
+    req->reqType = info->codes->major_opcode;
+    req->dri2ReqType = X_DRI2AuthConnection;
+    req->screen = screen;
+    req->magic = magic;
+    rep.authenticated = 0;
+    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+       UnlockDisplay(dpy);
+       SyncHandle();
+       return False;
+    }
+    UnlockDisplay(dpy);
+    SyncHandle();
+
+    return rep.authenticated;
+}
+
+void DRI2CreateDrawable(Display *dpy, XID drawable)
+{
+    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+    xDRI2CreateDrawableReq *req;
+
+    XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
+
+    LockDisplay(dpy);
+    GetReq(DRI2CreateDrawable, req);
+    req->reqType = info->codes->major_opcode;
+    req->dri2ReqType = X_DRI2CreateDrawable;
+    req->drawable = drawable;
+    UnlockDisplay(dpy);
+    SyncHandle();
+}
+
+DRI2Buffer *DRI2GetBuffers(Display *dpy, XID drawable,
+                          int *width, int *height,
+                          unsigned int *attachments, int count,
+                          int *outCount)
+{
+    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+    xDRI2GetBuffersReply rep;
+    xDRI2GetBuffersReq *req;
+    DRI2Buffer *buffers;
+    xDRI2Buffer repBuffer;
+    CARD32 *p;
+    int i;
+
+    XextCheckExtension (dpy, info, dri2ExtensionName, False);
+
+    LockDisplay(dpy);
+    GetReqExtra(DRI2GetBuffers, count * 4, req);
+    req->reqType = info->codes->major_opcode;
+    req->dri2ReqType = X_DRI2GetBuffers;
+    req->drawable = drawable;
+    req->count = count;
+    p = (CARD32 *) &req[1];
+    for (i = 0; i < count; i++)
+       p[i] = attachments[i];
+
+    if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+       UnlockDisplay(dpy);
+       SyncHandle();
+       return NULL;
+    }
+
+    *width = rep.width;
+    *height = rep.height;
+    *outCount = rep.count;
+
+    buffers = Xmalloc(count * sizeof buffers[0]);
+    if (buffers == NULL) {
+       _XEatData(dpy, rep.count * sizeof repBuffer);
+       UnlockDisplay(dpy);
+       SyncHandle();
+       return NULL;
+    }
+
+    for (i = 0; i < rep.count; i++) {
+       _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer);
+       buffers[i].attachment = repBuffer.attachment;
+       buffers[i].name = repBuffer.name;
+       buffers[i].pitch = repBuffer.pitch;
+       buffers[i].cpp = repBuffer.cpp;
+       buffers[i].flags = repBuffer.flags;
+    }
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+
+    return buffers;
+}
+
+void DRI2SwapBuffers(Display *dpy, XID drawable,
+                    int x, int y, int width, int height)
+{
+    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+    xDRI2SwapBuffersReq *req;
+    xDRI2SwapBuffersReply rep;
+
+    XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
+
+    LockDisplay(dpy);
+    GetReq(DRI2SwapBuffers, req);
+    req->reqType = info->codes->major_opcode;
+    req->dri2ReqType = X_DRI2SwapBuffers;
+    req->drawable = drawable;
+    req->x = x;
+    req->y = y;
+    req->width = width;
+    req->height = height;
+
+    _XReply(dpy, (xReply *)&rep, 0, xFalse);
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+}
+
+void DRI2DestroyDrawable(Display *dpy, XID drawable)
+{
+    XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+    xDRI2DestroyDrawableReq *req;
+
+    XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
+
+    XSync(dpy, GL_FALSE);
+
+    LockDisplay(dpy);
+    GetReq(DRI2DestroyDrawable, req);
+    req->reqType = info->codes->major_opcode;
+    req->dri2ReqType = X_DRI2DestroyDrawable;
+    req->drawable = drawable;
+    UnlockDisplay(dpy);
+    SyncHandle();
+}
diff --git a/src/glx/x11/dri2.h b/src/glx/x11/dri2.h
new file mode 100644 (file)
index 0000000..e57c4ce
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright Â© 2007,2008 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Soft-
+ * ware"), to deal in the Software without restriction, including without
+ * limitation the rights to use, copy, modify, merge, publish, distribute,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, provided that the above copyright
+ * notice(s) and this permission notice appear in all copies of the Soft-
+ * ware and that both the above copyright notice(s) and this permission
+ * notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+ * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
+ * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
+ * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
+ * QUENTIAL 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 PERFOR-
+ * MANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder shall
+ * not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization of
+ * the copyright holder.
+ *
+ * Authors:
+ *   Kristian Høgsberg (krh@redhat.com)
+ */
+
+#ifndef _DRI2_H_
+#define _DRI2_H_
+
+typedef struct {
+    unsigned int attachment;
+    unsigned int name;
+    unsigned int pitch;
+    unsigned int cpp;
+    unsigned int flags;
+} DRI2Buffer;
+
+extern Bool
+DRI2QueryExtension(Display *display, int *eventBase, int *errorBase);
+extern Bool
+DRI2QueryVersion(Display *display, int *major, int *minor);
+extern Bool
+DRI2Connect(Display *display, int screen,
+           char **driverName, char **busId, unsigned int *sareaHandle);
+extern Bool
+DRI2AuthConnection(Display *display, int screen, drm_magic_t magic);
+extern void
+DRI2CreateDrawable(Display *display, XID drawable);
+extern void
+DRI2DestroyDrawable(Display *display, XID handle);
+extern DRI2Buffer *
+DRI2GetBuffers(Display *dpy, XID drawable,
+              int *width, int *height,
+              unsigned int *attachments, int count,
+              int *outCount);
+extern void
+DRI2SwapBuffers(Display *dpy, XID drawable,
+               int x, int y, int width, int height);
+
+#endif
diff --git a/src/glx/x11/dri2_glx.c b/src/glx/x11/dri2_glx.c
new file mode 100644 (file)
index 0000000..3c366bf
--- /dev/null
@@ -0,0 +1,372 @@
+/*
+ * Copyright Â© 2008 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Soft-
+ * ware"), to deal in the Software without restriction, including without
+ * limitation the rights to use, copy, modify, merge, publish, distribute,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, provided that the above copyright
+ * notice(s) and this permission notice appear in all copies of the Soft-
+ * ware and that both the above copyright notice(s) and this permission
+ * notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+ * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
+ * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
+ * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
+ * QUENTIAL 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 PERFOR-
+ * MANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder shall
+ * not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization of
+ * the copyright holder.
+ *
+ * Authors:
+ *   Kristian Høgsberg (krh@redhat.com)
+ */
+
+#ifdef GLX_DIRECT_RENDERING
+
+#include <X11/Xlib.h>
+#include <X11/extensions/Xfixes.h>
+#include <X11/extensions/Xdamage.h>
+#include "glheader.h"
+#include "glxclient.h"
+#include "glcontextmodes.h"
+#include "xf86dri.h"
+#include "sarea.h"
+#include <dlfcn.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include "xf86drm.h"
+#include "dri2.h"
+#include "dri_common.h"
+
+typedef struct __GLXDRIdisplayPrivateRec __GLXDRIdisplayPrivate;
+typedef struct __GLXDRIcontextPrivateRec __GLXDRIcontextPrivate;
+typedef struct __GLXDRIdrawablePrivateRec __GLXDRIdrawablePrivate;
+
+struct __GLXDRIdisplayPrivateRec {
+    __GLXDRIdisplay base;
+
+    /*
+    ** XFree86-DRI version information
+    */
+    int driMajor;
+    int driMinor;
+    int driPatch;
+};
+
+struct __GLXDRIcontextPrivateRec {
+    __GLXDRIcontext base;
+    __DRIcontext *driContext;
+    __GLXscreenConfigs *psc;
+};
+
+struct __GLXDRIdrawablePrivateRec {
+    __GLXDRIdrawable base;
+    __DRIbuffer buffers[5];
+    int bufferCount;
+    int width, height;
+};
+
+static void dri2DestroyContext(__GLXDRIcontext *context,
+                             __GLXscreenConfigs *psc, Display *dpy)
+{
+    __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
+    const __DRIcoreExtension *core = pcp->psc->core;
+
+    (*core->destroyContext)(pcp->driContext);
+
+    Xfree(pcp);
+}
+
+static Bool dri2BindContext(__GLXDRIcontext *context,
+                          __GLXDRIdrawable *draw, __GLXDRIdrawable *read)
+{
+    __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
+    const __DRIcoreExtension *core = pcp->psc->core;
+
+    return (*core->bindContext)(pcp->driContext,
+                               draw->driDrawable,
+                               read->driDrawable);
+}
+
+static void dri2UnbindContext(__GLXDRIcontext *context)
+{
+    __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
+    const __DRIcoreExtension *core = pcp->psc->core;
+
+    (*core->unbindContext)(pcp->driContext);
+}
+
+static __GLXDRIcontext *dri2CreateContext(__GLXscreenConfigs *psc,
+                                        const __GLcontextModes *mode,
+                                        GLXContext gc,
+                                        GLXContext shareList, int renderType)
+{
+    __GLXDRIcontextPrivate *pcp, *pcp_shared;
+    __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode;
+    __DRIcontext *shared = NULL;
+
+    if (shareList) {
+       pcp_shared = (__GLXDRIcontextPrivate *) shareList->driContext;
+       shared = pcp_shared->driContext;
+    }
+
+    pcp = Xmalloc(sizeof *pcp);
+    if (pcp == NULL)
+       return NULL;
+
+    pcp->psc = psc;
+    pcp->driContext = 
+       (*psc->dri2->createNewContext)(psc->__driScreen,
+                                      config->driConfig, shared, pcp);
+    gc->__driContext = pcp->driContext;
+
+    if (pcp->driContext == NULL) {
+       Xfree(pcp);
+       return NULL;
+    }
+
+    pcp->base.destroyContext = dri2DestroyContext;
+    pcp->base.bindContext = dri2BindContext;
+    pcp->base.unbindContext = dri2UnbindContext;
+
+    return &pcp->base;
+}
+
+static void dri2DestroyDrawable(__GLXDRIdrawable *pdraw)
+{
+    const __DRIcoreExtension *core = pdraw->psc->core;
+
+    (*core->destroyDrawable)(pdraw->driDrawable);
+    DRI2DestroyDrawable(pdraw->psc->dpy, pdraw->drawable);
+    Xfree(pdraw);
+}
+
+static __GLXDRIdrawable *dri2CreateDrawable(__GLXscreenConfigs *psc,
+                                           XID xDrawable,
+                                           GLXDrawable drawable,
+                                           const __GLcontextModes *modes)
+{
+    __GLXDRIdrawablePrivate *pdraw;
+    __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
+
+    pdraw = Xmalloc(sizeof(*pdraw));
+    if (!pdraw)
+       return NULL;
+
+    pdraw->base.destroyDrawable = dri2DestroyDrawable;
+    pdraw->base.xDrawable = xDrawable;
+    pdraw->base.drawable = drawable;
+    pdraw->base.psc = psc;
+
+    DRI2CreateDrawable(psc->dpy, xDrawable);
+
+    /* Create a new drawable */
+    pdraw->base.driDrawable =
+       (*psc->dri2->createNewDrawable)(psc->__driScreen,
+                                       config->driConfig, pdraw);
+
+    if (!pdraw->base.driDrawable) {
+       DRI2DestroyDrawable(psc->dpy, drawable);
+       Xfree(pdraw);
+       return NULL;
+    }
+
+    return &pdraw->base;
+}
+
+static void dri2SwapBuffers(__GLXDRIdrawable *pdraw)
+{
+    __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw;
+
+    DRI2SwapBuffers(pdraw->psc->dpy, pdraw->drawable,
+                   0, 0, priv->width, priv->height);
+}
+
+static void dri2DestroyScreen(__GLXscreenConfigs *psc)
+{
+    /* Free the direct rendering per screen data */
+    (*psc->core->destroyScreen)(psc->__driScreen);
+    drmClose(psc->fd);
+    psc->__driScreen = NULL;
+}
+
+static __DRIbuffer *
+dri2GetBuffers(__DRIdrawable *driDrawable,
+              int *width, int *height,
+              unsigned int *attachments, int count,
+              int *out_count, void *loaderPrivate)
+{
+    __GLXDRIdrawablePrivate *pdraw = loaderPrivate;
+    DRI2Buffer *buffers;
+    int i;
+
+    buffers = DRI2GetBuffers(pdraw->base.psc->dpy, pdraw->base.xDrawable,
+                            width, height, attachments, count, out_count);
+    if (buffers == NULL)
+       return NULL;
+
+    pdraw->width = *width;
+    pdraw->height = *height;
+
+    /* This assumes the DRI2 buffer attachment tokens matches the
+     * __DRIbuffer tokens. */
+    for (i = 0; i < *out_count; i++) {
+       pdraw->buffers[i].attachment = buffers[i].attachment;
+       pdraw->buffers[i].name = buffers[i].name;
+       pdraw->buffers[i].pitch = buffers[i].pitch;
+       pdraw->buffers[i].cpp = buffers[i].cpp;
+       pdraw->buffers[i].flags = buffers[i].flags;
+    }
+
+    Xfree(buffers);
+
+    return pdraw->buffers;
+}
+
+static const __DRIdri2LoaderExtension dri2LoaderExtension = {
+    { __DRI_DRI2_LOADER, __DRI_DRI2_LOADER_VERSION },
+    dri2GetBuffers,
+};
+
+static const __DRIextension *loader_extensions[] = {
+    &dri2LoaderExtension.base,
+    &systemTimeExtension.base,
+    NULL
+};
+
+static __GLXDRIscreen *dri2CreateScreen(__GLXscreenConfigs *psc, int screen,
+                                       __GLXdisplayPrivate *priv)
+{
+    const __DRIconfig **driver_configs;
+    const __DRIextension **extensions;
+    __GLXDRIscreen *psp;
+    unsigned int sareaHandle;
+    char *driverName, *busID;
+    drm_magic_t magic;
+    int i;
+
+    psp = Xmalloc(sizeof *psp);
+    if (psp == NULL)
+       return NULL;
+
+    /* Initialize per screen dynamic client GLX extensions */
+    psc->ext_list_first_time = GL_TRUE;
+
+    if (!DRI2Connect(psc->dpy, screen, &driverName, &busID, &sareaHandle))
+       return NULL;
+
+    psc->driver = driOpenDriver(driverName);
+    if (psc->driver == NULL)
+       goto handle_error;
+
+    extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS);
+    if (extensions == NULL) {
+       ErrorMessageF("driver exports no extensions (%s)\n", dlerror());
+       goto handle_error;
+    }
+    
+    for (i = 0; extensions[i]; i++) {
+       if (strcmp(extensions[i]->name, __DRI_CORE) == 0)
+           psc->core = (__DRIcoreExtension *) extensions[i];
+       if (strcmp(extensions[i]->name, __DRI_DRI2) == 0)
+           psc->dri2 = (__DRIdri2Extension *) extensions[i];
+    }
+
+    if (psc->core == NULL || psc->dri2 == NULL) {
+       ErrorMessageF("core dri or dri2 extension not found\n");
+       goto handle_error;
+    }
+
+    psc->fd = drmOpen(NULL, busID);
+    if (psc->fd < 0) {
+       ErrorMessageF("failed to open drm device: %s\n", strerror(errno));
+       return NULL;
+    }
+
+    if (drmGetMagic(psc->fd, &magic))
+       return NULL;
+
+    if (!DRI2AuthConnection(psc->dpy, screen, magic)) {
+       ErrorMessageF("failed to authenticate drm access\n");
+       return NULL;
+    }
+
+    psc->__driScreen = 
+       psc->dri2->createNewScreen(screen, psc->fd,
+                                  loader_extensions, &driver_configs, psc);
+    if (psc->__driScreen == NULL) {
+       ErrorMessageF("failed to create dri screen\n");
+       return NULL;
+    }
+
+    driBindExtensions(psc, 1);
+
+    psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs);
+    psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);
+
+    psp->destroyScreen = dri2DestroyScreen;
+    psp->createContext = dri2CreateContext;
+    psp->createDrawable = dri2CreateDrawable;
+    psp->swapBuffers = dri2SwapBuffers;
+
+    Xfree(driverName);
+    Xfree(busID);
+
+    return psp;
+
+ handle_error:
+    Xfree(driverName);
+    Xfree(busID);
+
+    /* FIXME: clean up here */
+
+    return NULL;
+}
+
+/* Called from __glXFreeDisplayPrivate.
+ */
+static void dri2DestroyDisplay(__GLXDRIdisplay *dpy)
+{
+    Xfree(dpy);
+}
+
+/*
+ * Allocate, initialize and return a __DRIdisplayPrivate object.
+ * This is called from __glXInitialize() when we are given a new
+ * display pointer.
+ */
+_X_HIDDEN __GLXDRIdisplay *dri2CreateDisplay(Display *dpy)
+{
+    __GLXDRIdisplayPrivate *pdp;
+    int eventBase, errorBase;
+
+    if (!DRI2QueryExtension(dpy, &eventBase, &errorBase))
+       return NULL;
+
+    pdp = Xmalloc(sizeof *pdp);
+    if (pdp == NULL)
+       return NULL;
+
+    if (!DRI2QueryVersion(dpy, &pdp->driMajor, &pdp->driMinor)) {
+       Xfree(pdp);
+       return NULL;
+    }
+
+    pdp->driPatch = 0;
+
+    pdp->base.destroyDisplay = dri2DestroyDisplay;
+    pdp->base.createScreen = dri2CreateScreen;
+
+    return &pdp->base;
+}
+
+#endif /* GLX_DIRECT_RENDERING */
diff --git a/src/glx/x11/dri_common.c b/src/glx/x11/dri_common.c
new file mode 100644 (file)
index 0000000..8175f46
--- /dev/null
@@ -0,0 +1,399 @@
+/*
+ * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright Â© 2008 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Soft-
+ * ware"), to deal in the Software without restriction, including without
+ * limitation the rights to use, copy, modify, merge, publish, distribute,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, provided that the above copyright
+ * notice(s) and this permission notice appear in all copies of the Soft-
+ * ware and that both the above copyright notice(s) and this permission
+ * notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+ * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
+ * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
+ * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
+ * QUENTIAL 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 PERFOR-
+ * MANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder shall
+ * not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization of
+ * the copyright holder.
+ *
+ * Authors:
+ *   Kevin E. Martin <kevin@precisioninsight.com>
+ *   Brian Paul <brian@precisioninsight.com>
+ *   Kristian Høgsberg (krh@redhat.com)
+ */
+
+#ifdef GLX_DIRECT_RENDERING
+
+#include <unistd.h>
+#include <dlfcn.h>
+#include "glheader.h"
+#include "glxclient.h"
+#include "glcontextmodes.h"
+#include "dri_common.h"
+
+#ifndef RTLD_NOW
+#define RTLD_NOW 0
+#endif
+#ifndef RTLD_GLOBAL
+#define RTLD_GLOBAL 0
+#endif
+
+_X_HIDDEN 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);
+    }
+}
+
+/**
+ * Print error to stderr, unless LIBGL_DEBUG=="quiet".
+ */
+_X_HIDDEN void ErrorMessageF(const char *f, ...)
+{
+    va_list args;
+    const char *env;
+
+    if ((env = getenv("LIBGL_DEBUG")) && !strstr(env, "quiet")) {
+       fprintf(stderr, "libGL error: ");
+       va_start(args, f);
+       vfprintf(stderr, f, args);
+       va_end(args);
+    }
+}
+
+#ifndef DEFAULT_DRIVER_DIR
+/* this is normally defined in Mesa/configs/default with DRI_DRIVER_SEARCH_PATH */
+#define DEFAULT_DRIVER_DIR "/usr/local/lib/dri"
+#endif
+
+/**
+ * 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.
+ */
+_X_HIDDEN void *driOpenDriver(const char *driverName)
+{
+   void *glhandle, *handle;
+   const char *libPaths, *p, *next;
+   char realDriverName[200];
+   int len;
+
+   /* Attempt to make sure libGL symbols will be visible to the driver */
+   glhandle = dlopen("libGL.so.1", RTLD_NOW | RTLD_GLOBAL);
+
+   libPaths = NULL;
+   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 == NULL)
+       libPaths = DEFAULT_DRIVER_DIR;
+
+   handle = NULL;
+   for (p = libPaths; *p; p = next) {
+       next = strchr(p, ':');
+       if (next == NULL) {
+          len = strlen(p);
+          next = p + len;
+       } else {
+          len = next - p;
+          next++;
+       }
+
+#ifdef GLX_USE_TLS
+      snprintf(realDriverName, sizeof realDriverName,
+              "%.*s/tls/%s_dri.so", len, p, driverName);
+      InfoMessageF("OpenDriver: trying %s\n", realDriverName);
+      handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL);
+#endif
+
+      if ( handle == NULL ) {
+        snprintf(realDriverName, sizeof realDriverName,
+                 "%.*s/%s_dri.so", len, p, driverName);
+        InfoMessageF("OpenDriver: trying %s\n", realDriverName);
+        handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL);
+      }
+
+      if ( handle != NULL )
+         break;
+      else
+        ErrorMessageF("dlopen %s failed (%s)\n", realDriverName, dlerror());
+   }
+
+   if (!handle)
+      ErrorMessageF("unable to load driver: %s_dri.so\n", driverName);
+
+   if (glhandle)
+      dlclose(glhandle);
+
+   return handle;
+}
+
+_X_HIDDEN const __DRIsystemTimeExtension systemTimeExtension = {
+    { __DRI_SYSTEM_TIME, __DRI_SYSTEM_TIME_VERSION },
+    __glXGetUST,
+    __driGetMscRateOML
+};
+
+#define __ATTRIB(attrib, field) \
+    { attrib, offsetof(__GLcontextModes, field) }
+
+static const struct { unsigned int attrib, offset; } attribMap[] = {
+    __ATTRIB(__DRI_ATTRIB_BUFFER_SIZE,                 rgbBits),
+    __ATTRIB(__DRI_ATTRIB_LEVEL,                       level),
+    __ATTRIB(__DRI_ATTRIB_RED_SIZE,                    redBits),
+    __ATTRIB(__DRI_ATTRIB_GREEN_SIZE,                  greenBits),
+    __ATTRIB(__DRI_ATTRIB_BLUE_SIZE,                   blueBits),
+    __ATTRIB(__DRI_ATTRIB_ALPHA_SIZE,                  alphaBits),
+    __ATTRIB(__DRI_ATTRIB_DEPTH_SIZE,                  depthBits),
+    __ATTRIB(__DRI_ATTRIB_STENCIL_SIZE,                        stencilBits),
+    __ATTRIB(__DRI_ATTRIB_ACCUM_RED_SIZE,              accumRedBits),
+    __ATTRIB(__DRI_ATTRIB_ACCUM_GREEN_SIZE,            accumGreenBits),
+    __ATTRIB(__DRI_ATTRIB_ACCUM_BLUE_SIZE,             accumBlueBits),
+    __ATTRIB(__DRI_ATTRIB_ACCUM_ALPHA_SIZE,            accumAlphaBits),
+    __ATTRIB(__DRI_ATTRIB_SAMPLE_BUFFERS,              sampleBuffers),
+    __ATTRIB(__DRI_ATTRIB_SAMPLES,                     samples),
+    __ATTRIB(__DRI_ATTRIB_DOUBLE_BUFFER,               doubleBufferMode),
+    __ATTRIB(__DRI_ATTRIB_STEREO,                      stereoMode),
+    __ATTRIB(__DRI_ATTRIB_AUX_BUFFERS,                 numAuxBuffers),
+#if 0
+    __ATTRIB(__DRI_ATTRIB_TRANSPARENT_TYPE,            transparentPixel),
+    __ATTRIB(__DRI_ATTRIB_TRANSPARENT_INDEX_VALUE,     transparentIndex),
+    __ATTRIB(__DRI_ATTRIB_TRANSPARENT_RED_VALUE,       transparentRed),
+    __ATTRIB(__DRI_ATTRIB_TRANSPARENT_GREEN_VALUE,     transparentGreen),
+    __ATTRIB(__DRI_ATTRIB_TRANSPARENT_BLUE_VALUE,      transparentBlue),
+    __ATTRIB(__DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE,     transparentAlpha),
+    __ATTRIB(__DRI_ATTRIB_RED_MASK,                    redMask),
+    __ATTRIB(__DRI_ATTRIB_GREEN_MASK,                  greenMask),
+    __ATTRIB(__DRI_ATTRIB_BLUE_MASK,                   blueMask),
+    __ATTRIB(__DRI_ATTRIB_ALPHA_MASK,                  alphaMask),
+#endif
+    __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_WIDTH,           maxPbufferWidth),
+    __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_HEIGHT,          maxPbufferHeight),
+    __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_PIXELS,          maxPbufferPixels),
+    __ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH,       optimalPbufferWidth),
+    __ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT,      optimalPbufferHeight),
+#if 0
+    __ATTRIB(__DRI_ATTRIB_SWAP_METHOD,                 swapMethod),
+#endif
+    __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGB,         bindToTextureRgb),
+    __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGBA,                bindToTextureRgba),
+    __ATTRIB(__DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE,      bindToMipmapTexture),
+    __ATTRIB(__DRI_ATTRIB_YINVERTED,                   yInverted),
+};
+
+#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
+
+static int
+scalarEqual(__GLcontextModes *mode, unsigned int attrib, unsigned int value)
+{
+    unsigned int glxValue;
+    int i;
+
+    for (i = 0; i < ARRAY_SIZE(attribMap); i++)
+       if (attribMap[i].attrib == attrib) {
+           glxValue = *(unsigned int *) ((char *) mode + attribMap[i].offset);
+           return glxValue == GLX_DONT_CARE || glxValue == value;
+       }
+
+    return GL_TRUE; /* Is a non-existing attribute equal to value? */
+}
+
+static int
+driConfigEqual(const __DRIcoreExtension *core,
+              __GLcontextModes *modes, const __DRIconfig *driConfig)
+{
+    unsigned int attrib, value, glxValue;
+    int i;
+
+    i = 0;
+    while (core->indexConfigAttrib(driConfig, i++, &attrib, &value)) {
+       switch (attrib) {
+       case __DRI_ATTRIB_RENDER_TYPE:
+           glxValue = 0;
+           if (value & __DRI_ATTRIB_RGBA_BIT) {
+               glxValue |= GLX_RGBA_BIT;
+           } else if (value & __DRI_ATTRIB_COLOR_INDEX_BIT) {
+               glxValue |= GLX_COLOR_INDEX_BIT;
+           }
+           if (glxValue != modes->renderType)
+               return GL_FALSE;
+           break;
+
+       case __DRI_ATTRIB_CONFIG_CAVEAT:
+           if (value & __DRI_ATTRIB_NON_CONFORMANT_CONFIG)
+               glxValue = GLX_NON_CONFORMANT_CONFIG;
+           else if (value & __DRI_ATTRIB_SLOW_BIT)
+               glxValue = GLX_SLOW_CONFIG;
+           else
+               glxValue = GLX_NONE;
+           if (glxValue != modes->visualRating)
+               return GL_FALSE;
+           break;
+
+       case __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS:
+           glxValue = 0;
+           if (value & __DRI_ATTRIB_TEXTURE_1D_BIT)
+               glxValue |= GLX_TEXTURE_1D_BIT_EXT;
+           if (value & __DRI_ATTRIB_TEXTURE_2D_BIT)
+               glxValue |= GLX_TEXTURE_2D_BIT_EXT;
+           if (value & __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT)
+               glxValue |= GLX_TEXTURE_RECTANGLE_BIT_EXT;
+           if (modes->bindToTextureTargets != GLX_DONT_CARE &&
+               glxValue != modes->bindToTextureTargets)
+               return GL_FALSE;
+           break;      
+
+       default:
+           if (!scalarEqual(modes, attrib, value))
+               return GL_FALSE;
+       }
+    }
+
+    return GL_TRUE;
+}
+
+static __GLcontextModes *
+createDriMode(const __DRIcoreExtension *core,
+             __GLcontextModes *modes, const __DRIconfig **driConfigs)
+{
+    __GLXDRIconfigPrivate *config;
+    int i;
+
+    for (i = 0; driConfigs[i]; i++) {
+       if (driConfigEqual(core, modes, driConfigs[i]))
+           break;
+    }
+
+    if (driConfigs[i] == NULL)
+       return NULL;
+
+    config = Xmalloc(sizeof *config);
+    if (config == NULL)
+       return NULL;
+
+    config->modes = *modes;
+    config->driConfig = driConfigs[i];
+
+    return &config->modes;
+}
+
+_X_HIDDEN __GLcontextModes *
+driConvertConfigs(const __DRIcoreExtension *core,
+                 __GLcontextModes *modes, const __DRIconfig **configs)
+{
+    __GLcontextModes head, *tail, *m;
+
+    tail = &head;
+    head.next = NULL;
+    for (m = modes; m; m = m->next) {
+       tail->next = createDriMode(core, m, configs);
+       if (tail->next == NULL) {
+           /* no matching dri config for m */
+           continue;
+       }
+
+
+       tail = tail->next;
+    }
+
+    _gl_context_modes_destroy(modes);
+
+    return head.next;
+}
+
+_X_HIDDEN void
+driBindExtensions(__GLXscreenConfigs *psc, int dri2)
+{
+    const __DRIextension **extensions;
+    int i;
+
+    extensions = psc->core->getExtensions(psc->__driScreen);
+
+    for (i = 0; extensions[i]; i++) {
+#ifdef __DRI_COPY_SUB_BUFFER
+       if (strcmp(extensions[i]->name, __DRI_COPY_SUB_BUFFER) == 0) {
+           psc->copySubBuffer = (__DRIcopySubBufferExtension *) extensions[i];
+           __glXEnableDirectExtension(psc, "GLX_MESA_copy_sub_buffer_bit");
+       }
+#endif
+
+#ifdef __DRI_SWAP_CONTROL
+       if (strcmp(extensions[i]->name, __DRI_SWAP_CONTROL) == 0) {
+           psc->swapControl = (__DRIswapControlExtension *) extensions[i];
+           __glXEnableDirectExtension(psc, "GLX_SGI_swap_control");
+           __glXEnableDirectExtension(psc, "GLX_MESA_swap_control");
+       }
+#endif
+
+#ifdef __DRI_ALLOCATE
+       if (strcmp(extensions[i]->name, __DRI_ALLOCATE) == 0) {
+           psc->allocate = (__DRIallocateExtension *) extensions[i];
+           __glXEnableDirectExtension(psc, "GLX_MESA_allocate_memory");
+       }
+#endif
+
+#ifdef __DRI_FRAME_TRACKING
+       if (strcmp(extensions[i]->name, __DRI_FRAME_TRACKING) == 0) {
+           psc->frameTracking = (__DRIframeTrackingExtension *) extensions[i];
+           __glXEnableDirectExtension(psc, "GLX_MESA_swap_frame_usage");
+       }
+#endif
+
+#ifdef __DRI_MEDIA_STREAM_COUNTER
+       if (strcmp(extensions[i]->name, __DRI_MEDIA_STREAM_COUNTER) == 0) {
+           psc->msc = (__DRImediaStreamCounterExtension *) extensions[i];
+           __glXEnableDirectExtension(psc, "GLX_SGI_video_sync");
+       }
+#endif
+
+#ifdef __DRI_SWAP_BUFFER_COUNTER
+       /* No driver supports this at this time and the extension is
+        * not defined in dri_interface.h.  Will enable
+        * GLX_OML_sync_control if implemented. */
+#endif
+
+#ifdef __DRI_READ_DRAWABLE
+       if (strcmp(extensions[i]->name, __DRI_READ_DRAWABLE) == 0) {
+           __glXEnableDirectExtension(psc, "GLX_SGI_make_current_read");
+       }
+#endif
+
+#ifdef __DRI_TEX_BUFFER
+       if ((strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0) && dri2) {
+           psc->texBuffer = (__DRItexBufferExtension *) extensions[i];
+           __glXEnableDirectExtension(psc, "GLX_EXT_texture_from_pixmap");
+       }
+#endif
+
+       /* Ignore unknown extensions */
+    }
+}
+
+#endif /* GLX_DIRECT_RENDERING */
diff --git a/src/glx/x11/dri_common.h b/src/glx/x11/dri_common.h
new file mode 100644 (file)
index 0000000..15f6cc8
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright Â© 2008 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Soft-
+ * ware"), to deal in the Software without restriction, including without
+ * limitation the rights to use, copy, modify, merge, publish, distribute,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, provided that the above copyright
+ * notice(s) and this permission notice appear in all copies of the Soft-
+ * ware and that both the above copyright notice(s) and this permission
+ * notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+ * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
+ * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
+ * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
+ * QUENTIAL 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 PERFOR-
+ * MANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder shall
+ * not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization of
+ * the copyright holder.
+ *
+ * Authors:
+ *   Kevin E. Martin <kevin@precisioninsight.com>
+ *   Brian Paul <brian@precisioninsight.com>
+ *   Kristian Høgsberg (krh@redhat.com)
+ */
+
+#ifndef _DRI_COMMON_H
+#define _DRI_COMMON_H
+
+typedef struct __GLXDRIconfigPrivateRec  __GLXDRIconfigPrivate;
+
+struct __GLXDRIconfigPrivateRec {
+    __GLcontextModes modes;
+    const __DRIconfig *driConfig;
+};
+
+extern __GLcontextModes *
+driConvertConfigs(const __DRIcoreExtension *core,
+                 __GLcontextModes *modes, const __DRIconfig **configs);
+
+extern const __DRIsystemTimeExtension systemTimeExtension;
+
+extern void InfoMessageF(const char *f, ...);
+
+extern void ErrorMessageF(const char *f, ...);
+
+extern void *driOpenDriver(const char *driverName);
+
+extern void driBindExtensions(__GLXscreenConfigs *psc, int dri2);
+
+#endif /* _DRI_COMMON_H */
index e637c96ac9b1371077b688d0b0b1bf1347b4bd03..39bf6c430b03601f27301e55ee67cf1b28b5d572 100644 (file)
@@ -34,294 +34,47 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #ifdef GLX_DIRECT_RENDERING
 
-#include <unistd.h>
-#include <X11/Xlibint.h>
-#include <X11/extensions/Xext.h>
-#include <X11/extensions/extutil.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/Xfixes.h>
+#include <X11/extensions/Xdamage.h>
 #include "glheader.h"
 #include "glxclient.h"
+#include "glcontextmodes.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 Mesa/configs/default with DRI_DRIVER_SEARCH_PATH */
-#define DEFAULT_DRIVER_DIR "/usr/X11R6/lib/modules/dri"
-#endif
-
-static __DRIdriver *Drivers = NULL;
-
-
-/** If non-zero, prefer an "egl_foo_dri.so" driver over "foo_dri.so" */
-static int PreferEGL = 0;
-
-
-/**
- * This may be called by libEGL.so to tell libGL to prefer "egl_" drivers
- * over regular DRI drivers".
- */
-void __glXPreferEGL(int state)
-{
-   PreferEGL = state;
-}
-
-
-/*
- * 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);
-    }
-}
-
-/**
- * Print error to stderr, unless LIBGL_DEBUG=="quiet".
- */
-static void ErrorMessageF(const char *f, ...)
-{
-    va_list args;
-    const char *env;
-
-    if ((env = getenv("LIBGL_DEBUG")) && !strstr(env, "quiet")) {
-       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 );
-}
-
-
-/**
- * Try to dlopen() a driver.
- * \param libDir  the directory to search
- * \param driverName  the name of the driver (such as "r300").
- * \param tls  if true, try to find TLS version of driver
- * \param preferEGL  if true, try to find EGL-specific driver
- * \return  handle from dlopen(), will be NULL if fails.
- */
-static void *
-try_open(const char *libDir, const char *driverName,
-         GLboolean tls, GLboolean preferEGL)
-{
-   const char *tlsDir = tls ? "/tls/" : "";
-   const char *eglPrefix = preferEGL ? "egl_" : "";
-   char fullPathName[200];
-   void *handle = NULL;
-
-   snprintf(fullPathName, 200, "%s%s/%s%s_dri.so",
-            libDir, tlsDir, eglPrefix, driverName);
-   InfoMessageF("OpenDriver: trying %s\n", fullPathName);
-   handle = dlopen(fullPathName, RTLD_NOW | RTLD_GLOBAL);
-
-   return handle;
-}
-
-
-
-/**
- * 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)
-{
-   void *glhandle = NULL;
-   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;
-      }
-   }
-
-   /* Attempt to make sure libGL symbols will be visible to the driver */
-   glhandle = dlopen("libGL.so.1", RTLD_NOW | RTLD_GLOBAL);
-
-   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++ ) {
-      void *handle = NULL;
-
-      if (PreferEGL)
-         handle = try_open(libDir, driverName, GL_FALSE, GL_TRUE);
-#ifdef GLX_USE_TLS
-      if (!handle)
-         handle = try_open(libDir, driverName, GL_TRUE, GL_FALSE);
-#endif
-      if (!handle)
-         handle = try_open(libDir, driverName, GL_FALSE, GL_FALSE);
-
-      if ( handle != NULL ) {
-         /* allocate __DRIdriver struct */
-         driver = (__DRIdriver *) Xmalloc(sizeof(__DRIdriver));
-         if (!driver)
-            break; /* out of memory! */
-         /* init the struct */
-         driver->name = __glXstrdup(driverName);
-         if (!driver->name) {
-            Xfree(driver);
-            driver = NULL;
-            break; /* 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);
-            driver = NULL;
-            dlclose(handle);
-            continue;
-         }
-         driver->handle = handle;
-         /* put at head of linked list */
-         driver->next = Drivers;
-         Drivers = driver;
-         break;
-      }
-      else {
-        ErrorMessageF("Unable to find/open driver for %s (%s)\n",
-                       driverName, dlerror());
-      }
-   }
-
-   if (!driver)
-      ErrorMessageF("unable to load driver: %s_dri.so\n", driverName);
-
-   if (glhandle)
-      dlclose(glhandle);
-
-   return driver;
-}
-
+#include <sys/mman.h>
+#include "xf86drm.h"
+#include "dri_common.h"
+
+typedef struct __GLXDRIdisplayPrivateRec __GLXDRIdisplayPrivate;
+typedef struct __GLXDRIcontextPrivateRec __GLXDRIcontextPrivate;
+
+struct __GLXDRIdisplayPrivateRec {
+    __GLXDRIdisplay base;
+
+    /*
+    ** XFree86-DRI version information
+    */
+    int driMajor;
+    int driMinor;
+    int driPatch;
+};
+
+struct __GLXDRIcontextPrivateRec {
+    __GLXDRIcontext base;
+    __DRIcontext *driContext;
+    XID hwContextID;
+    __GLXscreenConfigs *psc;
+};
 
 /*
  * 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)
+static Bool driGetDriverName(Display *dpy, int scrNum, char **driverName)
 {
    int directCapable;
    Bool b;
@@ -351,25 +104,6 @@ static Bool GetDriverName(Display *dpy, int scrNum, char **driverName)
    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.
  *
@@ -379,7 +113,7 @@ __DRIdriver *driGetDriver(Display *dpy, int scrNum)
 PUBLIC const char *glXGetScreenDriver (Display *dpy, int scrNum) {
    static char ret[32];
    char *driverName;
-   if (GetDriverName(dpy, scrNum, &driverName)) {
+   if (driGetDriverName(dpy, scrNum, &driverName)) {
       int len;
       if (!driverName)
         return NULL;
@@ -393,7 +127,6 @@ PUBLIC const char *glXGetScreenDriver (Display *dpy, int scrNum) {
    return NULL;
 }
 
-
 /*
  * Exported function for obtaining a driver's option list (UTF-8 encoded XML).
  *
@@ -405,71 +138,536 @@ PUBLIC const char *glXGetScreenDriver (Display *dpy, int scrNum) {
  *
  * Note: The driver remains opened after this function returns.
  */
-PUBLIC const char *glXGetDriverConfig (const char *driverName) {
-   __DRIdriver *driver = OpenDriver (driverName);
-   if (driver)
-      return dlsym (driver->handle, "__driConfigOptions");
+PUBLIC const char *glXGetDriverConfig (const char *driverName)
+{
+   void *handle = driOpenDriver (driverName);
+   if (handle)
+      return dlsym (handle, "__driConfigOptions");
    else
       return NULL;
 }
 
+#ifdef XDAMAGE_1_1_INTERFACE
 
-/* Called from __glXFreeDisplayPrivate.
+static GLboolean has_damage_post(Display *dpy)
+{
+    static GLboolean inited = GL_FALSE;
+    static GLboolean has_damage;
+
+    if (!inited) {
+       int major, minor;
+
+       if (XDamageQueryVersion(dpy, &major, &minor) &&
+           major == 1 && minor >= 1)
+       {
+           has_damage = GL_TRUE;
+       } else {
+           has_damage = GL_FALSE;
+       }
+       inited = GL_TRUE;
+    }
+
+    return has_damage;
+}
+
+static void __glXReportDamage(__DRIdrawable *driDraw,
+                             int x, int y,
+                             drm_clip_rect_t *rects, int num_rects,
+                             GLboolean front_buffer,
+                             void *loaderPrivate)
+{
+    XRectangle *xrects;
+    XserverRegion region;
+    int i;
+    int x_off, y_off;
+    __GLXDRIdrawable *glxDraw = loaderPrivate;
+    __GLXscreenConfigs *psc = glxDraw->psc;
+    Display *dpy = psc->dpy;
+    Drawable drawable;
+
+    if (!has_damage_post(dpy))
+       return;
+
+    if (front_buffer) {
+       x_off = x;
+       y_off = y;
+       drawable = RootWindow(dpy, psc->scr);
+    } else{
+       x_off = 0;
+       y_off = 0;
+       drawable = glxDraw->xDrawable;
+    }
+
+    xrects = malloc(sizeof(XRectangle) * num_rects);
+    if (xrects == NULL)
+       return;
+
+    for (i = 0; i < num_rects; i++) {
+       xrects[i].x = rects[i].x1 + x_off;
+       xrects[i].y = rects[i].y1 + y_off;
+       xrects[i].width = rects[i].x2 - rects[i].x1;
+       xrects[i].height = rects[i].y2 - rects[i].y1;
+    }
+    region = XFixesCreateRegion(dpy, xrects, num_rects);
+    free(xrects);
+    XDamageAdd(dpy, drawable, region);
+    XFixesDestroyRegion(dpy, region);
+}
+
+static const __DRIdamageExtension damageExtension = {
+    { __DRI_DAMAGE, __DRI_DAMAGE_VERSION },
+    __glXReportDamage,
+};
+
+#endif
+
+static GLboolean
+__glXDRIGetDrawableInfo(__DRIdrawable *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,
+                       void *loaderPrivate)
+{
+    __GLXDRIdrawable *glxDraw = loaderPrivate;
+    __GLXscreenConfigs *psc = glxDraw->psc;
+    Display *dpy = psc->dpy;
+
+    return XF86DRIGetDrawableInfo(dpy, psc->scr, glxDraw->drawable,
+                                 index, stamp, X, Y, W, H,
+                                 numClipRects, pClipRects,
+                                 backX, backY,
+                                 numBackClipRects, pBackClipRects);
+}
+
+static const __DRIgetDrawableInfoExtension getDrawableInfoExtension = {
+    { __DRI_GET_DRAWABLE_INFO, __DRI_GET_DRAWABLE_INFO_VERSION },
+    __glXDRIGetDrawableInfo
+};
+
+static const __DRIextension *loader_extensions[] = {
+    &systemTimeExtension.base,
+    &getDrawableInfoExtension.base,
+#ifdef XDAMAGE_1_1_INTERFACE
+    &damageExtension.base,
+#endif
+    NULL
+};
+
+#ifndef GLX_USE_APPLEGL
+
+/**
+ * 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.
  */
-static void driDestroyDisplay(Display *dpy, void *private)
+static void *
+CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
+                   __GLXDRIdisplayPrivate * driDpy)
+{
+    void *psp = NULL;
+    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;
+
+    drm_magic_t magic;
+    drmVersionPtr version;
+    int newlyopened;
+    char *driverName;
+    drm_handle_t  hFB;
+    int        junk;
+    const __DRIconfig **driver_configs;
+
+    /* DRI protocol version. */
+    dri_version.major = driDpy->driMajor;
+    dri_version.minor = driDpy->driMinor;
+    dri_version.patch = driDpy->driPatch;
+
+    framebuffer.base = MAP_FAILED;
+    framebuffer.dev_priv = NULL;
+
+    if (!XF86DRIOpenConnection(dpy, scrn, &hSAREA, &BusID)) {
+       ErrorMessageF("XF86DRIOpenConnection failed\n");
+       goto handle_error;
+    }
+
+    fd = drmOpenOnce(NULL, BusID, &newlyopened);
+
+    Xfree(BusID); /* No longer needed */
+
+    if (fd < 0) {
+       ErrorMessageF("drmOpenOnce failed (%s)\n", strerror(-fd));
+       goto handle_error;
+    }
+
+    if (drmGetMagic(fd, &magic)) {
+       ErrorMessageF("drmGetMagic failed\n");
+       goto handle_error;
+    }
+
+    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;
+    }
+
+    if (newlyopened && !XF86DRIAuthConnection(dpy, scrn, magic)) {
+       ErrorMessageF("XF86DRIAuthConnection failed\n");
+       goto handle_error;
+    }
+
+    /* Get device name (like "tdfx") and the ddx version numbers.
+     * We'll check the version in each DRI driver's "createNewScreen"
+     * function. */
+    if (!XF86DRIGetClientDriverName(dpy, scrn,
+                                   &ddx_version.major,
+                                   &ddx_version.minor,
+                                   &ddx_version.patch,
+                                   &driverName)) {
+       ErrorMessageF("XF86DRIGetClientDriverName failed\n");
+       goto handle_error;
+    }
+
+    Xfree(driverName); /* No longer needed. */
+
+    /*
+     * 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.
+     */
+    if (!XF86DRIGetDeviceInfo(dpy, scrn, &hFB, &junk,
+                             &framebuffer.size, &framebuffer.stride,
+                             &framebuffer.dev_priv_size, &framebuffer.dev_priv)) {
+       ErrorMessageF("XF86DRIGetDeviceInfo failed");
+       goto handle_error;
+    }
+
+    framebuffer.width = DisplayWidth(dpy, scrn);
+    framebuffer.height = DisplayHeight(dpy, scrn);
+
+    /* Map the framebuffer region. */
+    status = drmMap(fd, hFB, framebuffer.size, 
+                   (drmAddressPtr)&framebuffer.base);
+    if (status != 0) {
+       ErrorMessageF("drmMap of framebuffer failed (%s)", strerror(-status));
+       goto handle_error;
+    }
+
+    /* Map the SAREA region.  Further mmap regions may be setup in
+     * each DRI driver's "createNewScreen" function.
+     */
+    status = drmMap(fd, hSAREA, SAREA_MAX, &pSAREA);
+    if (status != 0) {
+       ErrorMessageF("drmMap of SAREA failed (%s)", strerror(-status));
+       goto handle_error;
+    }
+
+    psp = (*psc->legacy->createNewScreen)(scrn,
+                                         &ddx_version,
+                                         &dri_version,
+                                         &drm_version,
+                                         &framebuffer,
+                                         pSAREA,
+                                         fd,
+                                         loader_extensions,
+                                         &driver_configs,
+                                         psc);
+
+    if (psp == NULL) {
+       ErrorMessageF("Calling driver entry point failed");
+       goto handle_error;
+    }
+
+    psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs);
+    psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);
+
+    return psp;
+
+ handle_error:
+    if (pSAREA != MAP_FAILED)
+       drmUnmap(pSAREA, SAREA_MAX);
+
+    if (framebuffer.base != MAP_FAILED)
+       drmUnmap((drmAddress)framebuffer.base, framebuffer.size);
+
+    if (framebuffer.dev_priv != NULL)
+       Xfree(framebuffer.dev_priv);
+
+    if (fd >= 0)
+       drmCloseOnce(fd);
+
+    XF86DRICloseConnection(dpy, scrn);
+
+    ErrorMessageF("reverting to software direct rendering\n");
+
+    return NULL;
+}
+
+#else /* !GLX_USE_APPLEGL */
+
+static void *
+CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
+                   __GLXDRIdisplayPrivate * driDpy)
+{
+    return NULL;
+}
+
+#endif /* !GLX_USE_APPLEGL */
+
+static void driDestroyContext(__GLXDRIcontext *context,
+                             __GLXscreenConfigs *psc, Display *dpy)
+{
+    __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
+                       
+    (*psc->core->destroyContext)(pcp->driContext);
+
+    XF86DRIDestroyContext(psc->dpy, psc->scr, pcp->hwContextID);
+    Xfree(pcp);
+}
+
+static Bool driBindContext(__GLXDRIcontext *context,
+                          __GLXDRIdrawable *draw, __GLXDRIdrawable *read)
+{
+    __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
+    const __DRIcoreExtension *core = pcp->psc->core;
+
+    return (*core->bindContext)(pcp->driContext,
+                               draw->driDrawable,
+                               read->driDrawable);
+}
+
+static void driUnbindContext(__GLXDRIcontext *context)
 {
-    __DRIdisplayPrivate *pdpyp = (__DRIdisplayPrivate *)private;
-
-    if (pdpyp) {
-        const int numScreens = ScreenCount(dpy);
-        int i;
-        for (i = 0; i < numScreens; i++) {
-          if (pdpyp->libraryHandles[i]) {
-             __DRIdriver *driver, *prev;
-
-             /* Remove driver from Drivers list */
-             for (prev = NULL, driver = Drivers; driver;
-                  prev = driver, driver = driver->next) {
-                if (driver->handle == pdpyp->libraryHandles[i]) {
-                   if (prev)
-                      prev->next = driver->next;
-                   else
-                      Drivers = driver->next;
-
-                   Xfree((void *) driver->name);
-                   Xfree(driver);
-                   break;
-                }
-             }
-
-             dlclose(pdpyp->libraryHandles[i]);
-          }
-        }
-        Xfree(pdpyp->libraryHandles);
-       Xfree(pdpyp);
+    __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
+    const __DRIcoreExtension *core = pcp->psc->core;
+
+    (*core->unbindContext)(pcp->driContext);
+}
+
+static __GLXDRIcontext *driCreateContext(__GLXscreenConfigs *psc,
+                                        const __GLcontextModes *mode,
+                                        GLXContext gc,
+                                        GLXContext shareList, int renderType)
+{
+    __GLXDRIcontextPrivate *pcp, *pcp_shared;
+    drm_context_t hwContext;
+    __DRIcontext *shared = NULL;
+    __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode;
+
+    if (!psc || !psc->driScreen)
+       return NULL;
+
+    if (shareList) {
+       pcp_shared = (__GLXDRIcontextPrivate *) shareList->driContext;
+       shared = pcp_shared->driContext;
     }
+
+    pcp = Xmalloc(sizeof *pcp);
+    if (pcp == NULL)
+       return NULL;
+
+    pcp->psc = psc;
+    if (!XF86DRICreateContextWithConfig(psc->dpy, psc->scr,
+                                       mode->visualID,
+                                       &pcp->hwContextID, &hwContext)) {
+       Xfree(pcp);
+       return NULL;
+    }
+
+    pcp->driContext =
+        (*psc->legacy->createNewContext)(psc->__driScreen,
+                                        config->driConfig,
+                                        renderType,
+                                        shared,
+                                        hwContext,
+                                        pcp);
+    if (pcp->driContext == NULL) {
+       XF86DRIDestroyContext(psc->dpy, psc->scr, pcp->hwContextID);
+       Xfree(pcp);
+       return NULL;
+    }
+
+    pcp->base.destroyContext = driDestroyContext;
+    pcp->base.bindContext = driBindContext;
+    pcp->base.unbindContext = driUnbindContext;
+
+    return &pcp->base;
+}
+
+static void driDestroyDrawable(__GLXDRIdrawable *pdraw)
+{
+    __GLXscreenConfigs *psc = pdraw->psc;
+
+    (*psc->core->destroyDrawable)(pdraw->driDrawable);
+    XF86DRIDestroyDrawable(psc->dpy, psc->scr, pdraw->drawable);
+    Xfree(pdraw);
+}
+
+static __GLXDRIdrawable *driCreateDrawable(__GLXscreenConfigs *psc,
+                                          XID xDrawable,
+                                          GLXDrawable drawable,
+                                          const __GLcontextModes *modes)
+{
+    __GLXDRIdrawable *pdraw;
+    drm_drawable_t hwDrawable;
+    void *empty_attribute_list = NULL;
+    __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
+
+    /* Old dri can't handle GLX 1.3+ drawable constructors. */
+    if (xDrawable != drawable)
+       return NULL;
+
+    pdraw = Xmalloc(sizeof(*pdraw));
+    if (!pdraw)
+       return NULL;
+
+    pdraw->drawable = drawable;
+    pdraw->psc = psc;
+
+    if (!XF86DRICreateDrawable(psc->dpy, psc->scr, drawable, &hwDrawable))
+       return NULL;
+
+    /* Create a new drawable */
+    pdraw->driDrawable =
+       (*psc->legacy->createNewDrawable)(psc->__driScreen,
+                                         config->driConfig,
+                                         hwDrawable,
+                                         GLX_WINDOW_BIT,
+                                         empty_attribute_list,
+                                         pdraw);
+
+    if (!pdraw->driDrawable) {
+       XF86DRIDestroyDrawable(psc->dpy, psc->scr, drawable);
+       Xfree(pdraw);
+       return NULL;
+    }
+
+    pdraw->destroyDrawable = driDestroyDrawable;
+
+    return pdraw;
+}
+
+static void driSwapBuffers(__GLXDRIdrawable *pdraw)
+{
+   (*pdraw->psc->core->swapBuffers)(pdraw->driDrawable);
+}
+
+static void driDestroyScreen(__GLXscreenConfigs *psc)
+{
+    /* Free the direct rendering per screen data */
+    if (psc->__driScreen)
+       (*psc->core->destroyScreen)(psc->__driScreen);
+    psc->__driScreen = NULL;
+    if (psc->driver)
+       dlclose(psc->driver);
+}
+
+static __GLXDRIscreen *driCreateScreen(__GLXscreenConfigs *psc, int screen,
+                                      __GLXdisplayPrivate *priv)
+{
+    __GLXDRIdisplayPrivate *pdp;
+    __GLXDRIscreen *psp;
+    const __DRIextension **extensions;
+    char *driverName;
+    int i;
+
+    psp = Xmalloc(sizeof *psp);
+    if (psp == NULL)
+       return NULL;
+
+    /* Initialize per screen dynamic client GLX extensions */
+    psc->ext_list_first_time = GL_TRUE;
+
+    if (!driGetDriverName(priv->dpy, screen, &driverName)) {
+       Xfree(psp);
+       return NULL;
+    }
+
+    psc->driver = driOpenDriver(driverName);
+    Xfree(driverName);
+    if (psc->driver == NULL) {
+       Xfree(psp);
+       return NULL;
+    }
+
+    extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS);
+    if (extensions == NULL) {
+       ErrorMessageF("driver exports no extensions (%s)\n", dlerror());
+       Xfree(psp);
+       return NULL;
+    }
+
+    for (i = 0; extensions[i]; i++) {
+       if (strcmp(extensions[i]->name, __DRI_CORE) == 0)
+           psc->core = (__DRIcoreExtension *) extensions[i];
+       if (strcmp(extensions[i]->name, __DRI_LEGACY) == 0)
+           psc->legacy = (__DRIlegacyExtension *) extensions[i];
+    }
+
+    if (psc->core == NULL || psc->legacy == NULL) {
+       Xfree(psp);
+       return NULL;
+    }
+  
+    pdp = (__GLXDRIdisplayPrivate *) priv->driDisplay;
+    psc->__driScreen =
+       CallCreateNewScreen(psc->dpy, screen, psc, pdp);
+    if (psc->__driScreen == NULL) {
+       dlclose(psc->driver);
+       Xfree(psp);
+       return NULL;
+    }
+
+    driBindExtensions(psc, 0);
+
+    psp->destroyScreen = driDestroyScreen;
+    psp->createContext = driCreateContext;
+    psp->createDrawable = driCreateDrawable;
+    psp->swapBuffers = driSwapBuffers;
+
+    return psp;
 }
 
+/* Called from __glXFreeDisplayPrivate.
+ */
+static void driDestroyDisplay(__GLXDRIdisplay *dpy)
+{
+    Xfree(dpy);
+}
 
 /*
  * 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)
+_X_HIDDEN __GLXDRIdisplay *driCreateDisplay(Display *dpy)
 {
-    const int numScreens = ScreenCount(dpy);
-    __DRIdisplayPrivate *pdpyp;
+    __GLXDRIdisplayPrivate *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;
@@ -479,7 +677,7 @@ void *driCreateDisplay(Display *dpy, __DRIdisplay *pdisp)
        return NULL;
     }
 
-    pdpyp = (__DRIdisplayPrivate *)Xmalloc(sizeof(__DRIdisplayPrivate));
+    pdpyp = Xmalloc(sizeof *pdpyp);
     if (!pdpyp) {
        return NULL;
     }
@@ -488,41 +686,10 @@ void *driCreateDisplay(Display *dpy, __DRIdisplay *pdisp)
     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;
-        }
-    }
+    pdpyp->base.destroyDisplay = driDestroyDisplay;
+    pdpyp->base.createScreen = driCreateScreen;
 
-    return (void *)pdpyp;
+    return &pdpyp->base;
 }
 
 #endif /* GLX_DIRECT_RENDERING */
diff --git a/src/glx/x11/dri_glx.h b/src/glx/x11/dri_glx.h
deleted file mode 100644 (file)
index 7556168..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/**************************************************************************
-
-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/src/glx/x11/drisw_glx.c b/src/glx/x11/drisw_glx.c
new file mode 100644 (file)
index 0000000..ad7b5eb
--- /dev/null
@@ -0,0 +1,447 @@
+/*
+ * Copyright 2008 George Sapountzis
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+ */
+
+#ifdef GLX_DIRECT_RENDERING
+
+#include <X11/Xlib.h>
+#include "glheader.h"
+#include "glxclient.h"
+#include "glcontextmodes.h"
+#include <dlfcn.h>
+#include "dri_common.h"
+
+typedef struct __GLXDRIdisplayPrivateRec __GLXDRIdisplayPrivate;
+typedef struct __GLXDRIcontextPrivateRec __GLXDRIcontextPrivate;
+typedef struct __GLXDRIdrawablePrivateRec __GLXDRIdrawablePrivate;
+
+struct __GLXDRIdisplayPrivateRec {
+    __GLXDRIdisplay base;
+};
+
+struct __GLXDRIcontextPrivateRec {
+    __GLXDRIcontext base;
+    __DRIcontext *driContext;
+    __GLXscreenConfigs *psc;
+};
+
+struct __GLXDRIdrawablePrivateRec {
+    __GLXDRIdrawable base;
+
+    GC gc;
+    GC swapgc;
+
+    XVisualInfo *visinfo;
+    XImage *ximage;
+    int bpp;
+};
+
+/**
+ * swrast loader functions
+ */
+
+static Bool XCreateDrawable(__GLXDRIdrawablePrivate *pdp,
+                           Display *dpy, XID drawable, int visualid)
+{
+    XGCValues gcvalues;
+    long visMask;
+    XVisualInfo visTemp;
+    int num_visuals;
+
+    /* create GC's */
+    pdp->gc = XCreateGC(dpy, drawable, 0, NULL);
+    pdp->swapgc = XCreateGC(dpy, drawable, 0, NULL);
+
+    gcvalues.function = GXcopy;
+    gcvalues.graphics_exposures = False;
+    XChangeGC(dpy, pdp->gc, GCFunction, &gcvalues);
+    XChangeGC(dpy, pdp->swapgc, GCFunction, &gcvalues);
+    XChangeGC(dpy, pdp->swapgc, GCGraphicsExposures, &gcvalues);
+
+    /* create XImage  */
+    visTemp.screen = DefaultScreen(dpy);
+    visTemp.visualid = visualid;
+    visMask = (VisualScreenMask | VisualIDMask);
+    pdp->visinfo = XGetVisualInfo(dpy, visMask, &visTemp, &num_visuals);
+
+    pdp->ximage = XCreateImage(dpy,
+                              pdp->visinfo->visual,
+                              pdp->visinfo->depth,
+                              ZPixmap, 0,   /* format, offset */
+                              NULL,         /* data */
+                              0, 0,         /* size */
+                              32,           /* bitmap_pad */
+                              0);           /* bytes_per_line */
+
+    /* get the true number of bits per pixel */
+    pdp->bpp = pdp->ximage->bits_per_pixel;
+
+    return True;
+}
+
+static void XDestroyDrawable(__GLXDRIdrawablePrivate *pdp,
+                            Display *dpy, XID drawable)
+{
+    XDestroyImage(pdp->ximage);
+    XFree(pdp->visinfo);
+
+    XFreeGC(dpy, pdp->gc);
+    XFreeGC(dpy, pdp->swapgc);
+}
+
+static void
+swrastGetDrawableInfo(__DRIdrawable *draw,
+                     int *x, int *y, int *w, int *h,
+                     void *loaderPrivate)
+{
+    __GLXDRIdrawablePrivate *pdp = loaderPrivate;
+    __GLXDRIdrawable *pdraw = &(pdp->base);;
+    Display *dpy = pdraw->psc->dpy;
+    Drawable drawable;
+
+    Window root;
+    Status stat;
+    unsigned int bw, depth;
+
+    drawable = pdraw->xDrawable;
+
+    stat = XGetGeometry(dpy, drawable, &root,
+                       x, y, (unsigned int *)w, (unsigned int *)h,
+                       &bw, &depth);
+}
+
+static inline int
+bytes_per_line(int w, int bpp, unsigned mul)
+{
+    unsigned mask = mul - 1;
+
+    return ((w * bpp + mask) & ~mask) / 8;
+}
+
+static void
+swrastPutImage(__DRIdrawable *draw, int op,
+              int x, int y, int w, int h, char *data,
+              void *loaderPrivate)
+{
+    __GLXDRIdrawablePrivate *pdp = loaderPrivate;
+    __GLXDRIdrawable *pdraw = &(pdp->base);;
+    Display *dpy = pdraw->psc->dpy;
+    Drawable drawable;
+    XImage *ximage;
+    GC gc;
+
+    switch (op) {
+    case __DRI_SWRAST_IMAGE_OP_DRAW:
+       gc = pdp->gc;
+       break;
+    case __DRI_SWRAST_IMAGE_OP_SWAP:
+       gc = pdp->swapgc;
+       break;
+    default:
+       return;
+    }
+
+    drawable = pdraw->xDrawable;
+
+    ximage = pdp->ximage;
+    ximage->data = data;
+    ximage->width = w;
+    ximage->height = h;
+    ximage->bytes_per_line = bytes_per_line(w, pdp->bpp, 32);
+
+    XPutImage(dpy, drawable, gc, ximage, 0, 0, x, y, w, h);
+
+    ximage->data = NULL;
+}
+
+static void
+swrastGetImage(__DRIdrawable *draw,
+              int x, int y, int w, int h, char *data,
+              void *loaderPrivate)
+{
+    __GLXDRIdrawablePrivate *pdp = loaderPrivate;
+    __GLXDRIdrawable *pdraw = &(pdp->base);;
+    Display *dpy = pdraw->psc->dpy;
+    Drawable drawable;
+    XImage *ximage;
+
+    drawable = pdraw->xDrawable;
+
+    ximage = pdp->ximage;
+    ximage->data = data;
+    ximage->width = w;
+    ximage->height = h;
+    ximage->bytes_per_line = bytes_per_line(w, pdp->bpp, 32);
+
+    XGetSubImage(dpy, drawable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0);
+
+    ximage->data = NULL;
+}
+
+static const __DRIswrastLoaderExtension swrastLoaderExtension = {
+    { __DRI_SWRAST_LOADER, __DRI_SWRAST_LOADER_VERSION },
+    swrastGetDrawableInfo,
+    swrastPutImage,
+    swrastGetImage
+};
+
+static const __DRIextension *loader_extensions[] = {
+    &systemTimeExtension.base,
+    &swrastLoaderExtension.base,
+    NULL
+};
+
+/**
+ * GLXDRI functions
+ */
+
+static void driDestroyContext(__GLXDRIcontext *context,
+                             __GLXscreenConfigs *psc, Display *dpy)
+{
+    __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
+    const __DRIcoreExtension *core = pcp->psc->core;
+
+    (*core->destroyContext)(pcp->driContext);
+
+    Xfree(pcp);
+}
+
+static Bool driBindContext(__GLXDRIcontext *context,
+                          __GLXDRIdrawable *draw, __GLXDRIdrawable *read)
+{
+    __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
+    const __DRIcoreExtension *core = pcp->psc->core;
+
+    return (*core->bindContext)(pcp->driContext,
+                               draw->driDrawable,
+                               read->driDrawable);
+}
+
+static void driUnbindContext(__GLXDRIcontext *context)
+{
+    __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
+    const __DRIcoreExtension *core = pcp->psc->core;
+
+    (*core->unbindContext)(pcp->driContext);
+}
+
+static __GLXDRIcontext *driCreateContext(__GLXscreenConfigs *psc,
+                                        const __GLcontextModes *mode,
+                                        GLXContext gc,
+                                        GLXContext shareList, int renderType)
+{
+    __GLXDRIcontextPrivate *pcp, *pcp_shared;
+    __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode;
+    const __DRIcoreExtension *core = psc->core;
+    __DRIcontext *shared = NULL;
+
+    if (!psc || !psc->driScreen)
+       return NULL;
+
+    if (shareList) {
+       pcp_shared = (__GLXDRIcontextPrivate *) shareList->driContext;
+       shared = pcp_shared->driContext;
+    }
+
+    pcp = Xmalloc(sizeof *pcp);
+    if (pcp == NULL)
+       return NULL;
+
+    pcp->psc = psc;
+    pcp->driContext =
+       (*core->createNewContext)(psc->__driScreen,
+                                 config->driConfig, shared, pcp);
+    if (pcp->driContext == NULL) {
+       Xfree(pcp);
+       return NULL;
+    }
+
+    pcp->base.destroyContext = driDestroyContext;
+    pcp->base.bindContext = driBindContext;
+    pcp->base.unbindContext = driUnbindContext;
+
+    return &pcp->base;
+}
+
+static void driDestroyDrawable(__GLXDRIdrawable *pdraw)
+{
+    __GLXDRIdrawablePrivate *pdp = (__GLXDRIdrawablePrivate *) pdraw;
+    const __DRIcoreExtension *core = pdraw->psc->core;
+
+    (*core->destroyDrawable)(pdraw->driDrawable);
+
+    XDestroyDrawable(pdp, pdraw->psc->dpy, pdraw->drawable);
+    Xfree(pdp);
+}
+
+static __GLXDRIdrawable *driCreateDrawable(__GLXscreenConfigs *psc,
+                                          XID xDrawable,
+                                          GLXDrawable drawable,
+                                          const __GLcontextModes *modes)
+{
+    __GLXDRIdrawable *pdraw;
+    __GLXDRIdrawablePrivate *pdp;
+    __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
+    const __DRIswrastExtension *swrast = psc->swrast;
+
+    /* Old dri can't handle GLX 1.3+ drawable constructors. */
+    if (xDrawable != drawable)
+       return NULL;
+
+    pdp = Xmalloc(sizeof(*pdp));
+    if (!pdp)
+       return NULL;
+
+    pdraw = &(pdp->base);
+    pdraw->xDrawable = xDrawable;
+    pdraw->drawable = drawable;
+    pdraw->psc = psc;
+
+    XCreateDrawable(pdp, psc->dpy, xDrawable, modes->visualID);
+
+    /* Create a new drawable */
+    pdraw->driDrawable =
+       (*swrast->createNewDrawable)(psc->__driScreen,
+                                    config->driConfig,
+                                    pdp);
+
+    if (!pdraw->driDrawable) {
+       XDestroyDrawable(pdp, psc->dpy, xDrawable);
+       Xfree(pdp);
+       return NULL;
+    }
+
+    pdraw->destroyDrawable = driDestroyDrawable;
+
+    return pdraw;
+}
+
+static void driSwapBuffers(__GLXDRIdrawable *pdraw)
+{
+    (*pdraw->psc->core->swapBuffers)(pdraw->driDrawable);
+}
+
+static void driDestroyScreen(__GLXscreenConfigs *psc)
+{
+    /* Free the direct rendering per screen data */
+    (*psc->core->destroyScreen)(psc->__driScreen);
+    psc->__driScreen = NULL;
+    if (psc->driver)
+       dlclose(psc->driver);
+}
+
+static __GLXDRIscreen *driCreateScreen(__GLXscreenConfigs *psc, int screen,
+                                      __GLXdisplayPrivate *priv)
+{
+    __GLXDRIscreen *psp;
+    const __DRIconfig **driver_configs;
+    const __DRIextension **extensions;
+    const char *driverName = "swrast";
+    int i;
+
+    psp = Xmalloc(sizeof *psp);
+    if (psp == NULL)
+       return NULL;
+
+    /* Initialize per screen dynamic client GLX extensions */
+    psc->ext_list_first_time = GL_TRUE;
+
+    psc->driver = driOpenDriver(driverName);
+    if (psc->driver == NULL)
+       goto handle_error;
+
+    extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS);
+    if (extensions == NULL) {
+       ErrorMessageF("driver exports no extensions (%s)\n", dlerror());
+       goto handle_error;
+    }
+
+    for (i = 0; extensions[i]; i++) {
+       if (strcmp(extensions[i]->name, __DRI_CORE) == 0)
+           psc->core = (__DRIcoreExtension *) extensions[i];
+       if (strcmp(extensions[i]->name, __DRI_SWRAST) == 0)
+           psc->swrast = (__DRIswrastExtension *) extensions[i];
+    }
+
+    if (psc->core == NULL || psc->swrast == NULL) {
+       ErrorMessageF("core dri extension not found\n");
+       goto handle_error;
+    }
+
+    psc->__driScreen =
+       psc->swrast->createNewScreen(screen,
+                                    loader_extensions, &driver_configs, psc);
+    if (psc->__driScreen == NULL) {
+       ErrorMessageF("failed to create dri screen\n");
+       goto handle_error;
+    }
+
+    driBindExtensions(psc, 0);
+
+    psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs);
+    psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);
+
+    psp->destroyScreen = driDestroyScreen;
+    psp->createContext = driCreateContext;
+    psp->createDrawable = driCreateDrawable;
+    psp->swapBuffers = driSwapBuffers;
+
+    return psp;
+
+ handle_error:
+    Xfree(psp);
+
+    if (psc->driver)
+       dlclose(psc->driver);
+
+    ErrorMessageF("reverting to indirect rendering\n");
+
+    return NULL;
+}
+
+/* Called from __glXFreeDisplayPrivate.
+ */
+static void driDestroyDisplay(__GLXDRIdisplay *dpy)
+{
+    Xfree(dpy);
+}
+
+/*
+ * Allocate, initialize and return a __DRIdisplayPrivate object.
+ * This is called from __glXInitialize() when we are given a new
+ * display pointer.
+ */
+_X_HIDDEN __GLXDRIdisplay *driswCreateDisplay(Display *dpy)
+{
+    __GLXDRIdisplayPrivate *pdpyp;
+
+    pdpyp = Xmalloc(sizeof *pdpyp);
+    if (pdpyp == NULL)
+       return NULL;
+
+    pdpyp->base.destroyDisplay = driDestroyDisplay;
+    pdpyp->base.createScreen = driCreateScreen;
+
+    return &pdpyp->base;
+}
+
+#endif /* GLX_DIRECT_RENDERING */
index 788ecf6a3aa49c731b80e3be0bca226b9ff65b2b..326c8b2357c5c0a0e0b665422f626d43c8f17485 100644 (file)
@@ -336,7 +336,8 @@ _gl_get_context_mode_data(const __GLcontextModes *mode, int attribute,
        *value_return = mode->bindToTextureRgba;
        return 0;
       case GLX_BIND_TO_MIPMAP_TEXTURE_EXT:
-       *value_return = mode->bindToMipmapTexture;
+       *value_return = mode->bindToMipmapTexture == GL_TRUE ? GL_TRUE :
+           GL_FALSE;
        return 0;
       case GLX_BIND_TO_TEXTURE_TARGETS_EXT:
        *value_return = mode->bindToTextureTargets;
@@ -417,7 +418,7 @@ _gl_context_modes_create( unsigned count, size_t minimum_size )
       (*next)->bindToTextureRgb = GLX_DONT_CARE;
       (*next)->bindToTextureRgba = GLX_DONT_CARE;
       (*next)->bindToMipmapTexture = GLX_DONT_CARE;
-      (*next)->bindToTextureTargets = 0;
+      (*next)->bindToTextureTargets = GLX_DONT_CARE;
       (*next)->yInverted = GLX_DONT_CARE;
 
       next = & ((*next)->next);
@@ -456,19 +457,28 @@ _gl_context_modes_destroy( __GLcontextModes * modes )
  */
 
 __GLcontextModes *
-_gl_context_modes_find_visual( __GLcontextModes * modes, int vid )
+_gl_context_modes_find_visual(__GLcontextModes *modes, int vid)
 {
-    while ( modes != NULL ) {
-       if ( modes->visualID == vid ) {
-           break;
-       }
+    __GLcontextModes *m;
 
-       modes = modes->next;
-    }
+    for (m = modes; m != NULL; m = m->next)
+       if (m->visualID == vid)
+           return m;
 
-    return modes;
+    return NULL;
 }
 
+__GLcontextModes *
+_gl_context_modes_find_fbconfig(__GLcontextModes *modes, int fbid)
+{
+    __GLcontextModes *m;
+
+    for (m = modes; m != NULL; m = m->next)
+       if (m->fbconfigID == fbid)
+           return m;
+
+    return NULL;
+}
 
 /**
  * Determine if two context-modes are the same.  This is intended to be used
index 4b5c6f68b8f02827b279cf37e69024625fdef4da..afd09cd7fbd0e01e0498e2af8b38861a74f4fb7c 100644 (file)
@@ -44,8 +44,10 @@ extern int _gl_get_context_mode_data( const __GLcontextModes *mode,
 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  __GLcontextModes *
+    _gl_context_modes_find_visual(__GLcontextModes *modes, int vid);
+extern __GLcontextModes *
+    _gl_context_modes_find_fbconfig(__GLcontextModes *modes, int fbid);
 extern GLboolean _gl_context_modes_are_same( const __GLcontextModes * a,
     const __GLcontextModes * b );
 
index 1df2d0f342a017dc448da3840f1dd2e081a9326a..0f878f223f806d58974213ed4bb618042600d331 100644 (file)
@@ -164,6 +164,33 @@ DestroyPbuffer( Display * dpy, GLXDrawable drawable )
 }
 
 
+#ifdef GLX_DIRECT_RENDERING
+extern __GLXDRIdrawable *
+GetGLXDRIDrawable(Display *dpy, GLXDrawable drawable, int * const scrn_num);
+
+static GLenum
+determineTextureTarget(const int *attribs, int numAttribs)
+{
+    GLenum target = 0;
+    int i;
+
+    for (i = 0; i < numAttribs; i++) {
+       if (attribs[2 * i] == GLX_TEXTURE_TARGET_EXT) {
+           switch (attribs[2 * i + 1]) {
+           case GLX_TEXTURE_2D_EXT:
+               target = GL_TEXTURE_2D;
+               break;
+           case GLX_TEXTURE_RECTANGLE_EXT:
+               target = GL_TEXTURE_RECTANGLE_ARB;
+               break;
+           }
+       }
+    }
+    return target;
+}
+#endif
+
 /**
  * Get a drawable's attribute.
  *
@@ -261,6 +288,16 @@ GetDrawableAttribute( Display *dpy, GLXDrawable drawable,
               }
           }
 
+#ifdef GLX_DIRECT_RENDERING
+          {
+               __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);
+
+               if (pdraw != NULL && !pdraw->textureTarget)
+                   pdraw->textureTarget = determineTextureTarget((const int *)data,
+                                                                 num_attributes);
+          }
+#endif
+
           Xfree( data );
        }
    }
@@ -271,7 +308,6 @@ GetDrawableAttribute( Display *dpy, GLXDrawable drawable,
    return 0;
 }
 
-
 /**
  * Create a non-pbuffer GLX drawable.
  *
@@ -306,7 +342,7 @@ CreateDrawable( Display *dpy, const __GLcontextModes * fbconfig,
    req->glxCode = glxCode;
    req->screen = (CARD32) fbconfig->screen;
    req->fbconfig = fbconfig->fbconfigID;
-   req->window = (GLXPbuffer) drawable;
+   req->window = (CARD32) drawable;
    req->glxwindow = (GLXWindow) XAllocID(dpy);
    req->numAttribs = (CARD32) i;
 
@@ -315,6 +351,34 @@ CreateDrawable( Display *dpy, const __GLcontextModes * fbconfig,
    UnlockDisplay(dpy);
    SyncHandle();
    
+#ifdef GLX_DIRECT_RENDERING
+   do {
+       /* FIXME: Maybe delay __DRIdrawable creation until the drawable
+       * is actually bound to a context... */
+
+       __GLXdisplayPrivate * const priv = __glXInitialize(dpy);
+       __GLXDRIdrawable *pdraw;
+       __GLXscreenConfigs *psc;
+
+       psc = &priv->screenConfigs[fbconfig->screen];
+       if (psc->driScreen == NULL)
+          break;
+       pdraw = psc->driScreen->createDrawable(psc, drawable,
+                                             req->glxwindow, fbconfig);
+       if (pdraw == NULL) {
+          fprintf(stderr, "failed to create drawable\n");
+          break;
+       }
+          
+       if (__glxHashInsert(psc->drawHash, req->glxwindow, pdraw)) {
+          (*pdraw->destroyDrawable)(pdraw);
+          return None; /* FIXME: Check what we're supposed to do here... */
+       }
+
+       pdraw->textureTarget = determineTextureTarget(attrib_list, i);
+   } while (0);
+#endif
+
    return (GLXDrawable)req->glxwindow;
 }
 
@@ -350,6 +414,20 @@ DestroyDrawable( Display * dpy, GLXDrawable drawable, CARD32 glxCode )
    UnlockDisplay(dpy);
    SyncHandle();
 
+#ifdef GLX_DIRECT_RENDERING
+   {
+       int screen;
+       __GLXdisplayPrivate * const priv = __glXInitialize(dpy);
+       __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
+       __GLXscreenConfigs *psc = &priv->screenConfigs[screen];
+
+       if (pdraw != NULL) {
+          (*pdraw->destroyDrawable)(pdraw);
+          __glxHashDelete(psc->drawHash, drawable);
+       }
+   }
+#endif
+
    return;
 }
 
@@ -460,8 +538,24 @@ glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config,
 PUBLIC GLXPbuffer
 glXCreatePbuffer(Display *dpy, GLXFBConfig config, const int *attrib_list)
 {
+   int i, width, height;
+
+   width = 0;
+   height = 0;
+
+   for (i = 0; attrib_list[i * 2]; i++) {
+      switch (attrib_list[i * 2]) {
+      case GLX_PBUFFER_WIDTH:
+        width = attrib_list[i * 2 + 1];
+        break;
+      case GLX_PBUFFER_HEIGHT:
+        height = attrib_list[i * 2 + 1];
+        break;
+      }
+   }
+
    return (GLXPbuffer) CreatePbuffer( dpy, (__GLcontextModes *) config,
-                                     0, 0,
+                                     width, height,
                                      attrib_list, GL_TRUE );
 }
 
diff --git a/src/glx/x11/glx_texture_compression.c b/src/glx/x11/glx_texture_compression.c
deleted file mode 100644 (file)
index 5676858..0000000
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- * (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 );
-    }
-}
index f9d076f56f88a8f2d9b0b6cb4e3721fa6698673f..4f96b7df0437e40c967f6d87f7815e0a1d779c72 100644 (file)
 #include "GL/glxproto.h"
 #include "GL/internal/glcore.h"
 #include "glapitable.h"
-#include "glxextensions.h"
+#include "glxhash.h"
 #if defined( USE_XTHREADS )
 # include <X11/Xthreads.h>
 #elif defined( PTHREADS )
 # include <pthread.h>
 #endif
 
+#include "glxextensions.h"
+
 #define GLX_MAJOR_VERSION      1       /* current version numbers */
 #define GLX_MINOR_VERSION      4
 
 #define __GLX_MAX_TEXTURE_UNITS 32
 
+typedef struct __GLXscreenConfigsRec __GLXscreenConfigs;
 typedef struct __GLXcontextRec __GLXcontext;
+typedef struct __GLXdrawableRec __GLXdrawable;
 typedef struct __GLXdisplayPrivateRec __GLXdisplayPrivate;
 typedef struct _glapi_table __GLapi;
 
@@ -78,6 +82,9 @@ typedef struct _glapi_table __GLapi;
 
 #ifdef GLX_DIRECT_RENDERING
 
+#define containerOf(ptr, type, member)                 \
+    (type *)( (char *)ptr - offsetof(type,member) )
+
 #include <GL/internal/dri_interface.h>
 
 
@@ -85,43 +92,67 @@ typedef struct _glapi_table __GLapi;
  * Display dependent methods.  This structure is initialized during the
  * \c driCreateDisplay call.
  */
-struct __DRIdisplayRec {
+typedef struct __GLXDRIdisplayRec __GLXDRIdisplay;
+typedef struct __GLXDRIscreenRec __GLXDRIscreen;
+typedef struct __GLXDRIdrawableRec __GLXDRIdrawable;
+typedef struct __GLXDRIcontextRec __GLXDRIcontext;
+
+#include "glxextensions.h"
+
+struct __GLXDRIdisplayRec {
     /**
      * Method to destroy the private DRI display data.
      */
-    void (*destroyDisplay)(Display *dpy, void *displayPrivate);
+    void (*destroyDisplay)(__GLXDRIdisplay *display);
 
-    /**
-     * Opaque pointer to private per display direct rendering data.
-     * \c NULL if direct rendering is not supported on this display.
-     */
-    struct __DRIdisplayPrivateRec *private;
+    __GLXDRIscreen *(*createScreen)(__GLXscreenConfigs *psc, int screen,
+                                   __GLXdisplayPrivate *priv);
+};
 
-    /**
-     * Array of pointers to methods to create and initialize the private DRI
-     * screen data.
-     */
-    PFNCREATENEWSCREENFUNC * createNewScreen;
+struct __GLXDRIscreenRec {
+
+    void (*destroyScreen)(__GLXscreenConfigs *psc);
+
+    __GLXDRIcontext *(*createContext)(__GLXscreenConfigs *psc,
+                                     const __GLcontextModes *mode,
+                                     GLXContext gc,
+                                     GLXContext shareList, int renderType);
+       
+    __GLXDRIdrawable *(*createDrawable)(__GLXscreenConfigs *psc,
+                                       XID drawable,
+                                       GLXDrawable glxDrawable,
+                                       const __GLcontextModes *modes);
+
+    void (*swapBuffers)(__GLXDRIdrawable *pdraw);
 };
 
+struct __GLXDRIcontextRec {
+    void (*destroyContext)(__GLXDRIcontext *context, __GLXscreenConfigs *psc,
+                          Display *dpy);
+    Bool (*bindContext)(__GLXDRIcontext *context,
+                       __GLXDRIdrawable *pdraw,
+                       __GLXDRIdrawable *pread);
+    
+    void (*unbindContext)(__GLXDRIcontext *context);
+};
 
-/*
-** 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;
+struct __GLXDRIdrawableRec {
+    void (*destroyDrawable)(__GLXDRIdrawable *drawable);
+
+    XID xDrawable;
+    XID drawable;
+    __GLXscreenConfigs *psc;
+    GLenum textureTarget;
+    __DRIdrawable *driDrawable;
 };
 
 /*
 ** 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 __GLXDRIdisplay *driswCreateDisplay(Display *dpy);
+extern __GLXDRIdisplay *driCreateDisplay(Display *dpy);
+extern __GLXDRIdisplay *dri2CreateDisplay(Display *dpy);
 
 extern void DRI_glXUseXFont( Font font, int first, int count, int listbase );
 
@@ -133,8 +164,6 @@ extern const char *glXGetScreenDriver (Display *dpy, int scrNum);
 
 extern const char *glXGetDriverConfig (const char *driverName);
 
-extern Bool __glXWindowExists(Display *dpy, GLXDrawable draw);
-
 #endif
 
 /************************************************************************/
@@ -225,19 +254,11 @@ struct __GLXcontextRec {
      */
     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;
+    __GLXscreenConfigs *psc;
 
     /**
      * \c GL_TRUE if the context was created with ImportContext, which
@@ -343,24 +364,15 @@ struct __GLXcontextRec {
      */
     GLint majorOpcode;
 
-#ifdef GLX_DIRECT_RENDERING
     /**
-     * Per context direct rendering interface functions and data.
+     * Pointer to the mode used to create this context.
      */
-    __DRIcontext driContext;
+    const __GLcontextModes * mode;
+
+#ifdef GLX_DIRECT_RENDERING
+    __GLXDRIcontext *driContext;
+    __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
@@ -438,7 +450,7 @@ extern void __glFreeAttributeState(__GLXcontext *);
  * 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 {
+struct __GLXscreenConfigsRec {
     /**
      * GLX extension string reported by the X-server.
      */
@@ -454,13 +466,48 @@ typedef struct __GLXscreenConfigsRec {
     /**
      * Per screen direct rendering interface functions and data.
      */
-    __DRIscreen driScreen;
+    __DRIscreen *__driScreen;
+    const __DRIcoreExtension *core;
+    const __DRIlegacyExtension *legacy;
+    const __DRIswrastExtension *swrast;
+    const __DRIdri2Extension *dri2;
+    __glxHashTable *drawHash;
+    Display *dpy;
+    int scr, fd;
+    void *driver;
+
+    __GLXDRIscreen *driScreen;
+
+#ifdef __DRI_COPY_SUB_BUFFER
+    const __DRIcopySubBufferExtension *copySubBuffer;
+#endif
+
+#ifdef __DRI_SWAP_CONTROL
+    const __DRIswapControlExtension *swapControl;
+#endif
+
+#ifdef __DRI_ALLOCATE
+    const __DRIallocateExtension *allocate;
+#endif
+
+#ifdef __DRI_FRAME_TRACKING
+    const __DRIframeTrackingExtension *frameTracking;
+#endif
+
+#ifdef __DRI_MEDIA_STREAM_COUNTER
+    const __DRImediaStreamCounterExtension *msc;
+#endif
+
+#ifdef __DRI_TEX_BUFFER
+    const __DRItexBufferExtension *texBuffer;
+#endif
+
 #endif
 
     /**
-     * Linked list of configurations for this screen.
+     * Linked list of glx visuals and  fbconfigs for this screen.
      */
-    __GLcontextModes *configs;
+    __GLcontextModes *visuals, *configs;
 
     /**
      * Per-screen dynamic GLX extension tracking.  The \c direct_support
@@ -474,7 +521,7 @@ typedef struct __GLXscreenConfigsRec {
     GLboolean ext_list_first_time;
     /*@}*/
 
-} __GLXscreenConfigs;
+};
 
 /**
  * Per display private data.  One of these records exists for each display
@@ -523,11 +570,12 @@ struct __GLXdisplayPrivateRec {
     /**
      * Per display direct rendering interface functions and data.
      */
-    __DRIdisplay driDisplay;
+    __GLXDRIdisplay *driswDisplay;
+    __GLXDRIdisplay *driDisplay;
+    __GLXDRIdisplay *dri2Display;
 #endif
 };
 
-void __glXFreeContext(__GLXcontext*);
 
 extern GLubyte *__glXFlushRenderBuffer(__GLXcontext*, GLubyte*);
 
@@ -573,6 +621,10 @@ extern __GLXcontext *__glXcurrentContext;
 
 #endif /* defined( USE_XTHREADS ) || defined( PTHREADS ) */
 
+extern void __glXSetCurrentContextNull(void);
+
+extern void __glXFreeContext(__GLXcontext*);
+
 
 /*
 ** Global lock for all threads in this address space using the GLX
@@ -647,9 +699,10 @@ extern void __glEmptyImage(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
 
 
 /*
-** Allocate and Initialize Vertex Array client state 
+** Allocate and Initialize Vertex Array client state, and free.
 */
-extern void __glXInitVertexArrayState(__GLXcontext*);
+extern void __glXInitVertexArrayState(__GLXcontext *);
+extern void __glXFreeVertexArrayState(__GLXcontext *);
 
 /*
 ** Inform the Server of the major and minor numbers and of the client
@@ -682,13 +735,16 @@ 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 );
 
-extern Bool __glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
-    int32_t * numerator, int32_t * denominator);
+extern GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
+                                   int32_t * numerator, int32_t * denominator);
+
+#ifdef GLX_DIRECT_RENDERING
+GLboolean
+__driGetMscRateOML(__DRIdrawable *draw,
+                  int32_t *numerator, int32_t *denominator, void *private);
+#endif
 
 #endif /* !__GLX_client_h__ */
index 80281896f69f4dc10190add4402a523f782bb8fe..bdcbd253106e8875f4a4d16b7995b93ebc5d6dd3 100644 (file)
  * 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"
+
+#ifdef GLX_DIRECT_RENDERING
 #include <sys/time.h>
+#include <X11/extensions/xf86vmode.h>
+#include "xf86dri.h"
+#endif
 
 static const char __glXGLXClientVendorName[] = "SGI";
 static const char __glXGLXClientVersion[] = "1.4";
 
 
 /****************************************************************************/
+
+#ifdef GLX_DIRECT_RENDERING
+
+static Bool windowExistsFlag;
+static int windowExistsErrorHandler(Display *dpy, XErrorEvent *xerr)
+{
+    if (xerr->error_code == BadWindow) {
+       windowExistsFlag = GL_FALSE;
+    }
+    return 0;
+}
+
+/**
+ * Find drawables in the local hash that have been destroyed on the
+ * server.
+ * 
+ * \param dpy    Display to destroy drawables for
+ * \param screen Screen number to destroy drawables for
+ */
+static void GarbageCollectDRIDrawables(Display *dpy, __GLXscreenConfigs *sc)
+{
+    XID draw;
+    __GLXDRIdrawable *pdraw;
+    XWindowAttributes xwa;
+    int (*oldXErrorHandler)(Display *, XErrorEvent *);
+
+    /* Set no-op error handler so Xlib doesn't bail out if the windows
+     * has alreay been destroyed on the server. */
+    XSync(dpy, GL_FALSE);
+    oldXErrorHandler = XSetErrorHandler(windowExistsErrorHandler);
+
+    if (__glxHashFirst(sc->drawHash, &draw, (void *)&pdraw) == 1) {
+       do {
+           windowExistsFlag = GL_TRUE;
+           XGetWindowAttributes(dpy, draw, &xwa); /* dummy request */
+           if (!windowExistsFlag) {
+               /* Destroy the local drawable data, if the drawable no
+                  longer exists in the Xserver */
+               (*pdraw->destroyDrawable)(pdraw);
+                __glxHashDelete(sc->drawHash, draw);
+           }
+       } while (__glxHashNext(sc->drawHash, &draw, (void *)&pdraw) == 1);
+    }
+
+    XSync(dpy, GL_FALSE);
+    XSetErrorHandler(oldXErrorHandler);
+}
+
+extern __GLXDRIdrawable *
+GetGLXDRIDrawable(Display *dpy, GLXDrawable drawable, int * const scrn_num);
+
 /**
  * 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.
+ * \param scrn_num  If non-NULL, the drawables screen is stored there
  * \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 )
+_X_HIDDEN __GLXDRIdrawable *
+GetGLXDRIDrawable(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;
+    __GLXdisplayPrivate *priv = __glXInitialize(dpy);
+    __GLXDRIdrawable *pdraw;
+    const unsigned  screen_count = ScreenCount(dpy);
+    unsigned   i;
+    __GLXscreenConfigs *psc;
 
-           if ( pdraw != NULL ) {
-               if ( scrn_num != NULL ) {
-                   *scrn_num = i;
-               }
-               return pdraw;
-           }
+    if (priv == NULL)
+       return NULL;
+    
+    for (i = 0; i < screen_count; i++) {
+       psc = &priv->screenConfigs[i];
+       if (psc->drawHash == NULL)
+           continue;
+
+       if (__glxHashLookup(psc->drawHash, drawable, (void *) &pdraw) == 0) {
+           if (scrn_num != NULL)
+               *scrn_num = i;
+           return pdraw;
        }
     }
 
     return NULL;
 }
+
 #endif
 
 
@@ -264,9 +311,9 @@ GLXContext AllocateGLXContext( Display *dpy )
     */
     gc->fastImageUnpack = GL_FALSE;
     gc->fillImage = __glFillImage;
-    gc->isDirect = GL_FALSE;
     gc->pc = gc->buf;
     gc->bufEnd = gc->buf + bufSize;
+    gc->isDirect = GL_FALSE;
     if (__glXDebug) {
        /*
        ** Set limit register so that there will be one command per packet
@@ -312,6 +359,10 @@ CreateContext(Display *dpy, XVisualInfo *vis,
              Bool use_glx_1_3, int renderType)
 {
     GLXContext gc;
+#ifdef GLX_DIRECT_RENDERING
+    int screen = (fbconfig == NULL) ? vis->screen : fbconfig->screen;
+    __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen);
+#endif
 
     if ( dpy == NULL )
        return NULL;
@@ -325,41 +376,36 @@ CreateContext(Display *dpy, XVisualInfo *vis,
            return NULL;
 
 #ifdef GLX_DIRECT_RENDERING
-       if (allowDirect) {
-           int screen = (fbconfig == NULL) ? vis->screen : fbconfig->screen;
-           __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen);
+       if (allowDirect && psc->driScreen) {
            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 );
+           if (fbconfig == NULL) {
+               mode = _gl_context_modes_find_visual(psc->visuals, vis->visualid);
+               if (mode == NULL) {
+                  xError error;
+
+                  error.errorCode = BadValue;
+                  error.resourceID = vis->visualid;
+                  error.sequenceNumber = dpy->request;
+                  error.type = X_Error;
+                  error.majorCode = gc->majorOpcode;
+                  error.minorCode = X_GLXCreateContext;
+                  _XError(dpy, &error);
+                  return None;
+               }
            }
            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;
-               }
+           gc->driContext = psc->driScreen->createContext(psc, mode, gc,
+                                                          shareList,
+                                                          renderType);
+           if (gc->driContext != NULL) {
+               gc->screen = mode->screen;
+               gc->psc = psc;
+               gc->mode = mode;
+               gc->isDirect = GL_TRUE;
            }
        }
 #endif
@@ -376,7 +422,11 @@ CreateContext(Display *dpy, XVisualInfo *vis,
            req->visual = vis->visualid;
            req->screen = vis->screen;
            req->shareList = shareList ? shareList->xid : None;
-           req->isDirect = gc->isDirect;
+#ifdef GLX_DIRECT_RENDERING
+           req->isDirect = gc->driContext != NULL;
+#else
+           req->isDirect = 0;
+#endif
        }
        else if ( use_glx_1_3 ) {
            xGLXCreateNewContextReq *req;
@@ -390,7 +440,11 @@ CreateContext(Display *dpy, XVisualInfo *vis,
            req->screen = fbconfig->screen;
            req->renderType = renderType;
            req->shareList = shareList ? shareList->xid : None;
-           req->isDirect = gc->isDirect;
+#ifdef GLX_DIRECT_RENDERING
+           req->isDirect = gc->driContext != NULL;
+#else
+           req->isDirect = 0;
+#endif
        }
        else {
            xGLXVendorPrivateWithReplyReq *vpreq;
@@ -408,7 +462,11 @@ CreateContext(Display *dpy, XVisualInfo *vis,
            req->screen = fbconfig->screen;
            req->renderType = renderType;
            req->shareList = shareList ? shareList->xid : None;
-           req->isDirect = gc->isDirect;
+#ifdef GLX_DIRECT_RENDERING
+           req->isDirect = gc->driContext != NULL;
+#else
+           req->isDirect = 0;
+#endif
        }
 
        UnlockDisplay(dpy);
@@ -430,7 +488,7 @@ PUBLIC GLXContext glXCreateContext(Display *dpy, XVisualInfo *vis,
                        False, 0);
 }
 
-void __glXFreeContext(__GLXcontext *gc)
+_X_HIDDEN void __glXFreeContext(__GLXcontext *gc)
 {
     if (gc->vendor) XFree((char *) gc->vendor);
     if (gc->renderer) XFree((char *) gc->renderer);
@@ -466,15 +524,15 @@ DestroyContext(Display *dpy, GLXContext gc)
 
 #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;
-       }
+    if (gc->driContext) {
+       (*gc->driContext->destroyContext)(gc->driContext, gc->psc, dpy);
+       gc->driContext = NULL;
+       GarbageCollectDRIDrawables(dpy, gc->psc);
     }
 #endif
 
+    __glXFreeVertexArrayState(gc);
+
     if (gc->currentDpy) {
        /* Have to free later cuz it's in use now */
        __glXUnlock();
@@ -552,7 +610,7 @@ PUBLIC void glXWaitGL(void)
     __glXFlushRenderBuffer(gc, gc->pc);
 
 #ifdef GLX_DIRECT_RENDERING
-    if (gc->isDirect) {
+    if (gc->driContext) {
 /* This bit of ugliness unwraps the glFinish function */
 #ifdef glFinish
 #undef glFinish
@@ -588,7 +646,7 @@ PUBLIC void glXWaitX(void)
     __glXFlushRenderBuffer(gc, gc->pc);
 
 #ifdef GLX_DIRECT_RENDERING
-    if (gc->isDirect) {
+    if (gc->driContext) {
        XSync(dpy, False);
        return;
     }
@@ -618,7 +676,7 @@ PUBLIC void glXUseXFont(Font font, int first, int count, int listBase)
     (void) __glXFlushRenderBuffer(gc, gc->pc);
 
 #ifdef GLX_DIRECT_RENDERING
-    if (gc->isDirect) {
+    if (gc->driContext) {
       DRI_glXUseXFont(font, first, count, listBase);
       return;
     }
@@ -658,7 +716,7 @@ PUBLIC void glXCopyContext(Display *dpy, GLXContext source,
     }
 
 #ifdef GLX_DIRECT_RENDERING
-    if (gc->isDirect) {
+    if (gc->driContext) {
        /* NOT_DONE: This does not work yet */
     }
 #endif
@@ -730,7 +788,7 @@ PUBLIC Bool glXIsDirect(Display *dpy, GLXContext gc)
     if (!gc) {
        return GL_FALSE;
 #ifdef GLX_DIRECT_RENDERING
-    } else if (gc->isDirect) {
+    } else if (gc->driContext) {
        return GL_TRUE;
 #endif
     }
@@ -793,10 +851,11 @@ PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable)
     GLXContextTag tag;
     CARD8 opcode;
 #ifdef GLX_DIRECT_RENDERING
-    __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, NULL );
+    __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);
 
-    if ( pdraw != NULL ) {
-       (*pdraw->swapBuffers)(dpy, pdraw->private);
+    if (pdraw != NULL) {
+       glFlush();          
+       (*pdraw->psc->driScreen->swapBuffers)(pdraw);
        return;
     }
 #endif
@@ -840,12 +899,12 @@ PUBLIC int glXGetConfig(Display *dpy, XVisualInfo *vis, int attribute,
 {
     __GLXdisplayPrivate *priv;
     __GLXscreenConfigs *psc;
+    __GLcontextModes *modes;
     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 );
+       modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid);
 
        /* Lookup attribute after first finding a match on the visual */
        if ( modes != NULL ) {
@@ -1223,7 +1282,7 @@ PUBLIC XVisualInfo *glXChooseVisual(Display *dpy, int screen, int *attribList)
     ** 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 ) {
+    for ( modes = psc->visuals ; modes != NULL ; modes = modes->next ) {
        if ( fbconfigs_compatible( & test_config, modes )
             && ((best_config == NULL)
                 || (fbconfig_compare( (const __GLcontextModes * const * const)&modes, &best_config ) < 0)) ) {
@@ -1268,7 +1327,7 @@ PUBLIC const char *glXQueryExtensionsString( Display *dpy, int screen )
 
        __glXCalculateUsableExtensions(psc,
 #ifdef GLX_DIRECT_RENDERING
-                                      (psc->driScreen.private != NULL),
+                                      (psc->driScreen != NULL),
 #else
                                       GL_FALSE,
 #endif
@@ -1447,13 +1506,15 @@ static int __glXQueryContextInfo(Display *dpy, GLXContext ctx)
                    ctx->share_xid = *pProp++;
                    break;
                case GLX_VISUAL_ID_EXT:
-                   ctx->vid = *pProp++;
+                   ctx->mode =
+                       _gl_context_modes_find_visual(ctx->psc->visuals, *pProp++);
                    break;
                case GLX_SCREEN:
                    ctx->screen = *pProp++;
                    break;
                case GLX_FBCONFIG_ID:
-                   ctx->fbconfigID = *pProp++;
+                   ctx->mode =
+                       _gl_context_modes_find_fbconfig(ctx->psc->configs, *pProp++);
                    break;
                case GLX_RENDER_TYPE:
                    ctx->renderType = *pProp++;
@@ -1478,7 +1539,11 @@ 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)) {
+#ifdef GLX_DIRECT_RENDERING
+    if (!ctx->driContext && (ctx->mode == NULL)) {
+#else
+    if (ctx->mode == NULL) {
+#endif
        retVal = __glXQueryContextInfo(dpy, ctx);
        if (Success != retVal) return retVal;
     }
@@ -1487,13 +1552,13 @@ glXQueryContext(Display *dpy, GLXContext ctx, int attribute, int *value)
        *value = (int)(ctx->share_xid);
        break;
     case GLX_VISUAL_ID_EXT:
-       *value = (int)(ctx->vid);
+       *value = ctx->mode ? ctx->mode->visualID : None;
        break;
     case GLX_SCREEN:
        *value = (int)(ctx->screen);
        break;
     case GLX_FBCONFIG_ID:
-       *value = (int)(ctx->fbconfigID);
+       *value = ctx->mode ? ctx->mode->fbconfigID : None;
        break;
     case GLX_RENDER_TYPE:
        *value = (int)(ctx->renderType);
@@ -1591,6 +1656,7 @@ PUBLIC GLXFBConfig *glXGetFBConfigs(Display *dpy, int screen, int *nelements)
     __GLcontextModes ** config = NULL;
     int   i;
 
+    *nelements = 0;
     if ( (priv->screenConfigs != NULL)
         && (screen >= 0) && (screen <= ScreenCount(dpy))
         && (priv->screenConfigs[screen].configs != NULL)
@@ -1615,8 +1681,10 @@ PUBLIC GLXFBConfig *glXGetFBConfigs(Display *dpy, int screen, int *nelements)
            for ( modes = priv->screenConfigs[screen].configs
                  ; modes != NULL
                  ; modes = modes->next ) {
-               config[i] = modes;
-               i++;
+               if ( modes->fbconfigID != GLX_DONT_CARE ) {
+                   config[i] = modes;
+                   i++;
+               }
            }
        }
     }
@@ -1668,16 +1736,15 @@ static int __glXSwapIntervalSGI(int interval)
       return GLX_BAD_VALUE;
    }
 
-#ifdef GLX_DIRECT_RENDERING
-   if ( gc->isDirect ) {
+#ifdef __DRI_SWAP_CONTROL
+   if (gc->driContext) {
        __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;
+       __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy,
+                                                  gc->currentDrawable,
+                                                  NULL);
+       if (psc->swapControl != NULL && pdraw != NULL) {
+          psc->swapControl->setSwapInterval(pdraw->driDrawable, interval);
           return 0;
        }
        else {
@@ -1715,25 +1782,22 @@ static int __glXSwapIntervalSGI(int interval)
 */
 static int __glXSwapIntervalMESA(unsigned int interval)
 {
-#ifdef GLX_DIRECT_RENDERING
+#ifdef __DRI_SWAP_CONTROL
    GLXContext gc = __glXGetCurrentContext();
 
    if ( interval < 0 ) {
       return GLX_BAD_VALUE;
    }
 
-   if ( (gc != NULL) && gc->isDirect ) {
+   if (gc != NULL && gc->driContext) {
       __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;
+      if ( (psc != NULL) && (psc->driScreen != NULL) ) {
+        __GLXDRIdrawable *pdraw = 
+            GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
+        if (psc->swapControl != NULL && pdraw != NULL) {
+           psc->swapControl->setSwapInterval(pdraw->driDrawable, interval);
            return 0;
         }
       }
@@ -1748,21 +1812,18 @@ static int __glXSwapIntervalMESA(unsigned int interval)
 
 static int __glXGetSwapIntervalMESA(void)
 {
-#ifdef GLX_DIRECT_RENDERING
+#ifdef __DRI_SWAP_CONTROL
    GLXContext gc = __glXGetCurrentContext();
 
-   if ( (gc != NULL) && gc->isDirect ) {
+   if (gc != NULL && gc->driContext) {
       __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;
+      if ( (psc != NULL) && (psc->driScreen != NULL) ) {
+        __GLXDRIdrawable *pdraw = 
+            GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
+        if (psc->swapControl != NULL && pdraw != NULL) {
+           return psc->swapControl->getSwapInterval(pdraw->driDrawable);
         }
       }
    }
@@ -1779,15 +1840,13 @@ static int __glXGetSwapIntervalMESA(void)
 static GLint __glXBeginFrameTrackingMESA(Display *dpy, GLXDrawable drawable)
 {
    int   status = GLX_BAD_CONTEXT;
-#ifdef GLX_DIRECT_RENDERING
+#ifdef __DRI_FRAME_TRACKING
    int screen;
-   __DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen);
+   __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(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 );
-   }
+   if (pdraw != NULL && psc->frameTracking != NULL)
+       status = psc->frameTracking->frameTracking(pdraw->driDrawable, GL_TRUE);
 #else
    (void) dpy;
    (void) drawable;
@@ -1799,15 +1858,14 @@ static GLint __glXBeginFrameTrackingMESA(Display *dpy, GLXDrawable drawable)
 static GLint __glXEndFrameTrackingMESA(Display *dpy, GLXDrawable drawable)
 {
    int   status = GLX_BAD_CONTEXT;
-#ifdef GLX_DIRECT_RENDERING
+#ifdef __DRI_FRAME_TRACKING
    int screen;
-   __DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen);
-   __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen);
+   __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, & screen);
+   __GLXscreenConfigs *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 );
-   }
+   if (pdraw != NULL && psc->frameTracking != NULL)
+       status = psc->frameTracking->frameTracking(pdraw->driDrawable,
+                                                 GL_FALSE);
 #else
    (void) dpy;
    (void) drawable;
@@ -1820,19 +1878,20 @@ static GLint __glXGetFrameUsageMESA(Display *dpy, GLXDrawable drawable,
                                    GLfloat *usage)
 {
    int   status = GLX_BAD_CONTEXT;
-#ifdef GLX_DIRECT_RENDERING
+#ifdef __DRI_FRAME_TRACKING
    int screen;
-   __DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen);
+   __GLXDRIdrawable * const pdraw = GetGLXDRIDrawable(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;
+   if (pdraw != NULL && psc->frameTracking != NULL) {
+       int64_t sbc, missedFrames;
+       float   lastMissedUsage;
 
-      status = pdraw->queryFrameTracking( dpy, pdraw->private, &sbc,
-                                         &missedFrames, &lastMissedUsage,
-                                         usage );
+       status = psc->frameTracking->queryFrameTracking(pdraw->driDrawable,
+                                                      &sbc,
+                                                      &missedFrames,
+                                                      &lastMissedUsage,
+                                                      usage);
    }
 #else
    (void) dpy;
@@ -1848,18 +1907,17 @@ static GLint __glXQueryFrameTrackingMESA(Display *dpy, GLXDrawable drawable,
                                         GLfloat *lastMissedUsage)
 {
    int   status = GLX_BAD_CONTEXT;
-#ifdef GLX_DIRECT_RENDERING
+#ifdef __DRI_FRAME_TRACKING
    int screen;
-   __DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen);
+   __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, & screen);
    __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen);
 
-   if ( (pdraw != NULL ) && (pdraw->queryFrameTracking != NULL)
-       && __glXExtensionBitIsEnabled( psc, MESA_swap_frame_usage_bit ) ) {
+   if (pdraw != NULL && psc->frameTracking != NULL) {
       float   usage;
 
-      status = pdraw->queryFrameTracking( dpy, pdraw->private, sbc,
-                                         missedFrames, lastMissedUsage,
-                                         & usage );
+      status = psc->frameTracking->queryFrameTracking(pdraw->driDrawable,
+                                                     sbc, missedFrames,
+                                                     lastMissedUsage, &usage);
    }
 #else
    (void) dpy;
@@ -1881,21 +1939,24 @@ static int __glXGetVideoSyncSGI(unsigned int *count)
     * FIXME: there should be a GLX encoding for this call.  I can find no
     * FIXME: documentation for the GLX encoding.
     */
-#ifdef GLX_DIRECT_RENDERING
+#ifdef __DRI_MEDIA_STREAM_COUNTER
    GLXContext gc = __glXGetCurrentContext();
 
 
-   if ( (gc != NULL) && gc->isDirect ) {
+   if (gc != NULL && gc->driContext) {
       __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;
+      if ( psc->msc && psc->driScreen ) {
+          __GLXDRIdrawable *pdraw = 
+              GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
+         int64_t temp; 
+         int ret;
+         ret = (*psc->msc->getDrawableMSC)(psc->__driScreen,
+                                           pdraw->driDrawable, &temp);
+         *count = (unsigned) temp;
 
-        ret = psc->driScreen.getMSC( psc->driScreen.private, & temp );
-        *count = (unsigned) temp;
-        return (ret == 0) ? 0 : GLX_BAD_CONTEXT;
+         return (ret == 0) ? 0 : GLX_BAD_CONTEXT;
       }
    }
 #else
@@ -1906,32 +1967,26 @@ static int __glXGetVideoSyncSGI(unsigned int *count)
 
 static int __glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
 {
-#ifdef GLX_DIRECT_RENDERING
+#ifdef __DRI_MEDIA_STREAM_COUNTER
    GLXContext gc = __glXGetCurrentContext();
 
    if ( divisor <= 0 || remainder < 0 )
      return GLX_BAD_VALUE;
 
-   if ( (gc != NULL) && gc->isDirect ) {
+   if (gc != NULL && gc->driContext) {
       __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;
-        }
+      if (psc->msc != NULL && psc->driScreen ) {
+        __GLXDRIdrawable *pdraw = 
+            GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
+        int       ret;
+        int64_t   msc;
+        int64_t   sbc;
+
+        ret = (*psc->msc->waitForMSC)(pdraw->driDrawable, 0,
+                                      divisor, remainder, &msc, &sbc);
+        *count = (unsigned) msc;
+        return (ret == 0) ? 0 : GLX_BAD_CONTEXT;
       }
    }
 #else
@@ -2083,20 +2138,19 @@ static Bool __glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max)
 static Bool __glXGetSyncValuesOML(Display *dpy, GLXDrawable drawable,
                                  int64_t *ust, int64_t *msc, int64_t *sbc)
 {
-#ifdef GLX_DIRECT_RENDERING
+#if defined(__DRI_SWAP_BUFFER_COUNTER) && defined(__DRI_MEDIA_STREAM_COUNTER)
     __GLXdisplayPrivate * const priv = __glXInitialize(dpy);
 
     if ( priv != NULL ) {
        int   i;
-       __DRIdrawable * const pdraw = GetDRIDrawable( dpy, drawable, & i );
+       __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(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) );
+       return ( (pdraw && psc->sbc && psc->msc)
+                && ((*psc->msc->getMSC)(psc->driScreen, msc) == 0)
+                && ((*psc->sbc->getSBC)(pdraw->driDrawable, sbc) == 0)
+                && (__glXGetUST(ust) == 0) );
     }
 #else
    (void) dpy;
@@ -2108,6 +2162,68 @@ static Bool __glXGetSyncValuesOML(Display *dpy, GLXDrawable drawable,
    return False;
 }
 
+#ifdef GLX_DIRECT_RENDERING
+_X_HIDDEN GLboolean
+__driGetMscRateOML(__DRIdrawable *draw,
+                  int32_t *numerator, int32_t *denominator, void *private)
+{
+#ifdef XF86VIDMODE
+    __GLXscreenConfigs *psc;
+    XF86VidModeModeLine   mode_line;
+    int   dot_clock;
+    int   i;
+    __GLXDRIdrawable *glxDraw = private;
+
+    psc = glxDraw->psc;
+    if (XF86VidModeQueryVersion(psc->dpy, &i, &i) &&
+       XF86VidModeGetModeLine(psc->dpy, psc->scr, &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;
+
+       return True;
+    }
+    else
+       return False;
+#else
+    return False;
+#endif
+}
+#endif
 
 /**
  * Determine the refresh rate of the specified drawable and display.
@@ -2125,70 +2241,17 @@ static Bool __glXGetSyncValuesOML(Display *dpy, GLXDrawable drawable,
  *       when GLX_OML_sync_control appears in the client extension string.
  */
 
-Bool __glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
-                       int32_t * numerator, int32_t * denominator)
+_X_HIDDEN GLboolean __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];
-              }
-           }
-        }
+    __GLXDRIdrawable *draw = GetGLXDRIDrawable(dpy, drawable, NULL);
 
-        *numerator = n;
-        *denominator = d;
+    if (draw == NULL)
+       return False;
 
-        (void) drawable;
-        return True;
-      }
-   }
+    return __driGetMscRateOML(draw->driDrawable, numerator, denominator, draw);
 #else
    (void) dpy;
    (void) drawable;
@@ -2203,9 +2266,9 @@ static int64_t __glXSwapBuffersMscOML(Display *dpy, GLXDrawable drawable,
                                      int64_t target_msc, int64_t divisor,
                                      int64_t remainder)
 {
-#ifdef GLX_DIRECT_RENDERING
+#ifdef __DRI_SWAP_BUFFER_COUNTER
    int screen;
-   __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen );
+   __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
    __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen );
 
    /* The OML_sync_control spec says these should "generate a GLX_BAD_VALUE
@@ -2218,11 +2281,10 @@ static int64_t __glXSwapBuffersMscOML(Display *dpy, GLXDrawable drawable,
    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);
-   }
+   if (pdraw != NULL && psc->counters != NULL)
+      return (*psc->sbc->swapBuffersMSC)(pdraw->driDrawable, target_msc,
+                                        divisor, remainder);
+
 #else
    (void) dpy;
    (void) drawable;
@@ -2239,9 +2301,9 @@ static Bool __glXWaitForMscOML(Display * dpy, GLXDrawable drawable,
                               int64_t remainder, int64_t *ust,
                               int64_t *msc, int64_t *sbc)
 {
-#ifdef GLX_DIRECT_RENDERING
+#ifdef __DRI_MEDIA_STREAM_COUNTER
    int screen;
-   __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen );
+   __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
    __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen );
    int  ret;
 
@@ -2253,10 +2315,9 @@ static Bool __glXWaitForMscOML(Display * dpy, GLXDrawable drawable,
    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 );
+   if (pdraw != NULL && psc->msc != NULL) {
+      ret = (*psc->msc->waitForMSC)(pdraw->driDrawable, 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.
@@ -2281,9 +2342,9 @@ static Bool __glXWaitForSbcOML(Display * dpy, GLXDrawable drawable,
                               int64_t target_sbc, int64_t *ust,
                               int64_t *msc, int64_t *sbc )
 {
-#ifdef GLX_DIRECT_RENDERING
+#ifdef __DRI_SWAP_BUFFER_COUNTER
    int screen;
-   __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen );
+   __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
    __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen );
    int  ret;
 
@@ -2293,9 +2354,8 @@ static Bool __glXWaitForSbcOML(Display * dpy, GLXDrawable drawable,
    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 );
+   if (pdraw != NULL && psc->sbc != NULL) {
+      ret = (*psc->sbc->waitForSBC)(pdraw->driDrawable, target_sbc, msc, sbc);
 
       /* __glXGetUST returns zero on success and non-zero on failure.
        * This function returns True on success and False on failure.
@@ -2323,16 +2383,13 @@ PUBLIC void *glXAllocateMemoryMESA(Display *dpy, int scrn,
                                   size_t size, float readFreq,
                                   float writeFreq, float priority)
 {
-#ifdef GLX_DIRECT_RENDERING
+#ifdef __DRI_ALLOCATE
    __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 );
-      }
-   }
+   if (psc && psc->allocate)
+       return (*psc->allocate->allocateMemory)(psc->__driScreen, size,
+                                              readFreq, writeFreq, priority);
+
 #else
    (void) dpy;
    (void) scrn;
@@ -2348,14 +2405,12 @@ PUBLIC void *glXAllocateMemoryMESA(Display *dpy, int scrn,
 
 PUBLIC void glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer)
 {
-#ifdef GLX_DIRECT_RENDERING
+#ifdef __DRI_ALLOCATE
    __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 );
-      }
-   }
+   if (psc && psc->allocate)
+        (*psc->allocate->freeMemory)(psc->__driScreen, pointer);
+
 #else
    (void) dpy;
    (void) scrn;
@@ -2367,14 +2422,12 @@ PUBLIC void glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer)
 PUBLIC GLuint glXGetMemoryOffsetMESA( Display *dpy, int scrn,
                                      const void *pointer )
 {
-#ifdef GLX_DIRECT_RENDERING
+#ifdef __DRI_ALLOCATE
    __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 );
-      }
-   }
+   if (psc && psc->allocate)
+       return (*psc->allocate->memoryOffset)(psc->__driScreen, pointer);
+
 #else
    (void) dpy;
    (void) scrn;
@@ -2447,13 +2500,14 @@ static void __glXCopySubBufferMESA(Display *dpy, GLXDrawable drawable,
     INT32 *x_ptr, *y_ptr, *w_ptr, *h_ptr;
     CARD8 opcode;
 
-#ifdef GLX_DIRECT_RENDERING
+#ifdef __DRI_COPY_SUB_BUFFER
     int screen;
-    __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen );
+    __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
     if ( pdraw != NULL ) {
        __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen );
-       if ( __glXExtensionBitIsEnabled( psc, MESA_copy_sub_buffer_bit ) ) {
-           (*pdraw->copySubBuffer)(dpy, pdraw->private, x, y, width, height);
+       if (psc->copySubBuffer != NULL) {
+           (*psc->copySubBuffer->copySubBuffer)(pdraw->driDrawable,
+                                                x, y, width, height);
        }
 
        return;
@@ -2529,8 +2583,16 @@ static void __glXBindTexImageEXT(Display *dpy,
     }
  
 #ifdef GLX_DIRECT_RENDERING
-    if (gc->isDirect)
+    if (gc->driContext) {
+       __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);
+
+       if (pdraw != NULL)
+           (*pdraw->psc->texBuffer->setTexBuffer)(gc->__driContext,
+                                                  pdraw->textureTarget,
+                                                  pdraw->driDrawable);
+
        return;
+    }
 #endif
 
     opcode = __glXSetupForCommand(dpy);
@@ -2581,7 +2643,7 @@ static void __glXReleaseTexImageEXT(Display *dpy,
        return;
 
 #ifdef GLX_DIRECT_RENDERING
-    if (gc->isDirect)
+    if (gc->driContext)
        return;
 #endif
 
@@ -2613,7 +2675,7 @@ static void __glXReleaseTexImageEXT(Display *dpy,
  * 
  * \sa strdup
  */
-char *
+_X_HIDDEN char *
 __glXstrdup(const char *str)
 {
    char *copy;
@@ -2840,98 +2902,6 @@ PUBLIC void (*glXGetProcAddress(const GLubyte *procName))( void )
 
 
 #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.
-     * 20060314 - Added support for GLX_MESA_copy_sub_buffer.
-     * 20070105 - Added support for damage reporting.
-     */
-    return 20070105;
-}
-
-
-
-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
@@ -2946,7 +2916,7 @@ Bool __glXWindowExists(Display *dpy, GLXDrawable draw)
  *
  * \since Internal API version 20030317.
  */
-int __glXGetUST( int64_t * ust )
+_X_HIDDEN int __glXGetUST( int64_t * ust )
 {
     struct timeval  tv;
     
diff --git a/src/glx/x11/glxcurrent.c b/src/glx/x11/glxcurrent.c
new file mode 100644 (file)
index 0000000..0d0c419
--- /dev/null
@@ -0,0 +1,518 @@
+/*
+** 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 glxcurrent.c
+ * Client-side GLX interface for current context management.
+ */
+
+#include "glxclient.h"
+#include "glapi.h"
+#include "glheader.h"
+#include "indirect_init.h"
+
+#ifdef GLX_DIRECT_RENDERING
+#include "xf86dri.h"
+#endif
+
+/*
+** 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;
+
+_X_HIDDEN __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;
+   }
+}
+
+_X_HIDDEN 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 */
+_X_HIDDEN xmutex_rec __glXmutex;
+
+#elif defined( PTHREADS )
+
+_X_HIDDEN 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;
+
+_X_HIDDEN 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 );
+    }
+}
+
+_X_HIDDEN void __glXSetCurrentContext( __GLXcontext * c )
+{
+    pthread_once( & once_control, init_thread_data );
+    pthread_setspecific( ContextTSD, c );
+}
+
+_X_HIDDEN __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 */
+_X_HIDDEN __GLXcontext *__glXcurrentContext = &dummyContext;
+
+#endif
+
+
+_X_HIDDEN void __glXSetCurrentContextNull(void)
+{
+    __glXSetCurrentContext(&dummyContext);
+#ifdef GLX_DIRECT_RENDERING
+    _glapi_set_dispatch(NULL);  /* no-op functions */
+#endif
+}
+
+
+/************************************************************************/
+
+PUBLIC GLXContext glXGetCurrentContext(void)
+{
+    GLXContext cx = __glXGetCurrentContext();
+    
+    if (cx == &dummyContext) {
+       return NULL;
+    } else {
+       return cx;
+    }
+}
+
+PUBLIC GLXDrawable glXGetCurrentDrawable(void)
+{
+    GLXContext gc = __glXGetCurrentContext();
+    return gc->currentDrawable;
+}
+
+
+/************************************************************************/
+
+/**
+ * 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)
+{
+    Bool ret;
+
+
+    LockDisplay(dpy);
+
+    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;
+       }
+    }
+
+    ret = _XReply(dpy, (xReply*) reply, 0, False);
+
+    UnlockDisplay(dpy);
+    SyncHandle();
+
+    return ret;
+}
+
+
+#ifdef GLX_DIRECT_RENDERING
+static __GLXDRIdrawable *
+FetchDRIDrawable(Display *dpy,
+                GLXDrawable glxDrawable, GLXContext gc, Bool pre13)
+{
+    __GLXdisplayPrivate * const priv = __glXInitialize(dpy);
+    __GLXDRIdrawable *pdraw;
+    __GLXscreenConfigs *psc;
+    XID drawable;
+
+    if (priv == NULL)
+       return NULL;
+    
+    psc = &priv->screenConfigs[gc->screen];
+    if (psc->drawHash == NULL)
+       return NULL;
+
+    if (__glxHashLookup(psc->drawHash, glxDrawable, (void *) &pdraw) == 0)
+       return pdraw;
+
+    /* If this is glXMakeCurrent (pre GLX 1.3) we allow creating the
+     * GLX drawable on the fly.  Otherwise we pass None as the X
+     * drawable */
+    if (pre13)
+       drawable = glxDrawable;
+    else
+       drawable = None;
+
+    pdraw = psc->driScreen->createDrawable(psc, drawable,
+                                          glxDrawable, gc->mode);
+    if (__glxHashInsert(psc->drawHash, glxDrawable, pdraw)) {
+       (*pdraw->destroyDrawable)(pdraw);
+       return NULL;
+    }
+
+    return pdraw;
+}
+#endif /* GLX_DIRECT_RENDERING */
+
+
+/**
+ * Make a particular context current.
+ * 
+ * \note This is in this file so that it can access dummyContext.
+ */
+static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
+                              GLXDrawable read, GLXContext gc,
+                              Bool pre13)
+{
+    xGLXMakeCurrentReply reply;
+    const GLXContext oldGC = __glXGetCurrentContext();
+    const CARD8 opcode = __glXSetupForCommand(dpy);
+    const CARD8 oldOpcode = ((gc == oldGC) || (oldGC == &dummyContext))
+      ? opcode : __glXSetupForCommand(oldGC->currentDpy);
+    Bool bindReturnValue;
+
+
+    if (!opcode || !oldOpcode) {
+       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;
+    }
+
+    _glapi_check_multithread();
+
+#ifdef GLX_DIRECT_RENDERING
+    /* Bind the direct rendering context to the drawable */
+    if (gc && gc->driContext) {
+       __GLXDRIdrawable *pdraw = FetchDRIDrawable(dpy, draw, gc, pre13);
+       __GLXDRIdrawable *pread = FetchDRIDrawable(dpy, read, gc, pre13);
+
+       bindReturnValue =
+           (gc->driContext->bindContext) (gc->driContext, pdraw, pread);
+    } else
+#endif
+    {
+       /* Send a glXMakeCurrent request to bind the new context. */
+       bindReturnValue = 
+         SendMakeCurrentRequest(dpy, opcode, gc ? gc->xid : None,
+                                ((dpy != oldGC->currentDpy) || oldGC->isDirect)
+                                ? None : oldGC->currentContextTag,
+                                draw, read, &reply);
+    }
+
+
+    if (!bindReturnValue) {
+       return False;
+    }
+
+#ifdef GLX_DIRECT_RENDERING
+    if ((dpy != oldGC->currentDpy || (gc && gc->driContext)) &&
+       !oldGC->isDirect && oldGC != &dummyContext) {
+#else
+    if ((dpy != oldGC->currentDpy) && oldGC != &dummyContext) {
+#endif
+       xGLXMakeCurrentReply dummy_reply;
+
+       /* 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.
+        */
+       (void) SendMakeCurrentRequest(oldGC->currentDpy, oldOpcode, None,
+                                     oldGC->currentContextTag, None, None,
+                                     & dummy_reply);
+    }
+#ifdef GLX_DIRECT_RENDERING
+    else if (oldGC->driContext) {
+       oldGC->driContext->unbindContext(oldGC->driContext);
+    }
+#endif
+
+
+    /* 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->driContext) {
+                   oldGC->driContext->destroyContext(oldGC->driContext,
+                                                     oldGC->psc,
+                                                     oldGC->createDpy);
+                   oldGC->driContext = NULL;
+               }
+#endif
+               __glXFreeContext(oldGC);
+           }
+       }
+       if (gc) {
+           __glXSetCurrentContext(gc);
+
+           gc->currentDpy = dpy;
+           gc->currentDrawable = draw;
+           gc->currentReadable = read;
+
+#ifdef GLX_DIRECT_RENDERING    
+            if (!gc->driContext) {
+#endif
+               if (!IndirectAPI)
+                  IndirectAPI = __glXNewIndirectAPI();
+               _glapi_set_dispatch(IndirectAPI);
+
+#ifdef GLX_USE_APPLEGL
+               do {
+                   extern void XAppleDRIUseIndirectDispatch(void);
+                   XAppleDRIUseIndirectDispatch();
+               } while (0);
+#endif
+
+               __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);
+               }
+#ifdef GLX_DIRECT_RENDERING    
+           }
+           else {
+               gc->currentContextTag = -1;
+           }
+#endif
+       } else {
+           __glXSetCurrentContextNull();
+       }
+    }
+    __glXUnlock();
+    return GL_TRUE;
+}
+
+
+PUBLIC Bool glXMakeCurrent(Display *dpy, GLXDrawable draw, GLXContext gc)
+{
+    return MakeContextCurrent(dpy, draw, draw, gc, True);
+}
+
+PUBLIC GLX_ALIAS(Bool, glXMakeCurrentReadSGI,
+         (Display *dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx),
+         (dpy, d, r, ctx, False), MakeContextCurrent)
+
+PUBLIC GLX_ALIAS(Bool, glXMakeContextCurrent,
+         (Display *dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx),
+         (dpy, d, r, ctx, False), MakeContextCurrent)
index 6403cbd56df9680b3be48e73a46f6efb0d749360..c5322f6d933f3146710fb7dc48f462ca0061b91c 100644 (file)
  */     
 
 #include "glxclient.h"
-#include <stdio.h>
 #include <X11/extensions/Xext.h>
 #include <X11/extensions/extutil.h>
-#include <X11/extensions/Xfixes.h>
-#include <X11/extensions/Xdamage.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/Xlib-xcb.h>
 #include <xcb/xcb.h>
 #include <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 { \
@@ -107,173 +75,11 @@ static int _mesa_sparc_needs_init = 1;
 #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);
-
-
-/************************************************************************/
+_X_HIDDEN int __glXDebug = 0;
 
 /* Extension required boiler plate */
 
@@ -296,16 +102,13 @@ static /* const */ char *error_list[] = {
     "GLXBadWindow",
 };
 
-int __glXCloseDisplay(Display *dpy, XExtCodes *codes)
+static 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
+    __glXSetCurrentContextNull();
     __glXFreeContext(gc);
   }
 
@@ -352,22 +155,27 @@ static void FreeScreenConfigs(__GLXdisplayPrivate *priv)
     for (i = 0; i < screens; i++, psc++) {
        if (psc->configs) {
            _gl_context_modes_destroy( psc->configs );
-           if(psc->effectiveGLXexts)
+           if (psc->effectiveGLXexts)
                Xfree(psc->effectiveGLXexts);
-
            psc->configs = NULL;        /* NOTE: just for paranoia */
        }
-       Xfree((char*) psc->serverGLXexts);
+        if (psc->visuals) {
+            _gl_context_modes_destroy( psc->visuals );
+            psc->visuals = NULL;  /* NOTE: just for paranoia */
+        }
+       Xfree((char*) psc->serverGLXexts);
 
 #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;
+       if (psc->driScreen) {
+           psc->driScreen->destroyScreen(psc);
+           __glxHashDestroy(psc->drawHash);
+            XFree(psc->driScreen);
+            psc->driScreen = NULL;
+       }
 #endif
     }
     XFree((char*) priv->screenConfigs);
+    priv->screenConfigs = NULL;
 }
 
 /*
@@ -391,14 +199,17 @@ static int __glXFreeDisplayPrivate(XExtData *extension)
 
 #ifdef 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;
-    if (priv->driDisplay.createNewScreen) {
-        Xfree(priv->driDisplay.createNewScreen); /* free array of ptrs */
-        priv->driDisplay.createNewScreen = NULL;
-    }
+    if (priv->driswDisplay)
+       (*priv->driswDisplay->destroyDisplay)(priv->driswDisplay);
+    priv->driswDisplay = NULL;
+
+    if (priv->driDisplay)
+       (*priv->driDisplay->destroyDisplay)(priv->driDisplay);
+    priv->driDisplay = NULL;
+
+    if (priv->dri2Display)
+       (*priv->dri2Display->destroyDisplay)(priv->dri2Display);
+    priv->dri2Display = NULL;
 #endif
 
     Xfree((char*) priv);
@@ -440,7 +251,7 @@ static Bool QueryVersion(Display *dpy, int opcode, int *major, int *minor)
 }
 
 
-void 
+_X_HIDDEN void 
 __glXInitializeVisualConfigFromTags( __GLcontextModes *config, int count, 
                                     const INT32 *bp, Bool tagged_only,
                                     Bool fbconfig_style_tags )
@@ -634,371 +445,128 @@ __glXInitializeVisualConfigFromTags( __GLcontextModes *config, int count,
     config->haveStencilBuffer = (config->stencilBits > 0);
 }
 
-
-#ifdef GLX_DIRECT_RENDERING
-static unsigned
-filter_modes( __GLcontextModes ** server_modes,
-             const __GLcontextModes * driver_modes )
+static __GLcontextModes *
+createConfigsFromProperties(Display *dpy, int nvisuals, int nprops,
+                           int screen, GLboolean tagged_only)
 {
-    __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.
-     */
+    INT32 buf[__GLX_TOTAL_CONFIG], *props;
+    unsigned prop_size;
+    __GLcontextModes *modes, *m;
+    int i;
 
-    prev_next = server_modes;
-    for ( m = *prev_next ; m != NULL ; m = *prev_next ) {
-       GLboolean do_delete = GL_TRUE;
+    if (nprops == 0)
+       return NULL;
 
-       for ( check = driver_modes ; check != NULL ; check = check->next ) {
-           if ( _gl_context_modes_are_same( m, check ) ) {
-               do_delete = GL_FALSE;
-               break;
-           }
-       }
+    /* FIXME: Is the __GLX_MIN_CONFIG_PROPS test correct for FBconfigs? */
 
-       /* 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;
-
-            if (getenv("LIBGL_DEBUG")) {
-               fprintf(stderr, "libGL warning: 3D driver claims to not support "
-                       "visual 0x%02x\n", m->visualID);
-            }
-       }
+    /* Check number of properties */
+    if (nprops < __GLX_MIN_CONFIG_PROPS || nprops > __GLX_MAX_CONFIG_PROPS)
+       return NULL;
 
-       if ( do_delete ) {
-           *prev_next = m->next;
+    /* Allocate memory for our config structure */
+    modes = _gl_context_modes_create(nvisuals, sizeof(__GLcontextModes));
+    if (!modes)
+       return NULL;
 
-           m->next = NULL;
-           _gl_context_modes_destroy( m );
-       }
-       else {
-           modes_count++;
-           prev_next = & m->next;
-       }
+    prop_size = nprops * __GLX_SIZE_INT32;
+    if (prop_size <= sizeof(buf))
+       props = buf;
+    else
+       props = Xmalloc(prop_size);
+
+    /* Read each config structure and convert it into our format */
+    m = modes;
+    for (i = 0; i < nvisuals; i++) {
+       _XRead(dpy, (char *)props, prop_size);
+       /* Older X servers don't send this so we default it here. */
+       m->drawableType = GLX_WINDOW_BIT;
+       __glXInitializeVisualConfigFromTags(m, nprops, props,
+                                           tagged_only, GL_TRUE);
+       m->screen = screen;
+       m = m->next;
     }
 
-    return modes_count;
-}
-
+    if (props != buf)
+       Xfree(props);
 
-/**
- * Implement \c __DRIinterfaceMethods::getProcAddress.
- */
-static __DRIfuncPtr get_proc_address( const char * proc_name )
-{
-    if (strcmp( proc_name, "glxEnableExtension" ) == 0) {
-       return (__DRIfuncPtr) __glXScrEnableExtension;
-    }
-    
-    return NULL;
+    return modes;
 }
 
-#ifdef XDAMAGE_1_1_INTERFACE
-static GLboolean has_damage_post(__DRInativeDisplay *dpy)
+static GLboolean
+getVisualConfigs(Display *dpy, __GLXdisplayPrivate *priv, int screen)
 {
-    static GLboolean inited = GL_FALSE;
-    static GLboolean has_damage;
-
-    if (!inited) {
-       int major, minor;
-
-       if (XDamageQueryVersion(dpy, &major, &minor) &&
-           major == 1 && minor >= 1)
-       {
-           has_damage = GL_TRUE;
-       } else {
-           has_damage = GL_FALSE;
-       }
-       inited = GL_TRUE;
-    }
+    xGLXGetVisualConfigsReq *req;
+    __GLXscreenConfigs *psc;
+    xGLXGetVisualConfigsReply reply;
+    
+    LockDisplay(dpy);
 
-    return has_damage;
-}
-#endif /* XDAMAGE_1_1_INTERFACE */
+    psc = priv->screenConfigs + screen;
+    psc->visuals = NULL;
+    GetReq(GLXGetVisualConfigs, req);
+    req->reqType = priv->majorOpcode;
+    req->glxCode = X_GLXGetVisualConfigs;
+    req->screen = screen;
 
-static void __glXReportDamage(__DRInativeDisplay *dpy, int screen,
-                             __DRIid drawable,
-                             int x, int y,
-                             drm_clip_rect_t *rects, int num_rects,
-                             GLboolean front_buffer)
-{
-#ifdef XDAMAGE_1_1_INTERFACE
-    XRectangle *xrects;
-    XserverRegion region;
-    int i;
-    int x_off, y_off;
-
-    if (!has_damage_post(dpy))
-       return;
-
-    if (front_buffer) {
-       x_off = x;
-       y_off = y;
-       drawable = RootWindow(dpy, screen);
-    } else{
-       x_off = 0;
-       y_off = 0;
-    }
+    if (!_XReply(dpy, (xReply*) &reply, 0, False))
+       goto out;
 
-    xrects = malloc(sizeof(XRectangle) * num_rects);
-    if (xrects == NULL)
-       return;
+    psc->visuals = createConfigsFromProperties(dpy,
+                                              reply.numVisuals,
+                                              reply.numProps,
+                                              screen, GL_FALSE);
 
-    for (i = 0; i < num_rects; i++) {
-       xrects[i].x = rects[i].x1 + x_off;
-       xrects[i].y = rects[i].y1 + y_off;
-       xrects[i].width = rects[i].x2 - rects[i].x1;
-       xrects[i].height = rects[i].y2 - rects[i].y1;
-    }
-    region = XFixesCreateRegion(dpy, xrects, num_rects);
-    free(xrects);
-    XDamageAdd(dpy, drawable, region);
-    XFixesDestroyRegion(dpy, region);
-#endif
+ out:
+    UnlockDisplay(dpy);
+    return psc->visuals != 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,
-
-    __glXReportDamage,
-};
-
-
-
-/**
- * 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)
+static GLboolean
+getFBConfigs(Display *dpy, __GLXdisplayPrivate *priv, int screen)
 {
-    __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)) {
-        int newlyopened;
-       fd = drmOpenOnce(NULL,BusID, &newlyopened);
-       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 (!newlyopened || 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);
-       }
+    xGLXGetFBConfigsReq *fb_req;
+    xGLXGetFBConfigsSGIXReq *sgi_req;
+    xGLXVendorPrivateWithReplyReq *vpreq;
+    xGLXGetFBConfigsReply reply;
+    __GLXscreenConfigs *psc;
 
-       if ( framebuffer.dev_priv != NULL ) {
-           Xfree(framebuffer.dev_priv);
-       }
+    psc = priv->screenConfigs + screen;
+    psc->serverGLXexts = __glXGetStringFromServer(dpy, priv->majorOpcode,
+                                                 X_GLXQueryServerString,
+                                                 screen, GLX_EXTENSIONS);
 
-       if ( fd >= 0 ) {
-           (void)drmCloseOnce(fd);
-       }
+    LockDisplay(dpy);
 
-       (void)XF86DRICloseConnection(dpy, scrn);
+    psc->configs = NULL;
+    if (atof(priv->serverGLXversion) >= 1.3) {
+       GetReq(GLXGetFBConfigs, fb_req);
+       fb_req->reqType = priv->majorOpcode;
+       fb_req->glxCode = X_GLXGetFBConfigs;
+       fb_req->screen = screen;
+    } else if (strstr(psc->serverGLXexts, "GLX_SGIX_fbconfig") != NULL) {
+       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 = screen;
+    } else
+       goto out;
 
-       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 );
-       }
+    if (!_XReply(dpy, (xReply*) &reply, 0, False))
+       goto out;
 
-        fprintf(stderr, "libGL error: reverting to (slow) indirect rendering\n");
-    }
-#endif /* !GLX_USE_APPLEGL */
+    psc->configs = createConfigsFromProperties(dpy,
+                                              reply.numFBConfigs,
+                                              reply.numAttribs * 2,
+                                              screen, GL_TRUE);
 
-    return psp;
+ out:
+    UnlockDisplay(dpy);
+    return psc->configs != NULL;
 }
-#endif /* GLX_DIRECT_RENDERING */
-
 
 /*
 ** Allocate the memory for the per screen configs for each screen.
@@ -1006,17 +574,8 @@ CallCreateNewScreen(Display *dpy, int scrn, __DRIscreen *psc,
 */
 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;
+    GLint i, screens;
 
     /*
     ** First allocate memory for the array of per screen configs.
@@ -1030,159 +589,36 @@ static Bool AllocAndFetchScreenConfigs(Display *dpy, __GLXdisplayPrivate *priv)
     priv->screenConfigs = psc;
     
     priv->serverGLXversion = __glXGetStringFromServer(dpy, priv->majorOpcode,
-                                        X_GLXQueryServerString,
-                                        0, GLX_VERSION);
+                                                     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;
-           }
-       }
-
+       getVisualConfigs(dpy, priv, i);
+       getFBConfigs(dpy, priv, i);
 
-       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);
-           SyncHandle();
-           FreeScreenConfigs(priv);
-           return GL_FALSE;
-       }
-
-       if (!reply.numVisuals) {
-           /* This screen does not support GL rendering */
-           UnlockDisplay(dpy);
+#ifdef GLX_DIRECT_RENDERING
+       psc->scr = i;
+       psc->dpy = dpy;
+       psc->drawHash = __glxHashCreate();
+       if (psc->drawHash == NULL)
            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;
-       }
+       if (priv->dri2Display)
+           psc->driScreen = (*priv->dri2Display->createScreen)(psc, i, priv);
 
-       /* 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;
-       }
+       if (psc->driScreen == NULL && priv->driDisplay)
+           psc->driScreen = (*priv->driDisplay->createScreen)(psc, i, priv);
 
-       /* Allocate memory for the properties, if needed */
-       if ( supported_request != 3 ) {
-           nprops *= 2;
-       }
+       if (psc->driScreen == NULL && priv->driswDisplay)
+           psc->driScreen = (*priv->driswDisplay->createScreen)(psc, i, priv);
 
-       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] );
-           }
+       if (psc->driScreen == NULL) {
+           __glxHashDestroy(psc->drawHash);
+           psc->drawHash = NULL;
        }
 #endif
     }
@@ -1193,13 +629,16 @@ static Bool AllocAndFetchScreenConfigs(Display *dpy, __GLXdisplayPrivate *priv)
 /*
 ** Initialize the client side extension code.
 */
-__GLXdisplayPrivate *__glXInitialize(Display* dpy)
+_X_HIDDEN __GLXdisplayPrivate *__glXInitialize(Display* dpy)
 {
     XExtDisplayInfo *info = __glXFindDisplay(dpy);
     XExtData **privList, *private, *found;
     __GLXdisplayPrivate *dpyPriv;
     XEDataObject dataObj;
     int major, minor;
+#ifdef GLX_DIRECT_RENDERING
+    Bool glx_direct, glx_accel;
+#endif
 
 #if defined(USE_XTHREADS)
     {
@@ -1267,15 +706,20 @@ __GLXdisplayPrivate *__glXInitialize(Display* dpy)
     dpyPriv->serverGLXversion = 0x0;
 
 #ifdef GLX_DIRECT_RENDERING
+    glx_direct = (getenv("LIBGL_ALWAYS_INDIRECT") == NULL);
+    glx_accel = (getenv("LIBGL_ALWAYS_SOFTWARE") == NULL);
+
     /*
     ** 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") == NULL) {
-        dpyPriv->driDisplay.private =
-            driCreateDisplay(dpy, &dpyPriv->driDisplay);
+    if (glx_direct && glx_accel) {
+       dpyPriv->dri2Display = dri2CreateDisplay(dpy);
+       dpyPriv->driDisplay = driCreateDisplay(dpy);
     }
+    if (glx_direct)
+       dpyPriv->driswDisplay = driswCreateDisplay(dpy);
 #endif
 
     if (!AllocAndFetchScreenConfigs(dpy, dpyPriv)) {
@@ -1308,7 +752,7 @@ __GLXdisplayPrivate *__glXInitialize(Display* dpy)
 ** 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)
+_X_HIDDEN CARD8 __glXSetupForCommand(Display *dpy)
 {
     GLXContext gc;
     __GLXdisplayPrivate *priv;
@@ -1349,7 +793,7 @@ CARD8 __glXSetupForCommand(Display *dpy)
  * Modify this function to use \c ctx->pc instead of the explicit
  * \c pc parameter.
  */
-GLubyte *__glXFlushRenderBuffer(__GLXcontext *ctx, GLubyte *pc)
+_X_HIDDEN GLubyte *__glXFlushRenderBuffer(__GLXcontext *ctx, GLubyte *pc)
 {
     Display * const dpy = ctx->currentDpy;
 #ifdef USE_XCB
@@ -1361,7 +805,8 @@ GLubyte *__glXFlushRenderBuffer(__GLXcontext *ctx, GLubyte *pc)
 
     if ( (dpy != NULL) && (size > 0) ) {
 #ifdef USE_XCB
-       xcb_glx_render(c, ctx->currentContextTag, size, (char *)ctx->buf);
+       xcb_glx_render(c, ctx->currentContextTag, size,
+                      (const uint8_t *)ctx->buf);
 #else
        /* Send the entire buffer as an X request */
        LockDisplay(dpy);
@@ -1398,9 +843,9 @@ GLubyte *__glXFlushRenderBuffer(__GLXcontext *ctx, GLubyte *pc)
  * \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)
+_X_HIDDEN void __glXSendLargeChunk(__GLXcontext *gc, GLint requestNumber, 
+                                  GLint totalRequests,
+                                  const GLvoid * data, GLint dataLen)
 {
     Display *dpy = gc->currentDpy;
 #ifdef USE_XCB
@@ -1446,9 +891,9 @@ void __glXSendLargeChunk(__GLXcontext *gc, GLint requestNumber,
  * \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)
+_X_HIDDEN void __glXSendLargeCommand(__GLXcontext *ctx,
+                                    const GLvoid *header, GLint headerLen,
+                                    const GLvoid *data, GLint dataLen)
 {
     GLint maxSize;
     GLint totalRequests, requestNumber;
@@ -1484,330 +929,8 @@ void __glXSendLargeCommand(__GLXcontext *ctx,
 
 /************************************************************************/
 
-PUBLIC GLXContext glXGetCurrentContext(void)
-{
-    GLXContext cx = __glXGetCurrentContext();
-    
-    if (cx == &dummyContext) {
-       return NULL;
-    } else {
-       return cx;
-    }
-}
-
-PUBLIC 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)
-{
-    Bool ret;
-
-
-    LockDisplay(dpy);
-
-    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;
-       }
-    }
-
-    ret = _XReply(dpy, (xReply*) reply, 0, False);
-
-    UnlockDisplay(dpy);
-    SyncHandle();
-
-    return ret;
-}
-
-
-#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;
-    const GLXContext oldGC = __glXGetCurrentContext();
-    const CARD8 opcode = __glXSetupForCommand(dpy);
-    const CARD8 oldOpcode = ((gc == oldGC) || (oldGC == &dummyContext))
-      ? opcode : __glXSetupForCommand(oldGC->currentDpy);
-    Bool bindReturnValue;
-
-
-    if (!opcode || !oldOpcode) {
-       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;
-    }
-
-#ifndef GLX_DIRECT_RENDERING
-    if (gc && gc->isDirect) {
-       return GL_FALSE;
-    }
-#endif
-
-    _glapi_check_multithread();
-
-#ifdef GLX_DIRECT_RENDERING
-    /* Bind the direct rendering context to the drawable */
-    if (gc && gc->isDirect) {
-       bindReturnValue = (gc->driContext.private) 
-         ? BindContextWrapper(dpy, gc, draw, read)
-         : False;
-    } else
-#endif
-    {
-       /* Send a glXMakeCurrent request to bind the new context. */
-       bindReturnValue = 
-         SendMakeCurrentRequest(dpy, opcode, gc ? gc->xid : None,
-                                ((dpy != oldGC->currentDpy) || oldGC->isDirect)
-                                ? None : oldGC->currentContextTag,
-                                draw, read, &reply);
-    }
-
-
-    if (!bindReturnValue) {
-       return False;
-    }
-
-    if ((dpy != oldGC->currentDpy || (gc && gc->isDirect)) &&
-       !oldGC->isDirect && oldGC != &dummyContext) {
-       xGLXMakeCurrentReply dummy_reply;
-
-       /* 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.
-        */
-       (void) SendMakeCurrentRequest(oldGC->currentDpy, oldOpcode, None,
-                                     oldGC->currentContextTag, None, None,
-                                     & dummy_reply);
-    }
-#ifdef GLX_DIRECT_RENDERING
-    else if (oldGC->isDirect && oldGC->driContext.private) {
-       (void) UnbindContextWrapper(oldGC);
-    }
-#endif
-
-
-    /* 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);
-
-           gc->currentDpy = dpy;
-           gc->currentDrawable = draw;
-           gc->currentReadable = read;
-
-            if (!gc->isDirect) {
-               if (!IndirectAPI)
-                  IndirectAPI = __glXNewIndirectAPI();
-               _glapi_set_dispatch(IndirectAPI);
-
-#ifdef GLX_USE_APPLEGL
-               do {
-                   extern void XAppleDRIUseIndirectDispatch(void);
-                   XAppleDRIUseIndirectDispatch();
-               } while (0);
-#endif
-
-               __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)
+_X_HIDDEN void __glXDumpDrawBuffer(__GLXcontext *ctx)
 {
     GLubyte *p = ctx->buf;
     GLubyte *end = ctx->pc;
@@ -1832,9 +955,23 @@ void __glXDumpDrawBuffer(__GLXcontext *ctx)
 
 #ifdef  USE_SPARC_ASM
 /*
- * Used only when we are sparc, using sparc assembler.
+ * 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)
index 1d99b61db085f6f873eb3fbe9db5e6f3579f4063..e84371847225d04fc328acc352ec373e5557ee7f 100644 (file)
@@ -356,28 +356,15 @@ __glXProcessServerString( const struct extension_info * ext,
    }
 }
 
-
-/**
- * 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 )
+__glXEnableDirectExtension(__GLXscreenConfigs *psc, const char *name)
 {
-   __glXExtensionsCtr();
-   __glXExtensionsCtrScreen(psc);
-   set_glx_extension( known_glx_extensions, name, strlen( name ), GL_TRUE,
-                     psc->direct_support );
-}
+    __glXExtensionsCtr();
+    __glXExtensionsCtrScreen(psc);
 
+    set_glx_extension(known_glx_extensions,
+                     name, strlen(name), GL_TRUE, psc->direct_support);
+}
 
 /**
  * Initialize global extension support tables.
index a4241b6b7f97d016370fecd43a2fa0c372b46aaf..b99cebbdfafe68f9c2acf13da03f038b521a47ef 100644 (file)
@@ -234,7 +234,7 @@ extern GLboolean __glXExtensionBitIsEnabled( struct __GLXscreenConfigsRec *psc,
 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 );
@@ -243,6 +243,8 @@ extern char * __glXGetClientGLExtensionString( void );
 extern GLboolean __glExtensionBitIsEnabled( const struct __GLXcontextRec * gc, 
     unsigned bit );
 
+extern void
+__glXEnableDirectExtension(struct __GLXscreenConfigsRec *psc, const char *name);
 
 /* Source-level backwards compatibility with old drivers. They won't
  * find the respective functions, though. 
diff --git a/src/glx/x11/glxhash.c b/src/glx/x11/glxhash.c
new file mode 100644 (file)
index 0000000..b7b8fb2
--- /dev/null
@@ -0,0 +1,414 @@
+/* glxhash.c -- Small hash table support for integer -> integer mapping
+ * Taken from libdrm.
+ *
+ * Created: Sun Apr 18 09:35:45 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.
+ *
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ * DESCRIPTION
+ *
+ * This file contains a straightforward implementation of a fixed-sized
+ * hash table using self-organizing linked lists [Knuth73, pp. 398-399] for
+ * collision resolution.  There are two potentially interesting things
+ * about this implementation:
+ *
+ * 1) The table is power-of-two sized.  Prime sized tables are more
+ * traditional, but do not have a significant advantage over power-of-two
+ * sized table, especially when double hashing is not used for collision
+ * resolution.
+ *
+ * 2) The hash computation uses a table of random integers [Hanson97,
+ * pp. 39-41].
+ *
+ * FUTURE ENHANCEMENTS
+ *
+ * With a table size of 512, the current implementation is sufficient for a
+ * few hundred keys.  Since this is well above the expected size of the
+ * tables for which this implementation was designed, the implementation of
+ * dynamic hash tables was postponed until the need arises.  A common (and
+ * naive) approach to dynamic hash table implementation simply creates a
+ * new hash table when necessary, rehashes all the data into the new table,
+ * and destroys the old table.  The approach in [Larson88] is superior in
+ * two ways: 1) only a portion of the table is expanded when needed,
+ * distributing the expansion cost over several insertions, and 2) portions
+ * of the table can be locked, enabling a scalable thread-safe
+ * implementation.
+ *
+ * REFERENCES
+ *
+ * [Hanson97] David R. Hanson.  C Interfaces and Implementations:
+ * Techniques for Creating Reusable Software.  Reading, Massachusetts:
+ * Addison-Wesley, 1997.
+ *
+ * [Knuth73] Donald E. Knuth. The Art of Computer Programming.  Volume 3:
+ * Sorting and Searching.  Reading, Massachusetts: Addison-Wesley, 1973.
+ *
+ * [Larson88] Per-Ake Larson. "Dynamic Hash Tables".  CACM 31(4), April
+ * 1988, pp. 446-457.
+ *
+ */
+
+#include "glxhash.h"
+#include <X11/Xfuncproto.h>
+
+#define HASH_MAIN 0
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define HASH_MAGIC 0xdeadbeef
+#define HASH_DEBUG 0
+#define HASH_SIZE  512         /* Good for about 100 entries */
+                               /* If you change this value, you probably
+                                   have to change the HashHash hashing
+                                   function! */
+
+#define HASH_ALLOC malloc
+#define HASH_FREE  free
+#define HASH_RANDOM_DECL
+#define HASH_RANDOM_INIT(seed)  srandom(seed)
+#define HASH_RANDOM             random()
+#define HASH_RANDOM_DESTROY
+
+typedef struct __glxHashBucket {
+    unsigned long     key;
+    void              *value;
+    struct __glxHashBucket *next;
+} __glxHashBucket, *__glxHashBucketPtr;
+
+typedef struct __glxHashTable *__glxHashTablePtr;
+struct __glxHashTable {
+    unsigned long    magic;
+    unsigned long    hits;     /* At top of linked list */
+    unsigned long    partials; /* Not at top of linked list */
+    unsigned long    misses;   /* Not in table */
+    __glxHashBucketPtr    buckets[HASH_SIZE];
+    int              p0;
+    __glxHashBucketPtr    p1;
+};
+
+static unsigned long HashHash(unsigned long key)
+{
+    unsigned long        hash = 0;
+    unsigned long        tmp  = key;
+    static int           init = 0;
+    static unsigned long scatter[256];
+    int                  i;
+
+    if (!init) {
+       HASH_RANDOM_DECL;
+       HASH_RANDOM_INIT(37);
+       for (i = 0; i < 256; i++) scatter[i] = HASH_RANDOM;
+       HASH_RANDOM_DESTROY;
+       ++init;
+    }
+
+    while (tmp) {
+       hash = (hash << 1) + scatter[tmp & 0xff];
+       tmp >>= 8;
+    }
+
+    hash %= HASH_SIZE;
+#if HASH_DEBUG
+    printf( "Hash(%d) = %d\n", key, hash);
+#endif
+    return hash;
+}
+
+_X_HIDDEN __glxHashTable *__glxHashCreate(void)
+{
+    __glxHashTablePtr table;
+    int          i;
+
+    table           = HASH_ALLOC(sizeof(*table));
+    if (!table) return NULL;
+    table->magic    = HASH_MAGIC;
+    table->hits     = 0;
+    table->partials = 0;
+    table->misses   = 0;
+
+    for (i = 0; i < HASH_SIZE; i++) table->buckets[i] = NULL;
+    return table;
+}
+
+_X_HIDDEN int __glxHashDestroy(__glxHashTable *t)
+{
+    __glxHashTablePtr  table = (__glxHashTablePtr)t;
+    __glxHashBucketPtr bucket;
+    __glxHashBucketPtr next;
+    int           i;
+
+    if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
+
+    for (i = 0; i < HASH_SIZE; i++) {
+       for (bucket = table->buckets[i]; bucket;) {
+           next = bucket->next;
+           HASH_FREE(bucket);
+           bucket = next;
+       }
+    }
+    HASH_FREE(table);
+    return 0;
+}
+
+/* Find the bucket and organize the list so that this bucket is at the
+   top. */
+
+static __glxHashBucketPtr HashFind(__glxHashTablePtr table,
+                             unsigned long key, unsigned long *h)
+{
+    unsigned long hash = HashHash(key);
+    __glxHashBucketPtr prev = NULL;
+    __glxHashBucketPtr bucket;
+
+    if (h) *h = hash;
+
+    for (bucket = table->buckets[hash]; bucket; bucket = bucket->next) {
+       if (bucket->key == key) {
+           if (prev) {
+                               /* Organize */
+               prev->next           = bucket->next;
+               bucket->next         = table->buckets[hash];
+               table->buckets[hash] = bucket;
+               ++table->partials;
+           } else {
+               ++table->hits;
+           }
+           return bucket;
+       }
+       prev = bucket;
+    }
+    ++table->misses;
+    return NULL;
+}
+
+_X_HIDDEN int __glxHashLookup(__glxHashTable *t,
+                             unsigned long key, void **value)
+{
+    __glxHashTablePtr  table = (__glxHashTablePtr)t;
+    __glxHashBucketPtr bucket;
+
+    if (!table || table->magic != HASH_MAGIC) return -1; /* Bad magic */
+
+    bucket = HashFind(table, key, NULL);
+    if (!bucket) return 1;     /* Not found */
+    *value = bucket->value;
+    return 0;                  /* Found */
+}
+
+_X_HIDDEN int __glxHashInsert(__glxHashTable *t,
+                             unsigned long key, void *value)
+{
+    __glxHashTablePtr  table = (__glxHashTablePtr)t;
+    __glxHashBucketPtr bucket;
+    unsigned long hash;
+
+    if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
+
+    if (HashFind(table, key, &hash)) return 1; /* Already in table */
+
+    bucket               = HASH_ALLOC(sizeof(*bucket));
+    if (!bucket) return -1;    /* Error */
+    bucket->key          = key;
+    bucket->value        = value;
+    bucket->next         = table->buckets[hash];
+    table->buckets[hash] = bucket;
+#if HASH_DEBUG
+    printf("Inserted %d at %d/%p\n", key, hash, bucket);
+#endif
+    return 0;                  /* Added to table */
+}
+
+_X_HIDDEN int __glxHashDelete(__glxHashTable *t, unsigned long key)
+{
+    __glxHashTablePtr  table = (__glxHashTablePtr)t;
+    unsigned long hash;
+    __glxHashBucketPtr bucket;
+
+    if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
+
+    bucket = HashFind(table, key, &hash);
+
+    if (!bucket) return 1;     /* Not found */
+
+    table->buckets[hash] = bucket->next;
+    HASH_FREE(bucket);
+    return 0;
+}
+
+_X_HIDDEN int __glxHashNext(__glxHashTable *t,
+                           unsigned long *key, void **value)
+{
+    __glxHashTablePtr  table = (__glxHashTablePtr)t;
+
+    while (table->p0 < HASH_SIZE) {
+       if (table->p1) {
+           *key       = table->p1->key;
+           *value     = table->p1->value;
+           table->p1  = table->p1->next;
+           return 1;
+       }
+       table->p1 = table->buckets[table->p0];
+       ++table->p0;
+    }
+    return 0;
+}
+
+_X_HIDDEN int __glxHashFirst(__glxHashTable *t,
+                            unsigned long *key, void **value)
+{
+    __glxHashTablePtr  table = (__glxHashTablePtr)t;
+
+    if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
+
+    table->p0 = 0;
+    table->p1 = table->buckets[0];
+    return __glxHashNext(table, key, value);
+}
+
+#if HASH_MAIN
+#define DIST_LIMIT 10
+static int dist[DIST_LIMIT];
+
+static void clear_dist(void) {
+    int i;
+
+    for (i = 0; i < DIST_LIMIT; i++) dist[i] = 0;
+}
+
+static int count_entries(__glxHashBucketPtr bucket)
+{
+    int count = 0;
+
+    for (; bucket; bucket = bucket->next) ++count;
+    return count;
+}
+
+static void update_dist(int count)
+{
+    if (count >= DIST_LIMIT) ++dist[DIST_LIMIT-1];
+    else                     ++dist[count];
+}
+
+static void compute_dist(__glxHashTablePtr table)
+{
+    int           i;
+    __glxHashBucketPtr bucket;
+
+    printf("Hits = %ld, partials = %ld, misses = %ld\n",
+          table->hits, table->partials, table->misses);
+    clear_dist();
+    for (i = 0; i < HASH_SIZE; i++) {
+       bucket = table->buckets[i];
+       update_dist(count_entries(bucket));
+    }
+    for (i = 0; i < DIST_LIMIT; i++) {
+       if (i != DIST_LIMIT-1) printf("%5d %10d\n", i, dist[i]);
+       else                   printf("other %10d\n", dist[i]);
+    }
+}
+
+static void check_table(__glxHashTablePtr table,
+                       unsigned long key, unsigned long value)
+{
+    unsigned long retval  = 0;
+    int           retcode = __glxHashLookup(table, key, &retval);
+
+    switch (retcode) {
+    case -1:
+       printf("Bad magic = 0x%08lx:"
+              " key = %lu, expected = %lu, returned = %lu\n",
+              table->magic, key, value, retval);
+       break;
+    case 1:
+       printf("Not found: key = %lu, expected = %lu returned = %lu\n",
+              key, value, retval);
+       break;
+    case 0:
+       if (value != retval)
+           printf("Bad value: key = %lu, expected = %lu, returned = %lu\n",
+                  key, value, retval);
+       break;
+    default:
+       printf("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n",
+              retcode, key, value, retval);
+       break;
+    }
+}
+
+int main(void)
+{
+    __glxHashTablePtr table;
+    int          i;
+
+    printf("\n***** 256 consecutive integers ****\n");
+    table = __glxHashCreate();
+    for (i = 0; i < 256; i++) __glxHashInsert(table, i, i);
+    for (i = 0; i < 256; i++) check_table(table, i, i);
+    for (i = 256; i >= 0; i--) check_table(table, i, i);
+    compute_dist(table);
+    __glxHashDestroy(table);
+
+    printf("\n***** 1024 consecutive integers ****\n");
+    table = __glxHashCreate();
+    for (i = 0; i < 1024; i++) __glxHashInsert(table, i, i);
+    for (i = 0; i < 1024; i++) check_table(table, i, i);
+    for (i = 1024; i >= 0; i--) check_table(table, i, i);
+    compute_dist(table);
+    __glxHashDestroy(table);
+
+    printf("\n***** 1024 consecutive page addresses (4k pages) ****\n");
+    table = __glxHashCreate();
+    for (i = 0; i < 1024; i++) __glxHashInsert(table, i*4096, i);
+    for (i = 0; i < 1024; i++) check_table(table, i*4096, i);
+    for (i = 1024; i >= 0; i--) check_table(table, i*4096, i);
+    compute_dist(table);
+    __glxHashDestroy(table);
+
+    printf("\n***** 1024 random integers ****\n");
+    table = __glxHashCreate();
+    srandom(0xbeefbeef);
+    for (i = 0; i < 1024; i++) __glxHashInsert(table, random(), i);
+    srandom(0xbeefbeef);
+    for (i = 0; i < 1024; i++) check_table(table, random(), i);
+    srandom(0xbeefbeef);
+    for (i = 0; i < 1024; i++) check_table(table, random(), i);
+    compute_dist(table);
+    __glxHashDestroy(table);
+
+    printf("\n***** 5000 random integers ****\n");
+    table = __glxHashCreate();
+    srandom(0xbeefbeef);
+    for (i = 0; i < 5000; i++) __glxHashInsert(table, random(), i);
+    srandom(0xbeefbeef);
+    for (i = 0; i < 5000; i++) check_table(table, random(), i);
+    srandom(0xbeefbeef);
+    for (i = 0; i < 5000; i++) check_table(table, random(), i);
+    compute_dist(table);
+    __glxHashDestroy(table);
+
+    return 0;
+}
+#endif
diff --git a/src/glx/x11/glxhash.h b/src/glx/x11/glxhash.h
new file mode 100644 (file)
index 0000000..66012fb
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef _GLX_HASH_H_
+#define _GLX_HASH_H_
+
+
+typedef struct __glxHashTable __glxHashTable;
+
+/* Hash table routines */
+extern __glxHashTable *__glxHashCreate(void);
+extern int  __glxHashDestroy(__glxHashTable *t);
+extern int  __glxHashLookup(__glxHashTable *t, unsigned long key, void **value);
+extern int  __glxHashInsert(__glxHashTable *t, unsigned long key, void *value);
+extern int  __glxHashDelete(__glxHashTable *t, unsigned long key);
+extern int  __glxHashFirst(__glxHashTable *t, unsigned long *key, void **value);
+extern int  __glxHashNext(__glxHashTable *t, unsigned long *key, void **value);
+
+#endif /* _GLX_HASH_H_ */
index fbb2a91956c913d88b84afc39f00b557e74950a9..82e1b2edccd811ea25668214595a8f8ebc2fd64b 100644 (file)
@@ -300,7 +300,9 @@ __indirect_glNewList(GLuint list, GLenum mode)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -324,7 +326,9 @@ __indirect_glEndList(void)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 0;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -360,6 +364,10 @@ __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 (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect((n >= 0) && (gc->currentDpy != NULL), 1)) {
         if (cmdlen <= gc->maxSmallRenderCommandSize) {
             if ((gc->pc + cmdlen) > gc->bufEnd) {
@@ -393,7 +401,9 @@ __indirect_glDeleteLists(GLuint list, GLsizei range)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -418,7 +428,9 @@ __indirect_glGenLists(GLsizei range)
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
     GLuint retval = (GLuint) 0;
+#ifndef USE_XCB
     const GLuint cmdlen = 4;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -3582,6 +3594,10 @@ __indirect_glPixelMapfv(GLenum map, GLsizei mapsize, const GLfloat * values)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 12 + __GLX_PAD((mapsize * 4));
+    if (mapsize < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect((mapsize >= 0) && (gc->currentDpy != NULL), 1)) {
         if (cmdlen <= gc->maxSmallRenderCommandSize) {
             if ((gc->pc + cmdlen) > gc->bufEnd) {
@@ -3615,6 +3631,10 @@ __indirect_glPixelMapuiv(GLenum map, GLsizei mapsize, const GLuint * values)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 12 + __GLX_PAD((mapsize * 4));
+    if (mapsize < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect((mapsize >= 0) && (gc->currentDpy != NULL), 1)) {
         if (cmdlen <= gc->maxSmallRenderCommandSize) {
             if ((gc->pc + cmdlen) > gc->bufEnd) {
@@ -3648,6 +3668,10 @@ __indirect_glPixelMapusv(GLenum map, GLsizei mapsize, const GLushort * values)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 12 + __GLX_PAD((mapsize * 2));
+    if (mapsize < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect((mapsize >= 0) && (gc->currentDpy != NULL), 1)) {
         if (cmdlen <= gc->maxSmallRenderCommandSize) {
             if ((gc->pc + cmdlen) > gc->bufEnd) {
@@ -3716,7 +3740,9 @@ __indirect_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
     __GLXcontext *const gc = __glXGetCurrentContext();
     const __GLXattribute *const state = gc->client_state_private;
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 28;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -3808,7 +3834,9 @@ __indirect_glGetClipPlane(GLenum plane, GLdouble * equation)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 4;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -3841,7 +3869,9 @@ __indirect_glGetLightfv(GLenum light, GLenum pname, GLfloat * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -3879,7 +3909,9 @@ __indirect_glGetLightiv(GLenum light, GLenum pname, GLint * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -3917,7 +3949,9 @@ __indirect_glGetMapdv(GLenum target, GLenum query, GLdouble * v)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -3953,7 +3987,9 @@ __indirect_glGetMapfv(GLenum target, GLenum query, GLfloat * v)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -3989,7 +4025,9 @@ __indirect_glGetMapiv(GLenum target, GLenum query, GLint * v)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -4025,7 +4063,9 @@ __indirect_glGetMaterialfv(GLenum face, GLenum pname, GLfloat * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -4063,7 +4103,9 @@ __indirect_glGetMaterialiv(GLenum face, GLenum pname, GLint * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -4101,7 +4143,9 @@ __indirect_glGetPixelMapfv(GLenum map, GLfloat * values)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 4;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -4137,7 +4181,9 @@ __indirect_glGetPixelMapuiv(GLenum map, GLuint * values)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 4;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -4174,7 +4220,9 @@ __indirect_glGetPixelMapusv(GLenum map, GLushort * values)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 4;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -4210,9 +4258,10 @@ void
 __indirect_glGetPolygonStipple(GLubyte *mask)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
-    const __GLXattribute *const state = gc->client_state_private;
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 4;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -4247,7 +4296,9 @@ __indirect_glGetTexEnvfv(GLenum target, GLenum pname, GLfloat * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -4285,7 +4336,9 @@ __indirect_glGetTexEnviv(GLenum target, GLenum pname, GLint * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -4323,7 +4376,9 @@ __indirect_glGetTexGendv(GLenum coord, GLenum pname, GLdouble * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -4361,7 +4416,9 @@ __indirect_glGetTexGenfv(GLenum coord, GLenum pname, GLfloat * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -4399,7 +4456,9 @@ __indirect_glGetTexGeniv(GLenum coord, GLenum pname, GLint * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -4439,7 +4498,9 @@ __indirect_glGetTexImage(GLenum target, GLint level, GLenum format,
     __GLXcontext *const gc = __glXGetCurrentContext();
     const __GLXattribute *const state = gc->client_state_private;
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 20;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -4483,7 +4544,9 @@ __indirect_glGetTexParameterfv(GLenum target, GLenum pname, GLfloat * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -4522,7 +4585,9 @@ __indirect_glGetTexParameteriv(GLenum target, GLenum pname, GLint * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -4562,7 +4627,9 @@ __indirect_glGetTexLevelParameterfv(GLenum target, GLint level, GLenum pname,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 12;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -4603,7 +4670,9 @@ __indirect_glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 12;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -4644,7 +4713,9 @@ __indirect_glIsList(GLuint list)
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
     GLboolean retval = (GLboolean) 0;
+#ifndef USE_XCB
     const GLuint cmdlen = 4;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -5012,7 +5083,13 @@ __indirect_glAreTexturesResident(GLsizei n, const GLuint * textures,
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
     GLboolean retval = (GLboolean) 0;
+#ifndef USE_XCB
     const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
+#endif
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return 0;
+    }
     if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -5047,14 +5124,21 @@ glAreTexturesResidentEXT(GLsizei n, const GLuint * textures,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-    if (gc->isDirect) {
+#ifdef GLX_DIRECT_RENDERING
+    if (gc->driContext) {
         return CALL_AreTexturesResident(GET_DISPATCH(),
                                         (n, textures, residences));
-    } else {
+    } else
+#endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         Display *const dpy = gc->currentDpy;
         GLboolean retval = (GLboolean) 0;
         const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
+        if (n < 0) {
+            __glXSetError(gc, GL_INVALID_VALUE);
+            return 0;
+        }
         if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
             GLubyte const *pc =
                 __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply,
@@ -5163,7 +5247,13 @@ __indirect_glDeleteTextures(GLsizei n, const GLuint * textures)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
+#endif
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -5187,12 +5277,19 @@ glDeleteTexturesEXT(GLsizei n, const GLuint * textures)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-    if (gc->isDirect) {
+#ifdef GLX_DIRECT_RENDERING
+    if (gc->driContext) {
         CALL_DeleteTextures(GET_DISPATCH(), (n, textures));
-    } else {
+    } else
+#endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         Display *const dpy = gc->currentDpy;
         const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
+        if (n < 0) {
+            __glXSetError(gc, GL_INVALID_VALUE);
+            return;
+        }
         if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
             GLubyte const *pc =
                 __glXSetupVendorRequest(gc, X_GLXVendorPrivate,
@@ -5212,7 +5309,13 @@ __indirect_glGenTextures(GLsizei n, GLuint * textures)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 4;
+#endif
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -5245,12 +5348,19 @@ glGenTexturesEXT(GLsizei n, GLuint * textures)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-    if (gc->isDirect) {
+#ifdef GLX_DIRECT_RENDERING
+    if (gc->driContext) {
         CALL_GenTextures(GET_DISPATCH(), (n, textures));
-    } else {
+    } else
+#endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         Display *const dpy = gc->currentDpy;
         const GLuint cmdlen = 4;
+        if (n < 0) {
+            __glXSetError(gc, GL_INVALID_VALUE);
+            return;
+        }
         if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
             GLubyte const *pc =
                 __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply,
@@ -5271,7 +5381,9 @@ __indirect_glIsTexture(GLuint texture)
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
     GLboolean retval = (GLboolean) 0;
+#ifndef USE_XCB
     const GLuint cmdlen = 4;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -5301,9 +5413,12 @@ glIsTextureEXT(GLuint texture)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-    if (gc->isDirect) {
+#ifdef GLX_DIRECT_RENDERING
+    if (gc->driContext) {
         return CALL_IsTexture(GET_DISPATCH(), (texture));
-    } else {
+    } else
+#endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         Display *const dpy = gc->currentDpy;
         GLboolean retval = (GLboolean) 0;
@@ -5328,6 +5443,10 @@ __indirect_glPrioritizeTextures(GLsizei n, const GLuint * textures,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 8 + __GLX_PAD((n * 4)) + __GLX_PAD((n * 4));
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(n >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_PrioritizeTextures, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (&n), 4);
@@ -5565,7 +5684,9 @@ __indirect_glGetColorTable(GLenum target, GLenum format, GLenum type,
     __GLXcontext *const gc = __glXGetCurrentContext();
     const __GLXattribute *const state = gc->client_state_private;
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 16;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -5609,9 +5730,12 @@ glGetColorTableEXT(GLenum target, GLenum format, GLenum type, GLvoid * table)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-    if (gc->isDirect) {
+#ifdef GLX_DIRECT_RENDERING
+    if (gc->driContext) {
         CALL_GetColorTable(GET_DISPATCH(), (target, format, type, table));
-    } else {
+    } else
+#endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         const __GLXattribute *const state = gc->client_state_private;
         Display *const dpy = gc->currentDpy;
@@ -5641,7 +5765,9 @@ __indirect_glGetColorTableParameterfv(GLenum target, GLenum pname,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -5680,10 +5806,13 @@ glGetColorTableParameterfvEXT(GLenum target, GLenum pname, GLfloat * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-    if (gc->isDirect) {
+#ifdef GLX_DIRECT_RENDERING
+    if (gc->driContext) {
         CALL_GetColorTableParameterfv(GET_DISPATCH(),
                                       (target, pname, params));
-    } else {
+    } else
+#endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         Display *const dpy = gc->currentDpy;
         const GLuint cmdlen = 8;
@@ -5709,7 +5838,9 @@ __indirect_glGetColorTableParameteriv(GLenum target, GLenum pname,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -5748,10 +5879,13 @@ glGetColorTableParameterivEXT(GLenum target, GLenum pname, GLint * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-    if (gc->isDirect) {
+#ifdef GLX_DIRECT_RENDERING
+    if (gc->driContext) {
         CALL_GetColorTableParameteriv(GET_DISPATCH(),
                                       (target, pname, params));
-    } else {
+    } else
+#endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         Display *const dpy = gc->currentDpy;
         const GLuint cmdlen = 8;
@@ -6029,7 +6163,9 @@ __indirect_glGetConvolutionFilter(GLenum target, GLenum format, GLenum type,
     __GLXcontext *const gc = __glXGetCurrentContext();
     const __GLXattribute *const state = gc->client_state_private;
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 16;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -6069,10 +6205,13 @@ gl_dispatch_stub_356(GLenum target, GLenum format, GLenum type,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-    if (gc->isDirect) {
+#ifdef GLX_DIRECT_RENDERING
+    if (gc->driContext) {
         CALL_GetConvolutionFilter(GET_DISPATCH(),
                                   (target, format, type, image));
-    } else {
+    } else
+#endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         const __GLXattribute *const state = gc->client_state_private;
         Display *const dpy = gc->currentDpy;
@@ -6103,7 +6242,9 @@ __indirect_glGetConvolutionParameterfv(GLenum target, GLenum pname,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -6142,10 +6283,13 @@ gl_dispatch_stub_357(GLenum target, GLenum pname, GLfloat * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-    if (gc->isDirect) {
+#ifdef GLX_DIRECT_RENDERING
+    if (gc->driContext) {
         CALL_GetConvolutionParameterfv(GET_DISPATCH(),
                                        (target, pname, params));
-    } else {
+    } else
+#endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         Display *const dpy = gc->currentDpy;
         const GLuint cmdlen = 8;
@@ -6171,7 +6315,9 @@ __indirect_glGetConvolutionParameteriv(GLenum target, GLenum pname,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -6210,10 +6356,13 @@ gl_dispatch_stub_358(GLenum target, GLenum pname, GLint * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-    if (gc->isDirect) {
+#ifdef GLX_DIRECT_RENDERING
+    if (gc->driContext) {
         CALL_GetConvolutionParameteriv(GET_DISPATCH(),
                                        (target, pname, params));
-    } else {
+    } else
+#endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         Display *const dpy = gc->currentDpy;
         const GLuint cmdlen = 8;
@@ -6240,7 +6389,9 @@ __indirect_glGetHistogram(GLenum target, GLboolean reset, GLenum format,
     __GLXcontext *const gc = __glXGetCurrentContext();
     const __GLXattribute *const state = gc->client_state_private;
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 16;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -6285,10 +6436,13 @@ gl_dispatch_stub_361(GLenum target, GLboolean reset, GLenum format,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-    if (gc->isDirect) {
+#ifdef GLX_DIRECT_RENDERING
+    if (gc->driContext) {
         CALL_GetHistogram(GET_DISPATCH(),
                           (target, reset, format, type, values));
-    } else {
+    } else
+#endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         const __GLXattribute *const state = gc->client_state_private;
         Display *const dpy = gc->currentDpy;
@@ -6319,7 +6473,9 @@ __indirect_glGetHistogramParameterfv(GLenum target, GLenum pname,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -6357,9 +6513,12 @@ gl_dispatch_stub_362(GLenum target, GLenum pname, GLfloat * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-    if (gc->isDirect) {
+#ifdef GLX_DIRECT_RENDERING
+    if (gc->driContext) {
         CALL_GetHistogramParameterfv(GET_DISPATCH(), (target, pname, params));
-    } else {
+    } else
+#endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         Display *const dpy = gc->currentDpy;
         const GLuint cmdlen = 8;
@@ -6385,7 +6544,9 @@ __indirect_glGetHistogramParameteriv(GLenum target, GLenum pname,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -6423,9 +6584,12 @@ gl_dispatch_stub_363(GLenum target, GLenum pname, GLint * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-    if (gc->isDirect) {
+#ifdef GLX_DIRECT_RENDERING
+    if (gc->driContext) {
         CALL_GetHistogramParameteriv(GET_DISPATCH(), (target, pname, params));
-    } else {
+    } else
+#endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         Display *const dpy = gc->currentDpy;
         const GLuint cmdlen = 8;
@@ -6452,7 +6616,9 @@ __indirect_glGetMinmax(GLenum target, GLboolean reset, GLenum format,
     __GLXcontext *const gc = __glXGetCurrentContext();
     const __GLXattribute *const state = gc->client_state_private;
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 16;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -6493,9 +6659,12 @@ gl_dispatch_stub_364(GLenum target, GLboolean reset, GLenum format,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-    if (gc->isDirect) {
+#ifdef GLX_DIRECT_RENDERING
+    if (gc->driContext) {
         CALL_GetMinmax(GET_DISPATCH(), (target, reset, format, type, values));
-    } else {
+    } else
+#endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         const __GLXattribute *const state = gc->client_state_private;
         Display *const dpy = gc->currentDpy;
@@ -6526,7 +6695,9 @@ __indirect_glGetMinmaxParameterfv(GLenum target, GLenum pname,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -6562,9 +6733,12 @@ gl_dispatch_stub_365(GLenum target, GLenum pname, GLfloat * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-    if (gc->isDirect) {
+#ifdef GLX_DIRECT_RENDERING
+    if (gc->driContext) {
         CALL_GetMinmaxParameterfv(GET_DISPATCH(), (target, pname, params));
-    } else {
+    } else
+#endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         Display *const dpy = gc->currentDpy;
         const GLuint cmdlen = 8;
@@ -6589,7 +6763,9 @@ __indirect_glGetMinmaxParameteriv(GLenum target, GLenum pname, GLint * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -6625,9 +6801,12 @@ gl_dispatch_stub_366(GLenum target, GLenum pname, GLint * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
 
-    if (gc->isDirect) {
+#ifdef GLX_DIRECT_RENDERING
+    if (gc->driContext) {
         CALL_GetMinmaxParameteriv(GET_DISPATCH(), (target, pname, params));
-    } else {
+    } else
+#endif
+    {
         __GLXcontext *const gc = __glXGetCurrentContext();
         Display *const dpy = gc->currentDpy;
         const GLuint cmdlen = 8;
@@ -7585,6 +7764,10 @@ __indirect_glProgramStringARB(GLenum target, GLenum format, GLsizei len,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 16 + __GLX_PAD(len);
+    if (len < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect((len >= 0) && (gc->currentDpy != NULL), 1)) {
         if (cmdlen <= gc->maxSmallRenderCommandSize) {
             if ((gc->pc + cmdlen) > gc->bufEnd) {
@@ -8200,7 +8383,13 @@ __indirect_glDeleteQueriesARB(GLsizei n, const GLuint * ids)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
+#endif
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -8238,7 +8427,13 @@ __indirect_glGenQueriesARB(GLsizei n, GLuint * ids)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 4;
+#endif
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -8271,7 +8466,9 @@ __indirect_glGetQueryObjectivARB(GLuint id, GLenum pname, GLint * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -8307,7 +8504,9 @@ __indirect_glGetQueryObjectuivARB(GLuint id, GLenum pname, GLuint * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -8343,7 +8542,9 @@ __indirect_glGetQueryivARB(GLenum target, GLenum pname, GLint * params)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
+#ifndef USE_XCB
     const GLuint cmdlen = 8;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -8383,7 +8584,9 @@ __indirect_glIsQueryARB(GLuint id)
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
     GLboolean retval = (GLboolean) 0;
+#ifndef USE_XCB
     const GLuint cmdlen = 4;
+#endif
     if (__builtin_expect(dpy != NULL, 1)) {
 #ifdef USE_XCB
         xcb_connection_t *c = XGetXCBConnection(dpy);
@@ -8414,6 +8617,10 @@ __indirect_glDrawBuffersARB(GLsizei n, const GLenum * bufs)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 8 + __GLX_PAD((n * 4));
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect((n >= 0) && (gc->currentDpy != NULL), 1)) {
         if (cmdlen <= gc->maxSmallRenderCommandSize) {
             if ((gc->pc + cmdlen) > gc->bufEnd) {
@@ -8774,6 +8981,10 @@ __indirect_glAreProgramsResidentNV(GLsizei n, const GLuint * ids,
     Display *const dpy = gc->currentDpy;
     GLboolean retval = (GLboolean) 0;
     const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return 0;
+    }
     if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
         GLubyte const *pc =
             __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply,
@@ -8809,6 +9020,10 @@ __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 (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
         GLubyte const *pc =
             __glXSetupVendorRequest(gc, X_GLXVendorPrivate,
@@ -8845,6 +9060,10 @@ __indirect_glGenProgramsNV(GLsizei n, GLuint * programs)
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
     const GLuint cmdlen = 4;
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
         GLubyte const *pc =
             __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply,
@@ -9051,6 +9270,10 @@ __indirect_glLoadProgramNV(GLenum target, GLuint id, GLsizei len,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 16 + __GLX_PAD(len);
+    if (len < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(len >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_LoadProgramNV, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4);
@@ -9071,6 +9294,10 @@ __indirect_glProgramParameters4dvNV(GLenum target, GLuint index, GLuint num,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 16 + __GLX_PAD((num * 32));
+    if (num < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(num >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_ProgramParameters4dvNV, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4);
@@ -9091,6 +9318,10 @@ __indirect_glProgramParameters4fvNV(GLenum target, GLuint index, GLuint num,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 16 + __GLX_PAD((num * 16));
+    if (num < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(num >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_ProgramParameters4fvNV, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (&target), 4);
@@ -9110,6 +9341,10 @@ __indirect_glRequestResidentProgramsNV(GLsizei n, const GLuint * ids)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 8 + __GLX_PAD((n * 4));
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(n >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_RequestResidentProgramsNV, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (&n), 4);
@@ -9561,6 +9796,10 @@ __indirect_glVertexAttribs1dvNV(GLuint index, GLsizei n, const GLdouble * v)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 12 + __GLX_PAD((n * 8));
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(n >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_VertexAttribs1dvNV, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
@@ -9579,6 +9818,10 @@ __indirect_glVertexAttribs1fvNV(GLuint index, GLsizei n, const GLfloat * v)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 12 + __GLX_PAD((n * 4));
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(n >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_VertexAttribs1fvNV, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
@@ -9597,6 +9840,10 @@ __indirect_glVertexAttribs1svNV(GLuint index, GLsizei n, const GLshort * v)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 12 + __GLX_PAD((n * 2));
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(n >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_VertexAttribs1svNV, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
@@ -9615,6 +9862,10 @@ __indirect_glVertexAttribs2dvNV(GLuint index, GLsizei n, const GLdouble * v)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 12 + __GLX_PAD((n * 16));
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(n >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_VertexAttribs2dvNV, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
@@ -9633,6 +9884,10 @@ __indirect_glVertexAttribs2fvNV(GLuint index, GLsizei n, const GLfloat * v)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 12 + __GLX_PAD((n * 8));
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(n >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_VertexAttribs2fvNV, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
@@ -9651,6 +9906,10 @@ __indirect_glVertexAttribs2svNV(GLuint index, GLsizei n, const GLshort * v)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 12 + __GLX_PAD((n * 4));
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(n >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_VertexAttribs2svNV, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
@@ -9669,6 +9928,10 @@ __indirect_glVertexAttribs3dvNV(GLuint index, GLsizei n, const GLdouble * v)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 12 + __GLX_PAD((n * 24));
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(n >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_VertexAttribs3dvNV, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
@@ -9687,6 +9950,10 @@ __indirect_glVertexAttribs3fvNV(GLuint index, GLsizei n, const GLfloat * v)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 12 + __GLX_PAD((n * 12));
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(n >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_VertexAttribs3fvNV, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
@@ -9705,6 +9972,10 @@ __indirect_glVertexAttribs3svNV(GLuint index, GLsizei n, const GLshort * v)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 12 + __GLX_PAD((n * 6));
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(n >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_VertexAttribs3svNV, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
@@ -9723,6 +9994,10 @@ __indirect_glVertexAttribs4dvNV(GLuint index, GLsizei n, const GLdouble * v)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 12 + __GLX_PAD((n * 32));
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(n >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_VertexAttribs4dvNV, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
@@ -9741,6 +10016,10 @@ __indirect_glVertexAttribs4fvNV(GLuint index, GLsizei n, const GLfloat * v)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 12 + __GLX_PAD((n * 16));
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(n >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_VertexAttribs4fvNV, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
@@ -9759,6 +10038,10 @@ __indirect_glVertexAttribs4svNV(GLuint index, GLsizei n, const GLshort * v)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 12 + __GLX_PAD((n * 8));
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(n >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_VertexAttribs4svNV, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
@@ -9777,6 +10060,10 @@ __indirect_glVertexAttribs4ubvNV(GLuint index, GLsizei n, const GLubyte *v)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 12 + __GLX_PAD((n * 4));
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(n >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_VertexAttribs4ubvNV, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (&index), 4);
@@ -9843,6 +10130,10 @@ __indirect_glGetProgramNamedParameterdvNV(GLuint id, GLsizei len,
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
     const GLuint cmdlen = 8 + __GLX_PAD(len);
+    if (len < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect((len >= 0) && (dpy != NULL), 1)) {
         GLubyte const *pc =
             __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply,
@@ -9867,6 +10158,10 @@ __indirect_glGetProgramNamedParameterfvNV(GLuint id, GLsizei len,
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
     const GLuint cmdlen = 8 + __GLX_PAD(len);
+    if (len < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect((len >= 0) && (dpy != NULL), 1)) {
         GLubyte const *pc =
             __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply,
@@ -9890,6 +10185,10 @@ __indirect_glProgramNamedParameter4dNV(GLuint id, GLsizei len,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 44 + __GLX_PAD(len);
+    if (len < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(len >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_ProgramNamedParameter4dvNV, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (&x), 8);
@@ -9914,6 +10213,10 @@ __indirect_glProgramNamedParameter4dvNV(GLuint id, GLsizei len,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 44 + __GLX_PAD(len);
+    if (len < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(len >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_ProgramNamedParameter4dvNV, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (v), 32);
@@ -9935,6 +10238,10 @@ __indirect_glProgramNamedParameter4fNV(GLuint id, GLsizei len,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 28 + __GLX_PAD(len);
+    if (len < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(len >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_ProgramNamedParameter4fvNV, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (&id), 4);
@@ -9959,6 +10266,10 @@ __indirect_glProgramNamedParameter4fvNV(GLuint id, GLsizei len,
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 28 + __GLX_PAD(len);
+    if (len < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(len >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_ProgramNamedParameter4fvNV, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (&id), 4);
@@ -10044,6 +10355,10 @@ __indirect_glDeleteFramebuffersEXT(GLsizei n, const GLuint * framebuffers)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 8 + __GLX_PAD((n * 4));
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(n >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_DeleteFramebuffersEXT, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (&n), 4);
@@ -10062,6 +10377,10 @@ __indirect_glDeleteRenderbuffersEXT(GLsizei n, const GLuint * renderbuffers)
 {
     __GLXcontext *const gc = __glXGetCurrentContext();
     const GLuint cmdlen = 8 + __GLX_PAD((n * 4));
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect(n >= 0, 1)) {
         emit_header(gc->pc, X_GLrop_DeleteRenderbuffersEXT, cmdlen);
         (void) memcpy((void *) (gc->pc + 4), (void *) (&n), 4);
@@ -10161,6 +10480,10 @@ __indirect_glGenFramebuffersEXT(GLsizei n, GLuint * framebuffers)
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
     const GLuint cmdlen = 4;
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
         GLubyte const *pc =
             __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply,
@@ -10180,6 +10503,10 @@ __indirect_glGenRenderbuffersEXT(GLsizei n, GLuint * renderbuffers)
     __GLXcontext *const gc = __glXGetCurrentContext();
     Display *const dpy = gc->currentDpy;
     const GLuint cmdlen = 4;
+    if (n < 0) {
+        __glXSetError(gc, GL_INVALID_VALUE);
+        return;
+    }
     if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
         GLubyte const *pc =
             __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply,
diff --git a/src/glx/x11/indirect_texture_compression.c b/src/glx/x11/indirect_texture_compression.c
new file mode 100644 (file)
index 0000000..5676858
--- /dev/null
@@ -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/src/glx/x11/indirect_va_private.h b/src/glx/x11/indirect_va_private.h
deleted file mode 100644 (file)
index ab97dc6..0000000
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * (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_ */
index 90ec277c41ba2044329f689543e51d1d1080def8..c7a20e2bc5608efc6a31e9bc3002c5c7ac87b1b5 100644 (file)
@@ -32,7 +32,7 @@
 #include <GL/glxproto.h>
 #include "glxextensions.h"
 #include "indirect_vertex_array.h"
-#include "indirect_va_private.h"
+#include "indirect_vertex_array_priv.h"
 
 #define __GLX_PAD(n) (((n)+3) & ~3)
 
@@ -62,7 +62,7 @@
  * "vbo", to support multiple texture coordinate arrays, generic attributes,
  * and vertex buffer objects.
  *
- * \author Ian Romanick <idr@us.ibm.com>
+ * \author Ian Romanick <ian.d.romanick@intel.com>
  */
 
 static void emit_DrawArrays_none( GLenum mode, GLint first, GLsizei count );
@@ -101,6 +101,31 @@ const GLuint __glXTypeSize_table[16] = {
 };
 
 
+/**
+ * Free the per-context array state that was allocated with
+ * __glXInitVertexArrayState().
+ */
+void
+__glXFreeVertexArrayState( __GLXcontext * gc )
+{
+    __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+    struct array_state_vector* arrays = state->array_state;
+
+    if (arrays) {
+        if (arrays->stack) {
+            free(arrays->stack);
+            arrays->stack = NULL;
+        }
+        if (arrays->arrays) {
+            free(arrays->arrays);
+            arrays->arrays = NULL;
+        }
+        free(arrays);
+        arrays = NULL;
+        state->array_state = NULL;
+    }
+}
+
 
 /**
  * Initialize vertex array state of a GLX context.
@@ -485,14 +510,14 @@ emit_DrawArrays_none( GLenum mode, GLint first, GLsizei count )
 
     for ( i = 0 ; i < count ; i++ ) {
        if ( (pc + single_vertex_size) >= gc->bufEnd ) {
-           pc = __glXFlushRenderBuffer(gc, gc->pc);
+           pc = __glXFlushRenderBuffer(gc, pc);
        }
 
        pc = emit_element_none( pc, arrays, first + i );
     }
 
     if ( (pc + 4) >= gc->bufEnd ) {
-       pc = __glXFlushRenderBuffer(gc, gc->pc);
+       pc = __glXFlushRenderBuffer(gc, pc);
     }
 
     (void) memcpy( pc, end_cmd, 4 );
@@ -527,7 +552,7 @@ static GLubyte *
 emit_DrawArrays_header_old( __GLXcontext * gc,
                            struct array_state_vector * arrays,
                            size_t * elements_per_request,
-                           size_t * total_requests,
+                           unsigned int * total_requests,
                            GLenum mode, GLsizei count )
 {
     size_t command_size;
@@ -640,7 +665,7 @@ emit_DrawArrays_old( GLenum mode, GLint first, GLsizei count )
 
     GLubyte * pc;
     size_t elements_per_request;
-    size_t total_requests = 0;
+    unsigned total_requests = 0;
     unsigned i;
     size_t total_sent = 0;
 
@@ -726,7 +751,7 @@ emit_DrawElements_none( GLenum mode, GLsizei count, GLenum type,
        unsigned  index = 0;
 
        if ( (pc + single_vertex_size) >= gc->bufEnd ) {
-           pc = __glXFlushRenderBuffer(gc, gc->pc);
+           pc = __glXFlushRenderBuffer(gc, pc);
        }
 
        switch( type ) {
@@ -744,7 +769,7 @@ emit_DrawElements_none( GLenum mode, GLsizei count, GLenum type,
     }
 
     if ( (pc + 4) >= gc->bufEnd ) {
-       pc = __glXFlushRenderBuffer(gc, gc->pc);
+       pc = __glXFlushRenderBuffer(gc, pc);
     }
 
     (void) memcpy( pc, end_cmd, 4 );
@@ -770,9 +795,10 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type,
 
     GLubyte * pc;
     size_t elements_per_request;
-    size_t total_requests = 0;
+    unsigned total_requests = 0;
     unsigned i;
     unsigned req;
+    unsigned req_element=0;
 
 
     pc = emit_DrawArrays_header_old( gc, arrays, & elements_per_request,
@@ -790,7 +816,7 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type,
 
        switch( type ) {
        case GL_UNSIGNED_INT: {
-           const GLuint   * ui_ptr = (const GLuint   *) indices;
+           const GLuint   * ui_ptr = (const GLuint   *) indices + req_element;
 
            for ( i = 0 ; i < elements_per_request ; i++ ) {
                const GLint index = (GLint) *(ui_ptr++);
@@ -799,7 +825,7 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type,
            break;
        }
        case GL_UNSIGNED_SHORT: {
-           const GLushort * us_ptr = (const GLushort *) indices;
+           const GLushort * us_ptr = (const GLushort *) indices + req_element;
 
            for ( i = 0 ; i < elements_per_request ; i++ ) {
                const GLint index = (GLint) *(us_ptr++);
@@ -808,7 +834,7 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type,
            break;
        }
        case GL_UNSIGNED_BYTE: {
-           const GLubyte  * ub_ptr = (const GLubyte  *) indices;
+           const GLubyte  * ub_ptr = (const GLubyte  *) indices + req_element;
 
            for ( i = 0 ; i < elements_per_request ; i++ ) {
                const GLint index = (GLint) *(ub_ptr++);
@@ -826,6 +852,7 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type,
        }
 
        count -= elements_per_request;
+       req_element += elements_per_request;
     }
 
 
@@ -1599,17 +1626,21 @@ void __indirect_glClientActiveTextureARB(GLenum texture)
 
 
 /**
+ * Modify the enable state for the selected array
  */
 GLboolean
-__glXSetArrayEnable( __GLXattribute * state,
-                    GLenum key, unsigned index, GLboolean enable )
+__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;
+    /* Texture coordinate arrays have an implict index set when the
+     * application calls glClientActiveTexture.
+     */
+    if (key == GL_TEXTURE_COORD_ARRAY) {
+        index = arrays->active_texture_unit;
     }
 
     a = get_array_entry( arrays, key, index );
diff --git a/src/glx/x11/indirect_vertex_array_priv.h b/src/glx/x11/indirect_vertex_array_priv.h
new file mode 100644 (file)
index 0000000..ab97dc6
--- /dev/null
@@ -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_ */
index 5383dcc981027ded1213a155ae3cbacb3605ea3c..4f1485a850c9072a228f0b8fb413822d638bcc7a 100644 (file)
@@ -23,6 +23,7 @@
  * SOFTWARE.
  */
 
+#include "glheader.h"
 #include <inttypes.h>
 #include <GL/gl.h>
 #include "indirect.h"
@@ -192,7 +193,13 @@ void __indirect_glGetVertexAttribivARB( GLuint index, GLenum pname,
     get_vertex_attrib( gc, 1303, index, pname, (xReply *) & reply );
 
     if ( reply.size != 0 ) {
-       if ( ! get_attrib_array_data( state, index, pname, params ) ) {
+       GLintptr data;
+
+
+       if ( get_attrib_array_data( state, index, pname, & data ) ) {
+           *params = (GLint) data;
+       }
+       else {
            if (reply.size == 1) {
                *params = (GLint) reply.pad3;
            } 
index 6f25ed786ef2ca9f7d4d42f58178e38c5a4070b2..82a01517528f2d94c965b9afbfccf8c725e5df2d 100644 (file)
@@ -33,6 +33,7 @@
 **
 */
 
+#include "glheader.h"
 #include "glxclient.h"
 #include "indirect.h"
 
index cd88684f7098d57ecac4d7b1216c49b086539749..9c984c75d281fbc094bf3c2d16bdeae49be30cf7 100644 (file)
@@ -33,6 +33,7 @@
 **
 */
 
+#include "glheader.h"
 #include "packsingle.h"
 #include "indirect.h"
 #include "dispatch.h"
@@ -117,12 +118,14 @@ void NAME(_gloffset_GetSeparableFilter)(GLenum target, GLenum format, GLenum typ
 {
     __GLXcontext * const gc = __glXGetCurrentContext();
 
-    if (gc->isDirect) {
+#ifdef GLX_DIRECT_RENDERING
+    if (gc->driContext) {
        CALL_GetSeparableFilter(GET_DISPATCH(),
                                (target, format, type, row, column, span));
        return;
-    }
-    else {
+    } else 
+#endif
+    {
         Display *const dpy = gc->currentDpy;
        const GLuint cmdlen = __GLX_PAD(13);
 
index c8c878f12742fe6abbb635f6abc375b192120ddb..a6a57c31356876e2e15942f74ea18cef7a34db02 100644 (file)
@@ -64,8 +64,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #ifndef _XF86DRI_SERVER_
 
-#include <GL/internal/dri_interface.h>
-
 _XFUNCPROTOBEGIN
 
 Bool XF86DRIQueryExtension( Display *dpy, int *event_base, int *error_base );
@@ -93,14 +91,14 @@ Bool XF86DRICreateContext( Display *dpy, int screen, Visual *visual,
 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 XF86DRIDestroyContext( Display *dpy, int screen,
+    XID context_id );
 
-extern GLboolean XF86DRICreateDrawable( __DRInativeDisplay *dpy, int screen,
-    __DRIid drawable, drm_drawable_t *hHWDrawable );
+extern GLboolean XF86DRICreateDrawable( Display *dpy, int screen,
+    XID drawable, drm_drawable_t *hHWDrawable );
 
-extern GLboolean XF86DRIDestroyDrawable( __DRInativeDisplay *dpy, int screen, 
-    __DRIid drawable);
+extern GLboolean XF86DRIDestroyDrawable( Display *dpy, int screen, 
+    XID drawable);
 
 Bool XF86DRIGetDrawableInfo( Display *dpy, int screen, Drawable drawable,
     unsigned int *index, unsigned int *stamp, 
index f3e3da3e790d2af0368108b1f3c126ca18badded..6ec8c2d6bf60a0e28d46442b0ab1814d541c6611 100644 (file)
@@ -33,6 +33,7 @@
   called by that routine when direct rendering is enabled.
 */
 
+#ifdef GLX_DIRECT_RENDERING
 
 #include "glxclient.h"
 
@@ -208,8 +209,7 @@ static XCharStruct *isvalid(XFontStruct *fs, int which)
   return(NULL);
 }
 
-
-void DRI_glXUseXFont( Font font, int first, int count, int listbase )
+_X_HIDDEN void DRI_glXUseXFont( Font font, int first, int count, int listbase )
 {
   GLXContext CC;
   Display *dpy;
@@ -373,4 +373,4 @@ bm_height);
   glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
 }
 
-/* The End. */
+#endif
index cd42cd654b047e58d50b83ee4346434bf18aeccc..2fba2e153b8d30c8650df2b48baaba4744a1521f 100644 (file)
@@ -5,7 +5,6 @@ include $(TOP)/configs/current
 
 include sources.mak
 
-
 .SUFFIXES : .cpp
 
 .c.o:
@@ -19,21 +18,25 @@ include sources.mak
 
 
 
-GLAPI_LIB = libglapi.a
+# Default: build dependencies, then asm_subdirs, then convenience
+# libs (.a) and finally the device drivers:
+default: depend asm_subdirs libmesa.a libglapi.a driver_subdirs
 
 
 # Default: build dependencies, then asm_subdirs, then convenience
 # libs (.a) and finally the device drivers:
 default: depend asm_subdirs libmesa.a $(GLAPI_LIB) driver_subdirs
 
-
-
 ######################################################################
 # Helper libraries used by many drivers:
 
 # Make archive of core mesa object files
 libmesa.a: $(MESA_OBJECTS)
-       @ $(TOP)/bin/mklib -o mesa -static $(MESA_OBJECTS)
+       @ $(MKLIB) -o mesa -static $(MESA_OBJECTS)
+
+# Make archive of gl* API dispatcher functions only
+libglapi.a: $(GLAPI_OBJECTS)
+       @ $(MKLIB) -o glapi -static $(GLAPI_OBJECTS)
 
 # Make archive of gl* API dispatcher functions only
 $(GLAPI_LIB): $(GLAPI_OBJECTS)
@@ -43,10 +46,9 @@ $(GLAPI_LIB): $(GLAPI_OBJECTS)
                $(TOP)/bin/mklib -o glapi -static $(GLAPI_OBJECTS) ; \
        fi
 
-
 ######################################################################
 # Device drivers
-driver_subdirs: libmesa.a $(GLAPI_LIB)
+driver_subdirs: libmesa.a libglapi.a
        (cd drivers && $(MAKE))
 
 
@@ -97,28 +99,29 @@ install: default
 
 pcedit = sed \
        -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \
-       -e 's,@LIB_DIR@,$(LIB_DIR),' \
+       -e 's,@INSTALL_LIB_DIR@,$(INSTALL_LIB_DIR),' \
+       -e 's,@INSTALL_INC_DIR@,$(INSTALL_INC_DIR),' \
        -e 's,@VERSION@,$(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY),'
 
 gl.pc: gl.pc.in
        $(pcedit) $< > $@
 
 install-headers:
-       $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/GL
        $(INSTALL) -m 644 $(TOP)/include/GL/*.h \
-               $(DESTDIR)$(INSTALL_DIR)/include/GL
+               $(DESTDIR)$(INSTALL_INC_DIR)/GL
 
 install-libgl: default gl.pc install-headers
-       $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
-       $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig
-       $(INSTALL) $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)* \
-               $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
-       $(INSTALL) -m 644 gl.pc $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
+       $(INSTALL) $(TOP)/$(LIB_DIR)/$(GL_LIB_GLOB) \
+               $(DESTDIR)$(INSTALL_LIB_DIR)
+       $(INSTALL) -m 644 gl.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
 
 install-osmesa: default
-       $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
-       $(INSTALL) $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME)* \
-               $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
+       $(INSTALL) $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_GLOB) \
+               $(DESTDIR)$(INSTALL_LIB_DIR)
 
 install-dri: default
        cd drivers/dri && $(MAKE) install
@@ -133,10 +136,10 @@ tags:
 clean:
        -rm -f */*.o
        -rm -f */*/*.o
-       -rm -f depend depend.bak libmesa.a $(GLAPI_LIB)
+       -rm -f depend depend.bak libmesa.a libglapi.a
        -rm -f drivers/*/*.o
+       -rm -f *.pc
        -@cd drivers/dri && $(MAKE) clean
-       -@cd drivers/xorg && $(MAKE) clean
        -@cd drivers/x11 && $(MAKE) clean
        -@cd drivers/osmesa && $(MAKE) clean
        -@cd x86 && $(MAKE) clean
diff --git a/src/mesa/Makefile.mgw b/src/mesa/Makefile.mgw
new file mode 100644 (file)
index 0000000..097c390
--- /dev/null
@@ -0,0 +1,235 @@
+# Mesa 3-D graphics library
+# Version:  7.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.
+
+# MinGW core makefile v1.4 for Mesa
+#
+#  Copyright (C) 2002 - Daniel Borca
+#  Email : dborca@users.sourceforge.net
+#  Web   : http://www.geocities.com/dborca
+
+# MinGW core-gl makefile updated for Mesa 7.0
+#
+#  updated : by Heromyth, on 2007-7-21
+#  Email   : zxpmyth@yahoo.com.cn
+#  Bugs    : 1) All the default settings work fine. But the setting X86=1 can't work. 
+#            The others havn't been tested yet.
+#            2) The generated DLLs are *not* compatible with the ones built
+#            with the other compilers like VC8, especially for GLUT. 
+#            3) Although more tests are needed, it can be used individually!
+
+
+#
+#  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-
+
+ifeq ($(ICD),1)
+  LIB_NAME = mesa32
+else
+  LIB_NAME = opengl32
+endif
+
+DLL_EXT = .dll
+IMP_EXT = .a
+LIB_PRE = lib
+STRIP = -s
+
+AR = ar
+ARFLAGS = crus
+DLLTOOL = dlltool
+
+TOP = ../..
+GLIDE ?= $(TOP)/glide3
+LIBDIR = $(TOP)/lib
+
+GL_DLL = $(LIB_NAME)$(DLL_EXT)
+GL_IMP = $(LIB_PRE)$(LIB_NAME)$(IMP_EXT)
+
+MESA_LIB = libmesa.a
+CC = $(TOOLS_PREFIX)gcc
+
+LDLIBS = -lgdi32 -luser32 -liberty
+LDFLAGS = $(STRIP) -shared -fPIC -Wl,--kill-at
+
+CFLAGS += -DBUILD_GL32 -D_DLL -DMESA_MINWARN
+CFLAGS += -DNDEBUG -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 = $(LIB_NAME).def
+  endif
+endif
+
+
+
+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.mak
+
+CFLAGS += $(INCLUDE_DIRS) 
+
+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 = $(MESA_SOURCES) $(GLAPI_SOURCES) $(X86_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) -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)
+       $(CC) $(LDFLAGS) -o $(LIBDIR)/$(GL_DLL) $^ $(LDLIBS)
+       $(DLLTOOL) --as=as --dllname $(LIB_NAME) --output-def $(LIBDIR)/$(GL_DEF) $^
+       $(DLLTOOL) --as=as -k --dllname $(LIB_NAME) --output-lib $(LIBDIR)/$(GL_IMP) --def $(LIBDIR)/$(GL_DEF)
+
+
+$(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,glapi/*.o)
+       -$(call UNLINK,main/*.o)
+       -$(call UNLINK,math/*.o)
+       -$(call UNLINK,vbo/*.o)
+       -$(call UNLINK,shader/*.o)
+       -$(call UNLINK,shader/slang/*.o)
+       -$(call UNLINK,shader/grammar/*.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,x86/rtasm/*.o)
+       -$(call UNLINK,x86-64/*.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/src/mesa/descrip.mms b/src/mesa/descrip.mms
new file mode 100644 (file)
index 0000000..dbfa336
--- /dev/null
@@ -0,0 +1,27 @@
+# Makefile for Mesa for VMS
+# contributed by Jouk Jansen  joukj@hrem.nano.tudelft.nl
+# Date last revision : 7 March 2007
+
+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 [-.vbo]
+       $(MMS)$(MMSQUALIFIERS)
index 342d7ce0243c87acb0a5797cd2d8e8478cb08aa0..c79dd24c390a17f9b1b8702946eaaad8bcaa5bb0 100644 (file)
@@ -181,9 +181,10 @@ $(TOP)/$(LIB_DIR):
        mkdir $(TOP)/$(LIB_DIR)
 
 $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) $(MESA_MODULES) $(GLU_MODULES)
-       @$(TOP)/bin/mklib -o $(GL_LIB) -ldflags '$(LDFLAGS)' -install $(TOP)/$(LIB_DIR) \
+       @$(MKLIB) -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
                -major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \
-               $(MKLIB_OPTIONS) $(GL_LIB_DEPS) $(OBJECTS) $(MESA_MODULES) $(GLU_MODULES)
+               -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) $(GL_LIB_DEPS) \
+               $(OBJECTS) $(MESA_MODULES) $(GLU_MODULES)
 
 # $(GLU_OBJECTS):
 #      cd $(GLU_DIR) && $(MAKE) $< ;
diff --git a/src/mesa/drivers/common/descrip.mms b/src/mesa/drivers/common/descrip.mms
new file mode 100644 (file)
index 0000000..99a2ae6
--- /dev/null
@@ -0,0 +1,41 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen  joukj@hrem.nano.tudelft.nl
+# Last revision : 3 October 2007
+
+.first
+       define gl [----.include.gl]
+       define math [--.math]
+       define tnl [--.tnl]
+       define swrast [--.swrast]
+       define glapi [--.glapi]
+       define shader [--.shader]
+       define main [--.main]
+
+.include [----]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [----.include],[--.main],[--.glapi],[--.shader]
+LIBDIR = [----.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)/float=ieee/ieee=denorm
+
+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
index b5b383b4e4233877e108c0b8762b03344b467fa2..7d6e6ef766be39eebb87ceaecc75fe1070bc0427 100644 (file)
 
 #include "glheader.h"
 #include "imports.h"
+#include "arrayobj.h"
 #include "buffers.h"
 #include "context.h"
 #include "framebuffer.h"
 #include "mipmap.h"
-#include "program.h"
-#include "prog_execute.h"
 #include "queryobj.h"
 #include "renderbuffer.h"
 #include "texcompress.h"
 #include "fbobject.h"
 #include "texrender.h"
 #endif
-#include "shader_api.h"
-#include "arrayobj.h"
 
+#include "shader/program.h"
+#include "shader/prog_execute.h"
+#include "shader/shader_api.h"
 #include "driverfuncs.h"
 #include "tnl/tnl.h"
 #include "swrast/swrast.h"
@@ -115,6 +115,8 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
    driver->DeleteTexture = _mesa_delete_texture_object;
    driver->NewTextureImage = _mesa_new_texture_image;
    driver->FreeTexImageData = _mesa_free_texture_image_data; 
+   driver->MapTexture = NULL;
+   driver->UnmapTexture = NULL;
    driver->TextureMemCpy = _mesa_memcpy; 
    driver->IsTextureResident = NULL;
    driver->PrioritizeTexture = NULL;
diff --git a/src/mesa/drivers/common/sources b/src/mesa/drivers/common/sources
deleted file mode 100644 (file)
index 90e29d7..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-MESA_DRIVER_COMMON_SOURCES = \
-driverfuncs.c
index ece0457cffa7f62a8845bc61b4186c036132a07c..94c82a2c9c93c6c8bb783646f2382963d7823bca 100644 (file)
@@ -37,7 +37,7 @@ default: directfb-libgl directfbgl_mesa
 
 # XXX this used to be in src/mesa/Makefile and is probably broken now
 directfb-libgl: $(LIBS)
-       @ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
+       @ $(MKLIB) -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
                -major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \
                -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) $(LIBS) \
                $(GL_LIB_DEPS)
index 694eeb054dfe697cb86d6cc7d1ce9dd072df0829..a364ada1f19cb9f90e483f353fff39fc524c2703 100644 (file)
@@ -102,7 +102,7 @@ typedef struct {
 static pthread_mutex_t global_lock = PTHREAD_MUTEX_INITIALIZER;
 static unsigned int    global_ref  = 0;
 
-static inline int directfbgl_init( void )
+static INLINE int directfbgl_init( void )
 {
      pthread_mutexattr_t attr;
      int                 ret;
@@ -118,7 +118,7 @@ static inline int directfbgl_init( void )
      return ret;
 }
 
-static inline void directfbgl_finish( void )
+static INLINE void directfbgl_finish( void )
 {
      if (--global_ref == 0)
           pthread_mutex_destroy( &global_lock );
@@ -503,10 +503,31 @@ dfbRenderbufferStorage( GLcontext *ctx, struct gl_renderbuffer *render,
           (((S[GCOMP]) & 0xf0)     ) | \
           (((S[BCOMP]) & 0xf0) >> 4) )
 #define FETCH_PIXEL(D, P) \
-   D[RCOMP] = ((*P & 0x0f00) >> 4); \
-   D[GCOMP] = ((*P & 0x00f0)     ); \
-   D[BCOMP] = ((*P & 0x000f) << 4); \
-   D[ACOMP] = ((*P & 0xf000) >> 8)
+   D[RCOMP] = ((*P & 0x0f00) >> 4) | ((*P & 0x0f00) >>  8); \
+   D[GCOMP] = ((*P & 0x00f0)     ) | ((*P & 0x00f0) >>  4); \
+   D[BCOMP] = ((*P & 0x000f) << 4) | ((*P & 0x000f)      ); \
+   D[ACOMP] = ((*P & 0xf000) >> 8) | ((*P & 0xf000) >> 12)
+
+#include "swrast/s_spantemp.h"
+
+/* RGB444 */
+#define NAME(PREFIX) PREFIX##_RGB444
+#define FORMAT GL_RGBA8
+#define RB_TYPE GLubyte
+#define SPAN_VARS \
+   IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;
+#define INIT_PIXEL_PTR(P, X, Y) \
+   GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2);
+#define INC_PIXEL_PTR(P) P += 1
+#define STORE_PIXEL(P, X, Y, S) \
+   *P = ( (((S[RCOMP]) & 0xf0) << 4) | \
+          (((S[GCOMP]) & 0xf0)     ) | \
+          (((S[BCOMP]) & 0xf0) >> 4) )
+#define FETCH_PIXEL(D, P) \
+   D[RCOMP] = ((*P & 0x0f00) >> 4) | ((*P & 0x0f00) >> 8); \
+   D[GCOMP] = ((*P & 0x00f0)     ) | ((*P & 0x00f0) >> 4); \
+   D[BCOMP] = ((*P & 0x000f) << 4) | ((*P & 0x000f)     ); \
+   D[ACOMP] = 0xff
 
 #include "swrast/s_spantemp.h"
 
@@ -557,13 +578,34 @@ dfbRenderbufferStorage( GLcontext *ctx, struct gl_renderbuffer *render,
           (((S[GCOMP]) & 0xf8) <<  2) | \
           (((S[BCOMP])       ) >>  3) )
 #define FETCH_PIXEL(D, P) \
-   D[RCOMP] = ((*P & 0x7c00) >> 7); \
-   D[GCOMP] = ((*P & 0x03e0) >> 2); \
-   D[BCOMP] = ((*P & 0x001f) << 3); \
+   D[RCOMP] = ((*P & 0x7c00) >> 7) | ((*P & 0x7c00) >> 12); \
+   D[GCOMP] = ((*P & 0x03e0) >> 2) | ((*P & 0x03e0) >>  7); \
+   D[BCOMP] = ((*P & 0x001f) << 3) | ((*P & 0x001f) <<  2); \
    D[ACOMP] = ((*P & 0x8000) ? 0xff : 0)
 
 #include "swrast/s_spantemp.h"
 
+/* RGB555 */
+#define NAME(PREFIX) PREFIX##_RGB555
+#define FORMAT GL_RGBA8
+#define RB_TYPE GLubyte
+#define SPAN_VARS \
+   IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx;
+#define INIT_PIXEL_PTR(P, X, Y) \
+   GLushort *P = (GLushort *) (data->video.end - (Y) * data->video.pitch + (X) * 2);
+#define INC_PIXEL_PTR(P) P += 1
+#define STORE_PIXEL(P, X, Y, S) \
+   *P = ( (((S[RCOMP]) & 0xf8) <<  7) | \
+          (((S[GCOMP]) & 0xf8) <<  2) | \
+          (((S[BCOMP])       ) >>  3) )
+#define FETCH_PIXEL(D, P) \
+   D[RCOMP] = ((*P & 0x7c00) >> 7) | ((*P & 0x7c00) >> 12); \
+   D[GCOMP] = ((*P & 0x03e0) >> 2) | ((*P & 0x03e0) >>  7); \
+   D[BCOMP] = ((*P & 0x001f) << 3) | ((*P & 0x001f) <<  2); \
+   D[ACOMP] = 0xff
+
+#include "swrast/s_spantemp.h"
+
 /* RGB16 */
 #define NAME(PREFIX) PREFIX##_RGB16
 #define FORMAT GL_RGBA8
@@ -578,9 +620,9 @@ dfbRenderbufferStorage( GLcontext *ctx, struct gl_renderbuffer *render,
           (((S[GCOMP]) & 0xfc) << 3) | \
           (((S[BCOMP])       ) >> 3) )
 #define FETCH_PIXEL(D, P) \
-   D[RCOMP] = ((*P & 0xf800) >> 8); \
-   D[GCOMP] = ((*P & 0x07e0) >> 3); \
-   D[BCOMP] = ((*P & 0x001f) << 3); \
+   D[RCOMP] = ((*P & 0xf800) >> 8) | ((*P & 0xf800) >> 13); \
+   D[GCOMP] = ((*P & 0x07e0) >> 3) | ((*P & 0x07e0) >>  9); \
+   D[BCOMP] = ((*P & 0x001f) << 3) | ((*P & 0x001f) >>  2); \
    D[ACOMP] = 0xff
 
 #include "swrast/s_spantemp.h"
@@ -706,22 +748,24 @@ directfbgl_init_visual( GLvisual              *visual,
                blueBits  = 2;
                break;
           case DSPF_ARGB4444:
+               alphaBits = 4;
+          case DSPF_RGB444:
                redBits   = 4;
                greenBits = 4;
                blueBits  = 4;
-               alphaBits = 4;
                break;
           case DSPF_ARGB2554:
+               alphaBits = 2;
                redBits   = 5;
                greenBits = 5;
                blueBits  = 4;
-               alphaBits = 2;
                break;
           case DSPF_ARGB1555:
+               alphaBits = 1;
+          case DSPF_RGB555:
                redBits   = 5;
                greenBits = 5;
                blueBits  = 5;
-               alphaBits = 1;
                break;
           case DSPF_RGB16:
                redBits   = 5;
@@ -818,6 +862,15 @@ directfbgl_create_context( GLcontext        *context,
                data->render.PutValues     = put_values_ARGB4444;
                data->render.PutMonoValues = put_mono_values_ARGB4444;
                break;
+          case DSPF_RGB444: 
+               data->render.GetRow        = get_row_RGB444;
+               data->render.GetValues     = get_values_RGB444;
+               data->render.PutRow        = put_row_RGB444;
+               data->render.PutRowRGB     = put_row_rgb_RGB444;
+               data->render.PutMonoRow    = put_mono_row_RGB444;
+               data->render.PutValues     = put_values_RGB444;
+               data->render.PutMonoValues = put_mono_values_RGB444;
+               break;
           case DSPF_ARGB2554: 
                data->render.GetRow        = get_row_ARGB2554;
                data->render.GetValues     = get_values_ARGB2554;
@@ -836,6 +889,15 @@ directfbgl_create_context( GLcontext        *context,
                data->render.PutValues     = put_values_ARGB1555;
                data->render.PutMonoValues = put_mono_values_ARGB1555;
                break;
+          case DSPF_RGB555:
+               data->render.GetRow        = get_row_RGB555;
+               data->render.GetValues     = get_values_RGB555;
+               data->render.PutRow        = put_row_RGB555;
+               data->render.PutRowRGB     = put_row_rgb_RGB555;
+               data->render.PutMonoRow    = put_mono_row_RGB555;
+               data->render.PutValues     = put_values_RGB555;
+               data->render.PutMonoValues = put_mono_values_RGB555;
+               break;
           case DSPF_RGB16:
                data->render.GetRow        = get_row_RGB16;
                data->render.GetValues     = get_values_RGB16;
index f466ce6c3cc8c0005f122b3b7104a93119c06fc2..eef68825bc97b3d8b2e873b05b2382437aa9064e 100644 (file)
@@ -20,19 +20,35 @@ subdirs:
                fi \
        done
 
+pcedit = sed \
+       -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \
+       -e 's,@INSTALL_LIB_DIR@,$(INSTALL_LIB_DIR),' \
+       -e 's,@INSTALL_INC_DIR@,$(INSTALL_INC_DIR),' \
+       -e 's,@VERSION@,$(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY),' \
+       -e 's,@DRI_DRIVER_DIR@,$(DRI_DRIVER_SEARCH_DIR),'
 
-install:
+dri.pc: dri.pc.in
+       $(pcedit) $< > $@
+
+
+install: dri.pc
        @for dir in $(DRI_DIRS) ; do \
                if [ -d $$dir ] ; then \
                        (cd $$dir && $(MAKE) install) || exit 1 ; \
                fi \
        done
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/GL/internal
+       $(INSTALL) -m 0644 $(TOP)/include/GL/internal/dri_interface.h \
+         $(DESTDIR)$(INSTALL_INC_DIR)/GL/internal
+       $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
+       $(INSTALL) -m 0644 dri.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
 
 
 clean:
-       @for dir in $(DRI_DIRS) ; do \
+       -@for dir in $(DRI_DIRS) ; do \
                if [ -d $$dir ] ; then \
                        (cd $$dir && $(MAKE) clean) ; \
                fi \
        done
        -rm -f common/*.o
+       -rm -f *.pc
index 3e7e527a9829a38404befb0a787301474b071b8c..166621cd6c4bf5b932f97eef741ad0785fbb7e99 100644 (file)
@@ -13,11 +13,6 @@ COMMON_SOURCES = $(COMMON_GALLIUM_SOURCES) \
         ../common/texmem.c \
         ../common/drirenderbuffer.c
 
-COMMON_BM_SOURCES = \
-       ../common/dri_bufmgr.c \
-       ../common/dri_drmpool.c
-
-
 ifeq ($(WINDOW_SYSTEM),dri)
 WINOBJ=
 WINLIB=
@@ -51,11 +46,6 @@ SHARED_INCLUDES = \
        -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 \
        $(LIBDRM_CFLAGS)
@@ -72,12 +62,12 @@ SHARED_INCLUDES = \
 
 ##### TARGETS #####
 
-default: depend symlinks $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME)
+default: symlinks depend $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME)
 
 
 $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) $(WINOBJ) Makefile $(TOP)/src/mesa/drivers/dri/Makefile.template
-       $(TOP)/bin/mklib -noprefix -o $@ \
-               $(OBJECTS) $(PIPE_DRIVERS) $(MESA_MODULES)  $(WINOBJ) $(DRI_LIB_DEPS)
+       $(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \
+               $(OBJECTS) $(PIPE_DRIVERS) $(MESA_MODULES) $(WINOBJ) $(DRI_LIB_DEPS)
 
 
 $(TOP)/$(LIB_DIR)/$(LIBNAME): $(LIBNAME)
@@ -88,7 +78,7 @@ depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
        rm -f depend
        touch depend
        $(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) \
-               $(ASM_SOURCES) 2> /dev/null
+               $(ASM_SOURCES)
 
 
 # Emacs tags
@@ -103,8 +93,8 @@ clean:
 
 
 install: $(LIBNAME)
-       $(INSTALL) -d $(DRI_DRIVER_INSTALL_DIR)
-       $(INSTALL) -m 755 $(LIBNAME) $(DRI_DRIVER_INSTALL_DIR)
+       $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
+       $(INSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
 
 
-include depend
+-include depend
index 55199abf6a3f4e317df88c4110b5891774100af2..fd2dab3b42238b6a55c107b34e16db373582b207 100644 (file)
@@ -29,7 +29,7 @@ static void TAG(WriteDepthSpan)( GLcontext *ctx,
 {
    HW_WRITE_LOCK()
       {
-         const GLuint *depth = (const GLuint *) values;
+         const VALUE_TYPE *depth = (const VALUE_TYPE *) values;
         GLint x1;
         GLint n1;
         LOCAL_DEPTH_VARS;
@@ -134,7 +134,7 @@ static void TAG(WriteDepthPixels)( GLcontext *ctx,
 {
    HW_WRITE_LOCK()
       {
-         const GLuint *depth = (const GLuint *) values;
+         const VALUE_TYPE *depth = (const VALUE_TYPE *) values;
         GLuint i;
         LOCAL_DEPTH_VARS;
 
@@ -180,7 +180,7 @@ static void TAG(ReadDepthSpan)( GLcontext *ctx,
 {
    HW_READ_LOCK()
       {
-         GLuint *depth = (GLuint *) values;
+         VALUE_TYPE *depth = (VALUE_TYPE *) values;
         GLint x1, n1;
         LOCAL_DEPTH_VARS;
 
@@ -215,7 +215,7 @@ static void TAG(ReadDepthPixels)( GLcontext *ctx,
 {
    HW_READ_LOCK()
       {
-         GLuint *depth = (GLuint *) values;
+         VALUE_TYPE *depth = (VALUE_TYPE *) values;
         GLuint i;
         LOCAL_DEPTH_VARS;
 
@@ -267,3 +267,4 @@ static void TAG(InitDepthPointers)(struct gl_renderbuffer *rb)
 #undef READ_DEPTH
 #endif
 #undef TAG
+#undef VALUE_TYPE
diff --git a/src/mesa/drivers/dri/common/dri_bufpool.h b/src/mesa/drivers/dri/common/dri_bufpool.h
deleted file mode 100644 (file)
index c6fb2c3..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and 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 SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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, AUTHORS 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.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * 
- **************************************************************************/
-/*
- * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
- */
-
-#ifndef _DRI_BUFPOOL_H_
-#define _DRI_BUFPOOL_H_
-
-#include <xf86drm.h>
-struct _DriFenceObject;
-
-typedef struct _DriBufferPool
-{
-   int fd;
-   int (*map) (struct _DriBufferPool * pool, void *private,
-               unsigned flags, int hint, void **virtual);
-   int (*unmap) (struct _DriBufferPool * pool, void *private);
-   int (*destroy) (struct _DriBufferPool * pool, void *private);
-   unsigned long (*offset) (struct _DriBufferPool * pool, void *private);
-   unsigned (*flags) (struct _DriBufferPool * pool, void *private);
-   unsigned long (*size) (struct _DriBufferPool * pool, void *private);
-   void *(*create) (struct _DriBufferPool * pool, unsigned long size,
-                    unsigned flags, unsigned hint, unsigned alignment);
-   int (*fence) (struct _DriBufferPool * pool, void *private,
-                 struct _DriFenceObject * fence);
-   drmBO *(*kernel) (struct _DriBufferPool * pool, void *private);
-   int (*validate) (struct _DriBufferPool * pool, void *private);
-   void *(*setstatic) (struct _DriBufferPool * pool, unsigned long offset,
-                       unsigned long size, void *virtual, unsigned flags);
-   int (*waitIdle) (struct _DriBufferPool *pool, void *private,
-                   int lazy);
-   void (*takeDown) (struct _DriBufferPool * pool);
-   void *data;
-} DriBufferPool;
-
-extern void bmError(int val, const char *file, const char *function,
-                    int line);
-#define BM_CKFATAL(val)                                               \
-  do{                                                         \
-    int tstVal = (val);                                               \
-    if (tstVal)                                               \
-      bmError(tstVal, __FILE__, __FUNCTION__, __LINE__);       \
-  } while(0);
-
-
-
-
-
-/*
- * Builtin pools.
- */
-
-/*
- * Kernel buffer objects. Size in multiples of page size. Page size aligned.
- */
-
-extern struct _DriBufferPool *driDRMPoolInit(int fd);
-extern struct _DriBufferPool *driDRMStaticPoolInit(int fd);
-
-#endif
diff --git a/src/mesa/drivers/dri/common/dri_drmpool.c b/src/mesa/drivers/dri/common/dri_drmpool.c
deleted file mode 100644 (file)
index 878a148..0000000
+++ /dev/null
@@ -1,227 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and 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 SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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, AUTHORS 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.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * 
- **************************************************************************/
-/*
- * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
- */
-
-#include <xf86drm.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include "dri_bufpool.h"
-
-/*
- * Buffer pool implementation using DRM buffer objects as DRI buffer objects.
- */
-
-static void *
-pool_create(struct _DriBufferPool *pool,
-            unsigned long size, unsigned flags, unsigned hint,
-            unsigned alignment)
-{
-   drmBO *buf = (drmBO *) malloc(sizeof(*buf));
-   int ret;
-   unsigned pageSize = getpagesize();
-
-   if (!buf)
-      return NULL;
-
-   if ((alignment > pageSize) && (alignment % pageSize)) {
-      return NULL;
-   }
-
-   ret = drmBOCreate(pool->fd, 0, size, alignment / pageSize,
-                    NULL, drm_bo_type_dc,
-                     flags, hint, buf);
-   if (ret) {
-      free(buf);
-      return NULL;
-   }
-
-   return (void *) buf;
-}
-
-static int
-pool_destroy(struct _DriBufferPool *pool, void *private)
-{
-   int ret;
-   drmBO *buf = (drmBO *) private;
-   ret = drmBODestroy(pool->fd, buf);
-   free(buf);
-   return ret;
-}
-
-static int
-pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
-         int hint, void **virtual)
-{
-   drmBO *buf = (drmBO *) private;
-
-   return drmBOMap(pool->fd, buf, flags, hint, virtual);
-}
-
-static int
-pool_unmap(struct _DriBufferPool *pool, void *private)
-{
-   drmBO *buf = (drmBO *) private;
-   return drmBOUnmap(pool->fd, buf);
-}
-
-static unsigned long
-pool_offset(struct _DriBufferPool *pool, void *private)
-{
-   drmBO *buf = (drmBO *) private;
-   return buf->offset;
-}
-
-static unsigned
-pool_flags(struct _DriBufferPool *pool, void *private)
-{
-   drmBO *buf = (drmBO *) private;
-   return buf->flags;
-}
-
-
-static unsigned long
-pool_size(struct _DriBufferPool *pool, void *private)
-{
-   drmBO *buf = (drmBO *) private;
-   return buf->size;
-}
-
-static int
-pool_fence(struct _DriBufferPool *pool, void *private,
-           struct _DriFenceObject *fence)
-{
-   /*
-    * Noop. The kernel handles all fencing.
-    */
-
-   return 0;
-}
-
-static drmBO *
-pool_kernel(struct _DriBufferPool *pool, void *private)
-{
-   return (drmBO *) private;
-}
-
-static int
-pool_waitIdle(struct _DriBufferPool *pool, void *private, int lazy)
-{
-   drmBO *buf = (drmBO *) private;
-   return drmBOWaitIdle(pool->fd, buf, (lazy) ? DRM_BO_HINT_WAIT_LAZY:0);
-}
-
-    
-static void
-pool_takedown(struct _DriBufferPool *pool)
-{
-   free(pool);
-}
-
-
-struct _DriBufferPool *
-driDRMPoolInit(int fd)
-{
-   struct _DriBufferPool *pool;
-
-   pool = (struct _DriBufferPool *) malloc(sizeof(*pool));
-
-   if (!pool)
-      return NULL;
-
-   pool->fd = fd;
-   pool->map = &pool_map;
-   pool->unmap = &pool_unmap;
-   pool->destroy = &pool_destroy;
-   pool->offset = &pool_offset;
-   pool->flags = &pool_flags;
-   pool->size = &pool_size;
-   pool->create = &pool_create;
-   pool->fence = &pool_fence;
-   pool->kernel = &pool_kernel;
-   pool->validate = NULL;
-   pool->setstatic = NULL;
-   pool->waitIdle = &pool_waitIdle;
-   pool->takeDown = &pool_takedown;
-   pool->data = NULL;
-   return pool;
-}
-
-
-static void *
-pool_setstatic(struct _DriBufferPool *pool, unsigned long offset,
-               unsigned long size, void *virtual, unsigned flags)
-{
-   drmBO *buf = (drmBO *) malloc(sizeof(*buf));
-   int ret;
-
-   if (!buf)
-      return NULL;
-
-   ret = drmBOCreate(pool->fd, offset, size, 0, NULL, drm_bo_type_fake,
-                     flags, DRM_BO_HINT_DONT_FENCE, buf);
-
-   if (ret) {
-      free(buf);
-      return NULL;
-   }
-
-   buf->virtual = virtual;
-
-   return (void *) buf;
-}
-
-
-struct _DriBufferPool *
-driDRMStaticPoolInit(int fd)
-{
-   struct _DriBufferPool *pool;
-
-   pool = (struct _DriBufferPool *) malloc(sizeof(*pool));
-
-   if (!pool)
-      return NULL;
-
-   pool->fd = fd;
-   pool->map = &pool_map;
-   pool->unmap = &pool_unmap;
-   pool->destroy = &pool_destroy;
-   pool->offset = &pool_offset;
-   pool->flags = &pool_flags;
-   pool->size = &pool_size;
-   pool->create = NULL;
-   pool->fence = &pool_fence;
-   pool->kernel = &pool_kernel;
-   pool->validate = NULL;
-   pool->setstatic = &pool_setstatic;
-   pool->waitIdle = &pool_waitIdle;
-   pool->takeDown = &pool_takedown;
-   pool->data = NULL;
-   return pool;
-}
index fff79c36ad628b9e38187564675746ca57287ef4..ce540624a520d55626c3dfe7b1f32d1cf1a1514d 100644 (file)
@@ -1,28 +1,4 @@
-/*
- * 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_util.c,v 1.7 2003/04/28 17:01:25 dawes Exp $ */
 /**
  * \file dri_util.c
  * DRI utility functions.
 
 #include "dri_util.h"
 #include "drm_sarea.h"
+#include "utils.h"
 
 #ifndef GLX_OML_sync_control
-typedef GLboolean ( * PFNGLXGETMSCRATEOMLPROC) (__DRInativeDisplay *dpy, __DRIid drawable, int32_t *numerator, int32_t *denominator);
+typedef GLboolean ( * PFNGLXGETMSCRATEOMLPROC) (__DRIdrawable *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.
+ * This is just a token extension used to signal that the driver
+ * supports setting a read drawable.
  */
-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);
-
+const __DRIextension driReadDrawableExtension = {
+    __DRI_READ_DRAWABLE, __DRI_READ_DRAWABLE_VERSION
+};
 
 /**
  * Print message to \c stderr if the \c LIBGL_DEBUG environment variable
@@ -111,64 +67,19 @@ __driUtilMessage(const char *f, ...)
     }
 }
 
-
-/*****************************************************************/
-/** \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)
+GLint
+driIntersectArea( drm_clip_rect_t rect1, drm_clip_rect_t rect2 )
 {
-    int retcode;
-    __DRIdrawable *pdraw;
-
-    retcode = drmHashLookup(drawHash, draw, (void *)&pdraw);
-    if (retcode)
-       return NULL;
-
-    return pdraw;
-}
-
+   if (rect2.x1 > rect1.x1) rect1.x1 = rect2.x1;
+   if (rect2.x2 < rect1.x2) rect1.x2 = rect2.x2;
+   if (rect2.y1 > rect1.y1) rect1.y1 = rect2.y1;
+   if (rect2.y2 < rect1.y2) rect1.y2 = rect2.y2;
 
-/**
- * Find drawables in the local hash that have been destroyed on the
- * server.
- * 
- * \param drawHash  Hash-table containing all known drawables.
- */
-static void __driGarbageCollectDrawables(void *drawHash)
-{
-    __DRIid draw;
-    __DRInativeDisplay *dpy;
-    __DRIdrawable *pdraw;
+   if (rect1.x1 > rect1.x2 || rect1.y1 > rect1.y2) return 0;
 
-    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);
-    }
+   return (rect1.x2 - rect1.x1) * (rect1.y2 - rect1.y1);
 }
 
-/*@}*/
-
-
 /*****************************************************************/
 /** \name Context (un)binding functions                          */
 /*****************************************************************/
@@ -177,10 +88,7 @@ static void __driGarbageCollectDrawables(void *drawHash)
 /**
  * Unbind context.
  * 
- * \param dpy the display handle.
- * \param scrn the screen number.
- * \param draw drawable.
- * \param read Current reading drawable.
+ * \param scrn the screen.
  * \param gc context.
  *
  * \return \c GL_TRUE on success, or \c GL_FALSE on failure.
@@ -193,56 +101,27 @@ static void __driGarbageCollectDrawables(void *drawHash)
  * 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)
+static int driUnbindContext(__DRIcontext *pcp)
 {
-    __DRIscreen *pDRIScreen;
-    __DRIdrawable *pdraw;
-    __DRIdrawable *pread;
-    __DRIcontextPrivate *pcp;
-    __DRIscreenPrivate *psp;
-    __DRIdrawablePrivate *pdp;
-    __DRIdrawablePrivate *prp;
+    __DRIscreen *psp;
+    __DRIdrawable *pdp;
+    __DRIdrawable *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;
+    if (pcp == NULL)
+        return GL_FALSE;
 
+    psp = pcp->driScreenPriv;
+    pdp = pcp->driDrawablePriv;
+    prp = pcp->driReadablePriv;
 
     /* Let driver unbind drawable from context */
     (*psp->DriverAPI.UnbindContext)(pcp);
 
-
     if (pdp->refcount == 0) {
        /* ERROR!!! */
        return GL_FALSE;
@@ -259,12 +138,6 @@ static GLboolean driUnbindContext(__DRInativeDisplay *dpy, int scrn,
        prp->refcount--;
     }
 
-   /* destroy the drawables if they no longer exist on the server */
-   if ((pdp->refcount == 0) || (prp->refcount == 0)) {
-      /* probably shouldn't need the collector here,
-         as we know the affected drawables (or could there be others?) */
-      __driGarbageCollectDrawables(pdp->driScreenPriv->drawHash);
-   }
 
     /* 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
@@ -279,77 +152,24 @@ static GLboolean driUnbindContext(__DRInativeDisplay *dpy, int scrn,
     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)
+static int driBindContext(__DRIcontext *pcp,
+                         __DRIdrawable *pdp,
+                         __DRIdrawable *prp)
 {
-    __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;
-       }
+    __DRIscreenPrivate *psp = pcp->driScreenPriv;
 
-    }
-    pdp = (__DRIdrawablePrivate *) pdraw->private;
+    /*
+    ** Assume error checking is done properly in glXMakeCurrent before
+    ** calling driBindContext.
+    */
 
-    /* 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;
-    }
+    if (pcp == NULL || pdp == None || prp == None)
+       return GL_FALSE;
 
     /* Bind the drawable to the context */
     pcp->driDrawablePriv = pdp;
@@ -364,16 +184,19 @@ static GLboolean DoBindContext(__DRInativeDisplay *dpy,
     ** 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);
-    }
 
-    if ((pdp != prp) && (!prp->pStamp || *prp->pStamp != prp->lastStamp)) {
-       DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
-       __driUtilUpdateDrawableInfo(prp);
-       DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
+    if (!psp->dri2.enabled) {
+       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);
+       }
+       
+       if ((pdp != prp) && (!prp->pStamp || *prp->pStamp != prp->lastStamp)) {
+           DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
+           __driUtilUpdateDrawableInfo(prp);
+           DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
+       }
     }
 
     /* Call device-specific MakeCurrent */
@@ -382,37 +205,6 @@ static GLboolean DoBindContext(__DRInativeDisplay *dpy,
     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 );
-}
 /*@}*/
 
 
@@ -436,7 +228,7 @@ static GLboolean driBindContext(__DRInativeDisplay *dpy, int scrn,
 void
 __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp)
 {
-    __DRIscreenPrivate *psp;
+    __DRIscreenPrivate *psp = pdp->driScreenPriv;
     __DRIcontextPrivate *pcp = pdp->driContextPriv;
     
     if (!pcp 
@@ -447,15 +239,6 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp)
         */
     }
 
-    psp = pdp->driScreenPriv;
-    if (!psp) {
-       /* ERROR!!! */
-       _mesa_problem(NULL, "Warning! Possible infinite loop due to bug "
-                    "in file %s, line %d\n",
-                    __FILE__, __LINE__);
-       return;
-    }
-
     if (pdp->pClipRects) {
        _mesa_free(pdp->pClipRects); 
        pdp->pClipRects = NULL;
@@ -468,15 +251,15 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp)
 
     DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
 
-    if (!__driFindDrawable(psp->drawHash, pdp->draw) ||
-       ! (*dri_interface->getDrawableInfo)(pdp->display, pdp->screen, pdp->draw,
+    if (! (*psp->getDrawableInfo->getDrawableInfo)(pdp,
                          &pdp->index, &pdp->lastStamp,
                          &pdp->x, &pdp->y, &pdp->w, &pdp->h,
                          &pdp->numClipRects, &pdp->pClipRects,
                          &pdp->backX,
                          &pdp->backY,
                          &pdp->numBackClipRects,
-                         &pdp->pBackClipRects )) {
+                         &pdp->pBackClipRects,
+                         pdp->loaderPrivate)) {
        /* Error -- eg the window may have been destroyed.  Keep going
         * with no cliprects.
         */
@@ -490,7 +273,6 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp)
        pdp->pStamp = &(psp->pSAREA->drawableTable[pdp->index].stamp);
 
     DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
-
 }
 
 /*@}*/
@@ -500,10 +282,28 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp)
 /*****************************************************************/
 /*@{*/
 
+static void driReportDamage(__DRIdrawable *pdp,
+                           struct drm_clip_rect *pClipRects, int numClipRects)
+{
+    __DRIscreen *psp = pdp->driScreenPriv;
+
+    /* Check that we actually have the new damage report method */
+    if (psp->damage) {
+       /* Report the damage.  Currently, all our drivers draw
+        * directly to the front buffer, so we report the damage there
+        * rather than to the backing storein (if any).
+        */
+       (*psp->damage->reportDamage)(pdp,
+                                    pdp->x, pdp->y,
+                                    pClipRects, numClipRects,
+                                    GL_TRUE, pdp->loaderPrivate);
+    }
+}
+
+
 /**
  * Swap buffers.
  *
- * \param dpy the display handle.
  * \param drawablePrivate opaque pointer to the per-drawable private info.
  * 
  * \internal
@@ -511,78 +311,32 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp)
  * 
  * Is called directly from glXSwapBuffers().
  */
-static void driSwapBuffers( __DRInativeDisplay *dpy, void *drawablePrivate )
+static void driSwapBuffers(__DRIdrawable *dPriv)
 {
-    __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
-    drm_clip_rect_t rect;
+    __DRIscreen *psp = dPriv->driScreenPriv;
 
-    dPriv->swapBuffers(dPriv);
+    if (!dPriv->numClipRects)
+        return;
 
-    /* Check that we actually have the new damage report method */
-    if (api_ver < 20070105 || dri_interface->reportDamage == NULL)
-       return;
-
-    /* Assume it's affecting the whole drawable for now */
-    rect.x1 = 0;
-    rect.y1 = 0;
-    rect.x2 = rect.x1 + dPriv->w;
-    rect.y2 = rect.y1 + dPriv->h;
-
-    /* Report the damage.  Currently, all our drivers draw directly to the
-     * front buffer, so we report the damage there rather than to the backing
-     * store (if any).
-     */
-    (*dri_interface->reportDamage)(dpy, dPriv->screen, dPriv->draw,
-                                  dPriv->x, dPriv->y,
-                                  &rect, 1, GL_TRUE);
-}
-
-/**
- * Called directly from a number of higher-level GLX functions.
- */
-static int driGetMSC( void *screenPrivate, int64_t *msc )
-{
-    __DRIscreenPrivate *sPriv = (__DRIscreenPrivate *) screenPrivate;
+    psp->DriverAPI.SwapBuffers(dPriv);
 
-    return sPriv->DriverAPI.GetMSC( sPriv, msc );
+    driReportDamage(dPriv, dPriv->pClipRects, dPriv->numClipRects);
 }
 
-/**
- * Called directly from a number of higher-level GLX functions.
- */
-static int driGetSBC( __DRInativeDisplay *dpy, void *drawablePrivate, int64_t *sbc )
+static int driDrawableGetMSC( __DRIscreen *sPriv, __DRIdrawable *dPriv,
+                             int64_t *msc )
 {
-   __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
-   __DRIswapInfo  sInfo;
-   int  status;
-
-
-   status = dPriv->driScreenPriv->DriverAPI.GetSwapInfo( dPriv, & sInfo );
-   *sbc = sInfo.swap_count;
-
-   return status;
+    return sPriv->DriverAPI.GetDrawableMSC(sPriv, dPriv, msc);
 }
 
-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 )
+static int driWaitForMSC(__DRIdrawable *dPriv, 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 );
@@ -600,63 +354,72 @@ static int driWaitForMSC( __DRInativeDisplay * dpy, void *drawablePriv,
     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 );
-}
+const __DRImediaStreamCounterExtension driMediaStreamCounterExtension = {
+    { __DRI_MEDIA_STREAM_COUNTER, __DRI_MEDIA_STREAM_COUNTER_VERSION },
+    driWaitForMSC,
+    driDrawableGetMSC,
+};
 
-static void driCopySubBuffer( __DRInativeDisplay *dpy, void *drawablePrivate,
+
+static void driCopySubBuffer(__DRIdrawable *dPriv,
                              int x, int y, int w, int h)
 {
-    __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
+    drm_clip_rect_t rect;
+
+    rect.x1 = x;
+    rect.y1 = dPriv->h - y - h;
+    rect.x2 = x + w;
+    rect.y2 = rect.y1 + h;
+    driReportDamage(dPriv, &rect, 1);
+
     dPriv->driScreenPriv->DriverAPI.CopySubBuffer(dPriv, x, y, w, h);
-    (void) dpy;
 }
 
+const __DRIcopySubBufferExtension driCopySubBufferExtension = {
+    { __DRI_COPY_SUB_BUFFER, __DRI_COPY_SUB_BUFFER_VERSION },
+    driCopySubBuffer
+};
+
+static void driSetSwapInterval(__DRIdrawable *dPriv, unsigned int interval)
+{
+    dPriv->swap_interval = interval;
+}
+
+static unsigned int driGetSwapInterval(__DRIdrawable *dPriv)
+{
+    return dPriv->swap_interval;
+}
+
+const __DRIswapControlExtension driSwapControlExtension = {
+    { __DRI_SWAP_CONTROL, __DRI_SWAP_CONTROL_VERSION },
+    driSetSwapInterval,
+    driGetSwapInterval
+};
+
+
 /**
  * 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)
+static __DRIdrawable *
+driCreateNewDrawable(__DRIscreen *psp, const __DRIconfig *config,
+                    drm_drawable_t hwDrawable, int renderType,
+                    const int *attrs, void *data)
 {
-    __DRIscreen * const pDRIScreen = (*dri_interface->getScreen)(dpy, modes->screen);
-    __DRIscreenPrivate *psp;
-    __DRIdrawablePrivate *pdp;
-
-
-    pdraw->private = NULL;
+    __DRIdrawable *pdp;
 
     /* 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));
+    pdp = _mesa_malloc(sizeof *pdp);
     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->loaderPrivate = data;
+    pdp->hHWDrawable = hwDrawable;
     pdp->refcount = 0;
     pdp->pStamp = NULL;
     pdp->lastStamp = 0;
@@ -669,80 +432,56 @@ static void *driCreateNewDrawable(__DRInativeDisplay *dpy,
     pdp->numBackClipRects = 0;
     pdp->pClipRects = NULL;
     pdp->pBackClipRects = NULL;
-    pdp->display = dpy;
-    pdp->screen = modes->screen;
+    pdp->vblSeq = 0;
+    pdp->vblFlags = 0;
 
-    psp = (__DRIscreenPrivate *)pDRIScreen->private;
     pdp->driScreenPriv = psp;
     pdp->driContextPriv = &psp->dummyContextPriv;
 
-    if (!(*psp->DriverAPI.CreateBuffer)(psp, pdp, modes,
+    if (!(*psp->DriverAPI.CreateBuffer)(psp, pdp, &config->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;
-
-    if (driCompareGLXAPIVersion (20060314) >= 0)
-       pdraw->copySubBuffer = driCopySubBuffer;
+    pdp->msc_base = 0;
 
     /* 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;
-    }
+    pdp->swap_interval = (unsigned)-1;
 
-   return (void *) pdp;
+    return pdp;
 }
 
+
 static __DRIdrawable *
-driGetDrawable(__DRInativeDisplay *dpy, __DRIid draw, void *screenPrivate)
+dri2CreateNewDrawable(__DRIscreen *screen,
+                     const __DRIconfig *config,
+                     void *loaderPrivate)
 {
-    __DRIscreenPrivate *psp = (__DRIscreenPrivate *) screenPrivate;
+    __DRIdrawable *pdraw;
 
-    /*
-    ** Make sure this routine returns NULL if the drawable is not bound
-    ** to a direct rendering context!
-    */
-    return __driFindDrawable(psp->drawHash, draw);
+    pdraw = driCreateNewDrawable(screen, config, 0, 0, NULL, loaderPrivate);
+    if (!pdraw)
+       return NULL;
+
+    pdraw->pClipRects = _mesa_malloc(sizeof *pdraw->pBackClipRects);
+    pdraw->pBackClipRects = _mesa_malloc(sizeof *pdraw->pBackClipRects);
+
+    return pdraw;
 }
 
+
 static void
-driDestroyDrawable(__DRInativeDisplay *dpy, void *drawablePrivate)
+driDestroyDrawable(__DRIdrawable *pdp)
 {
-    __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *) drawablePrivate;
     __DRIscreenPrivate *psp;
-    int scrn;
 
     if (pdp) {
        psp = pdp->driScreenPriv;
-       scrn = psp->myNum;
         (*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;
@@ -766,23 +505,15 @@ driDestroyDrawable(__DRInativeDisplay *dpy, void *drawablePrivate)
 /**
  * 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)
+driDestroyContext(__DRIcontext *pcp)
 {
-    __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);
     }
 }
@@ -791,13 +522,9 @@ driDestroyContext(__DRInativeDisplay *dpy, int scrn, void *contextPrivate)
 /**
  * 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.
+ * \param shared        Context with which to share textures, etc. or NULL
  *
  * \returns An opaque pointer to the per-context private information on
  *          success, or \c NULL on failure.
@@ -809,36 +536,18 @@ driDestroyContext(__DRInativeDisplay *dpy, int scrn, void *contextPrivate)
  * context.
  *
  */
-static void *
-driCreateNewContext(__DRInativeDisplay *dpy, const __GLcontextModes *modes,
-                   int render_type, void *sharedPrivate, __DRIcontext *pctx)
+static __DRIcontext *
+driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config,
+                   int render_type, __DRIcontext *shared, 
+                   drm_context_t hwContext, void *data)
 {
-    __DRIscreen *pDRIScreen;
-    __DRIcontextPrivate *pcp;
-    __DRIcontextPrivate *pshare = (__DRIcontextPrivate *) sharedPrivate;
-    __DRIscreenPrivate *psp;
-    void * const shareCtx = (pshare != NULL) ? pshare->driverPrivate : NULL;
+    __DRIcontext *pcp;
+    void * const shareCtx = (shared != NULL) ? shared->driverPrivate : NULL;
 
-    pDRIScreen = (*dri_interface->getScreen)(dpy, modes->screen);
-    if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) {
-       /* ERROR!!! */
+    pcp = _mesa_malloc(sizeof *pcp);
+    if (!pcp)
        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;
 
@@ -846,8 +555,7 @@ driCreateNewContext(__DRInativeDisplay *dpy, const __GLcontextModes *modes,
      * context.
      */
 
-    if (!psp->dummyContextPriv.driScreenPriv) {
-        psp->dummyContextPriv.contextID = 0;
+    if (!psp->dri2.enabled && !psp->dummyContextPriv.driScreenPriv) {
         psp->dummyContextPriv.hHWContext = psp->pSAREA->dummy_context;
         psp->dummyContextPriv.driScreenPriv = psp;
         psp->dummyContextPriv.driDrawablePriv = NULL;
@@ -855,21 +563,31 @@ driCreateNewContext(__DRInativeDisplay *dpy, const __GLcontextModes *modes,
        /* No other fields should be used! */
     }
 
-    pctx->destroyContext = driDestroyContext;
-    pctx->bindContext    = driBindContext;
-    pctx->unbindContext  = driUnbindContext;
+    pcp->hHWContext = hwContext;
 
-    if ( !(*psp->DriverAPI.CreateContext)(modes, pcp, shareCtx) ) {
-        (void) (*dri_interface->destroyContext)(dpy, modes->screen,
-                                               pcp->contextID);
+    if ( !(*psp->DriverAPI.CreateContext)(&config->modes, pcp, shareCtx) ) {
         _mesa_free(pcp);
         return NULL;
     }
 
-    __driGarbageCollectDrawables(pcp->driScreenPriv->drawHash);
-
     return pcp;
 }
+
+
+static __DRIcontext *
+dri2CreateNewContext(__DRIscreen *screen, const __DRIconfig *config,
+                     __DRIcontext *shared, void *data)
+{
+    return driCreateNewContext(screen, config, 0, shared, 0, data);
+}
+
+
+static int
+driCopyContext(__DRIcontext *dest, __DRIcontext *src, unsigned long mask)
+{
+    return GL_FALSE;
+}
+
 /*@}*/
 
 
@@ -881,18 +599,12 @@ driCreateNewContext(__DRInativeDisplay *dpy, const __GLcontextModes *modes,
 /**
  * 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)
+static void driDestroyScreen(__DRIscreen *psp)
 {
-    __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
@@ -902,34 +614,44 @@ static void driDestroyScreen(__DRInativeDisplay *dpy, int scrn, void *screenPriv
        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)drmCloseOnce(psp->fd);
-       if ( psp->modes != NULL ) {
-           (*dri_interface->destroyContextModes)( psp->modes );
+       if (!psp->dri2.enabled) {
+          (void)drmUnmap((drmAddress)psp->pSAREA, SAREA_MAX);
+          (void)drmUnmap((drmAddress)psp->pFB, psp->fbSize);
+          (void)drmCloseOnce(psp->fd);
        }
 
-       assert(psp->drawHash);
-       drmHashDestroy(psp->drawHash);
-
        _mesa_free(psp);
     }
 }
 
+static void
+setupLoaderExtensions(__DRIscreen *psp,
+                     const __DRIextension **extensions)
+{
+    int i;
+
+    for (i = 0; extensions[i]; i++) {
+       if (strcmp(extensions[i]->name, __DRI_GET_DRAWABLE_INFO) == 0)
+           psp->getDrawableInfo = (__DRIgetDrawableInfoExtension *) extensions[i];
+       if (strcmp(extensions[i]->name, __DRI_DAMAGE) == 0)
+           psp->damage = (__DRIdamageExtension *) extensions[i];
+       if (strcmp(extensions[i]->name, __DRI_SYSTEM_TIME) == 0)
+           psp->systemTime = (__DRIsystemTimeExtension *) extensions[i];
+       if (strcmp(extensions[i]->name, __DRI_DRI2_LOADER) == 0)
+           psp->dri2.loader = (__DRIdri2LoaderExtension *) extensions[i];
+    }
+}
 
 /**
- * Utility function used to create a new driver-private screen structure.
+ * 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.
+ *
+ * For legacy DRI.
  * 
- * \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.
@@ -938,48 +660,33 @@ static void driDestroyScreen(__DRInativeDisplay *dpy, int scrn, void *screenPriv
  *                     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.
+ * \param extensions   ??
+ * \param driver_modes  Returns modes suppoted by the driver
+ * \param loaderPrivate  ??
  * 
- * \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.
+ * \note There is no need to check the minimum API version in this
+ * function.  Since the name of this 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)
+static __DRIscreen *
+driCreateNewScreen(int scrn,
+                  const __DRIversion *ddx_version,
+                  const __DRIversion *dri_version,
+                  const __DRIversion *drm_version,
+                  const __DRIframebuffer *frame_buffer,
+                  drmAddress pSAREA, int fd, 
+                  const __DRIextension **extensions,
+                  const __DRIconfig ***driver_modes,
+                  void *loaderPrivate)
 {
-    __DRIscreenPrivate *psp;
-
-
-    api_ver = internal_api_version;
-
-    psp = (__DRIscreenPrivate *)_mesa_malloc(sizeof(__DRIscreenPrivate));
-    if (!psp) {
-       return NULL;
-    }
+    static const __DRIextension *emptyExtensionList[] = { NULL };
+    __DRIscreen *psp;
 
-    /* Create the hash table */
-    psp->drawHash = drmHashCreate();
-    if ( psp->drawHash == NULL ) {
-       _mesa_free( psp );
+    psp = _mesa_malloc(sizeof *psp);
+    if (!psp)
        return NULL;
-    }
 
-    psp->display = dpy;
-    psp->myNum = scrn;
-    psp->psc = psc;
-    psp->modes = modes;
+    setupLoaderExtensions(psp, extensions);
 
     /*
     ** NOT_DONE: This is used by the X server to detect when the client
@@ -988,20 +695,12 @@ __driUtilCreateNewScreen(__DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
     */
     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->drm_version = *drm_version;
+    psp->ddx_version = *ddx_version;
+    psp->dri_version = *dri_version;
 
     psp->pSAREA = pSAREA;
+    psp->lock = (drmLock *) &psp->pSAREA->lock;
 
     psp->pFB = frame_buffer->base;
     psp->fbSize = frame_buffer->size;
@@ -1012,7 +711,10 @@ __driUtilCreateNewScreen(__DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
     psp->pDevPriv = frame_buffer->dev_priv;
     psp->fbBPP = psp->fbStride * 8 / frame_buffer->width;
 
+    psp->extensions = emptyExtensionList;
     psp->fd = fd;
+    psp->myNum = scrn;
+    psp->dri2.enabled = GL_FALSE;
 
     /*
     ** Do not init dummy context here; actual initialization will be
@@ -1021,63 +723,125 @@ __driUtilCreateNewScreen(__DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
     */
     psp->dummyContextPriv.driScreenPriv = NULL;
 
-    psc->destroyScreen     = driDestroyScreen;
-    psc->createNewDrawable = driCreateNewDrawable;
-    psc->getDrawable       = driGetDrawable;
-    psc->getMSC            = driGetMSC;
-    psc->createNewContext  = driCreateNewContext;
-
-    if (internal_api_version >= 20070121)
-       psc->setTexOffset  = psp->DriverAPI.setTexOffset;
+    psp->DriverAPI = driDriverAPI;
 
-    if ( (psp->DriverAPI.InitDriver != NULL)
-        && !(*psp->DriverAPI.InitDriver)(psp) ) {
-       _mesa_free( psp );
+    *driver_modes = driDriverAPI.InitScreen(psp);
+    if (*driver_modes == NULL) {
+       _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().
+ * DRI2
  */
-int driCompareGLXAPIVersion( GLint required_version )
+static __DRIscreen *
+dri2CreateNewScreen(int scrn, int fd,
+                   const __DRIextension **extensions,
+                   const __DRIconfig ***driver_configs, void *data)
 {
-   if ( api_ver > required_version ) {
-      return 1;
-   }
-   else if ( api_ver == required_version ) {
-      return 0;
-   }
+    static const __DRIextension *emptyExtensionList[] = { NULL };
+    __DRIscreen *psp;
+    drmVersionPtr version;
+
+    if (driDriverAPI.InitScreen2 == NULL)
+        return NULL;
+
+    psp = _mesa_malloc(sizeof(*psp));
+    if (!psp)
+       return NULL;
+
+    setupLoaderExtensions(psp, extensions);
+
+    version = drmGetVersion(fd);
+    if (version) {
+       psp->drm_version.major = version->version_major;
+       psp->drm_version.minor = version->version_minor;
+       psp->drm_version.patch = version->version_patchlevel;
+       drmFreeVersion(version);
+    }
+
+    psp->extensions = emptyExtensionList;
+    psp->fd = fd;
+    psp->myNum = scrn;
+    psp->dri2.enabled = GL_TRUE;
 
-   return -1;
+    psp->DriverAPI = driDriverAPI;
+    *driver_configs = driDriverAPI.InitScreen2(psp);
+    if (*driver_configs == NULL) {
+       _mesa_free(psp);
+       return NULL;
+    }
+
+    psp->DriverAPI = driDriverAPI;
+
+    return psp;
 }
 
+static const __DRIextension **driGetExtensions(__DRIscreen *psp)
+{
+    return psp->extensions;
+}
+
+/** Core interface */
+const __DRIcoreExtension driCoreExtension = {
+    { __DRI_CORE, __DRI_CORE_VERSION },
+    NULL,
+    driDestroyScreen,
+    driGetExtensions,
+    driGetConfigAttrib,
+    driIndexConfigAttrib,
+    NULL,
+    driDestroyDrawable,
+    driSwapBuffers,
+    NULL,
+    driCopyContext,
+    driDestroyContext,
+    driBindContext,
+    driUnbindContext
+};
+
+/** Legacy DRI interface */
+const __DRIlegacyExtension driLegacyExtension = {
+    { __DRI_LEGACY, __DRI_LEGACY_VERSION },
+    driCreateNewScreen,
+    driCreateNewDrawable,
+    driCreateNewContext,
+};
+
+/** Legacy DRI interface */
+const __DRIdri2Extension driDRI2Extension = {
+    { __DRI_DRI2, __DRI_DRI2_VERSION },
+    dri2CreateNewScreen,
+    dri2CreateNewDrawable,
+    dri2CreateNewContext,
+};
+
+/* This is the table of extensions that the loader will dlsym() for. */
+PUBLIC const __DRIextension *__driDriverExtensions[] = {
+    &driCoreExtension.base,
+    &driLegacyExtension.base,
+    &driDRI2Extension.base,
+    NULL
+};
 
 static int
-driQueryFrameTracking( __DRInativeDisplay * dpy, void * priv,
-                      int64_t * sbc, int64_t * missedFrames,
-                      float * lastMissedUsage, float * usage )
+driFrameTracking(__DRIdrawable *drawable, GLboolean enable)
+{
+    return GLX_BAD_CONTEXT;
+}
+
+static int
+driQueryFrameTracking(__DRIdrawable *dpriv,
+                     int64_t * sbc, int64_t * missedFrames,
+                     float * lastMissedUsage, float * usage)
 {
    __DRIswapInfo   sInfo;
    int             status;
    int64_t         ust;
-   __DRIdrawablePrivate * dpriv = (__DRIdrawablePrivate *) priv;
-
+   __DRIscreenPrivate *psp = dpriv->driScreenPriv;
 
    status = dpriv->driScreenPriv->DriverAPI.GetSwapInfo( dpriv, & sInfo );
    if ( status == 0 ) {
@@ -1085,13 +849,18 @@ driQueryFrameTracking( __DRInativeDisplay * dpy, void * priv,
       *missedFrames = sInfo.swap_missed_count;
       *lastMissedUsage = sInfo.swap_missed_usage;
 
-      (*dri_interface->getUST)( & ust );
+      (*psp->systemTime->getUST)( & ust );
       *usage = driCalculateSwapUsage( dpriv, sInfo.swap_ust, ust );
    }
 
    return status;
 }
 
+const __DRIframeTrackingExtension driFrameTrackingExtension = {
+    { __DRI_FRAME_TRACKING, __DRI_FRAME_TRACKING_VERSION },
+    driFrameTracking,
+    driQueryFrameTracking    
+};
 
 /**
  * Calculate amount of swap interval used between GLX buffer swaps.
@@ -1129,11 +898,10 @@ driCalculateSwapUsage( __DRIdrawablePrivate *dPriv, int64_t last_swap_ust,
    int32_t   d;
    int       interval;
    float     usage = 1.0;
+   __DRIscreenPrivate *psp = dPriv->driScreenPriv;
 
-
-   if ( (*dri_interface->getMSCRate)( dPriv->display, dPriv->draw, &n, &d ) ) {
-      interval = (dPriv->pdraw->swap_interval != 0)
-         ? dPriv->pdraw->swap_interval : 1;
+   if ( (*psp->systemTime->getMSCRate)(dPriv, &n, &d, dPriv->loaderPrivate) ) {
+      interval = (dPriv->swap_interval != 0) ? dPriv->swap_interval : 1;
 
 
       /* We want to calculate
index c0cda5d25fc576954570c859adbbd5f0ad6f29a0..1a8f020c778bd07a69b13f0de7d30e20f994ae33 100644 (file)
 #define _DRI_UTIL_H_
 
 #include <GL/gl.h>
-#include "drm.h"
-#include "drm_sarea.h"
-#include "xf86drm.h"
+#include <drm.h>
+#include <drm_sarea.h>
+#include <xf86drm.h>
+#include "glheader.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;
 
+/* Typedefs to avoid rewriting the world. */
+typedef struct __DRIscreenRec  __DRIscreenPrivate;
+typedef struct __DRIdrawableRec        __DRIdrawablePrivate;
+typedef struct __DRIcontextRec __DRIcontextPrivate;
+
+/**
+ * Extensions.
+ */
+extern const __DRIlegacyExtension driLegacyExtension;
+extern const __DRIcoreExtension driCoreExtension;
+extern const __DRIextension driReadDrawableExtension;
+extern const __DRIcopySubBufferExtension driCopySubBufferExtension;
+extern const __DRIswapControlExtension driSwapControlExtension;
+extern const __DRIframeTrackingExtension driFrameTrackingExtension;
+extern const __DRImediaStreamCounterExtension driMediaStreamCounterExtension;
 
 /**
  * Used by DRI_VALIDATE_DRAWABLE_INFO
@@ -78,7 +89,7 @@ typedef struct __DRIutilversionRec2    __DRIutilversion2;
 /**
  * Utility macro to validate the drawable information.
  *
- * See __DRIdrawablePrivate::pStamp and __DRIdrawablePrivate::lastStamp.
+ * See __DRIdrawable::pStamp and __DRIdrawable::lastStamp.
  */
 #define DRI_VALIDATE_DRAWABLE_INFO(psp, pdp)                            \
 do {                                                                    \
@@ -107,94 +118,95 @@ do {                                                                    \
  * this structure.
  */
 struct __DriverAPIRec {
-    /** 
-     * Driver initialization callback
-     */
-    GLboolean (*InitDriver)(__DRIscreenPrivate *driScrnPriv);
-    
+    const __DRIconfig **(*InitScreen) (__DRIscreen * priv);
+
     /**
      * Screen destruction callback
      */
-    void (*DestroyScreen)(__DRIscreenPrivate *driScrnPriv);
+    void (*DestroyScreen)(__DRIscreen *driScrnPriv);
 
     /**
      * Context creation callback
      */                    
     GLboolean (*CreateContext)(const __GLcontextModes *glVis,
-                               __DRIcontextPrivate *driContextPriv,
+                               __DRIcontext *driContextPriv,
                                void *sharedContextPrivate);
 
     /**
      * Context destruction callback
      */
-    void (*DestroyContext)(__DRIcontextPrivate *driContextPriv);
+    void (*DestroyContext)(__DRIcontext *driContextPriv);
 
     /**
      * Buffer (drawable) creation callback
      */
-    GLboolean (*CreateBuffer)(__DRIscreenPrivate *driScrnPriv,
-                              __DRIdrawablePrivate *driDrawPriv,
+    GLboolean (*CreateBuffer)(__DRIscreen *driScrnPriv,
+                              __DRIdrawable *driDrawPriv,
                               const __GLcontextModes *glVis,
                               GLboolean pixmapBuffer);
     
     /**
      * Buffer (drawable) destruction callback
      */
-    void (*DestroyBuffer)(__DRIdrawablePrivate *driDrawPriv);
+    void (*DestroyBuffer)(__DRIdrawable *driDrawPriv);
 
     /**
      * Buffer swapping callback 
      */
-    void (*SwapBuffers)(__DRIdrawablePrivate *driDrawPriv);
+    void (*SwapBuffers)(__DRIdrawable *driDrawPriv);
 
     /**
      * Context activation callback
      */
-    GLboolean (*MakeCurrent)(__DRIcontextPrivate *driContextPriv,
-                             __DRIdrawablePrivate *driDrawPriv,
-                             __DRIdrawablePrivate *driReadPriv);
+    GLboolean (*MakeCurrent)(__DRIcontext *driContextPriv,
+                             __DRIdrawable *driDrawPriv,
+                             __DRIdrawable *driReadPriv);
 
     /**
      * Context unbinding callback
      */
-    GLboolean (*UnbindContext)(__DRIcontextPrivate *driContextPriv);
+    GLboolean (*UnbindContext)(__DRIcontext *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 );
-
+    int (*GetSwapInfo)( __DRIdrawable *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, 
+    int (*WaitForMSC)( __DRIdrawable *priv, int64_t target_msc, 
                       int64_t divisor, int64_t remainder,
                       int64_t * msc );
-    int (*WaitForSBC)( __DRIdrawablePrivate *priv, int64_t target_sbc,
+    int (*WaitForSBC)( __DRIdrawable *priv, int64_t target_sbc,
                       int64_t * msc, int64_t * sbc );
 
-    int64_t (*SwapBuffersMSC)( __DRIdrawablePrivate *priv, int64_t target_msc,
+    int64_t (*SwapBuffersMSC)( __DRIdrawable *priv, int64_t target_msc,
                               int64_t divisor, int64_t remainder );
     /*@}*/
-    void (*CopySubBuffer)(__DRIdrawablePrivate *driDrawPriv,
+    void (*CopySubBuffer)(__DRIdrawable *driDrawPriv,
                          int x, int y, int w, int h);
 
     /**
-     * See corresponding field in \c __DRIscreenRec.
+     * New version of GetMSC so we can pass drawable data to the low
+     * level DRM driver (e.g. pipe info).  Required if
+     * GLX_SGI_video_sync or GLX_OML_sync_control is supported.
      */
-    void (*setTexOffset)(__DRIcontext *pDRICtx, GLint texname,
-                        unsigned long long offset, GLint depth, GLuint pitch);
+    int (*GetDrawableMSC) ( __DRIscreen * priv,
+                           __DRIdrawable *drawablePrivate,
+                           int64_t *count);
+
+
+
+    /* DRI2 Entry point */
+    const __DRIconfig **(*InitScreen2) (__DRIscreen * priv);
 };
 
+extern const struct __DriverAPIRec driDriverAPI;
+
 
 struct __DRIswapInfoRec {
     /** 
@@ -230,7 +242,7 @@ struct __DRIswapInfoRec {
 /**
  * Per-drawable private DRI driver information.
  */
-struct __DRIdrawablePrivateRec {
+struct __DRIdrawableRec {
     /**
      * Kernel drawable handle
      */
@@ -244,10 +256,10 @@ struct __DRIdrawablePrivateRec {
     void *driverPrivate;
 
     /**
-     * X's drawable ID associated with this private drawable.
+     * Private data from the loader.  We just hold on to it and pass
+     * it back when calling into loader provided functions.
      */
-    __DRIid draw;
-    __DRIdrawable *pdraw;
+    void *loaderPrivate;
 
     /**
      * Reference count for number of context's currently bound to this
@@ -272,7 +284,7 @@ struct __DRIdrawablePrivateRec {
     /**
      * Last value of the stamp.
      *
-     * If this differs from the value stored at __DRIdrawablePrivate::pStamp,
+     * If this differs from the value stored at __DRIdrawable::pStamp,
      * then the drawable information has been modified by the X server, and the
      * drawable information (below) should be retrieved from the X server.
      */
@@ -306,41 +318,52 @@ struct __DRIdrawablePrivateRec {
     /*@}*/
 
     /**
-     * Pointer to context to which this drawable is currently bound.
+     * \name Vertical blank tracking information
+     * Used for waiting on vertical blank events.
      */
-    __DRIcontextPrivate *driContextPriv;
+    /*@{*/
+    unsigned int vblSeq;
+    unsigned int vblFlags;
+    /*@}*/
 
     /**
-     * Pointer to screen on which this drawable was created.
+     * \name Monotonic MSC tracking
+     *
+     * Low level driver is responsible for updating msc_base and
+     * vblSeq values so that higher level code can calculate
+     * a new msc value or msc target for a WaitMSC call.  The new value
+     * will be:
+     *   msc = msc_base + get_vblank_count() - vblank_base;
+     *
+     * And for waiting on a value, core code will use:
+     *   actual_target = target_msc - msc_base + vblank_base;
      */
-    __DRIscreenPrivate *driScreenPriv;
+    /*@{*/
+    int64_t vblank_base;
+    int64_t msc_base;
+    /*@}*/
 
     /**
-     * \name Display and screen information.
-     * 
-     * Basically just need these for when the locking code needs to call
-     * \c __driUtilUpdateDrawableInfo.
+     * Pointer to context to which this drawable is currently bound.
      */
-    /*@{*/
-    __DRInativeDisplay *display;
-    int screen;
-    /*@}*/
+    __DRIcontext *driContextPriv;
 
     /**
-     * Called via glXSwapBuffers().
+     * Pointer to screen on which this drawable was created.
      */
-    void (*swapBuffers)( __DRIdrawablePrivate *dPriv );
+    __DRIscreen *driScreenPriv;
+
+    /**
+     * Controls swap interval as used by GLX_SGI_swap_control and
+     * GLX_MESA_swap_control.
+     */
+    unsigned int swap_interval;
 };
 
 /**
  * Per-context private driver information.
  */
-struct __DRIcontextPrivateRec {
-    /**
-     * Kernel context handle used to access the device lock.
-     */
-    __DRIid contextID;
-
+struct __DRIcontextRec {
     /**
      * Kernel context handle used to access the device lock.
      */
@@ -352,35 +375,30 @@ struct __DRIcontextPrivateRec {
     void *driverPrivate;
 
     /**
-     * This context's display pointer.
+     * Pointer back to the \c __DRIcontext that contains this structure.
      */
-    __DRInativeDisplay *display;
+    __DRIcontext *pctx;
 
     /**
      * Pointer to drawable currently bound to this context for drawing.
      */
-    __DRIdrawablePrivate *driDrawablePriv;
+    __DRIdrawable *driDrawablePriv;
 
     /**
      * Pointer to drawable currently bound to this context for reading.
      */
-    __DRIdrawablePrivate *driReadablePriv;
+    __DRIdrawable *driReadablePriv;
 
     /**
      * Pointer to screen on which this context was created.
      */
-    __DRIscreenPrivate *driScreenPriv;
+    __DRIscreen *driScreenPriv;
 };
 
 /**
  * Per-screen private driver information.
  */
-struct __DRIscreenPrivateRec {
-    /**
-     * Display for this screen
-     */
-    __DRInativeDisplay *display;
-
+struct __DRIscreenRec {
     /**
      * Current screen's number
      */
@@ -391,38 +409,21 @@ struct __DRIscreenPrivateRec {
      */
     struct __DriverAPIRec DriverAPI;
 
+    const __DRIextension **extensions;
     /**
-     * \name DDX version
      * DDX / 2D driver version information.
-     * \todo Replace these fields with a \c __DRIversionRec.
      */
-    /*@{*/
-    int ddxMajor;
-    int ddxMinor;
-    int ddxPatch;
-    /*@}*/
+    __DRIversion ddx_version;
 
     /**
-     * \name DRI version
      * DRI X extension version information.
-     * \todo Replace these fields with a \c __DRIversionRec.
      */
-    /*@{*/
-    int driMajor;
-    int driMinor;
-    int driPatch;
-    /*@}*/
+    __DRIversion dri_version;
 
     /**
-     * \name DRM version
      * DRM (kernel module) version information.
-     * \todo Replace these fields with a \c __DRIversionRec.
      */
-    /*@{*/
-    int drmMajor;
-    int drmMinor;
-    int drmPatch;
-    /*@}*/
+    __DRIversion drm_version;
 
     /**
      * ID used when the client sets the drawable lock.
@@ -485,12 +486,7 @@ struct __DRIscreenPrivateRec {
      * 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;
+    __DRIcontext dummyContextPriv;
 
     /**
      * Device-dependent private information (not stored in the SAREA).
@@ -499,66 +495,39 @@ struct __DRIscreenPrivateRec {
      */
     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;
-};
 
+    /* Extensions provided by the loader. */
+    const __DRIgetDrawableInfoExtension *getDrawableInfo;
+    const __DRIsystemTimeExtension *systemTime;
+    const __DRIdamageExtension *damage;
 
-/**
- * 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. */
-};
+    struct {
+       /* Flag to indicate that this is a DRI2 screen.  Many of the above
+        * fields will not be valid or initializaed in that case. */
+       int enabled;
+       __DRIdri2LoaderExtension *loader;
+    } dri2;
 
+    /* The lock actually in use, old sarea or DRI2 */
+    drmLock *lock;
+};
 
 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 );
+__driUtilUpdateDrawableInfo(__DRIdrawable *pdp);
 
 extern float
-driCalculateSwapUsage( __DRIdrawablePrivate *dPriv,
+driCalculateSwapUsage( __DRIdrawable *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;
+extern GLint
+driIntersectArea( drm_clip_rect_t rect1, drm_clip_rect_t rect2 );
 
 #endif /* _DRI_UTIL_H_ */
index 65e96657b8aeea652f2daf02a76436905e537657..ea5b9973ddeaf952d4574fd9efd5d516fcb7fa56 100644 (file)
@@ -1077,13 +1077,6 @@ static const char AreTexturesResident_names[] =
     "";
 #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) || defined(need_GL_ATI_separate_stencil)
 static const char StencilOpSeparate_names[] = 
     "iiii\0" /* Parameter signature */
@@ -1763,13 +1756,6 @@ static const char DeleteFencesNV_names[] =
     "";
 #endif
 
-#if defined(need_GL_SGIX_polynomial_ffd)
-static const char DeformationMap3dSGIX_names[] = 
-    "iddiiddiiddiip\0" /* Parameter signature */
-    "glDeformationMap3dSGIX\0"
-    "";
-#endif
-
 #if defined(need_GL_VERSION_2_0)
 static const char IsShader_names[] = 
     "i\0" /* Parameter signature */
@@ -2015,6 +2001,13 @@ static const char WeightfvARB_names[] =
     "";
 #endif
 
+#if defined(need_GL_EXT_framebuffer_object)
+static const char IsRenderbufferEXT_names[] = 
+    "i\0" /* Parameter signature */
+    "glIsRenderbufferEXT\0"
+    "";
+#endif
+
 #if defined(need_GL_MESA_window_pos)
 static const char WindowPos4fMESA_names[] = 
     "ffff\0" /* Parameter signature */
@@ -4530,6 +4523,13 @@ static const char Minmax_names[] =
     "";
 #endif
 
+#if defined(need_GL_SGIX_polynomial_ffd)
+static const char DeformationMap3dSGIX_names[] = 
+    "iddiiddiiddiip\0" /* Parameter signature */
+    "glDeformationMap3dSGIX\0"
+    "";
+#endif
+
 #if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_fog_coord)
 static const char FogCoorddvEXT_names[] = 
     "p\0" /* Parameter signature */
@@ -5319,13 +5319,13 @@ static const struct dri_extension_function GL_EXT_framebuffer_blit_functions[] =
 #if defined(need_GL_EXT_framebuffer_object)
 static const struct dri_extension_function GL_EXT_framebuffer_object_functions[] = {
     { GenerateMipmapEXT_names, GenerateMipmapEXT_remap_index, -1 },
-    { IsRenderbufferEXT_names, IsRenderbufferEXT_remap_index, -1 },
     { RenderbufferStorageEXT_names, RenderbufferStorageEXT_remap_index, -1 },
     { CheckFramebufferStatusEXT_names, CheckFramebufferStatusEXT_remap_index, -1 },
     { DeleteRenderbuffersEXT_names, DeleteRenderbuffersEXT_remap_index, -1 },
     { FramebufferTexture3DEXT_names, FramebufferTexture3DEXT_remap_index, -1 },
     { FramebufferRenderbufferEXT_names, FramebufferRenderbufferEXT_remap_index, -1 },
     { FramebufferTexture1DEXT_names, FramebufferTexture1DEXT_remap_index, -1 },
+    { IsRenderbufferEXT_names, IsRenderbufferEXT_remap_index, -1 },
     { BindFramebufferEXT_names, BindFramebufferEXT_remap_index, -1 },
     { GenRenderbuffersEXT_names, GenRenderbuffersEXT_remap_index, -1 },
     { IsFramebufferEXT_names, IsFramebufferEXT_remap_index, -1 },
@@ -5965,9 +5965,9 @@ static const struct dri_extension_function GL_SGIX_pixel_texture_functions[] = {
 #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 },
+    { DeformationMap3dSGIX_names, DeformationMap3dSGIX_remap_index, -1 },
     { NULL, 0, 0 }
 };
 #endif
index 4952d788e81586ad1738cab1e3780f0be5ac29e7..9cd1d8ec3fa95d7941489180e0f04614574d0109 100644 (file)
@@ -4,7 +4,7 @@
 * 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)
+static INLINE void drimemsetio(void* address, int c, int size)
 {
 #if defined(__powerpc__) || defined(__ia64__)
      int i;
index 891056e1705fa90321cde1753b5a83daa1483306..dc43d1cdc9c58597ddedf6819166fbc68b6c45f8 100644 (file)
@@ -37,7 +37,7 @@
 
 #if defined( __powerpc__ )
 
-static __inline__ uint32_t
+static INLINE uint32_t
 read_MMIO_LE32( volatile void * base, unsigned long offset )
 {
    uint32_t val;
@@ -50,7 +50,7 @@ read_MMIO_LE32( volatile void * base, unsigned long offset )
 
 #else
 
-static __inline__ uint32_t
+static INLINE uint32_t
 read_MMIO_LE32( volatile void * base, unsigned long offset )
 {
    volatile uint32_t * p = (volatile uint32_t *) (((volatile char *) base) + offset);
index 50f3cf558169b081662dddab80b3e6435259b8fd..a1e56eb1484a502cc2c1661b1cc54bd33b8bbf4d 100644 (file)
 #define HW_WRITE_CLIPLOOP()    HW_CLIPLOOP()
 #endif
 
-
 #if (SPANTMP_PIXEL_FMT == GL_RGB)  && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_5_6_5)
 
 /**
  ** GL_RGB, GL_UNSIGNED_SHORT_5_6_5
  **/
 
+#ifndef GET_VALUE
 #ifndef GET_PTR
 #define GET_PTR(_x, _y) (buf + (_x) * 2 + (_y) * pitch)
 #endif
 
+#define GET_VALUE(_x, _y) *(volatile GLushort *)(GET_PTR(_x, _y))
+#define PUT_VALUE(_x, _y, _v) *(volatile GLushort *)(GET_PTR(_x, _y)) = (_v)
+#endif /* GET_VALUE */
+
 #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_PTR(_x, _y);                      \
-       _p[0] = ((((int)r & 0xf8) << 8) | (((int)g & 0xfc) << 3) |      \
-                  (((int)b & 0xf8) >> 3));                             \
-   } while(0)
+   PUT_VALUE(_x, _y, ((((int)r & 0xf8) << 8) |                         \
+                     (((int)g & 0xfc) << 3) |                          \
+                     (((int)b & 0xf8) >> 3)))                          \
 
-#define WRITE_PIXEL( _x, _y, p )                                       \
-   do {                                                                 \
-      GLushort * _p = (GLushort *) GET_PTR(_x, _y);                     \
-      _p[0] = p;                                                        \
-   } while(0)
+#define WRITE_PIXEL( _x, _y, p ) PUT_VALUE(_x, _y, p)
 
 #define READ_RGBA( rgba, _x, _y )                                      \
    do {                                                                        \
-      GLushort p = *(volatile GLshort *) GET_PTR(_x, _y);               \
+      GLushort p = GET_VALUE(_x, _y);                                  \
       rgba[0] = ((p >> 8) & 0xf8) * 255 / 0xf8;                                \
       rgba[1] = ((p >> 3) & 0xfc) * 255 / 0xfc;                                \
       rgba[2] = ((p << 3) & 0xf8) * 255 / 0xf8;                                \
  ** GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV
  **/
 
+#ifndef GET_VALUE
 #ifndef GET_PTR
 #define GET_PTR(_x, _y) (     buf + (_x) * 4 + (_y) * pitch)
 #endif
 
+#define GET_VALUE(_x, _y) *(volatile GLuint *)(GET_PTR(_x, _y))
+#define PUT_VALUE(_x, _y, _v) *(volatile GLuint *)(GET_PTR(_x, _y)) = (_v)
+#endif /* GET_VALUE */
+
 # 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_PTR(_x, _y);                        \
-       _p[0] = ((r << 16) | (g << 8) | (b << 0) | (a << 24));           \
-    } while(0)
+   PUT_VALUE(_x, _y, ((r << 16) |                                      \
+                     (g << 8) |                                        \
+                     (b << 0) |                                        \
+                     (a << 24)))
 
-#define WRITE_PIXEL(_x, _y, p)                                          \
-    do {                                                                \
-       GLuint * _p = (GLuint *) GET_PTR(_x, _y);                        \
-       _p[0] = p;                                                       \
-    } while(0)
+#define WRITE_PIXEL(_x, _y, p) PUT_VALUE(_x, _y, p)
 
 # if defined( USE_X86_ASM )
 #  define READ_RGBA(rgba, _x, _y)                                       \
     do {                                                                \
-        GLuint p = *(volatile GLuint *) GET_PTR(_x, _y);                \
+       GLuint p = GET_VALUE(_x, _y);                                   \
        __asm__ __volatile__( "bswap    %0; rorl $8, %0"                \
-                               : "=r" (p) : "r" (p) );                 \
+                               : "=r" (p) : "0" (p) );                 \
        ((GLuint *)rgba)[0] = p;                                         \
     } while (0)
 # elif defined( MESA_BIG_ENDIAN )
      */
 #  define READ_RGBA( rgba, _x, _y )                                    \
      do {                                                              \
-        GLuint p = *(volatile GLuint *) GET_PTR(_x, _y);                \
+        GLuint p = GET_VALUE(_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_PTR(_x, _y);                \
+        GLuint p = GET_VALUE(_x, _y);                                  \
        rgba[0] = (p >> 16) & 0xff;                                     \
        rgba[1] = (p >>  8) & 0xff;                                     \
        rgba[2] = (p >>  0) & 0xff;                                     \
@@ -389,7 +388,8 @@ static void TAG(ReadRGBASpan)( GLcontext *ctx,
 }
 
 
-#if defined(USE_MMX_ASM) && \
+#if defined(GET_PTR) && \
+   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) && \
@@ -440,7 +440,8 @@ static void TAG2(ReadRGBASpan,_MMX)( GLcontext *ctx,
 #endif
 
 
-#if defined(USE_SSE_ASM) && \
+#if defined(GET_PTR) &&        \
+   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,
@@ -474,7 +475,8 @@ static void TAG2(ReadRGBASpan,_SSE2)( GLcontext *ctx,
 }
 #endif
 
-#if defined(USE_SSE_ASM) && \
+#if defined(GET_PTR) &&        \
+   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,
@@ -567,6 +569,7 @@ static void TAG(InitPointers)(struct gl_renderbuffer *rb)
    rb->PutMonoValues = TAG(WriteMonoRGBAPixels);
    rb->GetValues = TAG(ReadRGBAPixels);
 
+#if defined(GET_PTR)
 #if defined(USE_SSE_ASM) && \
    (SPANTMP_PIXEL_FMT == GL_BGRA) && \
      (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)
@@ -596,6 +599,7 @@ static void TAG(InitPointers)(struct gl_renderbuffer *rb)
    }
    else
 #endif
+#endif /* GET_PTR */
    {
       if (DBG) fprintf( stderr, "Using %s version of GetRow\n", "C" );
       rb->GetRow = TAG(ReadRGBASpan);
@@ -610,6 +614,8 @@ static void TAG(InitPointers)(struct gl_renderbuffer *rb)
 #undef READ_RGBA
 #undef TAG
 #undef TAG2
+#undef GET_VALUE
+#undef PUT_VALUE
 #undef GET_PTR
 #undef SPANTMP_PIXEL_FMT
 #undef SPANTMP_PIXEL_TYPE
index a81cc2413d1c7baadd96a04d525d5bf14e7f6a68..b4af7c96e385845c67fe87bb517cc9a02df62dbe 100644 (file)
@@ -1277,6 +1277,7 @@ driCalculateTextureFirstLastLevel( driTextureObject * t )
       else {
         firstLevel = tObj->BaseLevel + (GLint)(tObj->MinLod + 0.5);
         firstLevel = MAX2(firstLevel, tObj->BaseLevel);
+        firstLevel = MIN2(firstLevel, tObj->BaseLevel + baseImage->MaxLog2);
         lastLevel = tObj->BaseLevel + (GLint)(tObj->MaxLod + 0.5);
         lastLevel = MAX2(lastLevel, t->tObj->BaseLevel);
         lastLevel = MIN2(lastLevel, t->tObj->BaseLevel + baseImage->MaxLog2);
index 67cffead00f69cfb85ce00e9057e1b77e039dede..431c26a19d8bcfd7b5c12f478b312cac39c32ea9 100644 (file)
@@ -421,21 +421,6 @@ driCheckDriDdxDrmVersions2(const char * driver_name,
                                drmActual, drmExpected);
 }
 
-
-
-GLint
-driIntersectArea( drm_clip_rect_t rect1, drm_clip_rect_t rect2 )
-{
-   if (rect2.x1 > rect1.x1) rect1.x1 = rect2.x1;
-   if (rect2.x2 < rect1.x2) rect1.x2 = rect2.x2;
-   if (rect2.y1 > rect1.y1) rect1.y1 = rect2.y1;
-   if (rect2.y2 < rect1.y2) rect1.y2 = rect2.y2;
-
-   if (rect1.x1 > rect1.x2 || rect1.y1 > rect1.y2) return 0;
-
-   return (rect1.x2 - rect1.x1) * (rect1.y2 - rect1.y1);
-}
-
 GLboolean driClipRectToFramebuffer( const GLframebuffer *buffer,
                                    GLint *x, GLint *y,
                                    GLsizei *width, GLsizei *height )
@@ -469,8 +454,6 @@ GLboolean driClipRectToFramebuffer( const GLframebuffer *buffer,
    return GL_TRUE;
 }
 
-
-
 /**
  * Creates a set of \c __GLcontextModes that a driver will expose.
  * 
@@ -541,85 +524,103 @@ GLboolean driClipRectToFramebuffer( const GLframebuffer *buffer,
  * \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 uint8_t * depth_bits, const uint8_t * stencil_bits,
-               unsigned num_depth_stencil_bits,
-               const GLenum * db_modes, unsigned num_db_modes,
-               const u_int8_t * msaa_samples, unsigned num_msaa_modes,
-               int visType )
+
+/* XXX: need to re-add msaa support after gallium-0.1 merge
+ */
+
+__DRIconfig **
+driCreateConfigs(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)
 {
-   static const uint8_t bits_table[3][4] = {
+   static const u_int8_t bits_table[4][4] = {
      /* R  G  B  A */
+      { 3, 3, 2, 0 }, /* Any GL_UNSIGNED_BYTE_3_3_2 */
       { 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 uint32_t masks_table_rgb[8][4] = {
-      { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
-      { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
-      { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+   static const u_int32_t masks_table_rgb[6][4] = {
+      { 0x000000E0, 0x0000001C, 0x00000003, 0x00000000 }, /* 3_3_2       */
+      { 0x00000007, 0x00000038, 0x000000C0, 0x00000000 }, /* 2_3_3_REV   */
       { 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 uint32_t masks_table_rgba[8][4] = {
-      { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
-      { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
-      { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+   static const u_int32_t masks_table_rgba[6][4] = {
+      { 0x000000E0, 0x0000001C, 0x00000003, 0x00000000 }, /* 3_3_2       */
+      { 0x00000007, 0x00000038, 0x000000C0, 0x00000000 }, /* 2_3_3_REV   */
       { 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 uint32_t masks_table_bgr[8][4] = {
-      { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
-      { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
-      { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+   static const u_int32_t masks_table_bgr[6][4] = {
+      { 0x00000007, 0x00000038, 0x000000C0, 0x00000000 }, /* 3_3_2       */
+      { 0x000000E0, 0x0000001C, 0x00000003, 0x00000000 }, /* 2_3_3_REV   */
       { 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 uint32_t masks_table_bgra[8][4] = {
-      { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
-      { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
-      { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+   static const u_int32_t masks_table_bgra[6][4] = {
+      { 0x00000007, 0x00000038, 0x000000C0, 0x00000000 }, /* 3_3_2       */
+      { 0x000000E0, 0x0000001C, 0x00000003, 0x00000000 }, /* 2_3_3_REV   */
       { 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 uint8_t bytes_per_pixel[8] = {
-      0, 0, 0, 2, 2, 4, 0, 4
+   static const u_int8_t bytes_per_pixel[6] = {
+      1, /* 3_3_2       */
+      1, /* 2_3_3_REV   */
+      2, /* 5_6_5       */
+      2, /* 5_6_5_REV   */
+      4, /* 8_8_8_8     */
+      4  /* 8_8_8_8_REV */
    };
 
-   const uint8_t  * bits;
-   const uint32_t * masks;
-   const int index = fb_type & 0x07;
-   __GLcontextModes * modes = *ptr_to_modes;
-   unsigned i, j, k, h;
-
-
-   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;
+   const u_int8_t  * bits;
+   const u_int32_t * masks;
+   int index;
+   __DRIconfig **configs, **c;
+   __GLcontextModes *modes;
+   unsigned i;
+   unsigned j;
+   unsigned k;
+   unsigned num_modes;
+   unsigned num_accum_bits = 2;
+
+   switch ( fb_type ) {
+      case GL_UNSIGNED_BYTE_3_3_2:
+        index = 0;
+        break;
+      case GL_UNSIGNED_BYTE_2_3_3_REV:
+        index = 1;
+        break;
+      case GL_UNSIGNED_SHORT_5_6_5:
+        index = 2;
+        break;
+      case GL_UNSIGNED_SHORT_5_6_5_REV:
+        index = 3;
+        break;
+      case GL_UNSIGNED_INT_8_8_8_8:
+        index = 4;
+        break;
+      case GL_UNSIGNED_INT_8_8_8_8_REV:
+        index = 5;
+        break;
+      default:
+        fprintf( stderr, "[%s:%u] Unknown framebuffer type 0x%04x.\n",
+               __FUNCTION__, __LINE__, fb_type );
+        return NULL;
    }
 
 
@@ -631,90 +632,254 @@ driFillInModes( __GLcontextModes ** ptr_to_modes,
 
    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;
+         fprintf( stderr, "[%s:%u] Unknown framebuffer format 0x%04x.\n",
+               __FUNCTION__, __LINE__, fb_format );
+         return NULL;
    }
 
+   switch ( bytes_per_pixel[ index ] ) {
+      case 1:
+        bits = bits_table[0];
+        break;
+      case 2:
+        bits = bits_table[1];
+        break;
+      default:
+        bits = ((fb_format == GL_RGB) || (fb_format == GL_BGR))
+           ? bits_table[2]
+           : bits_table[3];
+        break;
+   }
+
+   num_modes = num_depth_stencil_bits * num_db_modes * num_accum_bits;
+   configs = _mesa_calloc((num_modes + 1) * sizeof *configs);
+   if (configs == NULL)
+       return NULL;
 
+    c = configs;
     for ( k = 0 ; k < num_depth_stencil_bits ; k++ ) {
        for ( i = 0 ; i < num_db_modes ; i++ ) {
-           for ( h = 0 ; h < num_msaa_modes; h++ ) {
-               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->samples = msaa_samples[h];
-                   modes->sampleBuffers = modes->samples ? 1 : 0;
-
-                   modes->haveAccumBuffer = ((modes->accumRedBits +
-                                              modes->accumGreenBits +
-                                              modes->accumBlueBits +
-                                              modes->accumAlphaBits) > 0);
-                   modes->haveDepthBuffer = (modes->depthBits > 0);
-                   modes->haveStencilBuffer = (modes->stencilBits > 0);
-
-                   modes = modes->next;
+           for ( j = 0 ; j < num_accum_bits ; j++ ) {
+               *c = _mesa_malloc (sizeof **c);
+               modes = &(*c)->modes;
+               c++;
+
+               memset(modes, 0, sizeof *modes);
+               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->transparentPixel = GLX_NONE;
+               modes->transparentRed = GLX_DONT_CARE;
+               modes->transparentGreen = GLX_DONT_CARE;
+               modes->transparentBlue = GLX_DONT_CARE;
+               modes->transparentAlpha = GLX_DONT_CARE;
+               modes->transparentIndex = GLX_DONT_CARE;
+               modes->visualType = GLX_DONT_CARE;
+               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->bindToTextureRgb = GL_TRUE;
+               modes->bindToTextureRgba = GL_TRUE;
+               modes->bindToMipmapTexture = GL_FALSE;
+               modes->bindToTextureTargets = modes->rgbMode ?
+                   __DRI_ATTRIB_TEXTURE_1D_BIT |
+                   __DRI_ATTRIB_TEXTURE_2D_BIT |
+                   __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT :
+                   0;
            }
        }
     }
+    *c = NULL;
+
+    return configs;
+}
+
+const __DRIconfig **driConcatConfigs(__DRIconfig **a, __DRIconfig **b)
+{
+    const __DRIconfig **all;
+    int i, j, index;
+
+    i = 0;
+    while (a[i] != NULL)
+       i++;
+    j = 0;
+    while (b[j] != NULL)
+       j++;
+   
+    all = _mesa_malloc((i + j + 1) * sizeof *all);
+    index = 0;
+    for (i = 0; a[i] != NULL; i++)
+       all[index++] = a[i];
+    for (j = 0; b[j] != NULL; j++)
+       all[index++] = b[j];
+    all[index++] = NULL;
+
+    _mesa_free(a);
+    _mesa_free(b);
+
+    return all;
+}
+
+#define __ATTRIB(attrib, field) \
+    { attrib, offsetof(__GLcontextModes, field) }
+
+static const struct { unsigned int attrib, offset; } attribMap[] = {
+    __ATTRIB(__DRI_ATTRIB_BUFFER_SIZE,                 rgbBits),
+    __ATTRIB(__DRI_ATTRIB_LEVEL,                       level),
+    __ATTRIB(__DRI_ATTRIB_RED_SIZE,                    redBits),
+    __ATTRIB(__DRI_ATTRIB_GREEN_SIZE,                  greenBits),
+    __ATTRIB(__DRI_ATTRIB_BLUE_SIZE,                   blueBits),
+    __ATTRIB(__DRI_ATTRIB_ALPHA_SIZE,                  alphaBits),
+    __ATTRIB(__DRI_ATTRIB_DEPTH_SIZE,                  depthBits),
+    __ATTRIB(__DRI_ATTRIB_STENCIL_SIZE,                        stencilBits),
+    __ATTRIB(__DRI_ATTRIB_ACCUM_RED_SIZE,              accumRedBits),
+    __ATTRIB(__DRI_ATTRIB_ACCUM_GREEN_SIZE,            accumGreenBits),
+    __ATTRIB(__DRI_ATTRIB_ACCUM_BLUE_SIZE,             accumBlueBits),
+    __ATTRIB(__DRI_ATTRIB_ACCUM_ALPHA_SIZE,            accumAlphaBits),
+    __ATTRIB(__DRI_ATTRIB_SAMPLE_BUFFERS,              sampleBuffers),
+    __ATTRIB(__DRI_ATTRIB_SAMPLES,                     samples),
+    __ATTRIB(__DRI_ATTRIB_DOUBLE_BUFFER,               doubleBufferMode),
+    __ATTRIB(__DRI_ATTRIB_STEREO,                      stereoMode),
+    __ATTRIB(__DRI_ATTRIB_AUX_BUFFERS,                 numAuxBuffers),
+    __ATTRIB(__DRI_ATTRIB_TRANSPARENT_TYPE,            transparentPixel),
+    __ATTRIB(__DRI_ATTRIB_TRANSPARENT_INDEX_VALUE,     transparentPixel),
+    __ATTRIB(__DRI_ATTRIB_TRANSPARENT_RED_VALUE,       transparentRed),
+    __ATTRIB(__DRI_ATTRIB_TRANSPARENT_GREEN_VALUE,     transparentGreen),
+    __ATTRIB(__DRI_ATTRIB_TRANSPARENT_BLUE_VALUE,      transparentBlue),
+    __ATTRIB(__DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE,     transparentAlpha),
+    __ATTRIB(__DRI_ATTRIB_FLOAT_MODE,                  floatMode),
+    __ATTRIB(__DRI_ATTRIB_RED_MASK,                    redMask),
+    __ATTRIB(__DRI_ATTRIB_GREEN_MASK,                  greenMask),
+    __ATTRIB(__DRI_ATTRIB_BLUE_MASK,                   blueMask),
+    __ATTRIB(__DRI_ATTRIB_ALPHA_MASK,                  alphaMask),
+    __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_WIDTH,           maxPbufferWidth),
+    __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_HEIGHT,          maxPbufferHeight),
+    __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_PIXELS,          maxPbufferPixels),
+    __ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH,       optimalPbufferWidth),
+    __ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT,      optimalPbufferHeight),
+    __ATTRIB(__DRI_ATTRIB_SWAP_METHOD,                 swapMethod),
+    __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGB,         bindToTextureRgb),
+    __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGBA,                bindToTextureRgba),
+    __ATTRIB(__DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE,      bindToMipmapTexture),
+    __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS,     bindToTextureTargets),
+    __ATTRIB(__DRI_ATTRIB_YINVERTED,                   yInverted),
+
+    /* The struct field doesn't matter here, these are handled by the
+     * switch in driGetConfigAttribIndex.  We need them in the array
+     * so the iterator includes them though.*/
+    __ATTRIB(__DRI_ATTRIB_RENDER_TYPE,                 level),
+    __ATTRIB(__DRI_ATTRIB_CONFIG_CAVEAT,               level),
+    __ATTRIB(__DRI_ATTRIB_SWAP_METHOD,                 level)
+};
+
+#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
+
+static int
+driGetConfigAttribIndex(const __DRIconfig *config,
+                       unsigned int index, unsigned int *value)
+{
+    switch (attribMap[index].attrib) {
+    case __DRI_ATTRIB_RENDER_TYPE:
+       if (config->modes.rgbMode)
+           *value = __DRI_ATTRIB_RGBA_BIT;
+       else
+           *value = __DRI_ATTRIB_COLOR_INDEX_BIT;
+       break;
+    case __DRI_ATTRIB_CONFIG_CAVEAT:
+       if (config->modes.visualRating == GLX_NON_CONFORMANT_CONFIG)
+           *value = __DRI_ATTRIB_NON_CONFORMANT_CONFIG;
+       else if (config->modes.visualRating == GLX_SLOW_CONFIG)
+           *value = __DRI_ATTRIB_SLOW_BIT;
+       else
+           *value = 0;
+       break;
+    case __DRI_ATTRIB_SWAP_METHOD:
+       break;
+
+    case __DRI_ATTRIB_FLOAT_MODE:
+        *value = config->modes.floatMode;
+        break;
+
+    default:
+       *value = *(unsigned int *)
+           ((char *) &config->modes + attribMap[index].offset);
+       
+       break;
+    }
 
-    *ptr_to_modes = modes;
     return GL_TRUE;
 }
+
+int
+driGetConfigAttrib(const __DRIconfig *config,
+                  unsigned int attrib, unsigned int *value)
+{
+    int i;
+
+    for (i = 0; i < ARRAY_SIZE(attribMap); i++)
+       if (attribMap[i].attrib == attrib)
+           return driGetConfigAttribIndex(config, i, value);
+
+    return GL_FALSE;
+}
+
+int
+driIndexConfigAttrib(const __DRIconfig *config, int index,
+                    unsigned int *attrib, unsigned int *value)
+{
+    if (index >= 0 && index < ARRAY_SIZE(attribMap)) {
+       *attrib = attribMap[index].attrib;
+       return driGetConfigAttribIndex(config, index, value);
+    }
+
+    return GL_FALSE;
+}
index 20940c21b4ece4b85a59c8c9f174b5e336163fb2..9ac3b51447d05fdbd7a6923db89e25f5431887e3 100644 (file)
 #ifndef DRI_DEBUG_H
 #define DRI_DEBUG_H
 
+#include <GL/gl.h>
+#include <GL/internal/dri_interface.h>
 #include "context.h"
-#include "dri_util.h"
+
+typedef struct __DRIutilversionRec2    __DRIutilversion2;
 
 struct dri_debug_control {
     const char * string;
@@ -83,6 +86,17 @@ struct dri_extension {
     const struct dri_extension_function * functions;
 };
 
+/**
+ * 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 unsigned driParseDebugString( const char * debug,
     const struct dri_debug_control * control );
 
@@ -105,17 +119,27 @@ extern GLboolean driCheckDriDdxDrmVersions3(const char * driver_name,
     const __DRIversion * ddxActual, const __DRIutilversion2 * ddxExpected,
     const __DRIversion * drmActual, const __DRIversion * drmExpected);
 
-extern GLint driIntersectArea( drm_clip_rect_t rect1, drm_clip_rect_t rect2 );
-
 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 uint8_t * depth_bits, const uint8_t * stencil_bits,
-    unsigned num_depth_stencil_bits,
-    const GLenum * db_modes, unsigned num_db_modes,
-    const u_int8_t * msaa_samples, unsigned num_msaa_modes, int visType );
+struct __DRIconfigRec {
+    __GLcontextModes modes;
+};
+
+extern __DRIconfig **
+driCreateConfigs(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);
+
+const __DRIconfig **driConcatConfigs(__DRIconfig **a, __DRIconfig **b);
+
+int
+driGetConfigAttrib(const __DRIconfig *config,
+                  unsigned int attrib, unsigned int *value);
+int
+driIndexConfigAttrib(const __DRIconfig *config, int index,
+                    unsigned int *attrib, unsigned int *value);
 
 #endif /* DRI_DEBUG_H */
index 094950d36268a6e2821f3bae854591a02f3fd195..0008ab1c34acfa9c11e03524a3868cc5948bd130 100644 (file)
 #include "vblank.h"
 #include "xmlpool.h"
 
+static unsigned int msc_to_vblank(__DRIdrawablePrivate * dPriv, int64_t msc)
+{
+   return (unsigned int)(msc - dPriv->msc_base + dPriv->vblank_base);
+}
+
+static int64_t vblank_to_msc(__DRIdrawablePrivate * dPriv, unsigned int vblank)
+{
+   return (int64_t)(vblank - dPriv->vblank_base + dPriv->msc_base);
+}
+
 
 /****************************************************************************/
 /**
@@ -41,7 +51,7 @@
  *
  * 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.
+ * may, it will never decrease for a given drawable.
  *
  * \warning This function is called from \c glXGetVideoSyncSGI, which expects
  * a \c count of type \c unsigned (32-bit), and \c glXGetSyncValuesOML, which 
  * currently always returns a \c sequence of type \c unsigned.
  *
  * \param priv   Pointer to the DRI screen private struct.
+ * \param dPriv  Pointer to the DRI drawable 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 )
+int driDrawableGetMSC32( __DRIscreenPrivate * priv,
+                        __DRIdrawablePrivate * dPriv,
+                        int64_t * count)
 {
    drmVBlank vbl;
    int ret;
@@ -62,14 +75,21 @@ int driGetMSC32( __DRIscreenPrivate * priv, int64_t * count )
 
    vbl.request.type = DRM_VBLANK_RELATIVE;
    vbl.request.sequence = 0;
+   if ( dPriv && dPriv->vblFlags & VBLANK_FLAG_SECONDARY )
+      vbl.request.type |= DRM_VBLANK_SECONDARY;
 
    ret = drmWaitVBlank( priv->fd, &vbl );
-   *count = (int64_t)vbl.reply.sequence;
+
+   if (dPriv) {
+      *count = vblank_to_msc(dPriv, vbl.reply.sequence);
+   } else {
+      /* Old driver (no knowledge of drawable MSC callback) */
+      *count = vbl.reply.sequence;
+   }
 
    return ret;
 }
 
-
 /****************************************************************************/
 /**
  * Wait for a specified refresh count.  This implements most of the
@@ -122,7 +142,9 @@ int driWaitForMSC32( __DRIdrawablePrivate *priv,
           */
          vbl.request.type = dont_wait ? DRM_VBLANK_RELATIVE :
                                         DRM_VBLANK_ABSOLUTE;
-         vbl.request.sequence = next;
+         vbl.request.sequence = next ? msc_to_vblank(priv, next) : 0;
+        if ( priv->vblFlags & VBLANK_FLAG_SECONDARY )
+           vbl.request.type |= DRM_VBLANK_SECONDARY;
 
         if ( drmWaitVBlank( priv->driScreenPriv->fd, &vbl ) != 0 ) {
            /* FIXME: This doesn't seem like the right thing to return here.
@@ -130,8 +152,10 @@ int driWaitForMSC32( __DRIdrawablePrivate *priv,
            return GLX_BAD_CONTEXT;
         }
 
+        *msc = vblank_to_msc(priv, vbl.reply.sequence);
+
          dont_wait = 0;
-         if (target_msc != 0 && vbl.reply.sequence == target)
+         if (target_msc != 0 && *msc == target)
             break;
 
          /* Assuming the wait-done test fails, the next refresh to wait for
@@ -141,9 +165,9 @@ int driWaitForMSC32( __DRIdrawablePrivate *priv,
           * 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;
+         r = (*msc % (unsigned int)divisor);
+         next = (*msc - r + (unsigned int)remainder);
+         if (next <= *msc) next += (unsigned int)divisor;
 
       } while ( r != (unsigned int)remainder );
    }
@@ -153,7 +177,10 @@ int driWaitForMSC32( __DRIdrawablePrivate *priv,
        */
 
       vbl.request.type = DRM_VBLANK_ABSOLUTE;
-      vbl.request.sequence = target_msc;
+      vbl.request.sequence = target_msc ? msc_to_vblank(priv, target_msc) : 0;
+
+      if ( priv->vblFlags & VBLANK_FLAG_SECONDARY )
+        vbl.request.type |= DRM_VBLANK_SECONDARY;
 
       if ( drmWaitVBlank( priv->driScreenPriv->fd, &vbl ) != 0 ) {
         /* FIXME: This doesn't seem like the right thing to return here.
@@ -162,8 +189,8 @@ int driWaitForMSC32( __DRIdrawablePrivate *priv,
       }
    }
 
-   *msc  = (target_msc & 0xffffffff00000000LL);
-   *msc |= vbl.reply.sequence;
+   *msc = vblank_to_msc(priv, vbl.reply.sequence);
+
    if ( *msc < target_msc ) {
       *msc += 0x0000000100000000LL;
    }
@@ -232,8 +259,8 @@ static int do_wait( drmVBlank * vbl, GLuint * vbl_seq, int fd )
       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);
+                " working correctly.\nTry adjusting the vblank_mode"
+                " configuration parameter.\n", __FUNCTION__, ret);
         first_time = GL_FALSE;
       }
 
@@ -245,22 +272,44 @@ static int do_wait( drmVBlank * vbl, GLuint * vbl_seq, int fd )
 }
 
 
+/****************************************************************************/
+/**
+ * Returns the default swap interval of the given drawable.
+ */
+
+static unsigned
+driGetDefaultVBlankInterval( const  __DRIdrawablePrivate *priv )
+{
+   if ( (priv->vblFlags & (VBLANK_FLAG_THROTTLE | VBLANK_FLAG_SYNC)) != 0 ) {
+      return 1;
+   }
+   else {
+      return 0;
+   }
+}
+
+
 /****************************************************************************/
 /**
  * Sets the default swap interval when the drawable is first bound to a
  * direct rendering context.
  */
 
-void driDrawableInitVBlank( __DRIdrawablePrivate *priv, GLuint flags,
-                           GLuint *vbl_seq )
+void driDrawableInitVBlank( __DRIdrawablePrivate *priv )
 {
-   if ( priv->pdraw->swap_interval == (unsigned)-1 ) {
+   if ( priv->swap_interval == (unsigned)-1 &&
+       !( priv->vblFlags & VBLANK_FLAG_NO_IRQ ) ) {
       /* Get current vertical blank sequence */
-      drmVBlank vbl = { .request={ .type = DRM_VBLANK_RELATIVE, .sequence = 0 } };
-      do_wait( &vbl, vbl_seq, priv->driScreenPriv->fd );
-
-      priv->pdraw->swap_interval = (flags & (VBLANK_FLAG_THROTTLE |
-                                            VBLANK_FLAG_SYNC)) != 0 ? 1 : 0;
+      drmVBlank vbl;
+      vbl.request.type = DRM_VBLANK_RELATIVE;
+      if ( priv->vblFlags & VBLANK_FLAG_SECONDARY )
+        vbl.request.type |= DRM_VBLANK_SECONDARY;
+      vbl.request.sequence = 0;
+      do_wait( &vbl, &priv->vblSeq, priv->driScreenPriv->fd );
+      priv->vblank_base = priv->vblSeq;
+
+      priv->swap_interval = driGetDefaultVBlankInterval( priv );
    }
 }
 
@@ -271,21 +320,17 @@ void driDrawableInitVBlank( __DRIdrawablePrivate *priv, GLuint flags,
  */
 
 unsigned
-driGetVBlankInterval( const  __DRIdrawablePrivate *priv, GLuint flags )
+driGetVBlankInterval( const  __DRIdrawablePrivate *priv )
 {
-   if ( (flags & VBLANK_FLAG_INTERVAL) != 0 ) {
+   if ( (priv->vblFlags & VBLANK_FLAG_INTERVAL) != 0 ) {
       /* this must have been initialized when the drawable was first bound
        * to a direct rendering context. */
-      assert ( priv->pdraw->swap_interval != (unsigned)-1 );
+      assert ( priv->swap_interval != (unsigned)-1 );
 
-      return priv->pdraw->swap_interval;
-   }
-   else if ( (flags & (VBLANK_FLAG_THROTTLE | VBLANK_FLAG_SYNC)) != 0 ) {
-      return 1;
-   }
-   else {
-      return 0;
+      return priv->swap_interval;
    }
+   else 
+      return driGetDefaultVBlankInterval( priv );
 }
 
 
@@ -295,18 +340,17 @@ driGetVBlankInterval( const  __DRIdrawablePrivate *priv, GLuint flags )
  */
 
 void
-driGetCurrentVBlank( const  __DRIdrawablePrivate *priv, GLuint flags,
-                    GLuint *vbl_seq )
+driGetCurrentVBlank( __DRIdrawablePrivate *priv )
 {
    drmVBlank vbl;
 
    vbl.request.type = DRM_VBLANK_RELATIVE;
-   if ( flags & VBLANK_FLAG_SECONDARY ) {
+   if ( priv->vblFlags & VBLANK_FLAG_SECONDARY ) {
       vbl.request.type |= DRM_VBLANK_SECONDARY;
    }
    vbl.request.sequence = 0;
 
-   (void) do_wait( &vbl, vbl_seq, priv->driScreenPriv->fd );
+   (void) do_wait( &vbl, &priv->vblSeq, priv->driScreenPriv->fd );
 }
 
 
@@ -314,19 +358,15 @@ driGetCurrentVBlank( const  __DRIdrawablePrivate *priv, GLuint flags,
 /**
  * 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.
+ *                 than the "target" based on \c priv->vblFlags.  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 )
+driWaitForVBlank( __DRIdrawablePrivate *priv, GLboolean * missed_deadline )
 {
    drmVBlank vbl;
    unsigned   original_seq;
@@ -335,10 +375,10 @@ driWaitForVBlank( const  __DRIdrawablePrivate *priv, GLuint * vbl_seq,
    unsigned   diff;
 
    *missed_deadline = GL_FALSE;
-   if ( (flags & (VBLANK_FLAG_INTERVAL |
-                 VBLANK_FLAG_THROTTLE |
-                 VBLANK_FLAG_SYNC)) == 0 ||
-       (flags & VBLANK_FLAG_NO_IRQ) != 0 ) {
+   if ( (priv->vblFlags & (VBLANK_FLAG_INTERVAL |
+                          VBLANK_FLAG_THROTTLE |
+                          VBLANK_FLAG_SYNC)) == 0 ||
+       (priv->vblFlags & VBLANK_FLAG_NO_IRQ) != 0 ) {
       return 0;
    }
 
@@ -349,44 +389,45 @@ driWaitForVBlank( const  __DRIdrawablePrivate *priv, GLuint * vbl_seq,
     *
     * 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
+    * priv->vblSeq, we have to save the original value of priv->vblSeq for the
     * VBLANK_FLAG_INTERVAL / VBLANK_FLAG_THROTTLE calculation later.
     */
 
-   original_seq = *vbl_seq;
-   interval = driGetVBlankInterval(priv, flags);
+   original_seq = priv->vblSeq;
+   interval = driGetVBlankInterval(priv);
    deadline = original_seq + interval;
 
    vbl.request.type = DRM_VBLANK_RELATIVE;
-   if ( flags & VBLANK_FLAG_SECONDARY ) {
+   if ( priv->vblFlags & VBLANK_FLAG_SECONDARY ) {
       vbl.request.type |= DRM_VBLANK_SECONDARY;
    }
-   vbl.request.sequence = ((flags & VBLANK_FLAG_SYNC) != 0) ? 1 : 0;
+   vbl.request.sequence = ((priv->vblFlags & VBLANK_FLAG_SYNC) != 0) ? 1 : 0;
 
-   if ( do_wait( & vbl, vbl_seq, priv->driScreenPriv->fd ) != 0 ) {
+   if ( do_wait( & vbl, &priv->vblSeq, priv->driScreenPriv->fd ) != 0 ) {
       return -1;
    }
 
-   diff = *vbl_seq - deadline;
+   diff = priv->vblSeq - deadline;
 
    /* No need to wait again if we've already reached the target */
    if (diff <= (1 << 23)) {
-      *missed_deadline = (flags & VBLANK_FLAG_SYNC) ? (diff > 0) : GL_TRUE;
+      *missed_deadline = (priv->vblFlags & VBLANK_FLAG_SYNC) ? (diff > 0) :
+                        GL_TRUE;
       return 0;
    }
 
    /* Wait until the target vertical blank. */
    vbl.request.type = DRM_VBLANK_ABSOLUTE;
-   if ( flags & VBLANK_FLAG_SECONDARY ) {
+   if ( priv->vblFlags & VBLANK_FLAG_SECONDARY ) {
       vbl.request.type |= DRM_VBLANK_SECONDARY;
    }
    vbl.request.sequence = deadline;
 
-   if ( do_wait( & vbl, vbl_seq, priv->driScreenPriv->fd ) != 0 ) {
+   if ( do_wait( & vbl, &priv->vblSeq, priv->driScreenPriv->fd ) != 0 ) {
       return -1;
    }
 
-   diff = *vbl_seq - deadline;
+   diff = priv->vblSeq - deadline;
    *missed_deadline = diff > 0 && diff <= (1 << 23);
 
    return 0;
index 52c1933ca5b80abd772b76bacd44a00c78605676..b3a0dadab19799db5f937f5607a42c51db05408c 100644 (file)
                                          */
 
 extern int driGetMSC32( __DRIscreenPrivate * priv, int64_t * count );
+extern int driDrawableGetMSC32( __DRIscreenPrivate * priv,
+                               __DRIdrawablePrivate * drawablePrivate,
+                               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,
-                                   GLuint *vbl_seq );
-extern unsigned driGetVBlankInterval( const  __DRIdrawablePrivate *priv,
-                                     GLuint flags );
-extern void driGetCurrentVBlank( const  __DRIdrawablePrivate *priv,
-                                GLuint flags, GLuint *vbl_seq );
-extern int driWaitForVBlank( const __DRIdrawablePrivate *priv,
-    GLuint * vbl_seq, GLuint flags, GLboolean * missed_deadline );
+extern void driDrawableInitVBlank ( __DRIdrawablePrivate *priv );
+extern unsigned driGetVBlankInterval( const  __DRIdrawablePrivate *priv );
+extern void driGetCurrentVBlank( __DRIdrawablePrivate *priv );
+extern int driWaitForVBlank( __DRIdrawablePrivate *priv,
+                            GLboolean * missed_deadline );
 
 #undef usleep
 #include <unistd.h>  /* for usleep() */
index b635894fe53858bb0064a22c0f808924394cf56e..f6ae75520c508b51e195adc644daadecd32a19cd 100644 (file)
@@ -63,6 +63,12 @@ extern char *program_invocation_name, *program_invocation_short_name;
 #elif defined(__NetBSD__) && defined(__NetBSD_Version) && (__NetBSD_Version >= 106000100)
 #    include <stdlib.h>
 #    define GET_PROGRAM_NAME() getprogname()
+#elif defined(__sun)
+/* Solaris has getexecname() which returns the full path - return just
+   the basename to match BSD getprogname() */
+#    include <stdlib.h>
+#    include <libgen.h>
+#    define GET_PROGRAM_NAME() basename(getexecname())
 #endif
 
 #if !defined(GET_PROGRAM_NAME)
@@ -279,7 +285,7 @@ static GLfloat strToF (const XML_Char *string, const XML_Char **tail) {
 /** \brief Parse a value of a given type. */
 static GLboolean parseValue (driOptionValue *v, driOptionType type,
                             const XML_Char *string) {
-    const XML_Char *tail;
+    const XML_Char *tail = NULL;
   /* skip leading white-space */
     string += strspn (string, " \f\n\r\t\v");
     switch (type) {
@@ -403,40 +409,40 @@ static GLboolean checkValue (const driOptionValue *v, const driOptionInfo *info)
 /** \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)); \
+                      (int) XML_GetCurrentLineNumber(data->parser), \
+                      (int) 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), \
+                      (int) XML_GetCurrentLineNumber(data->parser), \
+                      (int) 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)); \
+                      (int) XML_GetCurrentLineNumber(data->parser), \
+                      (int) 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), \
+                      (int) XML_GetCurrentLineNumber(data->parser), \
+                      (int) 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)); \
+             (int) XML_GetCurrentLineNumber(data->parser),     \
+             (int) 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), \
+             (int) XML_GetCurrentLineNumber(data->parser),     \
+             (int) XML_GetCurrentColumnNumber(data->parser),           \
              args); \
     abort();\
 } while (0)
index b077809cd1860431810fd781f2d15eb107c28199..62ec919ea68c3e7113c327f208fa4032e7d6b80b 100644 (file)
@@ -57,8 +57,8 @@ 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)
+       -rm -f $(POT) *~
+       -rm -rf $(LANGS)
 
 # Default target options.h
 options.h: t_options.h mo
diff --git a/src/mesa/drivers/dri/dri.pc.in b/src/mesa/drivers/dri/dri.pc.in
new file mode 100644 (file)
index 0000000..c47ee9c
--- /dev/null
@@ -0,0 +1,10 @@
+prefix=@INSTALL_DIR@
+exec_prefix=${prefix}
+libdir=@INSTALL_LIB_DIR@
+includedir=@INSTALL_INC_DIR@
+dridriverdir=@DRI_DRIVER_DIR@
+
+Name: dri
+Description: Direct Rendering Infrastructure
+Version: @VERSION@
+Cflags: -I${includedir}
index 523a0c0380f90af97bff7594af72daacd46c0ad3..d3a936dd341884bf5a734c1399b2240d44adbba2 100644 (file)
@@ -657,8 +657,9 @@ struct DRIDriverRec __driDriver = {
 };
 
 static __GLcontextModes *
-fbFillInModes( unsigned pixel_bits, unsigned depth_bits,
-                 unsigned stencil_bits, GLboolean have_back_buffer )
+fbFillInModes( __DRIscreenPrivate *psp,
+              unsigned pixel_bits, unsigned depth_bits,
+              unsigned stencil_bits, GLboolean have_back_buffer )
 {
    __GLcontextModes * modes;
    __GLcontextModes * m;
@@ -705,7 +706,7 @@ fbFillInModes( unsigned pixel_bits, unsigned depth_bits,
       fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
    }
 
-   modes = (*dri_interface->createContextModes)( num_modes, sizeof( __GLcontextModes ) );
+   modes = (*psp->contextModes->createContextModes)( num_modes, sizeof( __GLcontextModes ) );
    m = modes;
    if ( ! driFillInModes( & m, fb_format, fb_type,
           depth_bits_array, stencil_bits_array, depth_buffer_factor,
@@ -776,7 +777,7 @@ void * __driCreateNewScreen( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc
                                          frame_buffer, pSAREA, fd,
                                          internal_api_version, &fbAPI);
           if ( psp != NULL ) {
-            *driver_modes = fbFillInModes( psp->fbBPP,
+            *driver_modes = fbFillInModes( psp, psp->fbBPP,
                                            (psp->fbBPP == 16) ? 16 : 24,
                                            (psp->fbBPP == 16) ? 0  : 8,
                                            1);
index 7de05b5cf0ca9fdf9e872070420357e26f77d2b0..1040f4263496c2664965c42cf8291be49d986956 100644 (file)
@@ -79,7 +79,7 @@ struct ff_fixups {
 /* Compute fixups of non-page aligned areas after a page fill.
  * Return the number of fixups needed.
  */
-static __inline__ int
+static INLINE int
 CreatorComputePageFillFixups(struct ff_fixups *fixups,
                             int x, int y, int w, int h,
                             int paligned_x, int paligned_y,
index e9d8260e1aab96048d8fc710978e982526349ffd..10e1375259b50ddf0ee6c90038f4ccd59d4dda76 100644 (file)
@@ -1,5 +1,5 @@
 
-static __inline void TAG(ffb_line)(GLcontext *ctx, ffb_vertex *v0, 
+static INLINE void TAG(ffb_line)(GLcontext *ctx, ffb_vertex *v0, 
                                   ffb_vertex *v1 )
 {
        ffbContextPtr fmesa = FFB_CONTEXT(ctx);
index 2c91426b3a218b566e09e950f1b9ce2e1debf78c..3003de70c69a187a172bf611bed2cc1bc46a50b1 100644 (file)
@@ -1,5 +1,5 @@
 
-static __inline void TAG(ffb_draw_point)(GLcontext *ctx, ffb_vertex *tmp )
+static INLINE void TAG(ffb_draw_point)(GLcontext *ctx, ffb_vertex *tmp )
 {
        ffbContextPtr fmesa = FFB_CONTEXT(ctx);
        ffb_fbcPtr ffb = fmesa->regs;
index 8b60f095c96cbeee0d2c0a676bfff6afb78629e0..1f9fecdcf786245dbd89da1cd20b90ec2bae2080 100644 (file)
 
 #include "ffb_vtxfmt.h"
 
-#ifndef __GNUC__
-#define __inline  /**/
-#endif
-
 #define TNL_VERTEX                     ffbTnlVertex
 
 #define INTERP_RGBA(t, out, a, b)              \
@@ -60,7 +56,7 @@ do {                                          \
 
 /* Color functions: */
 
-static __inline void ffb_recalc_base_color(GLcontext *ctx)
+static INLINE void ffb_recalc_base_color(GLcontext *ctx)
 {
        ffbContextPtr fmesa = FFB_CONTEXT(ctx);
        struct gl_light *light;
index a31cd57e882851c71495a4aac440a9392055e1e5..3b7aa45903c5439f31b59747cc027bb733950242 100644 (file)
@@ -604,35 +604,18 @@ void ffbXMesaUpdateState(ffbContextPtr fmesa)
        }
 }
 
-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 )
+static const __DRIconfig **
+ffbFillInModes( __DRIscreenPrivate *psp,
+               unsigned pixel_bits, unsigned depth_bits,
+               unsigned stencil_bits, GLboolean have_back_buffer )
 {
-   __GLcontextModes * modes;
-   __GLcontextModes * m;
-   unsigned num_modes;
+   __DRIconfig **configs;
+   __GLcontextModes *m;
    unsigned depth_buffer_factor;
    unsigned back_buffer_factor;
    GLenum fb_format;
    GLenum fb_type;
+   int i;
 
    /* GLX_SWAP_COPY_OML is only supported because the FFB driver doesn't
     * support pageflipping at all.
@@ -644,7 +627,6 @@ ffbFillInModes( unsigned pixel_bits, unsigned depth_bits,
    uint8_t depth_bits_array[3];
    uint8_t stencil_bits_array[3];
 
-
    depth_bits_array[0] = 0;
    depth_bits_array[1] = depth_bits;
    depth_bits_array[2] = depth_bits;
@@ -660,8 +642,6 @@ ffbFillInModes( unsigned pixel_bits, unsigned depth_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;
@@ -671,82 +651,68 @@ ffbFillInModes( unsigned pixel_bits, unsigned depth_bits,
         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;
+   configs = driCreateConfigs(fb_format, fb_type,
+                             depth_bits_array, stencil_bits_array,
+                             depth_buffer_factor, back_buffer_modes,
+                             back_buffer_factor);
+   if (configs == NULL) {
+    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;
+   for (i = 0; configs[i]; i++) {
+      m = &configs[i]->modes;
+      if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
+         m->visualRating = GLX_SLOW_CONFIG;
       }
    }
 
-   return modes;
+   return (const __DRIconfig **) configs;
 }
 
 
 /**
- * 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.
+ * This is the driver specific part of the createNewScreen entry point.
  * 
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on 
- *         failure.
+ * \todo maybe fold this into intelInitDriver
+ *
+ * \return the __GLcontextModes supported by this driver
  */
-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 )
-                            
+static const __DRIconfig **
+ffbInitScreen(__DRIscreen *psp)
 {
-   __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 ) ) {
+                                     &psp->dri_version, & dri_expected,
+                                     &psp->ddx_version, & ddx_expected,
+                                     &psp->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 );
-   }
+   if (!ffbInitDriver(psp))
+       return NULL;
 
-   return (void *) psp;
+   return ffbFillInModes( psp, 32, 16, 0, GL_TRUE );
 }
+
+const struct __DriverAPIRec driDriverAPI = {
+   .InitScreen      = ffbInitScreen,
+   .DestroyScreen   = ffbDestroyScreen,
+   .CreateContext   = ffbCreateContext,
+   .DestroyContext  = ffbDestroyContext,
+   .CreateBuffer    = ffbCreateBuffer,
+   .DestroyBuffer   = ffbDestroyBuffer,
+   .SwapBuffers     = ffbSwapBuffers,
+   .MakeCurrent     = ffbMakeCurrent,
+   .UnbindContext   = ffbUnbindContext,
+   .GetSwapInfo     = NULL,
+   .GetDrawableMSC  = NULL,
+   .WaitForMSC      = NULL,
+   .WaitForSBC      = NULL,
+   .SwapBuffersMSC  = NULL
+};
index 86af674ae75f031204353742394e388dcb864722..5f4ceb2439c8acd09b9eda8ab3ca9ef0d663ecca 100644 (file)
@@ -383,7 +383,7 @@ struct gamma_context {
     int                 TextureCount;
 };
 
-static __inline GLuint gammaPackColor( GLuint cpp,
+static INLINE GLuint gammaPackColor( GLuint cpp,
                                        GLubyte r, GLubyte g,
                                        GLubyte b, GLubyte a )
 {
index 9180ef925d0aa4c2c496ba701adf478c3977177f..211d7787ef7a023cd8655e6a1aac1d3d0aa4cf90 100644 (file)
@@ -129,13 +129,13 @@ static const GLuint hw_prim[GL_POLYGON+1] = {
    B_PrimType_Polygon
 };
 
-static __inline void gammaStartPrimitive( gammaContextPtr gmesa, GLenum prim )
+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 )
+static INLINE void gammaEndPrimitive( gammaContextPtr gmesa )
 {
    GLcontext *ctx = gmesa->glCtx;
 
@@ -193,7 +193,7 @@ static GLboolean gamma_run_render( GLcontext *ctx,
 
    for (i = 0 ; i < VB->PrimitiveCount ; i++)
    {
-      GLuint prim = VB->Primitive[i].mode;
+      GLuint prim = _tnl_translate_prim(&VB->Primitive[i]);
       GLuint start = VB->Primitive[i].start;
       GLuint length = VB->Primitive[i].count;
 
index ea9a20595c9c4be82b9d644464912430946c53f8..81b463013975fb18280fdb2d9c99d653b2d981c4 100644 (file)
@@ -111,6 +111,8 @@ do {                                                                        \
 
 /* 16 bit depthbuffer functions.
  */
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d )       \
    *(GLushort *)(buf + (_x)*2 + (_y)*pitch) = d;
 
@@ -124,6 +126,8 @@ do {                                                                        \
 #if 0 /* Unused */
 /* 32 bit depthbuffer functions.
  */
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d )       \
    *(GLuint *)(buf + (_x)*4 + (_y)*pitch) = d;
 
@@ -137,6 +141,8 @@ do {                                                                        \
 
 /* 24/8 bit interleaved depth/stencil functions
  */
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d ) {                     \
    GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*pitch);        \
    tmp &= 0xff;                                                \
index 4c0ebe18992746d74e8c3be3e90135ad08b52951..43e33b66a50ec8c1ce13a9c81a61480f08b57acd 100644 (file)
@@ -237,7 +237,7 @@ gammaUnbindContext( __DRIcontextPrivate *driContextPriv )
    return GL_TRUE;
 }
 
-static struct __DriverAPIRec gammaAPI = {
+const struct __DriverAPIRec driDriverAPI = {
    gammaInitDriver,
    gammaDestroyScreen,
    gammaCreateContext,
diff --git a/src/mesa/drivers/dri/glcore/glcore_driver.c b/src/mesa/drivers/dri/glcore/glcore_driver.c
deleted file mode 100644 (file)
index 2577816..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright 2006 Red Hat, Inc.
- *
- * Permission is hereby granted, free of charge, to 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 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- * IN AN ACTION 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 implements a software-only "DRI" driver.  It doesn't actually speak
- * any DRI protocol or talk to the DRM, it just looks enough like a DRI driver
- * that libglx in the server can load it for software rendering in the
- * unaccelerated case.
- */
-
-static GLboolean
-glcoreInitDriver(__DRIscreenPrivate *driScreenPriv)
-{
-}
-
-static void
-glcoreDestroyScreen(__DRIScreenPrivate *driScreenPriv)
-{
-}
-
-static GLboolean
-glcoreCreateContext(const __GLcontextModes *glVisual,
-                    __DRIcontextPrivate *driContextPriv,
-                    void *shared_context)
-{
-}
-
-static void
-glcoreDestroyContext(__DRIcontextPrivate *driContextPriv)
-{
-}
-
-static GLboolean
-glcoreCreateBuffer(__DRIscreenPrivate *driScreenPriv,
-                   __DRIdrawablePrivate *driDrawablePriv,
-                   const __GLcontextModes *mesaVisual,
-                   GLboolean isPixmap)
-{
-}
-
-static void
-glcoreDestroyBuffer(__DRIdrawablePrivate *driDrawablePriv)
-{
-}
-
-static void
-glcoreSwapBuffers(__DRIdrawablePrivate *driDrawablePriv)
-{
-}
-
-static GLboolean
-glcoreMakeCurrent(__DRIcontextPrivate *driContextPriv,
-                  __DRIdrawablePrivate *driDrawablePriv,
-                  __DRIdrawablePrivate *driReadablePriv)
-{
-}
-
-static GLboolean
-glcoreUnbindContext(__DRIcontextPrivate *driContextPriv)
-{
-}
-
-static struct __DriverAPIRec glcore_api = {
-    .InitDriver     = glcoreInitDriver,
-    .DestroyScreen  = glcoreDestroyScreen,
-    .CreateContext  = glcoreCreateContext,
-    .DestroyContext = glcoreDestroyContext,
-    .CreateBuffer   = glcoreCreateBuffer,
-    .DestroyBuffer  = glcoreDestroyBuffer,
-    .SwapBuffers    = glcoreSwapBuffers,
-    .MakeCurrent    = glcoreMakeCurrent,
-    .UnbindContext  = glcoreUnbindContext,
-};  
-
-static __GLcontextModes *
-glcoreFillInModes(unsigned pixel_bits)
-{
-}
-
-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 *fb, drmAddress pSarea,
-                              int fd, int internal_api_version,
-                              const ___DRIinterfaceMethods *interface,
-                              __GLcontextModes **driver_modes)
-{
-    __DRIscreenPrivate *driScreenPriv;
-    glcoreDriverPrivate *glcoreDriverPriv;
-    
-    /* would normally check ddx/dri/drm versions here */
-
-    driScreenPriv = __driUtilCreateNewScreen(dpy, scrn, psc, NULL, ddx_version,
-                                             dri_version, drm_version, fb,
-                                             internal_api_version, &glcore_api);
-    if (!driScreenPriv)
-        return NULL;
-
-    glcoreDriverPriv = driScreenPriv->pDrvPriv;
-
-    *driver_modes = glcoreFillInModes(glcoreDriverPriv->bpp);
-
-    driInitExtensions(NULL, NULL, GL_FALSE);
-
-    return driScreenPriv;
-}
index f90b3682f83832084cb5491b10859f1fb41f03f0..c13b21aeb33e4554430b857acf62936cae404dc4 100644 (file)
@@ -423,11 +423,11 @@ void i810XMesaSetBackClipRects( i810ContextPtr imesa )
 static void i810XMesaWindowMoved( i810ContextPtr imesa )
 {
    /* Determine current color drawing buffer */
-   switch (imesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0]) {
-   case BUFFER_BIT_FRONT_LEFT:
+   switch (imesa->glCtx->DrawBuffer->_ColorDrawBufferIndexes[0]) {
+   case BUFFER_FRONT_LEFT:
       i810XMesaSetFrontClipRects( imesa );
       break;
-   case BUFFER_BIT_BACK_LEFT:
+   case BUFFER_BACK_LEFT:
       i810XMesaSetBackClipRects( imesa );
       break;
    default:
@@ -485,11 +485,11 @@ i810UpdatePageFlipping( i810ContextPtr imesa )
    int front = 0;
 
    /* Determine current color drawing buffer */
-   switch (ctx->DrawBuffer->_ColorDrawBufferMask[0]) {
-   case BUFFER_BIT_FRONT_LEFT:
+   switch (ctx->DrawBuffer->_ColorDrawBufferIndexes[0]) {
+   case BUFFER_FRONT_LEFT:
       front = 1;
       break;
-   case BUFFER_BIT_BACK_LEFT:
+   case BUFFER_BACK_LEFT:
       front = 0;
       break;
    default:
index 748d29ae36aec1cf89423faa1ad5bb1ba3f9ce80..dfd6e21088943dd490e7f1ed4aba86c7aaff0777 100644 (file)
@@ -33,7 +33,7 @@ do {                                                          \
    }                                                           \
 } while (0)
 
-static __inline GLuint *i810AllocDmaLow( i810ContextPtr imesa, int bytes )
+static INLINE GLuint *i810AllocDmaLow( i810ContextPtr imesa, int bytes )
 {
    if (imesa->vertex_low + bytes > imesa->vertex_high) 
       i810FlushPrimsGetBuffer( imesa );
index a31d54236cb9878e0479aa30fe468dda2212f001..d0225969b66e654e666058c7868fb3cc58cfb84c 100644 (file)
@@ -144,7 +144,7 @@ static GLboolean i810_run_render( GLcontext *ctx,
 
    for (i = 0 ; i < VB->PrimitiveCount ; i++)
    {
-      GLuint prim = VB->Primitive[i].mode;
+      GLuint prim = _tnl_translate_prim(&VB->Primitive[i]);
       GLuint start = VB->Primitive[i].start;
       GLuint length = VB->Primitive[i].count;
 
index 733c97b2ad43c19436ced73a8c59494b236b5ea0..ea26e72fa8e3361aedccec73ce15252a0765c665 100644 (file)
@@ -55,77 +55,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 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 uint8_t bits[1][4] = {
-       {          5,          6,          5,          0 }
-    };
-
-    static const uint32_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,
+static const __DRIconfig **
+i810FillInModes( __DRIscreenPrivate *psp,
+                unsigned pixel_bits, unsigned depth_bits,
                 unsigned stencil_bits, GLboolean have_back_buffer )
-{    __GLcontextModes * modes;
+{
+    __DRIconfig **configs;
     __GLcontextModes * m;
-    unsigned num_modes;
     unsigned depth_buffer_factor;
     unsigned back_buffer_factor;
     unsigned i;
@@ -139,50 +75,42 @@ i810FillInModes( unsigned pixel_bits, unsigned depth_bits,
        GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */
     };
 
-    int depth_buffer_modes[2][2];
+    u_int8_t depth_bits_array[2];
+    u_int8_t stencil_bits_array[2];
 
-
-    depth_buffer_modes[0][0] = depth_bits;
-    depth_buffer_modes[1][0] = depth_bits;
+    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.
      */
-    depth_buffer_modes[0][1] = 0;
-    depth_buffer_modes[1][1] = (stencil_bits == 0) ? 8 : stencil_bits;
+    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;
-
-    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 );
+    configs = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
+                              depth_bits_array, stencil_bits_array,
+                              depth_buffer_factor,
+                              back_buffer_modes, back_buffer_factor);
+    if (configs == NULL) {
+       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) ) {
+    for (i = 0; configs[i]; i++) {
+       m = &configs[i]->modes;
+       if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
            m->visualRating = GLX_SLOW_CONFIG;
        }
     }
 
-    return modes;
-
+    return (const __DRIconfig **) configs;
 }
 
      
@@ -218,12 +146,24 @@ static drmBufMapPtr i810_create_empty_buffers(void)
 }
 
 
-static GLboolean
-i810InitDriver(__DRIscreenPrivate *sPriv)
+static const __DRIconfig **
+i810InitScreen(__DRIscreen *sPriv)
 {
+   static const __DRIversion ddx_expected = { 1, 0, 0 };
+   static const __DRIversion dri_expected = { 4, 0, 0 };
+   static const __DRIversion drm_expected = { 1, 2, 0 };
    i810ScreenPrivate *i810Screen;
    I810DRIPtr         gDRIPriv = (I810DRIPtr)sPriv->pDevPriv;
 
+   if ( ! driCheckDriDdxDrmVersions2( "i810",
+                                     &sPriv->dri_version, & dri_expected,
+                                     &sPriv->ddx_version, & ddx_expected,
+                                     &sPriv->drm_version, & drm_expected ) ) {
+      return NULL;
+   }
+
+   driInitExtensions( NULL, card_extensions, GL_TRUE );
+
    if (sPriv->devPrivSize != sizeof(I810DRIRec)) {
       fprintf(stderr,"\nERROR!  sizeof(I810DRIRec) does not match passed size from device driver\n");
       return GL_FALSE;
@@ -287,8 +227,8 @@ i810InitDriver(__DRIscreenPrivate *sPriv)
              i810Screen->depth.handle,
              i810Screen->depth.size,
              (drmAddress *)&i810Screen->depth.map) != 0) {
-      FREE(i810Screen);
       drmUnmap(i810Screen->back.map, i810Screen->back.size);
+      FREE(i810Screen);
       sPriv->private = NULL;
       __driUtilMessage("i810InitDriver: drmMap (2) failed");
       return GL_FALSE;
@@ -311,7 +251,7 @@ i810InitDriver(__DRIscreenPrivate *sPriv)
 
    i810Screen->sarea_priv_offset = gDRIPriv->sarea_priv_offset;
 
-   return GL_TRUE;
+   return i810FillInModes(sPriv, 16, 16, 0, 1);
 }
 
 static void
@@ -400,9 +340,8 @@ i810DestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
     _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)));
 }
 
-
-static const struct __DriverAPIRec i810API = {
-   .InitDriver      = i810InitDriver,
+const struct __DriverAPIRec driDriverAPI = {
+   .InitScreen      = i810InitScreen,
    .DestroyScreen   = i810DestroyScreen,
    .CreateContext   = i810CreateContext,
    .DestroyContext  = i810DestroyContext,
@@ -412,60 +351,8 @@ static const struct __DriverAPIRec i810API = {
    .MakeCurrent     = i810MakeCurrent,
    .UnbindContext   = i810UnbindContext,
    .GetSwapInfo     = NULL,
-   .GetMSC          = NULL,
+   .GetDrawableMSC  = 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;
-}
index 2112800eebccd0ec81dcbc002869e4cdb5c50c72..59511de973b757b9b370425af7ed93ef5ae11203 100644 (file)
@@ -67,6 +67,8 @@ do {                                                                  \
 
 /* 16 bit depthbuffer functions.
  */
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d ) \
    *(GLushort *)(buf + (_x)*2 + (_y)*pitch)  = d;
 
index e203c74f52ddf479cb0a9c59b4849b84018b1ccd..144632471613f3df84982eb8b0d2cddd657daac3 100644 (file)
@@ -26,7 +26,7 @@
 
 #include "tnl/t_pipeline.h"
 
-static __inline__ GLuint i810PackColor(GLuint format,
+static INLINE GLuint i810PackColor(GLuint format,
                                       GLubyte r, GLubyte g,
                                       GLubyte b, GLubyte a)
 {
@@ -291,18 +291,20 @@ 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:
+   if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) {
+      /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
+      FALLBACK( imesa, I810_FALLBACK_DRAW_BUFFER, GL_TRUE );
+      return;
+   }
+
+   switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0]) {
+   case BUFFER_FRONT_LEFT:
      front = 1;
      break;
-   case BUFFER_BIT_BACK_LEFT:
+   case BUFFER_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;
    }
index 08900cc67d87722b65d4dbd03b4bdc73f72b157e..9c24fcd8f5788d48f0a617b817959792be635813 100644 (file)
@@ -64,7 +64,7 @@ void i810DestroyTexObj(i810ContextPtr imesa, i810TextureObjectPtr t)
 /* 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)
+static INLINE void * __memcpy(void * to, const void * from, size_t n)
 {
 int d0, d1, d2;
 __asm__ __volatile__(
index 40ab436b951fdf0df9278c53bfe315b0e599a50e..0d5f5d93693b5ec205e5883a26cc42d7c69ba51b 100644 (file)
@@ -74,7 +74,7 @@ do {                                                                  \
 } while (0)
 #endif
 
-static __inline__ void i810_draw_triangle( i810ContextPtr imesa,
+static INLINE void i810_draw_triangle( i810ContextPtr imesa,
                                           i810VertexPtr v0,
                                           i810VertexPtr v1,
                                           i810VertexPtr v2 )
@@ -89,7 +89,7 @@ static __inline__ void i810_draw_triangle( i810ContextPtr imesa,
 }
 
 
-static __inline__ void i810_draw_quad( i810ContextPtr imesa,
+static INLINE void i810_draw_quad( i810ContextPtr imesa,
                                       i810VertexPtr v0,
                                       i810VertexPtr v1,
                                       i810VertexPtr v2,
@@ -108,7 +108,7 @@ static __inline__ void i810_draw_quad( i810ContextPtr imesa,
 }
 
 
-static __inline__ void i810_draw_point( i810ContextPtr imesa,
+static INLINE void i810_draw_point( i810ContextPtr imesa,
                                        i810VertexPtr tmp )
 {
    GLfloat sz = 0.5 * CLAMP(imesa->glCtx->Point.Size,
@@ -132,7 +132,7 @@ static __inline__ void i810_draw_point( i810ContextPtr imesa,
 }
 
 
-static __inline__ void i810_draw_line( i810ContextPtr imesa,
+static INLINE void i810_draw_line( i810ContextPtr imesa,
                                       i810VertexPtr v0,
                                       i810VertexPtr v1 )
 {
index 805abf75e088aff616624ce936b540067e768686..5858e0ee9fd44389e48e403280c0a4dbacc2415a 100644 (file)
@@ -7,16 +7,6 @@ LIBNAME = i915_dri.so
 MINIGLX_SOURCES = server/intel_dri.c
 
 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 \
@@ -24,18 +14,44 @@ DRIVER_SOURCES = \
        i830_tex.c \
        i830_texstate.c \
        i830_vtbl.c \
+       intel_render.c \
+       intel_regions.c \
+       intel_buffer_objects.c \
        intel_batchbuffer.c \
-       intel_context.c \
-       intel_ioctl.c \
+       intel_mipmap_tree.c \
+       i915_tex_layout.c \
+       intel_tex_layout.c \
+       intel_tex_image.c \
+       intel_tex_subimage.c \
+       intel_tex_copy.c \
+       intel_tex_validate.c \
+       intel_tex_format.c \
+       intel_tex.c \
        intel_pixel.c \
-       intel_render.c \
-       intel_rotate.c \
+       intel_pixel_bitmap.c \
+       intel_pixel_copy.c \
+       intel_pixel_draw.c \
+       intel_pixel_read.c \
+       intel_buffers.c \
+       intel_blit.c \
+       i915_tex.c \
+       i915_texstate.c \
+       i915_context.c \
+       i915_debug.c \
+       i915_debug_fp.c \
+       i915_fragprog.c \
+       i915_metaops.c \
+       i915_program.c \
+       i915_state.c \
+       i915_vtbl.c \
+       intel_context.c \
+       intel_decode.c \
        intel_screen.c \
        intel_span.c \
        intel_state.c \
-       intel_tex.c \
-       intel_texmem.c \
-       intel_tris.c 
+       intel_tris.c \
+       intel_fbo.c \
+       intel_depthstencil.c
 
 C_SOURCES = \
        $(COMMON_SOURCES) \
@@ -43,8 +59,16 @@ C_SOURCES = \
 
 ASM_SOURCES = 
 
+DRIVER_DEFINES = -I../intel -I../intel/server -DI915 \
+       $(shell pkg-config libdrm --atleast-version=2.3.1 \
+                               && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP")
 
+DRI_LIB_DEPS += -ldrm_intel
 
 include ../Makefile.template
 
+intel_decode.o: ../intel/intel_decode.c
+
+intel_tex_layout.o: ../intel/intel_tex_layout.c
+
 symlinks:
index 7ca601e1b5cee5b304365a10c4587eb2be542c94..116b52511f540472430fe4ce4372001eb4931ab6 100644 (file)
 #include "tnl/tnl.h"
 #include "tnl/t_vertex.h"
 #include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
 #include "utils.h"
+#include "intel_span.h"
+#include "intel_pixel.h"
+#include "intel_tris.h"
 
 /***************************************
  * Mesa's Driver Functions
  ***************************************/
 
-static const struct dri_extension i830_extensions[] =
+static void
+i830InitDriverFunctions(struct dd_function_table *functions)
 {
-    { "GL_ARB_texture_env_crossbar",       NULL },
-    { NULL,                                NULL }
-};
-
-
-static void i830InitDriverFunctions( struct dd_function_table *functions )
-{
-   intelInitDriverFunctions( functions );
-   i830InitStateFuncs( functions );
-   i830InitTextureFuncs( functions );
+   intelInitDriverFunctions(functions);
+   i830InitStateFuncs(functions);
+   i830InitTextureFuncs(functions);
 }
 
+extern const struct tnl_pipeline_stage *intel_pipeline[];
 
-GLboolean i830CreateContext( const __GLcontextModes *mesaVis,
-                           __DRIcontextPrivate *driContextPriv,
-                           void *sharedContextPrivate)
+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;
+   struct i830_context *i830 = CALLOC_STRUCT(i830_context);
+   struct intel_context *intel = &i830->intel;
    GLcontext *ctx = &intel->ctx;
-   GLuint i;
-   if (!i830) return GL_FALSE;
+   if (!i830)
+      return GL_FALSE;
 
-   i830InitVtbl( i830 );
-   i830InitDriverFunctions( &functions );
+   i830InitVtbl(i830);
+   i830InitDriverFunctions(&functions);
 
-   if (!intelInitContext( intel, mesaVis, driContextPriv,
-                         sharedContextPrivate, &functions )) {
+   if (!intelInitContext(intel, mesaVis, driContextPriv,
+                         sharedContextPrivate, &functions)) {
       FREE(i830);
       return GL_FALSE;
    }
 
+   /* Initialize swrast, tnl driver tables: */
+   intelInitSpanFuncs(ctx);
+   intelInitTriFuncs(ctx);
+
+   /* Install the customized pipeline: */
+   _tnl_destroy_pipeline(ctx);
+   _tnl_install_pipeline(ctx, intel_pipeline);
+
+   if (intel->no_rast)
+      FALLBACK(intel, INTEL_FALLBACK_USER, 1);
+
    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->tex.size,
-                           12,
-                           I830_NR_TEX_REGIONS,
-                           intel->sarea->texList,
-                           (unsigned *) & 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.
+   /* Advertise the full hardware capabilities.  The new memory
+    * manager should cope much better with overload situations:
     */
-   intel->ctx.Const.MaxTextureUnits = I830_TEX_UNITS;
-   i = driQueryOptioni( &intel->optionCache, "allow_large_textures");
-   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,
-                                i );
-
-   _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12, 
-                      18 * sizeof(GLfloat) );
-
-   intel->verts = TNL_CONTEXT(ctx)->clipspace.vertex_buf;
+   ctx->Const.MaxTextureLevels = 12;
+   ctx->Const.Max3DTextureLevels = 9;
+   ctx->Const.MaxCubeTextureLevels = 11;
+   ctx->Const.MaxTextureRectSize = (1 << 11);
+   ctx->Const.MaxTextureUnits = I830_TEX_UNITS;
 
-   driInitExtensions( ctx, i830_extensions, GL_FALSE );
+   _tnl_init_vertices(ctx, ctx->Const.MaxArrayLockSize + 12,
+                      18 * sizeof(GLfloat));
 
-   i830InitState( i830 );
+   intel->verts = TNL_CONTEXT(ctx)->clipspace.vertex_buf;
 
+   i830InitState(i830);
+   i830InitMetaFuncs(i830);
 
-   _tnl_allow_vertex_fog( ctx, 1 ); 
-   _tnl_allow_pixel_fog( ctx, 0 ); 
+   _tnl_allow_vertex_fog(ctx, 1);
+   _tnl_allow_pixel_fog(ctx, 0);
 
    return GL_TRUE;
 }
-
index bae777dd5a4ed35f3d357a4fb2cf0f497471bb24..a298c1407def85391d5940b1220d47e0fc5cd62c 100644 (file)
  */
 #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_DESTREG_DBUFADDR0 2
+#define I830_DESTREG_DBUFADDR1 3
+#define I830_DESTREG_DV0 4
+#define I830_DESTREG_DV1 5
+#define I830_DESTREG_SENABLE 6
+#define I830_DESTREG_SR0 7
+#define I830_DESTREG_SR1 8
+#define I830_DESTREG_SR2 9
+#define I830_DEST_SETUP_SIZE 10
 
 #define I830_CTXREG_STATE1             0
 #define I830_CTXREG_STATE2             1
@@ -73,7 +71,7 @@
 #define I830_CTXREG_AA                 9
 #define I830_CTXREG_FOGCOLOR           10
 #define I830_CTXREG_BLENDCOLOR0                11
-#define I830_CTXREG_BLENDCOLOR1                12 
+#define I830_CTXREG_BLENDCOLOR1                12
 #define I830_CTXREG_VF                 13
 #define I830_CTXREG_VF2                        14
 #define I830_CTXREG_MCSB0              15
 #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_TEXREG_TM0LI      0        /* load immediate 2 texture map n */
+#define I830_TEXREG_TM0S1      1
+#define I830_TEXREG_TM0S2      2
+#define I830_TEXREG_TM0S3      3
+#define I830_TEXREG_TM0S4      4
+#define I830_TEXREG_MCS               5        /* _3DSTATE_MAP_COORD_SETS */
+#define I830_TEXREG_CUBE       6        /* _3DSTATE_MAP_SUBE */
+#define I830_TEX_SETUP_SIZE    7
 
-#define I830_TEXBLEND_SIZE     12      /* (4 args + op) * 2 + COLOR_FACTOR */
+#define I830_TEXBLEND_SIZE     12      /* (4 args + op) * 2 + COLOR_FACTOR */
 
 struct i830_texture_object
 {
@@ -104,30 +101,39 @@ struct i830_texture_object
 
 #define I830_TEX_UNITS 4
 
-struct i830_hw_state {
+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_* */
+
+   struct intel_region *draw_region;
+   struct intel_region *depth_region;
+
+   /* Regions aren't actually that appropriate here as the memory may
+    * be from a PBO or FBO.  Will have to do this for draw and depth for
+    * FBO's...
+    */
+   dri_bo *tex_buffer[I830_TEX_UNITS];
+   GLuint tex_offset[I830_TEX_UNITS];
+
+   GLuint emitted;              /* I810_UPLOAD_* */
    GLuint active;
 };
 
-struct i830_context 
+struct i830_context
 {
    struct intel_context intel;
-   
-   DECLARE_RENDERINPUTS(last_index_bitset);
+
+   GLuint lodbias_tm0s3[MAX_TEXTURE_UNITS];
+     DECLARE_RENDERINPUTS(last_index_bitset);
 
    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))
 
 
 
@@ -148,71 +154,56 @@ do {                                              \
 
 /* i830_vtbl.c
  */
-extern void 
-i830InitVtbl( i830ContextPtr i830 );
+extern void i830InitVtbl(struct i830_context *i830);
 
+extern void
+i830_state_draw_region(struct intel_context *intel,
+                       struct i830_hw_state *state,
+                       struct intel_region *color_region,
+                       struct intel_region *depth_region);
 /* i830_context.c
  */
-extern GLboolean 
-i830CreateContext( const __GLcontextModes *mesaVis,
-                  __DRIcontextPrivate *driContextPriv,
-                  void *sharedContextPrivate);
+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 void i830UpdateTextureState(struct intel_context *intel);
 
-extern intelTextureObjectPtr
-i830AllocTexObj( struct gl_texture_object *tObj );
+extern void i830InitTextureFuncs(struct dd_function_table *functions);
 
 /* 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 GLuint i830SetTexEnvCombine(struct i830_context *i830,
+                                   const struct gl_tex_env_combine_state
+                                   *combine, GLint blendUnit, GLuint texel_op,
+                                   GLuint * state, const GLfloat * factor);
 
-extern void 
-i830EmitTextureBlend( i830ContextPtr i830 );
+extern void i830EmitTextureBlend(struct i830_context *i830);
 
 
 /* i830_state.c
  */
-extern void 
-i830InitStateFuncs( struct dd_function_table *functions );
+extern void i830InitStateFuncs(struct dd_function_table *functions);
 
-extern void 
-i830EmitState( i830ContextPtr i830 );
+extern void i830EmitState(struct i830_context *i830);
 
-extern void 
-i830InitState( i830ContextPtr i830 );
+extern void i830InitState(struct i830_context *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);
+extern void i830InitMetaFuncs(struct i830_context *i830);
 
-extern void
-i830RotateWindow(intelContextPtr intel, __DRIdrawablePrivate *dPriv,
-                 GLuint srcBuf);
+/*======================================================================
+ * Inline conversion functions.  These are better-typed than the
+ * macros used previously:
+ */
+static INLINE struct i830_context *
+i830_context(GLcontext * ctx)
+{
+   return (struct i830_context *) ctx;
+}
 
 #endif
-
index c1d7fe349c063f7b27384187846eb02bdf4e81b8..acfb3af9102b5a2e9069a159aea2355969a83ccc 100644 (file)
@@ -33,7 +33,7 @@
 
 #include "intel_screen.h"
 #include "intel_batchbuffer.h"
-#include "intel_ioctl.h"
+#include "intel_regions.h"
 
 #include "i830_context.h"
 #include "i830_reg.h"
 /* A large amount of state doesn't need to be uploaded.
  */
 #define ACTIVE (I830_UPLOAD_INVARIENT |         \
-               I830_UPLOAD_TEXBLEND(0) |       \
-               I830_UPLOAD_STIPPLE |           \
                I830_UPLOAD_CTX |               \
                I830_UPLOAD_BUFFERS |           \
-               I830_UPLOAD_TEX(0))             
+               I830_UPLOAD_STIPPLE |           \
+               I830_UPLOAD_TEXBLEND(0) |       \
+               I830_UPLOAD_TEX(0))
 
 
 #define SET_STATE( i830, STATE )               \
 do {                                           \
-   i830->current->emitted = 0;                 \
+   i830->current->emitted &= ~ACTIVE;                  \
    i830->current = &i830->STATE;               \
-   i830->current->emitted = 0;                 \
+   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 )
+static void
+set_no_stencil_write(struct intel_context *intel)
 {
+   struct i830_context *i830 = i830_context(&intel->ctx);
+
    /* ctx->Driver.Enable( ctx, GL_STENCIL_TEST, GL_FALSE )
     */
    i830->meta.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_STENCIL_TEST;
@@ -76,6 +68,13 @@ static void set_no_depth_stencil_write( i830ContextPtr i830 )
    i830->meta.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_STENCIL_TEST;
    i830->meta.Ctx[I830_CTXREG_ENABLES_2] |= DISABLE_STENCIL_WRITE;
 
+   i830->meta.emitted &= ~I830_UPLOAD_CTX;
+}
+
+static void
+set_no_depth_write(struct intel_context *intel)
+{
+   struct i830_context *i830 = i830_context(&intel->ctx);
 
    /* ctx->Driver.Enable( ctx, GL_DEPTH_TEST, GL_FALSE )
     */
@@ -87,35 +86,56 @@ static void set_no_depth_stencil_write( i830ContextPtr i830 )
    i830->meta.emitted &= ~I830_UPLOAD_CTX;
 }
 
-/* Set stencil unit to replace always with the reference value.
+/* Set depth unit to replace.
  */
-static void set_stencil_replace( i830ContextPtr i830,
-                                GLuint s_mask,
-                                GLuint s_clear)
+static void
+set_depth_replace(struct intel_context *intel)
 {
-   /* 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;
-
+   struct i830_context *i830 = i830_context(&intel->ctx);
 
    /* ctx->Driver.Enable( ctx, GL_DEPTH_TEST, GL_FALSE )
+    * ctx->Driver.DepthMask( ctx, GL_TRUE )
     */
    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.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_DEPTH_TEST;
+   i830->meta.Ctx[I830_CTXREG_ENABLES_2] |= ENABLE_DEPTH_WRITE;
+
+   /* ctx->Driver.DepthFunc( ctx, GL_ALWAYS )
+    */
+   i830->meta.Ctx[I830_CTXREG_STATE3] &= ~DEPTH_TEST_FUNC_MASK;
+   i830->meta.Ctx[I830_CTXREG_STATE3] |= (ENABLE_DEPTH_TEST_FUNC |
+                                          DEPTH_TEST_FUNC
+                                          (COMPAREFUNC_ALWAYS));
+
+   i830->meta.emitted &= ~I830_UPLOAD_CTX;
+}
+
+
+/* Set stencil unit to replace always with the reference value.
+ */
+static void
+set_stencil_replace(struct intel_context *intel,
+                    GLuint s_mask, GLuint s_clear)
+{
+   struct i830_context *i830 = i830_context(&intel->ctx);
+
+   /* 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.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)));
+                                          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] |= 
+   i830->meta.Ctx[I830_CTXREG_STENCILTST] |=
       (ENABLE_STENCIL_PARMS |
        STENCIL_FAIL_OP(STENCILOP_REPLACE) |
        STENCIL_PASS_DEPTH_FAIL_OP(STENCILOP_REPLACE) |
@@ -125,14 +145,14 @@ static void set_stencil_replace( i830ContextPtr i830,
     */
    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));
+                                          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_TEST_FUNC_MASK);
+   i830->meta.Ctx[I830_CTXREG_STENCILTST] |=
       (ENABLE_STENCIL_REF_VALUE |
        ENABLE_STENCIL_TEST_FUNC |
-       STENCIL_REF_VALUE((s_clear&0xff)) |
+       STENCIL_REF_VALUE((s_clear & 0xff)) |
        STENCIL_TEST_FUNC(COMPAREFUNC_ALWAYS));
 
 
@@ -141,38 +161,43 @@ static void set_stencil_replace( i830ContextPtr i830,
 }
 
 
-static void set_color_mask( i830ContextPtr i830, GLboolean state )
+static void
+set_color_mask(struct intel_context *intel, GLboolean state)
 {
+   struct i830_context *i830 = i830_context(&intel->ctx);
+
    const GLuint mask = ((1 << WRITEMASK_RED_SHIFT) |
-                       (1 << WRITEMASK_GREEN_SHIFT) |
-                       (1 << WRITEMASK_BLUE_SHIFT) |
-                       (1 << WRITEMASK_ALPHA_SHIFT));
+                        (1 << WRITEMASK_GREEN_SHIFT) |
+                        (1 << WRITEMASK_BLUE_SHIFT) |
+                        (1 << WRITEMASK_ALPHA_SHIFT));
 
    i830->meta.Ctx[I830_CTXREG_ENABLES_2] &= ~mask;
 
    if (state) {
-      i830->meta.Ctx[I830_CTXREG_ENABLES_2] |= 
-        (i830->state.Ctx[I830_CTXREG_ENABLES_2] & mask);
+      i830->meta.Ctx[I830_CTXREG_ENABLES_2] |=
+         (i830->state.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 void
+set_no_texture(struct intel_context *intel)
 {
+   struct i830_context *i830 = i830_context(&intel->ctx);
    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 },
+      {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);
+      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);
@@ -181,18 +206,22 @@ static void set_no_texture( i830ContextPtr i830 )
 /* Set up a single element blend stage for 'replace' texturing with no
  * funny ops.
  */
-static void enable_texture_blend_replace( i830ContextPtr i830 )
+static void
+set_texture_blend_replace(struct intel_context *intel)
 {
+   struct i830_context *i830 = i830_context(&intel->ctx);
    static const struct gl_tex_env_combine_state comb = {
       GL_REPLACE, GL_REPLACE,
-      { GL_TEXTURE, GL_TEXTURE, GL_TEXTURE }, { GL_TEXTURE, GL_TEXTURE, GL_TEXTURE, },
-      { GL_SRC_COLOR, GL_SRC_COLOR, GL_SRC_COLOR }, { GL_SRC_ALPHA, GL_SRC_ALPHA, GL_SRC_ALPHA },
+      {GL_TEXTURE, GL_TEXTURE, GL_TEXTURE,}, {GL_TEXTURE, GL_TEXTURE,
+                                              GL_TEXTURE,},
+      {GL_SRC_COLOR, GL_SRC_COLOR, GL_SRC_COLOR}, {GL_SRC_ALPHA, GL_SRC_ALPHA,
+                                                   GL_SRC_ALPHA},
       0, 0, 1, 1
    };
 
    i830->meta.TexBlendWordsUsed[0] =
-     i830SetTexEnvCombine( i830, & comb, 0, TEXBLENDARG_TEXEL0,
-                          i830->meta.TexBlend[0], NULL);
+      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);
@@ -206,717 +235,222 @@ static void enable_texture_blend_replace( i830ContextPtr i830 )
 /* 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, /* in bytes */
-                                GLuint textureFormat )
+static GLboolean
+set_tex_rect_source(struct intel_context *intel,
+                    dri_bo *buffer,
+                    GLuint offset,
+                    GLuint pitch, GLuint height, GLenum format, GLenum type)
 {
-   GLint numLevels = 1;
+   struct i830_context *i830 = i830_context(&intel->ctx);
    GLuint *setup = i830->meta.Tex[0];
+   GLint numLevels = 1;
+   GLuint textureFormat;
+   GLuint cpp;
 
-/*    fprintf(stderr, "%s: offset: %x w: %d h: %d pitch %d format %x\n", */
-/*        __FUNCTION__, offset, width, height, pitch, textureFormat ); */
+   /* A full implementation of this would do the upload through
+    * glTexImage2d, and get all the conversion operations at that
+    * point.  We are restricted, but still at least have access to the
+    * fragment program swizzle.
+    */
+   switch (format) {
+   case GL_BGRA:
+      switch (type) {
+      case GL_UNSIGNED_INT_8_8_8_8_REV:
+      case GL_UNSIGNED_BYTE:
+         textureFormat = (MAPSURF_32BIT | MT_32BIT_ARGB8888);
+         cpp = 4;
+         break;
+      default:
+         return GL_FALSE;
+      }
+      break;
+   case GL_RGBA:
+      switch (type) {
+      case GL_UNSIGNED_INT_8_8_8_8_REV:
+      case GL_UNSIGNED_BYTE:
+         textureFormat = (MAPSURF_32BIT | MT_32BIT_ABGR8888);
+         cpp = 4;
+         break;
+      default:
+         return GL_FALSE;
+      }
+      break;
+   case GL_BGR:
+      switch (type) {
+      case GL_UNSIGNED_SHORT_5_6_5_REV:
+         textureFormat = (MAPSURF_16BIT | MT_16BIT_RGB565);
+         cpp = 2;
+         break;
+      default:
+         return GL_FALSE;
+      }
+      break;
+   case GL_RGB:
+      switch (type) {
+      case GL_UNSIGNED_SHORT_5_6_5:
+         textureFormat = (MAPSURF_16BIT | MT_16BIT_RGB565);
+         cpp = 2;
+         break;
+      default:
+         return GL_FALSE;
+      }
+      break;
 
-   setup[I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 | 
-                              (LOAD_TEXTURE_MAP0 << 0) | 4);
-   setup[I830_TEXREG_TM0S0] = (TM0S0_USE_FENCE | offset);
+   default:
+      return GL_FALSE;
+   }
+
+   i830->meta.tex_buffer[0] = buffer;
+   i830->meta.tex_offset[0] = offset;
+
+   setup[I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
+                               (LOAD_TEXTURE_MAP0 << 0) | 4);
    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;
+                               ((pitch - 1) << TM0S1_WIDTH_SHIFT) |
+                               textureFormat);
+   setup[I830_TEXREG_TM0S2] =
+      (((((pitch * cpp) / 4) -
+         1) << TM0S2_PITCH_SHIFT) | TM0S2_CUBE_FACE_ENA_MASK);
+
+   setup[I830_TEXREG_TM0S3] =
+      ((((numLevels -
+          1) *
+         4) << TM0S3_MIN_MIP_SHIFT) | (FILTER_NEAREST <<
+                                       TM0S3_MIN_FILTER_SHIFT) |
+       (MIPFILTER_NONE << TM0S3_MIP_FILTER_SHIFT) | (FILTER_NEAREST <<
+                                                     TM0S3_MAG_FILTER_SHIFT));
+
+   setup[I830_TEXREG_CUBE] = (_3DSTATE_MAP_CUBE | MAP_UNIT(0));
 
    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));
+                             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);
+   return GL_TRUE;
 }
 
 
-/* Select between front and back draw buffers.
- */
-static void set_draw_region( i830ContextPtr i830,
-                             const intelRegion *region )
-{
-   i830->meta.Buffer[I830_DESTREG_CBUFADDR1] =
-      (BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(region->pitch) | BUF_3D_USE_FENCE);
-   i830->meta.Buffer[I830_DESTREG_CBUFADDR2] = region->offset;
-   i830->meta.emitted &= ~I830_UPLOAD_BUFFERS;
-}
-
-/* Setup an arbitary draw format, useful for targeting
- * texture or agp memory.
- */
-#if 0
-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);
-}
-#endif
-
-
-static void set_vertex_format( i830ContextPtr i830 )
+static void
+set_vertex_format(struct intel_context *intel)
 {
-   i830->meta.Ctx[I830_CTXREG_VF] =  (_3DSTATE_VFT0_CMD |
-                                     VFT0_TEX_COUNT(1) |
-                                     VFT0_DIFFUSE |
-                                     VFT0_SPEC |
-                                     VFT0_XYZW);
+   struct i830_context *i830 = i830_context(&intel->ctx);
+   i830->meta.Ctx[I830_CTXREG_VF] = (_3DSTATE_VFT0_CMD |
+                                     VFT0_TEX_COUNT(1) |
+                                     VFT0_DIFFUSE | VFT0_XYZ);
    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));
+                                      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]); */
-}
-
-static void draw_poly(i830ContextPtr i830, 
-                     GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha,
-                      GLuint numVerts,
-                      GLfloat verts[][2],
-                      GLfloat texcoords[][2])
+static void
+meta_import_pixel_state(struct intel_context *intel)
 {
-   GLuint vertex_size = 8;
-   GLuint *vb = intelEmitInlinePrimitiveLocked( &i830->intel, 
-                                               PRIM3D_TRIFAN, 
-                                               numVerts * vertex_size,
-                                               vertex_size );
-   intelVertex tmp;
-   int i, k;
-
-   /* initial constant vertex fields */
-   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;
-
-   for (k = 0; k < numVerts; k++) {
-      tmp.v.x = verts[k][0];
-      tmp.v.y = verts[k][1];
-      tmp.v.u0 = texcoords[k][0];
-      tmp.v.v0 = texcoords[k][1];
-
-      for (i = 0 ; i < vertex_size ; i++)
-         vb[i] = tmp.ui[i];
-
-      vb += vertex_size;
-   }
-}
-
-void 
-i830ClearWithTris(intelContextPtr intel, GLbitfield mask,
-                 GLboolean allFoo,
-                 GLint cxFoo, GLint cyFoo, GLint cwFoo, GLint chFoo)
-{
-   i830ContextPtr i830 = I830_CONTEXT( intel );
-   __DRIdrawablePrivate *dPriv = intel->driDrawable;
-   intelScreenPrivate *screen = intel->intelScreen;
-   int x0, y0, x1, y1;
-   GLint cx, cy, cw, ch;
-   GLboolean all;
-
-   INTEL_FIREVERTICES(intel);
-   SET_STATE( i830, meta );
-   set_initial_state( i830 );
-/*    set_no_texture( i830 ); */
-   set_vertex_format( i830 ); 
-
-   LOCK_HARDWARE(intel);
-
-   /* get clear bounds after locking */
-   cx = intel->ctx.DrawBuffer->_Xmin;
-   cy = intel->ctx.DrawBuffer->_Ymin;
-   cw = intel->ctx.DrawBuffer->_Xmax - cx;
-   ch = intel->ctx.DrawBuffer->_Ymax - cy;
-   all = (cw == intel->ctx.DrawBuffer->Width &&
-          ch == intel->ctx.DrawBuffer->Height);
-
-   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_region( i830, &screen->front );
-      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_region( i830, &screen->back );
-
-      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_region( i830, &screen->front );
-      draw_quad( i830, x0, x1, y0, y1, 0, 0, 0, 0, 0, 0, 0, 0 );
-   }
+   struct i830_context *i830 = i830_context(&intel->ctx);
+
+   i830->meta.Ctx[I830_CTXREG_STATE1] = i830->state.Ctx[I830_CTXREG_STATE1];
+   i830->meta.Ctx[I830_CTXREG_STATE2] = i830->state.Ctx[I830_CTXREG_STATE2];
+   i830->meta.Ctx[I830_CTXREG_STATE3] = i830->state.Ctx[I830_CTXREG_STATE3];
+   i830->meta.Ctx[I830_CTXREG_STATE4] = i830->state.Ctx[I830_CTXREG_STATE4];
+   i830->meta.Ctx[I830_CTXREG_STATE5] = i830->state.Ctx[I830_CTXREG_STATE5];
+   i830->meta.Ctx[I830_CTXREG_IALPHAB] = i830->state.Ctx[I830_CTXREG_IALPHAB];
+   i830->meta.Ctx[I830_CTXREG_STENCILTST] =
+      i830->state.Ctx[I830_CTXREG_STENCILTST];
+   i830->meta.Ctx[I830_CTXREG_ENABLES_1] =
+      i830->state.Ctx[I830_CTXREG_ENABLES_1];
+   i830->meta.Ctx[I830_CTXREG_ENABLES_2] =
+      i830->state.Ctx[I830_CTXREG_ENABLES_2];
+   i830->meta.Ctx[I830_CTXREG_AA] = i830->state.Ctx[I830_CTXREG_AA];
+   i830->meta.Ctx[I830_CTXREG_FOGCOLOR] =
+      i830->state.Ctx[I830_CTXREG_FOGCOLOR];
+   i830->meta.Ctx[I830_CTXREG_BLENDCOLOR0] =
+      i830->state.Ctx[I830_CTXREG_BLENDCOLOR0];
+   i830->meta.Ctx[I830_CTXREG_BLENDCOLOR1] =
+      i830->state.Ctx[I830_CTXREG_BLENDCOLOR1];
+   i830->meta.Ctx[I830_CTXREG_MCSB0] = i830->state.Ctx[I830_CTXREG_MCSB0];
+   i830->meta.Ctx[I830_CTXREG_MCSB1] = i830->state.Ctx[I830_CTXREG_MCSB1];
+
+
+   i830->meta.Ctx[I830_CTXREG_STATE3] &= ~CULLMODE_MASK;
+   i830->meta.Stipple[I830_STPREG_ST1] &= ~ST1_ENABLE;
+   i830->meta.emitted &= ~I830_UPLOAD_CTX;
 
-   UNLOCK_HARDWARE(intel);
 
-   INTEL_FIREVERTICES(intel);
-   SET_STATE( i830, state );
+   i830->meta.Buffer[I830_DESTREG_SENABLE] =
+      i830->state.Buffer[I830_DESTREG_SENABLE];
+   i830->meta.Buffer[I830_DESTREG_SR1] = i830->state.Buffer[I830_DESTREG_SR1];
+   i830->meta.Buffer[I830_DESTREG_SR2] = i830->state.Buffer[I830_DESTREG_SR2];
+   i830->meta.emitted &= ~I830_UPLOAD_BUFFERS;
 }
 
 
-#if 0
 
-GLboolean
-i830TryTextureReadPixels( GLcontext *ctx,
-                         GLint x, GLint y, GLsizei width, GLsizei height,
-                         GLenum format, GLenum type,
-                         const struct gl_pixelstore_attrib *pack,
-                         GLvoid *pixels )
+/* Select between front and back draw buffers.
+ */
+static void
+meta_draw_region(struct intel_context *intel,
+                 struct intel_region *color_region,
+                 struct intel_region *depth_region)
 {
-   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->front.pitch, 
-                          textureFormat ); 
-   
-   
-      enable_texture_blend_replace( i830 ); 
-
-
-      /* Set the 3d engine to draw into the agp memory
-       */
+   struct i830_context *i830 = i830_context(&intel->ctx);
 
-      set_draw_region( 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;
+   i830_state_draw_region(intel, &i830->meta, color_region, depth_region);
 }
 
 
-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 )
+/* 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
+install_meta_state(struct intel_context *intel)
 {
-   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.  
-    */
+   struct i830_context *i830 = i830_context(&intel->ctx);
+   memcpy(&i830->meta, &i830->initial, sizeof(i830->meta));
 
-   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 ); 
-
-   
-      /* 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); */
+   i830->meta.active = ACTIVE;
+   i830->meta.emitted = 0;
 
-      draw_quad( i830, 
-                x, x+width, y, y+height,
-                0, 255, 0, 0, 
-                0, width, 0, height );
+   SET_STATE(i830, meta);
+   set_vertex_format(intel);
+   set_no_texture(intel);
+}
 
-      intelWindowMoved( intel );
-   }
-   UNLOCK_HARDWARE( intel );
-   intelFinish( ctx ); /* required by GL */
-   
+static void
+leave_meta_state(struct intel_context *intel)
+{
+   struct i830_context *i830 = i830_context(&intel->ctx);
+   intel_region_release(&i830->meta.draw_region);
+   intel_region_release(&i830->meta.depth_region);
+/*    intel_region_release(intel, &i830->meta.tex_region[0]); */
    SET_STATE(i830, state);
-
-   return GL_TRUE;
 }
 
-#endif
 
-/**
- * Copy the window contents named by dPriv to the rotated (or reflected)
- * color buffer.
- * srcBuf is BUFFER_BIT_FRONT_LEFT or BUFFER_BIT_BACK_LEFT to indicate the source.
- */
+
 void
-i830RotateWindow(intelContextPtr intel, __DRIdrawablePrivate *dPriv,
-                 GLuint srcBuf)
+i830InitMetaFuncs(struct i830_context *i830)
 {
-   i830ContextPtr i830 = I830_CONTEXT( intel );
-   intelScreenPrivate *screen = intel->intelScreen;
-   const GLuint cpp = screen->cpp;
-   drm_clip_rect_t fullRect;
-   GLuint textureFormat, srcOffset, srcPitch;
-   const drm_clip_rect_t *clipRects;
-   int numClipRects;
-   int i;
-
-   int xOrig, yOrig;
-   int origNumClipRects;
-   drm_clip_rect_t *origRects;
-
-   /*
-    * set up hardware state
-    */
-   intelFlush( &intel->ctx );
-
-   SET_STATE( i830, meta ); 
-   set_initial_state( i830 ); 
-   set_no_texture( i830 ); 
-   set_vertex_format( i830 ); 
-   set_no_depth_stencil_write( i830 );
-   set_color_mask( i830, GL_FALSE );
-
-   LOCK_HARDWARE(intel);
-
-   /* save current drawing origin and cliprects (restored at end) */
-   xOrig = intel->drawX;
-   yOrig = intel->drawY;
-   origNumClipRects = intel->numClipRects;
-   origRects = intel->pClipRects;
-
-   if (!intel->numClipRects)
-      goto done;
-
-   /*
-    * set drawing origin, cliprects for full-screen access to rotated screen
-    */
-   fullRect.x1 = 0;
-   fullRect.y1 = 0;
-   fullRect.x2 = screen->rotatedWidth;
-   fullRect.y2 = screen->rotatedHeight;
-   intel->drawX = 0;
-   intel->drawY = 0;
-   intel->numClipRects = 1;
-   intel->pClipRects = &fullRect;
-
-   set_draw_region( i830, &screen->rotated );
-
-   if (cpp == 4)
-      textureFormat = MAPSURF_32BIT | MT_32BIT_ARGB8888;
-   else
-      textureFormat = MAPSURF_16BIT | MT_16BIT_RGB565;
-
-   if (srcBuf == BUFFER_BIT_FRONT_LEFT) {
-      srcPitch = screen->front.pitch;   /* in bytes */
-      srcOffset = screen->front.offset; /* bytes */
-      clipRects = dPriv->pClipRects;
-      numClipRects = dPriv->numClipRects;
-   }
-   else {
-      srcPitch = screen->back.pitch;   /* in bytes */
-      srcOffset = screen->back.offset; /* bytes */
-      clipRects = dPriv->pBackClipRects;
-      numClipRects = dPriv->numBackClipRects;
-   }
-
-   /* set the whole screen up as a texture to avoid alignment issues */
-   set_tex_rect_source(i830,
-                       srcOffset,
-                       screen->width,
-                       screen->height,
-                       srcPitch,
-                       textureFormat);
-
-   enable_texture_blend_replace(i830);
-
-   /*
-    * loop over the source window's cliprects
-    */
-   for (i = 0; i < numClipRects; i++) {
-      int srcX0 = clipRects[i].x1;
-      int srcY0 = clipRects[i].y1;
-      int srcX1 = clipRects[i].x2;
-      int srcY1 = clipRects[i].y2;
-      GLfloat verts[4][2], tex[4][2];
-      int j;
-
-      /* build vertices for four corners of clip rect */
-      verts[0][0] = srcX0;  verts[0][1] = srcY0;
-      verts[1][0] = srcX1;  verts[1][1] = srcY0;
-      verts[2][0] = srcX1;  verts[2][1] = srcY1;
-      verts[3][0] = srcX0;  verts[3][1] = srcY1;
-
-      /* .. and texcoords */
-      tex[0][0] = srcX0;  tex[0][1] = srcY0;
-      tex[1][0] = srcX1;  tex[1][1] = srcY0;
-      tex[2][0] = srcX1;  tex[2][1] = srcY1;
-      tex[3][0] = srcX0;  tex[3][1] = srcY1;
-
-      /* transform coords to rotated screen coords */
-
-      for (j = 0; j < 4; j++) {
-         matrix23TransformCoordf(&screen->rotMatrix,
-                                 &verts[j][0], &verts[j][1]);
-      }
-
-      /* draw polygon to map source image to dest region */
-      draw_poly(i830, 255, 255, 255, 255, 4, verts, tex);
-
-   } /* cliprect loop */
-
-   intelFlushBatchLocked( intel, GL_FALSE, GL_FALSE, GL_FALSE );
-
- done:
-   /* restore original drawing origin and cliprects */
-   intel->drawX = xOrig;
-   intel->drawY = yOrig;
-   intel->numClipRects = origNumClipRects;
-   intel->pClipRects = origRects;
-
-   UNLOCK_HARDWARE(intel);
-
-   SET_STATE( i830, state );
+   i830->intel.vtbl.install_meta_state = install_meta_state;
+   i830->intel.vtbl.leave_meta_state = leave_meta_state;
+   i830->intel.vtbl.meta_no_depth_write = set_no_depth_write;
+   i830->intel.vtbl.meta_no_stencil_write = set_no_stencil_write;
+   i830->intel.vtbl.meta_stencil_replace = set_stencil_replace;
+   i830->intel.vtbl.meta_depth_replace = set_depth_replace;
+   i830->intel.vtbl.meta_color_mask = set_color_mask;
+   i830->intel.vtbl.meta_no_texture = set_no_texture;
+   i830->intel.vtbl.meta_texture_blend_replace = set_texture_blend_replace;
+   i830->intel.vtbl.meta_tex_rect_source = set_tex_rect_source;
+   i830->intel.vtbl.meta_draw_region = meta_draw_region;
+   i830->intel.vtbl.meta_import_pixel_state = meta_import_pixel_state;
 }
-
index 98cee2f214ceb2a130d94ab6191932e937aff9c7..d210c2d08e4aa6b0c55250174fa634fd2ac7078d 100644 (file)
 #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 STENCIL_TEST_MASK(x)           (((x)&0xff)<<8)
 #define MODE4_ENABLE_STENCIL_WRITE_MASK        ((1<<16)|(0x00ff))
 #define ENABLE_STENCIL_WRITE_MASK      (1<<16)
 #define STENCIL_WRITE_MASK(x)          ((x)&0xff)
 #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    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_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_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_I8                     (0<<3)       /* SURFACE_8BIT */
 #define    MT_8BIT_L8                     (1<<3)
-#define    MT_16BIT_RGB565                (0<<3) /* SURFACE_16BIT */
+#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_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_ARGB8888              (0<<3)       /* SURFACE_32BIT */
 #define    MT_32BIT_ABGR8888              (1<<3)
+#define    MT_32BIT_XRGB8888              (2<<3)       /* XXX: Guess from i915_reg.h */
 #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_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_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 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
index f7980201f9a790ca922a5ef51ace61b29065f970..e44a7dfca1f41d19c763a1e92aac97dccef679f1 100644 (file)
 
 #include "intel_screen.h"
 #include "intel_batchbuffer.h"
+#include "intel_fbo.h"
 
 #include "i830_context.h"
 #include "i830_reg.h"
 
+#define FILE_DEBUG_FLAG DEBUG_STATE
+
 static void
-i830StencilFuncSeparate(GLcontext *ctx, GLenum face, GLenum func, GLint ref,
+i830StencilFuncSeparate(GLcontext * ctx, GLenum face, GLenum func, GLint ref,
                         GLuint mask)
 {
-   i830ContextPtr i830 = I830_CONTEXT(ctx);
+   struct i830_context *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);
+   DBG("%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));
+                                           STENCIL_TEST_MASK(mask));
    i830->state.Ctx[I830_CTXREG_STENCILTST] &= ~(STENCIL_REF_VALUE_MASK |
-                                            ENABLE_STENCIL_TEST_FUNC_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));
+                                               ENABLE_STENCIL_TEST_FUNC |
+                                               STENCIL_REF_VALUE(ref) |
+                                               STENCIL_TEST_FUNC(test));
 }
 
 static void
-i830StencilMaskSeparate(GLcontext *ctx, GLenum face, GLuint mask)
+i830StencilMaskSeparate(GLcontext * ctx, GLenum face, GLuint mask)
 {
-   i830ContextPtr i830 = I830_CONTEXT(ctx);
-
-   if (INTEL_DEBUG&DEBUG_DRI)
-      fprintf(stderr, "%s : mask 0x%x\n", __FUNCTION__, mask);
+   struct i830_context *i830 = i830_context(ctx);
 
+   DBG("%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));
+                                           STENCIL_WRITE_MASK(mask));
 }
 
 static void
-i830StencilOpSeparate(GLcontext *ctx, GLenum face, GLenum fail, GLenum zfail,
+i830StencilOpSeparate(GLcontext * ctx, GLenum face, GLenum fail, GLenum zfail,
                       GLenum zpass)
 {
-   i830ContextPtr i830 = I830_CONTEXT(ctx);
+   struct i830_context *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));
+   DBG("%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;
+   fop = 0;
+   dfop = 0;
+   dpop = 0;
 
-   switch(fail) {
-   case GL_KEEP: 
-      fop = STENCILOP_KEEP; 
+   switch (fail) {
+   case GL_KEEP:
+      fop = STENCILOP_KEEP;
       break;
-   case GL_ZERO: 
-      fop = STENCILOP_ZERO; 
+   case GL_ZERO:
+      fop = STENCILOP_ZERO;
       break;
-   case GL_REPLACE: 
-      fop = STENCILOP_REPLACE; 
+   case GL_REPLACE:
+      fop = STENCILOP_REPLACE;
       break;
-   case GL_INCR: 
+   case GL_INCR:
       fop = STENCILOP_INCRSAT;
       break;
-   case GL_DECR: 
+   case GL_DECR:
       fop = STENCILOP_DECRSAT;
       break;
    case GL_INCR_WRAP:
-      fop = STENCILOP_INCR; 
+      fop = STENCILOP_INCR;
       break;
    case GL_DECR_WRAP:
-      fop = STENCILOP_DECR; 
+      fop = STENCILOP_DECR;
       break;
-   case GL_INVERT: 
-      fop = STENCILOP_INVERT; 
+   case GL_INVERT:
+      fop = STENCILOP_INVERT;
       break;
-   default: 
+   default:
       break;
    }
-   switch(zfail) {
-   case GL_KEEP: 
-      dfop = STENCILOP_KEEP; 
+   switch (zfail) {
+   case GL_KEEP:
+      dfop = STENCILOP_KEEP;
       break;
-   case GL_ZERO: 
-      dfop = STENCILOP_ZERO; 
+   case GL_ZERO:
+      dfop = STENCILOP_ZERO;
       break;
-   case GL_REPLACE: 
-      dfop = STENCILOP_REPLACE; 
+   case GL_REPLACE:
+      dfop = STENCILOP_REPLACE;
       break;
-   case GL_INCR: 
+   case GL_INCR:
       dfop = STENCILOP_INCRSAT;
       break;
-   case GL_DECR: 
+   case GL_DECR:
       dfop = STENCILOP_DECRSAT;
       break;
    case GL_INCR_WRAP:
-      dfop = STENCILOP_INCR; 
+      dfop = STENCILOP_INCR;
       break;
    case GL_DECR_WRAP:
-      dfop = STENCILOP_DECR; 
+      dfop = STENCILOP_DECR;
       break;
-   case GL_INVERT: 
-      dfop = STENCILOP_INVERT; 
+   case GL_INVERT:
+      dfop = STENCILOP_INVERT;
       break;
-   default: 
+   default:
       break;
    }
-   switch(zpass) {
-   case GL_KEEP: 
-      dpop = STENCILOP_KEEP; 
+   switch (zpass) {
+   case GL_KEEP:
+      dpop = STENCILOP_KEEP;
       break;
-   case GL_ZERO: 
-      dpop = STENCILOP_ZERO; 
+   case GL_ZERO:
+      dpop = STENCILOP_ZERO;
       break;
-   case GL_REPLACE: 
-      dpop = STENCILOP_REPLACE; 
+   case GL_REPLACE:
+      dpop = STENCILOP_REPLACE;
       break;
-   case GL_INCR: 
+   case GL_INCR:
       dpop = STENCILOP_INCRSAT;
       break;
-   case GL_DECR: 
+   case GL_DECR:
       dpop = STENCILOP_DECRSAT;
       break;
    case GL_INCR_WRAP:
-      dpop = STENCILOP_INCR; 
+      dpop = STENCILOP_INCR;
       break;
    case GL_DECR_WRAP:
-      dpop = STENCILOP_DECR; 
+      dpop = STENCILOP_DECR;
       break;
-   case GL_INVERT: 
-      dpop = STENCILOP_INVERT; 
+   case GL_INVERT:
+      dpop = STENCILOP_INVERT;
       break;
-   default: 
+   default:
       break;
    }
 
@@ -188,27 +190,30 @@ i830StencilOpSeparate(GLcontext *ctx, GLenum face, GLenum fail, GLenum zfail,
    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));
+                                               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)
+static void
+i830AlphaFunc(GLcontext * ctx, GLenum func, GLfloat ref)
 {
-   i830ContextPtr i830 = I830_CONTEXT(ctx);
+   struct i830_context *i830 = i830_context(ctx);
    int test = intel_translate_compare_func(func);
    GLubyte refByte;
    GLuint refInt;
 
    UNCLAMPED_FLOAT_TO_UBYTE(refByte, ref);
-   refInt = (GLuint)refByte;
+   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));
+                                           ENABLE_ALPHA_REF_VALUE |
+                                           ALPHA_TEST_FUNC(test) |
+                                           ALPHA_REF_VALUE(refInt));
 }
 
 /**
@@ -221,45 +226,49 @@ static void i830AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref)
  * This function is substantially different from the old i830-specific driver.
  * I'm not sure which is correct.
  */
-static void i830EvalLogicOpBlendState(GLcontext *ctx)
+static void
+i830EvalLogicOpBlendState(GLcontext * ctx)
 {
-   i830ContextPtr i830 = I830_CONTEXT(ctx);
+   struct i830_context *i830 = i830_context(ctx);
 
    I830_STATECHANGE(i830, I830_UPLOAD_CTX);
 
    if (RGBA_LOGICOP_ENABLED(ctx)) {
       i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~(ENABLE_COLOR_BLEND |
-                                              ENABLE_LOGIC_OP_MASK);
+                                                  ENABLE_LOGIC_OP_MASK);
       i830->state.Ctx[I830_CTXREG_ENABLES_1] |= (DISABLE_COLOR_BLEND |
-                                             ENABLE_LOGIC_OP);
-   } else if (ctx->Color.BlendEnabled) {
+                                                 ENABLE_LOGIC_OP);
+   }
+   else if (ctx->Color.BlendEnabled) {
       i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~(ENABLE_COLOR_BLEND |
-                                              ENABLE_LOGIC_OP_MASK);
+                                                  ENABLE_LOGIC_OP_MASK);
       i830->state.Ctx[I830_CTXREG_ENABLES_1] |= (ENABLE_COLOR_BLEND |
-                                             DISABLE_LOGIC_OP);
-   } else {
+                                                 DISABLE_LOGIC_OP);
+   }
+   else {
       i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~(ENABLE_COLOR_BLEND |
-                                              ENABLE_LOGIC_OP_MASK);
+                                                  ENABLE_LOGIC_OP_MASK);
       i830->state.Ctx[I830_CTXREG_ENABLES_1] |= (DISABLE_COLOR_BLEND |
-                                             DISABLE_LOGIC_OP);
+                                                 DISABLE_LOGIC_OP);
    }
 }
 
-static void i830BlendColor(GLcontext *ctx, const GLfloat color[4])
+static void
+i830BlendColor(GLcontext * ctx, const GLfloat color[4])
 {
-   i830ContextPtr i830 = I830_CONTEXT(ctx);
+   struct i830_context *i830 = i830_context(ctx);
    GLubyte r, g, b, a;
 
-   if (INTEL_DEBUG&DEBUG_DRI)
-      fprintf(stderr, "%s\n", __FUNCTION__);
-
+   DBG("%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;
+   i830->state.Ctx[I830_CTXREG_BLENDCOLOR1] =
+      (a << 24) | (r << 16) | (g << 8) | b;
 }
 
 /**
@@ -268,9 +277,10 @@ static void i830BlendColor(GLcontext *ctx, const GLfloat color[4])
  * 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 )
+static void
+i830_set_blend_state(GLcontext * ctx)
 {
-   i830ContextPtr i830 = I830_CONTEXT(ctx);
+   struct i830_context *i830 = i830_context(ctx);
    int funcA;
    int funcRGB;
    int eqnA;
@@ -279,71 +289,72 @@ static void i830_set_blend_state( GLcontext * ctx )
    int s1;
 
 
-   funcRGB = SRC_BLND_FACT( intel_translate_blend_factor( ctx->Color.BlendSrcRGB ) )
-       | DST_BLND_FACT( intel_translate_blend_factor( ctx->Color.BlendDstRGB ) );
+   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) {
+   switch (ctx->Color.BlendEquationRGB) {
    case GL_FUNC_ADD:
-      eqnRGB = BLENDFUNC_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: 
+   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; 
+   case GL_FUNC_SUBTRACT:
+      eqnRGB = BLENDFUNC_SUB;
       break;
    case GL_FUNC_REVERSE_SUBTRACT:
-      eqnRGB = BLENDFUNC_RVRSE_SUB; 
+      eqnRGB = BLENDFUNC_RVRSE_SUB;
       break;
    default:
-      fprintf( stderr, "[%s:%u] Invalid RGB blend equation (0x%04x).\n",
-              __FUNCTION__, __LINE__, ctx->Color.BlendEquationRGB );
+      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 ) );
+   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) {
+   switch (ctx->Color.BlendEquationA) {
    case GL_FUNC_ADD:
-      eqnA = BLENDFUNC_ADD; 
+      eqnA = BLENDFUNC_ADD;
       break;
-   case GL_MIN: 
+   case GL_MIN:
       eqnA = BLENDFUNC_MIN;
       funcA = SRC_BLND_FACT(BLENDFACT_ONE) | DST_BLND_FACT(BLENDFACT_ONE);
       break;
-   case GL_MAX: 
+   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; 
+   case GL_FUNC_SUBTRACT:
+      eqnA = BLENDFUNC_SUB;
       break;
    case GL_FUNC_REVERSE_SUBTRACT:
-      eqnA = BLENDFUNC_RVRSE_SUB; 
+      eqnA = BLENDFUNC_RVRSE_SUB;
       break;
    default:
-      fprintf( stderr, "[%s:%u] Invalid alpha blend equation (0x%04x).\n",
-              __FUNCTION__, __LINE__, ctx->Color.BlendEquationA );
+      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;
+      | _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;
+      | _3DSTATE_MODES_1_CMD
+      | ENABLE_SRC_BLND_FACTOR | ENABLE_DST_BLND_FACTOR
+      | ENABLE_COLR_BLND_FUNC;
 
-   if ( (eqnA | funcA) != (eqnRGB | funcRGB) )
+   if ((eqnA | funcA) != (eqnRGB | funcRGB))
       iab |= ENABLE_INDPT_ALPHA_BLEND;
    else
       iab |= DISABLE_INDPT_ALPHA_BLEND;
@@ -363,70 +374,68 @@ static void i830_set_blend_state( GLcontext * ctx )
    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");
+      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) 
+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));
+   DBG("%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 );
+   i830_set_blend_state(ctx);
 }
 
 
-static void i830BlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB, 
-                                 GLenum dfactorRGB, GLenum sfactorA,
-                                 GLenum dfactorA )
+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));
+   DBG("%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 );
+   i830_set_blend_state(ctx);
 }
 
 
 
-static void i830DepthFunc(GLcontext *ctx, GLenum func)
+static void
+i830DepthFunc(GLcontext * ctx, GLenum func)
 {
-   i830ContextPtr i830 = I830_CONTEXT(ctx);
+   struct i830_context *i830 = i830_context(ctx);
    int test = intel_translate_compare_func(func);
 
-   if (INTEL_DEBUG&DEBUG_DRI)
-      fprintf(stderr, "%s\n", __FUNCTION__);
-
+   DBG("%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));
+                                           DEPTH_TEST_FUNC(test));
 }
 
-static void i830DepthMask(GLcontext *ctx, GLboolean flag)
+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);
+   struct i830_context *i830 = i830_context(ctx);
 
+   DBG("%s flag (%d)\n", __FUNCTION__, flag);
+   
    I830_STATECHANGE(i830, I830_UPLOAD_CTX);
 
    i830->state.Ctx[I830_CTXREG_ENABLES_2] &= ~ENABLE_DIS_DEPTH_WRITE_MASK;
@@ -443,14 +452,15 @@ static void i830DepthMask(GLcontext *ctx, GLboolean flag)
  * 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 )
+static void
+i830PolygonStipple(GLcontext * ctx, const GLubyte * mask)
 {
-   i830ContextPtr i830 = I830_CONTEXT(ctx);
+   struct i830_context *i830 = i830_context(ctx);
    const GLubyte *m = mask;
    GLubyte p[4];
-   int i,j,k;
+   int i, j, k;
    int active = (ctx->Polygon.StippleFlag &&
-                i830->intel.reduced_primitive == GL_TRIANGLES);
+                 i830->intel.reduced_primitive == GL_TRIANGLES);
    GLuint newMask;
 
    if (active) {
@@ -458,23 +468,26 @@ static void i830PolygonStipple( GLcontext *ctx, const GLubyte *mask )
       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;
-           }
+   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));
+              ((p[1] & 0xf) << 4) |
+              ((p[2] & 0xf) << 8) | ((p[3] & 0xf) << 12));
 
 
    if (newMask == 0xffff || newMask == 0x0) {
@@ -495,49 +508,54 @@ static void i830PolygonStipple( GLcontext *ctx, const GLubyte *mask )
 /* =============================================================
  * Hardware clipping
  */
-static void i830Scissor(GLcontext *ctx, GLint x, GLint y, 
-                       GLsizei w, GLsizei h)
+static void
+i830Scissor(GLcontext * ctx, GLint x, GLint y, GLsizei w, GLsizei h)
 {
-   i830ContextPtr i830 = I830_CONTEXT(ctx);
-   intelScreenPrivate *screen = i830->intel.intelScreen;
+   struct i830_context *i830 = i830_context(ctx);
    int x1, y1, x2, y2;
 
-   if (!i830->intel.driDrawable)
+   if (!ctx->DrawBuffer)
       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);
+   DBG("%s %d,%d %dx%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;
+   if (ctx->DrawBuffer->Name == 0) {
+      x1 = x;
+      y1 = ctx->DrawBuffer->Height - (y + h);
+      x2 = x + w - 1;
+      y2 = y1 + h - 1;
+      DBG("%s %d..%d,%d..%d (inverted)\n", __FUNCTION__, x1, x2, y1, y2);
+   }
+   else {
+      /* FBO - not inverted
+       */
+      x1 = x;
+      y1 = y;
+      x2 = x + w - 1;
+      y2 = y + h - 1;
+      DBG("%s %d..%d,%d..%d (not inverted)\n", __FUNCTION__, x1, x2, y1, y2);
+   }
 
+   x1 = CLAMP(x1, 0, ctx->DrawBuffer->Width - 1);
+   y1 = CLAMP(y1, 0, ctx->DrawBuffer->Height - 1);
+   x2 = CLAMP(x2, 0, ctx->DrawBuffer->Width - 1);
+   y2 = CLAMP(y2, 0, ctx->DrawBuffer->Height - 1);
+   
+   DBG("%s %d..%d,%d..%d (clamped)\n", __FUNCTION__, x1, x2, y1, y2);
 
    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)
+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__);
+   struct i830_context *i830 = i830_context(ctx);
+   int tmp = intel_translate_logic_op(opcode);
 
+   DBG("%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);
@@ -545,14 +563,14 @@ static void i830LogicOp(GLcontext *ctx, GLenum opcode)
 
 
 
-static void i830CullFaceFrontFace(GLcontext *ctx, GLenum unused)
+static void
+i830CullFaceFrontFace(GLcontext * ctx, GLenum unused)
 {
-   i830ContextPtr i830 = I830_CONTEXT(ctx);
+   struct i830_context *i830 = i830_context(ctx);
    GLuint mode;
 
-   if (INTEL_DEBUG&DEBUG_DRI)
-      fprintf(stderr, "%s\n", __FUNCTION__);
-
+   DBG("%s\n", __FUNCTION__);
+   
    if (!ctx->Polygon.CullFlag) {
       mode = CULLMODE_NONE;
    }
@@ -560,9 +578,9 @@ static void i830CullFaceFrontFace(GLcontext *ctx, GLenum unused)
       mode = CULLMODE_CW;
 
       if (ctx->Polygon.CullFaceMode == GL_FRONT)
-        mode ^= (CULLMODE_CW ^ CULLMODE_CCW);
+         mode ^= (CULLMODE_CW ^ CULLMODE_CCW);
       if (ctx->Polygon.FrontFace != GL_CCW)
-        mode ^= (CULLMODE_CW ^ CULLMODE_CCW);
+         mode ^= (CULLMODE_CW ^ CULLMODE_CCW);
    }
    else {
       mode = CULLMODE_BOTH;
@@ -573,18 +591,18 @@ static void i830CullFaceFrontFace(GLcontext *ctx, GLenum unused)
    i830->state.Ctx[I830_CTXREG_STATE3] |= ENABLE_CULL_MODE | mode;
 }
 
-static void i830LineWidth( GLcontext *ctx, GLfloat widthf )
+static void
+i830LineWidth(GLcontext * ctx, GLfloat widthf)
 {
-   i830ContextPtr i830 = I830_CONTEXT( ctx );
+   struct i830_context *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);
+   DBG("%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));
 
@@ -594,19 +612,19 @@ static void i830LineWidth( GLcontext *ctx, GLfloat widthf )
    }
 }
 
-static void i830PointSize(GLcontext *ctx, GLfloat size)
+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__);
+   struct i830_context *i830 = i830_context(ctx);
+   GLint point_size = (int) size;
 
+   DBG("%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));
+                                           FIXED_POINT_WIDTH(point_size));
 }
 
 
@@ -614,23 +632,21 @@ static void i830PointSize(GLcontext *ctx, GLfloat size)
  * Color masks
  */
 
-static void i830ColorMask(GLcontext *ctx,
-                         GLboolean r, GLboolean g,
-                         GLboolean b, GLboolean a)
+static void
+i830ColorMask(GLcontext * ctx,
+              GLboolean r, GLboolean g, GLboolean b, GLboolean a)
 {
-   i830ContextPtr i830 = I830_CONTEXT( ctx );
+   struct i830_context *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);
+   DBG("%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));
+          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);
@@ -638,9 +654,10 @@ static void i830ColorMask(GLcontext *ctx,
    }
 }
 
-static void update_specular( GLcontext *ctx )
+static void
+update_specular(GLcontext * ctx)
 {
-   i830ContextPtr i830 = I830_CONTEXT( ctx );
+   struct i830_context *i830 = i830_context(ctx);
 
    I830_STATECHANGE(i830, I830_UPLOAD_CTX);
    i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_SPEC_ADD_MASK;
@@ -651,22 +668,22 @@ static void update_specular( GLcontext *ctx )
       i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_SPEC_ADD;
 }
 
-static void i830LightModelfv(GLcontext *ctx, GLenum pname, 
-                            const GLfloat *param)
+static void
+i830LightModelfv(GLcontext * ctx, GLenum pname, const GLfloat * param)
 {
-   if (INTEL_DEBUG&DEBUG_DRI)
-      fprintf(stderr, "%s\n", __FUNCTION__);
-
+   DBG("%s\n", __FUNCTION__);
+   
    if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) {
-      update_specular( ctx );
+      update_specular(ctx);
    }
 }
 
 /* In Mesa 3.5 we can reliably do native flatshading.
  */
-static void i830ShadeModel(GLcontext *ctx, GLenum mode)
+static void
+i830ShadeModel(GLcontext * ctx, GLenum mode)
 {
-   i830ContextPtr i830 = I830_CONTEXT(ctx);
+   struct i830_context *i830 = i830_context(ctx);
    I830_STATECHANGE(i830, I830_UPLOAD_CTX);
 
 
@@ -675,58 +692,62 @@ static void i830ShadeModel(GLcontext *ctx, GLenum mode)
    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));
+      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)
+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__);
+   struct i830_context *i830 = i830_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));
+   DBG("%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);
+      i830->state.Ctx[I830_CTXREG_FOGCOLOR] =
+         (_3DSTATE_FOG_COLOR_CMD | color);
    }
 }
 
 /* =============================================================
  */
 
-static void i830Enable(GLcontext *ctx, GLenum cap, GLboolean state)
+static void
+i830Enable(GLcontext * ctx, GLenum cap, GLboolean state)
 {
-   i830ContextPtr i830 = I830_CONTEXT(ctx);
+   struct i830_context *i830 = i830_context(ctx);
 
-   switch(cap) {
+   switch (cap) {
    case GL_LIGHTING:
    case GL_COLOR_SUM:
-      update_specular( ctx );
+      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;
+         i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_ALPHA_TEST;
       else
-        i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_ALPHA_TEST;
+         i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_ALPHA_TEST;
 
       break;
 
@@ -739,18 +760,18 @@ static void i830Enable(GLcontext *ctx, GLenum cap, GLboolean state)
 
       /* Logicop doesn't seem to work at 16bpp:
        */
-      if (i830->intel.intelScreen->cpp == 2)
-        FALLBACK( &i830->intel, I830_FALLBACK_LOGICOP, state );
+      if (i830->intel.ctx.Visual.rgbBits == 16)
+         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;
+         i830->state.Ctx[I830_CTXREG_ENABLES_2] |= ENABLE_DITHER;
       else
-        i830->state.Ctx[I830_CTXREG_ENABLES_2] |= DISABLE_DITHER;
+         i830->state.Ctx[I830_CTXREG_ENABLES_2] |= DISABLE_DITHER;
       break;
 
    case GL_DEPTH_TEST:
@@ -758,46 +779,44 @@ static void i830Enable(GLcontext *ctx, GLenum cap, GLboolean state)
       i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_DIS_DEPTH_TEST_MASK;
 
       if (state)
-        i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_DEPTH_TEST;
+         i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_DEPTH_TEST;
       else
-        i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_DEPTH_TEST;
+         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 );
+      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);
+         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);
+         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;
+         i830->state.Ctx[I830_CTXREG_AA] |= AA_LINE_ENABLE;
       else
-        i830->state.Ctx[I830_CTXREG_AA] |= AA_LINE_DISABLE;
+         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;
+         i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_FOG;
       else
-        i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_FOG;
+         i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_FOG;
       break;
 
    case GL_CULL_FACE:
@@ -808,20 +827,32 @@ static void i830Enable(GLcontext *ctx, GLenum cap, GLboolean state)
       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 );
+      {
+         GLboolean hw_stencil = GL_FALSE;
+         if (ctx->DrawBuffer) {
+            struct intel_renderbuffer *irbStencil
+               = intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_STENCIL);
+            hw_stencil = (irbStencil && irbStencil->region);
+         }
+         if (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;
 
@@ -830,13 +861,12 @@ static void i830Enable(GLcontext *ctx, GLenum cap, GLboolean state)
        * 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;
+      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;
 
@@ -846,206 +876,172 @@ static void i830Enable(GLcontext *ctx, GLenum cap, GLboolean state)
 }
 
 
-static void i830_init_packets( i830ContextPtr i830 )
+static void
+i830_init_packets(struct i830_context *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);
+                                 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);
+                                 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);
+                                 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);
+                                 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_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);
+                                      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);
-
+                                             DISABLE_LOGIC_OP |
+                                             DISABLE_STENCIL_TEST |
+                                             DISABLE_DEPTH_BIAS |
+                                             DISABLE_SPEC_ADD |
+                                             DISABLE_FOG |
+                                             DISABLE_ALPHA_TEST |
+                                             DISABLE_COLOR_BLEND |
+                                             DISABLE_DEPTH_TEST);
+
+#if 000                         /* XXX all the stencil enable state is set in i830Enable(), right? */
    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 {
+                                                ENABLE_STENCIL_WRITE |
+                                                ENABLE_TEX_CACHE |
+                                                ENABLE_DITHER |
+                                                ENABLE_COLOR_MASK |
+                                                /* set no color comps disabled */
+                                                ENABLE_COLOR_WRITE |
+                                                ENABLE_DEPTH_WRITE);
+   }
+   else
+#endif
+   {
       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);
+                                                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) );
+                                          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) );
+                                          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);
+                                          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));
+                                          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) );
+                                              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);
+                                           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));
+                                            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->front.pitch) |  /* pitch in bytes */
-       BUF_3D_USE_FENCE);
+                                         TEXBIND_SET2(TEXCOORDSRC_VTXSET_2) |
+                                         TEXBIND_SET1(TEXCOORDSRC_VTXSET_1) |
+                                         TEXBIND_SET0(TEXCOORDSRC_VTXSET_0));
 
 
-   i830->state.Buffer[I830_DESTREG_DBUFADDR0] = _3DSTATE_BUF_INFO_CMD;
-   i830->state.Buffer[I830_DESTREG_DBUFADDR1] = 
-      (BUF_3D_ID_DEPTH |
-       BUF_3D_PITCH(screen->depth.pitch) |  /* pitch in bytes */
-       BUF_3D_USE_FENCE);
-   i830->state.Buffer[I830_DESTREG_DBUFADDR2] = screen->depth.offset;
-
+   i830->state.Stipple[I830_STPREG_ST0] = _3DSTATE_STIPPLE;
 
    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);
+                                               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 )
+void
+i830InitStateFuncs(struct dd_function_table *functions)
 {
    functions->AlphaFunc = i830AlphaFunc;
    functions->BlendColor = i830BlendColor;
@@ -1070,20 +1066,21 @@ void i830InitStateFuncs( struct dd_function_table *functions )
    functions->StencilOpSeparate = i830StencilOpSeparate;
 }
 
-void i830InitState( i830ContextPtr i830 )
+void
+i830InitState(struct i830_context *i830)
 {
    GLcontext *ctx = &i830->intel.ctx;
 
-   i830_init_packets( i830 );
+   i830_init_packets(i830);
 
    _mesa_init_driver_state(ctx);
 
-   memcpy( &i830->initial, &i830->state, sizeof(i830->state) );
+   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);
+   i830->state.active = (I830_UPLOAD_INVARIENT |
+                         I830_UPLOAD_TEXBLEND(0) |
+                         I830_UPLOAD_STIPPLE |
+                         I830_UPLOAD_CTX | I830_UPLOAD_BUFFERS);
 }
index 3c4aedb35cbd0f21daaca74fdfe88b38c496b238..c0126ba19a4635e0bfd32c7adef9684c3db496ff 100644 (file)
 
 #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)
+static void
+i830TexEnv(GLcontext * ctx, GLenum target,
+           GLenum pname, const GLfloat * param)
 {
-   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_COLOR:
    case GL_TEXTURE_ENV_MODE:
    case GL_COMBINE_RGB:
    case GL_COMBINE_ALPHA:
@@ -319,38 +69,32 @@ static void i830TexEnv( GLcontext *ctx, GLenum target,
    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;
-   }
+   case GL_TEXTURE_LOD_BIAS:{
+         struct i830_context *i830 = i830_context(ctx);
+         GLuint unit = ctx->Texture.CurrentUnit;
+         int b = (int) ((*param) * 16.0);
+         if (b > 63)
+            b = 63;
+         if (b < -64)
+            b = -64;
+         I830_STATECHANGE(i830, I830_UPLOAD_TEX(unit));
+         i830->lodbias_tm0s3[unit] =
+            ((b << TM0S3_LOD_BIAS_SHIFT) & TM0S3_LOD_BIAS_MASK);
+         break;
+      }
 
    default:
       break;
    }
 }
 
-static void i830BindTexture( GLcontext *ctx, GLenum target,
-                           struct gl_texture_object *texObj )
-{
-   i830TextureObjectPtr tex;
-   
-   if (!texObj->DriverData)
-      i830AllocTexObj( texObj );
-   
-   tex = (i830TextureObjectPtr)texObj->DriverData;
-}
 
 
 
-void i830InitTextureFuncs( struct dd_function_table *functions )
+void
+i830InitTextureFuncs(struct dd_function_table *functions)
 {
-   functions->BindTexture              = i830BindTexture;
-   functions->TexEnv                    = i830TexEnv;
-   functions->TexParameter              = i830TexParameter;
+/*
+   functions->TexEnv = i830TexEnv;
+*/
 }
index 49e0347643c02cbcfdc4adfc32af5fea66740579..dca72adecadaed35d9fd9573ded140cfaf59e930 100644 (file)
@@ -36,7 +36,6 @@
 #include "mm.h"
 
 #include "intel_screen.h"
-#include "intel_ioctl.h"
 #include "intel_tex.h"
 
 #include "i830_context.h"
 /* ================================================================
  * Texture combine functions
  */
-static GLuint pass_through( GLuint *state, GLuint blendUnit )
+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);
+               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);
+               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);
+               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);
+               TEXPIPE_ALPHA |
+               TEXBLEND_ARG1 |
+               TEXBLENDARG_MODIFY_PARMS | TEXBLENDARG_CURRENT);
 
    return 4;
 }
 
-static GLuint emit_factor( GLuint blendUnit, GLuint *state, GLuint count, 
-                          const GLfloat *factor )
+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]);
+              blendUnit, factor[0], factor[1], factor[2], factor[3]);
 
    UNCLAMPED_FLOAT_TO_UBYTE(r, factor[0]);
    UNCLAMPED_FLOAT_TO_UBYTE(g, factor[1]);
@@ -94,21 +89,27 @@ static GLuint emit_factor( GLuint blendUnit, GLuint *state, GLuint count,
 
    col = ((a << 24) | (r << 16) | (g << 8) | b);
 
-   state[count++] = _3DSTATE_COLOR_FACTOR_N_CMD(blendUnit); 
+   state[count++] = _3DSTATE_COLOR_FACTOR_N_CMD(blendUnit);
    state[count++] = col;
 
    return count;
 }
 
 
-static __inline__ GLuint GetTexelOp(GLint unit)
+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;
+   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;
    }
 }
 
@@ -132,12 +133,10 @@ static __inline__ GLuint GetTexelOp(GLint unit)
  * 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 )
+i830SetTexEnvCombine(struct i830_context * 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;
@@ -162,7 +161,7 @@ i830SetTexEnvCombine(i830ContextPtr i830,
       TEXPIPE_ALPHA | TEXBLEND_ARG0 | TEXBLENDARG_MODIFY_PARMS,
    };
 
-   if(INTEL_DEBUG&DEBUG_TEXTURE)
+   if (INTEL_DEBUG & DEBUG_TEXTURE)
       fprintf(stderr, "%s\n", __FUNCTION__);
 
 
@@ -188,23 +187,23 @@ i830SetTexEnvCombine(i830ContextPtr i830,
    }
 
 
-   switch(combine->ModeRGB) {
-   case GL_REPLACE: 
+   switch (combine->ModeRGB) {
+   case GL_REPLACE:
       blendop = TEXBLENDOP_ARG1;
       break;
-   case GL_MODULATE: 
+   case GL_MODULATE:
       blendop = TEXBLENDOP_MODULATE;
       break;
-   case GL_ADD: 
+   case GL_ADD:
       blendop = TEXBLENDOP_ADD;
       break;
    case GL_ADD_SIGNED:
-      blendop = TEXBLENDOP_ADDSIGNED; 
+      blendop = TEXBLENDOP_ADDSIGNED;
       break;
    case GL_INTERPOLATE:
-      blendop = TEXBLENDOP_BLEND; 
+      blendop = TEXBLENDOP_BLEND;
       break;
-   case GL_SUBTRACT: 
+   case GL_SUBTRACT:
       blendop = TEXBLENDOP_SUBTRACT;
       break;
    case GL_DOT3_RGB_EXT:
@@ -215,55 +214,54 @@ i830SetTexEnvCombine(i830ContextPtr i830,
    case GL_DOT3_RGBA:
       blendop = TEXBLENDOP_DOT3;
       break;
-   default: 
-      return pass_through( state, blendUnit );
+   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;
+   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;
+         args_RGB[i] = GetTexelOp(combine->SourceRGB[i] - GL_TEXTURE0);
+         break;
       case GL_CONSTANT:
-        args_RGB[i] = TEXBLENDARG_FACTOR_N; 
-        need_factor = 1;
-        break;
+         args_RGB[i] = TEXBLENDARG_FACTOR_N;
+         need_factor = 1;
+         break;
       case GL_PRIMARY_COLOR:
-        args_RGB[i] = TEXBLENDARG_DIFFUSE;
-        break;
+         args_RGB[i] = TEXBLENDARG_DIFFUSE;
+         break;
       case GL_PREVIOUS:
-        args_RGB[i] = TEXBLENDARG_CURRENT; 
-        break;
-      default: 
-        return pass_through( state, blendUnit );
+         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 );
+      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);
       }
    }
 
@@ -275,76 +273,76 @@ i830SetTexEnvCombine(i830ContextPtr i830,
     * 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 ) {
+   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[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;
+      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;
+         ablendop = TEXBLENDOP_ADDSIGNED;
+         break;
       case GL_INTERPOLATE:
-        ablendop = TEXBLENDOP_BLEND; 
-        break;
-      case GL_SUBTRACT: 
-        ablendop = TEXBLENDOP_SUBTRACT;
-        break;
+         ablendop = TEXBLENDOP_BLEND;
+         break;
+      case GL_SUBTRACT:
+         ablendop = TEXBLENDOP_SUBTRACT;
+         break;
       default:
-        return pass_through( state, blendUnit );
+         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 );
-        }
+      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);
+         }
       }
    }
 
@@ -363,86 +361,86 @@ i830SetTexEnvCombine(i830ContextPtr i830,
 
    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);
+                    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);
+                    TEXPIPE_ALPHA |
+                    ENABLE_TEXOUTPUT_WRT_SEL |
+                    TEXOP_OUTPUT_CURRENT | TEXOP_MODIFY_PARMS | ablendop);
 
-   for ( i = 0 ; i < numColorArgs ; i++ ) {
+   for (i = 0; i < numColorArgs; i++) {
       state[used++] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                      tex_blend_rgb[i] | args_RGB[i]);
+                       tex_blend_rgb[i] | args_RGB[i]);
    }
 
-   for ( i = 0 ; i < numAlphaArgs ; i++ ) {
+   for (i = 0; i < numAlphaArgs; i++) {
       state[used++] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
-                      tex_blend_a[i] | args_A[i]);
+                       tex_blend_a[i] | args_A[i]);
    }
 
 
-   if (need_factor) 
-      return emit_factor( blendUnit, state, used, factor );
-   else 
+   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 )
+static void
+emit_texblend(struct i830_context *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);
+   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 );
+    */
+   tmp_sz = i830SetTexEnvCombine(i830, texUnit->_CurrentCombine, blendUnit,
+                                 GetTexelOp(unit), tmp, texUnit->EnvColor);
 
-   if (last_stage) 
+   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));
+       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 )
+static void
+emit_passthrough(struct i830_context *i830)
 {
    GLuint tmp[I830_TEXBLEND_SIZE], tmp_sz;
    GLuint unit = 0;
 
-   tmp_sz = pass_through( tmp, unit );
+   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));
+       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 )
+void
+i830EmitTextureBlend(struct i830_context *i830)
 {
    GLcontext *ctx = &i830->intel.ctx;
    GLuint unit, last_stage = 0, blendunit = 0;
@@ -450,16 +448,15 @@ void i830EmitTextureBlend( i830ContextPtr i830 )
    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)
+            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 );
+      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 );
+      emit_passthrough(i830);
    }
 }
-
index ba972dac8f176b1d4b2023f338c42a8abeb5fd7a..314bbe32b65d0bda069c4d01d8830a2f33dde085 100644 (file)
  * 
  **************************************************************************/
 
-#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_mipmap_tree.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 )
+static GLuint
+translate_texture_format(GLuint mesa_format)
 {
-   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 ) {
+   switch (mesa_format) {
    case MESA_FORMAT_L8:
-      t->intel.texelBytes = 1;
-      textureFormat = MAPSURF_8BIT | MT_8BIT_L8;
-      break;
-
+      return MAPSURF_8BIT | MT_8BIT_L8;
    case MESA_FORMAT_I8:
-      t->intel.texelBytes = 1;
-      textureFormat = MAPSURF_8BIT | MT_8BIT_I8;
-      break;
-
+      return MAPSURF_8BIT | MT_8BIT_I8;
    case MESA_FORMAT_A8:
-      t->intel.texelBytes = 1;
-      textureFormat = MAPSURF_8BIT | MT_8BIT_I8; /* Kludge -- check with conform, glean */
-      break;
-
+      return MAPSURF_8BIT | MT_8BIT_I8; /* Kludge! */
    case MESA_FORMAT_AL88:
-      t->intel.texelBytes = 2;
-      textureFormat = MAPSURF_16BIT | MT_16BIT_AY88;
-      break;
-
+      return MAPSURF_16BIT | MT_16BIT_AY88;
    case MESA_FORMAT_RGB565:
-      t->intel.texelBytes = 2;
-      textureFormat = MAPSURF_16BIT | MT_16BIT_RGB565;
-      break;
-
+      return MAPSURF_16BIT | MT_16BIT_RGB565;
    case MESA_FORMAT_ARGB1555:
-      t->intel.texelBytes = 2;
-      textureFormat = MAPSURF_16BIT | MT_16BIT_ARGB1555;
-      break;
-
+      return MAPSURF_16BIT | MT_16BIT_ARGB1555;
    case MESA_FORMAT_ARGB4444:
-      t->intel.texelBytes = 2;
-      textureFormat = MAPSURF_16BIT | MT_16BIT_ARGB4444;
-      break;
-
+      return MAPSURF_16BIT | MT_16BIT_ARGB4444;
    case MESA_FORMAT_ARGB8888:
-      t->intel.texelBytes = 4;
-      textureFormat = MAPSURF_32BIT | MT_32BIT_ARGB8888;
-      break;
-
+      return MAPSURF_32BIT | MT_32BIT_ARGB8888;
    case MESA_FORMAT_YCBCR_REV:
-      t->intel.texelBytes = 2;
-      textureFormat = (MAPSURF_422 | MT_422_YCRCB_NORMAL | 
-                      TM0S1_COLORSPACE_CONVERSION);
-      break;
-
+      return (MAPSURF_422 | MT_422_YCRCB_NORMAL);
    case MESA_FORMAT_YCBCR:
-      t->intel.texelBytes = 2;
-      textureFormat = (MAPSURF_422 | MT_422_YCRCB_SWAPY | /* ??? */
-                      TM0S1_COLORSPACE_CONVERSION);
-      break;
-
+      return (MAPSURF_422 | MT_422_YCRCB_SWAPY);
    case MESA_FORMAT_RGB_FXT1:
    case MESA_FORMAT_RGBA_FXT1:
-     t->intel.texelBytes = 2;
-     textureFormat = MAPSURF_COMPRESSED | MT_COMPRESS_FXT1;
-     break;
-
+      return (MAPSURF_COMPRESSED | MT_COMPRESS_FXT1);
    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;
+      return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT1);
    case MESA_FORMAT_RGBA_DXT3:
-     t->intel.texelBytes = 4;
-     textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_DXT2_3);
-     break;
+      return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT2_3);
    case MESA_FORMAT_RGBA_DXT5:
-     t->intel.texelBytes = 4;
-     textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5);
-     break;
-
+      return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5);
    default:
-      fprintf(stderr, "%s: bad image format\n", __FUNCTION__);
+      fprintf(stderr, "%s: bad image format %x\n", __FUNCTION__, mesa_format);
       abort();
+      return 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.
-    */
-   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->_BaseFormat;
-
-           d >>= 1;
-           x += step_offsets[face][0] * d;
-           y += step_offsets[face][1] * d;
-        }
-      }
-      break;
-   }
+/* 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:
+   case GL_CLAMP_TO_EDGE:
+      return TEXCOORDMODE_CLAMP;        /* not really correct */
+   case GL_CLAMP_TO_BORDER:
+      return TEXCOORDMODE_CLAMP_BORDER;
+   case GL_MIRRORED_REPEAT:
+      return TEXCOORDMODE_MIRROR;
    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->_BaseFormat;
-        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;
+      return TEXCOORDMODE_WRAP;
    }
-
-   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 )
+/* Recalculate all state from scratch.  Perhaps not the most
+ * efficient, but this has gotten complex enough that we need
+ * something which is understandable and reliable.
+ */
+static GLboolean
+i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
 {
-   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);
-}
-
+   GLcontext *ctx = &intel->ctx;
+   struct i830_context *i830 = i830_context(ctx);
+   struct gl_texture_unit *tUnit = &ctx->Texture.Unit[unit];
+   struct gl_texture_object *tObj = tUnit->_Current;
+   struct intel_texture_object *intelObj = intel_texture_object(tObj);
+   struct gl_texture_image *firstImage;
+   GLuint *state = i830->state.Tex[unit], format, pitch;
+   GLint lodbias;
 
+   memset(state, 0, sizeof(state));
 
-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;
+   /*We need to refcount these. */
 
-   if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+   if (i830->state.tex_buffer[unit] != NULL) {
+       dri_bo_unreference(i830->state.tex_buffer[unit]);
+       i830->state.tex_buffer[unit] = NULL;
+   }
 
-   /* Fallback if there's a texture border */
-   if ( tObj->Image[0][tObj->BaseLevel]->Border > 0 ) {
-      fprintf(stderr, "Texture border\n");
+   if (!intelObj->imageOverride && !intel_finalize_mipmap_tree(intel, unit))
       return GL_FALSE;
-   }
 
-   /* Upload teximages (not pipelined)
+   /* Get first image here, since intelObj->firstLevel will get set in
+    * the intel_finalize_mipmap_tree() call above.
     */
-   if (t->intel.base.dirty_images[0]) {
-      if (!i830SetTexImages( i830, tObj )) {
-        return GL_FALSE;
+   firstImage = tObj->Image[0][intelObj->firstLevel];
+
+   if (intelObj->imageOverride) {
+      i830->state.tex_buffer[unit] = NULL;
+      i830->state.tex_offset[unit] = intelObj->textureOffset;
+
+      switch (intelObj->depthOverride) {
+      case 32:
+        format = MAPSURF_32BIT | MT_32BIT_ARGB8888;
+        break;
+      case 24:
+      default:
+        format = MAPSURF_32BIT | MT_32BIT_XRGB8888;
+        break;
+      case 16:
+        format = MAPSURF_16BIT | MT_16BIT_RGB565;
+        break;
       }
-   }
-
-   /* 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;
+      pitch = intelObj->pitchOverride;
+   } else {
+      dri_bo_reference(intelObj->mt->region->buffer);
+      i830->state.tex_buffer[unit] = intelObj->mt->region->buffer;
+      i830->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt,
+                                                               0, intelObj->
+                                                               firstLevel);
 
-   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;
+      format = translate_texture_format(firstImage->TexFormat->MesaFormat);
+      pitch = intelObj->mt->pitch * intelObj->mt->cpp;
    }
 
-   return GL_TRUE;
-}
+   state[I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
+                               (LOAD_TEXTURE_MAP0 << unit) | 4);
 
+/*    state[I830_TEXREG_TM0S0] = (TM0S0_USE_FENCE | */
+/*                            t->intel.TextureOffset); */
 
-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;
+   state[I830_TEXREG_TM0S1] =
+      (((firstImage->Height - 1) << TM0S1_HEIGHT_SHIFT) |
+       ((firstImage->Width - 1) << TM0S1_WIDTH_SHIFT) | format);
+
+   state[I830_TEXREG_TM0S2] =
+      ((((pitch / 4) - 1) << TM0S2_PITCH_SHIFT) | TM0S2_CUBE_FACE_ENA_MASK);
 
-   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;
+   {
+      if (tObj->Target == GL_TEXTURE_CUBE_MAP)
+         state[I830_TEXREG_CUBE] = (_3DSTATE_MAP_CUBE | MAP_UNIT(unit) |
+                                    CUBE_NEGX_ENABLE |
+                                    CUBE_POSX_ENABLE |
+                                    CUBE_NEGY_ENABLE |
+                                    CUBE_POSY_ENABLE |
+                                    CUBE_NEGZ_ENABLE | CUBE_POSZ_ENABLE);
+      else
+         state[I830_TEXREG_CUBE] = (_3DSTATE_MAP_CUBE | MAP_UNIT(unit));
    }
 
-   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;
-        }
+   {
+      GLuint minFilt, mipFilt, magFilt;
+
+      switch (tObj->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:
+         return GL_FALSE;
       }
-   }
-
 
-   return GL_TRUE;
-}
+      if (tObj->MaxAnisotropy > 1.0) {
+         minFilt = FILTER_ANISOTROPIC;
+         magFilt = FILTER_ANISOTROPIC;
+      }
+      else {
+         switch (tObj->MagFilter) {
+         case GL_NEAREST:
+            magFilt = FILTER_NEAREST;
+            break;
+         case GL_LINEAR:
+            magFilt = FILTER_LINEAR;
+            break;
+         default:
+            return GL_FALSE;
+         }
+      }
 
+      lodbias = (int) ((tUnit->LodBias + tObj->LodBias) * 16.0);
+      if (lodbias < -64)
+          lodbias = -64;
+      if (lodbias > 63)
+          lodbias = 63;
+      
+      state[I830_TEXREG_TM0S3] = ((lodbias << TM0S3_LOD_BIAS_SHIFT) & 
+                                  TM0S3_LOD_BIAS_MASK);
+#if 0
+      /* YUV conversion:
+       */
+      if (firstImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR ||
+          firstImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR_REV)
+         state[I830_TEXREG_TM0S3] |= SS2_COLORSPACE_CONVERSION;
+#endif
+
+      state[I830_TEXREG_TM0S3] |= ((intelObj->lastLevel -
+                                    intelObj->firstLevel) *
+                                   4) << TM0S3_MIN_MIP_SHIFT;
+
+      state[I830_TEXREG_TM0S3] |= ((minFilt << TM0S3_MIN_FILTER_SHIFT) |
+                                   (mipFilt << TM0S3_MIP_FILTER_SHIFT) |
+                                   (magFilt << TM0S3_MAG_FILTER_SHIFT));
+   }
 
-static GLboolean disable_tex( GLcontext *ctx, GLuint unit )
-{
-   i830ContextPtr i830 = I830_CONTEXT(ctx);
+   {
+      GLenum ws = tObj->WrapS;
+      GLenum wt = tObj->WrapT;
 
-   /* 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.
+      /* 3D textures not available on i830
        */
-
-      i830->intel.CurrentTexObj[unit]->base.bound &= ~(1U << 0);
-      i830->intel.CurrentTexObj[unit] = NULL;
+      if (tObj->Target == GL_TEXTURE_3D)
+         return GL_FALSE;
+
+      state[I830_TEXREG_MCS] = (_3DSTATE_MAP_COORD_SET_CMD |
+                                MAP_UNIT(unit) |
+                                ENABLE_TEXCOORD_PARAMS |
+                                ss3 |
+                                ENABLE_ADDR_V_CNTL |
+                                TEXCOORD_ADDR_V_MODE(translate_wrap_mode(wt))
+                                | ENABLE_ADDR_U_CNTL |
+                                TEXCOORD_ADDR_U_MODE(translate_wrap_mode
+                                                     (ws)));
    }
 
-   return GL_TRUE;
-}
 
-static GLboolean i830UpdateTexUnit( GLcontext *ctx, GLuint unit )
-{
-   struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+   state[I830_TEXREG_TM0S4] = INTEL_PACKCOLOR8888(tObj->_BorderChan[0],
+                                                  tObj->_BorderChan[1],
+                                                  tObj->_BorderChan[2],
+                                                  tObj->_BorderChan[3]);
 
-   if (texUnit->_ReallyEnabled &&
-       INTEL_CONTEXT(ctx)->intelScreen->tex.size < 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;
-   }
+   I830_ACTIVESTATE(i830, I830_UPLOAD_TEX(unit), GL_TRUE);
+   /* memcmp was already disabled, but definitely won't work as the
+    * region might now change and that wouldn't be detected:
+    */
+   I830_STATECHANGE(i830, I830_UPLOAD_TEX(unit));
+   return GL_TRUE;
 }
 
 
-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 ));
+void
+i830UpdateTextureState(struct intel_context *intel)
+{
+   struct i830_context *i830 = i830_context(&intel->ctx);
+   GLboolean ok = GL_TRUE;
+   GLuint i;
+
+   for (i = 0; i < I830_TEX_UNITS && ok; i++) {
+      switch (intel->ctx.Texture.Unit[i]._ReallyEnabled) {
+      case TEXTURE_1D_BIT:
+      case TEXTURE_2D_BIT:
+      case TEXTURE_CUBE_BIT:
+         ok = i830_update_tex_unit(intel, i, TEXCOORDS_ARE_NORMAL);
+         break;
+      case TEXTURE_RECT_BIT:
+         ok = i830_update_tex_unit(intel, i, TEXCOORDS_ARE_IN_TEXELUNITS);
+         break;
+      case 0:{
+        struct i830_context *i830 = i830_context(&intel->ctx);
+         if (i830->state.active & I830_UPLOAD_TEX(i)) 
+            I830_ACTIVESTATE(i830, I830_UPLOAD_TEX(i), GL_FALSE);
+
+        if (i830->state.tex_buffer[i] != NULL) {
+           dri_bo_unreference(i830->state.tex_buffer[i]);
+           i830->state.tex_buffer[i] = NULL;
+        }
+         break;
+      }
+      case TEXTURE_3D_BIT:
+      default:
+         ok = GL_FALSE;
+         break;
+      }
+   }
 
-   FALLBACK( intel, I830_FALLBACK_TEXTURE, !ok );
+   FALLBACK(intel, I830_FALLBACK_TEXTURE, !ok);
 
    if (ok)
-      i830EmitTextureBlend( i830 );
+      i830EmitTextureBlend(i830);
 }
-
-
-
index d40cf705a354bd127ac8dd979383d0d0b227a1b6..40a50ff772fa977d96d8a5e92be5cf6e646020aa 100644 (file)
  * 
  **************************************************************************/
 
+#include "glapi.h"
 
 #include "i830_context.h"
 #include "i830_reg.h"
-
 #include "intel_batchbuffer.h"
-
+#include "intel_regions.h"
+#include "intel_tris.h"
 #include "tnl/t_context.h"
 #include "tnl/t_vertex.h"
 
-static GLboolean i830_check_vertex_size( intelContextPtr intel,
-                                        GLuint expected );
+#define FILE_DEBUG_FLAG DEBUG_STATE
+
+static GLboolean i830_check_vertex_size(struct intel_context *intel,
+                                        GLuint expected);
 
 #define SZ_TO_HW(sz)  ((sz-2)&0x3)
 #define EMIT_SZ(sz)   (EMIT_1F + (sz) - 1)
@@ -59,10 +62,16 @@ do {                                                                        \
 #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 )
+static void
+i830_render_prevalidate(struct intel_context *intel)
+{
+}
+
+static void
+i830_render_start(struct intel_context *intel)
 {
    GLcontext *ctx = &intel->ctx;
-   i830ContextPtr i830 = I830_CONTEXT(intel);
+   struct i830_context *i830 = i830_context(ctx);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct vertex_buffer *VB = &tnl->vb;
    DECLARE_RENDERINPUTS(index_bitset);
@@ -70,7 +79,7 @@ static void i830_render_start( intelContextPtr intel )
    GLuint v2 = _3DSTATE_VFT1_CMD;
    GLuint mcsb1 = 0;
 
-   RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset );
+   RENDERINPUTS_COPY(index_bitset, tnl->render_inputs_bitset);
 
    /* Important:
     */
@@ -80,196 +89,215 @@ static void i830_render_start( intelContextPtr intel )
    /* EMIT_ATTR's must be in order as they tell t_vertex.c how to
     * build up a hardware vertex.
     */
-   if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) {
-      EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, VFT0_XYZW );
+   if (RENDERINPUTS_TEST_RANGE(index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX)) {
+      EMIT_ATTR(_TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, VFT0_XYZW);
       intel->coloroffset = 4;
    }
    else {
-      EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, VFT0_XYZ );
+      EMIT_ATTR(_TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, VFT0_XYZ);
       intel->coloroffset = 3;
    }
 
-   if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POINTSIZE )) {
-      EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F, VFT0_POINT_WIDTH );
+   if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_POINTSIZE)) {
+      EMIT_ATTR(_TNL_ATTRIB_POINTSIZE, EMIT_1F, VFT0_POINT_WIDTH);
    }
 
-   EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, VFT0_DIFFUSE );
-      
+   EMIT_ATTR(_TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, VFT0_DIFFUSE);
+
    intel->specoffset = 0;
-   if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 ) ||
-       RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) {
-      if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) {
+   if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_COLOR1) ||
+       RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_FOG)) {
+      if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_COLOR1)) {
          intel->specoffset = intel->coloroffset + 1;
-         EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, VFT0_SPEC );
+         EMIT_ATTR(_TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, VFT0_SPEC);
       }
       else
-         EMIT_PAD( 3 );
+         EMIT_PAD(3);
 
-      if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG ))
-         EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, VFT0_SPEC );
+      if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_FOG))
+         EMIT_ATTR(_TNL_ATTRIB_FOG, EMIT_1UB_1F, VFT0_SPEC);
       else
-         EMIT_PAD( 1 );
+         EMIT_PAD(1);
    }
 
-   if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) {
+   if (RENDERINPUTS_TEST_RANGE(index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX)) {
       int i, count = 0;
 
       for (i = 0; i < I830_TEX_UNITS; i++) {
-         if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(i) )) {
+         if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_TEX(i))) {
             GLuint sz = VB->TexCoordPtr[i]->size;
             GLuint emit;
-            GLuint mcs = (i830->state.Tex[i][I830_TEXREG_MCS] & 
+            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++;
-        }
+            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] ||
-       !RENDERINPUTS_EQUAL( index_bitset, i830->last_index_bitset )) {
-    
-      I830_STATECHANGE( i830, I830_UPLOAD_CTX );
+       !RENDERINPUTS_EQUAL(index_bitset, i830->last_index_bitset)) {
+      int k;
+
+      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 =
+         _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;
-      RENDERINPUTS_COPY( i830->last_index_bitset, index_bitset );
+      RENDERINPUTS_COPY(i830->last_index_bitset, index_bitset);
 
-      assert(i830_check_vertex_size( intel, intel->vertex_size ));
+      k = i830_check_vertex_size(intel, intel->vertex_size);
+      assert(k);
    }
 }
 
-static void i830_reduced_primitive_state( intelContextPtr intel,
-                                         GLenum rprim )
+static void
+i830_reduced_primitive_state(struct intel_context *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;
-    }
+   struct i830_context *i830 = i830_context(&intel->ctx);
+   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]) {
+      INTEL_FIREVERTICES(intel);
+
+      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 )
+static GLboolean
+i830_check_vertex_size(struct intel_context *intel, GLuint expected)
 {
-   i830ContextPtr i830 = I830_CONTEXT(intel);
+   struct i830_context *i830 = i830_context(&intel->ctx);
    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: 
+   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++) { 
+   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;
+      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) 
+
+   if (sz != expected)
       fprintf(stderr, "vertex size mismatch %d/%d\n", sz, expected);
-   
+
    return sz == expected;
 }
 
-static void i830_emit_invarient_state( intelContextPtr intel )
+static void
+i830_emit_invarient_state(struct intel_context *intel)
 {
    BATCH_LOCALS;
 
-   BEGIN_BATCH( 40 );
-
-   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));
+   BEGIN_BATCH(40, IGNORE_CLIPRECTS);
 
    OUT_BATCH(_3DSTATE_DFLT_DIFFUSE_CMD);
    OUT_BATCH(0);
@@ -282,37 +310,35 @@ static void i830_emit_invarient_state( intelContextPtr intel )
 
    OUT_BATCH(_3DSTATE_FOG_MODE_CMD);
    OUT_BATCH(FOGFUNC_ENABLE |
-            FOG_LINEAR_CONST | 
-            FOGSRC_INDEX_Z | 
-            ENABLE_FOG_DENSITY);
+             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));
+             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));
+             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));
+             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));
+             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));
@@ -324,21 +350,13 @@ static void i830_emit_invarient_state( intelContextPtr intel )
    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);
+             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_VERTEX_TRANSFORM);
    OUT_BATCH(DISABLE_VIEWPORT_TRANSFORM | DISABLE_PERSPECTIVE_DIVIDE);
@@ -349,45 +367,46 @@ static void i830_emit_invarient_state( intelContextPtr intel )
 
 
    OUT_BATCH(_3DSTATE_COLOR_FACTOR_CMD);
-   OUT_BATCH(0x80808080);      /* .5 required in alpha for GL_DOT3_RGBA_EXT */
+   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);
-
-static GLuint get_state_size( struct i830_hw_state *state )
+   intel_batchbuffer_data(intel->batch, state, size, IGNORE_CLIPRECTS )
+
+static GLuint
+get_dirty(struct i830_hw_state *state)
+{
+   return state->active & ~state->emitted;
+}
+
+static GLuint
+get_state_size(struct i830_hw_state *state)
 {
-   GLuint dirty = state->active & ~state->emitted;
+   GLuint dirty = get_dirty(state);
    GLuint sz = 0;
    GLuint i;
 
    if (dirty & I830_UPLOAD_INVARIENT)
       sz += 40 * sizeof(int);
 
-   if (dirty & I830_UPLOAD_CTX) 
+   if (dirty & I830_UPLOAD_CTX)
       sz += sizeof(state->Ctx);
 
-   if (dirty & I830_UPLOAD_BUFFERS) 
+   if (dirty & I830_UPLOAD_BUFFERS)
       sz += sizeof(state->Buffer);
 
-   if (dirty & I830_UPLOAD_STIPPLE) 
+   if (dirty & I830_UPLOAD_STIPPLE)
       sz += sizeof(state->Stipple);
 
    for (i = 0; i < I830_TEX_UNITS; i++) {
-      if ((dirty & I830_UPLOAD_TEX(i)))  
-        sz += sizeof(state->Tex[i]); 
+      if ((dirty & I830_UPLOAD_TEX(i)))
+         sz += sizeof(state->Tex[i]);
 
-      if (dirty & I830_UPLOAD_TEXBLEND(i)) 
-        sz += state->TexBlendWordsUsed[i] * 4;
+      if (dirty & I830_UPLOAD_TEXBLEND(i))
+         sz += state->TexBlendWordsUsed[i] * 4;
    }
 
    return sz;
@@ -396,139 +415,312 @@ static GLuint get_state_size( struct i830_hw_state *state )
 
 /* Push the state into the sarea and/or texture memory.
  */
-static void i830_emit_state( intelContextPtr intel )
+static void
+i830_emit_state(struct intel_context *intel)
 {
-   i830ContextPtr i830 = I830_CONTEXT(intel);
+   struct i830_context *i830 = i830_context(&intel->ctx);
    struct i830_hw_state *state = i830->current;
-   int i;
-   GLuint dirty = state->active & ~state->emitted;
-   GLuint counter = intel->batch.counter;
+   int i, count;
+   GLuint dirty;
+   GET_CURRENT_CONTEXT(ctx);
    BATCH_LOCALS;
+   dri_bo *aper_array[3 + I830_TEX_UNITS];
+   int aper_count;
+
+   /* We don't hold the lock at this point, so want to make sure that
+    * there won't be a buffer wrap between the state emits and the primitive
+    * emit header.
+    *
+    * It might be better to talk about explicit places where
+    * scheduling is allowed, rather than assume that it is whenever a
+    * batchbuffer fills up.
+    *
+    * Set the space as LOOP_CLIPRECTS now, since that's what our primitives
+    * will be emitted under.
+    */
+   intel_batchbuffer_require_space(intel->batch,
+                                  get_state_size(state) + INTEL_PRIM_EMIT_SIZE,
+                                  LOOP_CLIPRECTS);
+   count = 0;
+ again:
+   aper_count = 0;
+   dirty = get_dirty(state);
+
+   aper_array[aper_count++] = intel->batch->buf;
+   if (dirty & I830_UPLOAD_BUFFERS) {
+      aper_array[aper_count++] = state->draw_region->buffer;
+      aper_array[aper_count++] = state->depth_region->buffer;
+   }
 
-   if (intel->batch.space < get_state_size(state)) {
-      intelFlushBatch(intel, GL_TRUE);
-      dirty = state->active & ~state->emitted;
-      counter = intel->batch.counter;
+   for (i = 0; i < I830_TEX_UNITS; i++)
+     if (dirty & I830_UPLOAD_TEX(i)) {
+       if (state->tex_buffer[i]) {
+          aper_array[aper_count++] = state->tex_buffer[i];
+       }
+     }
+
+   if (dri_bufmgr_check_aperture_space(aper_array, aper_count)) {
+       if (count == 0) {
+          count++;
+          intel_batchbuffer_flush(intel->batch);
+          goto again;
+       } else {
+          _mesa_error(ctx, GL_OUT_OF_MEMORY, "i830 emit state");
+          assert(0);
+       }
    }
 
+
+   /* Do this here as we may have flushed the batchbuffer above,
+    * causing more state to be dirty!
+    */
+   dirty = get_dirty(state);
+   state->emitted |= dirty;
+   assert(get_dirty(state) == 0);
+
    if (dirty & I830_UPLOAD_INVARIENT) {
-      if (VERBOSE) fprintf(stderr, "I830_UPLOAD_INVARIENT:\n"); 
-      i830_emit_invarient_state( intel );
+      DBG("I830_UPLOAD_INVARIENT:\n");
+      i830_emit_invarient_state(intel);
    }
 
    if (dirty & I830_UPLOAD_CTX) {
-      if (VERBOSE) fprintf(stderr, "I830_UPLOAD_CTX:\n"); 
-      emit( i830, state->Ctx, sizeof(state->Ctx) );
+      DBG("I830_UPLOAD_CTX:\n");
+      emit(intel, 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) );
-   }
+      DBG("I830_UPLOAD_BUFFERS:\n");
+      BEGIN_BATCH(I830_DEST_SETUP_SIZE + 2, IGNORE_CLIPRECTS);
+      OUT_BATCH(state->Buffer[I830_DESTREG_CBUFADDR0]);
+      OUT_BATCH(state->Buffer[I830_DESTREG_CBUFADDR1]);
+      OUT_RELOC(state->draw_region->buffer,
+               I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
+                state->draw_region->draw_offset);
+
+      if (state->depth_region) {
+         OUT_BATCH(state->Buffer[I830_DESTREG_DBUFADDR0]);
+         OUT_BATCH(state->Buffer[I830_DESTREG_DBUFADDR1]);
+         OUT_RELOC(state->depth_region->buffer,
+                  I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
+                   state->depth_region->draw_offset);
+      }
 
+      OUT_BATCH(state->Buffer[I830_DESTREG_DV0]);
+      OUT_BATCH(state->Buffer[I830_DESTREG_DV1]);
+      OUT_BATCH(state->Buffer[I830_DESTREG_SENABLE]);
+      OUT_BATCH(state->Buffer[I830_DESTREG_SR0]);
+      OUT_BATCH(state->Buffer[I830_DESTREG_SR1]);
+      OUT_BATCH(state->Buffer[I830_DESTREG_SR2]);
+      ADVANCE_BATCH();
+   }
+   
    if (dirty & I830_UPLOAD_STIPPLE) {
-      if (VERBOSE) fprintf(stderr, "I830_UPLOAD_STIPPLE:\n"); 
-      emit( i830, state->Stipple, sizeof(state->Stipple) );
+      DBG("I830_UPLOAD_STIPPLE:\n");
+      emit(intel, 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_TEX(i))) {
+         DBG("I830_UPLOAD_TEX(%d):\n", i);
+
+         BEGIN_BATCH(I830_TEX_SETUP_SIZE + 1, IGNORE_CLIPRECTS);
+         OUT_BATCH(state->Tex[i][I830_TEXREG_TM0LI]);
+
+         if (state->tex_buffer[i]) {
+            OUT_RELOC(state->tex_buffer[i],
+                     I915_GEM_DOMAIN_SAMPLER, 0,
+                      state->tex_offset[i] | TM0S0_USE_FENCE);
+         }
+        else if (state == &i830->meta) {
+           assert(i == 0);
+           OUT_BATCH(0);
+        }
+        else {
+           OUT_BATCH(state->tex_offset[i]);
+        }
+
+         OUT_BATCH(state->Tex[i][I830_TEXREG_TM0S1]);
+         OUT_BATCH(state->Tex[i][I830_TEXREG_TM0S2]);
+         OUT_BATCH(state->Tex[i][I830_TEXREG_TM0S3]);
+         OUT_BATCH(state->Tex[i][I830_TEXREG_TM0S4]);
+         OUT_BATCH(state->Tex[i][I830_TEXREG_MCS]);
+         OUT_BATCH(state->Tex[i][I830_TEXREG_CUBE]);
+      }
 
       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 );
+         DBG("I830_UPLOAD_TEXBLEND(%d): %d words\n", i,
+             state->TexBlendWordsUsed[i]);
+         emit(intel, state->TexBlend[i], state->TexBlendWordsUsed[i] * 4);
       }
    }
 
-   state->emitted |= dirty;
-   intel->batch.last_emit_state = counter;
-   assert(counter == intel->batch.counter);
+   intel->batch->dirty_state &= ~dirty;
+   assert(get_dirty(state) == 0);
+   assert((intel->batch->dirty_state & (1<<1)) == 0);
 }
 
-static void i830_destroy_context( intelContextPtr intel )
+static void
+i830_destroy_context(struct intel_context *intel)
 {
+   GLuint i;
+   struct i830_context *i830 = i830_context(&intel->ctx);
+
+   for (i = 0; i < I830_TEX_UNITS; i++) {
+      if (i830->state.tex_buffer[i] != NULL) {
+        dri_bo_unreference(i830->state.tex_buffer[i]);
+        i830->state.tex_buffer[i] = NULL;
+      }
+   }
+
    _tnl_free_vertices(&intel->ctx);
 }
 
-static void
-i830_set_color_region(intelContextPtr intel, const intelRegion *region)
+
+void
+i830_state_draw_region(struct intel_context *intel,
+                      struct i830_hw_state *state,
+                      struct intel_region *color_region,
+                      struct intel_region *depth_region)
 {
-   i830ContextPtr i830 = I830_CONTEXT(intel);
-   I830_STATECHANGE( i830, I830_UPLOAD_BUFFERS );
-   i830->state.Buffer[I830_DESTREG_CBUFADDR1] =
-      (BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(region->pitch) | BUF_3D_USE_FENCE);
-   i830->state.Buffer[I830_DESTREG_CBUFADDR2] = region->offset;
+   struct i830_context *i830 = i830_context(&intel->ctx);
+   GLuint value;
+
+   ASSERT(state == &i830->state || state == &i830->meta);
+
+   if (state->draw_region != color_region) {
+      intel_region_release(&state->draw_region);
+      intel_region_reference(&state->draw_region, color_region);
+   }
+   if (state->depth_region != depth_region) {
+      intel_region_release(&state->depth_region);
+      intel_region_reference(&state->depth_region, depth_region);
+   }
+
+   /*
+    * Set stride/cpp values
+    */
+   if (color_region) {
+      state->Buffer[I830_DESTREG_CBUFADDR0] = _3DSTATE_BUF_INFO_CMD;
+      state->Buffer[I830_DESTREG_CBUFADDR1] =
+         (BUF_3D_ID_COLOR_BACK |
+          BUF_3D_PITCH(color_region->pitch * color_region->cpp) |
+          BUF_3D_USE_FENCE);
+   }
+
+   if (depth_region) {
+      state->Buffer[I830_DESTREG_DBUFADDR0] = _3DSTATE_BUF_INFO_CMD;
+      state->Buffer[I830_DESTREG_DBUFADDR1] =
+         (BUF_3D_ID_DEPTH |
+          BUF_3D_PITCH(depth_region->pitch * depth_region->cpp) |
+          BUF_3D_USE_FENCE);
+   }
+
+   /*
+    * Compute/set I830_DESTREG_DV1 value
+    */
+   value = (DSTORG_HORT_BIAS(0x8) |     /* .5 */
+            DSTORG_VERT_BIAS(0x8) | DEPTH_IS_Z);    /* .5 */
+            
+   if (color_region && color_region->cpp == 4) {
+      value |= DV_PF_8888;
+   }
+   else {
+      value |= DV_PF_565;
+   }
+   if (depth_region && depth_region->cpp == 4) {
+      value |= DEPTH_FRMT_24_FIXED_8_OTHER;
+   }
+   else {
+      value |= DEPTH_FRMT_16_FIXED;
+   }
+   state->Buffer[I830_DESTREG_DV1] = value;
+
+   I830_STATECHANGE(i830, I830_UPLOAD_BUFFERS);
+
+
 }
 
 
 static void
-i830_set_z_region(intelContextPtr intel, const intelRegion *region)
+i830_set_draw_region(struct intel_context *intel,
+                     struct intel_region *color_regions[],
+                     struct intel_region *depth_region,
+                    GLuint num_regions)
 {
-   i830ContextPtr i830 = I830_CONTEXT(intel);
-   I830_STATECHANGE( i830, I830_UPLOAD_BUFFERS );
-   i830->state.Buffer[I830_DESTREG_DBUFADDR1] =
-      (BUF_3D_ID_DEPTH | BUF_3D_PITCH(region->pitch) | BUF_3D_USE_FENCE);
-   i830->state.Buffer[I830_DESTREG_DBUFADDR2] = region->offset;
+   struct i830_context *i830 = i830_context(&intel->ctx);
+   i830_state_draw_region(intel, &i830->state, color_regions[0], depth_region);
 }
 
-
+#if 0
 static void
 i830_update_color_z_regions(intelContextPtr intel,
-                            const intelRegion *colorRegion,
-                            const intelRegion *depthRegion)
+                            const intelRegion * colorRegion,
+                            const intelRegion * depthRegion)
 {
    i830ContextPtr i830 = I830_CONTEXT(intel);
 
    i830->state.Buffer[I830_DESTREG_CBUFADDR1] =
-      (BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(colorRegion->pitch) | BUF_3D_USE_FENCE);
+      (BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(colorRegion->pitch) |
+       BUF_3D_USE_FENCE);
    i830->state.Buffer[I830_DESTREG_CBUFADDR2] = colorRegion->offset;
 
    i830->state.Buffer[I830_DESTREG_DBUFADDR1] =
       (BUF_3D_ID_DEPTH | BUF_3D_PITCH(depthRegion->pitch) | BUF_3D_USE_FENCE);
    i830->state.Buffer[I830_DESTREG_DBUFADDR2] = depthRegion->offset;
 }
+#endif
 
 
 /* This isn't really handled at the moment.
  */
-static void i830_lost_hardware( intelContextPtr intel )
+static void
+i830_new_batch(struct intel_context *intel)
 {
-   I830_CONTEXT(intel)->state.emitted = 0;
+   struct i830_context *i830 = i830_context(&intel->ctx);
+   i830->state.emitted = 0;
+
+   /* Check that we didn't just wrap our batchbuffer at a bad time. */
+   assert(!intel->no_batch_wrap);
 }
 
 
 
-static void i830_emit_flush( intelContextPtr intel )
+static GLuint
+i830_flush_cmd(void)
 {
-   BATCH_LOCALS;
-
-   BEGIN_BATCH(2);
-   OUT_BATCH( MI_FLUSH | FLUSH_MAP_CACHE ); 
-   OUT_BATCH( 0 );
-   ADVANCE_BATCH();
+   return MI_FLUSH | FLUSH_MAP_CACHE;
 }
 
 
+static void 
+i830_assert_not_dirty( struct intel_context *intel )
+{
+   struct i830_context *i830 = i830_context(&intel->ctx);
+   struct i830_hw_state *state = i830->current;
+   assert(!get_dirty(state));
+}
 
+static void
+i830_note_unlock( struct intel_context *intel )
+{
+    /* nothing */
+}
 
-void i830InitVtbl( i830ContextPtr i830 )
+void
+i830InitVtbl(struct i830_context *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.rotate_window = i830RotateWindow;
    i830->intel.vtbl.destroy = i830_destroy_context;
    i830->intel.vtbl.emit_state = i830_emit_state;
-   i830->intel.vtbl.lost_hardware = i830_lost_hardware;
+   i830->intel.vtbl.new_batch = i830_new_batch;
    i830->intel.vtbl.reduced_primitive_state = i830_reduced_primitive_state;
-   i830->intel.vtbl.set_color_region = i830_set_color_region;
-   i830->intel.vtbl.set_z_region = i830_set_z_region;
-   i830->intel.vtbl.update_color_z_regions = i830_update_color_z_regions;
+   i830->intel.vtbl.set_draw_region = i830_set_draw_region;
    i830->intel.vtbl.update_texture_state = i830UpdateTextureState;
-   i830->intel.vtbl.emit_flush = i830_emit_flush;
+   i830->intel.vtbl.flush_cmd = i830_flush_cmd;
    i830->intel.vtbl.render_start = i830_render_start;
+   i830->intel.vtbl.render_prevalidate = i830_render_prevalidate;
+   i830->intel.vtbl.assert_not_dirty = i830_assert_not_dirty;
+   i830->intel.vtbl.note_unlock = i830_note_unlock; 
+   i830->intel.vtbl.finish_batch = intel_finish_vb;
 }
index 2bc1cae9c317127a345b3687cab53fddece509a3..940b02513dae4f199ba97ef491c25f386b023901 100644 (file)
 #include "swrast/swrast.h"
 #include "swrast_setup/swrast_setup.h"
 #include "tnl/tnl.h"
-#include "vbo/vbo.h"
-
 
 #include "utils.h"
 #include "i915_reg.h"
 
+#include "intel_regions.h"
+#include "intel_batchbuffer.h"
+#include "intel_tris.h"
+#include "intel_span.h"
+#include "intel_pixel.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_ARB_texture_env_crossbar",       NULL },
-    { "GL_EXT_shadow_funcs",               NULL },
-    /* ARB extn won't work if not enabled */
-    { "GL_SGIX_depth_texture",             NULL },
-    { NULL,                                NULL }
+static const struct dri_extension i915_extensions[] = {
+   {"GL_ARB_depth_texture", NULL},
+   {"GL_ARB_fragment_program", NULL},
+   {"GL_ARB_shadow", NULL},
+   {"GL_ARB_texture_non_power_of_two", 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 )
+static void
+i915InvalidateState(GLcontext * ctx, GLuint new_state)
 {
-   _swrast_InvalidateState( ctx, new_state );
-   _swsetup_InvalidateState( ctx, new_state );
-   _vbo_InvalidateState( ctx, new_state );
-   _tnl_InvalidateState( ctx, new_state );
-   _tnl_invalidate_vertex_state( ctx, new_state );
-   INTEL_CONTEXT(ctx)->NewGLState |= new_state;
+   _swrast_InvalidateState(ctx, new_state);
+   _swsetup_InvalidateState(ctx, new_state);
+   _vbo_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;
+      struct i915_fragment_program *p =
+         (struct i915_fragment_program *) ctx->FragmentProgram._Current;
       if (p && p->nr_params)
-        p->params_uptodate = 0;
+         p->params_uptodate = 0;
    }
 
-   if (new_state & (_NEW_FOG|_NEW_HINT|_NEW_PROGRAM))
+   if (new_state & (_NEW_FOG | _NEW_HINT | _NEW_PROGRAM))
       i915_update_fog(ctx);
 }
 
 
-static void i915InitDriverFunctions( struct dd_function_table *functions )
+static void
+i915InitDriverFunctions(struct dd_function_table *functions)
 {
-   intelInitDriverFunctions( functions );
-   i915InitStateFunctions( functions );
-   i915InitTextureFuncs( functions );
-   i915InitFragProgFuncs( functions );
+   intelInitDriverFunctions(functions);
+   i915InitStateFunctions(functions);
+   i915InitTextureFuncs(functions);
+   i915InitFragProgFuncs(functions);
    functions->UpdateState = i915InvalidateState;
 }
 
 
+extern const struct tnl_pipeline_stage *intel_pipeline[];
 
-GLboolean i915CreateContext( const __GLcontextModes *mesaVis,
-                           __DRIcontextPrivate *driContextPriv,
-                           void *sharedContextPrivate)
+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;
+   struct i915_context *i915 =
+      (struct i915_context *) CALLOC_STRUCT(i915_context);
+   struct intel_context *intel = &i915->intel;
    GLcontext *ctx = &intel->ctx;
-   GLuint i;
 
-   if (!i915) return GL_FALSE;
+   if (!i915)
+      return GL_FALSE;
+
+   if (0)
+      _mesa_printf("\ntexmem-0-3 branch\n\n");
 
-   i915InitVtbl( i915 );
+   i915InitVtbl(i915);
+   i915InitMetaFuncs(i915);
 
-   i915InitDriverFunctions( &functions );
+   i915InitDriverFunctions(&functions);
 
-   if (!intelInitContext( intel, mesaVis, driContextPriv,
-                         sharedContextPrivate, &functions )) {
+   if (!intelInitContext(intel, mesaVis, driContextPriv,
+                         sharedContextPrivate, &functions)) {
       FREE(i915);
       return GL_FALSE;
    }
 
+   /* Initialize swrast, tnl driver tables: */
+   intelInitSpanFuncs(ctx);
+   intelInitTriFuncs(ctx);
+
+   /* Install the customized pipeline: */
+   _tnl_destroy_pipeline(ctx);
+   _tnl_install_pipeline(ctx, intel_pipeline);
+
+   if (intel->no_rast)
+      FALLBACK(intel, INTEL_FALLBACK_USER, 1);
+
    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->tex.size,
-                           12,
-                           I830_NR_TEX_REGIONS,
-                           intel->sarea->texList,
-                           (unsigned *) & 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.
+
+   /* Advertise the full hardware capabilities.  The new memory
+    * manager should cope much better with overload situations:
     */
+   ctx->Const.MaxTextureLevels = 12;
+   ctx->Const.Max3DTextureLevels = 9;
+   ctx->Const.MaxCubeTextureLevels = 12;
+   ctx->Const.MaxTextureRectSize = (1 << 11);
    ctx->Const.MaxTextureUnits = I915_TEX_UNITS;
-   i = driQueryOptioni( &intel->optionCache, "allow_large_textures");
-   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,
-                                i );
 
    /* 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.FragmentProgram.MaxNativeTemps = I915_MAX_TEMPORARY;
-   ctx->Const.FragmentProgram.MaxNativeAttribs = 11; /* 8 tex, 2 color, fog */
+   ctx->Const.FragmentProgram.MaxNativeAttribs = 11;    /* 8 tex, 2 color, fog */
    ctx->Const.FragmentProgram.MaxNativeParameters = I915_MAX_CONSTANT;
    ctx->Const.FragmentProgram.MaxNativeAluInstructions = I915_MAX_ALU_INSN;
    ctx->Const.FragmentProgram.MaxNativeTexInstructions = I915_MAX_TEX_INSN;
-   ctx->Const.FragmentProgram.MaxNativeInstructions = (I915_MAX_ALU_INSN + 
-                                               I915_MAX_TEX_INSN);
-   ctx->Const.FragmentProgram.MaxNativeTexIndirections = I915_MAX_TEX_INDIRECT;
+   ctx->Const.FragmentProgram.MaxNativeInstructions = (I915_MAX_ALU_INSN +
+                                                       I915_MAX_TEX_INSN);
+   ctx->Const.FragmentProgram.MaxNativeTexIndirections =
+      I915_MAX_TEX_INDIRECT;
    ctx->Const.FragmentProgram.MaxNativeAddressRegs = 0; /* I don't think we have one */
+
    ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
    ctx->FragmentProgram._UseTexEnvProgram = GL_TRUE;
 
-
-   driInitExtensions( ctx, i915_extensions, GL_FALSE );
+   driInitExtensions(ctx, i915_extensions, GL_FALSE);
 
 
-   _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12, 
-                      36 * sizeof(GLfloat) );
+   _tnl_init_vertices(ctx, ctx->Const.MaxArrayLockSize + 12,
+                      36 * sizeof(GLfloat));
 
    intel->verts = TNL_CONTEXT(ctx)->clipspace.vertex_buf;
 
-   i915InitState( i915 );
+   i915InitState(i915);
 
    return GL_TRUE;
 }
-
index ec1550126a6efb66b66cdc26d506814df8797735..c6958dd8d4be0a67707ab32b8fcf85e2f27d7d1d 100644 (file)
@@ -29,6 +29,7 @@
 #define I915CONTEXT_INC
 
 #include "intel_context.h"
+#include "i915_reg.h"
 
 #define I915_FALLBACK_TEXTURE           0x1000
 #define I915_FALLBACK_COLORMASK                 0x2000
@@ -46,6 +47,7 @@
 #define I915_UPLOAD_CONSTANTS        0x10
 #define I915_UPLOAD_FOG              0x20
 #define I915_UPLOAD_INVARIENT        0x40
+#define I915_UPLOAD_DEFAULTS         0x80
 #define I915_UPLOAD_TEX(i)           (0x00010000<<(i))
 #define I915_UPLOAD_TEX_ALL          (0x00ff0000)
 #define I915_UPLOAD_TEX_0_SHIFT      16
  */
 #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
@@ -89,7 +89,6 @@
 #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_SS4        5
 #define I915_TEX_SETUP_SIZE    6
 
+#define I915_DEFREG_C0    0
+#define I915_DEFREG_C1    1
+#define I915_DEFREG_S0    2
+#define I915_DEFREG_S1    3
+#define I915_DEFREG_Z0    4
+#define I915_DEFREG_Z1    5
+#define I915_DEF_SETUP_SIZE    6
+
+
 #define I915_MAX_CONSTANT      32
 #define I915_CONSTANT_SIZE     (2+(4*I915_MAX_CONSTANT))
 
 
 #define I915_PROGRAM_SIZE      192
 
+#define I915_MAX_INSN          (I915_MAX_TEX_INSN+I915_MAX_ALU_INSN)
 
 /* Hardware version of a parsed fragment program.  "Derived" from the
  * mesa fragment_program struct.
  */
-struct i915_fragment_program {
+struct i915_fragment_program
+{
    struct gl_fragment_program FragProg;
 
    GLboolean translated;
    GLboolean params_uptodate;
    GLboolean on_hardware;
-   GLboolean error;            /* If program is malformed for any reason. */
+   GLboolean error;             /* If program is malformed for any reason. */
 
    GLuint nr_tex_indirect;
    GLuint nr_tex_insn;
@@ -135,52 +145,40 @@ struct i915_fragment_program {
    GLuint constant_flags[I915_MAX_CONSTANT];
    GLuint nr_constants;
 
-   GLuint *csr;                        /* Cursor, points into program.
-                                */
+   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 *decl;                /* Cursor, points into declarations.
+                                 */
 
-   GLuint temp_flag;           /* Tracks temporary regs which are in
-                                * use.
-                                */
+   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 utemp_flag;          /* Tracks TYPE_U temporary regs which are in
-                                * use.
-                                */
+   GLuint temp_flag;            /* Tracks temporary regs which are in
+                                 * use.
+                                 */
 
+   GLuint utemp_flag;           /* Tracks TYPE_U temporary regs which are in
+                                 * use.
+                                 */
 
 
+   /* Track which R registers are "live" for each instruction.
+    * A register is live between the time it's written to and the last time
+    * it's read. */
+   GLuint usedRegs[I915_MAX_INSN];
+
    /* Helpers for i915_fragprog.c:
     */
    GLuint wpos_tex;
    GLboolean depth_written;
 
-   struct { 
-      GLuint reg;              /* Hardware constant idx */
-      const GLfloat *values;   /* Pointer to tracked values */
+   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;
 };
 
 
@@ -188,67 +186,68 @@ struct i915_fragment_program {
 
 
 
-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 {
+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 Defaults[I915_DEF_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_* */
+
+   /* Region pointers for relocation: 
+    */
+   struct intel_region *draw_region;
+   struct intel_region *depth_region;
+/*    struct intel_region *tex_region[I915_TEX_UNITS]; */
+
+   /* Regions aren't actually that appropriate here as the memory may
+    * be from a PBO or FBO.  Will have to do this for draw and depth for
+    * FBO's...
+    */
+   dri_bo *tex_buffer[I915_TEX_UNITS];
+   GLuint tex_offset[I915_TEX_UNITS];
+
+
+   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 i915_context
 {
    struct intel_context intel;
 
    GLuint last_ReallyEnabled;
    GLuint vertex_fog;
+   GLuint lodbias_ss2[MAX_TEXTURE_UNITS];
+
 
-   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);                          \
@@ -260,7 +259,13 @@ do {                                                               \
 /*======================================================================
  * i915_vtbl.c
  */
-extern void i915InitVtbl( i915ContextPtr i915 );
+extern void i915InitVtbl(struct i915_context *i915);
+
+extern void
+i915_state_draw_region(struct intel_context *intel,
+                       struct i915_hw_state *state,
+                       struct intel_region *color_region,
+                       struct intel_region *depth_region);
 
 
 
@@ -289,70 +294,58 @@ do {                                                                      \
 /*======================================================================
  * i915_context.c
  */
-extern GLboolean i915CreateContext( const __GLcontextModes *mesaVis,
-                                   __DRIcontextPrivate *driContextPriv,
-                                   void *sharedContextPrivate);
-
-
-/*======================================================================
- * i915_texprog.c
- */
-extern void i915ValidateTextureProgram( i915ContextPtr i915 );
+extern GLboolean i915CreateContext(const __GLcontextModes * mesaVis,
+                                   __DRIcontextPrivate * driContextPriv,
+                                   void *sharedContextPrivate);
 
 
 /*======================================================================
  * i915_debug.c
  */
-extern void i915_disassemble_program( const GLuint *program, GLuint sz );
-extern void i915_print_ureg( const char *msg, GLuint ureg );
+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 *ctxx);
+extern void i915InitStateFunctions(struct dd_function_table *functions);
+extern void i915InitState(struct i915_context *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 );
+extern void i915UpdateTextureState(struct intel_context *intel);
+extern void i915InitTextureFuncs(struct dd_function_table *functions);
 
 /*======================================================================
  * 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 );
+void i915InitMetaFuncs(struct i915_context *i915);
 
-extern void 
-i915ClearWithTris( intelContextPtr intel, GLbitfield mask,
-                  GLboolean all, GLint cx, GLint cy, GLint cw, GLint ch);
-
-
-extern void
-i915RotateWindow(intelContextPtr intel, __DRIdrawablePrivate *dPriv,
-                 GLuint srcBuf);
 
 /*======================================================================
  * i915_fragprog.c
  */
-extern void i915ValidateFragmentProgram( i915ContextPtr i915 );
-extern void i915InitFragProgFuncs( struct dd_function_table *functions );
-       
-#endif
+extern void i915ValidateFragmentProgram(struct i915_context *i915);
+extern void i915InitFragProgFuncs(struct dd_function_table *functions);
+
+/*======================================================================
+ * Inline conversion functions.  These are better-typed than the
+ * macros used previously:
+ */
+static INLINE struct i915_context *
+i915_context(GLcontext * ctx)
+{
+   return (struct i915_context *) ctx;
+}
+
 
+
+#define I915_CONTEXT(ctx)      i915_context(ctx)
+
+
+
+#endif
index 054b561605a9188132b6332e2e590e3e64d614a5..eb1a052b9e25ce0d94aab692c2bf128b1c0c17f7 100644 (file)
  * 
  **************************************************************************/
 
+#include "imports.h"
+
 #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 )
+#include "i915_debug.h"
+
+#define PRINTF( ... ) _mesa_printf( __VA_ARGS__ )
+
+static GLboolean debug( struct debug_stream *stream, const char *name, GLuint len )
 {
-   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;
+   GLuint i;
+   GLuint *ptr = (GLuint *)(stream->ptr + stream->offset);
+   
+   if (len == 0) {
+      PRINTF("Error - zero length packet (0x%08x)\n", stream->ptr[0]);
+      assert(0);
+      return GL_FALSE;
    }
 
-   fprintf(stderr, "%s[%d]", regname[type], nr);
-}
+   if (stream->print_addresses)
+      PRINTF("%08x:  ", stream->offset);
+
 
-#define REG_SWIZZLE_MASK 0x7777
-#define REG_NEGATE_MASK 0x8888
+   PRINTF("%s (%d dwords):\n", name, len);
+   for (i = 0; i < len; i++)
+      PRINTF("\t0x%08x\n",  ptr[i]);   
+   PRINTF("\n");
 
-#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))
+   stream->offset += len * sizeof(GLuint);
+   
+   return GL_TRUE;
+}
 
 
-static void print_reg_neg_swizzle( GLuint reg )
+static const char *get_prim_name( GLuint val )
 {
-   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;
-      }
+   switch (val & PRIM3D_MASK) {
+   case PRIM3D_TRILIST: return "TRILIST"; break;
+   case PRIM3D_TRISTRIP: return "TRISTRIP"; break;
+   case PRIM3D_TRISTRIP_RVRSE: return "TRISTRIP_RVRSE"; break;
+   case PRIM3D_TRIFAN: return "TRIFAN"; break;
+   case PRIM3D_POLY: return "POLY"; break;
+   case PRIM3D_LINELIST: return "LINELIST"; break;
+   case PRIM3D_LINESTRIP: return "LINESTRIP"; break;
+   case PRIM3D_RECTLIST: return "RECTLIST"; break;
+   case PRIM3D_POINTLIST: return "POINTLIST"; break;
+   case PRIM3D_DIB: return "DIB"; break;
+   case PRIM3D_CLEAR_RECT: return "CLEAR_RECT"; break;
+   case PRIM3D_ZONE_INIT: return "ZONE_INIT"; break;
+   default: return "????"; break;
    }
 }
 
-
-static void print_src_reg( GLuint dword )
+static GLboolean debug_prim( struct debug_stream *stream, const char *name, 
+                            GLboolean dump_floats,
+                            GLuint len )
 {
-   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 );
+   GLuint *ptr = (GLuint *)(stream->ptr + stream->offset);
+   const char *prim = get_prim_name( ptr[0] );
+   GLuint i;
+   
+
+
+   PRINTF("%s %s (%d dwords):\n", name, prim, len);
+   PRINTF("\t0x%08x\n",  ptr[0]);   
+   for (i = 1; i < len; i++) {
+      if (dump_floats)
+        PRINTF("\t0x%08x // %f\n",  ptr[i], *(GLfloat *)&ptr[i]);   
+      else
+        PRINTF("\t0x%08x\n",  ptr[i]);   
+   }
+
+      
+   PRINTF("\n");
+
+   stream->offset += len * sizeof(GLuint);
+   
+   return GL_TRUE;
 }
+   
+
 
-void i915_print_ureg( const char *msg, GLuint ureg )
+
+static GLboolean debug_program( struct debug_stream *stream, const char *name, GLuint len )
 {
-   fprintf(stderr, "%s: ", msg);
-   print_src_reg( ureg >> 8 );
-   fprintf(stderr, "\n");
+   GLuint *ptr = (GLuint *)(stream->ptr + stream->offset);
+
+   if (len == 0) {
+      PRINTF("Error - zero length packet (0x%08x)\n", stream->ptr[0]);
+      assert(0);
+      return GL_FALSE;
+   }
+
+   if (stream->print_addresses)
+      PRINTF("%08x:  ", stream->offset);
+
+   PRINTF("%s (%d dwords):\n", name, len);
+   i915_disassemble_program( ptr, len );
+
+   stream->offset += len * sizeof(GLuint);
+   return GL_TRUE;
 }
 
-static void print_dest_reg( GLuint dword )
+
+static GLboolean debug_chain( struct debug_stream *stream, const char *name, GLuint len )
 {
-   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");
+   GLuint *ptr = (GLuint *)(stream->ptr + stream->offset);
+   GLuint old_offset = stream->offset + len * sizeof(GLuint);
+   GLuint i;
+
+   PRINTF("%s (%d dwords):\n", name, len);
+   for (i = 0; i < len; i++)
+      PRINTF("\t0x%08x\n",  ptr[i]);
+
+   stream->offset = ptr[1] & ~0x3;
+   
+   if (stream->offset < old_offset)
+      PRINTF("\n... skipping backwards from 0x%x --> 0x%x ...\n\n", 
+                  old_offset, stream->offset );
+   else
+      PRINTF("\n... skipping from 0x%x --> 0x%x ...\n\n", 
+                  old_offset, stream->offset );
+
+
+   return GL_TRUE;
 }
 
 
-#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 GLboolean debug_variable_length_prim( struct debug_stream *stream )
+{
+   GLuint *ptr = (GLuint *)(stream->ptr + stream->offset);
+   const char *prim = get_prim_name( ptr[0] );
+   GLuint i, len;
+
+   GLushort *idx = (GLushort *)(ptr+1);
+   for (i = 0; idx[i] != 0xffff; i++)
+      ;
+
+   len = 1+(i+2)/2;
+
+   PRINTF("3DPRIM, %s variable length %d indicies (%d dwords):\n", prim, i, len);
+   for (i = 0; i < len; i++)
+      PRINTF("\t0x%08x\n",  ptr[i]);
+   PRINTF("\n");
+
+   stream->offset += len * sizeof(GLuint);
+   return GL_TRUE;
+}
 
 
-static void print_arith_op( GLuint opcode, const GLuint *program )
+#define BITS( dw, hi, lo, ... )                                \
+do {                                                   \
+   unsigned himask = 0xffffffffU >> (31 - (hi));               \
+   PRINTF("\t\t ");                            \
+   PRINTF(__VA_ARGS__);                        \
+   PRINTF(": 0x%x\n", ((dw) & himask) >> (lo));        \
+} while (0)
+
+#define MBZ( dw, hi, lo) do {                                                  \
+   unsigned x = (dw) >> (lo);                          \
+   unsigned lomask = (1 << (lo)) - 1;                  \
+   unsigned himask;                                    \
+   himask = (1UL << (hi)) - 1;                         \
+   assert ((x & himask & ~lomask) == 0);       \
+} while (0)
+
+#define FLAG( dw, bit, ... )                   \
+do {                                                   \
+   if (((dw) >> (bit)) & 1) {                          \
+      PRINTF("\t\t ");                         \
+      PRINTF(__VA_ARGS__);                     \
+      PRINTF("\n");                            \
+   }                                                   \
+} while (0)
+
+static GLboolean debug_load_immediate( struct debug_stream *stream,
+                                      const char *name,
+                                      GLuint len )
 {
-   if (opcode != A0_NOP) {
-      print_dest_reg(program[0]);
-      if (program[0] & A0_DEST_SATURATE)
-        fprintf(stderr, " = SATURATE ");
-      else
-        fprintf(stderr, " = ");
+   GLuint *ptr = (GLuint *)(stream->ptr + stream->offset);
+   GLuint bits = (ptr[0] >> 4) & 0xff;
+   GLuint j = 0;
+   
+   PRINTF("%s (%d dwords, flags: %x):\n", name, len, bits);
+   PRINTF("\t0x%08x\n",  ptr[j++]);
+
+   if (bits & (1<<0)) {
+      PRINTF("\t  LIS0: 0x%08x\n", ptr[j]);
+      PRINTF("\t vb address: 0x%08x\n", (ptr[j] & ~0x3));
+      BITS(ptr[j], 0, 0, "vb invalidate disable");
+      j++;
+   }
+   if (bits & (1<<1)) {
+      PRINTF("\t  LIS1: 0x%08x\n", ptr[j]);
+      BITS(ptr[j], 29, 24, "vb dword width");
+      BITS(ptr[j], 21, 16, "vb dword pitch");
+      BITS(ptr[j], 15, 0, "vb max index");
+      j++;
    }
+   if (bits & (1<<2)) {
+      int i;
+      PRINTF("\t  LIS2: 0x%08x\n", ptr[j]);
+      for (i = 0; i < 8; i++) {
+        unsigned tc = (ptr[j] >> (i * 4)) & 0xf;
+        if (tc != 0xf)
+           BITS(tc, 3, 0, "tex coord %d", i);
+      }
+      j++;
+   }
+   if (bits & (1<<3)) {
+      PRINTF("\t  LIS3: 0x%08x\n", ptr[j]);
+      j++;
+   }
+   if (bits & (1<<4)) {
+      PRINTF("\t  LIS4: 0x%08x\n", ptr[j]);
+      BITS(ptr[j], 31, 23, "point width");
+      BITS(ptr[j], 22, 19, "line width");
+      FLAG(ptr[j], 18, "alpha flatshade");
+      FLAG(ptr[j], 17, "fog flatshade");
+      FLAG(ptr[j], 16, "spec flatshade");
+      FLAG(ptr[j], 15, "rgb flatshade");
+      BITS(ptr[j], 14, 13, "cull mode");
+      FLAG(ptr[j], 12, "vfmt: point width");
+      FLAG(ptr[j], 11, "vfmt: specular/fog");
+      FLAG(ptr[j], 10, "vfmt: rgba");
+      FLAG(ptr[j], 9, "vfmt: depth offset");
+      BITS(ptr[j], 8, 6, "vfmt: position (2==xyzw)");
+      FLAG(ptr[j], 5, "force dflt diffuse");
+      FLAG(ptr[j], 4, "force dflt specular");
+      FLAG(ptr[j], 3, "local depth offset enable");
+      FLAG(ptr[j], 2, "vfmt: fp32 fog coord");
+      FLAG(ptr[j], 1, "sprite point");
+      FLAG(ptr[j], 0, "antialiasing");
+      j++;
+   }
+   if (bits & (1<<5)) {
+      PRINTF("\t  LIS5: 0x%08x\n", ptr[j]);
+      BITS(ptr[j], 31, 28, "rgba write disables");
+      FLAG(ptr[j], 27,     "force dflt point width");
+      FLAG(ptr[j], 26,     "last pixel enable");
+      FLAG(ptr[j], 25,     "global z offset enable");
+      FLAG(ptr[j], 24,     "fog enable");
+      BITS(ptr[j], 23, 16, "stencil ref");
+      BITS(ptr[j], 15, 13, "stencil test");
+      BITS(ptr[j], 12, 10, "stencil fail op");
+      BITS(ptr[j], 9, 7,   "stencil pass z fail op");
+      BITS(ptr[j], 6, 4,   "stencil pass z pass op");
+      FLAG(ptr[j], 3,      "stencil write enable");
+      FLAG(ptr[j], 2,      "stencil test enable");
+      FLAG(ptr[j], 1,      "color dither enable");
+      FLAG(ptr[j], 0,      "logiop enable");
+      j++;
+   }
+   if (bits & (1<<6)) {
+      PRINTF("\t  LIS6: 0x%08x\n", ptr[j]);
+      FLAG(ptr[j], 31,      "alpha test enable");
+      BITS(ptr[j], 30, 28,  "alpha func");
+      BITS(ptr[j], 27, 20,  "alpha ref");
+      FLAG(ptr[j], 19,      "depth test enable");
+      BITS(ptr[j], 18, 16,  "depth func");
+      FLAG(ptr[j], 15,      "blend enable");
+      BITS(ptr[j], 14, 12,  "blend func");
+      BITS(ptr[j], 11, 8,   "blend src factor");
+      BITS(ptr[j], 7,  4,   "blend dst factor");
+      FLAG(ptr[j], 3,       "depth write enable");
+      FLAG(ptr[j], 2,       "color write enable");
+      BITS(ptr[j], 1,  0,   "provoking vertex"); 
+      j++;
+   }
+
 
-   fprintf(stderr, "%s ", opcodes[opcode]);
+   PRINTF("\n");
 
-   print_src_reg(GET_SRC0_REG(program[0], program[1]));
-   if (args[opcode] == 1) {
-      fprintf(stderr, "\n");
-      return;
+   assert(j == len);
+
+   stream->offset += len * sizeof(GLuint);
+   
+   return GL_TRUE;
+}
+
+
+static GLboolean debug_load_indirect( struct debug_stream *stream,
+                                     const char *name,
+                                     GLuint len )
+{
+   GLuint *ptr = (GLuint *)(stream->ptr + stream->offset);
+   GLuint bits = (ptr[0] >> 8) & 0x3f;
+   GLuint i, j = 0;
+   
+   PRINTF("%s (%d dwords):\n", name, len);
+   PRINTF("\t0x%08x\n",  ptr[j++]);
+
+   for (i = 0; i < 6; i++) {
+      if (bits & (1<<i)) {
+        switch (1<<(8+i)) {
+        case LI0_STATE_STATIC_INDIRECT:
+           PRINTF("        STATIC: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++;
+           PRINTF("                0x%08x\n", ptr[j++]);
+           break;
+        case LI0_STATE_DYNAMIC_INDIRECT:
+           PRINTF("       DYNAMIC: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++;
+           break;
+        case LI0_STATE_SAMPLER:
+           PRINTF("       SAMPLER: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++;
+           PRINTF("                0x%08x\n", ptr[j++]);
+           break;
+        case LI0_STATE_MAP:
+           PRINTF("           MAP: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++;
+           PRINTF("                0x%08x\n", ptr[j++]);
+           break;
+        case LI0_STATE_PROGRAM:
+           PRINTF("       PROGRAM: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++;
+           PRINTF("                0x%08x\n", ptr[j++]);
+           break;
+        case LI0_STATE_CONSTANTS:
+           PRINTF("     CONSTANTS: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++;
+           PRINTF("                0x%08x\n", ptr[j++]);
+           break;
+        default:
+           assert(0);
+           break;
+        }
+      }
    }
 
-   fprintf(stderr, ", ");
-   print_src_reg(GET_SRC1_REG(program[1], program[2]));
-   if (args[opcode] == 2) { 
-      fprintf(stderr, "\n");
-      return;
+   if (bits == 0) {
+      PRINTF("\t  DUMMY: 0x%08x\n", ptr[j++]);
    }
 
-   fprintf(stderr, ", ");
-   print_src_reg(GET_SRC2_REG(program[2]));
-   fprintf(stderr, "\n");
-   return;
+   PRINTF("\n");
+
+
+   assert(j == len);
+
+   stream->offset += len * sizeof(GLuint);
+   
+   return GL_TRUE;
+}
+       
+static void BR13( struct debug_stream *stream,
+                 GLuint val )
+{
+   PRINTF("\t0x%08x\n",  val);
+   FLAG(val, 30, "clipping enable");
+   BITS(val, 25, 24, "color depth (3==32bpp)");
+   BITS(val, 23, 16, "raster op");
+   BITS(val, 15, 0,  "dest pitch");
 }
 
 
-static void print_tex_op( GLuint opcode, const GLuint *program )
+static void BR2223( struct debug_stream *stream,
+                   GLuint val22, GLuint val23 )
 {
-   print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL);
-   fprintf(stderr, " = ");
+   union { GLuint val; short field[2]; } BR22, BR23;
 
-   fprintf(stderr, "%s ", opcodes[opcode]);
+   BR22.val = val22;
+   BR23.val = val23;
 
-   fprintf(stderr, "S[%d],", 
-          program[0] & T0_SAMPLER_NR_MASK);
+   PRINTF("\t0x%08x\n",  val22);
+   BITS(val22, 31, 16, "dest y1");
+   BITS(val22, 15, 0,  "dest x1");
 
-   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");
+   PRINTF("\t0x%08x\n",  val23);
+   BITS(val23, 31, 16, "dest y2");
+   BITS(val23, 15, 0,  "dest x2");
+
+   /* The blit engine may produce unexpected results when these aren't met */
+   assert(BR22.field[0] < BR23.field[0]);
+   assert(BR22.field[1] < BR23.field[1]);
 }
 
-static void print_dcl_op( GLuint opcode, const GLuint *program )
+static void BR09( struct debug_stream *stream,
+                 GLuint val )
 {
-   fprintf(stderr, "%s ", opcodes[opcode]);
-   print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL);
-   fprintf(stderr, "\n");
+   PRINTF("\t0x%08x -- dest address\n",  val);
 }
 
+static void BR26( struct debug_stream *stream,
+                 GLuint val )
+{
+   PRINTF("\t0x%08x\n",  val);
+   BITS(val, 31, 16, "src y1");
+   BITS(val, 15, 0,  "src x1");
+}
+
+static void BR11( struct debug_stream *stream,
+                 GLuint val )
+{
+   PRINTF("\t0x%08x\n",  val);
+   BITS(val, 15, 0,  "src pitch");
+}
 
-void i915_disassemble_program( const GLuint *program, GLuint sz )
+static void BR12( struct debug_stream *stream,
+                 GLuint val )
 {
-   GLuint size = program[0] & 0x1ff;
-   GLint i;
+   PRINTF("\t0x%08x -- src address\n",  val);
+}
+
+static void BR16( struct debug_stream *stream,
+                 GLuint val )
+{
+   PRINTF("\t0x%08x -- color\n",  val);
+}
+   
+static GLboolean debug_copy_blit( struct debug_stream *stream,
+                                 const char *name,
+                                 GLuint len )
+{
+   GLuint *ptr = (GLuint *)(stream->ptr + stream->offset);
+   int j = 0;
+
+   PRINTF("%s (%d dwords):\n", name, len);
+   PRINTF("\t0x%08x\n",  ptr[j++]);
+   
+   BR13(stream, ptr[j++]);
+   BR2223(stream, ptr[j], ptr[j+1]);
+   j += 2;
+   BR09(stream, ptr[j++]);
+   BR26(stream, ptr[j++]);
+   BR11(stream, ptr[j++]);
+   BR12(stream, ptr[j++]);
+
+   stream->offset += len * sizeof(GLuint);
+   assert(j == len);
+   return GL_TRUE;
+}
+
+static GLboolean debug_color_blit( struct debug_stream *stream,
+                                 const char *name,
+                                 GLuint len )
+{
+   GLuint *ptr = (GLuint *)(stream->ptr + stream->offset);
+   int j = 0;
+
+   PRINTF("%s (%d dwords):\n", name, len);
+   PRINTF("\t0x%08x\n",  ptr[j++]);
+
+   BR13(stream, ptr[j++]);
+   BR2223(stream, ptr[j], ptr[j+1]);
+   j += 2;
+   BR09(stream, ptr[j++]);
+   BR16(stream, ptr[j++]);
+
+   stream->offset += len * sizeof(GLuint);
+   assert(j == len);
+   return GL_TRUE;
+}
+
+static GLboolean debug_modes4( struct debug_stream *stream,
+                                 const char *name,
+                                 GLuint len )
+{
+   GLuint *ptr = (GLuint *)(stream->ptr + stream->offset);
+   int j = 0;
+
+   PRINTF("%s (%d dwords):\n", name, len);
+   PRINTF("\t0x%08x\n",  ptr[j]);
+   BITS(ptr[j], 21, 18, "logicop func");
+   FLAG(ptr[j], 17, "stencil test mask modify-enable");
+   FLAG(ptr[j], 16, "stencil write mask modify-enable");
+   BITS(ptr[j], 15, 8, "stencil test mask");
+   BITS(ptr[j], 7, 0,  "stencil write mask");
+   j++;
+
+   stream->offset += len * sizeof(GLuint);
+   assert(j == len);
+   return GL_TRUE;
+}
+
+static GLboolean debug_map_state( struct debug_stream *stream,
+                                 const char *name,
+                                 GLuint len )
+{
+   GLuint *ptr = (GLuint *)(stream->ptr + stream->offset);
+   int j = 0;
+
+   PRINTF("%s (%d dwords):\n", name, len);
+   PRINTF("\t0x%08x\n",  ptr[j++]);
+   
+   {
+      PRINTF("\t0x%08x\n",  ptr[j]);
+      BITS(ptr[j], 15, 0,   "map mask");
+      j++;
+   }
+
+   while (j < len) {
+      {
+        PRINTF("\t  TMn.0: 0x%08x\n", ptr[j]);
+        PRINTF("\t map address: 0x%08x\n", (ptr[j] & ~0x3));
+        FLAG(ptr[j], 1, "vertical line stride");
+        FLAG(ptr[j], 0, "vertical line stride offset");
+        j++;
+      }
+
+      {
+        PRINTF("\t  TMn.1: 0x%08x\n", ptr[j]);
+        BITS(ptr[j], 31, 21, "height");
+        BITS(ptr[j], 20, 10, "width");
+        BITS(ptr[j], 9, 7, "surface format");
+        BITS(ptr[j], 6, 3, "texel format");
+        FLAG(ptr[j], 2, "use fence regs");
+        FLAG(ptr[j], 1, "tiled surface");
+        FLAG(ptr[j], 0, "tile walk ymajor");
+        j++;
+      }
+      {
+        PRINTF("\t  TMn.2: 0x%08x\n", ptr[j]);
+        BITS(ptr[j], 31, 21, "dword pitch");
+        BITS(ptr[j], 20, 15, "cube face enables");
+        BITS(ptr[j], 14, 9, "max lod");
+        FLAG(ptr[j], 8,     "mip layout right");
+        BITS(ptr[j], 7, 0, "depth");
+        j++;
+      }
+   }
+
+   stream->offset += len * sizeof(GLuint);
+   assert(j == len);
+   return GL_TRUE;
+}
+
+static GLboolean debug_sampler_state( struct debug_stream *stream,
+                                 const char *name,
+                                 GLuint len )
+{
+   GLuint *ptr = (GLuint *)(stream->ptr + stream->offset);
+   int j = 0;
+
+   PRINTF("%s (%d dwords):\n", name, len);
+   PRINTF("\t0x%08x\n",  ptr[j++]);
+   
+   {
+      PRINTF("\t0x%08x\n",  ptr[j]);
+      BITS(ptr[j], 15, 0,   "sampler mask");
+      j++;
+   }
+
+   while (j < len) {
+      {
+        PRINTF("\t  TSn.0: 0x%08x\n", ptr[j]);
+        FLAG(ptr[j], 31, "reverse gamma");
+        FLAG(ptr[j], 30, "planar to packed");
+        FLAG(ptr[j], 29, "yuv->rgb");
+        BITS(ptr[j], 28, 27, "chromakey index");
+        BITS(ptr[j], 26, 22, "base mip level");
+        BITS(ptr[j], 21, 20, "mip mode filter");
+        BITS(ptr[j], 19, 17, "mag mode filter");
+        BITS(ptr[j], 16, 14, "min mode filter");
+        BITS(ptr[j], 13, 5,  "lod bias (s4.4)");
+        FLAG(ptr[j], 4,      "shadow enable");
+        FLAG(ptr[j], 3,      "max-aniso-4");
+        BITS(ptr[j], 2, 0,   "shadow func");
+        j++;
+      }
+
+      {
+        PRINTF("\t  TSn.1: 0x%08x\n", ptr[j]);
+        BITS(ptr[j], 31, 24, "min lod");
+        MBZ( ptr[j], 23, 18 );
+        FLAG(ptr[j], 17,     "kill pixel enable");
+        FLAG(ptr[j], 16,     "keyed tex filter mode");
+        FLAG(ptr[j], 15,     "chromakey enable");
+        BITS(ptr[j], 14, 12, "tcx wrap mode");
+        BITS(ptr[j], 11, 9,  "tcy wrap mode");
+        BITS(ptr[j], 8,  6,  "tcz wrap mode");
+        FLAG(ptr[j], 5,      "normalized coords");
+        BITS(ptr[j], 4,  1,  "map (surface) index");
+        FLAG(ptr[j], 0,      "EAST deinterlacer enable");
+        j++;
+      }
+      {
+        PRINTF("\t  TSn.2: 0x%08x  (default color)\n", ptr[j]);
+        j++;
+      }
+   }
+
+   stream->offset += len * sizeof(GLuint);
+   assert(j == len);
+   return GL_TRUE;
+}
+
+static GLboolean debug_dest_vars( struct debug_stream *stream,
+                                 const char *name,
+                                 GLuint len )
+{
+   GLuint *ptr = (GLuint *)(stream->ptr + stream->offset);
+   int j = 0;
+
+   PRINTF("%s (%d dwords):\n", name, len);
+   PRINTF("\t0x%08x\n",  ptr[j++]);
+
+   {
+      PRINTF("\t0x%08x\n",  ptr[j]);
+      FLAG(ptr[j], 31,     "early classic ztest");
+      FLAG(ptr[j], 30,     "opengl tex default color");
+      FLAG(ptr[j], 29,     "bypass iz");
+      FLAG(ptr[j], 28,     "lod preclamp");
+      BITS(ptr[j], 27, 26, "dither pattern");
+      FLAG(ptr[j], 25,     "linear gamma blend");
+      FLAG(ptr[j], 24,     "debug dither");
+      BITS(ptr[j], 23, 20, "dstorg x");
+      BITS(ptr[j], 19, 16, "dstorg y");
+      MBZ (ptr[j], 15, 15 );
+      BITS(ptr[j], 14, 12, "422 write select");
+      BITS(ptr[j], 11, 8,  "cbuf format");
+      BITS(ptr[j], 3, 2,   "zbuf format");
+      FLAG(ptr[j], 1,      "vert line stride");
+      FLAG(ptr[j], 1,      "vert line stride offset");
+      j++;
+   }
    
-   fprintf(stderr, "BEGIN\n");
+   stream->offset += len * sizeof(GLuint);
+   assert(j == len);
+   return GL_TRUE;
+}
 
-   if (size+2 != sz) {
-      fprintf(stderr, "%s: program size mismatch %d/%d\n", __FUNCTION__,
-             size+2, sz);
-      exit(1);
+static GLboolean debug_buf_info( struct debug_stream *stream,
+                                 const char *name,
+                                 GLuint len )
+{
+   GLuint *ptr = (GLuint *)(stream->ptr + stream->offset);
+   int j = 0;
+
+   PRINTF("%s (%d dwords):\n", name, len);
+   PRINTF("\t0x%08x\n",  ptr[j++]);
+
+   {
+      PRINTF("\t0x%08x\n",  ptr[j]);
+      BITS(ptr[j], 28, 28, "aux buffer id");
+      BITS(ptr[j], 27, 24, "buffer id (7=depth, 3=back)");
+      FLAG(ptr[j], 23,     "use fence regs");
+      FLAG(ptr[j], 22,     "tiled surface");
+      FLAG(ptr[j], 21,     "tile walk ymajor");
+      MBZ (ptr[j], 20, 14);
+      BITS(ptr[j], 13, 2,  "dword pitch");
+      MBZ (ptr[j], 2,  0);
+      j++;
    }
+   
+   PRINTF("\t0x%08x -- buffer base address\n",  ptr[j++]);
+
+   stream->offset += len * sizeof(GLuint);
+   assert(j == len);
+   return GL_TRUE;
+}
 
-   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);
+static GLboolean i915_debug_packet( struct debug_stream *stream )
+{
+   GLuint *ptr = (GLuint *)(stream->ptr + stream->offset);
+   GLuint cmd = *ptr;
+   
+   switch (((cmd >> 29) & 0x7)) {
+   case 0x0:
+      switch ((cmd >> 23) & 0x3f) {
+      case 0x0:
+        return debug(stream, "MI_NOOP", 1);
+      case 0x3:
+        return debug(stream, "MI_WAIT_FOR_EVENT", 1);
+      case 0x4:
+        return debug(stream, "MI_FLUSH", 1);
+      case 0xA:
+        debug(stream, "MI_BATCH_BUFFER_END", 1);
+        return GL_FALSE;
+      case 0x22:
+        return debug(stream, "MI_LOAD_REGISTER_IMM", 3);
+      case 0x31:
+        return debug_chain(stream, "MI_BATCH_BUFFER_START", 2);
+      default:
+        break;
+      }
+      break;
+   case 0x1:
+      break;
+   case 0x2:
+      switch ((cmd >> 22) & 0xff) {     
+      case 0x50:
+        return debug_color_blit(stream, "XY_COLOR_BLT", (cmd & 0xff) + 2);
+      case 0x53:
+        return debug_copy_blit(stream, "XY_SRC_COPY_BLT", (cmd & 0xff) + 2);
+      default:
+        return debug(stream, "blit command", (cmd & 0xff) + 2);
+      }
+      break;
+   case 0x3:
+      switch ((cmd >> 24) & 0x1f) {     
+      case 0x6:
+        return debug(stream, "3DSTATE_ANTI_ALIASING", 1);
+      case 0x7:
+        return debug(stream, "3DSTATE_RASTERIZATION_RULES", 1);
+      case 0x8:
+        return debug(stream, "3DSTATE_BACKFACE_STENCIL_OPS", 2);
+      case 0x9:
+        return debug(stream, "3DSTATE_BACKFACE_STENCIL_MASKS", 1);
+      case 0xb:
+        return debug(stream, "3DSTATE_INDEPENDENT_ALPHA_BLEND", 1);
+      case 0xc:
+        return debug(stream, "3DSTATE_MODES5", 1);      
+      case 0xd:
+        return debug_modes4(stream, "3DSTATE_MODES4", 1);
+      case 0x15:
+        return debug(stream, "3DSTATE_FOG_COLOR", 1);
+      case 0x16:
+        return debug(stream, "3DSTATE_COORD_SET_BINDINGS", 1);
+      case 0x1c:
+        /* 3DState16NP */
+        switch((cmd >> 19) & 0x1f) {
+        case 0x10:
+           return debug(stream, "3DSTATE_SCISSOR_ENABLE", 1);
+        case 0x11:
+           return debug(stream, "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE", 1);
+        default:
+           break;
+        }
+        break;
+      case 0x1d:
+        /* 3DStateMW */
+        switch ((cmd >> 16) & 0xff) {
+        case 0x0:
+           return debug_map_state(stream, "3DSTATE_MAP_STATE", (cmd & 0x1f) + 2);
+        case 0x1:
+           return debug_sampler_state(stream, "3DSTATE_SAMPLER_STATE", (cmd & 0x1f) + 2);
+        case 0x4:
+           return debug_load_immediate(stream, "3DSTATE_LOAD_STATE_IMMEDIATE", (cmd & 0xf) + 2);
+        case 0x5:
+           return debug_program(stream, "3DSTATE_PIXEL_SHADER_PROGRAM", (cmd & 0x1ff) + 2);
+        case 0x6:
+           return debug(stream, "3DSTATE_PIXEL_SHADER_CONSTANTS", (cmd & 0xff) + 2);
+        case 0x7:
+           return debug_load_indirect(stream, "3DSTATE_LOAD_INDIRECT", (cmd & 0xff) + 2);
+        case 0x80:
+           return debug(stream, "3DSTATE_DRAWING_RECTANGLE", (cmd & 0xffff) + 2);
+        case 0x81:
+           return debug(stream, "3DSTATE_SCISSOR_RECTANGLE", (cmd & 0xffff) + 2);
+        case 0x83:
+           return debug(stream, "3DSTATE_SPAN_STIPPLE", (cmd & 0xffff) + 2);
+        case 0x85:
+           return debug_dest_vars(stream, "3DSTATE_DEST_BUFFER_VARS", (cmd & 0xffff) + 2);
+        case 0x88:
+           return debug(stream, "3DSTATE_CONSTANT_BLEND_COLOR", (cmd & 0xffff) + 2);
+        case 0x89:
+           return debug(stream, "3DSTATE_FOG_MODE", (cmd & 0xffff) + 2);
+        case 0x8e:
+           return debug_buf_info(stream, "3DSTATE_BUFFER_INFO", (cmd & 0xffff) + 2);
+        case 0x97:
+           return debug(stream, "3DSTATE_DEPTH_OFFSET_SCALE", (cmd & 0xffff) + 2);
+        case 0x98:
+           return debug(stream, "3DSTATE_DEFAULT_Z", (cmd & 0xffff) + 2);
+        case 0x99:
+           return debug(stream, "3DSTATE_DEFAULT_DIFFUSE", (cmd & 0xffff) + 2);
+        case 0x9a:
+           return debug(stream, "3DSTATE_DEFAULT_SPECULAR", (cmd & 0xffff) + 2);
+        case 0x9c:
+           return debug(stream, "3DSTATE_CLEAR_PARAMETERS", (cmd & 0xffff) + 2);
+        default:
+           assert(0);
+           return 0;
+        }
+        break;
+      case 0x1e:
+        if (cmd & (1 << 23))
+           return debug(stream, "???", (cmd & 0xffff) + 1);
+        else
+           return debug(stream, "", 1);
+        break;
+      case 0x1f:
+        if ((cmd & (1 << 23)) == 0)    
+           return debug_prim(stream, "3DPRIM (inline)", 1, (cmd & 0x1ffff) + 2);
+        else if (cmd & (1 << 17)) 
+        {
+           if ((cmd & 0xffff) == 0)
+              return debug_variable_length_prim(stream);
+           else
+              return debug_prim(stream, "3DPRIM (indexed)", 0, (((cmd & 0xffff) + 1) / 2) + 1);
+        }
+        else
+           return debug_prim(stream, "3DPRIM  (indirect sequential)", 0, 2); 
+        break;
+      default:
+        return debug(stream, "", 0);
+      }
+   default:
+      assert(0);
+      return 0;
+   }
+
+   assert(0);
+   return 0;
+}
+
+
+
+void
+i915_dump_batchbuffer( GLuint *start,
+                      GLuint *end )
+{
+   struct debug_stream stream;
+   GLuint bytes = (end - start) * 4;
+   GLboolean done = GL_FALSE;
+
+   PRINTF("\n\nBATCH: (%d)\n", bytes / 4);
+
+   stream.offset = 0;
+   stream.ptr = (char *)start;
+   stream.print_addresses = 0;
+
+   while (!done &&
+         stream.offset < bytes &&
+         stream.offset >= 0)
+   {
+      if (!i915_debug_packet( &stream ))
+        break;
+
+      assert(stream.offset <= bytes &&
+            stream.offset >= 0);
    }
 
-   fprintf(stderr, "END\n\n");
+   PRINTF("END-BATCH\n\n\n");
 }
+
+
diff --git a/src/mesa/drivers/dri/i915/i915_debug.h b/src/mesa/drivers/dri/i915/i915_debug.h
new file mode 100644 (file)
index 0000000..0643a8c
--- /dev/null
@@ -0,0 +1,55 @@
+/**************************************************************************
+ * 
+ * Copyright 2007 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.
+ * 
+ **************************************************************************/
+
+/* Authors:  Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#ifndef I915_DEBUG_H
+#define I915_DEBUG_H
+
+struct i915_context;
+
+struct debug_stream 
+{
+   unsigned offset;            /* current gtt offset */
+   char *ptr;          /* pointer to gtt offset zero */
+   char *end;          /* pointer to gtt offset zero */
+   unsigned print_addresses;
+};
+
+
+
+extern void i915_disassemble_program(const unsigned *program, unsigned sz);
+extern void i915_print_ureg(const char *msg, unsigned ureg);
+
+
+void
+i915_dump_batchbuffer( unsigned *start,
+                      unsigned *end );
+
+
+#endif
diff --git a/src/mesa/drivers/dri/i915/i915_debug_fp.c b/src/mesa/drivers/dri/i915/i915_debug_fp.c
new file mode 100644 (file)
index 0000000..84347a0
--- /dev/null
@@ -0,0 +1,333 @@
+/**************************************************************************
+ * 
+ * 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 "i915_reg.h"
+#include "i915_debug.h"
+#include "main/imports.h"
+#include "shader/program.h"
+#include "shader/prog_instruction.h"
+#include "shader/prog_print.h"
+
+#define PRINTF( ... ) _mesa_printf( __VA_ARGS__ )
+
+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:
+         PRINTF("T_DIFFUSE");
+         return;
+      case T_SPECULAR:
+         PRINTF("T_SPECULAR");
+         return;
+      case T_FOG_W:
+         PRINTF("T_FOG_W");
+         return;
+      default:
+         PRINTF("T_TEX%d", nr);
+         return;
+      }
+   case REG_TYPE_OC:
+      if (nr == 0) {
+         PRINTF("oC");
+         return;
+      }
+      break;
+   case REG_TYPE_OD:
+      if (nr == 0) {
+         PRINTF("oD");
+         return;
+      }
+      break;
+   default:
+      break;
+   }
+
+   PRINTF("%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;
+
+   PRINTF(".");
+
+   for (i = 3; i >= 0; i--) {
+      if (reg & (1 << ((i * 4) + 3)))
+         PRINTF("-");
+
+      switch ((reg >> (i * 4)) & 0x7) {
+      case 0:
+         PRINTF("x");
+         break;
+      case 1:
+         PRINTF("y");
+         break;
+      case 2:
+         PRINTF("z");
+         break;
+      case 3:
+         PRINTF("w");
+         break;
+      case 4:
+         PRINTF("0");
+         break;
+      case 5:
+         PRINTF("1");
+         break;
+      default:
+         PRINTF("?");
+         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);
+}
+
+
+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;
+   PRINTF(".");
+   if (dword & A0_DEST_CHANNEL_X)
+      PRINTF("x");
+   if (dword & A0_DEST_CHANNEL_Y)
+      PRINTF("y");
+   if (dword & A0_DEST_CHANNEL_Z)
+      PRINTF("z");
+   if (dword & A0_DEST_CHANNEL_W)
+      PRINTF("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)
+         PRINTF(" = SATURATE ");
+      else
+         PRINTF(" = ");
+   }
+
+   PRINTF("%s ", opcodes[opcode]);
+
+   print_src_reg(GET_SRC0_REG(program[0], program[1]));
+   if (args[opcode] == 1) {
+      PRINTF("\n");
+      return;
+   }
+
+   PRINTF(", ");
+   print_src_reg(GET_SRC1_REG(program[1], program[2]));
+   if (args[opcode] == 2) {
+      PRINTF("\n");
+      return;
+   }
+
+   PRINTF(", ");
+   print_src_reg(GET_SRC2_REG(program[2]));
+   PRINTF("\n");
+   return;
+}
+
+
+static void
+print_tex_op(GLuint opcode, const GLuint * program)
+{
+   print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL);
+   PRINTF(" = ");
+
+   PRINTF("%s ", opcodes[opcode]);
+
+   PRINTF("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);
+   PRINTF("\n");
+}
+
+static void
+print_dcl_op(GLuint opcode, const GLuint * program)
+{
+   PRINTF("%s ", opcodes[opcode]);
+   print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL);
+   PRINTF("\n");
+}
+
+
+void
+i915_disassemble_program(const GLuint * program, GLuint sz)
+{
+   GLuint size = program[0] & 0x1ff;
+   GLint i;
+
+   PRINTF("\t\tBEGIN\n");
+
+   assert(size + 2 == sz);
+
+   program++;
+   for (i = 1; i < sz; i += 3, program += 3) {
+      GLuint opcode = program[0] & (0x1f << 24);
+
+      PRINTF("\t\t");
+
+      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
+         PRINTF("Unknown opcode 0x%x\n", opcode);
+   }
+
+   PRINTF("\t\tEND\n\n");
+}
+
+
index 702b878828243297170a84a800cca271dd4010cc..1876218ca0253b304ad388c2cc49f2654d8d4aec 100644 (file)
 #include "macros.h"
 #include "enums.h"
 
+#include "shader/prog_instruction.h"
+#include "shader/prog_parameter.h"
+#include "shader/program.h"
+#include "shader/programopt.h"
+
 #include "tnl/tnl.h"
 #include "tnl/t_context.h"
+
 #include "intel_batchbuffer.h"
 
 #include "i915_reg.h"
 #include "i915_context.h"
 #include "i915_program.h"
 
-#include "prog_instruction.h"
-#include "prog_parameter.h"
-#include "program.h"
-#include "programopt.h"
-
-
+static const GLfloat sin_quad_constants[2][4] = {
+   {
+      2.0,
+      -1.0,
+      .5,
+      .75
+   },
+   {
+      4.0,
+      -4.0,
+      1.0 / (2.0 * M_PI),
+      .2225
+   }
+};
 
-/* 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) };
+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) };
+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 prog_src_register *source,
-                         const struct gl_fragment_program *program )
+static GLuint
+src_vector(struct i915_fragment_program *p,
+           const struct prog_src_register *source,
+           const struct gl_fragment_program *program)
 {
    GLuint src;
 
@@ -70,136 +86,152 @@ static GLuint src_vector( struct i915_fragment_program *p,
 
       /* 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 );
+   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 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;
-        }
+      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, ZERO, ZERO, ONE);
+         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;
-
-        /* 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_CONSTANT:
-      case PROGRAM_STATE_VAR:
-      case PROGRAM_NAMED_PARAM:
-         src = i915_emit_param4fv( 
-           p, program->Base.Parameters->ParameterValues[source->Index] );
-        break;
 
       default:
-        i915_program_error( p, "Bad source->File" ); 
-        return 0;
+         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_CONSTANT:
+   case PROGRAM_STATE_VAR:
+   case PROGRAM_NAMED_PARAM:
+      src =
+         i915_emit_param4fv(p,
+                            program->Base.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));
+   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, 
-                   GET_BIT(source->NegateBase, 0),
-                   GET_BIT(source->NegateBase, 1),
-                   GET_BIT(source->NegateBase, 2),
-                   GET_BIT(source->NegateBase, 3));
+      src = negate(src,
+                   GET_BIT(source->NegateBase, 0),
+                   GET_BIT(source->NegateBase, 1),
+                   GET_BIT(source->NegateBase, 2),
+                   GET_BIT(source->NegateBase, 3));
 
    return src;
 }
 
 
-static GLuint get_result_vector( struct i915_fragment_program *p,
-                                const struct prog_instruction *inst )
+static GLuint
+get_result_vector(struct i915_fragment_program *p,
+                  const struct prog_instruction *inst)
 {
    switch (inst->DstReg.File) {
    case PROGRAM_OUTPUT:
       switch (inst->DstReg.Index) {
-      case FRAG_RESULT_COLR: 
-        return UREG(REG_TYPE_OC, 0);
-      case FRAG_RESULT_DEPR: 
-        p->depth_written = 1;
-        return UREG(REG_TYPE_OD, 0);
-      default: 
-        i915_program_error( p, "Bad inst->DstReg.Index" ); 
-        return 0;
+      case FRAG_RESULT_COLR:
+         return UREG(REG_TYPE_OC, 0);
+      case FRAG_RESULT_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" ); 
+      i915_program_error(p, "Bad inst->DstReg.File");
       return 0;
    }
 }
-   
-static GLuint get_result_flags( const struct prog_instruction *inst )
+
+static GLuint
+get_result_flags(const struct prog_instruction *inst)
 {
    GLuint flags = 0;
 
-   if (inst->SaturateMode == SATURATE_ZERO_ONE) 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;
+   if (inst->SaturateMode == SATURATE_ZERO_ONE)
+      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_target( struct i915_fragment_program *p,
-                                    GLubyte bit )
+static GLuint
+translate_tex_src_target(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;
+   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;
    }
 }
 
@@ -211,7 +243,7 @@ do {                                                                \
    GLuint coord = src_vector( p, &inst->SrcReg[0], program);   \
    /* Texel lookup */                                          \
                                                                \
-   i915_emit_texld( p,                                         \
+   i915_emit_texld( p, get_live_regs(p, inst),                                         \
               get_result_vector( p, inst ),                    \
               get_result_flags( inst ),                        \
               sampler,                                         \
@@ -234,6 +266,43 @@ do {                                                                       \
 #define EMIT_2ARG_ARITH( OP ) EMIT_ARITH( OP, 2 )
 #define EMIT_3ARG_ARITH( OP ) EMIT_ARITH( OP, 3 )
 
+/* 
+ * TODO: consider moving this into core 
+ */
+static void calc_live_regs( struct i915_fragment_program *p )
+{
+    const struct gl_fragment_program *program = p->ctx->FragmentProgram._Current;
+    GLuint regsUsed = 0xffff0000;
+    GLint i;
+   
+    for (i = program->Base.NumInstructions - 1; i >= 0; i--) {
+        struct prog_instruction *inst = &program->Base.Instructions[i];
+        int opArgs = _mesa_num_inst_src_regs(inst->Opcode);
+        int a;
+
+        /* Register is written to: unmark as live for this and preceeding ops */ 
+        if (inst->DstReg.File == PROGRAM_TEMPORARY)
+            regsUsed &= ~(1 << inst->DstReg.Index);
+
+        for (a = 0; a < opArgs; a++) {
+            /* Register is read from: mark as live for this and preceeding ops */ 
+            if (inst->SrcReg[a].File == PROGRAM_TEMPORARY)
+                regsUsed |= 1 << inst->SrcReg[a].Index;
+        }
+
+        p->usedRegs[i] = regsUsed;
+    }
+}
+
+static GLuint get_live_regs( struct i915_fragment_program *p, 
+                             const struct prog_instruction *inst )
+{
+    const struct gl_fragment_program *program = p->ctx->FragmentProgram._Current;
+    GLuint nr = inst - program->Base.Instructions;
+
+    return p->usedRegs[nr];
+}
 
 /* Possible concerns:
  *
@@ -246,9 +315,11 @@ do {                                                                       \
  * can lead to confusion -- hopefully we cope with it ok now.
  *
  */
-static void upload_program( struct i915_fragment_program *p )
+static void
+upload_program(struct i915_fragment_program *p)
 {
-   const struct gl_fragment_program *program = p->ctx->FragmentProgram._Current;
+   const struct gl_fragment_program *program =
+      p->ctx->FragmentProgram._Current;
    const struct prog_instruction *inst = program->Base.Instructions;
 
 /*    _mesa_debug_fp_inst(program->Base.NumInstructions, inst); */
@@ -258,510 +329,551 @@ static void upload_program( struct i915_fragment_program *p )
     * this being uploaded to hardware.
     */
    if (inst[0].Opcode == 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);
+      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;
    }
 
+   if (program->Base.NumInstructions > I915_MAX_INSN) {
+       i915_program_error( p, "Exceeded max instructions" );
+       return;
+    }
+
+   /* Not always needed:
+    */
+   calc_live_regs(p);
+
    while (1) {
       GLuint src0, src1, src2, flags;
-      GLuint tmp = 0;
+      GLuint tmp = 0, consts0 = 0, consts1 = 0;
 
       switch (inst->Opcode) {
-      case 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 OPCODE_ADD: 
-        EMIT_2ARG_ARITH( A0_ADD );
-        break;
-
-      case 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 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 OPCODE_COS:
-        src0 = src_vector( p, &inst->SrcReg[0], program);
-        tmp = i915_get_utemp( p );
+      case OPCODE_ADD:
+         EMIT_2ARG_ARITH(A0_ADD);
+         break;
 
-        i915_emit_arith( p, 
-                        A0_MUL,
-                        tmp, A0_DEST_CHANNEL_X, 0,
-                        src0, 
-                        i915_emit_const1f(p, 1.0/(M_PI * 2)),
-                        0);
+      case 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;
 
-        i915_emit_arith( p, 
-                        A0_MOD,
+      case OPCODE_COS:
+         src0 = src_vector(p, &inst->SrcReg[0], program);
+         tmp = i915_get_utemp(p);
+        consts0 = i915_emit_const4fv(p, sin_quad_constants[0]);
+        consts1 = i915_emit_const4fv(p, sin_quad_constants[1]);
+
+        /* Reduce range from repeating about [-pi,pi] to [-1,1] */
+         i915_emit_arith(p,
+                         A0_MAD,
+                         tmp, A0_DEST_CHANNEL_X, 0,
+                         src0,
+                        swizzle(consts1, Z, ZERO, ZERO, ZERO), /* 1/(2pi) */
+                        swizzle(consts0, W, ZERO, ZERO, ZERO)); /* .75 */
+
+         i915_emit_arith(p, A0_FRC, tmp, A0_DEST_CHANNEL_X, 0, tmp, 0, 0);
+
+        i915_emit_arith(p,
+                        A0_MAD,
                         tmp, A0_DEST_CHANNEL_X, 0,
-                        tmp, 
-                        0, 0 );
+                        tmp,
+                        swizzle(consts0, X, ZERO, ZERO, ZERO), /* 2 */
+                        swizzle(consts0, Y, ZERO, ZERO, ZERO)); /* -1 */
 
-        /* By choosing different taylor constants, could get rid of this mul:
+        /* Compute COS with the same calculation used for SIN, but a
+         * different source range has been mapped to [-1,1] this time.
          */
-        i915_emit_arith( p, 
-                        A0_MUL,
-                        tmp, A0_DEST_CHANNEL_X, 0,
-                        tmp, 
-                        i915_emit_const1f(p, (M_PI * 2)),
+
+        /* tmp.y = abs(tmp.x); {x, abs(x), 0, 0} */
+        i915_emit_arith(p,
+                         A0_MAX,
+                        tmp, A0_DEST_CHANNEL_Y, 0,
+                        swizzle(tmp, ZERO, X, ZERO, ZERO),
+                        negate(swizzle(tmp, ZERO, X, ZERO, ZERO), 0, 1, 0, 0),
                         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, 
+        /* tmp.y = tmp.y * tmp.x; {x, x * abs(x), 0, 0} */
+        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);
+                        tmp, A0_DEST_CHANNEL_Y, 0,
+                        swizzle(tmp, ZERO, X, ZERO, ZERO),
+                        tmp,
+                        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);
+        /* tmp.x = tmp.xy DP sin_quad_constants[2].xy */
+         i915_emit_arith(p,
+                         A0_DP3,
+                         tmp, A0_DEST_CHANNEL_X, 0,
+                        tmp,
+                         swizzle(consts1, X, Y, ZERO, ZERO),
+                        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 OPCODE_DP3: 
-        EMIT_2ARG_ARITH( A0_DP3 );
-        break;
-
-      case OPCODE_DP4: 
-        EMIT_2ARG_ARITH( A0_DP4 );
-        break;
-
-      case 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 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];
+        /* tmp.x now contains a first approximation (y).  Now, weight it
+         * against tmp.y**2 to get closer.
          */
-        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  ),
+        i915_emit_arith(p,
+                         A0_MAX,
+                        tmp, A0_DEST_CHANNEL_Y, 0,
+                        swizzle(tmp, ZERO, X, ZERO, ZERO),
+                        negate(swizzle(tmp, ZERO, X, ZERO, ZERO), 0, 1, 0, 0),
                         0);
-        break;
 
-      case OPCODE_EX2: 
-        src0 = src_vector( p, &inst->SrcReg[0], program);
+        /* tmp.y = tmp.x * tmp.y - tmp.x; {y, y * abs(y) - y, 0, 0} */
+        i915_emit_arith(p,
+                        A0_MAD,
+                        tmp, A0_DEST_CHANNEL_Y, 0,
+                        swizzle(tmp, ZERO, X, ZERO, ZERO),
+                        swizzle(tmp, ZERO, Y, ZERO, ZERO),
+                        negate(swizzle(tmp, ZERO, X, ZERO, ZERO), 0, 1, 0, 0));
+
+        /* result = .2225 * tmp.y + tmp.x =.2225(y * abs(y) - y) + y= */
+        i915_emit_arith(p,
+                        A0_MAD,
+                         get_result_vector(p, inst),
+                         get_result_flags(inst), 0,
+                        swizzle(consts1, W, W, W, W),
+                        swizzle(tmp, Y, Y, Y, Y),
+                        swizzle(tmp, X, X, X, X));
+         break;
+
+      case OPCODE_DP3:
+         EMIT_2ARG_ARITH(A0_DP3);
+         break;
+
+      case OPCODE_DP4:
+         EMIT_2ARG_ARITH(A0_DP4);
+         break;
+
+      case OPCODE_DPH:
+         src0 = src_vector(p, &inst->SrcReg[0], program);
+         src1 = src_vector(p, &inst->SrcReg[1], 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;
+         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 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 OPCODE_FLR: 
-        EMIT_1ARG_ARITH( A0_FLR );
-        break;
+      case OPCODE_EX2:
+         src0 = src_vector(p, &inst->SrcReg[0], program);
 
-      case OPCODE_FRC: 
-        EMIT_1ARG_ARITH( A0_FRC );
-        break;
+         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 OPCODE_FLR:
+         EMIT_1ARG_ARITH(A0_FLR);
+         break;
+
+      case OPCODE_FRC:
+         EMIT_1ARG_ARITH(A0_FRC);
+         break;
 
       case 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 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 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 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 );
+         src0 = src_vector(p, &inst->SrcReg[0], program);
+         tmp = i915_get_utemp(p);
+
+         i915_emit_texld(p, get_live_regs(p, inst),
+                         tmp, A0_DEST_CHANNEL_ALL,   /* use a dummy dest reg */
+                         0, src0, T0_TEXKILL);
+         break;
+
+      case 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 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));
 
-        i915_emit_arith( p, A0_MAD, 
-                        get_result_vector( p, inst ), 
-                        flags, 0, 
-                        negate(src2, 1,1,1,1), src0, tmp );
-        break;
+         break;
+
+      case 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 OPCODE_MAD:
-        EMIT_3ARG_ARITH( A0_MAD );
-        break;
+         EMIT_3ARG_ARITH(A0_MAD);
+         break;
 
       case OPCODE_MAX:
-        EMIT_2ARG_ARITH( A0_MAX );
-        break;
-
-      case 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 OPCODE_MOV: 
-        EMIT_1ARG_ARITH( A0_MOV );
-        break;
-
-      case OPCODE_MUL: 
-        EMIT_2ARG_ARITH( A0_MUL );
-        break;
-
-      case 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);
+         EMIT_2ARG_ARITH(A0_MAX);
+         break;
 
-        i915_emit_arith( p,
-                        A0_MUL,
-                        tmp, A0_DEST_CHANNEL_X, 0,
-                        tmp, src1, 0);
+      case 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 OPCODE_MOV:
+         EMIT_1ARG_ARITH(A0_MOV);
+         break;
 
-        i915_emit_arith( p,
-                        A0_EXP,
-                        get_result_vector( p, inst ), 
-                        flags, 0,
-                        swizzle(tmp,X,X,X,X), 0, 0);
+      case OPCODE_MUL:
+         EMIT_2ARG_ARITH(A0_MUL);
+         break;
 
-        break;
+      case 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);
 
-      case OPCODE_RCP: 
-        src0 = src_vector( p, &inst->SrcReg[0], program);
+         /* 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_RCP,
-                        get_result_vector( p, inst ), 
-                        get_result_flags( inst ), 0,
-                        swizzle(src0,X,X,X,X), 0, 0);
-        break;
+         i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, tmp, src1, 0);
 
-      case OPCODE_RSQ: 
 
-        src0 = src_vector( p, &inst->SrcReg[0], program);
+         i915_emit_arith(p,
+                         A0_EXP,
+                         get_result_vector(p, inst),
+                         flags, 0, swizzle(tmp, X, X, X, X), 0, 0);
+
+         break;
+
+      case 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 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;
 
-        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 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);
+         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;
 
-        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 OPCODE_SGE: 
-        EMIT_2ARG_ARITH( A0_SGE );
-        break;
+      case OPCODE_SGE:
+         EMIT_2ARG_ARITH(A0_SGE);
+         break;
 
       case OPCODE_SIN:
-        src0 = src_vector( p, &inst->SrcReg[0], program);
-        tmp = i915_get_utemp( p );
+         src0 = src_vector(p, &inst->SrcReg[0], program);
+         tmp = i915_get_utemp(p);
+        consts0 = i915_emit_const4fv(p, sin_quad_constants[0]);
+        consts1 = i915_emit_const4fv(p, sin_quad_constants[1]);
+
+        /* Reduce range from repeating about [-pi,pi] to [-1,1] */
+         i915_emit_arith(p,
+                         A0_MAD,
+                         tmp, A0_DEST_CHANNEL_X, 0,
+                         src0,
+                        swizzle(consts1, Z, ZERO, ZERO, ZERO), /* 1/(2pi) */
+                        swizzle(consts0, Z, ZERO, ZERO, ZERO)); /* .5 */
+
+         i915_emit_arith(p, A0_FRC, tmp, A0_DEST_CHANNEL_X, 0, tmp, 0, 0);
+
+        i915_emit_arith(p,
+                        A0_MAD,
+                        tmp, A0_DEST_CHANNEL_X, 0,
+                        tmp,
+                        swizzle(consts0, X, ZERO, ZERO, ZERO), /* 2 */
+                        swizzle(consts0, Y, ZERO, ZERO, ZERO)); /* -1 */
 
-        i915_emit_arith( p, 
+        /* Compute sin using a quadratic and quartic.  It gives continuity
+         * that repeating the Taylor series lacks every 2*pi, and has
+         * reduced error.
+         *
+         * The idea was described at:
+         * http://www.devmaster.net/forums/showthread.php?t=5784
+         */
+
+        /* tmp.y = abs(tmp.x); {x, abs(x), 0, 0} */
+        i915_emit_arith(p,
+                         A0_MAX,
+                        tmp, A0_DEST_CHANNEL_Y, 0,
+                        swizzle(tmp, ZERO, X, ZERO, ZERO),
+                        negate(swizzle(tmp, ZERO, X, ZERO, ZERO), 0, 1, 0, 0),
+                        0);
+
+        /* tmp.y = tmp.y * tmp.x; {x, x * abs(x), 0, 0} */
+        i915_emit_arith(p,
                         A0_MUL,
-                        tmp, A0_DEST_CHANNEL_X, 0,
-                        src0, 
-                        i915_emit_const1f(p, 1.0/(M_PI * 2)),
+                        tmp, A0_DEST_CHANNEL_Y, 0,
+                        swizzle(tmp, ZERO, X, ZERO, ZERO),
+                        tmp,
                         0);
 
-        i915_emit_arith( p, 
-                        A0_MOD,
-                        tmp, A0_DEST_CHANNEL_X, 0,
-                        tmp, 
-                        0, 0 );
+        /* tmp.x = tmp.xy DP sin_quad_constants[2].xy */
+         i915_emit_arith(p,
+                         A0_DP3,
+                         tmp, A0_DEST_CHANNEL_X, 0,
+                        tmp,
+                         swizzle(consts1, X, Y, ZERO, ZERO),
+                        0);
 
-        /* By choosing different taylor constants, could get rid of this mul:
+        /* tmp.x now contains a first approximation (y).  Now, weight it
+         * against tmp.y**2 to get closer.
          */
-        i915_emit_arith( p, 
-                        A0_MUL,
-                        tmp, A0_DEST_CHANNEL_X, 0,
-                        tmp, 
-                        i915_emit_const1f(p, (M_PI * 2)),
+        i915_emit_arith(p,
+                         A0_MAX,
+                        tmp, A0_DEST_CHANNEL_Y, 0,
+                        swizzle(tmp, ZERO, X, ZERO, ZERO),
+                        negate(swizzle(tmp, ZERO, X, ZERO, ZERO), 0, 1, 0, 0),
                         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);
+        /* tmp.y = tmp.x * tmp.y - tmp.x; {y, y * abs(y) - y, 0, 0} */
+        i915_emit_arith(p,
+                        A0_MAD,
+                        tmp, A0_DEST_CHANNEL_Y, 0,
+                        swizzle(tmp, ZERO, X, ZERO, ZERO),
+                        swizzle(tmp, ZERO, Y, ZERO, ZERO),
+                        negate(swizzle(tmp, ZERO, X, ZERO, ZERO), 0, 1, 0, 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);
+        /* result = .2225 * tmp.y + tmp.x =.2225(y * abs(y) - y) + y= */
+        i915_emit_arith(p,
+                        A0_MAD,
+                         get_result_vector(p, inst),
+                         get_result_flags(inst), 0,
+                        swizzle(consts1, W, W, W, W),
+                        swizzle(tmp, Y, Y, Y, Y),
+                        swizzle(tmp, X, X, X, X));
 
-        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 OPCODE_SLT: 
-        EMIT_2ARG_ARITH( A0_SLT );
-        break;
-
-      case 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 OPCODE_SWZ: 
-        EMIT_1ARG_ARITH( A0_MOV ); /* extended swizzle handled natively */
-        break;
-
-      case OPCODE_TEX: 
-        EMIT_TEX( T0_TEXLD );
-        break;
+         break;
+
+      case OPCODE_SLT:
+         EMIT_2ARG_ARITH(A0_SLT);
+         break;
+
+      case 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 OPCODE_SWZ:
+         EMIT_1ARG_ARITH(A0_MOV);       /* extended swizzle handled natively */
+         break;
+
+      case OPCODE_TEX:
+         EMIT_TEX(T0_TEXLD);
+         break;
 
       case OPCODE_TXB:
-        EMIT_TEX( T0_TEXLDB );
-        break;
+         EMIT_TEX(T0_TEXLDB);
+         break;
 
       case OPCODE_TXP:
-        EMIT_TEX( T0_TEXLDP );
-        break;
+         EMIT_TEX(T0_TEXLDP);
+         break;
 
       case 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;
+         /* 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 OPCODE_END:
-        return;
-        
+         return;
+
       default:
-        i915_program_error( p, "bad opcode" );
-        return;
+         i915_program_error(p, "bad opcode");
+         return;
       }
 
       inst++;
-      i915_release_utemps( p ); 
+      i915_release_utemps(p);
    }
 }
 
@@ -769,21 +881,22 @@ static void upload_program( struct i915_fragment_program *p )
  * 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 )
+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);
+      i915_emit_arith(p,
+                      A0_MOV,
+                      depth, A0_DEST_CHANNEL_W, 0,
+                      swizzle(depth, X, Y, Z, Z), 0, 0);
    }
 }
 
 
-static void check_wpos( struct i915_fragment_program *p )
+static void
+check_wpos(struct i915_fragment_program *p)
 {
    GLuint inputs = p->FragProg.Base.InputsRead;
    GLint i;
@@ -791,12 +904,12 @@ static void check_wpos( struct i915_fragment_program *p )
    p->wpos_tex = -1;
 
    for (i = 0; i < p->ctx->Const.MaxTextureCoordUnits; i++) {
-      if (inputs & FRAG_BIT_TEX(i)) 
-        continue;
+      if (inputs & FRAG_BIT_TEX(i))
+         continue;
       else if (inputs & FRAG_BIT_WPOS) {
-        p->wpos_tex = i;
-        inputs &= ~FRAG_BIT_WPOS;
-      }   
+         p->wpos_tex = i;
+         inputs &= ~FRAG_BIT_WPOS;
+      }
    }
 
    if (inputs & FRAG_BIT_WPOS) {
@@ -805,53 +918,54 @@ static void check_wpos( struct i915_fragment_program *p )
 }
 
 
-static void translate_program( struct i915_fragment_program *p )
+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 ); 
-   
+   struct i915_context *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 )
+static void
+track_params(struct i915_fragment_program *p)
 {
    GLint i;
 
    if (p->nr_params)
-      _mesa_load_state_parameters(p->ctx, p->FragProg.Base.Parameters); 
+      _mesa_load_state_parameters(p->ctx, p->FragProg.Base.Parameters);
 
    for (i = 0; i < p->nr_params; i++) {
       GLint reg = p->param[i].reg;
-      COPY_4V( p->constant[reg], p->param[i].values );
+      COPY_4V(p->constant[reg], p->param[i].values);
    }
-   
+
    p->params_uptodate = 1;
-   p->on_hardware = 0;         /* overkill */
+   p->on_hardware = 0;          /* overkill */
 }
 
 
-static void i915BindProgram( GLcontext *ctx,
-                           GLenum target, 
-                           struct gl_program *prog )
+static void
+i915BindProgram(GLcontext * ctx, GLenum target, struct gl_program *prog)
 {
    if (target == GL_FRAGMENT_PROGRAM_ARB) {
-      i915ContextPtr i915 = I915_CONTEXT(ctx);
-      struct i915_fragment_program *p = (struct i915_fragment_program *)prog;
+      struct i915_context *i915 = I915_CONTEXT(ctx);
+      struct i915_fragment_program *p = (struct i915_fragment_program *) prog;
+
+      if (i915->current_program == p)
+         return;
 
-      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->on_hardware = 0;
+         i915->current_program->params_uptodate = 0;
       }
-      
+
       i915->current_program = p;
 
       assert(p->on_hardware == 0);
@@ -860,71 +974,70 @@ static void i915BindProgram( GLcontext *ctx,
    }
 }
 
-static struct gl_program *i915NewProgram( GLcontext *ctx,
-                                     GLenum target, 
-                                     GLuint id )
+static struct gl_program *
+i915NewProgram(GLcontext * ctx, GLenum target, GLuint id)
 {
    switch (target) {
    case GL_VERTEX_PROGRAM_ARB:
-      return _mesa_init_vertex_program( ctx, CALLOC_STRUCT(gl_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 );
+      return _mesa_init_vertex_program(ctx, CALLOC_STRUCT(gl_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;
       }
-      else
-        return NULL;
-   }
 
    default:
       /* Just fallback:
        */
-      return _mesa_new_program( ctx, target, id );
+      return _mesa_new_program(ctx, target, id);
    }
 }
 
-static void i915DeleteProgram( GLcontext *ctx,
-                             struct gl_program *prog )
+static void
+i915DeleteProgram(GLcontext * ctx, struct gl_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;
+      struct i915_context *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 );
+   _mesa_delete_program(ctx, prog);
 }
 
 
-static GLboolean i915IsProgramNative( GLcontext *ctx,
-                                    GLenum target, 
-                                    struct gl_program *prog )
+static GLboolean
+i915IsProgramNative(GLcontext * ctx, GLenum target, struct gl_program *prog)
 {
    if (target == GL_FRAGMENT_PROGRAM_ARB) {
-      struct i915_fragment_program *p = (struct i915_fragment_program *)prog;
+      struct i915_fragment_program *p = (struct i915_fragment_program *) prog;
 
       if (!p->translated)
-        translate_program( p );
-      
+         translate_program(p);
+
       return !p->error;
    }
    else
       return GL_TRUE;
 }
 
-static void i915ProgramStringNotify( GLcontext *ctx,
-                                   GLenum target,
-                                   struct gl_program *prog )
+static void
+i915ProgramStringNotify(GLcontext * ctx,
+                        GLenum target, struct gl_program *prog)
 {
    if (target == GL_FRAGMENT_PROGRAM_ARB) {
-      struct i915_fragment_program *p = (struct i915_fragment_program *)prog;
+      struct i915_fragment_program *p = (struct i915_fragment_program *) prog;
       p->translated = 0;
 
       /* Hack: make sure fog is correctly enabled according to this
@@ -941,28 +1054,28 @@ static void i915ProgramStringNotify( GLcontext *ctx,
 }
 
 
-void i915ValidateFragmentProgram( i915ContextPtr i915 )
+void
+i915ValidateFragmentProgram(struct i915_context *i915)
 {
    GLcontext *ctx = &i915->intel.ctx;
-   intelContextPtr intel = INTEL_CONTEXT(ctx);
+   struct intel_context *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;
+   struct i915_fragment_program *p =
+      (struct i915_fragment_program *) ctx->FragmentProgram._Current;
 
    const GLuint inputsRead = p->FragProg.Base.InputsRead;
    GLuint s4 = i915->state.Ctx[I915_CTXREG_LIS4] & ~S4_VFMT_MASK;
    GLuint s2 = S2_TEXCOORD_NONE;
    int i, offset = 0;
 
-   if (i915->current_program != p) 
-   {
+   if (i915->current_program != p) {
       if (i915->current_program) {
-        i915->current_program->on_hardware = 0;
-        i915->current_program->params_uptodate = 0;
+         i915->current_program->on_hardware = 0;
+         i915->current_program->params_uptodate = 0;
       }
-      
+
       i915->current_program = p;
    }
 
@@ -971,8 +1084,8 @@ void i915ValidateFragmentProgram( i915ContextPtr i915 )
     */
    VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
 
-   if (!p->translated) 
-      translate_program( p );
+   if (!p->translated)
+      translate_program(p);
 
    intel->vertex_attr_count = 0;
    intel->wpos_offset = 0;
@@ -981,31 +1094,31 @@ void i915ValidateFragmentProgram( i915ContextPtr i915 )
    intel->specoffset = 0;
 
    if (inputsRead & FRAG_BITS_TEX_ANY) {
-      EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, S4_VFMT_XYZW, 16 );
+      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 );
+      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 );
+      EMIT_ATTR(_TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, S4_VFMT_COLOR, 4);
    }
-   
-   if ((inputsRead & (FRAG_BIT_COL1|FRAG_BIT_FOGC)) || 
+
+   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 );
+         intel->specoffset = offset / 4;
+         EMIT_ATTR(_TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, S4_VFMT_SPEC_FOG, 3);
       }
       else
-        EMIT_PAD(3);
+         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 );
+      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 );
+         EMIT_PAD(1);
    }
 
    /* XXX this was disabled, but enabling this code helped fix the Glean
@@ -1013,63 +1126,66 @@ void i915ValidateFragmentProgram( i915ContextPtr i915 )
     */
 #if 1
    if ((inputsRead & FRAG_BIT_FOGC) || i915->vertex_fog != I915_FOG_NONE) {
-      EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1F, S4_VFMT_FOG_PARAM, 4 );
+      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));
+         int sz = VB->TexCoordPtr[i]->size;
 
-        EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_SZ(sz), 0, sz * 4 );
+         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);
+         /* 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 );
-      }   
+         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 );
+      int k;
+
+      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 = _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 ));
+      k = intel->vtbl.check_vertex_size(intel, intel->vertex_size);
+      assert(k);
    }
 
-   if (!p->params_uptodate) 
-      track_params( p );
+   if (!p->params_uptodate)
+      track_params(p);
 
-   if (!p->on_hardware) 
-      i915_upload_program( i915, p );
+   if (!p->on_hardware)
+      i915_upload_program(i915, p);
 }
 
-void i915InitFragProgFuncs( struct dd_function_table *functions )
+void
+i915InitFragProgFuncs(struct dd_function_table *functions)
 {
    functions->BindProgram = i915BindProgram;
    functions->NewProgram = i915NewProgram;
index 1be7ac4c48531fe81624f7f75f378648e22b9012..bfe97f13e57162be0f7969f17c94a12e566ba7cb 100644 (file)
 
 #include "intel_screen.h"
 #include "intel_batchbuffer.h"
-#include "intel_ioctl.h"
-#include "intel_rotate.h"
+#include "intel_regions.h"
 
 #include "i915_context.h"
 #include "i915_reg.h"
 
-/* A large amount of state doesn't need to be uploaded.
+/* We touch almost everything:
  */
-#define ACTIVE (I915_UPLOAD_INVARIENT |         \
-               I915_UPLOAD_PROGRAM |           \
-               I915_UPLOAD_STIPPLE |           \
+#define ACTIVE (I915_UPLOAD_INVARIENT |        \
                I915_UPLOAD_CTX |               \
                I915_UPLOAD_BUFFERS |           \
-               I915_UPLOAD_TEX(0))             
+               I915_UPLOAD_STIPPLE |           \
+                I915_UPLOAD_PROGRAM |          \
+                I915_UPLOAD_FOG |              \
+               I915_UPLOAD_TEX(0))
 
-#define SET_STATE( i915, STATE )                       \
+#define SET_STATE( i915, STATE )               \
 do {                                           \
    i915->current->emitted &= ~ACTIVE;          \
-   i915->current = &i915->STATE;                       \
+   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 )
+static void
+meta_no_stencil_write(struct intel_context *intel)
 {
+   struct i915_context *i915 = i915_context(&intel->ctx);
+
    /* ctx->Driver.Enable( ctx, GL_STENCIL_TEST, GL_FALSE )
     */
-   i915->meta.Ctx[I915_CTXREG_LIS5] &= ~(S5_STENCIL_TEST_ENABLE | 
-                                      S5_STENCIL_WRITE_ENABLE);
+   i915->meta.Ctx[I915_CTXREG_LIS5] &= ~(S5_STENCIL_TEST_ENABLE |
+                                         S5_STENCIL_WRITE_ENABLE);
+
+   i915->meta.emitted &= ~I915_UPLOAD_CTX;
+}
+
+static void
+meta_no_depth_write(struct intel_context *intel)
+{
+   struct i915_context *i915 = i915_context(&intel->ctx);
 
    /* ctx->Driver.Enable( ctx, GL_DEPTH_TEST, GL_FALSE )
     */
    i915->meta.Ctx[I915_CTXREG_LIS6] &= ~(S6_DEPTH_TEST_ENABLE |
-                                      S6_DEPTH_WRITE_ENABLE);
+                                         S6_DEPTH_WRITE_ENABLE);
 
    i915->meta.emitted &= ~I915_UPLOAD_CTX;
 }
 
+static void
+meta_depth_replace(struct intel_context *intel)
+{
+   struct i915_context *i915 = i915_context(&intel->ctx);
+
+   /* ctx->Driver.Enable( ctx, GL_DEPTH_TEST, GL_TRUE )
+    * ctx->Driver.DepthMask( ctx, GL_TRUE )
+    */
+   i915->meta.Ctx[I915_CTXREG_LIS6] |= (S6_DEPTH_TEST_ENABLE |
+                                        S6_DEPTH_WRITE_ENABLE);
+
+   /* ctx->Driver.DepthFunc( ctx, GL_ALWAYS )
+    */
+   i915->meta.Ctx[I915_CTXREG_LIS6] &= ~S6_DEPTH_TEST_FUNC_MASK;
+   i915->meta.Ctx[I915_CTXREG_LIS6] |=
+      COMPAREFUNC_ALWAYS << S6_DEPTH_TEST_FUNC_SHIFT;
+
+   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)
+static void
+meta_stencil_replace(struct intel_context *intel,
+                     GLuint s_mask, GLuint s_clear)
 {
+   struct i915_context *i915 = i915_context(&intel->ctx);
    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);
-
+   i915->meta.Ctx[I915_CTXREG_LIS5] |= (S5_STENCIL_TEST_ENABLE |
+                                        S5_STENCIL_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));
-
+                                          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);
+                                         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));
+                                        (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));
+                                          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)); 
+                                         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 )
+static void
+meta_color_mask(struct intel_context *intel, GLboolean state)
 {
+   struct i915_context *i915 = i915_context(&intel->ctx);
    const GLuint mask = (S5_WRITEDISABLE_RED |
-                       S5_WRITEDISABLE_GREEN |
-                       S5_WRITEDISABLE_BLUE |
-                       S5_WRITEDISABLE_ALPHA);
+                        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);
+      i915->meta.Ctx[I915_CTXREG_LIS5] |=
+         (i915->state.Ctx[I915_CTXREG_LIS5] & mask);
    }
-   else 
+   else
       i915->meta.Ctx[I915_CTXREG_LIS5] |= mask;
-      
+
+   i915->meta.emitted &= ~I915_UPLOAD_CTX;
+}
+
+
+
+static void
+meta_import_pixel_state(struct intel_context *intel)
+{
+   struct i915_context *i915 = i915_context(&intel->ctx);
+   memcpy(i915->meta.Fog, i915->state.Fog, I915_FOG_SETUP_SIZE * 4);
+
+   i915->meta.Ctx[I915_CTXREG_LIS5] = i915->state.Ctx[I915_CTXREG_LIS5];
+   i915->meta.Ctx[I915_CTXREG_LIS6] = i915->state.Ctx[I915_CTXREG_LIS6];
+   i915->meta.Ctx[I915_CTXREG_STATE4] = i915->state.Ctx[I915_CTXREG_STATE4];
+   i915->meta.Ctx[I915_CTXREG_BLENDCOLOR1] =
+      i915->state.Ctx[I915_CTXREG_BLENDCOLOR1];
+   i915->meta.Ctx[I915_CTXREG_IAB] = i915->state.Ctx[I915_CTXREG_IAB];
+
+   i915->meta.Buffer[I915_DESTREG_SENABLE] =
+      i915->state.Buffer[I915_DESTREG_SENABLE];
+   i915->meta.Buffer[I915_DESTREG_SR1] = i915->state.Buffer[I915_DESTREG_SR1];
+   i915->meta.Buffer[I915_DESTREG_SR2] = i915->state.Buffer[I915_DESTREG_SR2];
+
+   i915->meta.emitted &= ~I915_UPLOAD_FOG;
+   i915->meta.emitted &= ~I915_UPLOAD_BUFFERS;
    i915->meta.emitted &= ~I915_UPLOAD_CTX;
 }
 
@@ -212,69 +252,64 @@ static void set_color_mask( i915ContextPtr i915, GLboolean state )
 
 
 
-static void set_no_texture( i915ContextPtr i915 )
+static void
+meta_no_texture(struct intel_context *intel)
 {
+   struct i915_context *i915 = i915_context(&intel->ctx);
+
    static const GLuint prog[] = {
       _3DSTATE_PIXEL_SHADER_PROGRAM,
 
       /* Declare incoming diffuse color:
        */
-      (D0_DCL |
-       D0_DECL_REG( REG_T_DIFFUSE ) |
-       D0_CHANNEL_ALL),
+      (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 )),
+       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) );
+
+   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;
 }
 
-
-static void enable_texture_blend_replace( i915ContextPtr i915 )
+static void
+meta_texture_blend_replace(struct intel_context *intel)
 {
+   struct i915_context *i915 = i915_context(&intel->ctx);
+
    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),
+      (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),
+      (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 )),
+      (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) );
+   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;
@@ -287,425 +322,186 @@ static void enable_texture_blend_replace( i915ContextPtr i915 )
 /* 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, /* in bytes! */
-                                GLuint textureFormat )
+static GLboolean
+meta_tex_rect_source(struct intel_context *intel,
+                     dri_bo *buffer,
+                     GLuint offset,
+                     GLuint pitch, GLuint height, GLenum format, GLenum type)
 {
+   struct i915_context *i915 = i915_context(&intel->ctx);
    GLuint unit = 0;
    GLint numLevels = 1;
    GLuint *state = i915->meta.Tex[0];
+   GLuint textureFormat;
+   GLuint cpp;
 
-#if 0
-   printf("TexRect source offset 0x%x  pitch %d\n", offset, pitch);
-#endif
+   /* A full implementation of this would do the upload through
+    * glTexImage2d, and get all the conversion operations at that
+    * point.  We are restricted, but still at least have access to the
+    * fragment program swizzle.
+    */
+   switch (format) {
+   case GL_BGRA:
+      switch (type) {
+      case GL_UNSIGNED_INT_8_8_8_8_REV:
+      case GL_UNSIGNED_BYTE:
+         textureFormat = (MAPSURF_32BIT | MT_32BIT_ARGB8888);
+         cpp = 4;
+         break;
+      default:
+         return GL_FALSE;
+      }
+      break;
+   case GL_RGBA:
+      switch (type) {
+      case GL_UNSIGNED_INT_8_8_8_8_REV:
+      case GL_UNSIGNED_BYTE:
+         textureFormat = (MAPSURF_32BIT | MT_32BIT_ABGR8888);
+         cpp = 4;
+         break;
+      default:
+         return GL_FALSE;
+      }
+      break;
+   case GL_BGR:
+      switch (type) {
+      case GL_UNSIGNED_SHORT_5_6_5_REV:
+         textureFormat = (MAPSURF_16BIT | MT_16BIT_RGB565);
+         cpp = 2;
+         break;
+      default:
+         return GL_FALSE;
+      }
+      break;
+   case GL_RGB:
+      switch (type) {
+      case GL_UNSIGNED_SHORT_5_6_5:
+         textureFormat = (MAPSURF_16BIT | MT_16BIT_RGB565);
+         cpp = 2;
+         break;
+      default:
+         return GL_FALSE;
+      }
+      break;
 
-/*    fprintf(stderr, "%s: offset: %x w: %d h: %d pitch %d format %x\n", */
-/*        __FUNCTION__, offset, width, height, pitch, textureFormat ); */
+   default:
+      return GL_FALSE;
+   }
+
+
+   if ((pitch * cpp) & 3) {
+      _mesa_printf("%s: texture is not dword pitch\n", __FUNCTION__);
+      return GL_FALSE;
+   }
+
+/*    intel_region_release(&i915->meta.tex_region[0]); */
+/*    intel_region_reference(&i915->meta.tex_region[0], region); */
+   i915->meta.tex_buffer[0] = buffer;
+   i915->meta.tex_offset[0] = offset;
 
-   state[I915_TEXREG_MS2] = offset;
    state[I915_TEXREG_MS3] = (((height - 1) << MS3_HEIGHT_SHIFT) |
-                           ((width - 1) << MS3_WIDTH_SHIFT) |
-                           textureFormat |
-                           MS3_USE_FENCE_REGS);
+                             ((pitch - 1) << MS3_WIDTH_SHIFT) |
+                             textureFormat | MS3_USE_FENCE_REGS);
 
-   state[I915_TEXREG_MS4] = ((((pitch / 4) - 1) << MS4_PITCH_SHIFT) | 
-                           ((((numLevels-1) * 4)) << MS4_MAX_LOD_SHIFT));
+   state[I915_TEXREG_MS4] = (((((pitch * cpp) / 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));
+                             (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));
+                             (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);
+   return GL_TRUE;
 }
 
 
-/* Select between front and back draw buffers.
+/**
+ * Set the color and depth drawing region for meta ops.
  */
-static void set_draw_region( i915ContextPtr i915, const intelRegion *region )
+static void
+meta_draw_region(struct intel_context *intel,
+                 struct intel_region *color_region,
+                 struct intel_region *depth_region)
 {
-#if 0
-   printf("Rotate into region: offset 0x%x  pitch %d\n",
-          region->offset, region->pitch);
-#endif
-   i915->meta.Buffer[I915_DESTREG_CBUFADDR1] =
-      (BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(region->pitch) | BUF_3D_USE_FENCE);
-   i915->meta.Buffer[I915_DESTREG_CBUFADDR2] = region->offset;
-   i915->meta.emitted &= ~I915_UPLOAD_BUFFERS;
+   struct i915_context *i915 = i915_context(&intel->ctx);
+   i915_state_draw_region(intel, &i915->meta, color_region, depth_region);
 }
 
 
-#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)
+static void
+set_vertex_format(struct intel_context *intel)
 {
-   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
+   struct i915_context *i915 = i915_context(&intel->ctx);
 
-static void set_vertex_format( i915ContextPtr i915 )
-{
-   i915->meta.Ctx[I915_CTXREG_LIS2] = 
+   i915->meta.Ctx[I915_CTXREG_LIS2] =
       (S2_TEXCOORD_FMT(0, TEXCOORDFMT_2D) |
-       S2_TEXCOORD_FMT(1, TEXCOORDFMT_NOT_PRESENT) | 
+       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(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.Ctx[I915_CTXREG_LIS4] |= (S4_VFMT_COLOR | S4_VFMT_XYZ);
 
    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];
-}
-
 
-static void draw_poly(i915ContextPtr i915, 
-                     GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha,
-                      GLuint numVerts,
-                      /*const*/ GLfloat verts[][2],
-                      /*const*/ GLfloat texcoords[][2])
+/* 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
+install_meta_state(struct intel_context *intel)
 {
-   GLuint vertex_size = 8;
-   GLuint *vb = intelEmitInlinePrimitiveLocked( &i915->intel, 
-                                               PRIM3D_TRIFAN, 
-                                               numVerts * vertex_size,
-                                               vertex_size );
-   intelVertex tmp;
-   int i, k;
-
-   /* initial constant vertex fields */
-   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;
-
-   for (k = 0; k < numVerts; k++) {
-      tmp.v.x = verts[k][0];
-      tmp.v.y = verts[k][1];
-      tmp.v.u0 = texcoords[k][0];
-      tmp.v.v0 = texcoords[k][1];
-
-      for (i = 0 ; i < vertex_size ; i++)
-         vb[i] = tmp.ui[i];
-
-      vb += vertex_size;
-   }
-}
+   struct i915_context *i915 = i915_context(&intel->ctx);
+   memcpy(&i915->meta, &i915->initial, sizeof(i915->meta));
+   i915->meta.active = ACTIVE;
+   i915->meta.emitted = 0;
 
+   SET_STATE(i915, meta);
+   set_vertex_format(intel);
+   meta_no_texture(intel);
+}
 
-void 
-i915ClearWithTris(intelContextPtr intel, GLbitfield buffers,
-                 GLboolean allFoo,
-                 GLint cxFoo, GLint cyFoo, GLint cwFoo, GLint chFoo)
+static void
+leave_meta_state(struct intel_context *intel)
 {
-   i915ContextPtr i915 = I915_CONTEXT( intel );
-   __DRIdrawablePrivate *dPriv = intel->driDrawable;
-   intelScreenPrivate *screen = intel->intelScreen;
-   int x0, y0, x1, y1;
-   GLint cx, cy, cw, ch;
-   GLboolean all;
-
-   SET_STATE( i915, meta ); 
-   set_initial_state( i915 ); 
-   set_no_texture( i915 ); 
-   set_vertex_format( i915 ); 
-
-   LOCK_HARDWARE(intel);
-
-   /* get clear bounds after locking */
-   cx = intel->ctx.DrawBuffer->_Xmin;
-   cy = intel->ctx.DrawBuffer->_Ymin;
-   cw = intel->ctx.DrawBuffer->_Xmax - cx;
-   ch = intel->ctx.DrawBuffer->_Ymax - cy;
-   all = (cw == intel->ctx.DrawBuffer->Width &&
-          ch == intel->ctx.DrawBuffer->Height);
-
-   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 (buffers & BUFFER_BIT_FRONT_LEFT) { 
-      set_no_depth_stencil_write( i915 );
-      set_color_mask( i915, GL_TRUE );
-      set_draw_region( i915, &screen->front );
-
-      draw_quad(i915, x0, x1, y0, y1,
-               intel->clear_red, intel->clear_green, 
-               intel->clear_blue, intel->clear_alpha, 
-               0, 0, 0, 0);
-   }
-
-   if (buffers & BUFFER_BIT_BACK_LEFT) {
-      set_no_depth_stencil_write( i915 );
-      set_color_mask( i915, GL_TRUE );
-      set_draw_region( i915, &screen->back );
-
-      draw_quad(i915, x0, x1, y0, y1,
-               intel->clear_red, intel->clear_green,
-               intel->clear_blue, intel->clear_alpha,
-               0, 0, 0, 0);
-   }
-
-   if (buffers & BUFFER_BIT_STENCIL) {
-      set_stencil_replace( i915, 
-                          intel->ctx.Stencil.WriteMask[0], 
-                          intel->ctx.Stencil.Clear);
-      
-      set_color_mask( i915, GL_FALSE );
-      set_draw_region( i915, &screen->front ); /* 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 );
+   struct i915_context *i915 = i915_context(&intel->ctx);
+   intel_region_release(&i915->meta.draw_region);
+   intel_region_release(&i915->meta.depth_region);
+/*    intel_region_release(&i915->meta.tex_region[0]); */
+   SET_STATE(i915, state);
 }
 
 
-/**
- * Copy the window contents named by dPriv to the rotated (or reflected)
- * color buffer.
- * srcBuf is BUFFER_BIT_FRONT_LEFT or BUFFER_BIT_BACK_LEFT to indicate the source.
- */
+
 void
-i915RotateWindow(intelContextPtr intel, __DRIdrawablePrivate *dPriv,
-                 GLuint srcBuf)
+i915InitMetaFuncs(struct i915_context *i915)
 {
-   i915ContextPtr i915 = I915_CONTEXT( intel );
-   intelScreenPrivate *screen = intel->intelScreen;
-   const GLuint cpp = screen->cpp;
-   drm_clip_rect_t fullRect;
-   GLuint textureFormat, srcOffset, srcPitch;
-   const drm_clip_rect_t *clipRects;
-   int numClipRects;
-   int i;
-
-   int xOrig, yOrig;
-   int origNumClipRects;
-   drm_clip_rect_t *origRects;
-
-   /*
-    * set up hardware state
-    */
-   intelFlush( &intel->ctx );
-
-   SET_STATE( i915, meta ); 
-   set_initial_state( i915 ); 
-   set_no_texture( i915 ); 
-   set_vertex_format( i915 ); 
-   set_no_depth_stencil_write( i915 );
-   set_color_mask( i915, GL_TRUE );
-
-   LOCK_HARDWARE(intel);
-
-   /* save current drawing origin and cliprects (restored at end) */
-   xOrig = intel->drawX;
-   yOrig = intel->drawY;
-   origNumClipRects = intel->numClipRects;
-   origRects = intel->pClipRects;
-
-   if (!intel->numClipRects)
-      goto done;
-
-   /*
-    * set drawing origin, cliprects for full-screen access to rotated screen
-    */
-   fullRect.x1 = 0;
-   fullRect.y1 = 0;
-   fullRect.x2 = screen->rotatedWidth;
-   fullRect.y2 = screen->rotatedHeight;
-   intel->drawX = 0;
-   intel->drawY = 0;
-   intel->numClipRects = 1;
-   intel->pClipRects = &fullRect;
-
-   set_draw_region( i915, &screen->rotated );
-
-   if (cpp == 4)
-      textureFormat = MAPSURF_32BIT | MT_32BIT_ARGB8888;
-   else
-      textureFormat = MAPSURF_16BIT | MT_16BIT_RGB565;
-
-   if (srcBuf == BUFFER_BIT_FRONT_LEFT) {
-      srcPitch = screen->front.pitch;   /* in bytes */
-      srcOffset = screen->front.offset; /* bytes */
-      clipRects = dPriv->pClipRects;
-      numClipRects = dPriv->numClipRects;
-   }
-   else {
-      srcPitch = screen->back.pitch;   /* in bytes */
-      srcOffset = screen->back.offset; /* bytes */
-      clipRects = dPriv->pBackClipRects;
-      numClipRects = dPriv->numBackClipRects;
-   }
-
-   /* set the whole screen up as a texture to avoid alignment issues */
-   set_tex_rect_source(i915,
-                       srcOffset,
-                       screen->width,
-                      screen->height,
-                       srcPitch,
-                       textureFormat);
-
-   enable_texture_blend_replace(i915);
-
-   /*
-    * loop over the source window's cliprects
-    */
-   for (i = 0; i < numClipRects; i++) {
-      int srcX0 = clipRects[i].x1;
-      int srcY0 = clipRects[i].y1;
-      int srcX1 = clipRects[i].x2;
-      int srcY1 = clipRects[i].y2;
-      GLfloat verts[4][2], tex[4][2];
-      int j;
-
-      /* build vertices for four corners of clip rect */
-      verts[0][0] = srcX0;  verts[0][1] = srcY0;
-      verts[1][0] = srcX1;  verts[1][1] = srcY0;
-      verts[2][0] = srcX1;  verts[2][1] = srcY1;
-      verts[3][0] = srcX0;  verts[3][1] = srcY1;
-
-      /* .. and texcoords */
-      tex[0][0] = srcX0;  tex[0][1] = srcY0;
-      tex[1][0] = srcX1;  tex[1][1] = srcY0;
-      tex[2][0] = srcX1;  tex[2][1] = srcY1;
-      tex[3][0] = srcX0;  tex[3][1] = srcY1;
-
-      /* transform coords to rotated screen coords */
-      for (j = 0; j < 4; j++) {
-         matrix23TransformCoordf(&screen->rotMatrix,
-                                 &verts[j][0], &verts[j][1]);
-      }
-
-      /* draw polygon to map source image to dest region */
-      draw_poly(i915, 255, 255, 255, 255, 4, verts, tex);
-
-   } /* cliprect loop */
-
-   intelFlushBatchLocked( intel, GL_FALSE, GL_FALSE, GL_FALSE );
-
- done:
-   /* restore original drawing origin and cliprects */
-   intel->drawX = xOrig;
-   intel->drawY = yOrig;
-   intel->numClipRects = origNumClipRects;
-   intel->pClipRects = origRects;
-
-   UNLOCK_HARDWARE(intel);
-
-   SET_STATE( i915, state );
+   i915->intel.vtbl.install_meta_state = install_meta_state;
+   i915->intel.vtbl.leave_meta_state = leave_meta_state;
+   i915->intel.vtbl.meta_no_depth_write = meta_no_depth_write;
+   i915->intel.vtbl.meta_no_stencil_write = meta_no_stencil_write;
+   i915->intel.vtbl.meta_stencil_replace = meta_stencil_replace;
+   i915->intel.vtbl.meta_depth_replace = meta_depth_replace;
+   i915->intel.vtbl.meta_color_mask = meta_color_mask;
+   i915->intel.vtbl.meta_no_texture = meta_no_texture;
+   i915->intel.vtbl.meta_texture_blend_replace = meta_texture_blend_replace;
+   i915->intel.vtbl.meta_tex_rect_source = meta_tex_rect_source;
+   i915->intel.vtbl.meta_draw_region = meta_draw_region;
+   i915->intel.vtbl.meta_import_pixel_state = meta_import_pixel_state;
 }
-
index 68491124449ff0f0beb4facebd8e10f2f292d557..f79d00ddcf30d730f9ce9b4c7ad484870b001249 100644 (file)
 
 #define I915_CONSTFLAG_PARAM 0x1f
 
-GLuint i915_get_temp( struct i915_fragment_program *p )
+GLuint
+i915_get_temp(struct i915_fragment_program *p)
 {
-   int bit = ffs( ~p->temp_flag );
+   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));
+   p->temp_flag |= 1 << (bit - 1);
+   return UREG(REG_TYPE_R, (bit - 1));
 }
 
 
-GLuint i915_get_utemp( struct i915_fragment_program *p )
+GLuint
+i915_get_utemp(struct i915_fragment_program * p)
 {
-   int bit = ffs( ~p->utemp_flag );
+   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));
+   p->utemp_flag |= 1 << (bit - 1);
+   return UREG(REG_TYPE_U, (bit - 1));
 }
 
-void i915_release_utemps( struct i915_fragment_program *p )
+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
+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;
+      if (p->decl_t & (1 << nr))
+         return reg;
 
-      p->decl_t |= (1<<nr);
+      p->decl_t |= (1 << nr);
    }
    else if (type == REG_TYPE_S) {
-      if (p->decl_s & (1<<nr))
-        return reg;
+      if (p->decl_s & (1 << nr))
+         return reg;
 
-      p->decl_s |= (1<<nr);
+      p->decl_s |= (1 << nr);
    }
-   else 
+   else
       return reg;
 
-   *(p->decl++) = (D0_DCL | D0_DEST( reg ) | d0_flags);
+   *(p->decl++) = (D0_DCL | D0_DEST(reg) | d0_flags);
    *(p->decl++) = D1_MBZ;
    *(p->decl++) = D2_MBZ;
 
@@ -131,24 +135,26 @@ GLuint i915_emit_decl( struct i915_fragment_program *p,
    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
+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)));
+   dest = UREG(GET_UREG_TYPE(dest), GET_UREG_NR(dest));
+   assert(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;
+   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 -
@@ -164,57 +170,67 @@ GLuint i915_emit_arith( struct i915_fragment_program *p,
       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;
-        }
+      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->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->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;
 }
 
+static GLuint get_free_rreg (struct i915_fragment_program *p, 
+                             GLuint live_regs)
+{
+    int bit = ffs(~live_regs);
+    if (!bit) {
+        i915_program_error(p, "Can't find free R reg");
+        return UREG_BAD;
+    }
+    return UREG(REG_TYPE_R, bit - 1);
+}
+
 GLuint i915_emit_texld( struct i915_fragment_program *p,
+                       GLuint live_regs,               
                        GLuint dest,
                        GLuint destmask,
                        GLuint sampler,
                        GLuint coord,
                        GLuint op )
 {
-   if (coord != UREG(GET_UREG_TYPE(coord), GET_UREG_NR(coord))) {
-      /* No real way to work around this in the general case - need to
-       * allocate and declare a new temporary register (a utemp won't
-       * do).  Will fallback for now.
-       */
-      i915_program_error(p, "Can't (yet) swizzle TEX arguments");
-      return 0;
-   }
-
-   /* Don't worry about saturate as we only support  
+    if (coord != UREG(GET_UREG_TYPE(coord), GET_UREG_NR(coord))) {
+        /* With the help of the "needed registers" table created earlier, pick
+         * a register we can MOV the swizzled TC to (since TEX doesn't support
+         * swizzled sources) */
+        GLuint swizCoord = get_free_rreg(p, live_regs);
+        if (swizCoord == UREG_BAD) 
+            return 0;
+
+        i915_emit_arith( p, A0_MOV, swizCoord, A0_DEST_CHANNEL_ALL, 0, coord, 0, 0 );
+        coord = swizCoord;
+    }
+
+   /* Don't worry about saturate as we only support texture formats
+    * that are always in the 0..1 range.
     */
    if (destmask != A0_DEST_CHANNEL_ALL) {
       GLuint tmp = i915_get_utemp(p);
-      i915_emit_texld( p, tmp, A0_DEST_CHANNEL_ALL, sampler, coord, op );
+      i915_emit_texld( p, 0, tmp, A0_DEST_CHANNEL_ALL, sampler, coord, op );
       i915_emit_arith( p, A0_MOV, dest, destmask, 0, tmp, 0, 0 );
       return dest;
    }
@@ -239,24 +255,28 @@ GLuint i915_emit_texld( struct i915_fragment_program *p,
 }
 
 
-GLuint i915_emit_const1f( struct i915_fragment_program *p, GLfloat c0 )
+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 );
+   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;
+         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);
-        }
+         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);
+         }
       }
    }
 
@@ -265,29 +285,35 @@ GLuint i915_emit_const1f( struct i915_fragment_program *p, GLfloat c0 )
    return 0;
 }
 
-GLuint i915_emit_const2f( struct i915_fragment_program *p, 
-                        GLfloat c0, GLfloat c1 )
+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 (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);
+   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;
+          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);
-        }
+         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);
+         }
       }
    }
 
@@ -298,27 +324,28 @@ GLuint i915_emit_const2f( struct i915_fragment_program *p,
 
 
 
-GLuint i915_emit_const4f( struct i915_fragment_program *p, 
-                        GLfloat c0, GLfloat c1, GLfloat c2, GLfloat c3 )
+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);
+          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);
+         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);
       }
    }
 
@@ -328,34 +355,36 @@ GLuint i915_emit_const4f( struct i915_fragment_program *p,
 }
 
 
-GLuint i915_emit_const4fv( struct i915_fragment_program *p, const GLfloat *c )
+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] );
+   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 )
+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);
+         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->constant_flags[reg] = I915_CONSTFLAG_PARAM;
+         i = p->nr_params++;
 
-        p->param[i].values = values;
-        p->param[i].reg = reg;
-        p->params_uptodate = 0;
+         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);
+         if (reg + 1 > p->nr_constants)
+            p->nr_constants = reg + 1;
+         return UREG(REG_TYPE_CONST, reg);
       }
    }
 
@@ -366,30 +395,31 @@ GLuint i915_emit_param4fv( struct i915_fragment_program *p,
 
 
 
-
-void i915_program_error( struct i915_fragment_program *p, const char *msg )
+void
+i915_program_error(struct i915_fragment_program *p, const char *msg)
 {
    _mesa_problem(NULL, "i915_program_error: %s", msg);
    p->error = 1;
 }
 
-void i915_init_program( i915ContextPtr i915, struct i915_fragment_program *p )
+
+void
+i915_init_program(struct i915_context *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_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->ctx = ctx;
+   memset(p->constant_flags, 0, sizeof(p->constant_flags));
 
    p->nr_constants = 0;
    p->csr = p->program;
@@ -402,21 +432,17 @@ void i915_init_program( i915ContextPtr i915, struct i915_fragment_program *p )
    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 )
+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) 
+
+   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)
@@ -446,22 +472,24 @@ void i915_fini_program( struct i915_fragment_program *p )
    p->declarations[0] |= program_size + decl_size - 2;
 }
 
-void i915_upload_program( i915ContextPtr i915, struct i915_fragment_program *p )
+void
+i915_upload_program(struct i915_context *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 );
+   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));
+       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));
+             program_size * sizeof(int));
       i915->state.ProgramSize = decl_size + program_size;
    }
 
@@ -470,30 +498,28 @@ void i915_upload_program( i915ContextPtr i915, struct i915_fragment_program *p )
     */
    if (p->nr_constants) {
       GLuint nr = p->nr_constants;
-      
-      I915_ACTIVESTATE( i915, I915_UPLOAD_CONSTANTS, 1 );
-      I915_STATECHANGE( i915, I915_UPLOAD_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.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]);
-        }
+         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 );
-   }  
+      I915_ACTIVESTATE(i915, I915_UPLOAD_CONSTANTS, 0);
+   }
 
    p->on_hardware = 1;
 }
index 8891a177855a56052dd144b6483ccbfa08dd4dd5..14a3f08801fffcbb063772b2b6d1773d838fca5f 100644 (file)
 #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_ZERO_SHIFT       4
 #define UREG_CHANNEL_ONE_NEGATE_MBZ   1
-#define UREG_CHANNEL_ONE_SHIFT        0      
+#define UREG_CHANNEL_ONE_SHIFT        0
 
-#define UREG_BAD          0xffffffff /* not a valid ureg */
+#define UREG_BAD          0xffffffff    /* not a valid ureg */
 
 #define X    SRC_X
 #define Y    SRC_Y
 
 /* One neat thing about the UREG representation:  
  */
-static __inline int swizzle( int reg, int x, int y, int z, int w )
+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 ));
+           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 )
+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));
+   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_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_texld(struct i915_fragment_program *p,
+                              GLuint live_regs,
+                              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_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_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_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_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_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_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 GLuint i915_emit_param4fv(struct i915_fragment_program *p,
+                                 const GLfloat * values);
 
-extern void i915_program_error( struct i915_fragment_program *p,
-                                const char *msg );
+extern void i915_program_error(struct i915_fragment_program *p,
+                               const char *msg);
 
-extern void i915_init_program( i915ContextPtr i915,
-                             struct i915_fragment_program *p );
+extern void i915_init_program(struct i915_context *i915,
+                              struct i915_fragment_program *p);
 
-extern void i915_upload_program( i915ContextPtr i915, 
-                               struct i915_fragment_program *p );
+extern void i915_upload_program(struct i915_context *i915,
+                                struct i915_fragment_program *p);
 
-extern void i915_fini_program( struct i915_fragment_program *p );
+extern void i915_fini_program(struct i915_fragment_program *p);
 
 
 
index 694cd4c8c3c1f239628315f0738fc182b49823b2..8891e11c6fd22ee0101712eef7d082443f78ccbc 100644 (file)
@@ -34,8 +34,6 @@
 
 #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)
 /* 3DSTATE_CHROMA_KEY */
 
 /* 3DSTATE_CLEAR_PARAMETERS, p150 */
+/* 
+ * Sets the color, depth and stencil clear values used by the
+ * CLEAR_RECT and ZONE_INIT primitive types, respectively.  These
+ * primitives set override most 3d state and only take a minimal x/y
+ * vertex.  The color/z/stencil information is supplied here and
+ * therefore cannot vary per vertex.
+ */
+#define _3DSTATE_CLEAR_PARAMETERS      (CMD_3D | (0x1d<<24) | (0x9c<<16) | 5)
+/* Dword 1 */
+#define CLEARPARAM_CLEAR_RECT          (1 << 16)
+#define CLEARPARAM_ZONE_INIT           (0 << 16)
+#define CLEARPARAM_WRITE_COLOR         (1 << 2)
+#define CLEARPARAM_WRITE_DEPTH         (1 << 1)
+#define CLEARPARAM_WRITE_STENCIL       (1 << 0)
 
 /* 3DSTATE_CONSTANT_BLEND_COLOR, p153 */
 #define _3DSTATE_CONST_BLEND_COLOR_CMD (CMD_3D | (0x1d<<24) | (0x88<<16))
 #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
+/* Helper macros for blend factors
+ */
+#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)
+
+
+
 
 /* 3DSTATE_MAP_DEINTERLACER_PARAMETERS */
-/* 3DSTATE_MAP_PALETTE_LOAD_32, p206 */
 
+/* 3DSTATE_MAP_PALETTE_LOAD_32, p206 */
+#define _3DSTATE_MAP_PALETTE_LOAD_32    (CMD_3D|(0x1d<<24)|(0x8f<<16))
+/* subsequent dwords up to length (max 16) are ARGB8888 color values */
 
 /* _3DSTATE_MODES_4, p218 */
 #define _3DSTATE_MODES_4_CMD           (CMD_3D|(0x0d<<24))
 #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 STENCIL_TEST_MASK(x)           (((x)&0xff)<<8)
 #define MODE4_ENABLE_STENCIL_WRITE_MASK        ((1<<16)|(0x00ff))
 #define ENABLE_STENCIL_WRITE_MASK      (1<<16)
 #define STENCIL_WRITE_MASK(x)          ((x)&0xff)
 
 
 #define I915_MAX_TEX_INDIRECT 4
-#define I915_MAX_TEX_INSN     32     
+#define I915_MAX_TEX_INSN     32
 #define I915_MAX_ALU_INSN     64
 #define I915_MAX_DECL_INSN    27
 #define I915_MAX_TEMPORARY    16
  */
 #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_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
 
 #define T_TEX7     7
 #define T_DIFFUSE  8
 #define T_SPECULAR 9
-#define T_FOG_W    10          /* interpolated fog is in W coord */
+#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_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 */
 
 
 /* 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_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
  */
 #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_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 */
+#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_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    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_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_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_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_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_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_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_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 MS4_MIP_LAYOUT_LEGACY           (0<<8)
 #define MS4_MIP_LAYOUT_BELOW_LPT        (0<<8)
 #define MS4_MIP_LAYOUT_RIGHT_LPT        (1<<8)
-#define MS4_VOLUME_DEPTH_SHIFT          0    
+#define MS4_VOLUME_DEPTH_SHIFT          0
 #define MS4_VOLUME_DEPTH_MASK           (0xff<<0)
 
 /* p244 */
 #define   FILTER_4X4_1         3
 #define   FILTER_4X4_2         4
 #define   FILTER_4X4_FLAT      5
-#define   FILTER_6X5_MONO      6 /* XXX - check */
+#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 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)
-
+#define _3DSTATE_DEFAULT_Z          ((0x3<<29)|(0x1d<<24)|(0x98<<16))
+#define _3DSTATE_DEFAULT_DIFFUSE    ((0x3<<29)|(0x1d<<24)|(0x99<<16))
+#define _3DSTATE_DEFAULT_SPECULAR   ((0x3<<29)|(0x1d<<24)|(0x9a<<16))
 
 #endif
index 1c4ec74755843dd96786fdfd082c14357d5d6223..c814f8d532e7a47f44cdda83f1cd798ac48e5673 100644 (file)
 
 #include "drivers/common/driverfuncs.h"
 
+#include "intel_fbo.h"
 #include "intel_screen.h"
 #include "intel_batchbuffer.h"
 
 #include "i915_context.h"
 #include "i915_reg.h"
 
-
+#define FILE_DEBUG_FLAG DEBUG_STATE
 
 static void
-i915StencilFuncSeparate(GLcontext *ctx, GLenum face, GLenum func, GLint ref,
+i915StencilFuncSeparate(GLcontext * ctx, GLenum face, GLenum func, GLint ref,
                         GLuint mask)
 {
-   i915ContextPtr i915 = I915_CONTEXT(ctx);
-   int test = intel_translate_compare_func( func );
+   struct i915_context *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);
+   DBG("%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));
+                                           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)); 
+                                          S5_STENCIL_TEST_FUNC_MASK);
+
+   i915->state.Ctx[I915_CTXREG_LIS5] |= ((ref << S5_STENCIL_REF_SHIFT) |
+                                         (test <<
+                                          S5_STENCIL_TEST_FUNC_SHIFT));
 }
 
 static void
-i915StencilMaskSeparate(GLcontext *ctx, GLenum face, GLuint mask)
+i915StencilMaskSeparate(GLcontext * ctx, GLenum face, GLuint mask)
 {
-   i915ContextPtr i915 = I915_CONTEXT(ctx);
-
-   if (INTEL_DEBUG&DEBUG_DRI)
-      fprintf(stderr, "%s : mask 0x%x\n", __FUNCTION__, mask);
+   struct i915_context *i915 = I915_CONTEXT(ctx);
 
+   DBG("%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));
+                                           STENCIL_WRITE_MASK(mask));
 }
 
 
 static void
-i915StencilOpSeparate(GLcontext *ctx, GLenum face, GLenum fail, GLenum zfail,
+i915StencilOpSeparate(GLcontext * ctx, GLenum face, 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); 
+   struct i915_context *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));
+   DBG("%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);
+                                          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));
+                                         (dfop <<
+                                          S5_STENCIL_PASS_Z_FAIL_SHIFT) |
+                                         (dpop <<
+                                          S5_STENCIL_PASS_Z_PASS_SHIFT));
 }
 
-static void i915AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref)
+static void
+i915AlphaFunc(GLcontext * ctx, GLenum func, GLfloat ref)
 {
-   i915ContextPtr i915 = I915_CONTEXT(ctx);
-   int test = intel_translate_compare_func( func );
+   struct i915_context *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);
+                                          S6_ALPHA_REF_MASK);
    i915->state.Ctx[I915_CTXREG_LIS6] |= ((test << S6_ALPHA_TEST_FUNC_SHIFT) |
-                                      (((GLuint)refByte) << S6_ALPHA_REF_SHIFT));
+                                         (((GLuint) refByte) <<
+                                          S6_ALPHA_REF_SHIFT));
 }
 
 /* This function makes sure that the proper enables are
@@ -137,41 +139,45 @@ static void i915AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref)
  * could change the LogicOp or Independant Alpha Blend without subsequent
  * calls to glEnable.
  */
-static void i915EvalLogicOpBlendState(GLcontext *ctx)
+static void
+i915EvalLogicOpBlendState(GLcontext * ctx)
 {
-   i915ContextPtr i915 = I915_CONTEXT(ctx);
+   struct i915_context *i915 = I915_CONTEXT(ctx);
 
    I915_STATECHANGE(i915, I915_UPLOAD_CTX);
 
    if (RGBA_LOGICOP_ENABLED(ctx)) {
       i915->state.Ctx[I915_CTXREG_LIS5] |= S5_LOGICOP_ENABLE;
       i915->state.Ctx[I915_CTXREG_LIS6] &= ~S6_CBUF_BLEND_ENABLE;
-   } else {
+   }
+   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;
+         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])
+static void
+i915BlendColor(GLcontext * ctx, const GLfloat color[4])
 {
-   i915ContextPtr i915 = I915_CONTEXT(ctx);
+   struct i915_context *i915 = I915_CONTEXT(ctx);
    GLubyte r, g, b, a;
 
-   if (INTEL_DEBUG&DEBUG_DRI)
-      fprintf(stderr, "%s\n", __FUNCTION__);
-
+   DBG("%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;
+   i915->state.Ctx[I915_CTXREG_BLENDCOLOR1] =
+      (a << 24) | (r << 16) | (g << 8) | b;
 }
 
 
@@ -182,31 +188,37 @@ static void i915BlendColor(GLcontext *ctx, const GLfloat color[4])
 
 
 
-static GLuint translate_blend_equation( GLenum mode )
+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;
+   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 )
+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));
+   struct i915_context *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;
@@ -223,15 +235,15 @@ static void i915UpdateBlendState( GLcontext *ctx )
       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;
+   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;
+   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) 
+   if (srcA != srcRGB || dstA != dstRGB || eqA != eqRGB)
       iab |= IAB_ENABLE;
 
    if (iab != i915->state.Ctx[I915_CTXREG_IAB] ||
@@ -246,41 +258,41 @@ static void i915UpdateBlendState( GLcontext *ctx )
 }
 
 
-static void i915BlendFuncSeparate(GLcontext *ctx, GLenum srcRGB, 
-                                GLenum dstRGB, GLenum srcA,
-                                GLenum dstA )
-{  
-   i915UpdateBlendState( 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) 
+static void
+i915BlendEquationSeparate(GLcontext * ctx, GLenum eqRGB, GLenum eqA)
 {
-   i915UpdateBlendState( ctx );
+   i915UpdateBlendState(ctx);
 }
 
 
-static void i915DepthFunc(GLcontext *ctx, GLenum func)
+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__);
+   struct i915_context *i915 = I915_CONTEXT(ctx);
+   int test = intel_translate_compare_func(func);
 
+   DBG("%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)
+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);
+   struct i915_context *i915 = I915_CONTEXT(ctx);
 
+   DBG("%s flag (%d)\n", __FUNCTION__, flag);
+   
    I915_STATECHANGE(i915, I915_UPLOAD_CTX);
 
    if (flag && ctx->Depth.Test)
@@ -295,14 +307,15 @@ static void i915DepthMask(GLcontext *ctx, GLboolean flag)
  * 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 )
+static void
+i915PolygonStipple(GLcontext * ctx, const GLubyte * mask)
 {
-   i915ContextPtr i915 = I915_CONTEXT(ctx);
-   const GLubyte *m = mask;
+   struct i915_context *i915 = I915_CONTEXT(ctx);
+   const GLubyte *m;
    GLubyte p[4];
-   int i,j,k;
+   int i, j, k;
    int active = (ctx->Polygon.StippleFlag &&
-                i915->intel.reduced_primitive == GL_TRIANGLES);
+                 i915->intel.reduced_primitive == GL_TRIANGLES);
    GLuint newMask;
 
    if (active) {
@@ -310,23 +323,32 @@ static void i915PolygonStipple( GLcontext *ctx, const GLubyte *mask )
       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;
-           }
+   /* Use the already unpacked stipple data from the context rather than the
+    * uninterpreted mask passed in.
+    */
+   mask = (const GLubyte *)ctx->PolygonStipple;
+   m = mask;
+
+   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));
+              ((p[1] & 0xf) << 4) |
+              ((p[2] & 0xf) << 8) | ((p[3] & 0xf) << 12));
 
 
    if (newMask == 0xffff || newMask == 0x0) {
@@ -347,49 +369,54 @@ static void i915PolygonStipple( GLcontext *ctx, const GLubyte *mask )
 /* =============================================================
  * Hardware clipping
  */
-static void i915Scissor(GLcontext *ctx, GLint x, GLint y, 
-                       GLsizei w, GLsizei h)
+static void
+i915Scissor(GLcontext * ctx, GLint x, GLint y, GLsizei w, GLsizei h)
 {
-   i915ContextPtr i915 = I915_CONTEXT(ctx);
-   intelScreenPrivate *screen = i915->intel.intelScreen;
+   struct i915_context *i915 = I915_CONTEXT(ctx);
    int x1, y1, x2, y2;
 
-   if (!i915->intel.driDrawable)
+   if (!ctx->DrawBuffer)
       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;
+   DBG("%s %d,%d %dx%d\n", __FUNCTION__, x, y, w, h);
 
+   if (ctx->DrawBuffer->Name == 0) {
+      x1 = x;
+      y1 = ctx->DrawBuffer->Height - (y + h);
+      x2 = x + w - 1;
+      y2 = y1 + h - 1;
+      DBG("%s %d..%d,%d..%d (inverted)\n", __FUNCTION__, x1, x2, y1, y2);
+   }
+   else {
+      /* FBO - not inverted
+       */
+      x1 = x;
+      y1 = y;
+      x2 = x + w - 1;
+      y2 = y + h - 1;
+      DBG("%s %d..%d,%d..%d (not inverted)\n", __FUNCTION__, x1, x2, y1, y2);
+   }
+   
+   x1 = CLAMP(x1, 0, ctx->DrawBuffer->Width - 1);
+   y1 = CLAMP(y1, 0, ctx->DrawBuffer->Height - 1);
+   x2 = CLAMP(x2, 0, ctx->DrawBuffer->Width - 1);
+   y2 = CLAMP(y2, 0, ctx->DrawBuffer->Height - 1);
+   
+   DBG("%s %d..%d,%d..%d (clamped)\n", __FUNCTION__, x1, x2, y1, y2);
 
    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)
+static void
+i915LogicOp(GLcontext * ctx, GLenum opcode)
 {
-   i915ContextPtr i915 = I915_CONTEXT(ctx);
+   struct i915_context *i915 = I915_CONTEXT(ctx);
    int tmp = intel_translate_logic_op(opcode);
 
-   if (INTEL_DEBUG&DEBUG_DRI)
-      fprintf(stderr, "%s\n", __FUNCTION__);
-
+   DBG("%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);
@@ -397,13 +424,14 @@ static void i915LogicOp(GLcontext *ctx, GLenum opcode)
 
 
 
-static void i915CullFaceFrontFace(GLcontext *ctx, GLenum unused)
+static void
+i915CullFaceFrontFace(GLcontext * ctx, GLenum unused)
 {
-   i915ContextPtr i915 = I915_CONTEXT(ctx);
+   struct i915_context *i915 = I915_CONTEXT(ctx);
    GLuint mode;
 
-   if (INTEL_DEBUG&DEBUG_DRI)
-      fprintf(stderr, "%s\n", __FUNCTION__);
+   DBG("%s %d\n", __FUNCTION__,
+       ctx->DrawBuffer ? ctx->DrawBuffer->Name : 0);
 
    if (!ctx->Polygon.CullFlag) {
       mode = S4_CULLMODE_NONE;
@@ -411,10 +439,12 @@ static void i915CullFaceFrontFace(GLcontext *ctx, GLenum unused)
    else if (ctx->Polygon.CullFaceMode != GL_FRONT_AND_BACK) {
       mode = S4_CULLMODE_CW;
 
+      if (ctx->DrawBuffer && ctx->DrawBuffer->Name != 0)
+         mode ^= (S4_CULLMODE_CW ^ S4_CULLMODE_CCW);
       if (ctx->Polygon.CullFaceMode == GL_FRONT)
-        mode ^= (S4_CULLMODE_CW ^ S4_CULLMODE_CCW);
+         mode ^= (S4_CULLMODE_CW ^ S4_CULLMODE_CCW);
       if (ctx->Polygon.FrontFace != GL_CCW)
-        mode ^= (S4_CULLMODE_CW ^ S4_CULLMODE_CCW);
+         mode ^= (S4_CULLMODE_CW ^ S4_CULLMODE_CCW);
    }
    else {
       mode = S4_CULLMODE_BOTH;
@@ -425,16 +455,16 @@ static void i915CullFaceFrontFace(GLcontext *ctx, GLenum unused)
    i915->state.Ctx[I915_CTXREG_LIS4] |= mode;
 }
 
-static void i915LineWidth( GLcontext *ctx, GLfloat widthf )
+static void
+i915LineWidth(GLcontext * ctx, GLfloat widthf)
 {
-   i915ContextPtr i915 = I915_CONTEXT( ctx );
+   struct i915_context *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);
+   DBG("%s\n", __FUNCTION__);
+   
+   width = (int) (widthf * 2);
    CLAMP_SELF(width, 1, 0xf);
    lis4 |= width << S4_LINE_WIDTH_SHIFT;
 
@@ -444,15 +474,15 @@ static void i915LineWidth( GLcontext *ctx, GLfloat widthf )
    }
 }
 
-static void i915PointSize(GLcontext *ctx, GLfloat size)
+static void
+i915PointSize(GLcontext * ctx, GLfloat size)
 {
-   i915ContextPtr i915 = I915_CONTEXT(ctx);
+   struct i915_context *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__);
+   GLint point_size = (int) size;
 
+   DBG("%s\n", __FUNCTION__);
+   
    CLAMP_SELF(point_size, 1, 255);
    lis4 |= point_size << S4_POINT_WIDTH_SHIFT;
 
@@ -467,20 +497,24 @@ static void i915PointSize(GLcontext *ctx, GLfloat size)
  * Color masks
  */
 
-static void i915ColorMask(GLcontext *ctx,
-                        GLboolean r, GLboolean g,
-                        GLboolean b, GLboolean a)
+static void
+i915ColorMask(GLcontext * ctx,
+              GLboolean r, GLboolean g, GLboolean b, GLboolean a)
 {
-   i915ContextPtr i915 = I915_CONTEXT( ctx );
+   struct i915_context *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);
+   DBG("%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 (!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);
@@ -488,54 +522,55 @@ static void i915ColorMask(GLcontext *ctx,
    }
 }
 
-static void update_specular( GLcontext *ctx )
+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; 
+   intel_context(ctx)->NewGLState |= _NEW_TEXTURE;
 }
 
-static void i915LightModelfv(GLcontext *ctx, GLenum pname, 
-                            const GLfloat *param)
+static void
+i915LightModelfv(GLcontext * ctx, GLenum pname, const GLfloat * param)
 {
-   if (INTEL_DEBUG&DEBUG_DRI)
-      fprintf(stderr, "%s\n", __FUNCTION__);
-
+   DBG("%s\n", __FUNCTION__);
+   
    if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) {
-      update_specular( ctx );
+      update_specular(ctx);
    }
 }
 
-static void i915ShadeModel(GLcontext *ctx, GLenum mode)
+static void
+i915ShadeModel(GLcontext * ctx, GLenum mode)
 {
-   i915ContextPtr i915 = I915_CONTEXT(ctx);
+   struct i915_context *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);
+      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 )
+void
+i915_update_fog(GLcontext * ctx)
 {
-   i915ContextPtr i915 = I915_CONTEXT(ctx);
+   struct i915_context *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;
@@ -546,7 +581,7 @@ void i915_update_fog( GLcontext *ctx )
 #if 0
       /* XXX - DISABLED -- Need ortho fallback */
       try_pixel_fog = (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT
-                       &&ctx->Hint.Fog == GL_NICEST);
+                       && ctx->Hint.Fog == GL_NICEST);
 #else
       try_pixel_fog = 0;
 #endif
@@ -559,48 +594,49 @@ void i915_update_fog( GLcontext *ctx )
       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 {
+         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.
+             */
+            printf("vertex fog!\n");
+            i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_VERTEX;
+            i915->vertex_fog = I915_FOG_VERTEX;
+         }
+         else {
             GLfloat c2 = 1.0 / (ctx->Fog.End - ctx->Fog.Start);
             GLfloat c1 = ctx->Fog.End * c2;
 
-           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 {
-              fi_type fi;
-              fi.f = c2; 
-              i915->state.Fog[I915_FOGREG_MODE2] = fi.i; 
-           }
-        }
-        break;
+            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 {
+               fi_type 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;
+         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;
+         i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_PIXEL_EXP2;
+         break;
       default:
-        break;
+         break;
       }
    }
-   else /* if (i915->vertex_fog != I915_FOG_VERTEX) */ {      
+   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;
@@ -622,38 +658,38 @@ void i915_update_fog( GLcontext *ctx )
 }
 
 static void
-i915Fogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
+i915Fogfv(GLcontext * ctx, GLenum pname, const GLfloat * param)
 {
-   i915ContextPtr i915 = I915_CONTEXT(ctx);
+   struct i915_context *i915 = I915_CONTEXT(ctx);
 
    switch (pname) {
-   case GL_FOG_COORDINATE_SOURCE_EXT: 
+   case GL_FOG_COORDINATE_SOURCE_EXT:
    case GL_FOG_MODE:
    case GL_FOG_START:
-   case GL_FOG_END: 
+   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);
+         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; 
+         fi_type fi;
+         fi.f = ctx->Fog.Density;
+         i915->state.Fog[I915_FOGREG_MODE3] = fi.i;
       }
       break;
 
-   case GL_FOG_COLOR: 
+   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));
+      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:
@@ -661,7 +697,8 @@ i915Fogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
    }
 }
 
-static void i915Hint(GLcontext *ctx, GLenum target, GLenum state)
+static void
+i915Hint(GLcontext * ctx, GLenum target, GLenum state)
 {
    switch (target) {
    case GL_FOG_HINT:
@@ -674,25 +711,26 @@ static void i915Hint(GLcontext *ctx, GLenum target, GLenum state)
 /* =============================================================
  */
 
-static void i915Enable(GLcontext *ctx, GLenum cap, GLboolean state)
+static void
+i915Enable(GLcontext * ctx, GLenum cap, GLboolean state)
 {
-   i915ContextPtr i915 = I915_CONTEXT(ctx);
+   struct i915_context *i915 = I915_CONTEXT(ctx);
 
-   switch(cap) {
+   switch (cap) {
    case GL_TEXTURE_2D:
       break;
 
    case GL_LIGHTING:
    case GL_COLOR_SUM:
-      update_specular( ctx );
+      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;
+         i915->state.Ctx[I915_CTXREG_LIS6] |= S6_ALPHA_TEST_ENABLE;
       else
-        i915->state.Ctx[I915_CTXREG_LIS6] &= ~S6_ALPHA_TEST_ENABLE;
+         i915->state.Ctx[I915_CTXREG_LIS6] &= ~S6_ALPHA_TEST_ENABLE;
       break;
 
    case GL_BLEND:
@@ -704,8 +742,8 @@ static void i915Enable(GLcontext *ctx, GLenum cap, GLboolean state)
 
       /* Logicop doesn't seem to work at 16bpp:
        */
-      if (i915->intel.intelScreen->cpp == 2)
-        FALLBACK( &i915->intel, I915_FALLBACK_LOGICOP, state );
+      if (ctx->Visual.rgbBits == 16)
+         FALLBACK(&i915->intel, I915_FALLBACK_LOGICOP, state);
       break;
 
    case GL_FRAGMENT_PROGRAM_ARB:
@@ -714,37 +752,37 @@ static void i915Enable(GLcontext *ctx, GLenum cap, GLboolean state)
    case GL_DITHER:
       I915_STATECHANGE(i915, I915_UPLOAD_CTX);
       if (state)
-        i915->state.Ctx[I915_CTXREG_LIS5] |= S5_COLOR_DITHER_ENABLE;
+         i915->state.Ctx[I915_CTXREG_LIS5] |= S5_COLOR_DITHER_ENABLE;
       else
-        i915->state.Ctx[I915_CTXREG_LIS5] &= ~S5_COLOR_DITHER_ENABLE;
+         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;
+         i915->state.Ctx[I915_CTXREG_LIS6] |= S6_DEPTH_TEST_ENABLE;
       else
-        i915->state.Ctx[I915_CTXREG_LIS6] &= ~S6_DEPTH_TEST_ENABLE;
+         i915->state.Ctx[I915_CTXREG_LIS6] &= ~S6_DEPTH_TEST_ENABLE;
 
-      i915DepthMask( ctx, ctx->Depth.Mask );
+      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);
+         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);
+         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;
+         i915->state.Ctx[I915_CTXREG_LIS4] |= S4_LINE_ANTIALIAS_ENABLE;
       else
-        i915->state.Ctx[I915_CTXREG_LIS4] &= ~S4_LINE_ANTIALIAS_ENABLE;
+         i915->state.Ctx[I915_CTXREG_LIS4] &= ~S4_LINE_ANTIALIAS_ENABLE;
       break;
 
    case GL_FOG:
@@ -755,16 +793,25 @@ static void i915Enable(GLcontext *ctx, GLenum cap, GLboolean state)
       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 );
+      {
+         GLboolean hw_stencil = GL_FALSE;
+         if (ctx->DrawBuffer) {
+            struct intel_renderbuffer *irbStencil
+               = intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_STENCIL);
+            hw_stencil = (irbStencil && irbStencil->region);
+         }
+         if (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;
 
@@ -773,23 +820,20 @@ static void i915Enable(GLcontext *ctx, GLenum cap, GLboolean state)
        * 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;
+      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;
 
    case GL_POLYGON_SMOOTH:
-      FALLBACK( &i915->intel, I915_FALLBACK_POLYGON_SMOOTH, state );
       break;
 
    case GL_POINT_SMOOTH:
-      FALLBACK( &i915->intel, I915_FALLBACK_POINT_SMOOTH, state );
       break;
 
    default:
@@ -798,10 +842,9 @@ static void i915Enable(GLcontext *ctx, GLenum cap, GLboolean state)
 }
 
 
-static void i915_init_packets( i915ContextPtr i915 )
+static void
+i915_init_packets(struct i915_context *i915)
 {
-   intelScreenPrivate *screen = i915->intel.intelScreen;
-
    /* Zero all state */
    memset(&i915->state, 0, sizeof(i915->state));
 
@@ -811,39 +854,35 @@ static void i915_init_packets( i915ContextPtr i915 )
       /* 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) | 
-                                      (3));
+      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) | (3));
       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;
+      if (i915->intel.ctx.Visual.rgbBits == 16)
+         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));
+                                           (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;
+                                             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;
 
    }
@@ -858,79 +897,50 @@ static void i915_init_packets( i915ContextPtr i915 )
       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);
+                                            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);
-      /* color buffer offset/stride */
-      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->front.pitch) |  /* pitch in bytes */
-         BUF_3D_USE_FENCE);
-      /*i915->state.Buffer[I915_DESTREG_CBUFADDR2] is the offset */
-
-
-      /* depth/Z buffer offset/stride */
-      i915->state.Buffer[I915_DESTREG_DBUFADDR0] = _3DSTATE_BUF_INFO_CMD;
-      i915->state.Buffer[I915_DESTREG_DBUFADDR1] = 
-        (BUF_3D_ID_DEPTH |
-         BUF_3D_PITCH(screen->depth.pitch) |  /* pitch in bytes */
-         BUF_3D_USE_FENCE);
-      i915->state.Buffer[I915_DESTREG_DBUFADDR2] = screen->depth.offset;
-
-
       i915->state.Buffer[I915_DESTREG_DV0] = _3DSTATE_DST_BUF_VARS_CMD;
 
-      /* color/depth pixel format */
-      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;
-      }
-
       /* scissor */
-      i915->state.Buffer[I915_DESTREG_SENABLE] = (_3DSTATE_SCISSOR_ENABLE_CMD |
-                                               DISABLE_SCISSOR_RECT);
+      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;
    }
 
 
+#if 0
+   {
+      I915_STATECHANGE(i915, I915_UPLOAD_DEFAULTS);
+      i915->state.Default[I915_DEFREG_C0] = _3DSTATE_DEFAULT_DIFFUSE;
+      i915->state.Default[I915_DEFREG_C1] = 0;
+      i915->state.Default[I915_DEFREG_S0] = _3DSTATE_DEFAULT_SPECULAR;
+      i915->state.Default[I915_DEFREG_S1] = 0;
+      i915->state.Default[I915_DEFREG_Z0] = _3DSTATE_DEFAULT_Z;
+      i915->state.Default[I915_DEFREG_Z1] = 0;
+   }
+#endif
+
+
    /* 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 | 
-                        I915_UPLOAD_INVARIENT);
+   i915->state.active = (I915_UPLOAD_PROGRAM |
+                         I915_UPLOAD_STIPPLE |
+                         I915_UPLOAD_CTX |
+                         I915_UPLOAD_BUFFERS | I915_UPLOAD_INVARIENT);
 }
 
-void i915InitStateFunctions( struct dd_function_table *functions )
+void
+i915InitStateFunctions(struct dd_function_table *functions)
 {
    functions->AlphaFunc = i915AlphaFunc;
    functions->BlendColor = i915BlendColor;
@@ -957,14 +967,15 @@ void i915InitStateFunctions( struct dd_function_table *functions )
 }
 
 
-void i915InitState( i915ContextPtr i915 )
+void
+i915InitState(struct i915_context *i915)
 {
    GLcontext *ctx = &i915->intel.ctx;
 
-   i915_init_packets( i915 );
+   i915_init_packets(i915);
 
    _mesa_init_driver_state(ctx);
 
-   memcpy( &i915->initial, &i915->state, sizeof(i915->state) );
+   memcpy(&i915->initial, &i915->state, sizeof(i915->state));
    i915->current = &i915->state;
 }
index d9609d31933fbcdeb4b3024a8a2e6d24dc98cff1..cb55bf6125330b1a731410a26ccfdf5ae600f8f7 100644 (file)
 
 #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 )
+static void
+i915TexEnv(GLcontext * ctx, GLenum target,
+           GLenum pname, const GLfloat * param)
 {
-   i915ContextPtr i915 = I915_CONTEXT( ctx );
-   GLuint unit = ctx->Texture.CurrentUnit;
+   struct i915_context *i915 = I915_CONTEXT(ctx);
 
    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;
-   }
+   case GL_TEXTURE_LOD_BIAS:{
+         GLuint unit = ctx->Texture.CurrentUnit;
+         GLint b = (int) ((*param) * 16.0);
+         if (b > 255)
+            b = 255;
+         if (b < -256)
+            b = -256;
+         I915_STATECHANGE(i915, I915_UPLOAD_TEX(unit));
+         i915->lodbias_ss2[unit] =
+            ((b << SS2_LOD_BIAS_SHIFT) & SS2_LOD_BIAS_MASK);
+         break;
+      }
 
    default:
       break;
@@ -155,33 +69,10 @@ static void i915TexEnv( GLcontext *ctx, GLenum target,
 }
 
 
-static void i915BindTexture( GLcontext *ctx, GLenum target,
-                           struct gl_texture_object *texObj )
-{
-   i915TextureObjectPtr tex;
-   
-   if (!texObj->DriverData)
-      i915AllocTexObj( texObj );
-   
-   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 )
+void
+i915InitTextureFuncs(struct dd_function_table *functions)
 {
-   functions->BindTexture = i915BindTexture;
+/*
    functions->TexEnv = i915TexEnv;
-   functions->TexParameter = i915TexParameter;
+*/
 }
diff --git a/src/mesa/drivers/dri/i915/i915_tex_layout.c b/src/mesa/drivers/dri/i915/i915_tex_layout.c
new file mode 100644 (file)
index 0000000..b5085f4
--- /dev/null
@@ -0,0 +1,477 @@
+/**************************************************************************
+ * 
+ * Copyright 2006 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.
+ * 
+ **************************************************************************/
+
+/** @file i915_tex_layout.c
+ * Code to layout images in a mipmap tree for i830M-GM915 and G945 and beyond.
+ */
+
+#include "intel_mipmap_tree.h"
+#include "intel_tex_layout.h"
+#include "macros.h"
+#include "intel_context.h"
+
+#define FILE_DEBUG_FLAG DEBUG_TEXTURE
+
+static GLint initial_offsets[6][2] = {
+   [FACE_POS_X] = {0, 0},
+   [FACE_POS_Y] = {1, 0},
+   [FACE_POS_Z] = {1, 1},
+   [FACE_NEG_X] = {0, 2},
+   [FACE_NEG_Y] = {1, 2},
+   [FACE_NEG_Z] = {1, 3},
+};
+
+
+static GLint step_offsets[6][2] = {
+   [FACE_POS_X] = {0, 2},
+   [FACE_POS_Y] = {-1, 2},
+   [FACE_POS_Z] = {-1, 1},
+   [FACE_NEG_X] = {0, 2},
+   [FACE_NEG_Y] = {-1, 2},
+   [FACE_NEG_Z] = {-1, 1},
+};
+
+/**
+ * Cube texture map layout for i830M-GM915.
+ *
+ * Hardware layout looks like:
+ *
+ * +-------+-------+
+ * |       |       |
+ * |       |       |
+ * |       |       |
+ * |  +x   |  +y   |
+ * |       |       |
+ * |       |       |
+ * |       |       |
+ * |       |       |
+ * +---+---+-------+
+ * |   |   |       |
+ * | +x| +y|       |
+ * |   |   |       |
+ * |   |   |       |
+ * +-+-+---+  +z   |
+ * | | |   |       |
+ * +-+-+ +z|       |
+ *   | |   |       |
+ * +-+-+---+-------+
+ * |       |       |
+ * |       |       |
+ * |       |       |
+ * |  -x   |  -y   |
+ * |       |       |
+ * |       |       |
+ * |       |       |
+ * |       |       |
+ * +---+---+-------+
+ * |   |   |       |
+ * | -x| -y|       |
+ * |   |   |       |
+ * |   |   |       |
+ * +-+-+---+  -z   |
+ * | | |   |       |
+ * +-+-+ -z|       |
+ *   | |   |       |
+ *   +-+---+-------+
+ *
+ */
+static void
+i915_miptree_layout_cube(struct intel_context *intel,
+                        struct intel_mipmap_tree * mt)
+{
+   const GLuint dim = mt->width0;
+   GLuint face;
+   GLuint lvlWidth = mt->width0, lvlHeight = mt->height0;
+   GLint level;
+
+   assert(lvlWidth == lvlHeight); /* cubemap images are square */
+
+   /* double pitch for cube layouts */
+   mt->pitch = intel_miptree_pitch_align (intel, mt, dim * 2);
+   mt->total_height = dim * 4;
+
+   for (level = mt->first_level; level <= mt->last_level; level++) {
+      intel_miptree_set_level_info(mt, level, 6,
+                                  0, 0,
+                                  /*OLD: mt->pitch, mt->total_height,*/
+                                  lvlWidth, lvlHeight,
+                                  1);
+      lvlWidth /= 2;
+      lvlHeight /= 2;
+   }
+
+   for (face = 0; face < 6; face++) {
+      GLuint x = initial_offsets[face][0] * dim;
+      GLuint y = initial_offsets[face][1] * dim;
+      GLuint d = dim;
+
+      for (level = mt->first_level; level <= mt->last_level; level++) {
+        intel_miptree_set_image_offset(mt, level, face, x, y);
+
+        if (d == 0)
+           _mesa_printf("cube mipmap %d/%d (%d..%d) is 0x0\n",
+                        face, level, mt->first_level, mt->last_level);
+
+        d >>= 1;
+        x += step_offsets[face][0] * d;
+        y += step_offsets[face][1] * d;
+      }
+   }
+}
+
+static void
+i915_miptree_layout_3d(struct intel_context *intel,
+                      struct intel_mipmap_tree * mt)
+{
+   GLuint width = mt->width0;
+   GLuint height = mt->height0;
+   GLuint depth = mt->depth0;
+   GLuint stack_height = 0;
+   GLint level;
+
+   /* Calculate the size of a single slice. */
+   mt->pitch = intel_miptree_pitch_align (intel, mt, mt->width0);
+
+   /* XXX: hardware expects/requires 9 levels at minimum. */
+   for (level = mt->first_level; level <= MAX2(8, mt->last_level); level++) {
+      intel_miptree_set_level_info(mt, level, depth, 0, mt->total_height,
+                                  width, height, depth);
+
+      stack_height += MAX2(2, height);
+
+      width = minify(width);
+      height = minify(height);
+      depth = minify(depth);
+   }
+
+   /* Fixup depth image_offsets: */
+   depth = mt->depth0;
+   for (level = mt->first_level; level <= mt->last_level; level++) {
+      GLuint i;
+      for (i = 0; i < depth; i++) {
+        intel_miptree_set_image_offset(mt, level, i,
+                                       0, i * stack_height);
+      }
+
+      depth = minify(depth);
+   }
+
+   /* Multiply slice size by texture depth for total size.  It's
+    * remarkable how wasteful of memory the i915 texture layouts
+    * are.  They are largely fixed in the i945.
+    */
+   mt->total_height = stack_height * mt->depth0;
+}
+
+static void
+i915_miptree_layout_2d(struct intel_context *intel,
+                      struct intel_mipmap_tree * mt)
+{
+   GLuint width = mt->width0;
+   GLuint height = mt->height0;
+   GLuint img_height;
+   GLint level;
+
+   mt->pitch = intel_miptree_pitch_align (intel, mt, mt->width0);
+   mt->total_height = 0;
+
+   for (level = mt->first_level; level <= mt->last_level; level++) {
+      intel_miptree_set_level_info(mt, level, 1,
+                                  0, mt->total_height,
+                                  width, height, 1);
+
+      if (mt->compressed)
+        img_height = MAX2(1, height / 4);
+      else
+        img_height = (MAX2(2, height) + 1) & ~1;
+
+      mt->total_height += img_height;
+
+      width = minify(width);
+      height = minify(height);
+   }
+}
+
+GLboolean
+i915_miptree_layout(struct intel_context *intel, struct intel_mipmap_tree * mt)
+{
+   switch (mt->target) {
+   case GL_TEXTURE_CUBE_MAP:
+      i915_miptree_layout_cube(intel, mt);
+      break;
+   case GL_TEXTURE_3D:
+      i915_miptree_layout_3d(intel, mt);
+      break;
+   case GL_TEXTURE_1D:
+   case GL_TEXTURE_2D:
+   case GL_TEXTURE_RECTANGLE_ARB:
+      i915_miptree_layout_2d(intel, mt);
+      break;
+   default:
+      _mesa_problem(NULL, "Unexpected tex target in i915_miptree_layout()");
+      break;
+   }
+
+   DBG("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__,
+       mt->pitch,
+       mt->total_height, mt->cpp, mt->pitch * mt->total_height * mt->cpp);
+
+   return GL_TRUE;
+}
+
+
+/**
+ * Cube texture map layout for GM945 and later.
+ *
+ * The hardware layout looks like the 830-915 layout, except for the small
+ * sizes.  A zoomed in view of the layout for 945 is:
+ *
+ * +-------+-------+
+ * |  8x8  |  8x8  |
+ * |       |       |
+ * |       |       |
+ * |  +x   |  +y   |
+ * |       |       |
+ * |       |       |
+ * |       |       |
+ * |       |       |
+ * +---+---+-------+
+ * |4x4|   |  8x8  |
+ * | +x|   |       |
+ * |   |   |       |
+ * |   |   |       |
+ * +---+   |  +z   |
+ * |4x4|   |       |
+ * | +y|   |       |
+ * |   |   |       |
+ * +---+   +-------+
+ *
+ * ...
+ *
+ * +-------+-------+
+ * |  8x8  |  8x8  |
+ * |       |       |
+ * |       |       |
+ * |  -x   |  -y   |
+ * |       |       |
+ * |       |       |
+ * |       |       |
+ * |       |       |
+ * +---+---+-------+
+ * |4x4|   |  8x8  |
+ * | -x|   |       |
+ * |   |   |       |
+ * |   |   |       |
+ * +---+   |  -z   |
+ * |4x4|   |       |
+ * | -y|   |       |
+ * |   |   |       |
+ * +---+   +---+---+---+---+---+---+---+---+---+
+ * |4x4|   |4x4|   |2x2|   |2x2|   |2x2|   |2x2|
+ * | +z|   | -z|   | +x|   | +y|   | +z|   | -x| ...
+ * |   |   |   |   |   |   |   |   |   |   |   |
+ * +---+   +---+   +---+   +---+   +---+   +---+
+ *
+ * The bottom row continues with the remaining 2x2 then the 1x1 mip contents
+ * in order, with each of them aligned to a 4x4 block boundary.  Thus, for
+ * 32x32 cube maps and smaller, the bottom row layout is going to dictate the
+ * pitch of the tree.  For a tree with 4x4 images, the pitch is at least
+ * 14 * 8 = 112 texels, for 2x2 it is at least 12 * 8 texels, and for 1x1
+ * it is 6 * 8 texels.
+ */
+
+static void
+i945_miptree_layout_cube(struct intel_context *intel,
+                        struct intel_mipmap_tree * mt)
+{
+   const GLuint dim = mt->width0;
+   GLuint face;
+   GLuint lvlWidth = mt->width0, lvlHeight = mt->height0;
+   GLint level;
+
+   assert(lvlWidth == lvlHeight); /* cubemap images are square */
+
+   /* 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)
+      mt->pitch = intel_miptree_pitch_align (intel, mt, dim * 2);
+   else
+      mt->pitch = intel_miptree_pitch_align (intel, mt, 14 * 8);
+
+   if (dim >= 4)
+      mt->total_height = dim * 4 + 4;
+   else
+      mt->total_height = 4;
+
+   /* Set all the levels to effectively occupy the whole rectangular region. */
+   for (level = mt->first_level; level <= mt->last_level; level++) {
+      intel_miptree_set_level_info(mt, level, 6,
+                                  0, 0,
+                                  lvlWidth, lvlHeight, 1);
+      lvlWidth /= 2;
+      lvlHeight /= 2;
+   }
+
+   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 = mt->total_height - 4;
+        x = (face - 4) * 8;
+      } else if (dim < 4 && (face > 0 || mt->first_level > 0)) {
+        y = mt->total_height - 4;
+        x = face * 8;
+      }
+
+      for (level = mt->first_level; level <= mt->last_level; level++) {
+        intel_miptree_set_image_offset(mt, level, face, x, y);
+
+        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 = mt->total_height - 4;
+              x = (face - 4) * 8;
+              break;
+           }
+
+        case 2:
+           y = mt->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;
+        }
+      }
+   }
+}
+
+static void
+i945_miptree_layout_3d(struct intel_context *intel,
+                      struct intel_mipmap_tree * mt)
+{
+   GLuint width = mt->width0;
+   GLuint height = mt->height0;
+   GLuint depth = mt->depth0;
+   GLuint pack_x_pitch, pack_x_nr;
+   GLuint pack_y_pitch;
+   GLuint level;
+
+   mt->pitch = intel_miptree_pitch_align (intel, mt, mt->width0);
+   mt->total_height = 0;
+
+   pack_y_pitch = MAX2(mt->height0, 2);
+   pack_x_pitch = mt->pitch;
+   pack_x_nr = 1;
+
+   for (level = mt->first_level; level <= mt->last_level; level++) {
+      GLint x = 0;
+      GLint y = 0;
+      GLint q, j;
+
+      intel_miptree_set_level_info(mt, level, depth,
+                                  0, mt->total_height,
+                                  width, height, depth);
+
+      for (q = 0; q < depth;) {
+        for (j = 0; j < pack_x_nr && q < depth; j++, q++) {
+           intel_miptree_set_image_offset(mt, level, q, x, y);
+           x += pack_x_pitch;
+        }
+
+        x = 0;
+        y += pack_y_pitch;
+      }
+
+      mt->total_height += y;
+
+      if (pack_x_pitch > 4) {
+        pack_x_pitch >>= 1;
+        pack_x_nr <<= 1;
+        assert(pack_x_pitch * pack_x_nr <= mt->pitch);
+      }
+
+      if (pack_y_pitch > 2) {
+        pack_y_pitch >>= 1;
+      }
+
+      width = minify(width);
+      height = minify(height);
+      depth = minify(depth);
+   }
+}
+
+GLboolean
+i945_miptree_layout(struct intel_context *intel, struct intel_mipmap_tree * mt)
+{
+   switch (mt->target) {
+   case GL_TEXTURE_CUBE_MAP:
+      i945_miptree_layout_cube(intel, mt);
+      break;
+   case GL_TEXTURE_3D:
+      i945_miptree_layout_3d(intel, mt);
+      break;
+   case GL_TEXTURE_1D:
+   case GL_TEXTURE_2D:
+   case GL_TEXTURE_RECTANGLE_ARB:
+      i945_miptree_layout_2d(intel, mt);
+      break;
+   default:
+      _mesa_problem(NULL, "Unexpected tex target in i945_miptree_layout()");
+      break;
+   }
+
+   DBG("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__,
+       mt->pitch,
+       mt->total_height, mt->cpp, mt->pitch * mt->total_height * mt->cpp);
+
+   return GL_TRUE;
+}
diff --git a/src/mesa/drivers/dri/i915/i915_texprog.c b/src/mesa/drivers/dri/i915/i915_texprog.c
deleted file mode 100644 (file)
index f6a8b02..0000000
+++ /dev/null
@@ -1,676 +0,0 @@
-/**************************************************************************
- * 
- * 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]->_BaseFormat;
-   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;
-   DECLARE_RENDERINPUTS(index_bitset);
-   int i, offset;
-   GLuint s4 = i915->state.Ctx[I915_CTXREG_LIS4] & ~S4_VFMT_MASK;
-   GLuint s2 = S2_TEXCOORD_NONE;
-
-   RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset );
-
-   /* Important:
-    */
-   VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
-   intel->vertex_attr_count = 0;
-   intel->coloroffset = 0;
-   intel->specoffset = 0;
-   offset = 0;
-
-   if (i915->current_program) {
-      i915->current_program->on_hardware = 0;
-      i915->current_program->params_uptodate = 0;
-   }
-
-   if (i915->vertex_fog == I915_FOG_PIXEL) {
-      EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, S4_VFMT_XYZW, 16 );
-      RENDERINPUTS_CLEAR( index_bitset, _TNL_ATTRIB_FOG );
-   }
-   else if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) {
-      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 (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_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 (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 ) ||
-       RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) {
-      if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) {
-        intel->specoffset = offset / 4;
-        EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, S4_VFMT_SPEC_FOG, 3 );
-      } else 
-        EMIT_PAD( 3 );
-      
-      if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG ))
-        EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, S4_VFMT_SPEC_FOG, 1 );
-      else
-        EMIT_PAD( 1 );
-   }
-
-   if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) {
-      for (i = 0; i < 8; i++) {
-        if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_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;
-   }
-}
index a19d4b65840a330e0bac03bdbe77017ebfafffd2..48137f025f02ecc0a2acbf0c30e7839bdcbe4e4b 100644 (file)
  * 
  **************************************************************************/
 
-#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_mipmap_tree.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->_BaseFormat;
-
-           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->_BaseFormat;
-        }
-
-        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->_BaseFormat;
-        if (t->intel.image[0][i].image->IsCompressed) {
-           total_height += (t->intel.image[0][i].image->Height + 3) / 4;
-        }
-        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 )
+static GLuint
+translate_texture_format(GLuint mesa_format, GLenum DepthMode)
 {
-   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->_BaseFormat;
-
-           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->_BaseFormat;
-        
-
-
-        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->_BaseFormat;
-
-        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 ) {
+   switch (mesa_format) {
    case MESA_FORMAT_L8:
-      t->intel.texelBytes = 1;
-      textureFormat = MAPSURF_8BIT | MT_8BIT_L8;
-      break;
-
+      return MAPSURF_8BIT | MT_8BIT_L8;
    case MESA_FORMAT_I8:
-      t->intel.texelBytes = 1;
-      textureFormat = MAPSURF_8BIT | MT_8BIT_I8;
-      break;
-
+      return MAPSURF_8BIT | MT_8BIT_I8;
    case MESA_FORMAT_A8:
-      t->intel.texelBytes = 1;
-      textureFormat = MAPSURF_8BIT | MT_8BIT_A8; 
-      break;
-
+      return MAPSURF_8BIT | MT_8BIT_A8;
    case MESA_FORMAT_AL88:
-      t->intel.texelBytes = 2;
-      textureFormat = MAPSURF_16BIT | MT_16BIT_AY88;
-      break;
-
+      return MAPSURF_16BIT | MT_16BIT_AY88;
    case MESA_FORMAT_RGB565:
-      t->intel.texelBytes = 2;
-      textureFormat = MAPSURF_16BIT | MT_16BIT_RGB565;
-      break;
-
+      return MAPSURF_16BIT | MT_16BIT_RGB565;
    case MESA_FORMAT_ARGB1555:
-      t->intel.texelBytes = 2;
-      textureFormat = MAPSURF_16BIT | MT_16BIT_ARGB1555;
-      break;
-
+      return MAPSURF_16BIT | MT_16BIT_ARGB1555;
    case MESA_FORMAT_ARGB4444:
-      t->intel.texelBytes = 2;
-      textureFormat = MAPSURF_16BIT | MT_16BIT_ARGB4444;
-      break;
-
+      return MAPSURF_16BIT | MT_16BIT_ARGB4444;
    case MESA_FORMAT_ARGB8888:
-      t->intel.texelBytes = 4;
-      textureFormat = MAPSURF_32BIT | MT_32BIT_ARGB8888;
-      break;
-
+      return MAPSURF_32BIT | MT_32BIT_ARGB8888;
    case MESA_FORMAT_YCBCR_REV:
-      t->intel.texelBytes = 2;
-      textureFormat = (MAPSURF_422 | MT_422_YCRCB_NORMAL);
-      ss2 |= SS2_COLORSPACE_CONVERSION;
-      break;
-
+      return (MAPSURF_422 | MT_422_YCRCB_NORMAL);
    case MESA_FORMAT_YCBCR:
-      t->intel.texelBytes = 2;
-      textureFormat = (MAPSURF_422 | MT_422_YCRCB_SWAPY);
-      ss2 |= SS2_COLORSPACE_CONVERSION;
-      break;
-
+      return (MAPSURF_422 | MT_422_YCRCB_SWAPY);
    case MESA_FORMAT_RGB_FXT1:
    case MESA_FORMAT_RGBA_FXT1:
-     t->intel.texelBytes = 2;
-     textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_FXT1);
-     break;
-
+      return (MAPSURF_COMPRESSED | MT_COMPRESS_FXT1);
    case MESA_FORMAT_Z16:
-      t->intel.texelBytes = 2;
-      textureFormat = (MAPSURF_16BIT | MT_16BIT_L16);
-      break;
-
+      if (DepthMode == GL_ALPHA)
+          return (MAPSURF_16BIT | MT_16BIT_A16);
+      else if (DepthMode == GL_INTENSITY)
+          return (MAPSURF_16BIT | MT_16BIT_I16);
+      else
+          return (MAPSURF_16BIT | MT_16BIT_L16);
    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;
-
+      return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT1);
    case MESA_FORMAT_RGBA_DXT3:
-     t->intel.texelBytes = 4;
-     textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_DXT2_3);
-     break;
-
+      return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT2_3);
    case MESA_FORMAT_RGBA_DXT5:
-     t->intel.texelBytes = 4;
-     textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5);
-     break;
-
-#if 0
-   case MESA_FORMAT_Z24_S8:
-      t->intel.texelBytes = 4;
-      textureFormat = (MAPSURF_32BIT | MT_32BIT_xL824);
-      break;
-#endif
-
+      return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5);
+   case MESA_FORMAT_S8_Z24:
+      return (MAPSURF_32BIT | MT_32BIT_xI824);
    default:
-      fprintf(stderr, "%s: bad image format %x\n", __FUNCTION__,
-             baseImage->TexFormat->MesaFormat);
+      fprintf(stderr, "%s: bad image format %x\n", __FUNCTION__, mesa_format);
       abort();
+      return 0;
    }
+}
 
-   switch (i915->intel.intelScreen->deviceID) {
-   case PCI_CHIP_I945_G:
-   case PCI_CHIP_I945_GM:
-   case PCI_CHIP_I945_GME:
-   case PCI_CHIP_G33_G:
-   case PCI_CHIP_Q33_G:
-   case PCI_CHIP_Q35_G:
-       i945LayoutTextureImages( i915, tObj );
-       break;
-   default:
-       i915LayoutTextureImages( i915, tObj );
-       break;
-   }
-
-   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 )
+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;
+   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:
-      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]);
+      return TEXCOORDMODE_WRAP;
    }
 }
 
 
 
-static void i915_import_tex_unit( i915ContextPtr i915, 
-                                i915TextureObjectPtr t,
-                                GLuint unit )
+/* Recalculate all state from scratch.  Perhaps not the most
+ * efficient, but this has gotten complex enough that we need
+ * something which is understandable and reliable.
+ */
+static GLboolean
+i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
 {
-   GLuint state[I915_TEX_SETUP_SIZE];
+   GLcontext *ctx = &intel->ctx;
+   struct i915_context *i915 = i915_context(ctx);
+   struct gl_texture_unit *tUnit = &ctx->Texture.Unit[unit];
+   struct gl_texture_object *tObj = tUnit->_Current;
+   struct intel_texture_object *intelObj = intel_texture_object(tObj);
+   struct gl_texture_image *firstImage;
+   GLuint *state = i915->state.Tex[unit], format, pitch;
+   GLint lodbias;
 
-   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);
+   memset(state, 0, sizeof(state));
 
-   i915->intel.CurrentTexObj[unit] = (intelTextureObjectPtr)t;
-   t->intel.base.bound |= (1 << unit);
+   /*We need to refcount these. */
 
-   if (t->intel.dirty & I915_UPLOAD_TEX(unit)) {
-      i915ImportTexObjState( t->intel.base.tObj );
-      t->intel.dirty &= ~I915_UPLOAD_TEX(unit);
+   if (i915->state.tex_buffer[unit] != NULL) {
+       dri_bo_unreference(i915->state.tex_buffer[unit]);
+       i915->state.tex_buffer[unit] = NULL;
    }
 
-   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));
+   if (!intelObj->imageOverride && !intel_finalize_mipmap_tree(intel, unit))
+      return GL_FALSE;
 
-   state[I915_TEXREG_SS3] |= (unit<<SS3_TEXTUREMAP_INDEX_SHIFT);
+   /* Get first image here, since intelObj->firstLevel will get set in
+    * the intel_finalize_mipmap_tree() call above.
+    */
+   firstImage = tObj->Image[0][intelObj->firstLevel];
 
-   state[I915_TEXREG_SS4] = t->Setup[I915_TEXREG_SS4];
+   if (intelObj->imageOverride) {
+      i915->state.tex_buffer[unit] = NULL;
+      i915->state.tex_offset[unit] = intelObj->textureOffset;
 
+      switch (intelObj->depthOverride) {
+      case 32:
+        format = MAPSURF_32BIT | MT_32BIT_ARGB8888;
+        break;
+      case 24:
+      default:
+        format = MAPSURF_32BIT | MT_32BIT_XRGB8888;
+        break;
+      case 16:
+        format = MAPSURF_16BIT | MT_16BIT_RGB565;
+        break;
+      }
 
-   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));
+      pitch = intelObj->pitchOverride;
+   } else {
+      dri_bo_reference(intelObj->mt->region->buffer);
+      i915->state.tex_buffer[unit] = intelObj->mt->region->buffer;
+      i915->state.tex_offset[unit] =  intel_miptree_image_offset(intelObj->mt,
+                                                                0, intelObj->
+                                                                firstLevel);
+
+      format = translate_texture_format(firstImage->TexFormat->MesaFormat, 
+               tObj->DepthMode);
+      pitch = intelObj->mt->pitch * intelObj->mt->cpp;
    }
-}
-
-
 
-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;
+   state[I915_TEXREG_MS3] =
+      (((firstImage->Height - 1) << MS3_HEIGHT_SHIFT) |
+       ((firstImage->Width - 1) << MS3_WIDTH_SHIFT) | format |
+       MS3_USE_FENCE_REGS);
 
-   if (0) fprintf(stderr, "%s %d\n", __FUNCTION__, unit);
+   state[I915_TEXREG_MS4] =
+     ((((pitch / 4) - 1) << MS4_PITCH_SHIFT) | MS4_CUBE_FACE_ENA_MASK |
+       ((((intelObj->lastLevel - intelObj->firstLevel) * 4)) <<
+       MS4_MAX_LOD_SHIFT) | ((firstImage->Depth - 1) <<
+                             MS4_VOLUME_DEPTH_SHIFT));
 
-   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;
-   }
+   {
+      GLuint minFilt, mipFilt, magFilt;
 
+      switch (tObj->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:
+         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;
-   }
+      if (tObj->MaxAnisotropy > 1.0) {
+         minFilt = FILTER_ANISOTROPIC;
+         magFilt = FILTER_ANISOTROPIC;
+      }
+      else {
+         switch (tObj->MagFilter) {
+         case GL_NEAREST:
+            magFilt = FILTER_NEAREST;
+            break;
+         case GL_LINEAR:
+            magFilt = FILTER_LINEAR;
+            break;
+         default:
+            return GL_FALSE;
+         }
+      }
 
-   return GL_TRUE;
-}
+      lodbias = (int) ((tUnit->LodBias + tObj->LodBias) * 16.0);
+      if (lodbias < -256)
+          lodbias = -256;
+      if (lodbias > 255)
+          lodbias = 255;
+      state[I915_TEXREG_SS2] = ((lodbias << SS2_LOD_BIAS_SHIFT) & 
+                                SS2_LOD_BIAS_MASK);
 
-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];
+      /* YUV conversion:
+       */
+      if (firstImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR ||
+          firstImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR_REV)
+         state[I915_TEXREG_SS2] |= SS2_COLORSPACE_CONVERSION;
 
-   ss3 &= ~SS3_NORMALIZED_COORDS;
+      /* Shadow:
+       */
+      if (tObj->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB &&
+          tObj->Target != GL_TEXTURE_3D) {
+         if (tObj->Target == GL_TEXTURE_1D) 
+            return GL_FALSE;
 
-   if (ss3 != i915->state.Tex[unit][I915_TEXREG_SS3]) {
-      I915_STATECHANGE(i915, I915_UPLOAD_TEX(unit));
-      i915->state.Tex[unit][I915_TEXREG_SS3] = ss3;
-   }
+         state[I915_TEXREG_SS2] |=
+            (SS2_SHADOW_ENABLE |
+             intel_translate_shadow_compare_func(tObj->CompareFunc));
 
-   /* Upload teximages (not pipelined)
-    */
-   if (t->intel.base.dirty_images[0]) {
-      i915SetTexImages( i915, tObj );
-      if (!intelUploadTexImages( &i915->intel, &t->intel, 0 )) {
-        return GL_FALSE;
+         minFilt = FILTER_4X4_FLAT;
+         magFilt = FILTER_4X4_FLAT;
       }
-   }
-
-   return GL_TRUE;
-}
 
+      state[I915_TEXREG_SS2] |= ((minFilt << SS2_MIN_FILTER_SHIFT) |
+                                 (mipFilt << SS2_MIP_FILTER_SHIFT) |
+                                 (magFilt << SS2_MAG_FILTER_SHIFT));
+   }
 
-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;
+   {
+      GLenum ws = tObj->WrapS;
+      GLenum wt = tObj->WrapT;
+      GLenum wr = tObj->WrapR;
 
-   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;
-      }
-   }
+      /* 3D textures don't seem to respect the border color.
+       * Fallback if there's ever a danger that they might refer to
+       * it.  
+       * 
+       * Effectively this means fallback on 3D clamp or
+       * clamp_to_border.
+       */
+      if (tObj->Target == GL_TEXTURE_3D &&
+          (tObj->MinFilter != GL_NEAREST ||
+           tObj->MagFilter != GL_NEAREST) &&
+          (ws == GL_CLAMP ||
+           wt == GL_CLAMP ||
+           wr == GL_CLAMP ||
+           ws == GL_CLAMP_TO_BORDER ||
+           wt == GL_CLAMP_TO_BORDER || wr == GL_CLAMP_TO_BORDER))
+         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;
-   }
+      state[I915_TEXREG_SS3] = ss3;     /* SS3_NORMALIZED_COORDS */
 
-   /* 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 );
-   }
+      state[I915_TEXREG_SS3] |=
+         ((translate_wrap_mode(ws) << SS3_TCX_ADDR_MODE_SHIFT) |
+          (translate_wrap_mode(wt) << SS3_TCY_ADDR_MODE_SHIFT) |
+          (translate_wrap_mode(wr) << SS3_TCZ_ADDR_MODE_SHIFT));
 
-   /* 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;
-        }
-      }
+      state[I915_TEXREG_SS3] |= (unit << SS3_TEXTUREMAP_INDEX_SHIFT);
    }
 
 
-   return GL_TRUE;
-}
+   state[I915_TEXREG_SS4] = INTEL_PACKCOLOR8888(tObj->_BorderChan[0],
+                                                tObj->_BorderChan[1],
+                                                tObj->_BorderChan[2],
+                                                tObj->_BorderChan[3]);
 
-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:
+   I915_ACTIVESTATE(i915, I915_UPLOAD_TEX(unit), GL_TRUE);
+   /* memcmp was already disabled, but definitely won't work as the
+    * region might now change and that wouldn't be detected:
     */
-   if (t->refs_border_color)
-      return GL_FALSE;
+   I915_STATECHANGE(i915, I915_UPLOAD_TEX(unit));
 
-   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;
-   }
+#if 0
+   DBG(TEXTURE, "state[I915_TEXREG_SS2] = 0x%x\n", state[I915_TEXREG_SS2]);
+   DBG(TEXTURE, "state[I915_TEXREG_SS3] = 0x%x\n", state[I915_TEXREG_SS3]);
+   DBG(TEXTURE, "state[I915_TEXREG_SS4] = 0x%x\n", state[I915_TEXREG_SS4]);
+   DBG(TEXTURE, "state[I915_TEXREG_MS2] = 0x%x\n", state[I915_TEXREG_MS2]);
+   DBG(TEXTURE, "state[I915_TEXREG_MS3] = 0x%x\n", state[I915_TEXREG_MS3]);
+   DBG(TEXTURE, "state[I915_TEXREG_MS4] = 0x%x\n", state[I915_TEXREG_MS4]);
+#endif
 
    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->tex.size < 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 )
+void
+i915UpdateTextureState(struct intel_context *intel)
 {
-   GLcontext *ctx = &intel->ctx;
    GLboolean ok = GL_TRUE;
    GLuint i;
 
-   for (i = 0 ; i < I915_TEX_UNITS && ok ; i++) {
-      ok = i915UpdateTexUnit( ctx, i );
+   for (i = 0; i < I915_TEX_UNITS && ok; i++) {
+      switch (intel->ctx.Texture.Unit[i]._ReallyEnabled) {
+      case TEXTURE_1D_BIT:
+      case TEXTURE_2D_BIT:
+      case TEXTURE_CUBE_BIT:
+      case TEXTURE_3D_BIT:
+         ok = i915_update_tex_unit(intel, i, SS3_NORMALIZED_COORDS);
+         break;
+      case TEXTURE_RECT_BIT:
+         ok = i915_update_tex_unit(intel, i, 0);
+         break;
+      case 0:{
+            struct i915_context *i915 = i915_context(&intel->ctx);
+            if (i915->state.active & I915_UPLOAD_TEX(i))
+               I915_ACTIVESTATE(i915, I915_UPLOAD_TEX(i), GL_FALSE);
+
+           if (i915->state.tex_buffer[i] != NULL) {
+              dri_bo_unreference(i915->state.tex_buffer[i]);
+              i915->state.tex_buffer[i] = NULL;
+           }
+
+            break;
+         }
+      default:
+         ok = GL_FALSE;
+         break;
+      }
    }
 
-   FALLBACK( intel, I915_FALLBACK_TEXTURE, !ok );
+   FALLBACK(intel, I915_FALLBACK_TEXTURE, !ok);
 }
-
-
-
index cc8a605e50537c21868f96b1e4dd18035b84eb89..19f2206285da04e17b3e1fcc67f8215e33a30cea 100644 (file)
 #include "tnl/t_vertex.h"
 
 #include "intel_batchbuffer.h"
+#include "intel_tex.h"
+#include "intel_regions.h"
+#include "intel_tris.h"
 
 #include "i915_reg.h"
 #include "i915_context.h"
 
-static void i915_render_start( intelContextPtr intel )
+#include "glapi.h"
+
+static void
+i915_render_prevalidate(struct intel_context *intel)
 {
-   GLcontext *ctx = &intel->ctx;
-   i915ContextPtr i915 = I915_CONTEXT(intel);
+   struct i915_context *i915 = i915_context(&intel->ctx);
 
-   if (ctx->FragmentProgram._Active) 
-      i915ValidateFragmentProgram( i915 );
-   else {
-      assert(!ctx->FragmentProgram._MaintainTexEnvProgram);
-      i915ValidateTextureProgram( i915 );
-   }
+   if (!intel->Fallback)
+       i915ValidateFragmentProgram(i915);
+}
+
+static void
+i915_render_start(struct intel_context *intel)
+{
 }
 
 
-static void i915_reduced_primitive_state( intelContextPtr intel,
-                                         GLenum rprim )
+static void
+i915_reduced_primitive_state(struct intel_context *intel, GLenum rprim)
 {
-    i915ContextPtr i915 = I915_CONTEXT(intel);
-    GLuint st1 = i915->state.Stipple[I915_STPREG_ST1];
-
-    st1 &= ~ST1_ENABLE;
-
-    switch (rprim) {
-    case GL_QUADS: /* from RASTERIZE(GL_QUADS) in t_dd_tritemp.h */
-    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;
-    }
+   struct i915_context *i915 = i915_context(&intel->ctx);
+   GLuint st1 = i915->state.Stipple[I915_STPREG_ST1];
+
+   st1 &= ~ST1_ENABLE;
+
+   switch (rprim) {
+   case GL_QUADS: /* from RASTERIZE(GL_QUADS) in t_dd_tritemp.h */
+   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]) {
+      INTEL_FIREVERTICES(intel);
+
+      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 )
+static GLboolean
+i915_check_vertex_size(struct intel_context *intel, GLuint expected)
 {
-   i915ContextPtr i915 = I915_CONTEXT(intel);
+   struct i915_context *i915 = i915_context(&intel->ctx);
    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: 
+   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++) { 
+   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;
+      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;
+         fprintf(stderr, "bad texcoord fmt %d\n", i);
+         return GL_FALSE;
       }
       lis2 >>= S2_TEXCOORD_FMT1_SHIFT;
    }
-       
-   if (sz != expected) 
+
+   if (sz != expected)
       fprintf(stderr, "vertex size mismatch %d/%d\n", sz, expected);
-   
+
    return sz == expected;
 }
 
 
-static void i915_emit_invarient_state( intelContextPtr intel )
+static void
+i915_emit_invarient_state(struct intel_context *intel)
 {
    BATCH_LOCALS;
 
-   BEGIN_BATCH( 20 );
+   BEGIN_BATCH(200, IGNORE_CLIPRECTS);
 
    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);
+             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);
@@ -158,35 +191,27 @@ static void i915_emit_invarient_state( intelContextPtr intel )
 
    /* 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));
+             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);
+             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) |
-            (0));
+   OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(3) | (0));
    OUT_BATCH(0);
+
    /* XXX: Use this */
-   OUT_BATCH(_3DSTATE_SCISSOR_ENABLE_CMD | 
-            DISABLE_SCISSOR_RECT);
+   OUT_BATCH(_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT);
 
    OUT_BATCH(_3DSTATE_SCISSOR_RECT_0_CMD);
    OUT_BATCH(0);
@@ -194,29 +219,23 @@ static void i915_emit_invarient_state( intelContextPtr intel )
 
    OUT_BATCH(_3DSTATE_DEPTH_SUBRECT_DISABLE);
 
-   OUT_BATCH(_3DSTATE_LOAD_INDIRECT | 0); /* disable indirect state */
+   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 );
-   
+   OUT_BATCH(_3DSTATE_BACKFACE_STENCIL_OPS | BFO_ENABLE_STENCIL_TWO_SIDE | 0);
+   OUT_BATCH(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);
+#define emit(intel, state, size )                   \
+   intel_batchbuffer_data(intel->batch, state, size, IGNORE_CLIPRECTS )
 
-static GLuint get_dirty( struct i915_hw_state *state )
+static GLuint
+get_dirty(struct i915_hw_state *state)
 {
    GLuint dirty;
 
@@ -227,94 +246,172 @@ static GLuint get_dirty( struct i915_hw_state *state )
    if (dirty & I915_UPLOAD_TEX_ALL)
       state->emitted &= ~I915_UPLOAD_TEX_ALL;
    dirty = state->active & ~state->emitted;
-
    return dirty;
 }
 
 
-static GLuint get_state_size( struct i915_hw_state *state )
+static GLuint
+get_state_size(struct i915_hw_state *state)
 {
    GLuint dirty = get_dirty(state);
    GLuint i;
    GLuint sz = 0;
 
    if (dirty & I915_UPLOAD_INVARIENT)
-      sz += 20 * sizeof(int);
+      sz += 30 * 4;
 
    if (dirty & I915_UPLOAD_CTX)
       sz += sizeof(state->Ctx);
 
-   if (dirty & I915_UPLOAD_BUFFERS) 
+   if (dirty & I915_UPLOAD_BUFFERS)
       sz += sizeof(state->Buffer);
 
    if (dirty & I915_UPLOAD_STIPPLE)
       sz += sizeof(state->Stipple);
 
-   if (dirty & I915_UPLOAD_FOG) 
+   if (dirty & I915_UPLOAD_FOG)
       sz += sizeof(state->Fog);
 
    if (dirty & I915_UPLOAD_TEX_ALL) {
       int nr = 0;
-      for (i = 0; i < I915_TEX_UNITS; i++) 
-        if (dirty & I915_UPLOAD_TEX(i)) 
-           nr++;
+      for (i = 0; i < I915_TEX_UNITS; i++)
+         if (dirty & I915_UPLOAD_TEX(i))
+            nr++;
 
-      sz += (2+nr*3) * sizeof(GLuint) * 2;
+      sz += (2 + nr * 3) * sizeof(GLuint) * 2;
    }
 
-   if (dirty & I915_UPLOAD_CONSTANTS) 
+   if (dirty & I915_UPLOAD_CONSTANTS)
       sz += state->ConstantSize * sizeof(GLuint);
 
-   if (dirty & I915_UPLOAD_PROGRAM) 
+   if (dirty & I915_UPLOAD_PROGRAM)
       sz += state->ProgramSize * sizeof(GLuint);
 
    return sz;
 }
 
-
 /* Push the state into the sarea and/or texture memory.
  */
-static void i915_emit_state( intelContextPtr intel )
+static void
+i915_emit_state(struct intel_context *intel)
 {
-   i915ContextPtr i915 = I915_CONTEXT(intel);
+   struct i915_context *i915 = i915_context(&intel->ctx);
    struct i915_hw_state *state = i915->current;
-   int i;
-   GLuint dirty = get_dirty(state);
-   GLuint counter = intel->batch.counter;
+   int i, count, aper_count;
+   GLuint dirty;
+   dri_bo *aper_array[3 + I915_TEX_UNITS];
+   GET_CURRENT_CONTEXT(ctx);
    BATCH_LOCALS;
 
-   if (intel->batch.space < get_state_size(state)) {
-      intelFlushBatch(intel, GL_TRUE);
-      dirty = get_dirty(state);
-      counter = intel->batch.counter;
+   /* We don't hold the lock at this point, so want to make sure that
+    * there won't be a buffer wrap between the state emits and the primitive
+    * emit header.
+    *
+    * It might be better to talk about explicit places where
+    * scheduling is allowed, rather than assume that it is whenever a
+    * batchbuffer fills up.
+    *
+    * Set the space as LOOP_CLIPRECTS now, since that's what our primitives
+    * will be emitted under.
+    */
+   intel_batchbuffer_require_space(intel->batch,
+                                  get_state_size(state) + INTEL_PRIM_EMIT_SIZE,
+                                  LOOP_CLIPRECTS);
+   count = 0;
+ again:
+   aper_count = 0;
+   dirty = get_dirty(state);
+
+   aper_array[aper_count++] = intel->batch->buf;
+   if (dirty & I915_UPLOAD_BUFFERS) {
+      aper_array[aper_count++] = state->draw_region->buffer;
+      if (state->depth_region)
+        aper_array[aper_count++] = state->depth_region->buffer;
+   }
+
+   if (dirty & I915_UPLOAD_TEX_ALL) {
+      for (i = 0; i < I915_TEX_UNITS; i++) {
+        if (dirty & I915_UPLOAD_TEX(i)) {
+           if (state->tex_buffer[i]) {
+              aper_array[aper_count++] = state->tex_buffer[i];
+           }
+        }
+      }
    }
 
-   if (VERBOSE) 
+   if (dri_bufmgr_check_aperture_space(aper_array, aper_count)) {
+       if (count == 0) {
+          count++;
+          intel_batchbuffer_flush(intel->batch);
+          goto again;
+       } else {
+          _mesa_error(ctx, GL_OUT_OF_MEMORY, "i915 emit state");
+          assert(0);
+       }
+   }
+
+   /* work out list of buffers to emit */
+   
+   /* Do this here as we may have flushed the batchbuffer above,
+    * causing more state to be dirty!
+    */
+   dirty = get_dirty(state);
+   state->emitted |= dirty;
+   assert(get_dirty(state) == 0);
+
+   if (INTEL_DEBUG & DEBUG_STATE)
       fprintf(stderr, "%s dirty: %x\n", __FUNCTION__, dirty);
 
    if (dirty & I915_UPLOAD_INVARIENT) {
-      if (VERBOSE) fprintf(stderr, "I915_UPLOAD_INVARIENT:\n"); 
-      i915_emit_invarient_state( intel );
+      if (INTEL_DEBUG & DEBUG_STATE)
+         fprintf(stderr, "I915_UPLOAD_INVARIENT:\n");
+      i915_emit_invarient_state(intel);
    }
 
    if (dirty & I915_UPLOAD_CTX) {
-      if (VERBOSE) fprintf(stderr, "I915_UPLOAD_CTX:\n"); 
-      emit( i915, state->Ctx, sizeof(state->Ctx) );
+      if (INTEL_DEBUG & DEBUG_STATE)
+         fprintf(stderr, "I915_UPLOAD_CTX:\n");
+
+      emit(intel, 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 (INTEL_DEBUG & DEBUG_STATE)
+         fprintf(stderr, "I915_UPLOAD_BUFFERS:\n");
+      BEGIN_BATCH(I915_DEST_SETUP_SIZE + 2, IGNORE_CLIPRECTS);
+      OUT_BATCH(state->Buffer[I915_DESTREG_CBUFADDR0]);
+      OUT_BATCH(state->Buffer[I915_DESTREG_CBUFADDR1]);
+      OUT_RELOC(state->draw_region->buffer,
+               I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
+                state->draw_region->draw_offset);
+
+      if (state->depth_region) {
+         OUT_BATCH(state->Buffer[I915_DESTREG_DBUFADDR0]);
+         OUT_BATCH(state->Buffer[I915_DESTREG_DBUFADDR1]);
+         OUT_RELOC(state->depth_region->buffer,
+                  I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
+                   state->depth_region->draw_offset);
+      }
+
+      OUT_BATCH(state->Buffer[I915_DESTREG_DV0]);
+      OUT_BATCH(state->Buffer[I915_DESTREG_DV1]);
+      OUT_BATCH(state->Buffer[I915_DESTREG_SENABLE]);
+      OUT_BATCH(state->Buffer[I915_DESTREG_SR0]);
+      OUT_BATCH(state->Buffer[I915_DESTREG_SR1]);
+      OUT_BATCH(state->Buffer[I915_DESTREG_SR2]);
+      ADVANCE_BATCH();
    }
 
    if (dirty & I915_UPLOAD_STIPPLE) {
-      if (VERBOSE) fprintf(stderr, "I915_UPLOAD_STIPPLE:\n"); 
-      emit( i915, state->Stipple, sizeof(state->Stipple) );
+      if (INTEL_DEBUG & DEBUG_STATE)
+         fprintf(stderr, "I915_UPLOAD_STIPPLE:\n");
+      emit(intel, 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) );
+      if (INTEL_DEBUG & DEBUG_STATE)
+         fprintf(stderr, "I915_UPLOAD_FOG:\n");
+      emit(intel, state->Fog, sizeof(state->Fog));
    }
 
    /* Combine all the dirty texture state into a single command to
@@ -323,141 +420,219 @@ static void i915_emit_state( intelContextPtr intel )
    if (dirty & I915_UPLOAD_TEX_ALL) {
       int nr = 0;
 
-      for (i = 0; i < I915_TEX_UNITS; i++) 
-        if (dirty & I915_UPLOAD_TEX(i)) 
-           nr++;
+      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));
+      BEGIN_BATCH(2 + nr * 3, IGNORE_CLIPRECTS);
+      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]);
-        }
+      for (i = 0; i < I915_TEX_UNITS; i++)
+         if (dirty & I915_UPLOAD_TEX(i)) {
+
+            if (state->tex_buffer[i]) {
+               OUT_RELOC(state->tex_buffer[i],
+                        I915_GEM_DOMAIN_SAMPLER, 0,
+                         state->tex_offset[i]);
+            }
+            else if (state == &i915->meta) {
+               assert(i == 0);
+               OUT_BATCH(0);
+            }
+            else {
+               OUT_BATCH(state->tex_offset[i]);
+            }
+
+            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));
+      BEGIN_BATCH(2 + nr * 3, IGNORE_CLIPRECTS);
+      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]);
-        }
+      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 (INTEL_DEBUG & DEBUG_STATE)
+         fprintf(stderr, "I915_UPLOAD_CONSTANTS:\n");
+      emit(intel, state->Constant, state->ConstantSize * sizeof(GLuint));
    }
 
    if (dirty & I915_UPLOAD_PROGRAM) {
-      if (VERBOSE) fprintf(stderr, "I915_UPLOAD_PROGRAM:\n"); 
+      if (state->ProgramSize) {
+         if (INTEL_DEBUG & DEBUG_STATE)
+            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 );
+         assert((state->Program[0] & 0x1ff) + 2 == state->ProgramSize);
+
+         emit(intel, state->Program, state->ProgramSize * sizeof(GLuint));
+         if (INTEL_DEBUG & DEBUG_STATE)
+            i915_disassemble_program(state->Program, state->ProgramSize);
+      }
    }
 
-   state->emitted |= dirty;
-   intel->batch.last_emit_state = counter;
-   assert(counter == intel->batch.counter);
+   intel->batch->dirty_state &= ~dirty;
+   assert(get_dirty(state) == 0);
+   assert((intel->batch->dirty_state & (1<<1)) == 0);
 }
 
-static void i915_destroy_context( intelContextPtr intel )
+static void
+i915_destroy_context(struct intel_context *intel)
 {
+   GLuint i;
+   struct i915_context *i915 = i915_context(&intel->ctx);
+
+   for (i = 0; i < I915_TEX_UNITS; i++) {
+      if (i915->state.tex_buffer[i] != NULL) {
+        dri_bo_unreference(i915->state.tex_buffer[i]);
+        i915->state.tex_buffer[i] = NULL;
+      }
+   }
+
    _tnl_free_vertices(&intel->ctx);
 }
 
 
 /**
- * Set the color buffer drawing region.
+ * Set the drawing regions for the color and depth/stencil buffers.
+ * This involves setting the pitch, cpp and buffer ID/location.
+ * Also set pixel format for color and Z rendering
+ * Used for setting both regular and meta state.
  */
-static void
-i915_set_color_region( intelContextPtr intel, const intelRegion *region)
+void
+i915_state_draw_region(struct intel_context *intel,
+                       struct i915_hw_state *state,
+                       struct intel_region *color_region,
+                       struct intel_region *depth_region)
 {
-   i915ContextPtr i915 = I915_CONTEXT(intel);
-   I915_STATECHANGE( i915, I915_UPLOAD_BUFFERS );
-   i915->state.Buffer[I915_DESTREG_CBUFADDR1] =
-      (BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(region->pitch) | BUF_3D_USE_FENCE);
-   i915->state.Buffer[I915_DESTREG_CBUFADDR2] = region->offset;
+   struct i915_context *i915 = i915_context(&intel->ctx);
+   GLuint value;
+
+   ASSERT(state == &i915->state || state == &i915->meta);
+
+   if (state->draw_region != color_region) {
+      intel_region_release(&state->draw_region);
+      intel_region_reference(&state->draw_region, color_region);
+   }
+   if (state->depth_region != depth_region) {
+      intel_region_release(&state->depth_region);
+      intel_region_reference(&state->depth_region, depth_region);
+   }
+
+   /*
+    * Set stride/cpp values
+    */
+   if (color_region) {
+      state->Buffer[I915_DESTREG_CBUFADDR0] = _3DSTATE_BUF_INFO_CMD;
+      state->Buffer[I915_DESTREG_CBUFADDR1] =
+         (BUF_3D_ID_COLOR_BACK |
+          BUF_3D_PITCH(color_region->pitch * color_region->cpp) |
+          BUF_3D_USE_FENCE);
+   }
+
+   if (depth_region) {
+      state->Buffer[I915_DESTREG_DBUFADDR0] = _3DSTATE_BUF_INFO_CMD;
+      state->Buffer[I915_DESTREG_DBUFADDR1] =
+         (BUF_3D_ID_DEPTH |
+          BUF_3D_PITCH(depth_region->pitch * depth_region->cpp) |
+          BUF_3D_USE_FENCE);
+   }
+
+   /*
+    * Compute/set I915_DESTREG_DV1 value
+    */
+   value = (DSTORG_HORT_BIAS(0x8) |     /* .5 */
+            DSTORG_VERT_BIAS(0x8) |     /* .5 */
+            LOD_PRECLAMP_OGL | TEX_DEFAULT_COLOR_OGL);
+   if (color_region && color_region->cpp == 4) {
+      value |= DV_PF_8888;
+   }
+   else {
+      value |= (DITHER_FULL_ALWAYS | DV_PF_565);
+   }
+   if (depth_region && depth_region->cpp == 4) {
+      value |= DEPTH_FRMT_24_FIXED_8_OTHER;
+   }
+   else {
+      value |= DEPTH_FRMT_16_FIXED;
+   }
+   state->Buffer[I915_DESTREG_DV1] = value;
+
+   I915_STATECHANGE(i915, I915_UPLOAD_BUFFERS);
 }
 
 
-/**
- * specify the z-buffer/stencil region
- */
 static void
-i915_set_z_region( intelContextPtr intel, const intelRegion *region)
+i915_set_draw_region(struct intel_context *intel,
+                     struct intel_region *color_regions[],
+                     struct intel_region *depth_region,
+                    GLuint num_regions)
 {
-   i915ContextPtr i915 = I915_CONTEXT(intel);
-   I915_STATECHANGE( i915, I915_UPLOAD_BUFFERS );
-   i915->state.Buffer[I915_DESTREG_DBUFADDR1] =
-      (BUF_3D_ID_DEPTH | BUF_3D_PITCH(region->pitch) | BUF_3D_USE_FENCE);
-   i915->state.Buffer[I915_DESTREG_DBUFADDR2] = region->offset;
+   struct i915_context *i915 = i915_context(&intel->ctx);
+   i915_state_draw_region(intel, &i915->state, color_regions[0], depth_region);
 }
 
 
-/**
- * Set both the color and Z/stencil drawing regions.
- * Similar to two previous functions, but don't use I915_STATECHANGE()
- */
+
 static void
-i915_update_color_z_regions(intelContextPtr intel,
-                            const intelRegion *colorRegion,
-                            const intelRegion *depthRegion)
+i915_new_batch(struct intel_context *intel)
 {
-   i915ContextPtr i915 = I915_CONTEXT(intel);
+   struct i915_context *i915 = i915_context(&intel->ctx);
 
-   i915->state.Buffer[I915_DESTREG_CBUFADDR1] =
-      (BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(colorRegion->pitch) | BUF_3D_USE_FENCE);
-   i915->state.Buffer[I915_DESTREG_CBUFADDR2] = colorRegion->offset;
+   /* Mark all state as needing to be emitted when starting a new batchbuffer.
+    * Using hardware contexts would be an alternative, but they have some
+    * difficulties associated with them (physical address requirements).
+    */
+   i915->state.emitted = 0;
 
-   i915->state.Buffer[I915_DESTREG_DBUFADDR1] =
-      (BUF_3D_ID_DEPTH |
-       BUF_3D_PITCH(depthRegion->pitch) |  /* pitch in bytes */
-       BUF_3D_USE_FENCE);
-   i915->state.Buffer[I915_DESTREG_DBUFADDR2] = depthRegion->offset;
+   /* Check that we didn't just wrap our batchbuffer at a bad time. */
+   assert(!intel->no_batch_wrap);
 }
 
-
-static void i915_lost_hardware( intelContextPtr intel )
+static GLuint
+i915_flush_cmd(void)
 {
-   I915_CONTEXT(intel)->state.emitted = 0;
+   return MI_FLUSH | FLUSH_MAP_CACHE;
 }
 
-static void i915_emit_flush( intelContextPtr intel )
+static void 
+i915_assert_not_dirty( struct intel_context *intel )
 {
-   BATCH_LOCALS;
+   struct i915_context *i915 = i915_context(&intel->ctx);
+   struct i915_hw_state *state = i915->current;
+   GLuint dirty = get_dirty(state);
+   assert(!dirty);
+}
 
-   BEGIN_BATCH(2);
-   OUT_BATCH( MI_FLUSH | FLUSH_MAP_CACHE | FLUSH_RENDER_CACHE ); 
-   OUT_BATCH( 0 );
-   ADVANCE_BATCH();
+static void
+i915_note_unlock( struct intel_context *intel )
+{
+    /* nothing */
 }
 
 
-void i915InitVtbl( i915ContextPtr i915 )
+void
+i915InitVtbl(struct i915_context *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.rotate_window = i915RotateWindow;
    i915->intel.vtbl.destroy = i915_destroy_context;
    i915->intel.vtbl.emit_state = i915_emit_state;
-   i915->intel.vtbl.lost_hardware = i915_lost_hardware;
+   i915->intel.vtbl.new_batch = i915_new_batch;
    i915->intel.vtbl.reduced_primitive_state = i915_reduced_primitive_state;
    i915->intel.vtbl.render_start = i915_render_start;
-   i915->intel.vtbl.set_color_region = i915_set_color_region;
-   i915->intel.vtbl.set_z_region = i915_set_z_region;
-   i915->intel.vtbl.update_color_z_regions = i915_update_color_z_regions;
+   i915->intel.vtbl.render_prevalidate = i915_render_prevalidate;
+   i915->intel.vtbl.set_draw_region = i915_set_draw_region;
    i915->intel.vtbl.update_texture_state = i915UpdateTextureState;
-   i915->intel.vtbl.emit_flush = i915_emit_flush;
+   i915->intel.vtbl.flush_cmd = i915_flush_cmd;
+   i915->intel.vtbl.assert_not_dirty = i915_assert_not_dirty;
+   i915->intel.vtbl.note_unlock = i915_note_unlock; 
+   i915->intel.vtbl.finish_batch = intel_finish_vb;
 }
-
deleted file mode 100644 (file)
index 803b41b2567deb39128a92a18395d4a7c1482380..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,829 +0,0 @@
-/**************************************************************************
- * 
- * 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 "vblank.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 )
-{
-   x += intel->drawX;
-   y += intel->drawY;
-
-   if (x >= 0 && y >= 0 &&
-       x+w < intel->intelScreen->width &&
-       y+h < intel->intelScreen->height)
-      intelEmitFillBlitLocked( intel, 
-                              intel->intelScreen->cpp,
-                              intel->intelScreen->back.pitch,
-                              intel->intelScreen->back.offset,
-                              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); 
-      intel->vtbl.emit_state( intel );
-   }
-
-#if 1
-   if (((unsigned long)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;
-   intel->batch.contains_geometry = 1;
-
-   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+dwords)*4 >= intel->batch.space) {
-      intelFlushBatch(intel, GL_TRUE); 
-      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();
-
-   intel->batch.contains_geometry = 1;
-
- do_discard:
-   return tmp;
-}
-
-
-static void intelWaitForFrameCompletion( intelContextPtr intel )
-{
-  drm_i915_sarea_t *sarea = (drm_i915_sarea_t *)intel->sarea;
-
-   if (intel->do_irqs) {
-      if (intelGetLastFrame(intel) < sarea->last_dispatch) {
-        if (!intel->irqsEmitted) {
-           while (intelGetLastFrame (intel) < sarea->last_dispatch)
-              ;
-        }
-        else {
-           intelWaitIrq( intel, intel->alloc.irq_emitted );    
-        }
-        intel->irqsEmitted = 10;
-      }
-
-      if (intel->irqsEmitted) {
-        LOCK_HARDWARE( intel ); 
-        intelEmitIrqLocked( intel );
-        intel->irqsEmitted--;
-        UNLOCK_HARDWARE( intel ); 
-      }
-   } 
-   else {
-      while (intelGetLastFrame (intel) < sarea->last_dispatch) {
-        if (intel->do_usleeps) 
-           DO_USLEEP( 1 );
-      }
-   }
-}
-
-/*
- * Copy the back buffer to the front buffer. 
- */
-void intelCopyBuffer( const __DRIdrawablePrivate *dPriv,
-                     const drm_clip_rect_t      *rect)
-{
-   intelContextPtr intel;
-   const intelScreenPrivate *intelScreen;
-   GLboolean   missed_target;
-   int64_t ust;
-
-   if (0)
-      fprintf(stderr, "%s\n", __FUNCTION__);
-
-   assert(dPriv);
-   assert(dPriv->driContextPriv);
-   assert(dPriv->driContextPriv->driverPrivate);
-
-   intel = (intelContextPtr) dPriv->driContextPriv->driverPrivate;
-
-   intelFlush( &intel->ctx );
-   
-   intelScreen = intel->intelScreen;
-
-   if (!rect && !intel->swap_scheduled && intelScreen->drmMinor >= 6 &&
-       !(intel->vblank_flags & VBLANK_FLAG_NO_IRQ) &&
-       intelScreen->current_rotation == 0) {
-      unsigned int interval = driGetVBlankInterval(dPriv, intel->vblank_flags);
-      unsigned int target;
-      drm_i915_vblank_swap_t swap;
-
-      swap.drawable = dPriv->hHWDrawable;
-      swap.seqtype = DRM_VBLANK_ABSOLUTE;
-      target = swap.sequence = intel->vbl_seq + interval;
-
-      if (intel->vblank_flags & VBLANK_FLAG_SYNC) {
-        swap.seqtype |= DRM_VBLANK_NEXTONMISS;
-      } else if (interval == 0) {
-        goto noschedule;
-      }
-
-      if ( intel->vblank_flags & VBLANK_FLAG_SECONDARY ) {
-        swap.seqtype |= DRM_VBLANK_SECONDARY;
-      }
-
-      if (!drmCommandWriteRead(intel->driFd, DRM_I915_VBLANK_SWAP, &swap,
-                              sizeof(swap))) {
-        intel->swap_scheduled = 1;
-        intel->vbl_seq = swap.sequence;
-        swap.sequence -= target;
-        missed_target = swap.sequence > 0 && swap.sequence <= (1 << 23);
-      }
-   } else {
-      intel->swap_scheduled = 0;
-   }
-noschedule:
-
-   if (!intel->swap_scheduled) {
-      intelWaitForFrameCompletion( intel );
-      LOCK_HARDWARE( intel );
-
-      if (!rect)
-      {
-        UNLOCK_HARDWARE( intel );
-        driWaitForVBlank( dPriv, &intel->vbl_seq, intel->vblank_flags, & missed_target );
-        LOCK_HARDWARE( intel );
-      }
-      {
-        const intelScreenPrivate *intelScreen = intel->intelScreen;
-        const __DRIdrawablePrivate *dPriv = intel->driDrawable;
-        const int nbox = dPriv->numClipRects;
-        const drm_clip_rect_t *pbox = dPriv->pClipRects;
-        drm_clip_rect_t box;
-        const int cpp = intelScreen->cpp;
-        const int pitch = intelScreen->front.pitch; /* in bytes */
-        int i;
-        GLuint CMD, BR13;
-        BATCH_LOCALS;
-
-        switch(cpp) {
-        case 2: 
-           BR13 = (pitch) | (0xCC << 16) | (1<<24);
-           CMD = XY_SRC_COPY_BLT_CMD;
-           break;
-        case 4:
-           BR13 = (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:
-           BR13 = (pitch) | (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) {
-              _mesa_warning(&intel->ctx, "Bad cliprect in intelCopyBuffer()");
-              continue;
-           }
-
-           box = *pbox;
-
-           if (rect)
-           {
-              if (rect->x1 > box.x1)
-                 box.x1 = rect->x1;
-              if (rect->y1 > box.y1)
-                 box.y1 = rect->y1;
-              if (rect->x2 < box.x2)
-                 box.x2 = rect->x2;
-              if (rect->y2 < box.y2)
-                 box.y2 = rect->y2;
-
-              if (box.x1 > box.x2 || box.y1 > box.y2)
-                 continue;
-           }
-
-           BEGIN_BATCH( 8);
-           OUT_BATCH( CMD );
-           OUT_BATCH( BR13 );
-           OUT_BATCH( (box.y1 << 16) | box.x1 );
-           OUT_BATCH( (box.y2 << 16) | box.x2 );
-
-           if (intel->sarea->pf_current_page == 0) 
-              OUT_BATCH( intelScreen->front.offset );
-           else
-              OUT_BATCH( intelScreen->back.offset );                   
-
-           OUT_BATCH( (box.y1 << 16) | box.x1 );
-           OUT_BATCH( BR13 & 0xffff );
-
-           if (intel->sarea->pf_current_page == 0) 
-              OUT_BATCH( intelScreen->back.offset );                   
-           else
-              OUT_BATCH( intelScreen->front.offset );
-
-           ADVANCE_BATCH();
-        }
-      }
-      intelFlushBatchLocked( intel, GL_TRUE, GL_TRUE, GL_TRUE );
-      UNLOCK_HARDWARE( intel );
-   }
-
-   if (!rect)
-   {
-       intel->swap_count++;
-       (*dri_interface->getUST)(&ust);
-       if (missed_target) {
-          intel->swap_missed_count++;
-          intel->swap_missed_ust = ust -  intel->swap_ust;
-       }
-   
-       intel->swap_ust = ust;
-   }
-}
-
-
-
-
-void intelEmitFillBlitLocked( intelContextPtr intel,
-                             GLuint cpp,
-                             GLshort dst_pitch,  /* in bytes */
-                             GLuint dst_offset,
-                             GLshort x, GLshort y, 
-                             GLshort w, GLshort h,
-                             GLuint color )
-{
-   GLuint BR13, CMD;
-   BATCH_LOCALS;
-
-   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 buffers, GLboolean allFoo,
-                        GLint cx1Foo, GLint cy1Foo, GLint cwFoo, GLint chFoo)
-{
-   intelContextPtr intel = INTEL_CONTEXT( ctx );
-   intelScreenPrivate *intelScreen = intel->intelScreen;
-   GLuint clear_depth, clear_color;
-   GLint cx, cy, cw, ch;
-   GLboolean all;
-   GLint pitch;
-   GLint cpp = intelScreen->cpp;
-   GLint i;
-   GLuint BR13, CMD, D_CMD;
-   BATCH_LOCALS;
-
-   intelFlush( &intel->ctx );
-   LOCK_HARDWARE( intel );
-
-   /* get clear bounds after locking */
-   cx = intel->ctx.DrawBuffer->_Xmin;
-   cy = intel->ctx.DrawBuffer->_Ymin;
-   cw = intel->ctx.DrawBuffer->_Xmax - cx;
-   ch = intel->ctx.DrawBuffer->_Ymax - cy;
-   all = (cw == intel->ctx.DrawBuffer->Width &&
-          ch == intel->ctx.DrawBuffer->Height);
-
-   pitch = intelScreen->front.pitch;
-
-   clear_color = intel->ClearColor;
-   clear_depth = 0;
-
-   if (buffers & BUFFER_BIT_DEPTH) {
-      clear_depth = (GLuint)(ctx->Depth.Clear * intel->ClearDepth);
-   }
-
-   if (buffers & BUFFER_BIT_STENCIL) {
-      clear_depth |= (ctx->Stencil.Clear & 0xff) << 24;
-   }
-
-   switch(cpp) {
-   case 2: 
-      BR13 = (0xF0 << 16) | (pitch) | (1<<24);
-      D_CMD = CMD = XY_COLOR_BLT_CMD;
-      break;
-   case 4:
-      BR13 = (0xF0 << 16) | (pitch) | (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 (buffers & BUFFER_BIT_DEPTH) D_CMD |= XY_COLOR_BLT_WRITE_RGB;
-      if (buffers & BUFFER_BIT_STENCIL) D_CMD |= XY_COLOR_BLT_WRITE_ALPHA;
-      break;
-   default:
-      BR13 = (0xF0 << 16) | (pitch) | (1<<24);
-      D_CMD = CMD = XY_COLOR_BLT_CMD;
-      break;
-   }
-
-   {
-      /* flip top to bottom */
-      cy = intel->driDrawable->h - cy - ch;
-      cx = cx + intel->drawX;
-      cy += intel->drawY;
-
-      /* adjust for page flipping */
-      if ( intel->sarea->pf_current_page == 1 ) {
-        GLuint tmp = buffers;
-
-        buffers &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT);
-        if ( tmp & BUFFER_BIT_FRONT_LEFT ) buffers |= BUFFER_BIT_BACK_LEFT;
-        if ( tmp & BUFFER_BIT_BACK_LEFT )  buffers |= 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->x1;
-           GLint y = box->y1;
-           GLint w = box->x2 - x;
-           GLint h = box->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 ( buffers & 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->front.offset );
-           OUT_BATCH( clear_color );
-           ADVANCE_BATCH();
-        }
-
-        if ( buffers & 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->back.offset );
-           OUT_BATCH( clear_color );
-           ADVANCE_BATCH();
-        }
-
-        if ( buffers & (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->depth.offset );
-           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.offset) {
-      intelFreeAGP( intel, intel->alloc.ptr );
-      intel->alloc.ptr = NULL;
-      intel->alloc.offset = 0;
-   }
-   else if (intel->alloc.ptr) {
-      free(intel->alloc.ptr);
-      intel->alloc.ptr = NULL;
-   }
-
-   memset(&intel->batch, 0, sizeof(intel->batch));
-}
-
-
-void intelInitBatchBuffer( GLcontext *ctx )
-{
-   intelContextPtr intel = INTEL_CONTEXT(ctx);
-
-   /* This path isn't really safe with rotate:
-    */
-   if (getenv("INTEL_BATCH") && intel->intelScreen->allow_batchbuffer) {      
-      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 );
-      else
-         intel->alloc.offset = 0; /* OK? */
-   }
-
-   /* The default is now to use a local buffer and pass that to the
-    * kernel.  This is also a fallback if allocation fails on the
-    * above path:
-    */
-   if (!intel->alloc.ptr) {
-      intel->alloc.size = 8 * 1024;
-      intel->alloc.ptr = malloc( intel->alloc.size );
-      intel->alloc.offset = 0;
-   }
-
-   assert(intel->alloc.ptr);
-}
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..d38cdf31cc6c2d95a6f2970a9bbba75736bf2e3c
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_batchbuffer.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i915/intel_batchbuffer.h b/src/mesa/drivers/dri/i915/intel_batchbuffer.h
deleted file mode 100644 (file)
index 577d071..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-/**************************************************************************
- * 
- * 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(%ld) in %s, %d dwords free\n",     \
-                       ((unsigned long)n), __FUNCTION__,               \
-                       intel->batch.space/4);                          \
-   if (intel->batch.space < (n)*4)                                     \
-      intelFlushBatch(intel, GL_TRUE);                                 \
-   if (intel->batch.space == intel->batch.size)        intel->batch.func = __FUNCTION__;                       \
-   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,
-                            const drm_clip_rect_t      *rect);
-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/src/mesa/drivers/dri/i915/intel_blit.c b/src/mesa/drivers/dri/i915/intel_blit.c
new file mode 120000 (symlink)
index 0000000..dd6c8d1
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_blit.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i915/intel_buffer_objects.c b/src/mesa/drivers/dri/i915/intel_buffer_objects.c
new file mode 120000 (symlink)
index 0000000..e06dd3c
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_buffer_objects.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i915/intel_buffers.c b/src/mesa/drivers/dri/i915/intel_buffers.c
new file mode 120000 (symlink)
index 0000000..c86daa4
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_buffers.c
\ No newline at end of file
deleted file mode 100644 (file)
index 11c23f24a1b8538d1c496f3b3223b35165605d89..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,776 +0,0 @@
-/**************************************************************************
- * 
- * 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 "points.h"
-
-#include "swrast/swrast.h"
-#include "swrast_setup/swrast_setup.h"
-#include "tnl/tnl.h"
-#include "vbo/vbo.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 "vblank.h"
-#include "utils.h"
-#include "xmlpool.h" /* for symbolic values of enum-type options */
-#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 "20061017"
-
-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;
-      case PCI_CHIP_I945_GM:
-        chipset = "Intel(R) 945GM"; break;
-      case PCI_CHIP_I945_GME:
-        chipset = "Intel(R) 945GME"; break;
-      case PCI_CHIP_G33_G:
-        chipset = "Intel(R) G33"; break;
-      case PCI_CHIP_Q35_G:
-        chipset = "Intel(R) Q35"; break;
-      case PCI_CHIP_Q33_G:
-        chipset = "Intel(R) Q33"; break;
-      default:
-        chipset = "Unknown Intel Chipset"; break;
-      }
-
-      (void) driGetRendererString( buffer, chipset, DRIVER_DATE, 0 );
-      return (GLubyte *) buffer;
-
-   default:
-      return NULL;
-   }
-}
-
-
-/**
- * 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_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 );
-   _vbo_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->Clear = intelClear;
-   functions->Flush = intelglFlush;
-   functions->Finish = intelFinish;
-   functions->GetString = intelGetString;
-   functions->UpdateState = intelInvalidateState;
-
-   intelInitTextureFuncs( functions );
-   intelInitPixelFuncs( functions );
-   intelInitStateFuncs( functions );
-}
-
-static void intel_emit_invarient_state( GLcontext *ctx )
-{
-}
-
-
-
-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);
-   int fthrottle_mode;
-
-   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 );
-
-   driParseConfigFiles (&intel->optionCache, &intelScreen->optionCache,
-                       intel->driScreen->myNum, "i915");
-
-   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;
-
-   /* reinitialize the context point state.
-    * It depend on constants in __GLcontextRec::Const
-    */
-   _mesa_init_point(ctx);
-
-   /* Initialize the software rasterizer and helper modules. */
-   _swrast_CreateContext( ctx );
-   _vbo_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;
-
-   fthrottle_mode = driQueryOptioni(&intel->optionCache, "fthrottle_mode");
-   intel->iw.irq_seq = -1;
-   intel->irqsEmitted = 0;
-
-   intel->do_irqs = (intel->intelScreen->irq_active &&
-                    fthrottle_mode == DRI_CONF_FTHROTTLE_IRQS);
-
-   intel->do_usleeps = (fthrottle_mode == DRI_CONF_FTHROTTLE_USLEEPS);
-
-   intel->vblank_flags = (intel->intelScreen->irq_active != 0)
-       ? driGetDefaultVBlankFlags(&intel->optionCache) : VBLANK_FLAG_NO_IRQ;
-
-   (*dri_interface->getUST)(&intel->swap_ust);
-   _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 (&intel->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 ); */
-
-
-   intelInitBatchBuffer(&intel->ctx);
-   intel->prim.flush = intel_emit_invarient_state;
-   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_FIREVERTICES( intel );
-
-      intel->vtbl.destroy( intel );
-
-      release_texture_heaps = (intel->ctx.Shared->RefCount == 1);
-      _swsetup_DestroyContext (&intel->ctx);
-      _tnl_DestroyContext (&intel->ctx);
-      _vbo_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 )
-{
-   __DRIdrawablePrivate *dPriv = intel->driDrawable;
-   GLframebuffer *drawFb = (GLframebuffer *) dPriv->driverPrivate;
-
-   if (!intel->ctx.DrawBuffer) {
-      intelSetFrontClipRects( intel );
-   }
-   else {
-      driUpdateFramebufferSize(&intel->ctx, dPriv);
-      switch (drawFb->_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 );
-      }
-   }
-
-   if (drawFb->Width != dPriv->w || drawFb->Height != dPriv->h) {
-      /* update Mesa's notion of framebuffer/window size */
-      _mesa_resize_framebuffer(&intel->ctx, drawFb, dPriv->w, dPriv->h);
-      drawFb->Initialized = GL_TRUE; /* XXX remove someday */
-   }
-
-   /* Set state we know depends on drawable parameters:
-    */
-   {
-      GLcontext *ctx = &intel->ctx;
-
-      if (intel->intelScreen->driScrnPriv->ddxMinor >= 7) {
-        drmI830Sarea *sarea = intel->sarea;
-        drm_clip_rect_t drw_rect = { .x1 = dPriv->x, .x2 = dPriv->x + dPriv->w,
-                                     .y1 = dPriv->y, .y2 = dPriv->y + dPriv->h };
-        drm_clip_rect_t pipeA_rect = { .x1 = sarea->pipeA_x,
-                                       .x2 = sarea->pipeA_x + sarea->pipeA_w,
-                                       .y1 = sarea->pipeA_y,
-                                       .y2 = sarea->pipeA_y + sarea->pipeA_h };
-        drm_clip_rect_t pipeB_rect = { .x1 = sarea->pipeB_x,
-                                       .x2 = sarea->pipeB_x + sarea->pipeB_w,
-                                       .y1 = sarea->pipeB_y,
-                                       .y2 = sarea->pipeB_y + sarea->pipeB_h };
-        GLint areaA = driIntersectArea( drw_rect, pipeA_rect );
-        GLint areaB = driIntersectArea( drw_rect, pipeB_rect );
-        GLuint flags = intel->vblank_flags;
-
-        if (areaB > areaA || (areaA == areaB && areaB > 0)) {
-           flags = intel->vblank_flags | VBLANK_FLAG_SECONDARY;
-        } else {
-           flags = intel->vblank_flags & ~VBLANK_FLAG_SECONDARY;
-        }
-
-        if (flags != intel->vblank_flags) {
-           intel->vblank_flags = flags;
-           driGetCurrentVBlank(dPriv, intel->vblank_flags, &intel->vbl_seq);
-        }
-      } else {
-        intel->vblank_flags &= ~VBLANK_FLAG_SECONDARY;
-      }
-
-      ctx->Driver.Scissor( ctx, ctx->Scissor.X, ctx->Scissor.Y,
-                          ctx->Scissor.Width, ctx->Scissor.Height );
-      
-      ctx->Driver.DepthRange( ctx, 
-                             ctx->Viewport.Near,
-                             ctx->Viewport.Far );
-   }
-}
-
-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? */
-        driDrawableInitVBlank( driDrawPriv, intel->vblank_flags,
-                               &intel->vbl_seq );
-
-        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;
-}
-
-/**
- * Use the information in the sarea to update the screen parameters
- * related to screen rotation.
- */
-static void
-intelUpdateScreenRotation(intelContextPtr intel,
-                          __DRIscreenPrivate *sPriv,
-                          drmI830Sarea *sarea)
-{
-   intelScreenPrivate *intelScreen = (intelScreenPrivate *)sPriv->private;
-   intelRegion *colorBuf;
-
-   intelUnmapScreenRegions(intelScreen);
-
-   intelUpdateScreenFromSAREA(intelScreen, sarea);
-
-   /* update the current hw offsets for the color and depth buffers */
-   if (intel->ctx.DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT)
-      colorBuf = &intelScreen->back;
-   else
-      colorBuf = &intelScreen->front;
-   intel->vtbl.update_color_z_regions(intel, colorBuf, &intelScreen->depth);
-
-   if (!intelMapScreenRegions(sPriv)) {
-      fprintf(stderr, "ERROR Remapping screen regions!!!\n");
-   }
-}
-
-void intelGetLock( intelContextPtr intel, GLuint flags )
-{
-   __DRIdrawablePrivate *dPriv = intel->driDrawable;
-   __DRIscreenPrivate *sPriv = intel->driScreen;
-   intelScreenPrivate *intelScreen = (intelScreenPrivate *)sPriv->private;
-   drmI830Sarea * sarea = intel->sarea;
-   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 (dPriv && intel->lastStamp != dPriv->lastStamp) {
-      intelWindowMoved( intel );
-      intel->lastStamp = dPriv->lastStamp;
-   }
-
-   /* 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->width != intelScreen->width ||
-       sarea->height != intelScreen->height ||
-       sarea->rotation != intelScreen->current_rotation) {
-      intelUpdateScreenRotation(intel, sPriv, sarea);
-
-      /* This will drop the outstanding batchbuffer on the floor */
-      intel->batch.ptr -= (intel->batch.size - intel->batch.space);
-      intel->batch.space = intel->batch.size;
-      /* lose all primitives */
-      intel->prim.primitive = ~0;
-      intel->prim.start_ptr = 0;
-      intel->prim.flush = 0;
-      intel->vtbl.lost_hardware( intel ); 
-
-      intel->lastStamp = 0; /* force window update */
-
-      /* Release batch buffer
-       */
-      intelDestroyBatchBuffer(&intel->ctx);
-      intelInitBatchBuffer(&intel->ctx);
-      intel->prim.flush = intel_emit_invarient_state;
-
-      /* Still need to reset the global LRU?
-       */
-      intel_driReinitTextureHeap( intel->texture_heaps[0], intel->intelScreen->tex.size );
-   }
-
-   /* 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 ] );
-   }
-}
-
-
-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) {
-         intelScreenPrivate *screen = intel->intelScreen;
-        _mesa_notifySwapBuffers( ctx );  /* flush pending rendering comands */
-        if ( 0 /*intel->doPageFlip*/ ) { /* doPageFlip is never set !!! */
-           intelPageFlip( dPriv );
-        } else {
-            intelCopyBuffer( dPriv, NULL );
-        }
-         if (screen->current_rotation != 0) {
-            intelRotateWindow(intel, dPriv, BUFFER_BIT_FRONT_LEFT);
-         }
-      }
-   } 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 intelCopySubBuffer( __DRIdrawablePrivate *dPriv,
-                        int x, int y, int w, int h )
-{
-   if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
-      intelContextPtr intel;
-      GLcontext *ctx;
-      intel = (intelContextPtr) dPriv->driContextPriv->driverPrivate;
-      ctx = &intel->ctx;
-      if (ctx->Visual.doubleBufferMode) {
-        drm_clip_rect_t rect;
-        rect.x1 = x + dPriv->x;
-        rect.y1 = (dPriv->h - y - h) + dPriv->y;
-        rect.x2 = rect.x1 + w;
-        rect.y2 = rect.y1 + h;
-        _mesa_notifySwapBuffers( ctx );  /* flush pending rendering comands */
-        intelCopyBuffer( dPriv, &rect );
-      }
-   } 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__);
-   }
-}
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..27a1cbb255e69228f67acb1a50cb0f51622074ca
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_context.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i915/intel_context.h b/src/mesa/drivers/dri/i915/intel_context.h
deleted file mode 100644 (file)
index 3b50107..0000000
+++ /dev/null
@@ -1,563 +0,0 @@
-/**************************************************************************
- * 
- * 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 "vblank.h"
-
-#include "intel_screen.h"
-#include "i915_drm.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 (*lost_hardware)( intelContextPtr intel );
-      void (*update_texture_state)( intelContextPtr intel );
-
-      void (*render_start)( intelContextPtr intel );
-      void (*set_color_region)( intelContextPtr intel, const intelRegion *reg );
-      void (*set_z_region)( intelContextPtr intel, const intelRegion *reg );
-      void (*update_color_z_regions)(intelContextPtr intel,
-                                     const intelRegion *colorRegion,
-                                     const intelRegion *depthRegion);
-      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);
-
-      void (*rotate_window)( intelContextPtr intel,
-                             __DRIdrawablePrivate *dPriv, GLuint srcBuf);
-
-      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;
-      GLuint counter;
-      GLuint last_emit_state;
-      GLboolean contains_geometry;
-      const char *func;
-      GLuint last_swap;
-   } 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;
-   unsigned 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;
-
-   /* Drawing buffer state
-    */
-   intelRegion *drawRegion;  /* current drawing buffer */
-   intelRegion *readRegion;  /* current reading buffer */
-
-   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;
-
-   GLuint do_usleeps;
-   int do_irqs;
-   GLuint irqsEmitted;
-   drm_i915_irq_wait_t iw;
-
-   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;
-
-   /* VBI
-    */
-   GLuint vbl_seq;
-   GLuint vblank_flags;
-
-   int64_t swap_ust;
-   int64_t swap_missed_ust;
-
-   GLuint swap_count;
-   GLuint swap_missed_count;
-
-   GLuint swap_scheduled;
-};
-
-
-#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);                          \
-    if ((intel)->swap_scheduled) {                     \
-        drmVBlank vbl;                                 \
-        vbl.request.type = DRM_VBLANK_ABSOLUTE;                \
-        if ((intel)->vblank_flags &                    \
-            VBLANK_FLAG_SECONDARY) {                   \
-            vbl.request.type |= DRM_VBLANK_SECONDARY;  \
-        }                                              \
-        vbl.request.sequence = (intel)->vbl_seq;       \
-        drmWaitVBlank((intel)->driFd, &vbl);           \
-        (intel)->swap_scheduled = 0;                   \
-    }                                                  \
-    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
-#define PCI_CHIP_I945_GM               0x27A2
-#define PCI_CHIP_I945_GME              0x27AE
-#define PCI_CHIP_G33_G                 0x29C2
-#define PCI_CHIP_Q35_G                 0x29B2
-#define PCI_CHIP_Q33_G                 0x29D2
-
-
-/* ================================================================
- * 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 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/src/mesa/drivers/dri/i915/intel_decode.c b/src/mesa/drivers/dri/i915/intel_decode.c
new file mode 120000 (symlink)
index 0000000..f671b6c
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_decode.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i915/intel_depthstencil.c b/src/mesa/drivers/dri/i915/intel_depthstencil.c
new file mode 120000 (symlink)
index 0000000..4ac4ae6
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_depthstencil.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i915/intel_fbo.c b/src/mesa/drivers/dri/i915/intel_fbo.c
new file mode 120000 (symlink)
index 0000000..a19f86d
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_fbo.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i915/intel_ioctl.c b/src/mesa/drivers/dri/i915/intel_ioctl.c
deleted file mode 100644 (file)
index aa7c6d1..0000000
+++ /dev/null
@@ -1,659 +0,0 @@
-/**************************************************************************
- * 
- * 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"
-
-uint32_t intelGetLastFrame (intelContextPtr intel) 
-{
-   int ret;
-   uint32_t frame;
-   drm_i915_getparam_t gp;
-   
-   gp.param = I915_PARAM_LAST_DISPATCH;
-   gp.value = (int *)&frame;
-   ret = drmCommandWriteRead( intel->driFd, DRM_I915_GETPARAM,
-                             &gp, sizeof(gp) );
-   return frame;
-}
-
-int intelEmitIrqLocked( intelContextPtr intel )
-{
-   drmI830IrqEmit ie;
-   int ret, seq;
-      
-   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;
-}
-
-void intelWaitIrq( intelContextPtr intel, int seq )
-{
-   int ret;
-      
-   if (0)
-      fprintf(stderr, "%s %d\n", __FUNCTION__, seq );
-
-   intel->iw.irq_seq = seq;
-        
-   do {
-     ret = drmCommandWrite( intel->driFd, DRM_I830_IRQ_WAIT, &intel->iw, sizeof(intel->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%x: 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 = (unsigned 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 (started in %s)\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,
-             intel->batch.func);
-
-   /* 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) {
-
-      if (intel->sarea->ctxOwner != intel->hHWContext) {
-        intel->perf_boxes |= I830_BOX_LOST_CONTEXT;
-        intel->sarea->ctxOwner = intel->hHWContext;
-      }
-
-      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 );
-
-      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 = (char *)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.
-       */
-      if (intel->batch.contains_geometry) 
-        assert(intel->batch.last_emit_state == intel->batch.counter);
-
-      intel->batch.counter++;
-      intel->batch.contains_geometry = 0;
-      intel->batch.func = 0;
-      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;
-}
-
-
-/**
- * Check if we need to rotate/warp the front color buffer to the
- * rotated screen.  We generally need to do this when we get a glFlush
- * or glFinish after drawing to the front color buffer.
- */
-static void
-intelCheckFrontRotate(GLcontext *ctx)
-{
-   intelContextPtr intel = INTEL_CONTEXT( ctx );
-   if (intel->ctx.DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT) {
-      intelScreenPrivate *screen = intel->intelScreen;
-      if (screen->current_rotation != 0) {
-         __DRIdrawablePrivate *dPriv = intel->driDrawable;
-         intelRotateWindow(intel, dPriv, BUFFER_BIT_FRONT_LEFT);
-      }
-   }
-}
-
-
-/**
- * NOT directly called via glFlush.
- */
-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 );
-}
-
-
-/**
- * Called via glFlush.
- */
-void intelglFlush( GLcontext *ctx )
-{
-   intelFlush(ctx);
-   intelCheckFrontRotate(ctx);
-}
-
-
-void intelFinish( GLcontext *ctx  ) 
-{
-   intelContextPtr intel = INTEL_CONTEXT( ctx );
-   intelFlush( ctx );
-   intelWaitForIdle( intel );
-   intelCheckFrontRotate(ctx);
-}
-
-
-void intelClear(GLcontext *ctx, GLbitfield mask)
-{
-   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) != 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, 0, 0, 0, 0, 0);
-
-   if (tri_mask) 
-      intel->vtbl.clear_with_tris( intel, tri_mask, 0, 0, 0, 0, 0);
-
-   if (swrast_mask)
-      _swrast_Clear( ctx, swrast_mask );
-}
-
-
-void
-intelRotateWindow(intelContextPtr intel, __DRIdrawablePrivate *dPriv,
-                  GLuint srcBuffer)
-{
-   if (intel->vtbl.rotate_window) {
-      intel->vtbl.rotate_window(intel, dPriv, srcBuffer);
-   }
-}
-
-
-void *intelAllocateAGP( intelContextPtr intel, GLsizei size )
-{
-   int region_offset;
-   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->tex.offset + 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/src/mesa/drivers/dri/i915/intel_mipmap_tree.c b/src/mesa/drivers/dri/i915/intel_mipmap_tree.c
new file mode 120000 (symlink)
index 0000000..242fed0
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_mipmap_tree.c
\ No newline at end of file
deleted file mode 100644 (file)
index c3030d42b04801944f3124c1eaf87d0d80715b62..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,524 +0,0 @@
-/**************************************************************************
- * 
- * 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->Current.RasterPosValid);
-   
-   return result;
-}
-
-
-/**
- * Clip the given rectangle against the buffer's bounds (including scissor).
- * \param size returns the 
- * \return GL_TRUE if any pixels remain, GL_FALSE if totally clipped.
- *
- * XXX Replace this with _mesa_clip_drawpixels() and _mesa_clip_readpixels()
- * from Mesa 6.4.  We shouldn't apply scissor for ReadPixels.
- */
-static GLboolean
-clip_pixelrect( const GLcontext *ctx,
-               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;
-}
-
-
-/**
- * Compute intersection of a clipping rectangle and pixel rectangle,
- * returning results in x/y/w/hOut vars.
- * \return GL_TRUE if there's intersection, GL_FALSE if disjoint.
- */
-static INLINE GLboolean
-intersect_region(const drm_clip_rect_t *box,
-                GLint x, GLint y, GLsizei width, GLsizei height,
-                GLint *xOut, GLint *yOut, GLint *wOut, GLint *hOut)
-{
-   GLint bx = box->x1;
-   GLint by = box->y1;
-   GLint bw = box->x2 - bx;
-   GLint bh = box->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;
-
-   *xOut = bx;
-   *yOut = by;
-   *wOut = bw;
-   *hOut = bh;
-
-   if (bw <= 0) return GL_FALSE;
-   if (bh <= 0) return GL_FALSE;
-
-   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; /* not really used */
-   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 drawing offset 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->readRegion->offset;
-      int src_pitch = intel->intelScreen->front.pitch;
-      int dst_offset = intelAgpOffsetFromVirtual( intel, pixels);
-      drm_clip_rect_t *box = dPriv->pClipRects;
-      int i;
-
-      assert(dst_offset != ~0);  /* should have been caught above */
-
-      if (!clip_pixelrect(ctx, ctx->ReadBuffer, &x, &y, &width, &height)) {
-        UNLOCK_HARDWARE( intel );
-        if (INTEL_DEBUG & DEBUG_PIXEL)
-           fprintf(stderr, "%s totally clipped -- nothing to do\n",
-                   __FUNCTION__);
-        return GL_TRUE;
-      }
-
-      /* convert to screen coords (y=0=top) */
-      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);
-
-      /* We don't really have to do window clipping for readpixels.
-       * The OpenGL spec says that pixels read from outside the
-       * visible window region (pixel ownership) have undefined value.
-       */
-      for (i = 0 ; i < nbox ; i++)
-      {
-         GLint bx, by, bw, bh;
-         if (intersect_region(box+i, x, y, width, height,
-                              &bx, &by, &bw, &bh)) {
-            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 src_offset = intelAgpOffsetFromVirtual( intel, pixels);
-   int src_pitch = pitch;
-
-   assert(src_offset != ~0);  /* should be caught earlier */
-
-   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)) {
-        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, by, bw, bh;
-        if (intersect_region(box + i, x, y, width, height,
-                             &bx, &by, &bw, &bh)) {
-            intelEmitCopyBlitLocked( intel,
-                                     intel->intelScreen->cpp,
-                                     src_pitch, src_offset,
-                                     intel->intelScreen->front.pitch,
-                                     intel->drawRegion->offset,
-                                     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->drawRegion->offset;
-
-      /* 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;
-
-   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 ))
-      return;
-
-   if (ctx->FragmentProgram._Current == ctx->FragmentProgram._TexEnvProgram) {
-      /*
-       * We don't want the i915 texenv program to be applied to DrawPixels.
-       * This is really just a performance optimization (mesa will other-
-       * wise happily run the fragment program on each pixel in the image).
-       */
-      struct gl_fragment_program *fpSave = ctx->FragmentProgram._Current;
-   /* can't just set current frag prog to 0 here as on buffer resize
-      we'll get new state checks which will segfault. Remains a hack. */
-      ctx->FragmentProgram._Current = NULL;
-      ctx->FragmentProgram._UseTexEnvProgram = GL_FALSE;
-      ctx->FragmentProgram._Active = GL_FALSE;
-      _swrast_DrawPixels( ctx, x, y, width, height, format, type,
-                          unpack, pixels );
-      ctx->FragmentProgram._Current = fpSave;
-      ctx->FragmentProgram._UseTexEnvProgram = GL_TRUE;
-      ctx->FragmentProgram._Active = GL_TRUE;
-   }
-   else {
-      _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 )
-{
-   functions->CopyPixels = intelCopyPixels;
-   if (!getenv("INTEL_NO_BLITS")) {
-      functions->ReadPixels = intelReadPixels;  
-      functions->DrawPixels = intelDrawPixels; 
-   }
-}
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..d733c5e874563faf2be92dc96255261d0b3efc6d
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_pixel.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i915/intel_pixel_bitmap.c b/src/mesa/drivers/dri/i915/intel_pixel_bitmap.c
new file mode 120000 (symlink)
index 0000000..9085c7b
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_pixel_bitmap.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i915/intel_pixel_copy.c b/src/mesa/drivers/dri/i915/intel_pixel_copy.c
new file mode 120000 (symlink)
index 0000000..ee43360
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_pixel_copy.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i915/intel_pixel_draw.c b/src/mesa/drivers/dri/i915/intel_pixel_draw.c
new file mode 120000 (symlink)
index 0000000..8431a24
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_pixel_draw.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i915/intel_pixel_read.c b/src/mesa/drivers/dri/i915/intel_pixel_read.c
new file mode 100644 (file)
index 0000000..120c887
--- /dev/null
@@ -0,0 +1,306 @@
+/**************************************************************************
+ * 
+ * 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 "image.h"
+#include "bufferobj.h"
+#include "swrast/swrast.h"
+
+#include "intel_screen.h"
+#include "intel_context.h"
+#include "intel_batchbuffer.h"
+#include "intel_blit.h"
+#include "intel_buffers.h"
+#include "intel_regions.h"
+#include "intel_pixel.h"
+#include "intel_buffer_objects.h"
+
+/* For many applications, the new ability to pull the source buffers
+ * back out of the GTT and then do the packing/conversion operations
+ * in software will be as much of an improvement as trying to get the
+ * blitter and/or texture engine to do the work. 
+ *
+ * This step is gated on private backbuffers.
+ * 
+ * Obviously the frontbuffer can't be pulled back, so that is either
+ * an argument for blit/texture readpixels, or for blitting to a
+ * temporary and then pulling that back.
+ *
+ * When the destination is a pbo, however, it's not clear if it is
+ * ever going to be pulled to main memory (though the access param
+ * will be a good hint).  So it sounds like we do want to be able to
+ * choose between blit/texture implementation on the gpu and pullback
+ * and cpu-based copying.
+ *
+ * Unless you can magically turn client memory into a PBO for the
+ * duration of this call, there will be a cpu-based copying step in
+ * any case.
+ */
+
+
+static GLboolean
+do_texture_readpixels(GLcontext * ctx,
+                      GLint x, GLint y, GLsizei width, GLsizei height,
+                      GLenum format, GLenum type,
+                      const struct gl_pixelstore_attrib *pack,
+                      struct intel_region *dest_region)
+{
+#if 0
+   struct intel_context *intel = intel_context(ctx);
+   intelScreenPrivate *screen = intel->intelScreen;
+   GLint pitch = pack->RowLength ? pack->RowLength : width;
+   __DRIdrawablePrivate *dPriv = intel->driDrawable;
+   int textureFormat;
+   GLenum glTextureFormat;
+   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) {
+      if (INTEL_DEBUG & DEBUG_PIXEL)
+         fprintf(stderr, "%s: check_color failed\n", __FUNCTION__);
+      return GL_FALSE;
+   }
+
+   intel->vtbl.meta_texrect_source(intel, intel_readbuf_region(intel));
+
+   if (!intel->vtbl.meta_render_dest(intel, dest_region, type, format)) {
+      if (INTEL_DEBUG & DEBUG_PIXEL)
+         fprintf(stderr, "%s: couldn't set dest %s/%s\n",
+                 __FUNCTION__,
+                 _mesa_lookup_enum_by_nr(type),
+                 _mesa_lookup_enum_by_nr(format));
+      return GL_FALSE;
+   }
+
+   LOCK_HARDWARE(intel);
+
+   if (intel->driDrawable->numClipRects) {
+      intel->vtbl.install_meta_state(intel);
+      intel->vtbl.meta_no_depth_write(intel);
+      intel->vtbl.meta_no_stencil_write(intel);
+
+      if (!driClipRectToFramebuffer(ctx->ReadBuffer, &x, &y, &width, &height)) {
+         UNLOCK_HARDWARE(intel);
+         SET_STATE(i830, state);
+         if (INTEL_DEBUG & DEBUG_PIXEL)
+            fprintf(stderr, "%s: cliprect failed\n", __FUNCTION__);
+         return GL_TRUE;
+      }
+
+      y = dPriv->h - y - height;
+      x += dPriv->x;
+      y += dPriv->y;
+
+
+      /* Set the frontbuffer up as a large rectangular texture.
+       */
+      intel->vtbl.meta_tex_rect_source(intel, src_region, textureFormat);
+
+
+      intel->vtbl.meta_texture_blend_replace(i830, glTextureFormat);
+
+
+      /* Set the 3d engine to draw into the destination region:
+       */
+
+      intel->vtbl.meta_draw_region(intel, dest_region);
+      intel->vtbl.meta_draw_format(intel, destFormat, depthFormat);     /* ?? */
+
+
+      /* Draw a single quad, no cliprects:
+       */
+      intel->vtbl.meta_disable_cliprects(intel);
+
+      intel->vtbl.draw_quad(intel,
+                            0, width, 0, height,
+                            0x00ff00ff, x, x + width, y, y + height);
+
+      intel->vtbl.leave_meta_state(intel);
+   }
+   UNLOCK_HARDWARE(intel);
+
+   intel_region_wait_fence(ctx, dest_region);   /* required by GL */
+   return GL_TRUE;
+#endif
+
+   return GL_FALSE;
+}
+
+
+
+
+static GLboolean
+do_blit_readpixels(GLcontext * ctx,
+                   GLint x, GLint y, GLsizei width, GLsizei height,
+                   GLenum format, GLenum type,
+                   const struct gl_pixelstore_attrib *pack, GLvoid * pixels)
+{
+   struct intel_context *intel = intel_context(ctx);
+   struct intel_region *src = intel_readbuf_region(intel);
+   struct intel_buffer_object *dst = intel_buffer_object(pack->BufferObj);
+   GLuint dst_offset;
+   GLuint rowLength;
+
+   if (INTEL_DEBUG & DEBUG_PIXEL)
+      _mesa_printf("%s\n", __FUNCTION__);
+
+   if (!src)
+      return GL_FALSE;
+
+   if (dst) {
+      /* XXX This validation should be done by core mesa:
+       */
+      if (!_mesa_validate_pbo_access(2, pack, width, height, 1,
+                                     format, type, pixels)) {
+         _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels");
+         return GL_TRUE;
+      }
+   }
+   else {
+      /* PBO only for now:
+       */
+      if (INTEL_DEBUG & DEBUG_PIXEL)
+         _mesa_printf("%s - not PBO\n", __FUNCTION__);
+      return GL_FALSE;
+   }
+
+
+   if (ctx->_ImageTransferState ||
+       !intel_check_blit_format(src, format, type)) {
+      if (INTEL_DEBUG & DEBUG_PIXEL)
+         _mesa_printf("%s - bad format for blit\n", __FUNCTION__);
+      return GL_FALSE;
+   }
+
+   if (pack->Alignment != 1 || pack->SwapBytes || pack->LsbFirst) {
+      if (INTEL_DEBUG & DEBUG_PIXEL)
+         _mesa_printf("%s: bad packing params\n", __FUNCTION__);
+      return GL_FALSE;
+   }
+
+   if (pack->RowLength > 0)
+      rowLength = pack->RowLength;
+   else
+      rowLength = width;
+
+   if (pack->Invert) {
+      if (INTEL_DEBUG & DEBUG_PIXEL)
+         _mesa_printf("%s: MESA_PACK_INVERT not done yet\n", __FUNCTION__);
+      return GL_FALSE;
+   }
+   else {
+      rowLength = -rowLength;
+   }
+
+   /* XXX 64-bit cast? */
+   dst_offset = (GLuint) _mesa_image_address(2, pack, pixels, width, height,
+                                             format, type, 0, 0, 0);
+
+
+   /* Although the blits go on the command buffer, need to do this and
+    * fire with lock held to guarentee cliprects are correct.
+    */
+   intelFlush(&intel->ctx);
+   LOCK_HARDWARE(intel);
+
+   if (intel->driDrawable->numClipRects) {
+      GLboolean all = (width * height * src->cpp == dst->Base.Size &&
+                       x == 0 && dst_offset == 0);
+
+      dri_bo *dst_buffer = intel_bufferobj_buffer(intel, dst,
+                                                 all ? INTEL_WRITE_FULL :
+                                                 INTEL_WRITE_PART);
+      __DRIdrawablePrivate *dPriv = intel->driDrawable;
+      int nbox = dPriv->numClipRects;
+      drm_clip_rect_t *box = dPriv->pClipRects;
+      drm_clip_rect_t rect;
+      drm_clip_rect_t src_rect;
+      int i;
+
+      src_rect.x1 = dPriv->x + x;
+      src_rect.y1 = dPriv->y + dPriv->h - (y + height);
+      src_rect.x2 = src_rect.x1 + width;
+      src_rect.y2 = src_rect.y1 + height;
+
+
+
+      for (i = 0; i < nbox; i++) {
+         if (!intel_intersect_cliprects(&rect, &src_rect, &box[i]))
+            continue;
+
+         intelEmitCopyBlit(intel,
+                           src->cpp,
+                           src->pitch, src->buffer, 0, src->tiling,
+                           rowLength, dst_buffer, dst_offset, GL_FALSE,
+                           rect.x1,
+                           rect.y1,
+                           rect.x1 - src_rect.x1,
+                           rect.y2 - src_rect.y2,
+                           rect.x2 - rect.x1, rect.y2 - rect.y1,
+                          GL_COPY);
+      }
+   }
+   UNLOCK_HARDWARE(intel);
+
+   if (INTEL_DEBUG & DEBUG_PIXEL)
+      _mesa_printf("%s - DONE\n", __FUNCTION__);
+
+   return GL_TRUE;
+}
+
+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__);
+
+   intelFlush(ctx);
+
+   if (do_blit_readpixels
+       (ctx, x, y, width, height, format, type, pack, pixels))
+      return;
+
+   if (do_texture_readpixels
+       (ctx, x, y, width, height, format, type, pack, pixels))
+      return;
+
+   if (INTEL_DEBUG & DEBUG_PIXEL)
+      _mesa_printf("%s: fallback to swrast\n", __FUNCTION__);
+
+   _swrast_ReadPixels(ctx, x, y, width, height, format, type, pack, pixels);
+}
diff --git a/src/mesa/drivers/dri/i915/intel_reg.h b/src/mesa/drivers/dri/i915/intel_reg.h
deleted file mode 100644 (file)
index 1ec1532..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/**************************************************************************
- * 
- * 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/src/mesa/drivers/dri/i915/intel_regions.c b/src/mesa/drivers/dri/i915/intel_regions.c
new file mode 120000 (symlink)
index 0000000..89b2f15
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_regions.c
\ No newline at end of file
index d9438ba0fd898a5e3de890db8ec73e7b8a9eb9af..838d450378c0166cae04e3b4271500033e6d16f3 100644 (file)
@@ -39,6 +39,7 @@
 
 #include "tnl/t_context.h"
 #include "tnl/t_vertex.h"
+#include "tnl/t_pipeline.h"
 
 #include "intel_screen.h"
 #include "intel_context.h"
  * 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_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_STRIP_1 0      /* has it, template can't use it yet */
 #define HAVE_TRI_FANS    1
 #define HAVE_POLYGONS    1
 #define HAVE_QUADS       0
@@ -66,7 +67,7 @@
 
 #define HAVE_ELTS        0
 
-static GLuint hw_prim[GL_POLYGON+1] = {
+static uint32_t hw_prim[GL_POLYGON + 1] = {
    0,
    PRIM3D_LINELIST,
    PRIM3D_LINESTRIP,
@@ -79,7 +80,7 @@ static GLuint hw_prim[GL_POLYGON+1] = {
    PRIM3D_POLY
 };
 
-static const GLenum reduced_prim[GL_POLYGON+1] = {  
+static const GLenum reduced_prim[GL_POLYGON + 1] = {
    GL_POINTS,
    GL_LINES,
    GL_LINES,
@@ -92,58 +93,60 @@ static const GLenum reduced_prim[GL_POLYGON+1] = {
    GL_TRIANGLES
 };
 
-static const int scale_prim[GL_POLYGON+1] = {  
-   0,                          /* fallback case */
+static const int scale_prim[GL_POLYGON + 1] = {
+   0,                           /* fallback case */
    1,
    2,
    2,
    1,
    3,
    3,
-   0,                          /* fallback case */
-   0,                          /* fallback case */
+   0,                           /* fallback case */
+   0,                           /* fallback case */
    3
 };
 
 
-static void intelDmaPrimitive( intelContextPtr intel, GLenum prim )
+static void
+intelDmaPrimitive(struct intel_context *intel, GLenum prim)
 {
-   if (0) fprintf(stderr, "%s %s\n", __FUNCTION__, _mesa_lookup_enum_by_nr(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] );
+   intel->vtbl.reduced_primitive_state(intel, reduced_prim[prim]);
+   intel_set_prim(intel, hw_prim[prim]);
 }
 
 
-#define LOCAL_VARS intelContextPtr intel = INTEL_CONTEXT(ctx)
+#define LOCAL_VARS struct intel_context *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 FLUSH() INTEL_FIREVERTICES(intel)
+
+#define GET_SUBSEQUENT_VB_MAX_VERTS() (INTEL_VB_SIZE / (intel->vertex_size * 4))
+#define GET_CURRENT_VB_MAX_VERTS() \
+   ((INTEL_VB_SIZE - intel->prim.current_offset) / (intel->vertex_size * 4))
+
+#define ALLOC_VERTS(nr) intel_get_prim_space(intel, nr)
 
-#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 )  
+  _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 )
+static GLboolean
+choose_render(struct intel_context *intel, struct vertex_buffer *VB)
 {
    int vertsz = intel->vertex_size;
    int cost_render = 0;
@@ -153,20 +156,20 @@ static GLboolean choose_render( intelContextPtr intel,
    int nr_rverts = 0;
    int rprim = intel->reduced_primitive;
    int i = 0;
-   
-   for (i = 0 ; i < VB->PrimitiveCount ; i++) {
+
+   for (i = 0; i < VB->PrimitiveCount; i++) {
       GLuint prim = VB->Primitive[i].mode;
       GLuint length = VB->Primitive[i].count;
 
       if (!length)
-        continue;
+         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];
+         nr_rprims++;
+         rprim = reduced_prim[prim & PRIM_MODE_MASK];
       }
    }
 
@@ -177,64 +180,82 @@ static GLboolean choose_render( intelContextPtr intel,
 
    /* One point for every 1024 dwords (4k) of dma:
     */
-   cost_render += (vertsz * i) / 1024; 
-   cost_fallback += (vertsz * nr_rverts) / 1024; 
+   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);
+              cost_render, cost_fallback);
 
-   if (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 )
+static GLboolean
+intel_run_render(GLcontext * ctx, struct tnl_pipeline_stage *stage)
 {
-   intelContextPtr intel = INTEL_CONTEXT(ctx);
+   struct intel_context *intel = intel_context(ctx);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct vertex_buffer *VB = &tnl->vb;
    GLuint i;
 
+   intel->vtbl.render_prevalidate( intel );
+
    /* Don't handle clipping or indexed vertices.
     */
-   if (intel->RenderIndex != 0 || 
-       !intel_validate_render( ctx, VB ) || 
-       !choose_render( intel, VB )) {
+   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;
+   tnl->Driver.Render.Start(ctx);
+
+   for (i = 0; i < VB->PrimitiveCount; i++) {
+      GLuint prim = _tnl_translate_prim(&VB->Primitive[i]);
       GLuint start = VB->Primitive[i].start;
       GLuint length = VB->Primitive[i].count;
 
       if (!length)
-        continue;
+         continue;
 
-      intel_render_tab_verts[prim & PRIM_MODE_MASK]( ctx, start, start + length,
-                                                    prim );
+      intel_render_tab_verts[prim & PRIM_MODE_MASK] (ctx, start,
+                                                     start + length, prim);
    }
-      
-   tnl->Driver.Render.Finish( ctx );
 
-   return GL_FALSE;     /* finished the pipe */
+   tnl->Driver.Render.Finish(ctx);
+
+   INTEL_FIREVERTICES(intel);
+
+   return GL_FALSE;             /* finished the pipe */
 }
 
-const struct tnl_pipeline_stage _intel_render_stage =
-{
+static const struct tnl_pipeline_stage _intel_render_stage = {
    "intel render",
    NULL,
    NULL,
    NULL,
    NULL,
-   intel_run_render    /* run */
+   intel_run_render             /* run */
+};
+
+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_vertex_program_stage,
+#if 1
+   &_intel_render_stage,        /* ADD: unclipped rastersetup-to-dma */
+#endif
+   &_tnl_render_stage,
+   0,
 };
diff --git a/src/mesa/drivers/dri/i915/intel_rotate.c b/src/mesa/drivers/dri/i915/intel_rotate.c
deleted file mode 100644 (file)
index a77640e..0000000
+++ /dev/null
@@ -1,221 +0,0 @@
-
-/**
- * Routines for simple 2D->2D transformations for rotated, flipped screens.
- *
- * XXX This code is not intel-specific.  Move it into a common/utility
- * someday.
- */
-
-#include "intel_rotate.h"
-
-#define MIN2(A, B)   ( ((A) < (B)) ? (A) : (B) )
-
-#define ABS(A)  ( ((A) < 0) ? -(A) : (A) )
-
-
-void
-matrix23Set(struct matrix23 *m,
-            int m00, int m01, int m02,
-            int m10, int m11, int m12)
-{
-   m->m00 = m00;   m->m01 = m01;   m->m02 = m02;
-   m->m10 = m10;   m->m11 = m11;   m->m12 = m12;
-}
-
-
-/*
- * Transform (x,y) coordinate by the given matrix.
- */
-void
-matrix23TransformCoordf(const struct matrix23 *m, float *x, float *y)
-{
-   const float x0 = *x;
-   const float y0 = *y;
-
-   *x = m->m00 * x0 + m->m01 * y0 + m->m02;
-   *y = m->m10 * x0 + m->m11 * y0 + m->m12;
-}
-
-
-void
-matrix23TransformCoordi(const struct matrix23 *m, int *x, int *y)
-{
-   const int x0 = *x;
-   const int y0 = *y;
-
-   *x = m->m00 * x0 + m->m01 * y0 + m->m02;
-   *y = m->m10 * x0 + m->m11 * y0 + m->m12;
-}
-
-
-/*
- * Transform a width and height by the given matrix.
- * XXX this could be optimized quite a bit.
- */
-void
-matrix23TransformDistance(const struct matrix23 *m, int *xDist, int *yDist)
-{
-   int x0 = 0, y0 = 0;
-   int x1 = *xDist, y1 = 0;
-   int x2 = 0, y2 = *yDist;
-   matrix23TransformCoordi(m, &x0, &y0);
-   matrix23TransformCoordi(m, &x1, &y1);
-   matrix23TransformCoordi(m, &x2, &y2);
-
-   *xDist = (x1 - x0) + (x2 - x0);
-   *yDist = (y1 - y0) + (y2 - y0);
-
-   if (*xDist < 0)
-       *xDist = -*xDist;
-   if (*yDist < 0)
-       *yDist = -*yDist;
-}
-
-
-/**
- * Transform the rect defined by (x, y, w, h) by m.
- */
-void
-matrix23TransformRect(const struct matrix23 *m, int *x, int *y, int *w, int *h)
-{
-   int x0 = *x, y0 = *y;
-   int x1 = *x + *w, y1 = *y;
-   int x2 = *x + *w, y2 = *y + *h;
-   int x3 = *x, y3 = *y + *h;
-   matrix23TransformCoordi(m, &x0, &y0);
-   matrix23TransformCoordi(m, &x1, &y1);
-   matrix23TransformCoordi(m, &x2, &y2);
-   matrix23TransformCoordi(m, &x3, &y3);
-   *w = ABS(x1 - x0) + ABS(x2 - x1);
-   /**w = ABS(*w);*/
-   *h = ABS(y1 - y0) + ABS(y2 - y1);
-   /**h = ABS(*h);*/
-   *x = MIN2(x0, x1);
-   *x = MIN2(*x, x2);
-   *y = MIN2(y0, y1);
-   *y = MIN2(*y, y2);
-}
-
-
-/*
- * Make rotation matrix for width X height screen.
- */
-void
-matrix23Rotate(struct matrix23 *m, int width, int height, int angle)
-{
-   switch (angle) {
-   case 0:
-      matrix23Set(m, 1, 0, 0, 0, 1, 0);
-      break;
-   case 90:
-      matrix23Set(m, 0, 1, 0,  -1, 0, width);
-      break;
-   case 180:
-      matrix23Set(m, -1, 0, width,  0, -1, height);
-      break;
-   case 270:
-      matrix23Set(m, 0, -1, height,  1, 0, 0);
-      break;
-   default:
-      /*abort()*/;
-   }
-}
-
-
-/*
- * Make flip/reflection matrix for width X height screen.
- */
-void
-matrix23Flip(struct matrix23 *m, int width, int height, int xflip, int yflip)
-{
-   if (xflip) {
-      m->m00 = -1;  m->m01 = 0;   m->m02 = width - 1;
-   }
-   else {
-      m->m00 = 1;   m->m01 = 0;   m->m02 = 0;
-   }
-   if (yflip) {
-      m->m10 = 0;   m->m11 = -1;  m->m12 = height - 1;
-   }
-   else {
-      m->m10 = 0;   m->m11 = 1;   m->m12 = 0;
-   }
-}
-
-
-/*
- * result = a * b
- */
-void
-matrix23Multiply(struct matrix23 *result,
-                 const struct matrix23 *a, const struct matrix23 *b)
-{
-   result->m00 = a->m00 * b->m00 + a->m01 * b->m10;
-   result->m01 = a->m00 * b->m01 + a->m01 * b->m11;
-   result->m02 = a->m00 * b->m02 + a->m01 * b->m12 + a->m02;
-
-   result->m10 = a->m10 * b->m00 + a->m11 * b->m10;
-   result->m11 = a->m10 * b->m01 + a->m11 * b->m11;
-   result->m12 = a->m10 * b->m02 + a->m11 * b->m12 + a->m12;
-}
-
-
-#if 000
-
-#include <stdio.h>
-
-int
-main(int argc, char *argv[])
-{
-   int width = 500, height = 400;
-   int rot;
-   int fx = 0, fy = 0;  /* flip x and/or y ? */
-   int coords[4][2];
-
-   /* four corner coords to test with */
-   coords[0][0] = 0;  coords[0][1] = 0;
-   coords[1][0] = width-1;  coords[1][1] = 0;
-   coords[2][0] = width-1;  coords[2][1] = height-1;
-   coords[3][0] = 0;  coords[3][1] = height-1;
-
-
-   for (rot = 0; rot < 360; rot += 90) {
-      struct matrix23 rotate, flip, m;
-      int i;
-
-      printf("Rot %d, xFlip %d, yFlip %d:\n", rot, fx, fy);
-
-      /* make transformation matrix 'm' */
-      matrix23Rotate(&rotate, width, height, rot);
-      matrix23Flip(&flip, width, height, fx, fy);
-      matrix23Multiply(&m, &rotate, &flip);
-
-      /* xform four coords */
-      for (i = 0; i < 4; i++) {
-         int x = coords[i][0];
-         int y = coords[i][1];
-         matrix23TransformCoordi(&m, &x, &y);
-         printf("  %d, %d  -> %d %d\n", coords[i][0], coords[i][1], x, y);
-      }
-
-      /* xform width, height */
-      {
-         int x = width;
-         int y = height;
-         matrix23TransformDistance(&m, &x, &y);
-         printf("  %d x %d -> %d x %d\n", width, height, x, y);
-      }
-
-      /* xform rect */
-      {
-         int x = 50, y = 10, w = 200, h = 100;
-         matrix23TransformRect(&m, &x, &y, &w, &h);
-         printf("  %d,%d %d x %d -> %d, %d %d x %d\n", 50, 10, 200, 100,
-                x, y, w, h);
-      }
-
-   }
-
-   return 0;
-}
-#endif
diff --git a/src/mesa/drivers/dri/i915/intel_rotate.h b/src/mesa/drivers/dri/i915/intel_rotate.h
deleted file mode 100644 (file)
index 0da45d2..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef INTEL_ROTATE_H
-#define INTEL_ROTATE_H 1
-
-struct matrix23
-{
-   int m00, m01, m02;
-   int m10, m11, m12;
-};
-
-
-
-extern void
-matrix23Set(struct matrix23 *m,
-            int m00, int m01, int m02,
-            int m10, int m11, int m12);
-
-extern void
-matrix23TransformCoordi(const struct matrix23 *m, int *x, int *y);
-
-extern void
-matrix23TransformCoordf(const struct matrix23 *m, float *x, float *y);
-
-extern void
-matrix23TransformDistance(const struct matrix23 *m, int *xDist, int *yDist);
-
-extern void
-matrix23TransformRect(const struct matrix23 *m,
-                      int *x, int *y, int *w, int *h);
-
-extern void
-matrix23Rotate(struct matrix23 *m, int width, int height, int angle);
-
-extern void
-matrix23Flip(struct matrix23 *m, int width, int height, int xflip, int yflip);
-
-extern void
-matrix23Multiply(struct matrix23 *result,
-                 const struct matrix23 *a, const struct matrix23 *b);
-
-
-#endif /* INTEL_ROTATE_H */
diff --git a/src/mesa/drivers/dri/i915/intel_screen.h b/src/mesa/drivers/dri/i915/intel_screen.h
deleted file mode 100644 (file)
index 24cfd9b..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/**************************************************************************
- * 
- * 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 "xmlconfig.h"
-#include "dri_util.h"
-#include "intel_rotate.h"
-#include "i830_common.h"
-
-
-/* This roughly corresponds to a gl_renderbuffer (Mesa 6.4) */
-typedef struct {
-   drm_handle_t handle;
-   drmSize size;        /* region size in bytes */
-   char *map;           /* memory map */
-   int offset;          /* from start of video mem, in bytes */
-   int pitch;           /* row stride, in bytes */
-} intelRegion;
-
-typedef struct 
-{
-   intelRegion front;
-   intelRegion back;
-   intelRegion rotated;
-   intelRegion depth;
-   intelRegion tex;
-   
-   int deviceID;
-   int width;
-   int height;
-   int mem;         /* unused */
-   
-   int cpp;         /* for front and back buffers */
-   int fbFormat;
-
-   int logTextureGranularity;
-   
-   __DRIscreenPrivate *driScrnPriv;
-   unsigned int sarea_priv_offset;
-
-   int drmMinor;
-
-   int irq_active;
-   int allow_batchbuffer;
-
-   struct matrix23 rotMatrix;
-
-   int current_rotation;  /* 0, 90, 180 or 270 */
-   int rotatedWidth, rotatedHeight;
-
-   /**
-   * Configuration cache with default values for all contexts
-   */
-   driOptionCache optionCache;
-} intelScreenPrivate;
-
-
-extern GLboolean
-intelMapScreenRegions(__DRIscreenPrivate *sPriv);
-
-extern void
-intelUnmapScreenRegions(intelScreenPrivate *intelScreen);
-
-extern void
-intelUpdateScreenFromSAREA(intelScreenPrivate *intelScreen,
-                           drmI830Sarea *sarea);
-
-extern void
-intelDestroyContext(__DRIcontextPrivate *driContextPriv);
-
-extern GLboolean
-intelUnbindContext(__DRIcontextPrivate *driContextPriv);
-
-extern GLboolean
-intelMakeCurrent(__DRIcontextPrivate *driContextPriv,
-                 __DRIdrawablePrivate *driDrawPriv,
-                 __DRIdrawablePrivate *driReadPriv);
-
-extern void
-intelSwapBuffers(__DRIdrawablePrivate *dPriv);
-
-extern void
-intelCopySubBuffer( __DRIdrawablePrivate *dPriv, int x, int y, int w, int h );
-
-#endif
deleted file mode 100644 (file)
index c3ffc4b2ac0553bbad8e1fc08b0d6c334ada3c45..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,258 +0,0 @@
-/**************************************************************************
- * 
- * 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;           \
-   driRenderbuffer *drb = (driRenderbuffer *) rb;              \
-   GLuint pitch = drb->pitch;                                  \
-   GLuint height = dPriv->h;                                   \
-   char *buf = (char *) drb->Base.Data +                       \
-                       dPriv->x * drb->cpp +                   \
-                       dPriv->y * pitch;                       \
-   GLushort p;                                                 \
-   (void) buf; (void) p
-
-#define LOCAL_DEPTH_VARS                                       \
-   intelContextPtr intel = INTEL_CONTEXT(ctx);                 \
-   __DRIdrawablePrivate *dPriv = intel->driDrawable;           \
-   driRenderbuffer *drb = (driRenderbuffer *) rb;              \
-   GLuint pitch = drb->pitch;                                  \
-   GLuint height = dPriv->h;                                   \
-   char *buf = (char *) drb->Base.Data +                       \
-                       dPriv->x * drb->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 *)(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 *)(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##_z16
-#include "depthtmp.h"
-
-
-#undef LOCAL_VARS
-#define LOCAL_VARS                                             \
-   intelContextPtr intel = INTEL_CONTEXT(ctx);                 \
-   __DRIdrawablePrivate *dPriv = intel->driDrawable;           \
-   driRenderbuffer *drb = (driRenderbuffer *) rb;              \
-   GLuint pitch = drb->pitch;                                  \
-   GLuint height = dPriv->h;                                   \
-   char *buf = (char *)drb->Base.Data +                                \
-                       dPriv->x * drb->cpp +                   \
-                       dPriv->y * pitch;                       \
-   GLuint p;                                                   \
-   (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 *)(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##_z24_s8
-#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##_z24_s8
-#include "stenciltmp.h"
-
-
-/* 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 )
-{
-   struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
-   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) {
-         intelInitPointers_555(&drb->Base);
-      }
-      else if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
-         intelInitPointers_565(&drb->Base);
-      }
-      else {
-         assert(vis->redBits == 8);
-         assert(vis->greenBits == 8);
-         assert(vis->blueBits == 8);
-         intelInitPointers_8888(&drb->Base);
-      }
-   }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
-      intelInitDepthPointers_z16(&drb->Base);
-   }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
-      intelInitDepthPointers_z24_s8(&drb->Base);
-   }
-   else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
-      intelInitStencilPointers_z24_s8(&drb->Base);
-   }
-}
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..05e5e8e58338a4d3c83c4b7b79fc7d573d333082
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_span.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i915/intel_span.h b/src/mesa/drivers/dri/i915/intel_span.h
deleted file mode 100644 (file)
index 2d4f858..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/**************************************************************************
- * 
- * 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
index e5988a5ed6cd5211071566944a103ef2a52390c1..d1ca11dec4f2f94254f16b64df2621634d908503 100644 (file)
 #include "context.h"
 #include "macros.h"
 #include "enums.h"
+#include "colormac.h"
 #include "dd.h"
 
 #include "intel_screen.h"
 #include "intel_context.h"
+#include "intel_fbo.h"
+#include "intel_regions.h"
 #include "swrast/swrast.h"
 
-int intel_translate_compare_func( GLenum func )
+int 
+intel_translate_shadow_compare_func( GLenum func )
 {
    switch(func) {
    case GL_NEVER: 
-      return COMPAREFUNC_NEVER
+       return COMPAREFUNC_ALWAYS
    case GL_LESS: 
-      return COMPAREFUNC_LESS
+       return COMPAREFUNC_LEQUAL
    case GL_LEQUAL: 
-      return COMPAREFUNC_LEQUAL; 
+       return COMPAREFUNC_LESS;
    case GL_GREATER: 
-      return COMPAREFUNC_GREATER
+       return COMPAREFUNC_GEQUAL
    case GL_GEQUAL: 
-      return COMPAREFUNC_GEQUAL
+      return COMPAREFUNC_GREATER
    case GL_NOTEQUAL: 
-      return COMPAREFUNC_NOTEQUAL; 
-   case GL_EQUAL: 
       return COMPAREFUNC_EQUAL; 
+   case GL_EQUAL: 
+      return COMPAREFUNC_NOTEQUAL; 
    case GL_ALWAYS: 
-      return COMPAREFUNC_ALWAYS; 
+       return COMPAREFUNC_NEVER; 
+   }
+
+   fprintf(stderr, "Unknown value in %s: %x\n", __FUNCTION__, func);
+   return COMPAREFUNC_NEVER; 
+}
+
+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; 
+   return COMPAREFUNC_ALWAYS;
 }
 
-int intel_translate_stencil_op( GLenum op )
+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: 
+   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: 
+   case GL_DECR:
       return STENCILOP_DECRSAT;
    case GL_INCR_WRAP:
-      return STENCILOP_INCR; 
+      return STENCILOP_INCR;
    case GL_DECR_WRAP:
-      return STENCILOP_DECR; 
-   case GL_INVERT: 
-      return STENCILOP_INVERT; 
-   default: 
+      return STENCILOP_DECR;
+   case GL_INVERT:
+      return STENCILOP_INVERT;
+   default:
       return STENCILOP_ZERO;
    }
 }
 
-int intel_translate_blend_factor( GLenum factor )
+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; 
+   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; 
+      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_INV_DST_ALPHA;
+   case GL_SRC_ALPHA_SATURATE:
       return BLENDFACT_SRC_ALPHA_SATURATE;
    case GL_CONSTANT_COLOR:
-      return BLENDFACT_CONST_COLOR; 
+      return BLENDFACT_CONST_COLOR;
    case GL_ONE_MINUS_CONSTANT_COLOR:
       return BLENDFACT_INV_CONST_COLOR;
    case GL_CONSTANT_ALPHA:
-      return BLENDFACT_CONST_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 )
+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:
+   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;
-   }
-}
-
-static void intelDrawBuffer(GLcontext *ctx, GLenum mode )
-{
-   intelContextPtr intel = INTEL_CONTEXT(ctx);
-   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;
-   }
-
-   if ( intel->sarea->pf_current_page == 1 ) 
-      front ^= 1;
-   
-   intelSetFrontClipRects( intel );
-
-   if (front) {
-      intel->drawRegion = &intel->intelScreen->front;
-      intel->readRegion = &intel->intelScreen->front;
-   } else {
-      intel->drawRegion = &intel->intelScreen->back;
-      intel->readRegion = &intel->intelScreen->back;
+      return LOGICOP_SET;
    }
-
-   intel->vtbl.set_color_region( intel, intel->drawRegion );
-}
-
-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])
+static void
+intelClearColor(GLcontext * ctx, const GLfloat color[4])
 {
-   intelContextPtr intel = INTEL_CONTEXT(ctx);
-   intelScreenPrivate *screen = intel->intelScreen;
+   struct intel_context *intel = intel_context(ctx);
+   GLubyte clear[4];
 
-   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]);
+   CLAMPED_FLOAT_TO_UBYTE(clear[0], color[0]);
+   CLAMPED_FLOAT_TO_UBYTE(clear[1], color[1]);
+   CLAMPED_FLOAT_TO_UBYTE(clear[2], color[2]);
+   CLAMPED_FLOAT_TO_UBYTE(clear[3], color[3]);
 
-   intel->ClearColor = INTEL_PACKCOLOR(screen->fbFormat,
-                                      intel->clear_red, 
-                                      intel->clear_green, 
-                                      intel->clear_blue, 
-                                      intel->clear_alpha);
+   /* compute both 32 and 16-bit clear values */
+   intel->ClearColor8888 = INTEL_PACKCOLOR8888(clear[0], clear[1],
+                                               clear[2], clear[3]);
+   intel->ClearColor565 = INTEL_PACKCOLOR565(clear[0], clear[1], clear[2]);
 }
 
 
-static void intelCalcViewport( GLcontext *ctx )
+/**
+ * Update the viewport transformation matrix.  Depends on:
+ *  - viewport pos/size
+ *  - depthrange
+ *  - window pos/size or FBO size
+ */
+static void
+intelCalcViewport(GLcontext * ctx)
 {
-   intelContextPtr intel = INTEL_CONTEXT(ctx);
+   struct intel_context *intel = intel_context(ctx);
    const GLfloat *v = ctx->Viewport._WindowMap.m;
+   const GLfloat depthScale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
    GLfloat *m = intel->ViewportMatrix.m;
-   GLint h = 0;
+   GLfloat yScale, yBias;
+
+   if (ctx->DrawBuffer->Name) {
+      /* User created FBO */
+      struct intel_renderbuffer *irb
+         = intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]);
+      if (irb && !irb->RenderToTexture) {
+         /* y=0=top */
+         yScale = -1.0;
+         yBias = irb->Base.Height;
+      }
+      else {
+         /* y=0=bottom */
+         yScale = 1.0;
+         yBias = 0.0;
+      }
+   }
+   else {
+      /* window buffer, y=0=top */
+      yScale = -1.0;
+      yBias = (intel->driDrawable) ? intel->driDrawable->h : 0.0F;
+   }
 
-   if (intel->driDrawable) 
-      h = intel->driDrawable->h + SUBPIXEL_Y;
+   m[MAT_SX] = v[MAT_SX];
+   m[MAT_TX] = v[MAT_TX];
 
-   /* 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] + h;
-   m[MAT_SZ] =   v[MAT_SZ] * intel->depth_scale;
-   m[MAT_TZ] =   v[MAT_TZ] * intel->depth_scale;
+   m[MAT_SY] = v[MAT_SY] * yScale;
+   m[MAT_TY] = v[MAT_TY] * yScale + yBias;
+
+   m[MAT_SZ] = v[MAT_SZ] * depthScale;
+   m[MAT_TZ] = v[MAT_TZ] * depthScale;
 }
 
-static void intelViewport( GLcontext *ctx,
-                         GLint x, GLint y,
-                         GLsizei width, GLsizei height )
+static void
+intelViewport(GLcontext * ctx,
+              GLint x, GLint y, GLsizei width, GLsizei height)
 {
-   intelCalcViewport( ctx );
+   intelCalcViewport(ctx);
 }
 
-static void intelDepthRange( GLcontext *ctx,
-                           GLclampd nearval, GLclampd farval )
+static void
+intelDepthRange(GLcontext * ctx, GLclampd nearval, GLclampd farval)
 {
-   intelCalcViewport( ctx );
+   intelCalcViewport(ctx);
 }
 
 /* Fallback to swrast for select and feedback.
  */
-static void intelRenderMode( GLcontext *ctx, GLenum mode )
+static void
+intelRenderMode(GLcontext * ctx, GLenum mode)
 {
-   intelContextPtr intel = INTEL_CONTEXT(ctx);
-   FALLBACK( intel, INTEL_FALLBACK_RENDERMODE, (mode != GL_RENDER) );
+   struct intel_context *intel = intel_context(ctx);
+   FALLBACK(intel, INTEL_FALLBACK_RENDERMODE, (mode != GL_RENDER));
 }
 
 
-void intelInitStateFuncs( struct dd_function_table *functions )
+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/src/mesa/drivers/dri/i915/intel_structs.h b/src/mesa/drivers/dri/i915/intel_structs.h
new file mode 100644 (file)
index 0000000..522e3bd
--- /dev/null
@@ -0,0 +1,132 @@
+#ifndef INTEL_STRUCTS_H
+#define INTEL_STRUCTS_H
+
+struct br0 {
+   GLuint length:8;
+   GLuint pad0:3;
+   GLuint dst_tiled:1;
+   GLuint pad1:8;
+   GLuint write_rgb:1;
+   GLuint write_alpha:1;
+   GLuint opcode:7;
+   GLuint client:3;
+};
+
+   
+struct br13 {
+   GLint dest_pitch:16;
+   GLuint rop:8;
+   GLuint color_depth:2;
+   GLuint pad1:3;
+   GLuint mono_source_transparency:1;
+   GLuint clipping_enable:1;
+   GLuint pad0:1;
+};
+
+
+
+/* This is an attempt to move some of the 2D interaction in this
+ * driver to using structs for packets rather than a bunch of #defines
+ * and dwords.
+ */
+struct xy_color_blit {
+   struct br0 br0;
+   struct br13 br13;
+
+   struct {
+      GLuint dest_x1:16;
+      GLuint dest_y1:16;
+   } dw2;
+
+   struct {
+      GLuint dest_x2:16;
+      GLuint dest_y2:16;
+   } dw3;
+   
+   GLuint dest_base_addr;
+   GLuint color;
+};
+
+struct xy_src_copy_blit {
+   struct br0 br0;
+   struct br13 br13;
+
+   struct {
+      GLuint dest_x1:16;
+      GLuint dest_y1:16;
+   } dw2;
+
+   struct {
+      GLuint dest_x2:16;
+      GLuint dest_y2:16;
+   } dw3;
+   
+   GLuint dest_base_addr;
+
+   struct {
+      GLuint src_x1:16;
+      GLuint src_y1:16;
+   } dw5;
+
+   struct {
+      GLint src_pitch:16;
+      GLuint pad:16;
+   } dw6;
+   
+   GLuint src_base_addr;
+};
+
+struct xy_setup_blit {
+   struct br0 br0;
+   struct br13 br13;
+
+   struct {
+      GLuint clip_x1:16;
+      GLuint clip_y1:16;
+   } dw2;
+
+   struct {
+      GLuint clip_x2:16;
+      GLuint clip_y2:16;
+   } dw3;
+      
+   GLuint dest_base_addr;
+   GLuint background_color;
+   GLuint foreground_color;
+   GLuint pattern_base_addr;
+};
+
+
+struct xy_text_immediate_blit {
+   struct {
+      GLuint length:8;
+      GLuint pad2:3;
+      GLuint dst_tiled:1;
+      GLuint pad1:4;
+      GLuint byte_packed:1;
+      GLuint pad0:5;
+      GLuint opcode:7;
+      GLuint client:3;
+   } dw0;
+
+   struct {
+      GLuint dest_x1:16;
+      GLuint dest_y1:16;
+   } dw1;
+
+   struct {
+      GLuint dest_x2:16;
+      GLuint dest_y2:16;
+   } dw2;   
+
+   /* Src bitmap data follows as inline dwords.
+    */
+};
+
+
+#define CLIENT_2D 0x2
+#define OPCODE_XY_SETUP_BLT 0x1
+#define OPCODE_XY_COLOR_BLT 0x50
+#define OPCODE_XY_TEXT_IMMEDIATE_BLT 0x31
+
+#endif
deleted file mode 100644 (file)
index 5bd280652afb0939a6d690bc38f70522fb584d35..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,877 +0,0 @@
-/**************************************************************************
- * 
- * 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->tex.size > 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_z16;
-
-   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 = 0;
-      GLubyte *dst = (GLubyte *)(t->BufAddr + offset);
-      GLubyte *src = (GLubyte *)image->Data;
-      GLuint j;
-
-      /* must always copy whole blocks (8/16 bytes) */
-      switch (image->InternalFormat) {
-       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:
-         row_len = (image->Width * 2 + 7) & ~7;
-         break;
-       case GL_RGBA_S3TC:
-       case GL_RGBA4_S3TC:
-       case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
-       case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
-         row_len = (image->Width * 4 + 15) & ~15;
-         break;
-       default:
-         fprintf(stderr,"Internal Compressed format not supported %d\n", image->InternalFormat);
-         break;
-      }
-
-      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) {
-        for (j = 0 ; j < (image->Height + 3)/4 ; j++, dst += (t->Pitch)) {
-          __memcpy(dst, src, row_len );
-          src += row_len;
-        }
-      }
-   }
-   /* Time for another vtbl entry:
-    */
-   else if (intel->intelScreen->deviceID == PCI_CHIP_I945_G ||
-            intel->intelScreen->deviceID == PCI_CHIP_I945_GM ||
-            intel->intelScreen->deviceID == PCI_CHIP_I945_GME ||
-            intel->intelScreen->deviceID == PCI_CHIP_G33_G ||
-            intel->intelScreen->deviceID == PCI_CHIP_Q33_G ||
-            intel->intelScreen->deviceID == PCI_CHIP_Q35_G) {
-      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) {
-        memcpy( dst, src, row_len * image->Height * image->Depth );
-      }
-      else { 
-        GLuint x = 0, y = 0;
-
-        for (d = 0 ; d < image->Depth ; d++) {
-           GLubyte *dst0 = dst + x + y * t->Pitch;
-
-           for (j = 0 ; j < image->Height ; j++) {
-              __memcpy(dst0, src, row_len );
-              src += row_len;
-              dst0 += t->Pitch;
-           }
-
-           x += MIN2(4, row_len); /* Guess: 4 byte minimum alignment */
-           if (x > t->Pitch) {
-              x = 0;
-              y += image->Height;
-           }
-        }
-      }
-
-   }
-   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 = (GLubyte *) (intel->intelScreen->tex.map + 
-                                  t->base.memBlock->ofs);
-        t->TextureOffset = intel->intelScreen->tex.offset + 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;
-}
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..d77ce749a3e0a9b2a6eacae06e9b1177af3775fb
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_tex.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i915/intel_tex.h b/src/mesa/drivers/dri/i915/intel_tex.h
deleted file mode 100644 (file)
index 9b7e550..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/**************************************************************************
- * 
- * 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 );
-
-GLboolean 
-intel_driReinitTextureHeap( driTexHeap *heap,
-                           unsigned size );
-#endif
diff --git a/src/mesa/drivers/dri/i915/intel_tex_copy.c b/src/mesa/drivers/dri/i915/intel_tex_copy.c
new file mode 120000 (symlink)
index 0000000..87196c5
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_tex_copy.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i915/intel_tex_format.c b/src/mesa/drivers/dri/i915/intel_tex_format.c
new file mode 120000 (symlink)
index 0000000..3415f75
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_tex_format.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i915/intel_tex_image.c b/src/mesa/drivers/dri/i915/intel_tex_image.c
new file mode 120000 (symlink)
index 0000000..567abe4
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_tex_image.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i915/intel_tex_layout.c b/src/mesa/drivers/dri/i915/intel_tex_layout.c
new file mode 120000 (symlink)
index 0000000..fe61b44
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_tex_layout.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i915/intel_tex_subimage.c b/src/mesa/drivers/dri/i915/intel_tex_subimage.c
new file mode 120000 (symlink)
index 0000000..b3a8a3d
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_tex_subimage.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i915/intel_tex_validate.c b/src/mesa/drivers/dri/i915/intel_tex_validate.c
new file mode 120000 (symlink)
index 0000000..41a7567
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_tex_validate.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i915/intel_texmem.c b/src/mesa/drivers/dri/i915/intel_texmem.c
deleted file mode 100644 (file)
index 09beec9..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-#include "texmem.h"
-#include "simple_list.h"
-#include "imports.h"
-#include "macros.h"
-
-#include "intel_tex.h"
-
-static GLuint
-driLog2( GLuint n )
-{
-   GLuint log2;
-
-   for ( log2 = 1 ; n > 1 ; log2++ ) {
-      n >>= 1;
-   }
-
-   return log2;
-}
-
-static void calculate_heap_size( driTexHeap * heap, unsigned size, 
-                                unsigned nr_regions, unsigned alignmentShift )
-{
-   unsigned     l;
-
-   l = driLog2( (size - 1) / nr_regions );
-   if ( l < alignmentShift )
-   {
-      l = alignmentShift;
-   }
-
-   heap->logGranularity = l;
-   heap->size = size & ~((1L << l) - 1);
-}
-
-
-GLboolean 
-intel_driReinitTextureHeap( driTexHeap *heap,
-                           unsigned size )
-{
-   driTextureObject *t, *tmp;
-
-   /* Kick out everything:
-    */
-   foreach_s ( t, tmp, & heap->texture_objects ) {
-      if ( t->tObj != NULL ) {
-        driSwapOutTextureObject( t );
-      }
-      else {
-        driDestroyTextureObject( t );
-      }
-   }
-   
-   /* Destroy the memory manager:
-    */
-   mmDestroy( heap->memory_heap );
-      
-   /* Recreate the memory manager:
-    */
-   calculate_heap_size(heap, size, heap->nrRegions, heap->alignmentShift);
-   heap->memory_heap = mmInit( 0, heap->size );
-   if ( heap->memory_heap == NULL ) {
-      fprintf(stderr, "driReinitTextureHeap: couldn't recreate memory heap\n");
-      FREE( heap );
-      return GL_FALSE;
-   }
-
-   make_empty_list( & heap->texture_objects );
-
-   return GL_TRUE;
-}
-
-
index b2787ee60ac1ece080b50713df32f868590eee40..5f4b852212aa9eee8dd1d4146679adee761f3ada 100644 (file)
  * 
  **************************************************************************/
 
+/** @file intel_tris.c
+ *
+ * This file contains functions for managing the vertex buffer and emitting
+ * primitives into it.
+ */
+
 #include "glheader.h"
 #include "context.h"
 #include "macros.h"
 #include "enums.h"
+#include "texobj.h"
+#include "state.h"
 #include "dd.h"
 
 #include "swrast/swrast.h"
 #include "tnl/t_vertex.h"
 
 #include "intel_screen.h"
+#include "intel_context.h"
 #include "intel_tris.h"
 #include "intel_batchbuffer.h"
+#include "intel_buffers.h"
 #include "intel_reg.h"
 #include "intel_span.h"
+#include "intel_tex.h"
+#include "intel_chipset.h"
+#include "i830_context.h"
+#include "i830_reg.h"
+
+static void intelRenderPrimitive(GLcontext * ctx, GLenum prim);
+static void intelRasterPrimitive(GLcontext * ctx, GLenum rprim,
+                                 GLuint hwprim);
+
+/** Sets the primitive type for a primitive sequence, flushing as needed. */
+void intel_set_prim(struct intel_context *intel, uint32_t prim)
+{
+   if (prim != intel->prim.primitive) {
+      INTEL_FIREVERTICES(intel);
+      intel->prim.primitive = prim;
+   }
+}
+
+/** Returns mapped VB space for the given number of vertices */
+uint32_t *intel_get_prim_space(struct intel_context *intel, unsigned int count)
+{
+   uint32_t *addr;
+
+   /* Check for space in the existing VB */
+   if (intel->prim.vb_bo == NULL ||
+       (intel->prim.current_offset +
+       count * intel->vertex_size * 4) > INTEL_VB_SIZE ||
+       (intel->prim.count + count) >= (1 << 16)) {
+      /* Flush existing prim if any */
+      INTEL_FIREVERTICES(intel);
+
+      intel_finish_vb(intel);
+
+      /* Start a new VB */
+      if (intel->prim.vb == NULL)
+        intel->prim.vb = malloc(INTEL_VB_SIZE);
+      intel->prim.vb_bo = dri_bo_alloc(intel->bufmgr, "vb",
+                                      INTEL_VB_SIZE, 4);
+      intel->prim.start_offset = 0;
+      intel->prim.current_offset = 0;
+   }
+
+   intel->prim.flush = intel_flush_prim;
+
+   addr = (uint32_t *)(intel->prim.vb + intel->prim.current_offset);
+   intel->prim.current_offset += intel->vertex_size * 4 * count;
+   intel->prim.count += count;
+
+   return addr;
+}
+
+/** Dispatches the accumulated primitive to the batchbuffer. */
+void intel_flush_prim(struct intel_context *intel)
+{
+   BATCH_LOCALS;
+   dri_bo *aper_array[2];
+   dri_bo *vb_bo;
+
+   /* Must be called after an intel_start_prim. */
+   assert(intel->prim.primitive != ~0);
+
+   if (intel->prim.count == 0)
+      return;
+
+   /* Keep a reference on the BO as it may get finished as we start the
+    * batch emit.
+    */
+   vb_bo = intel->prim.vb_bo;
+   dri_bo_reference(vb_bo);
+
+   intel_wait_flips(intel);
+
+   intel->vtbl.emit_state(intel);
+
+   aper_array[0] = intel->batch->buf;
+   aper_array[1] = vb_bo;
+   if (dri_bufmgr_check_aperture_space(aper_array, 2)) {
+      intel_batchbuffer_flush(intel->batch);
+      intel->vtbl.emit_state(intel);
+   }
+
+   /* Ensure that we don't start a new batch for the following emit, which
+    * depends on the state just emitted. emit_state should be making sure we
+    * have the space for this.
+    */
+   intel->no_batch_wrap = GL_TRUE;
+
+   /* Check that we actually emitted the state into this batch, using the
+    * UPLOAD_CTX bit as the signal.
+    */
+   assert((intel->batch->dirty_state & (1<<1)) == 0);
+
+#if 0
+   printf("emitting %d..%d=%d vertices size %d\n", intel->prim.start_offset,
+         intel->prim.current_offset, intel->prim.count,
+         intel->vertex_size * 4);
+#endif
 
-/* XXX we shouldn't include these headers in this file, but we need them
- * for fallbackStrings, below.
+   if (IS_9XX(intel->intelScreen->deviceID)) {
+      BEGIN_BATCH(5, LOOP_CLIPRECTS);
+      OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
+               I1_LOAD_S(0) | I1_LOAD_S(1) | 1);
+      assert((intel->prim.start_offset & !S0_VB_OFFSET_MASK) == 0);
+      OUT_RELOC(vb_bo, I915_GEM_DOMAIN_VERTEX, 0,
+               intel->prim.start_offset);
+      OUT_BATCH((intel->vertex_size << S1_VERTEX_WIDTH_SHIFT) |
+               (intel->vertex_size << S1_VERTEX_PITCH_SHIFT));
+
+      OUT_BATCH(_3DPRIMITIVE |
+               PRIM_INDIRECT |
+               PRIM_INDIRECT_SEQUENTIAL |
+               intel->prim.primitive |
+               intel->prim.count);
+      OUT_BATCH(0); /* Beginning vertex index */
+      ADVANCE_BATCH();
+   } else {
+      struct i830_context *i830 = i830_context(&intel->ctx);
+
+      BEGIN_BATCH(5, LOOP_CLIPRECTS);
+      OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
+               I1_LOAD_S(0) | I1_LOAD_S(2) | 1);
+      /* S0 */
+      assert((intel->prim.start_offset & !S0_VB_OFFSET_MASK_830) == 0);
+      OUT_RELOC(vb_bo, I915_GEM_DOMAIN_VERTEX, 0,
+               intel->prim.start_offset |
+               (intel->vertex_size << S0_VB_PITCH_SHIFT_830) |
+               S0_VB_ENABLE_830);
+      /* S1
+       * This is somewhat unfortunate -- VB width is tied up with
+       * vertex format data that we've already uploaded through
+       * _3DSTATE_VFT[01]_CMD.  We may want to replace emits of VFT state with
+       * STATE_IMMEDIATE_1 like this to avoid duplication.
+       */
+      OUT_BATCH((i830->state.Ctx[I830_CTXREG_VF] & VFT0_TEX_COUNT_MASK) >>
+               VFT0_TEX_COUNT_SHIFT << S2_TEX_COUNT_SHIFT_830 |
+               (i830->state.Ctx[I830_CTXREG_VF2] << 16) |
+               intel->vertex_size << S2_VERTEX_0_WIDTH_SHIFT_830);
+
+      OUT_BATCH(_3DPRIMITIVE |
+               PRIM_INDIRECT |
+               PRIM_INDIRECT_SEQUENTIAL |
+               intel->prim.primitive |
+               intel->prim.count);
+      OUT_BATCH(0); /* Beginning vertex index */
+      ADVANCE_BATCH();
+   }
+
+   intel->no_batch_wrap = GL_FALSE;
+
+   intel->prim.flush = NULL;
+   intel->prim.start_offset = intel->prim.current_offset;
+   if (!IS_9XX(intel->intelScreen->deviceID))
+      intel->prim.start_offset = ALIGN(intel->prim.start_offset, 128);
+   intel->prim.count = 0;
+
+   dri_bo_unreference(vb_bo);
+}
+
+/**
+ * Uploads the locally-accumulated VB into the buffer object.
+ *
+ * This avoids us thrashing the cachelines in and out as the buffer gets
+ * filled, dispatched, then reused as the hardware completes rendering from it,
+ * and also lets us clflush less if we dispatch with a partially-filled VB.
+ *
+ * This is called normally from get_space when we're finishing a BO, but also
+ * at batch flush time so that we don't try accessing the contents of a
+ * just-dispatched buffer.
  */
-#include "i830_context.h"
-#include "i915_context.h"
+void intel_finish_vb(struct intel_context *intel)
+{
+   if (intel->prim.vb_bo == NULL)
+      return;
 
-static void intelRenderPrimitive( GLcontext *ctx, GLenum prim );
-static void intelRasterPrimitive( GLcontext *ctx, GLenum rprim, GLuint hwprim );
+   dri_bo_subdata(intel->prim.vb_bo, 0, intel->prim.start_offset,
+                 intel->prim.vb);
+   dri_bo_unreference(intel->prim.vb_bo);
+   intel->prim.vb_bo = NULL;
+}
 
 /***********************************************************************
  *                    Emit primitives as inline vertices               *
@@ -69,75 +249,81 @@ do {                                                               \
 #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 )
+static void
+intel_draw_quad(struct intel_context *intel,
+                intelVertexPtr v0,
+                intelVertexPtr v1, intelVertexPtr v2, intelVertexPtr v3)
 {
    GLuint vertsize = intel->vertex_size;
-   GLuint *vb = intelExtendInlinePrimitive( intel, 6 * vertsize );
+   GLuint *vb = intel_get_prim_space(intel, 6);
    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 );
+   COPY_DWORDS(j, vb, vertsize, v0);
+   COPY_DWORDS(j, vb, vertsize, v1);
+
+   /* If smooth shading, draw like a trifan which gives better
+    * rasterization.  Otherwise draw as two triangles with provoking
+    * vertex in third position as required for flat shading.
+    */
+   if (intel->ctx.Light.ShadeModel == GL_FLAT) {
+      COPY_DWORDS(j, vb, vertsize, v3);
+      COPY_DWORDS(j, vb, vertsize, v1);
+   }
+   else {
+      COPY_DWORDS(j, vb, vertsize, v2);
+      COPY_DWORDS(j, vb, vertsize, v0);
+   }
+
+   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 )
+static void
+intel_draw_triangle(struct intel_context *intel,
+                    intelVertexPtr v0, intelVertexPtr v1, intelVertexPtr v2)
 {
    GLuint vertsize = intel->vertex_size;
-   GLuint *vb = intelExtendInlinePrimitive( intel, 3 * vertsize );
+   GLuint *vb = intel_get_prim_space(intel, 3);
    int j;
-   
-   COPY_DWORDS( j, vb, vertsize, v0 );
-   COPY_DWORDS( j, vb, vertsize, v1 );
-   COPY_DWORDS( j, vb, vertsize, v2 );
+
+   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 )
+static void
+intel_draw_line(struct intel_context *intel,
+                intelVertexPtr v0, intelVertexPtr v1)
 {
    GLuint vertsize = intel->vertex_size;
-   GLuint *vb = intelExtendInlinePrimitive( intel, 2 * vertsize );
+   GLuint *vb = intel_get_prim_space(intel, 2);
    int j;
 
-   COPY_DWORDS( j, vb, vertsize, v0 );
-   COPY_DWORDS( j, vb, vertsize, v1 );
+   COPY_DWORDS(j, vb, vertsize, v0);
+   COPY_DWORDS(j, vb, vertsize, v1);
 }
 
 
-static __inline__ void intel_draw_point( intelContextPtr intel,
-                                        intelVertexPtr v0 )
+static void
+intel_draw_point(struct intel_context *intel, intelVertexPtr v0)
 {
    GLuint vertsize = intel->vertex_size;
-   GLuint *vb = intelExtendInlinePrimitive( intel, vertsize );
+   GLuint *vb = intel_get_prim_space(intel, 1);
    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];
+   *(float *) &vb[0] = v0->v.x;
+   *(float *) &vb[1] = v0->v.y;
+   for (j = 2; j < vertsize; j++)
+      vb[j] = v0->ui[j];
 }
 
 
@@ -146,13 +332,17 @@ static __inline__ void intel_draw_point( intelContextPtr intel,
  *                Fixup for ARB_point_parameters                       *
  ***********************************************************************/
 
-static void intel_atten_point( intelContextPtr intel, intelVertexPtr v0 )
+/* Currently not working - VERT_ATTRIB_POINTSIZE isn't correctly
+ * represented in the fragment program InputsRead field.
+ */
+static void
+intel_atten_point(struct intel_context *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 );
+   _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];
@@ -170,19 +360,19 @@ static void intel_atten_point( intelContextPtr intel, intelVertexPtr v0 )
       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 );
+      _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);
+      _tnl_set_attr(ctx, v0, _TNL_ATTRIB_POINTSIZE, psz);
+      _tnl_set_attr(ctx, v0, _TNL_ATTRIB_COLOR0, col);
    }
    else
-      intel_draw_point( intel, v0 );
+      intel_draw_point(intel, v0);
 }
 
 
@@ -195,45 +385,59 @@ static void intel_atten_point( intelContextPtr intel, intelVertexPtr v0 )
 
 
 
-static void intel_wpos_triangle( intelContextPtr intel,
-                                intelVertexPtr v0,
-                                intelVertexPtr v1,
-                                intelVertexPtr v2 )
+static void
+intel_wpos_triangle(struct intel_context *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 );
+   GLfloat *v0_wpos = (GLfloat *)((char *)v0 + offset);
+   GLfloat *v1_wpos = (GLfloat *)((char *)v1 + offset);
+   GLfloat *v2_wpos = (GLfloat *)((char *)v2 + offset);
+
+   __memcpy(v0_wpos, v0, size);
+   __memcpy(v1_wpos, v1, size);
+   __memcpy(v2_wpos, v2, size);
+
+   v0_wpos[1] = -v0_wpos[1] + intel->driDrawable->h;
+   v1_wpos[1] = -v1_wpos[1] + intel->driDrawable->h;
+   v2_wpos[1] = -v2_wpos[1] + intel->driDrawable->h;
+
 
-   intel_draw_triangle( intel, v0, v1, v2 );
+   intel_draw_triangle(intel, v0, v1, v2);
 }
 
 
-static void intel_wpos_line( intelContextPtr intel,
-                            intelVertexPtr v0,
-                            intelVertexPtr v1 )
+static void
+intel_wpos_line(struct intel_context *intel,
+                intelVertexPtr v0, intelVertexPtr v1)
 {
    GLuint offset = intel->wpos_offset;
    GLuint size = intel->wpos_size;
+   GLfloat *v0_wpos = (GLfloat *)((char *)v0 + offset);
+   GLfloat *v1_wpos = (GLfloat *)((char *)v1 + offset);
+
+   __memcpy(v0_wpos, v0, size);
+   __memcpy(v1_wpos, v1, size);
 
-   __memcpy( ((char *)v0) + offset, v0, size );
-   __memcpy( ((char *)v1) + offset, v1, size );
+   v0_wpos[1] = -v0_wpos[1] + intel->driDrawable->h;
+   v1_wpos[1] = -v1_wpos[1] + intel->driDrawable->h;
 
-   intel_draw_line( intel, v0, v1 );
+   intel_draw_line(intel, v0, v1);
 }
 
 
-static void intel_wpos_point( intelContextPtr intel,
-                             intelVertexPtr v0 )
+static void
+intel_wpos_point(struct intel_context *intel, intelVertexPtr v0)
 {
    GLuint offset = intel->wpos_offset;
    GLuint size = intel->wpos_size;
+   GLfloat *v0_wpos = (GLfloat *)((char *)v0 + offset);
 
-   __memcpy( ((char *)v0) + offset, v0, size );
+   __memcpy(v0_wpos, v0, size);
+   v0_wpos[1] = -v0_wpos[1] + intel->driDrawable->h;
 
-   intel_draw_point( intel, v0 );
+   intel_draw_point(intel, v0);
 }
 
 
@@ -290,11 +494,12 @@ do {                                              \
 #define INTEL_MAX_TRIFUNC      0x10
 
 
-static struct {
-   tnl_points_func             points;
-   tnl_line_func               line;
-   tnl_triangle_func   triangle;
-   tnl_quad_func               quad;
+static struct
+{
+   tnl_points_func points;
+   tnl_line_func line;
+   tnl_triangle_func triangle;
+   tnl_quad_func quad;
 } rast_tab[INTEL_MAX_TRIFUNC];
 
 
@@ -355,10 +560,10 @@ do {                                                      \
 #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;                   \
+   struct intel_context *intel = intel_context(ctx);                   \
+   GLuint color[n] = { 0, }, spec[n] = { 0, };                         \
+   GLuint coloroffset = intel->coloroffset;                            \
+   GLboolean specoffset = intel->specoffset;                           \
    (void) color; (void) spec; (void) coloroffset; (void) specoffset;
 
 
@@ -366,7 +571,7 @@ do {                                                        \
  *                Helpers for rendering unfilled primitives            *
  ***********************************************************************/
 
-static const GLuint hw_prim[GL_POLYGON+1] = {
+static const GLuint hw_prim[GL_POLYGON + 1] = {
    PRIM3D_POINTLIST,
    PRIM3D_LINELIST,
    PRIM3D_LINELIST,
@@ -456,7 +661,8 @@ static const GLuint hw_prim[GL_POLYGON+1] = {
 #include "tnl_dd/t_dd_tritmp.h"
 
 
-static void init_rast_tab( void )
+static void
+init_rast_tab(void)
 {
    init();
    init_offset();
@@ -487,10 +693,8 @@ static void init_rast_tab( void )
  * primitives.
  */
 static void
-intel_fallback_tri( intelContextPtr intel,
-                  intelVertex *v0,
-                  intelVertex *v1,
-                  intelVertex *v2 )
+intel_fallback_tri(struct intel_context *intel,
+                   intelVertex * v0, intelVertex * v1, intelVertex * v2)
 {
    GLcontext *ctx = &intel->ctx;
    SWvertex v[3];
@@ -498,19 +702,20 @@ intel_fallback_tri( intelContextPtr intel,
    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 );
+   INTEL_FIREVERTICES(intel);
+
+   _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 )
+intel_fallback_line(struct intel_context *intel,
+                    intelVertex * v0, intelVertex * v1)
 {
    GLcontext *ctx = &intel->ctx;
    SWvertex v[2];
@@ -518,17 +723,18 @@ intel_fallback_line( intelContextPtr intel,
    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 );
-}
+   INTEL_FIREVERTICES(intel);
 
+   _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 )
+intel_fallback_point(struct intel_context *intel,
+                    intelVertex * v0)
 {
    GLcontext *ctx = &intel->ctx;
    SWvertex v[1];
@@ -536,12 +742,13 @@ intel_fallback_point( intelContextPtr intel,
    if (0)
       fprintf(stderr, "\n%s\n", __FUNCTION__);
 
-   _swsetup_Translate( ctx, v0, &v[0] );
-   intelSpanRenderStart( ctx );
-   _swrast_Point( ctx, &v[0] );
-   intelSpanRenderFinish( ctx );
-}
+   INTEL_FIREVERTICES(intel);
 
+   _swsetup_Translate(ctx, v0, &v[0]);
+   intelSpanRenderStart(ctx);
+   _swrast_Point(ctx, &v[0]);
+   intelSpanRenderFinish(ctx);
+}
 
 
 /**********************************************************************/
@@ -558,7 +765,7 @@ intel_fallback_point( intelContextPtr intel,
 #define INIT(x) intelRenderPrimitive( ctx, x )
 #undef LOCAL_VARS
 #define LOCAL_VARS                                             \
-    intelContextPtr intel = INTEL_CONTEXT(ctx);                        \
+    struct intel_context *intel = intel_context(ctx);                  \
     GLubyte *vertptr = (GLubyte *)intel->verts;                        \
     const GLuint vertsize = intel->vertex_size;        \
     const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts;      \
@@ -581,10 +788,10 @@ intel_fallback_point( intelContextPtr intel,
 
 
 
-static void intelRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
-                                  GLuint n )
+static void
+intelRenderClippedPoly(GLcontext * ctx, const GLuint * elts, GLuint n)
 {
-   intelContextPtr intel = INTEL_CONTEXT(ctx);
+   struct intel_context *intel = intel_context(ctx);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
    GLuint prim = intel->render_primitive;
@@ -593,39 +800,40 @@ static void intelRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
     */
    {
       GLuint *tmp = VB->Elts;
-      VB->Elts = (GLuint *)elts;
-      tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, 
-                                                 PRIM_BEGIN|PRIM_END );
+      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 );
+      tnl->Driver.Render.PrimitiveNotify(ctx, prim);
 }
 
-static void intelRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
+static void
+intelRenderClippedLine(GLcontext * ctx, GLuint ii, GLuint jj)
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
 
-   tnl->Driver.Render.Line( ctx, ii, jj );
+   tnl->Driver.Render.Line(ctx, ii, jj);
 }
 
-static void intelFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
-                                      GLuint n )
+static void
+intelFastRenderClippedPoly(GLcontext * ctx, const GLuint * elts, GLuint n)
 {
-   intelContextPtr intel = INTEL_CONTEXT( ctx );
+   struct intel_context *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 );
+   GLuint *vb = intel_get_prim_space(intel, (n - 2) * 3);
+   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);
    }
 }
 
@@ -636,68 +844,75 @@ static void intelFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
 
 
 
-#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)
+#define ANY_FALLBACK_FLAGS (DD_LINE_STIPPLE | DD_TRI_STIPPLE | DD_POINT_ATTEN | DD_POINT_SMOOTH | DD_TRI_SMOOTH)
+#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE | DD_TRI_OFFSET | DD_TRI_UNFILLED)
 
-void intelChooseRenderState(GLcontext *ctx)
+void
+intelChooseRenderState(GLcontext * ctx)
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
-   intelContextPtr intel = INTEL_CONTEXT(ctx);
+   struct intel_context *intel = intel_context(ctx);
    GLuint flags = ctx->_TriangleCaps;
    const struct gl_fragment_program *fprog = ctx->FragmentProgram._Current;
    GLboolean have_wpos = (fprog && (fprog->Base.InputsRead & FRAG_BIT_WPOS));
    GLuint index = 0;
 
    if (INTEL_DEBUG & DEBUG_STATE)
-     fprintf(stderr,"\n%s\n",__FUNCTION__);
+      fprintf(stderr, "\n%s\n", __FUNCTION__);
 
-   if ((flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS)) || have_wpos) {
+   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 (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;
+         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;
+         /* 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;
+         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 (flags & ANY_FALLBACK_FLAGS) {
+         if (flags & DD_LINE_STIPPLE)
+            intel->draw_line = intel_fallback_line;
+
+         if ((flags & DD_TRI_STIPPLE) && !intel->hw_stipple)
+            intel->draw_tri = intel_fallback_tri;
+
+         if (flags & DD_TRI_SMOOTH) {
+           if (intel->strict_conformance)
+              intel->draw_tri = intel_fallback_tri;
+        }
+
+         if (flags & DD_POINT_ATTEN) {
+           if (0)
+              intel->draw_point = intel_atten_point;
+           else
+              intel->draw_point = intel_fallback_point;
+        }
+
+        if (flags & DD_POINT_SMOOTH) {
+           if (intel->strict_conformance)
+              intel->draw_point = intel_fallback_point;
+        }
+
+         index |= INTEL_FALLBACK_BIT;
       }
    }
 
@@ -710,20 +925,21 @@ void intelChooseRenderState(GLcontext *ctx)
       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;
+         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] = {
+static const GLenum reduced_prim[GL_POLYGON + 1] = {
    GL_POINTS,
    GL_LINES,
    GL_LINES,
@@ -744,35 +960,52 @@ static const GLenum reduced_prim[GL_POLYGON+1] = {
 
 
 
-static void intelRunPipeline( GLcontext *ctx )
+static void
+intelRunPipeline(GLcontext * ctx)
 {
-   intelContextPtr intel = INTEL_CONTEXT(ctx);
+   struct intel_context *intel = intel_context(ctx);
+
+   _mesa_lock_context_textures(ctx);
+   
+   if (ctx->NewState)
+      _mesa_update_state_locked(ctx);
 
    if (intel->NewGLState) {
       if (intel->NewGLState & _NEW_TEXTURE) {
-        intel->vtbl.update_texture_state( intel ); 
+         intel->vtbl.update_texture_state(intel);
       }
 
       if (!intel->Fallback) {
-        if (intel->NewGLState & _INTEL_NEW_RENDERSTATE)
-           intelChooseRenderState( ctx );
+         if (intel->NewGLState & _INTEL_NEW_RENDERSTATE)
+            intelChooseRenderState(ctx);
       }
 
       intel->NewGLState = 0;
    }
 
-   _tnl_run_pipeline( ctx );
+   _tnl_run_pipeline(ctx);
+
+   _mesa_unlock_context_textures(ctx);
 }
 
-static void intelRenderStart( GLcontext *ctx )
+static void
+intelRenderStart(GLcontext * ctx)
 {
-   INTEL_CONTEXT(ctx)->vtbl.render_start( INTEL_CONTEXT(ctx) );
+   struct intel_context *intel = intel_context(ctx);
+
+   intel->vtbl.render_start(intel_context(ctx));
+   intel->vtbl.emit_state(intel);
 }
 
-static void intelRenderFinish( GLcontext *ctx )
+static void
+intelRenderFinish(GLcontext * ctx)
 {
-   if (INTEL_CONTEXT(ctx)->RenderIndex & INTEL_FALLBACK_BIT)
-      _swrast_flush( ctx );
+   struct intel_context *intel = intel_context(ctx);
+
+   if (intel->RenderIndex & INTEL_FALLBACK_BIT)
+      _swrast_flush(ctx);
+
+   INTEL_FIREVERTICES(intel);
 }
 
 
@@ -781,28 +1014,33 @@ static void intelRenderFinish( GLcontext *ctx )
  /* System to flush dma and emit state changes based on the rasterized
   * primitive.
   */
-static void intelRasterPrimitive( GLcontext *ctx, GLenum rprim, GLuint hwprim )
+static void
+intelRasterPrimitive(GLcontext * ctx, GLenum rprim, GLuint hwprim)
 {
-   intelContextPtr intel = INTEL_CONTEXT(ctx);
+   struct intel_context *intel = intel_context(ctx);
 
    if (0)
-      fprintf(stderr, "%s %s %x\n", __FUNCTION__, 
-             _mesa_lookup_enum_by_nr(rprim), hwprim);
+      fprintf(stderr, "%s %s %x\n", __FUNCTION__,
+              _mesa_lookup_enum_by_nr(rprim), hwprim);
+
+   intel->vtbl.reduced_primitive_state(intel, rprim);
 
-   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 );
+   if (hwprim != intel->prim.primitive) {
+      INTEL_FIREVERTICES(intel);
+
+      intel_set_prim(intel, hwprim);
+   }
 }
 
 
-/* 
- */
-static void intelRenderPrimitive( GLcontext *ctx, GLenum prim )
+ /* 
+  */
+static void
+intelRenderPrimitive(GLcontext * ctx, GLenum prim)
 {
-   intelContextPtr intel = INTEL_CONTEXT(ctx);
+   struct intel_context *intel = intel_context(ctx);
 
    if (0)
       fprintf(stderr, "%s %s\n", __FUNCTION__, _mesa_lookup_enum_by_nr(prim));
@@ -817,63 +1055,54 @@ static void intelRenderPrimitive( GLcontext *ctx, GLenum prim )
     * lower level functions in that case, potentially pingponging the
     * state:
     */
-   if (reduced_prim[prim] == GL_TRIANGLES && 
+   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] );
+   intelRasterPrimitive(ctx, reduced_prim[prim], hw_prim[prim]);
 }
 
 
-/**********************************************************************/
-/*           Transition to/from hardware rasterization.               */
-/**********************************************************************/
-
-static struct {
-   GLuint bit;
-   const char *str;
-} fallbackStrings[] = {
-   { INTEL_FALLBACK_DRAW_BUFFER, "Draw buffer" },
-   { INTEL_FALLBACK_READ_BUFFER, "Read buffer" },
-   { INTEL_FALLBACK_USER, "User" },
-   { INTEL_FALLBACK_NO_BATCHBUFFER, "No Batchbuffer" },
-   { INTEL_FALLBACK_NO_TEXMEM, "No Texmem" },
-   { INTEL_FALLBACK_RENDERMODE, "Rendermode" },
-
-   { I830_FALLBACK_TEXTURE, "i830 texture" },
-   { I830_FALLBACK_COLORMASK, "i830 colormask" },
-   { I830_FALLBACK_STENCIL, "i830 stencil" },
-   { I830_FALLBACK_STIPPLE, "i830 stipple" },
-   { I830_FALLBACK_LOGICOP, "i830 logicop" },
-
-   { I915_FALLBACK_TEXTURE, "i915 texture" },
-   { I915_FALLBACK_COLORMASK, "i915 colormask" },
-   { I915_FALLBACK_STENCIL, "i915 stencil" },
-   { I915_FALLBACK_STIPPLE, "i915 stipple" },
-   { I915_FALLBACK_PROGRAM, "i915 program" },
-   { I915_FALLBACK_LOGICOP, "i915 logicop" },
-   { I915_FALLBACK_POLYGON_SMOOTH, "i915 polygon smooth" },
-   { I915_FALLBACK_POINT_SMOOTH, "i915 point smooth" },
-
-   { 0, NULL }
+ /**********************************************************************/
+ /*           Transition to/from hardware rasterization.               */
+ /**********************************************************************/
+
+static char *fallbackStrings[] = {
+   [0] = "Draw buffer",
+   [1] = "Read buffer",
+   [2] = "Depth buffer",
+   [3] = "Stencil buffer",
+   [4] = "User disable",
+   [5] = "Render mode",
+
+   [12] = "Texture",
+   [13] = "Color mask",
+   [14] = "Stencil",
+   [15] = "Stipple",
+   [16] = "Program",
+   [17] = "Logic op",
+   [18] = "Smooth polygon",
+   [19] = "Smooth point",
 };
 
 
-static const char *
+static char *
 getFallbackString(GLuint bit)
 {
-   int i;
-   for (i = 0; fallbackStrings[i].bit; i++) {
-      if (fallbackStrings[i].bit == bit)
-         return fallbackStrings[i].str;
+   int i = 0;
+   while (bit > 1) {
+      i++;
+      bit >>= 1;
    }
-   return "unknown fallback bit";
+   return fallbackStrings[i];
 }
 
 
-void intelFallback( intelContextPtr intel, GLuint bit, GLboolean mode )
+
+void
+intelFallback(struct intel_context *intel, GLuint bit, GLboolean mode)
 {
    GLcontext *ctx = &intel->ctx;
    TNLcontext *tnl = TNL_CONTEXT(ctx);
@@ -883,20 +1112,19 @@ void intelFallback( intelContextPtr intel, GLuint bit, GLboolean mode )
       intel->Fallback |= bit;
       if (oldfallback == 0) {
          intelFlush(ctx);
-         if (INTEL_DEBUG & DEBUG_FALLBACKS) 
-            fprintf(stderr, "ENTER FALLBACK 0x%x: %s\n",
+         if (INTEL_DEBUG & DEBUG_FALLBACKS)
+            fprintf(stderr, "ENTER FALLBACK %x: %s\n",
                     bit, getFallbackString(bit));
-         _swsetup_Wakeup( ctx );
+         _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 0x%x: %s\n",
-                    bit, getFallbackString(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;
@@ -904,18 +1132,99 @@ void intelFallback( intelContextPtr intel, GLuint bit, GLboolean mode )
          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 ); 
+         _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;
       }
    }
 }
 
+union fi
+{
+   GLfloat f;
+   GLint i;
+};
+
+
+/**********************************************************************/
+/*             Used only with the metaops callbacks.                  */
+/**********************************************************************/
+static void
+intel_meta_draw_poly(struct intel_context *intel,
+                     GLuint n,
+                     GLfloat xy[][2],
+                     GLfloat z, GLuint color, GLfloat tex[][2])
+{
+   union fi *vb;
+   GLint i;
+   GLboolean was_locked = intel->locked;
+   unsigned int saved_vertex_size = intel->vertex_size;
+
+   if (!was_locked)
+       LOCK_HARDWARE(intel);
+
+   intel->vertex_size = 6;
+
+   /* All 3d primitives should be emitted with LOOP_CLIPRECTS,
+    * otherwise the drawing origin (DR4) might not be set correctly.
+    */
+   intel_set_prim(intel, PRIM3D_TRIFAN);
+   vb = (union fi *) intel_get_prim_space(intel, n);
+
+   for (i = 0; i < n; i++) {
+      vb[0].f = xy[i][0];
+      vb[1].f = xy[i][1];
+      vb[2].f = z;
+      vb[3].i = color;
+      vb[4].f = tex[i][0];
+      vb[5].f = tex[i][1];
+      vb += 6;
+   }
+
+   INTEL_FIREVERTICES(intel);
+
+   intel->vertex_size = saved_vertex_size;
+
+   if (!was_locked)
+       UNLOCK_HARDWARE(intel);
+}
+
+static void
+intel_meta_draw_quad(struct intel_context *intel,
+                     GLfloat x0, GLfloat x1,
+                     GLfloat y0, GLfloat y1,
+                     GLfloat z,
+                     GLuint color,
+                     GLfloat s0, GLfloat s1, GLfloat t0, GLfloat t1)
+{
+   GLfloat xy[4][2];
+   GLfloat tex[4][2];
+
+   xy[0][0] = x0;
+   xy[0][1] = y0;
+   xy[1][0] = x1;
+   xy[1][1] = y0;
+   xy[2][0] = x1;
+   xy[2][1] = y1;
+   xy[3][0] = x0;
+   xy[3][1] = y1;
+
+   tex[0][0] = s0;
+   tex[0][1] = t0;
+   tex[1][0] = s1;
+   tex[1][1] = t0;
+   tex[2][0] = s1;
+   tex[2][1] = t1;
+   tex[3][0] = s0;
+   tex[3][1] = t1;
+
+   intel_meta_draw_poly(intel, 4, xy, z, color, tex);
+}
 
 
 
@@ -924,8 +1233,10 @@ void intelFallback( intelContextPtr intel, GLuint bit, GLboolean mode )
 /**********************************************************************/
 
 
-void intelInitTriFuncs( GLcontext *ctx )
+void
+intelInitTriFuncs(GLcontext * ctx)
 {
+   struct intel_context *intel = intel_context(ctx);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    static int firsttime = 1;
 
@@ -942,4 +1253,6 @@ void intelInitTriFuncs( GLcontext *ctx )
    tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
    tnl->Driver.Render.CopyPV = _tnl_copy_pv;
    tnl->Driver.Render.Interp = _tnl_interp;
+
+   intel->vtbl.meta_draw_quad = intel_meta_draw_quad;
 }
index d7e382fdb3e231c69269ca949d4378222984e34d..0e08986221f61a907a41d091dada762e651ef85e 100644 (file)
 
 #include "mtypes.h"
 
+#define INTEL_VB_SIZE          (32 * 1024)
+/** 3 dwords of state_immediate and 2 of 3dprim, in intel_flush_prim */
+#define INTEL_PRIM_EMIT_SIZE   (5 * 4)
+
 #define _INTEL_NEW_RENDERSTATE (_DD_NEW_LINE_STIPPLE |         \
                               _DD_NEW_TRI_UNFILLED |           \
                               _DD_NEW_TRI_LIGHT_TWOSIDE |      \
                               _NEW_PROGRAM |           \
                               _NEW_POLYGONSTIPPLE)
 
-extern void intelInitTriFuncs( GLcontext *ctx );
+extern void intelInitTriFuncs(GLcontext * ctx);
+
+extern void intelChooseRenderState(GLcontext * ctx);
 
-extern void intelPrintRenderState( const char *msg, GLuint state );
-extern void intelChooseRenderState( GLcontext *ctx );
+void intel_set_prim(struct intel_context *intel, uint32_t prim);
+GLuint *intel_get_prim_space(struct intel_context *intel, unsigned int count);
+void intel_flush_prim(struct intel_context *intel);
+void intel_finish_vb(struct intel_context *intel);
 
 #endif
diff --git a/src/mesa/drivers/dri/i915/server/intel.h b/src/mesa/drivers/dri/i915/server/intel.h
deleted file mode 100644 (file)
index d7858a2..0000000
+++ /dev/null
@@ -1,328 +0,0 @@
-#ifndef _INTEL_H_
-#define _INTEL_H_
-
-#include "xf86drm.h"           /* drm_handle_t, etc */
-
-/* Intel */
-#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
-#define PCI_CHIP_I810_BRIDGE       0x7120
-#define PCI_CHIP_I810_DC100_BRIDGE 0x7122
-#define PCI_CHIP_I810_E_BRIDGE     0x7124
-#define PCI_CHIP_I815_BRIDGE       0x1130
-#endif
-
-#define PCI_CHIP_845_G                 0x2562
-#define PCI_CHIP_I830_M                        0x3577
-
-#ifndef PCI_CHIP_I855_GM
-#define PCI_CHIP_I855_GM          0x3582
-#define PCI_CHIP_I855_GM_BRIDGE           0x3580
-#endif
-
-#ifndef PCI_CHIP_I865_G
-#define PCI_CHIP_I865_G                   0x2572
-#define PCI_CHIP_I865_G_BRIDGE    0x2570
-#endif
-
-#ifndef PCI_CHIP_I915_G
-#define PCI_CHIP_I915_G                   0x2582
-#define PCI_CHIP_I915_G_BRIDGE    0x2580
-#endif
-
-#ifndef PCI_CHIP_I915_GM
-#define PCI_CHIP_I915_GM          0x2592
-#define PCI_CHIP_I915_GM_BRIDGE           0x2590
-#endif
-
-#ifndef PCI_CHIP_E7221_G
-#define PCI_CHIP_E7221_G          0x258A
-/* Same as I915_G_BRIDGE */
-#define PCI_CHIP_E7221_G_BRIDGE           0x2580
-#endif
-
-#ifndef PCI_CHIP_I945_G
-#define PCI_CHIP_I945_G        0x2772
-#define PCI_CHIP_I945_G_BRIDGE 0x2770
-#endif
-
-#ifndef PCI_CHIP_I945_GM
-#define PCI_CHIP_I945_GM        0x27A2
-#define PCI_CHIP_I945_GM_BRIDGE 0x27A0
-#endif
-
-#define IS_I810(pI810) (pI810->Chipset == PCI_CHIP_I810 ||     \
-                       pI810->Chipset == PCI_CHIP_I810_DC100 || \
-                       pI810->Chipset == PCI_CHIP_I810_E)
-#define IS_I815(pI810) (pI810->Chipset == PCI_CHIP_I815)
-#define IS_I830(pI810) (pI810->Chipset == PCI_CHIP_I830_M)
-#define IS_845G(pI810) (pI810->Chipset == PCI_CHIP_845_G)
-#define IS_I85X(pI810)  (pI810->Chipset == PCI_CHIP_I855_GM)
-#define IS_I852(pI810)  (pI810->Chipset == PCI_CHIP_I855_GM && (pI810->variant == I852_GM || pI810->variant == I852_GME))
-#define IS_I855(pI810)  (pI810->Chipset == PCI_CHIP_I855_GM && (pI810->variant == I855_GM || pI810->variant == I855_GME))
-#define IS_I865G(pI810) (pI810->Chipset == PCI_CHIP_I865_G)
-
-#define IS_I915G(pI810) (pI810->Chipset == PCI_CHIP_I915_G || pI810->Chipset == PCI_CHIP_E7221_G)
-#define IS_I915GM(pI810) (pI810->Chipset == PCI_CHIP_I915_GM)
-#define IS_I945G(pI810) (pI810->Chipset == PCI_CHIP_I945_G)
-#define IS_I945GM(pI810) (pI810->Chipset == PCI_CHIP_I945_GM)
-#define IS_I9XX(pI810) (IS_I915G(pI810) || IS_I915GM(pI810) || IS_I945G(pI810) || IS_I945GM(pI810))
-
-#define IS_MOBILE(pI810) (IS_I830(pI810) || IS_I85X(pI810) || IS_I915GM(pI810) || IS_I945GM(pI810))
-
-#define I830_GMCH_CTRL         0x52
-
-
-#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 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 I915G_GMCH_GMS_STOLEN_48M              (0x6 << 4)
-#define I915G_GMCH_GMS_STOLEN_64M              (0x7 << 4)
-
-typedef unsigned char Bool;
-#define TRUE 1
-#define FALSE 0
-
-#define PIPE_NONE      0<<0
-#define PIPE_CRT       1<<0
-#define PIPE_TV                1<<1
-#define PIPE_DFP       1<<2
-#define PIPE_LFP       1<<3
-#define PIPE_CRT2      1<<4
-#define PIPE_TV2       1<<5
-#define PIPE_DFP2      1<<6
-#define PIPE_LFP2      1<<7
-
-typedef struct _I830MemPool *I830MemPoolPtr;
-typedef struct _I830MemRange *I830MemRangePtr;
-typedef struct _I830MemRange {
-   long Start;
-   long End;
-   long Size;
-   unsigned long Physical;
-   unsigned long Offset;               /* Offset of AGP-allocated portion */
-   unsigned long Alignment;
-   drm_handle_t Key;
-   unsigned long Pitch; // add pitch
-   I830MemPoolPtr Pool;
-} I830MemRange;
-
-typedef struct _I830MemPool {
-   I830MemRange Total;
-   I830MemRange Free;
-   I830MemRange Fixed;
-   I830MemRange Allocated;
-} I830MemPool;
-
-typedef struct {
-   int tail_mask;
-   I830MemRange mem;
-   unsigned char *virtual_start;
-   int head;
-   int tail;
-   int space;
-} I830RingBuffer;
-
-typedef struct _I830Rec {
-   unsigned char *MMIOBase;
-   unsigned char *FbBase;
-   int cpp;
-
-   unsigned int bios_version;
-
-   /* These are set in PreInit and never changed. */
-   long FbMapSize;
-   long TotalVideoRam;
-   I830MemRange StolenMemory;          /* pre-allocated memory */
-   long BIOSMemorySize;                        /* min stolen pool size */
-   int BIOSMemSizeLoc;
-
-   /* These change according to what has been allocated. */
-   long FreeMemory;
-   I830MemRange MemoryAperture;
-   I830MemPool StolenPool;
-   long allocatedMemory;
-
-   /* Regions allocated either from the above pools, or from agpgart. */
-   /* for single and dual head configurations */
-   I830MemRange FrontBuffer;
-   I830MemRange FrontBuffer2;
-   I830MemRange Scratch;
-   I830MemRange Scratch2;
-
-   I830RingBuffer *LpRing;
-
-   I830MemRange BackBuffer;
-   I830MemRange DepthBuffer;
-   I830MemRange TexMem;
-   int TexGranularity;
-   I830MemRange ContextMem;
-   int drmMinor;
-   Bool have3DWindows;
-
-   Bool NeedRingBufferLow;
-   Bool allowPageFlip;
-   Bool disableTiling;
-
-   int Chipset;
-   unsigned long LinearAddr;
-   unsigned long MMIOAddr;
-
-   drmSize           registerSize;     /**< \brief MMIO register map size */
-   drm_handle_t         registerHandle;   /**< \brief MMIO register map handle */
-  //   IOADDRESS ioBase;
-   int               irq;              /**< \brief IRQ number */
-   int GttBound;
-
-   drm_handle_t ring_map;
-   unsigned int Fence[8];
-
-} I830Rec;
-
-/*
- * 12288 is set as the maximum, chosen because it is enough for
- * 1920x1440@32bpp with a 2048 pixel line pitch with some to spare.
- */
-#define I830_MAXIMUM_VBIOS_MEM         12288
-#define I830_DEFAULT_VIDEOMEM_2D       (MB(32) / 1024)
-#define I830_DEFAULT_VIDEOMEM_3D       (MB(64) / 1024)
-
-/* Flags for memory allocation function */
-#define FROM_ANYWHERE                  0x00000000
-#define FROM_POOL_ONLY                 0x00000001
-#define FROM_NEW_ONLY                  0x00000002
-#define FROM_MASK                      0x0000000f
-
-#define ALLOCATE_AT_TOP                        0x00000010
-#define ALLOCATE_AT_BOTTOM             0x00000020
-#define FORCE_GAPS                     0x00000040
-
-#define NEED_PHYSICAL_ADDR             0x00000100
-#define ALIGN_BOTH_ENDS                        0x00000200
-#define FORCE_LOW                      0x00000400
-
-#define ALLOC_NO_TILING                        0x00001000
-#define ALLOC_INITIAL                  0x00002000
-
-#define ALLOCATE_DRY_RUN               0x80000000
-
-/* Chipset registers for VIDEO BIOS memory RW access */
-#define _855_DRAM_RW_CONTROL 0x58
-#define _845_DRAM_RW_CONTROL 0x90
-#define DRAM_WRITE    0x33330000
-
-#define KB(x) ((x) * 1024)
-#define MB(x) ((x) * KB(1024))
-
-#define GTT_PAGE_SIZE                  KB(4)
-#define ROUND_TO(x, y)                 (((x) + (y) - 1) / (y) * (y))
-#define ROUND_DOWN_TO(x, y)            ((x) / (y) * (y))
-#define ROUND_TO_PAGE(x)               ROUND_TO((x), GTT_PAGE_SIZE)
-#define ROUND_TO_MB(x)                 ROUND_TO((x), MB(1))
-#define PRIMARY_RINGBUFFER_SIZE                KB(128)
-
-
-/* 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          0x03FFFFF8
-#define I830_RING_START_MASK   0xFFFFF000
-
-#define RING_LEN       0x0C
-#define RING_NR_PAGES       0x001FF000 
-#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
-
-
-/* Fence/Tiling ranges [0..7]
- */
-#define FENCE            0x2000
-#define FENCE_NR         8
-
-#define I915G_FENCE_START_MASK 0x0ff00000
-
-#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 I915G_FENCE_SIZE_1M       0x00000000
-#define I915G_FENCE_SIZE_2M       0x00000100
-#define I915G_FENCE_SIZE_4M       0x00000200
-#define I915G_FENCE_SIZE_8M       0x00000300
-#define I915G_FENCE_SIZE_16M      0x00000400
-#define I915G_FENCE_SIZE_32M      0x00000500
-#define I915G_FENCE_SIZE_64M   0x00000600
-#define I915G_FENCE_SIZE_128M  0x00000700
-#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
-
-#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(MMIO, addr)
-#define INREG(addr)         MMIO_IN32(MMIO, addr)
-#define OUTREG8(addr, val)  MMIO_OUT8(MMIO, addr, val)
-#define OUTREG(addr, val)   MMIO_OUT32(MMIO, addr, val)
-
-#define DSPABASE               0x70184
-
-#endif
deleted file mode 100644 (file)
index b6946b75d20bc213a6544ab83caa71f3b6e0cb6f..0000000000000000000000000000000000000000
+++ /dev/null
-/**
- * \file server/intel_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) 2006 Dave Airlie (airlied@linux.ie)
-
- Permission is hereby granted, free of charge, to any person obtaining a
- copy of this software and 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 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-
-#include "driver.h"
-#include "drm.h"
-
-#include "intel.h"
-#include "i830_dri.h"
-
-#include "memops.h"
-#include "pciaccess.h"
-
-static size_t drm_page_size;
-static int nextTile = 0;
-#define xf86DrvMsg(...) do {} while(0)
-
-static const int pitches[] = {
-  128 * 8,
-  128 * 16,
-  128 * 32,
-  128 * 64,
-  0
-};
-
-static Bool I830DRIDoMappings(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea);
-
-static unsigned long
-GetBestTileAlignment(unsigned long size)
-{
-   unsigned long i;
-
-   for (i = KB(512); i < size; i <<= 1)
-      ;
-
-   if (i > MB(64))
-      i = MB(64);
-
-   return i;
-}
-
-static void SetFenceRegs(const DRIDriverContext *ctx, I830Rec *pI830)
-{
-  int i;
-  unsigned char *MMIO = ctx->MMIOAddress;
-
-  for (i = 0; i < 8; i++) {
-    OUTREG(FENCE + i * 4, pI830->Fence[i]);
-    //    if (I810_DEBUG & DEBUG_VERBOSE_VGA)
-    fprintf(stderr,"Fence Register : %x\n", pI830->Fence[i]);
-  }
-}
-
-/* Tiled memory is good... really, really good...
- *
- * Need to make it less likely that we miss out on this - probably
- * need to move the frontbuffer away from the 'guarenteed' alignment
- * of the first memory segment, or perhaps allocate a discontigous
- * framebuffer to get more alignment 'sweet spots'.
- */
-static void
-SetFence(const DRIDriverContext *ctx, I830Rec *pI830,
-        int nr, unsigned int start, unsigned int pitch,
-         unsigned int size)
-{
-   unsigned int val;
-   unsigned int fence_mask = 0;
-   unsigned int fence_pitch;
-
-   if (nr < 0 || nr > 7) {
-      fprintf(stderr,
-                "SetFence: fence %d out of range\n",nr);
-      return;
-   }
-
-   pI830->Fence[nr] = 0;
-
-   if (IS_I9XX(pI830))
-       fence_mask = ~I915G_FENCE_START_MASK;
-   else
-       fence_mask = ~I830_FENCE_START_MASK;
-
-   if (start & fence_mask) {
-      fprintf(stderr,
-                "SetFence: %d: start (0x%08x) is not %s aligned\n",
-                nr, start, (IS_I9XX(pI830)) ? "1MB" : "512k");
-      return;
-   }
-
-   if (start % size) {
-      fprintf(stderr,
-                "SetFence: %d: start (0x%08x) is not size (%dk) aligned\n",
-                nr, start, size / 1024);
-      return;
-   }
-
-   if (pitch & 127) {
-      fprintf(stderr,
-                "SetFence: %d: pitch (%d) not a multiple of 128 bytes\n",
-                nr, pitch);
-      return;
-   }
-
-   val = (start | FENCE_X_MAJOR | FENCE_VALID);
-
-   if (IS_I9XX(pI830)) {
-       switch (size) {
-          case MB(1):
-               val |= I915G_FENCE_SIZE_1M;
-               break;
-          case MB(2):
-               val |= I915G_FENCE_SIZE_2M;
-               break;
-          case MB(4):
-               val |= I915G_FENCE_SIZE_4M;
-               break;
-          case MB(8):
-               val |= I915G_FENCE_SIZE_8M;
-               break;
-          case MB(16):
-               val |= I915G_FENCE_SIZE_16M;
-               break;
-          case MB(32):
-               val |= I915G_FENCE_SIZE_32M;
-               break;
-          case MB(64):
-               val |= I915G_FENCE_SIZE_64M;
-               break;
-          default:
-               fprintf(stderr,
-                "SetFence: %d: illegal size (%d kByte)\n", nr, size / 1024);
-               return;
-       }
-    } else {
-       switch (size) {
-          case KB(512):
-               val |= FENCE_SIZE_512K;
-               break;
-          case MB(1):
-               val |= FENCE_SIZE_1M;
-               break;
-          case MB(2):
-               val |= FENCE_SIZE_2M;
-               break;
-          case MB(4):
-               val |= FENCE_SIZE_4M;
-               break;
-          case MB(8):
-               val |= FENCE_SIZE_8M;
-               break;
-          case MB(16):
-               val |= FENCE_SIZE_16M;
-               break;
-          case MB(32):
-               val |= FENCE_SIZE_32M;
-               break;
-          case MB(64):
-               val |= FENCE_SIZE_64M;
-               break;
-          default:
-               fprintf(stderr,
-                "SetFence: %d: illegal size (%d kByte)\n", nr, size / 1024);
-               return;
-       }
-   }
-
-   if (IS_I9XX(pI830))
-       fence_pitch = pitch / 512;
-   else
-       fence_pitch = pitch / 128;
-
-   switch (fence_pitch) {
-   case 1:
-      val |= FENCE_PITCH_1;
-      break;
-   case 2:
-      val |= FENCE_PITCH_2;
-      break;
-   case 4:
-      val |= FENCE_PITCH_4;
-      break;
-   case 8:
-      val |= FENCE_PITCH_8;
-      break;
-   case 16:
-      val |= FENCE_PITCH_16;
-      break;
-   case 32:
-      val |= FENCE_PITCH_32;
-      break;
-   case 64:
-      val |= FENCE_PITCH_64;
-      break;
-   default:
-      fprintf(stderr,
-                "SetFence: %d: illegal pitch (%d)\n", nr, pitch);
-      return;
-   }
-
-   pI830->Fence[nr] = val;
-}
-
-static Bool
-MakeTiles(const DRIDriverContext *ctx, I830Rec *pI830, I830MemRange *pMem)
-{
-   int pitch, ntiles, i;
-
-   pitch = pMem->Pitch * ctx->cpp;
-   /*
-    * Simply try to break the region up into at most four pieces of size
-    * equal to the alignment.
-    */
-   ntiles = ROUND_TO(pMem->Size, pMem->Alignment) / pMem->Alignment;
-   if (ntiles >= 4) {
-      return FALSE;
-   }
-
-   for (i = 0; i < ntiles; i++, nextTile++) {
-     SetFence(ctx, pI830, nextTile, pMem->Start + i * pMem->Alignment,
-              pitch, pMem->Alignment);
-   }
-   return TRUE;
-}
-
-static void I830SetupMemoryTiling(const DRIDriverContext *ctx, I830Rec *pI830)
-{
-  int i;
-
-  /* Clear out */
-  for (i = 0; i < 8; i++)
-    pI830->Fence[i] = 0;
-  
-  nextTile = 0;
-
-  if (pI830->BackBuffer.Alignment >= KB(512)) {
-    if (MakeTiles(ctx, pI830, &(pI830->BackBuffer))) {
-      fprintf(stderr,
-                "Activating tiled memory for the back buffer.\n");
-    } else {
-      fprintf(stderr,
-                "MakeTiles failed for the back buffer.\n");
-      pI830->allowPageFlip = FALSE;
-    }
-  }
-  
-  if (pI830->DepthBuffer.Alignment >= KB(512)) {
-    if (MakeTiles(ctx, pI830, &(pI830->DepthBuffer))) {
-      fprintf(stderr,
-                "Activating tiled memory for the depth buffer.\n");
-    } else {
-      fprintf(stderr,
-                "MakeTiles failed for the depth buffer.\n");
-    }
-  }
-
-  return;
-}
-
-static int I830DetectMemory(const DRIDriverContext *ctx, I830Rec *pI830)
-{
-  struct pci_device host_bridge;
-  uint32_t gmch_ctrl;
-  int memsize = 0;
-  int range;
-
-  memset(&host_bridge, 0, sizeof(host_bridge));
-
-  pci_device_cfg_read_u32(&host_bridge, &gmch_ctrl, I830_GMCH_CTRL);
-  
-  /* We need to reduce the stolen size, by the GTT and the popup.
-   * The GTT varying according the the FbMapSize and the popup is 4KB */
-  range = (ctx->shared.fbSize / (1024*1024)) + 4;
-
-   if (IS_I85X(pI830) || IS_I865G(pI830) || IS_I9XX(pI830)) {
-      switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
-      case I855_GMCH_GMS_STOLEN_1M:
-        memsize = MB(1) - KB(range);
-        break;
-      case I855_GMCH_GMS_STOLEN_4M:
-        memsize = MB(4) - KB(range);
-        break;
-      case I855_GMCH_GMS_STOLEN_8M:
-        memsize = MB(8) - KB(range);
-        break;
-      case I855_GMCH_GMS_STOLEN_16M:
-        memsize = MB(16) - KB(range);
-        break;
-      case I855_GMCH_GMS_STOLEN_32M:
-        memsize = MB(32) - KB(range);
-        break;
-      case I915G_GMCH_GMS_STOLEN_48M:
-        if (IS_I9XX(pI830))
-           memsize = MB(48) - KB(range);
-        break;
-      case I915G_GMCH_GMS_STOLEN_64M:
-        if (IS_I9XX(pI830))
-           memsize = MB(64) - KB(range);
-        break;
-      }
-   } else {
-      switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
-      case I830_GMCH_GMS_STOLEN_512:
-        memsize = KB(512) - KB(range);
-        break;
-      case I830_GMCH_GMS_STOLEN_1024:
-        memsize = MB(1) - KB(range);
-        break;
-      case I830_GMCH_GMS_STOLEN_8192:
-        memsize = MB(8) - KB(range);
-        break;
-      case I830_GMCH_GMS_LOCAL:
-        memsize = 0;
-        xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-                   "Local memory found, but won't be used.\n");
-        break;
-      }
-   }
-   if (memsize > 0) {
-     fprintf(stderr,
-                "detected %d kB stolen memory.\n", memsize / 1024);
-   } else {
-     fprintf(stderr,
-                "no video memory detected.\n");
-   }
-   return memsize;
-}
-
-static int AgpInit(const DRIDriverContext *ctx, I830Rec *info)
-{
-  unsigned long mode = 0x4;
-
-  if (drmAgpAcquire(ctx->drmFD) < 0) {
-    fprintf(stderr, "[gart] AGP not available\n");
-    return 0;
-  }
-  
-  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);
-
-  return 1;
-}
-
-/*
- * Allocate memory from the given pool.  Grow the pool if needed and if
- * possible.
- */
-static unsigned long
-AllocFromPool(const DRIDriverContext *ctx, I830Rec *pI830, 
-             I830MemRange *result, I830MemPool *pool,
-             long size, unsigned long alignment, int flags)
-{
-   long needed, start, end;
-
-   if (!result || !pool || !size)
-      return 0;
-
-   /* Calculate how much space is needed. */
-   if (alignment <= GTT_PAGE_SIZE)
-      needed = size;
-   else {
-        start = ROUND_TO(pool->Free.Start, alignment);
-        end = ROUND_TO(start + size, alignment);
-        needed = end - pool->Free.Start;
-   }
-   if (needed > pool->Free.Size) {
-     return 0;
-   }
-
-   result->Start = ROUND_TO(pool->Free.Start, alignment);
-   pool->Free.Start += needed;
-   result->End = pool->Free.Start;
-
-   pool->Free.Size = pool->Free.End - pool->Free.Start;
-   result->Size = result->End - result->Start;
-   result->Pool = pool;
-   result->Alignment = alignment;
-   return needed;
-}
-
-static unsigned long AllocFromAGP(const DRIDriverContext *ctx, I830Rec *pI830, long size, unsigned long alignment, I830MemRange  *result)
-{
-   unsigned long start, end;
-   unsigned long newApStart, newApEnd;
-   int ret;
-   if (!result || !size)
-      return 0;
-   
-   if (!alignment)
-     alignment = 4;
-
-   start = ROUND_TO(pI830->MemoryAperture.Start, alignment);
-   end = ROUND_TO(start + size, alignment);
-   newApStart = end;
-   newApEnd = pI830->MemoryAperture.End;
-
-   ret=drmAgpAlloc(ctx->drmFD, size, 0, &(result->Physical), (drm_handle_t *)&(result->Key));
-   
-   if (ret)
-   {
-     fprintf(stderr,"drmAgpAlloc failed %d\n", ret);
-     return 0;
-   }
-   pI830->allocatedMemory += size;
-   pI830->MemoryAperture.Start = newApStart;
-   pI830->MemoryAperture.End = newApEnd;
-   pI830->MemoryAperture.Size = newApEnd - newApStart;
-   //   pI830->FreeMemory -= size;
-   result->Start = start;
-   result->End = start + size;
-   result->Size = size;
-   result->Offset = start;
-   result->Alignment = alignment;
-   result->Pool = NULL;
-  
-   return size;
-}
-
-unsigned long
-I830AllocVidMem(const DRIDriverContext *ctx, I830Rec *pI830,
-                I830MemRange *result, I830MemPool *pool, long size,
-                unsigned long alignment, int flags)
-{
-   unsigned long ret;
-
-   if (!result)
-      return 0;
-
-   /* Make sure these are initialised. */
-   result->Size = 0;
-   result->Key = -1;
-
-   if (!size) {
-      return 0;
-   }
-
-   if (pool->Free.Size < size) {
-      ret = AllocFromAGP(ctx, pI830, size, alignment, result);
-   }
-   else {
-      ret = AllocFromPool(ctx, pI830, result, pool, size, alignment, flags);
-      if (ret == 0)
-         ret = AllocFromAGP(ctx, pI830, size, alignment, result);
-   }
-   return ret;
-}
-
-static Bool BindAgpRange(const DRIDriverContext *ctx, I830MemRange *mem)
-{
-  if (!mem)
-    return FALSE;
-  
-  if (mem->Key == -1)
-    return TRUE;
-
-  return !drmAgpBind(ctx->drmFD, mem->Key, mem->Offset);
-}
-
-/* simple memory allocation routines needed */
-/* put ring buffer in low memory */
-/* need to allocate front, back, depth buffers aligned correctly,
-   allocate ring buffer, 
-*/
-
-/* */
-static Bool
-I830AllocateMemory(const DRIDriverContext *ctx, I830Rec *pI830)
-{
-  unsigned long size, ret;
-  unsigned long lines, lineSize, align;
-
-  /* allocate ring buffer */
-  memset(pI830->LpRing, 0, sizeof(I830RingBuffer));
-  pI830->LpRing->mem.Key = -1;
-
-  size = PRIMARY_RINGBUFFER_SIZE;
-  
-  ret = I830AllocVidMem(ctx, pI830, &pI830->LpRing->mem, &pI830->StolenPool, size, 0x1000, 0);
-  
-  if (ret != size)
-  {
-    fprintf(stderr,"unable to allocate ring buffer %ld\n", ret);
-    return FALSE;
-  }
-
-  pI830->LpRing->tail_mask = pI830->LpRing->mem.Size - 1;
-
-  
-  /* allocate front buffer */
-  memset(&(pI830->FrontBuffer), 0, sizeof(pI830->FrontBuffer));
-  pI830->FrontBuffer.Key = -1;
-  pI830->FrontBuffer.Pitch = ctx->shared.virtualWidth;
-
-  align = KB(512);  
-
-  lineSize = ctx->shared.virtualWidth * ctx->cpp;
-  lines = (ctx->shared.virtualHeight + 15) / 16 * 16;
-  size = lineSize * lines;
-  size = ROUND_TO_PAGE(size);
-
-  align = GetBestTileAlignment(size);
-
-  ret = I830AllocVidMem(ctx, pI830, &pI830->FrontBuffer, &pI830->StolenPool, size, align, 0);
-  if (ret < size)
-  {
-    fprintf(stderr,"unable to allocate front buffer %ld\n", ret);
-    return FALSE;
-  }
-
-  memset(&(pI830->BackBuffer), 0, sizeof(pI830->BackBuffer));
-  pI830->BackBuffer.Key = -1;
-  pI830->BackBuffer.Pitch = ctx->shared.virtualWidth;
-
-  ret = I830AllocVidMem(ctx, pI830, &pI830->BackBuffer, &pI830->StolenPool, size, align, 0);
-  if (ret < size)
-  {
-    fprintf(stderr,"unable to allocate back buffer %ld\n", ret);
-    return FALSE;
-  }
-  
-  memset(&(pI830->DepthBuffer), 0, sizeof(pI830->DepthBuffer));
-  pI830->DepthBuffer.Key = -1;
-  pI830->DepthBuffer.Pitch = ctx->shared.virtualWidth;
-
-  ret = I830AllocVidMem(ctx, pI830, &pI830->DepthBuffer, &pI830->StolenPool, size, align, 0);
-  if (ret < size)
-  {
-    fprintf(stderr,"unable to allocate depth buffer %ld\n", ret);
-    return FALSE;
-  }
-
-  memset(&(pI830->ContextMem), 0, sizeof(pI830->ContextMem));
-  pI830->ContextMem.Key = -1;
-  size = KB(32);
-
-  ret = I830AllocVidMem(ctx, pI830, &pI830->ContextMem, &pI830->StolenPool, size, align, 0);
-  if (ret < size)
-  {
-    fprintf(stderr,"unable to allocate context buffer %ld\n", ret);
-    return FALSE;
-  }
-  
-  memset(&(pI830->TexMem), 0, sizeof(pI830->TexMem));
-  pI830->TexMem.Key = -1;
-
-  size = 32768 * 1024;
-  ret = AllocFromAGP(ctx, pI830, size, align, &pI830->TexMem);
-  if (ret < size)
-  {
-    fprintf(stderr,"unable to allocate texture memory %ld\n", ret);
-    return FALSE;
-  }
-
-  return TRUE;
-}
-
-static Bool
-I830BindMemory(const DRIDriverContext *ctx, I830Rec *pI830)
-{
-  if (!BindAgpRange(ctx, &pI830->LpRing->mem))
-    return FALSE;
-  if (!BindAgpRange(ctx, &pI830->FrontBuffer))
-    return FALSE;
-  if (!BindAgpRange(ctx, &pI830->BackBuffer))
-    return FALSE;
-  if (!BindAgpRange(ctx, &pI830->DepthBuffer))
-    return FALSE;
-  if (!BindAgpRange(ctx, &pI830->ContextMem))
-    return FALSE;
-  if (!BindAgpRange(ctx, &pI830->TexMem))
-    return FALSE;
-
-  return TRUE;
-}
-
-static Bool
-I830CleanupDma(const DRIDriverContext *ctx)
-{
-   drmI830Init info;
-
-   memset(&info, 0, sizeof(drmI830Init));
-   info.func = I830_CLEANUP_DMA;
-
-   if (drmCommandWrite(ctx->drmFD, DRM_I830_INIT,
-                      &info, sizeof(drmI830Init))) {
-     fprintf(stderr, "I830 Dma Cleanup Failed\n");
-      return FALSE;
-   }
-
-   return TRUE;
-}
-
-static Bool
-I830InitDma(const DRIDriverContext *ctx, I830Rec *pI830)
-{
-   I830RingBuffer *ring = pI830->LpRing;
-   drmI830Init info;
-
-   memset(&info, 0, sizeof(drmI830Init));
-   info.func = I830_INIT_DMA;
-
-   info.ring_start = ring->mem.Start + pI830->LinearAddr;
-   info.ring_end = ring->mem.End + pI830->LinearAddr;
-   info.ring_size = ring->mem.Size;
-
-   info.mmio_offset = (unsigned int)ctx->MMIOStart;
-
-   info.sarea_priv_offset = sizeof(drm_sarea_t);
-
-   info.front_offset = pI830->FrontBuffer.Start;
-   info.back_offset = pI830->BackBuffer.Start;
-   info.depth_offset = pI830->DepthBuffer.Start;
-   info.w = ctx->shared.virtualWidth;
-   info.h = ctx->shared.virtualHeight;
-   info.pitch = ctx->shared.virtualWidth;
-   info.back_pitch = pI830->BackBuffer.Pitch;
-   info.depth_pitch = pI830->DepthBuffer.Pitch;
-   info.cpp = ctx->cpp;
-
-   if (drmCommandWrite(ctx->drmFD, DRM_I830_INIT,
-                      &info, sizeof(drmI830Init))) {
-      fprintf(stderr,
-                "I830 Dma Initialization Failed\n");
-      return FALSE;
-   }
-
-   return TRUE;
-}
-
-static int I830CheckDRMVersion( const DRIDriverContext *ctx,
-                                 I830Rec *pI830 )
-{
-   drmVersionPtr  version;
-
-   version = drmGetVersion(ctx->drmFD);
-
-   if (version) {
-     int req_minor, req_patch;
-
-     req_minor = 4;
-     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] I830DRIScreenInit failed because of a version "
-              "mismatch.\n"
-              "[dri] i915.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;
-     }
-     
-     pI830->drmMinor = version->version_minor;
-     drmFreeVersion(version);
-   }
-   return 1;
-}
-
-static void
-I830SetRingRegs(const DRIDriverContext *ctx, I830Rec *pI830)
-{
-  unsigned int itemp;
-  unsigned char *MMIO = ctx->MMIOAddress;
-
-   OUTREG(LP_RING + RING_LEN, 0);
-   OUTREG(LP_RING + RING_TAIL, 0);
-   OUTREG(LP_RING + RING_HEAD, 0);
-
-   if ((long)(pI830->LpRing->mem.Start & I830_RING_START_MASK) !=
-       pI830->LpRing->mem.Start) {
-      fprintf(stderr,
-                "I830SetRingRegs: Ring buffer start (%lx) violates its "
-                "mask (%x)\n", pI830->LpRing->mem.Start, I830_RING_START_MASK);
-   }
-   /* Don't care about the old value.  Reserved bits must be zero anyway. */
-   itemp = pI830->LpRing->mem.Start & I830_RING_START_MASK;
-   OUTREG(LP_RING + RING_START, itemp);
-
-   if (((pI830->LpRing->mem.Size - 4096) & I830_RING_NR_PAGES) !=
-       pI830->LpRing->mem.Size - 4096) {
-      fprintf(stderr,
-                "I830SetRingRegs: Ring buffer size - 4096 (%lx) violates its "
-                "mask (%x)\n", pI830->LpRing->mem.Size - 4096,
-                I830_RING_NR_PAGES);
-   }
-   /* Don't care about the old value.  Reserved bits must be zero anyway. */
-   itemp = (pI830->LpRing->mem.Size - 4096) & I830_RING_NR_PAGES;
-   itemp |= (RING_NO_REPORT | RING_VALID);
-   OUTREG(LP_RING + RING_LEN, itemp);
-
-   pI830->LpRing->head = INREG(LP_RING + RING_HEAD) & I830_HEAD_MASK;
-   pI830->LpRing->tail = INREG(LP_RING + RING_TAIL);
-   pI830->LpRing->space = pI830->LpRing->head - (pI830->LpRing->tail + 8);
-   if (pI830->LpRing->space < 0)
-      pI830->LpRing->space += pI830->LpRing->mem.Size;
-
-   SetFenceRegs(ctx, pI830);
-   
-   /* RESET THE DISPLAY PIPE TO POINT TO THE FRONTBUFFER - hacky
-      hacky hacky */
-   OUTREG(DSPABASE, pI830->FrontBuffer.Start + pI830->LinearAddr);
-
-}
-
-static Bool
-I830SetParam(const DRIDriverContext *ctx, int param, int value)
-{
-   drmI830SetParam sp;
-
-   memset(&sp, 0, sizeof(sp));
-   sp.param = param;
-   sp.value = value;
-
-   if (drmCommandWrite(ctx->drmFD, DRM_I830_SETPARAM, &sp, sizeof(sp))) {
-      fprintf(stderr, "I830 SetParam Failed\n");
-      return FALSE;
-   }
-
-   return TRUE;
-}
-
-static Bool
-I830DRIMapScreenRegions(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea)
-{
-   fprintf(stderr,
-              "[drm] Mapping front buffer\n");
-
-   if (drmAddMap(ctx->drmFD,
-                 (drm_handle_t)(sarea->front_offset + pI830->LinearAddr),
-                 sarea->front_size,
-                 DRM_FRAME_BUFFER,  /*DRM_AGP,*/
-                 0,
-                 &sarea->front_handle) < 0) {
-     fprintf(stderr,
-            "[drm] drmAddMap(front_handle) failed. Disabling DRI\n");
-      return FALSE;
-   }
-   ctx->shared.hFrameBuffer = sarea->front_handle;
-   ctx->shared.fbSize = sarea->front_size;
-   fprintf(stderr, "[drm] Front Buffer = 0x%08x\n",
-          sarea->front_handle);
-
-   if (drmAddMap(ctx->drmFD,
-                 (drm_handle_t)(sarea->back_offset),
-                 sarea->back_size, DRM_AGP, 0,
-                 &sarea->back_handle) < 0) {
-      fprintf(stderr,
-                 "[drm] drmAddMap(back_handle) failed. Disabling DRI\n");
-      return FALSE;
-   }
-   fprintf(stderr, "[drm] Back Buffer = 0x%08x\n",
-              sarea->back_handle);
-
-   if (drmAddMap(ctx->drmFD,
-                 (drm_handle_t)sarea->depth_offset,
-                 sarea->depth_size, DRM_AGP, 0,
-                 &sarea->depth_handle) < 0) {
-      fprintf(stderr,
-                 "[drm] drmAddMap(depth_handle) failed. Disabling DRI\n");
-      return FALSE;
-   }
-   fprintf(stderr, "[drm] Depth Buffer = 0x%08x\n",
-              sarea->depth_handle);
-
-   if (drmAddMap(ctx->drmFD,
-                (drm_handle_t)sarea->tex_offset,
-                sarea->tex_size, DRM_AGP, 0,
-                &sarea->tex_handle) < 0) {
-      fprintf(stderr,
-                "[drm] drmAddMap(tex_handle) failed. Disabling DRI\n");
-      return FALSE;
-   }
-   fprintf(stderr, "[drm] textures = 0x%08x\n",
-             sarea->tex_handle);
-
-   return TRUE;
-}
-
-
-static void
-I830DRIUnmapScreenRegions(const DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea)
-{
-#if 1
-   if (sarea->front_handle) {
-      drmRmMap(ctx->drmFD, sarea->front_handle);
-      sarea->front_handle = 0;
-   }
-#endif
-   if (sarea->back_handle) {
-      drmRmMap(ctx->drmFD, sarea->back_handle);
-      sarea->back_handle = 0;
-   }
-   if (sarea->depth_handle) {
-      drmRmMap(ctx->drmFD, sarea->depth_handle);
-      sarea->depth_handle = 0;
-   }
-   if (sarea->tex_handle) {
-      drmRmMap(ctx->drmFD, sarea->tex_handle);
-      sarea->tex_handle = 0;
-   }
-}
-
-static void
-I830InitTextureHeap(const DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea)
-{
-   /* Start up the simple memory manager for agp space */
-   drmI830MemInitHeap drmHeap;
-   drmHeap.region = I830_MEM_REGION_AGP;
-   drmHeap.start  = 0;
-   drmHeap.size   = sarea->tex_size;
-      
-   if (drmCommandWrite(ctx->drmFD, DRM_I830_INIT_HEAP,
-                         &drmHeap, sizeof(drmHeap))) {
-      fprintf(stderr,
-                   "[drm] Failed to initialized agp heap manager\n");
-   } else {
-      fprintf(stderr,
-                   "[drm] Initialized kernel agp heap manager, %d\n",
-                   sarea->tex_size);
-
-      I830SetParam(ctx, I830_SETPARAM_TEX_LRU_LOG_GRANULARITY, 
-                     sarea->log_tex_granularity);
-   }
-}
-
-static Bool
-I830DRIDoMappings(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea)
-{
-  if (drmAddMap(ctx->drmFD,
-               (drm_handle_t)pI830->LpRing->mem.Start,
-               pI830->LpRing->mem.Size, DRM_AGP, 0,
-               &pI830->ring_map) < 0) {
-    fprintf(stderr,
-           "[drm] drmAddMap(ring_map) failed. Disabling DRI\n");
-    return FALSE;
-  }
-  fprintf(stderr, "[drm] ring buffer = 0x%08x\n",
-         pI830->ring_map);
-
-  if (I830InitDma(ctx, pI830) == FALSE) {
-    return FALSE;
-  }
-  
-   /* init to zero to be safe */
-
-  I830DRIMapScreenRegions(ctx, pI830, sarea);
-  I830InitTextureHeap(ctx, pI830, sarea);
-
-   if (ctx->pciDevice != PCI_CHIP_845_G &&
-       ctx->pciDevice != PCI_CHIP_I830_M) {
-      I830SetParam(ctx, I830_SETPARAM_USE_MI_BATCHBUFFER_START, 1 );
-   }
-
-   /* Okay now initialize the dma engine */
-   {
-      pI830->irq = drmGetInterruptFromBusID(ctx->drmFD,
-                                           ctx->pciBus,
-                                           ctx->pciDevice,
-                                           ctx->pciFunc);
-
-      if (drmCtlInstHandler(ctx->drmFD, pI830->irq)) {
-        fprintf(stderr,
-                   "[drm] failure adding irq handler\n");
-        pI830->irq = 0;
-        return FALSE;
-      }
-      else
-        fprintf(stderr,
-                   "[drm] dma control initialized, using IRQ %d\n",
-                   pI830->irq);
-   }
-
-   fprintf(stderr, "[dri] visual configs initialized\n");
-
-   return TRUE;
-}
-
-static Bool
-I830ClearScreen(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea)
-{
-  /* need to drmMap front and back buffers and zero them */
-  drmAddress map_addr;
-  int ret;
-
-  ret = drmMap(ctx->drmFD,
-              sarea->front_handle,
-              sarea->front_size,
-              &map_addr);
-
-  if (ret)
-  {
-    fprintf(stderr, "Unable to map front buffer\n");
-    return FALSE;
-  }
-
-  drimemsetio((char *)map_addr,
-             0,
-             sarea->front_size);
-  drmUnmap(map_addr, sarea->front_size);
-
-
-  ret = drmMap(ctx->drmFD,
-              sarea->back_handle,
-              sarea->back_size,
-              &map_addr);
-
-  if (ret)
-  {
-    fprintf(stderr, "Unable to map back buffer\n");
-    return FALSE;
-  }
-
-  drimemsetio((char *)map_addr,
-             0,
-             sarea->back_size);
-  drmUnmap(map_addr, sarea->back_size);
-
-  return TRUE;
-}
-
-static Bool
-I830ScreenInit(DRIDriverContext *ctx, I830Rec *pI830)
-                 
-{
-   I830DRIPtr pI830DRI;
-   drmI830Sarea *pSAREAPriv;
-   int err;
-      
-   drm_page_size = getpagesize();   
-
-   pI830->registerSize = ctx->MMIOSize;
-   /* This is a hack for now.  We have to have more than a 4k page here
-    * because of the size of the state.  However, the state should be
-    * in a per-context mapping.  This will be added in the Mesa 3.5 port
-    * of the I830 driver.
-    */
-   ctx->shared.SAREASize = SAREA_MAX;
-
-   /* Note that drmOpen will try to load the kernel module, if needed. */
-   ctx->drmFD = drmOpen("i915", 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%08x\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%08x 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, 
-                &pI830->registerHandle) < 0) {
-      fprintf(stderr, "[drm] drmAddMap mmio failed\n");        
-      return 0;
-   }
-   fprintf(stderr,
-          "[drm] register handle = 0x%08x\n", pI830->registerHandle);
-
-
-   if (!I830CheckDRMVersion(ctx, pI830)) {
-     return 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 SAREA private data structure */
-   pSAREAPriv = (drmI830Sarea *)(((char*)ctx->pSAREA) + 
-                                sizeof(drm_sarea_t));
-   memset(pSAREAPriv, 0, sizeof(*pSAREAPriv));
-
-   pI830->StolenMemory.Size = I830DetectMemory(ctx, pI830);
-   pI830->StolenMemory.Start = 0;
-   pI830->StolenMemory.End = pI830->StolenMemory.Size;
-
-   pI830->MemoryAperture.Start = pI830->StolenMemory.End;
-   pI830->MemoryAperture.End = KB(40000);
-   pI830->MemoryAperture.Size = pI830->MemoryAperture.End - pI830->MemoryAperture.Start;
-
-   pI830->StolenPool.Fixed = pI830->StolenMemory;
-   pI830->StolenPool.Total = pI830->StolenMemory;
-   pI830->StolenPool.Free = pI830->StolenPool.Total;
-   pI830->FreeMemory = pI830->StolenPool.Total.Size;
-
-   if (!AgpInit(ctx, pI830))
-     return FALSE;
-
-   if (I830AllocateMemory(ctx, pI830) == FALSE)
-   {
-     return FALSE;
-   }
-
-   if (I830BindMemory(ctx, pI830) == FALSE)
-   {
-     return FALSE;
-   }
-
-   pSAREAPriv->front_offset = pI830->FrontBuffer.Start;
-   pSAREAPriv->front_size = pI830->FrontBuffer.Size;
-   pSAREAPriv->width = ctx->shared.virtualWidth;
-   pSAREAPriv->height = ctx->shared.virtualHeight;
-   pSAREAPriv->pitch = ctx->shared.virtualWidth;
-   pSAREAPriv->virtualX = ctx->shared.virtualWidth;
-   pSAREAPriv->virtualY = ctx->shared.virtualHeight;
-   pSAREAPriv->back_offset = pI830->BackBuffer.Start;
-   pSAREAPriv->back_size = pI830->BackBuffer.Size;
-   pSAREAPriv->depth_offset = pI830->DepthBuffer.Start;
-   pSAREAPriv->depth_size = pI830->DepthBuffer.Size;
-   pSAREAPriv->tex_offset = pI830->TexMem.Start;
-   pSAREAPriv->tex_size = pI830->TexMem.Size;
-   pSAREAPriv->log_tex_granularity = pI830->TexGranularity;
-
-   ctx->driverClientMsg = malloc(sizeof(I830DRIRec));
-   ctx->driverClientMsgSize = sizeof(I830DRIRec);
-   pI830DRI = (I830DRIPtr)ctx->driverClientMsg;
-   pI830DRI->deviceID = pI830->Chipset;
-   pI830DRI->regsSize = I830_REG_SIZE;
-   pI830DRI->width = ctx->shared.virtualWidth;
-   pI830DRI->height = ctx->shared.virtualHeight;
-   pI830DRI->mem = ctx->shared.fbSize;
-   pI830DRI->cpp = ctx->cpp;
-   pI830DRI->backOffset = pI830->BackBuffer.Start;
-   pI830DRI->backPitch = pI830->BackBuffer.Pitch; 
-
-   pI830DRI->depthOffset = pI830->DepthBuffer.Start;
-   pI830DRI->depthPitch = pI830->DepthBuffer.Pitch; 
-
-   pI830DRI->fbOffset = pI830->FrontBuffer.Start;
-   pI830DRI->fbStride = pI830->FrontBuffer.Pitch;
-
-   pI830DRI->bitsPerPixel = ctx->bpp;
-   pI830DRI->sarea_priv_offset = sizeof(drm_sarea_t);
-   
-   err = I830DRIDoMappings(ctx, pI830, pSAREAPriv);
-   if (err == FALSE)
-       return FALSE;
-
-   I830SetupMemoryTiling(ctx, pI830);
-
-   /* 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.
-    */
-   I830ClearScreen(ctx, pI830, pSAREAPriv);
-
-   I830SetRingRegs(ctx, pI830);
-
-   return TRUE;
-}
-
-
-/**
- * \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 i830ValidateMode( 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 i810ValidateMode().
- */
-static int i830PostValidateMode( const DRIDriverContext *ctx )
-{
-  I830Rec *pI830 = ctx->driverPrivate;
-
-  I830SetRingRegs(ctx, pI830);
-  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 i830InitFBDev( DRIDriverContext *ctx )
-{
-  I830Rec *pI830 = calloc(1, sizeof(I830Rec));
-  int i;
-
-   {
-      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->shared.Width = ctx->shared.virtualWidth;
-   }
-
-
-   for (i = 0; pitches[i] != 0; i++) {
-     if (pitches[i] >= ctx->shared.virtualWidth) {
-       ctx->shared.virtualWidth = pitches[i];
-       break;
-     }
-   }
-
-   ctx->driverPrivate = (void *)pI830;
-   
-   pI830->LpRing = calloc(1, sizeof(I830RingBuffer));
-   pI830->Chipset = ctx->chipset;
-   pI830->LinearAddr = ctx->FBStart;
-
-   if (!I830ScreenInit( ctx, pI830 ))
-      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 i830HaltFBDev( DRIDriverContext *ctx )
-{
-  drmI830Sarea *pSAREAPriv;
-  I830Rec *pI830 = ctx->driverPrivate;
-
-   if (pI830->irq) {
-       drmCtlUninstHandler(ctx->drmFD);
-       pI830->irq = 0;   }
-
-   I830CleanupDma(ctx);
-
-  pSAREAPriv = (drmI830Sarea *)(((char*)ctx->pSAREA) + 
-                               sizeof(drm_sarea_t));
-
-  I830DRIUnmapScreenRegions(ctx, pI830, pSAREAPriv);
-  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 = {
-   i830ValidateMode,
-   i830PostValidateMode,
-   i830InitFBDev,
-   i830HaltFBDev,
-   NULL,//I830EngineShutdown,
-   NULL, //I830EngineRestore,  
-#ifndef _EMBEDDED
-   0,
-#else
-   i810NotifyFocus, 
-#endif
-};
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..effdd26448adc737a4c46b1b500f9a11f1830972
--- /dev/null
@@ -0,0 +1 @@
+../../intel/server/intel_dri.c
\ No newline at end of file
index 9e4ff112dc37e13e62e35360e1ce4015b053af90..c2d555cd0cfa4ec0f1b5aed807644080ecce85fb 100644 (file)
@@ -5,25 +5,29 @@ include $(TOP)/configs/current
 LIBNAME = i965_dri.so
 
 DRIVER_SOURCES = \
-       bufmgr_fake.c \
        intel_batchbuffer.c \
        intel_blit.c \
        intel_buffer_objects.c \
        intel_buffers.c \
        intel_context.c \
-       intel_ioctl.c \
+       intel_decode.c \
+       intel_depthstencil.c \
+       intel_fbo.c \
        intel_mipmap_tree.c \
        intel_regions.c \
        intel_screen.c \
        intel_span.c \
+       intel_pixel.c \
        intel_pixel_copy.c \
        intel_pixel_bitmap.c \
        intel_state.c \
        intel_tex.c \
+       intel_tex_copy.c \
+       intel_tex_format.c \
+       intel_tex_image.c \
        intel_tex_layout.c \
+       intel_tex_subimage.c \
        intel_tex_validate.c \
-       brw_aub.c \
-       brw_aub_playback.c \
        brw_cc.c \
        brw_clip.c \
        brw_clip_line.c \
@@ -44,7 +48,6 @@ DRIVER_SOURCES = \
        brw_gs.c \
        brw_gs_emit.c \
        brw_gs_state.c \
-       brw_hal.c \
        brw_metaops.c \
        brw_misc_state.c \
        brw_program.c \
@@ -53,7 +56,7 @@ DRIVER_SOURCES = \
        brw_sf_state.c \
        brw_state_batch.c \
        brw_state_cache.c \
-       brw_state_pool.c \
+       brw_state_dump.c \
        brw_state_upload.c \
        brw_tex.c \
        brw_tex_layout.c \
@@ -70,6 +73,7 @@ DRIVER_SOURCES = \
        brw_wm_emit.c \
        brw_wm_fp.c \
        brw_wm_iz.c \
+       brw_wm_glsl.c \
        brw_wm_pass0.c \
        brw_wm_pass1.c \
        brw_wm_pass2.c \
@@ -84,10 +88,12 @@ C_SOURCES = \
 
 ASM_SOURCES = 
 
-DRIVER_DEFINES = -I../intel
+DRIVER_DEFINES = -I../intel -I../intel/server
 
-include ../Makefile.template
+DRI_LIB_DEPS += -ldrm_intel
 
-intel_tex_layout.o: ../intel/intel_tex_layout.c
+include ../Makefile.template
 
 symlinks:
+intel_decode.o: ../intel/intel_decode.c
+intel_tex_layout.o: ../intel/intel_tex_layout.c
diff --git a/src/mesa/drivers/dri/i965/brw_aub.c b/src/mesa/drivers/dri/i965/brw_aub.c
deleted file mode 100644 (file)
index f851a5b..0000000
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- Copyright (C) Intel Corp.  2006.  All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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 "brw_context.h"
-#include "brw_aub.h"
-#include "intel_regions.h"
-#include <stdio.h>
-
-extern char *__progname;
-
-
-/* Registers to control page table
- */
-#define PGETBL_CTL       0x2020
-#define PGETBL_ENABLED   0x1
-
-#define NR_GTT_ENTRIES  65536  /* 256 mb */
-
-#define FAIL                                                                           \
-do {                                                                                   \
-   fprintf(stderr, "failed to write aub data at %s/%d\n", __FUNCTION__, __LINE__);     \
-   exit(1);                                                                            \
-} while (0)
-
-
-/* Emit the headers at the top of each aubfile.  Initialize the GTT.
- */
-static void init_aubfile( FILE *aub_file )
-{   
-   struct aub_file_header fh;
-   struct aub_block_header bh;
-   unsigned int data;
-
-   static int nr;
-   
-   nr++;
-
-   /* Emit the aub header:
-    */
-   memset(&fh, 0, sizeof(fh));
-
-   fh.instruction_type = AUB_FILE_HEADER;
-   fh.minor = 0x0;
-   fh.major = 0x7;
-   memcpy(fh.application, __progname, sizeof(fh.application));
-   fh.day = (nr>>24) & 0xff;
-   fh.month = 0x0;
-   fh.year = 0x0;
-   fh.timezone = 0x0;
-   fh.second = nr & 0xff;
-   fh.minute = (nr>>8) & 0xff;
-   fh.hour = (nr>>16) & 0xff;
-   fh.comment_length = 0x0;   
-
-   if (fwrite(&fh, sizeof(fh), 1, aub_file) < 0) 
-      FAIL;
-         
-   /* Setup the GTT starting at main memory address zero (!):
-    */
-   memset(&bh, 0, sizeof(bh));
-   
-   bh.instruction_type = AUB_BLOCK_HEADER;
-   bh.operation = BH_MMI0_WRITE32;
-   bh.type = 0x0;
-   bh.address_space = ADDR_GTT;        /* ??? */
-   bh.general_state_type = 0x0;
-   bh.surface_state_type = 0x0;
-   bh.address = PGETBL_CTL;
-   bh.length = 0x4;
-
-   if (fwrite(&bh, sizeof(bh), 1, aub_file) < 0) 
-      FAIL;
-
-   data = 0x0 | PGETBL_ENABLED;
-
-   if (fwrite(&data, sizeof(data), 1, aub_file) < 0) 
-      FAIL;
-}
-
-
-static void init_aub_gtt( struct brw_context *brw,
-                         GLuint start_offset, 
-                         GLuint size )
-{
-   FILE *aub_file = brw->intel.aub_file;
-   struct aub_block_header bh;
-   unsigned int i;
-
-   assert(start_offset + size < NR_GTT_ENTRIES * 4096);
-
-
-   memset(&bh, 0, sizeof(bh));
-   
-   bh.instruction_type = AUB_BLOCK_HEADER;
-   bh.operation = BH_DATA_WRITE;
-   bh.type = 0x0;
-   bh.address_space = ADDR_MAIN;
-   bh.general_state_type = 0x0;
-   bh.surface_state_type = 0x0;
-   bh.address =  start_offset / 4096 * 4;
-   bh.length = size / 4096 * 4;
-
-   if (fwrite(&bh, sizeof(bh), 1, aub_file) < 0) 
-      FAIL;
-
-   for (i = 0; i < size / 4096; i++) {
-      GLuint data = brw->next_free_page | 1;
-
-      brw->next_free_page += 4096;
-
-      if (fwrite(&data, sizeof(data), 1, aub_file) < 0) 
-        FAIL;
-   }
-
-}
-
-static void write_block_header( FILE *aub_file,
-                               struct aub_block_header *bh,
-                               const GLuint *data,
-                               GLuint sz )
-{
-   sz = (sz + 3) & ~3;
-
-   if (fwrite(bh, sizeof(*bh), 1, aub_file) < 0) 
-      FAIL;
-
-   if (fwrite(data, sz, 1, aub_file) < 0) 
-      FAIL;
-
-   fflush(aub_file);
-}
-
-
-static void write_dump_bmp( FILE *aub_file,
-                           struct aub_dump_bmp *db )
-{
-   if (fwrite(db, sizeof(*db), 1, aub_file) < 0) 
-      FAIL;
-
-   fflush(aub_file);
-}
-
-
-
-static void brw_aub_gtt_data( struct intel_context *intel,
-                             GLuint offset,
-                             const void *data,
-                             GLuint sz,
-                             GLuint type,
-                             GLuint state_type )
-{
-   struct aub_block_header bh;
-
-   bh.instruction_type = AUB_BLOCK_HEADER;
-   bh.operation = BH_DATA_WRITE;
-   bh.type = type;
-   bh.address_space = ADDR_GTT;
-   bh.pad0 = 0;
-
-   if (type == DW_GENERAL_STATE) {
-      bh.general_state_type = state_type;
-      bh.surface_state_type = 0;
-   }
-   else {
-      bh.general_state_type = 0;
-      bh.surface_state_type = state_type;
-   }
-
-   bh.pad1 = 0;
-   bh.address = offset;
-   bh.length = sz;
-
-   write_block_header(intel->aub_file, &bh, data, sz);
-}
-
-
-
-static void brw_aub_gtt_cmds( struct intel_context *intel,
-                             GLuint offset,
-                             const void *data,
-                             GLuint sz )
-{
-   struct brw_context *brw = brw_context(&intel->ctx);
-   struct aub_block_header bh;   
-   GLuint type = CW_PRIMARY_RING_A;
-   
-
-   bh.instruction_type = AUB_BLOCK_HEADER;
-   bh.operation = BH_COMMAND_WRITE;
-   bh.type = type;
-   bh.address_space = ADDR_GTT;
-   bh.pad0 = 0;
-   bh.general_state_type = 0;
-   bh.surface_state_type = 0;
-   bh.pad1 = 0;
-   bh.address = offset;
-   bh.length = sz;
-
-   write_block_header(brw->intel.aub_file, &bh, data, sz);
-}
-
-static void brw_aub_dump_bmp( struct intel_context *intel,
-                             GLuint buffer )
-{
-   struct brw_context *brw = brw_context(&intel->ctx);
-   intelScreenPrivate *intelScreen = brw->intel.intelScreen;
-   struct aub_dump_bmp db;
-   GLuint format;
-
-   if (intelScreen->cpp == 4)
-      format = 0x7;
-   else
-      format = 0x3;
-
-
-   if (buffer == 0) {
-      db.instruction_type = AUB_DUMP_BMP;
-      db.xmin = 0;
-      db.ymin = 0;
-      db.format = format;
-      db.bpp = intelScreen->cpp * 8;
-      db.pitch = intelScreen->front.pitch / intelScreen->cpp;
-      db.xsize = intelScreen->width;
-      db.ysize = intelScreen->height;
-      db.addr = intelScreen->front.offset;
-      db.unknown = 0x0;                /* 4: xmajor tiled, 0: not tiled */
-
-      write_dump_bmp(brw->intel.aub_file, &db);
-   }
-   else {
-      db.instruction_type = AUB_DUMP_BMP;
-      db.xmin = 0;
-      db.ymin = 0;
-      db.format = format;
-      db.bpp = intel->back_region->cpp * 8;
-      db.pitch = intel->back_region->pitch;
-      db.xsize = intel->back_region->pitch;
-      db.ysize = intel->back_region->height;
-      db.addr = intelScreen->back.offset;
-      db.unknown = intel->back_region->tiled ? 0x4 : 0x0;
-
-      write_dump_bmp(brw->intel.aub_file, &db);
-   }
-}
-
-/* Attempt to prevent monster aubfiles by closing and reopening when
- * the state pools wrap.
- */
-static void brw_aub_wrap( struct intel_context *intel )
-{
-   struct brw_context *brw = brw_context(&intel->ctx);   
-   if (intel->aub_file) {
-      brw_aub_destroy(brw);
-      brw_aub_init(brw);
-   }
-   brw->wrap = 1;              /* ??? */
-}
-
-
-int brw_aub_init( struct brw_context *brw )
-{
-   struct intel_context *intel = &brw->intel;
-   intelScreenPrivate *intelScreen = intel->intelScreen;
-   char filename[80];
-   int val;
-   static int i = 0;
-
-   i++;
-
-   if (_mesa_getenv("INTEL_REPLAY"))
-      return 0;
-
-   if (_mesa_getenv("INTEL_AUBFILE")) {
-      val = snprintf(filename, sizeof(filename), "%s%d.aub", _mesa_getenv("INTEL_AUBFILE"), i%4);
-      _mesa_printf("--> Aub file: %s\n", filename);
-      brw->intel.aub_file = fopen(filename, "w");
-   }
-   else if (_mesa_getenv("INTEL_AUB")) {
-      val = snprintf(filename, sizeof(filename), "%s.aub", __progname);
-      if (val < 0 || val > sizeof(filename)) 
-        strcpy(filename, "default.aub");   
-   
-      _mesa_printf("--> Aub file: %s\n", filename);
-      brw->intel.aub_file = fopen(filename, "w");
-   }
-   else {
-      return 0;
-   }
-
-   if (!brw->intel.aub_file) {
-      _mesa_printf("couldn't open aubfile\n");
-      exit(1);
-   }
-
-   brw->intel.vtbl.aub_commands = brw_aub_gtt_cmds;
-   brw->intel.vtbl.aub_dump_bmp = brw_aub_dump_bmp;
-   brw->intel.vtbl.aub_gtt_data = brw_aub_gtt_data;
-   brw->intel.vtbl.aub_wrap = brw_aub_wrap;
-   
-   init_aubfile(brw->intel.aub_file);
-
-   /* The GTT is located starting address zero in main memory.  Pages
-    * to populate the gtt start after this point.
-    */
-   brw->next_free_page = (NR_GTT_ENTRIES * 4 + 4095) & ~4095;
-
-   /* More or less correspond with all the agp regions mapped by the
-    * driver:
-    */
-   init_aub_gtt(brw, 0, 4096*4); /* so new fulsim doesn't crash */
-   init_aub_gtt(brw, intelScreen->front.offset, intelScreen->back.size);
-   init_aub_gtt(brw, intelScreen->back.offset, intelScreen->back.size);
-   init_aub_gtt(brw, intelScreen->depth.offset, intelScreen->back.size);
-   init_aub_gtt(brw, intelScreen->tex.offset, intelScreen->tex.size);
-
-   return 0;
-}
-
-void brw_aub_destroy( struct brw_context *brw )
-{
-   if (brw->intel.aub_file) {
-      fclose(brw->intel.aub_file);
-      brw->intel.aub_file = NULL;
-   }
-}
diff --git a/src/mesa/drivers/dri/i965/brw_aub.h b/src/mesa/drivers/dri/i965/brw_aub.h
deleted file mode 100644 (file)
index 198e36d..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- Copyright (C) Intel Corp.  2006.  All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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 BRW_AUB_H
-#define BRW_AUB_H
-
-struct aub_file_header {
-   unsigned int instruction_type;
-   unsigned int pad0:16;
-   unsigned int minor:8;
-   unsigned int major:8;
-   unsigned char application[8*4];
-   unsigned int day:8;
-   unsigned int month:8;
-   unsigned int year:16;
-   unsigned int timezone:8;
-   unsigned int second:8;
-   unsigned int minute:8;
-   unsigned int hour:8;
-   unsigned int comment_length:16;   
-   unsigned int pad1:16;
-};
-
-struct aub_block_header {
-   unsigned int instruction_type;
-   unsigned int operation:8;
-   unsigned int type:8;
-   unsigned int address_space:8;
-   unsigned int pad0:8;
-   unsigned int general_state_type:8;
-   unsigned int surface_state_type:8;
-   unsigned int pad1:16;
-   unsigned int address;
-   unsigned int length;
-};
-
-struct aub_dump_bmp {
-   unsigned int instruction_type;
-   unsigned int xmin:16;
-   unsigned int ymin:16;
-   unsigned int pitch:16;
-   unsigned int bpp:8;
-   unsigned int format:8;
-   unsigned int xsize:16;
-   unsigned int ysize:16;
-   unsigned int addr;
-   unsigned int unknown;
-};
-
-enum bh_operation {
-   BH_COMMENT,
-   BH_DATA_WRITE,
-   BH_COMMAND_WRITE,
-   BH_MMI0_WRITE32,
-   BH_END_SCENE,
-   BH_CONFIG_MEMORY_MAP,
-   BH_MAX_OPERATION
-};
-
-enum command_write_type {
-   CW_HWB_RING = 1,
-   CW_PRIMARY_RING_A,
-   CW_PRIMARY_RING_B,          /* XXX - disagreement with listaub! */
-   CW_PRIMARY_RING_C,
-   CW_MAX_TYPE
-};
-
-enum data_write_type {
-   DW_NOTYPE,
-   DW_BATCH_BUFFER,
-   DW_BIN_BUFFER,
-   DW_BIN_POINTER_LIST,
-   DW_SLOW_STATE_BUFFER,
-   DW_VERTEX_BUFFER,
-   DW_2D_MAP,
-   DW_CUBE_MAP,
-   DW_INDIRECT_STATE_BUFFER,
-   DW_VOLUME_MAP,
-   DW_1D_MAP,
-   DW_CONSTANT_BUFFER,
-   DW_CONSTANT_URB_ENTRY,
-   DW_INDEX_BUFFER,
-   DW_GENERAL_STATE,
-   DW_SURFACE_STATE,
-   DW_MEDIA_OBJECT_INDIRECT_DATA,
-   DW_MAX_TYPE
-};
-
-enum data_write_general_state_type {
-   DWGS_NOTYPE,
-   DWGS_VERTEX_SHADER_STATE,
-   DWGS_GEOMETRY_SHADER_STATE ,
-   DWGS_CLIPPER_STATE,
-   DWGS_STRIPS_FANS_STATE,
-   DWGS_WINDOWER_IZ_STATE,
-   DWGS_COLOR_CALC_STATE,
-   DWGS_CLIPPER_VIEWPORT_STATE,        /* was 0x7 */
-   DWGS_STRIPS_FANS_VIEWPORT_STATE,
-   DWGS_COLOR_CALC_VIEWPORT_STATE, /* was 0x9 */
-   DWGS_SAMPLER_STATE,
-   DWGS_KERNEL_INSTRUCTIONS,
-   DWGS_SCRATCH_SPACE,
-   DWGS_SAMPLER_DEFAULT_COLOR,
-   DWGS_INTERFACE_DESCRIPTOR,
-   DWGS_VLD_STATE,
-   DWGS_VFE_STATE,
-   DWGS_MAX_TYPE
-};
-
-enum data_write_surface_state_type {
-   DWSS_NOTYPE,
-   DWSS_BINDING_TABLE_STATE,
-   DWSS_SURFACE_STATE,
-   DWSS_MAX_TYPE
-};
-
-enum memory_map_type {
-   MM_DEFAULT,
-   MM_DYNAMIC,
-   MM_MAX_TYPE
-};
-
-enum address_space {
-   ADDR_GTT,
-   ADDR_LOCAL,
-   ADDR_MAIN,
-   ADDR_MAX
-};
-
-
-#define AUB_FILE_HEADER 0xe085000b
-#define AUB_BLOCK_HEADER 0xe0c10003
-#define AUB_DUMP_BMP 0xe09e0004
-
-struct brw_context;
-struct intel_context;
-
-int brw_aub_init( struct brw_context *brw );
-void brw_aub_destroy( struct brw_context *brw );
-
-int brw_playback_aubfile(struct brw_context *brw,
-                        const char *filename);
-
-#endif
diff --git a/src/mesa/drivers/dri/i965/brw_aub_playback.c b/src/mesa/drivers/dri/i965/brw_aub_playback.c
deleted file mode 100644 (file)
index 2433d50..0000000
+++ /dev/null
@@ -1,443 +0,0 @@
-
-#include <stdio.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include "brw_aub.h"
-#include "brw_defines.h"
-#include "brw_context.h"
-#include "intel_ioctl.h"
-#include "bufmgr.h"
-
-struct aub_state {
-   struct intel_context *intel;
-   const char *map;
-   unsigned int csr;
-   unsigned int sz;
-};
-
-
-static int gobble( struct aub_state *s, int size )
-{
-   if (s->csr + size > s->sz) {
-      _mesa_printf("EOF in %s\n", __FUNCTION__);
-      return 1;
-   }
-
-   s->csr += size;
-   return 0;
-}
-
-static void flush_and_fence( struct aub_state *s )
-{
-   struct intel_context *intel = s->intel;
-   GLuint buf[2];
-
-   buf[0] = intel->vtbl.flush_cmd();
-   buf[1] = 0;
-
-   intel_cmd_ioctl(intel, (char *)&buf, sizeof(buf));
-      
-   intelWaitIrq( intel, intelEmitIrqLocked( intel ));
-}
-
-static void flush_cmds( struct aub_state *s,
-                       const void *data,
-                       int len )
-{
-   DBG("%s %d\n", __FUNCTION__, len);
-
-   if (len & 0x4) {
-      unsigned int *tmp = malloc(len + 4);
-      DBG("padding to octword\n");
-      memcpy(tmp, data, len);
-      tmp[len/4] = MI_NOOP;
-      flush_cmds(s, tmp, len+4);
-      free(tmp);
-      return;
-   }
-
-   /* For ring data, just send off immediately via an ioctl.
-    * This differs slightly from how the stream was executed
-    * initially as this would have been a batchbuffer.
-    */
-   intel_cmd_ioctl(s->intel, (void *)data, len);
-
-   if (1)
-      flush_and_fence(s);
-}
-
-static const char *pstrings[] = {
-   "none",
-   "POINTLIST",
-   "LINELIST",
-   "LINESTRIP",
-   "TRILIST",
-   "TRISTRIP",
-   "TRIFAN",
-   "QUADLIST",
-   "QUADSTRIP",
-   "LINELIST_ADJ",
-   "LINESTRIP_ADJ",
-   "TRILIST_ADJ",
-   "TRISTRIP_ADJ",
-   "TRISTRIP_REVERSE",
-   "POLYGON",
-   "RECTLIST",
-   "LINELOOP",
-   "POINTLIST_BF",
-   "LINESTRIP_CONT",
-   "LINESTRIP_BF",
-   "LINESTRIP_CONT_BF",
-   "TRIFAN_NOSTIPPLE",
-};
-
-static void do_3d_prim( struct aub_state *s,
-                       const void *data,
-                       int len )
-{
-   struct brw_3d_primitive prim;
-   const struct brw_3d_primitive *orig = data;
-   int i;
-
-   assert(len == sizeof(prim));
-   memcpy(&prim, data, sizeof(prim));
-
-#define START 0
-#define BLOCK (12*28)
-
-   if (orig->verts_per_instance < BLOCK)
-      flush_cmds(s, &prim, sizeof(prim));
-   else {
-      for (i = START; i + BLOCK < orig->verts_per_instance; i += BLOCK/2) {
-        prim.start_vert_location = i;
-        prim.verts_per_instance = BLOCK;
-        _mesa_printf("%sprim %d/%s verts %d..%d (of %d)\n", 
-                     prim.header.indexed ? "INDEXED " : "",
-                     prim.header.topology, pstrings[prim.header.topology%16],
-                     prim.start_vert_location, 
-                     prim.start_vert_location + prim.verts_per_instance,
-                     orig->verts_per_instance);
-        flush_cmds(s, &prim, sizeof(prim));
-      }
-   }
-}
-
-
-
-static struct {
-   int cmd;
-   const char *name;
-   int has_length;
-} cmd_info[] = {
-   { 0, "NOOP", 0 },
-   { 0x5410, "XY_COLOR_BLT_RGB", 1 },
-   { 0x5430, "XY_COLOR_BLT_RGBA", 1 },
-   { 0x54d0, "XY_SRC_COPY_BLT_RGB", 1 },
-   { 0x54f0, "XY_SRC_COPY_BLT_RGBA", 1 },
-   { CMD_URB_FENCE, "URB_FENCE",  1 },
-   { CMD_CONST_BUFFER_STATE, "CONST_BUFFER_STATE",  1 },
-   { CMD_CONST_BUFFER, "CONST_BUFFER",  1 },
-   { CMD_STATE_BASE_ADDRESS, "STATE_BASE_ADDRESS",  1 },
-   { CMD_STATE_INSN_POINTER, "STATE_INSN_POINTER",  1 },
-   { CMD_PIPELINE_SELECT, "PIPELINE_SELECT", 0, },
-   { CMD_PIPELINED_STATE_POINTERS, "PIPELINED_STATE_POINTERS", 1 },
-   { CMD_BINDING_TABLE_PTRS, "BINDING_TABLE_PTRS", 1 },
-   { CMD_VERTEX_BUFFER, "VERTEX_BUFFER", 1 },
-   { CMD_VERTEX_ELEMENT, "VERTEX_ELEMENT", 1 },
-   { CMD_INDEX_BUFFER, "INDEX_BUFFER", 1 },
-   { CMD_VF_STATISTICS, "VF_STATISTICS", 0 },
-   { CMD_DRAW_RECT, "DRAW_RECT", 1 },
-   { CMD_BLEND_CONSTANT_COLOR, "BLEND_CONSTANT_COLOR", 1 },
-   { CMD_CHROMA_KEY, "CHROMA_KEY", 1 },
-   { CMD_DEPTH_BUFFER, "DEPTH_BUFFER", 1 },
-   { CMD_POLY_STIPPLE_OFFSET, "POLY_STIPPLE_OFFSET", 1 },
-   { CMD_POLY_STIPPLE_PATTERN, "POLY_STIPPLE_PATTERN", 1 },
-   { CMD_LINE_STIPPLE_PATTERN, "LINE_STIPPLE_PATTERN", 1 },
-   { CMD_GLOBAL_DEPTH_OFFSET_CLAMP, "GLOBAL_DEPTH_OFFSET_CLAMP", 1 },
-   { CMD_PIPE_CONTROL, "PIPE_CONTROL", 1 },
-   { CMD_MI_FLUSH, "MI_FLUSH", 0 },
-   { CMD_3D_PRIM, "3D_PRIM", 1 },
-};
-
-#define NR_CMDS (sizeof(cmd_info)/sizeof(cmd_info[0]))
-
-
-static int find_command( unsigned int cmd )
-{
-   int i;
-
-   for (i = 0; i < NR_CMDS; i++) 
-      if (cmd == cmd_info[i].cmd) 
-        return i;
-
-   return -1;
-}
-
-
-
-static int parse_commands( struct aub_state *s,
-                          const unsigned int *data,
-                          int len )
-{
-   while (len) {
-      int cmd = data[0] >> 16;
-      int dwords;
-      int i;
-
-      i = find_command(cmd);
-
-      if (i < 0) {
-        _mesa_printf("couldn't find info for cmd %x\n", cmd);
-        return 1;
-      }
-
-      if (cmd_info[i].has_length)
-        dwords = (data[0] & 0xff) + 2;
-      else
-        dwords = 1;
-
-      _mesa_printf("%s (%d dwords) 0x%x\n", cmd_info[i].name, dwords, data[0]);
-
-      if (len < dwords * 4) {
-        _mesa_printf("EOF in %s (%d bytes)\n", __FUNCTION__, len);
-        return 1;
-      }
-
-
-      if (0 && cmd == CMD_3D_PRIM)
-        do_3d_prim(s, data, dwords * 4);
-      else
-        flush_cmds(s, data, dwords * 4);
-
-      data += dwords;
-      len -= dwords * 4;
-   }
-
-   return 0;
-}
-
-
-
-static void parse_data_write( struct aub_state *s,
-                            const struct aub_block_header *bh,
-                            void *dest,
-                            const unsigned int *data,
-                            int len )
-{
-   switch (bh->type) {
-   case DW_GENERAL_STATE:
-      switch (bh->general_state_type) {
-      case DWGS_VERTEX_SHADER_STATE: {
-        struct brw_vs_unit_state vs;
-        assert(len == sizeof(vs));
-
-        _mesa_printf("DWGS_VERTEX_SHADER_STATE\n");
-        memcpy(&vs, data, sizeof(vs));
-
-/*      vs.vs6.vert_cache_disable = 1;  */
-/*      vs.thread4.max_threads = 4;  */
-
-        memcpy(dest, &vs, sizeof(vs));
-        return;
-      }
-      case DWGS_CLIPPER_STATE: {
-        struct brw_clip_unit_state clip;
-        assert(len == sizeof(clip));
-
-        _mesa_printf("DWGS_CLIPPER_STATE\n");
-        memcpy(&clip, data, sizeof(clip));
-
-/*      clip.thread4.max_threads = 0; */
-/*      clip.clip5.clip_mode = BRW_CLIPMODE_REJECT_ALL;   */
-
-        memcpy(dest, &clip, sizeof(clip));
-        return;
-      }
-
-      case DWGS_NOTYPE:
-      case DWGS_GEOMETRY_SHADER_STATE:
-      case DWGS_STRIPS_FANS_STATE:
-        break;
-
-      case DWGS_WINDOWER_IZ_STATE: {
-           struct brw_wm_unit_state wm;
-           assert(len == sizeof(wm));
-
-           _mesa_printf("DWGS_WINDOWER_IZ_STATE\n");
-           memcpy(&wm, data, sizeof(wm));
-
-/*         wm.wm5.max_threads = 10; */
-
-           memcpy(dest, &wm, sizeof(wm));
-           return;
-        }
-
-      case DWGS_COLOR_CALC_STATE:
-      case DWGS_CLIPPER_VIEWPORT_STATE:
-      case DWGS_STRIPS_FANS_VIEWPORT_STATE:
-      case DWGS_COLOR_CALC_VIEWPORT_STATE:
-      case DWGS_SAMPLER_STATE:
-      case DWGS_KERNEL_INSTRUCTIONS:
-      case DWGS_SCRATCH_SPACE:
-      case DWGS_SAMPLER_DEFAULT_COLOR:
-      case DWGS_INTERFACE_DESCRIPTOR:
-      case DWGS_VLD_STATE:
-      case DWGS_VFE_STATE:
-      default:
-        break;
-      }
-      break;
-   case DW_SURFACE_STATE:
-      break;
-   case DW_1D_MAP:
-   case DW_2D_MAP:
-   case DW_CUBE_MAP:
-   case DW_VOLUME_MAP:
-   case DW_CONSTANT_BUFFER:
-   case DW_CONSTANT_URB_ENTRY:
-   case DW_VERTEX_BUFFER:
-   case DW_INDEX_BUFFER:
-   default:
-      break;
-   }
-
-   memcpy(dest, data, len);
-}
-
-
-/* In order to work, the memory layout has to be the same as the X
- * server which created the aubfile.
- */
-static int parse_block_header( struct aub_state *s )
-{
-   struct aub_block_header *bh = (struct aub_block_header *)(s->map + s->csr);
-   void *data = (void *)(bh + 1);
-   unsigned int len = (bh->length + 3) & ~3;
-
-   _mesa_printf("block header at 0x%x\n", s->csr);
-
-   if (s->csr + len + sizeof(*bh) > s->sz) {
-      _mesa_printf("EOF in data in %s\n", __FUNCTION__);
-      return 1;
-   }
-
-   if (bh->address_space == ADDR_GTT) {
-
-      switch (bh->operation)
-      {
-      case BH_DATA_WRITE: {
-        void *dest = bmFindVirtual( s->intel, bh->address, len );
-        if (dest == NULL) {
-           _mesa_printf("Couldn't find virtual address for offset %x\n", bh->address);
-           return 1;
-        }
-
-#if 1
-        parse_data_write(s, bh, dest, data, len);
-#else
-        memcpy(dest, data, len);
-#endif
-        break;
-      }
-      case BH_COMMAND_WRITE:
-#if 0
-        intel_cmd_ioctl(s->intel, (void *)data, len);
-#else
-        if (parse_commands(s, data, len) != 0)
-           _mesa_printf("parse_commands failed\n");
-#endif
-        break;
-      default:
-        break;
-      }
-   }
-
-   s->csr += sizeof(*bh) + len;
-   return 0;
-}
-
-
-#define AUB_FILE_HEADER 0xe085000b
-#define AUB_BLOCK_HEADER 0xe0c10003
-#define AUB_DUMP_BMP 0xe09e0004
-
-int brw_playback_aubfile(struct brw_context *brw,
-                        const char *filename)
-{
-   struct intel_context *intel = &brw->intel;
-   struct aub_state state;
-   struct stat sb;
-   int fd;
-   int retval = 0;
-
-   state.intel = intel;
-
-   fd = open(filename, O_RDONLY, 0);
-   if (fd < 0) {
-      _mesa_printf("couldn't open aubfile: %s\n", filename);
-      return 1;
-   }
-
-   if (fstat(fd, &sb) != 0) {
-      _mesa_printf("couldn't open %s\n", filename);
-      return 1;
-   }
-
-   state.csr = 0;
-   state.sz = sb.st_size;
-   state.map = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
-   
-   if (state.map == NULL) {
-      _mesa_printf("couldn't mmap %s\n", filename);
-      return 1;
-   }
-
-   LOCK_HARDWARE(intel); 
-   {
-      /* Make sure we don't confuse anything that might happen to be
-       * going on with the hardware:
-       */
-/*       bmEvictAll(intel); */
-/*       intel->vtbl.lost_hardware(intel); */
-      
-
-      /* Replay the aubfile item by item: 
-       */
-      while (retval == 0 && 
-            state.csr != state.sz) {
-        unsigned int insn = *(unsigned int *)(state.map + state.csr);
-
-        switch (insn) {
-        case AUB_FILE_HEADER:
-           retval = gobble(&state, sizeof(struct aub_file_header));
-           break;
-        
-        case AUB_BLOCK_HEADER:   
-           retval = parse_block_header(&state);
-           break;
-        
-        case AUB_DUMP_BMP:
-           retval = gobble(&state, sizeof(struct aub_dump_bmp));
-           break;
-        
-        default:
-           _mesa_printf("unknown instruction %x\n", insn);
-           retval = 1;
-           break;
-        }
-      }
-   }
-   UNLOCK_HARDWARE(intel);
-   return retval;
-}
-
-
-
-
-
-
-                 
index 8a1d1527db30aab77a9fdbf5f34bebd20e7771d9..0458bf598329dd6a9dc08d97a93e8d7c973efb61 100644 (file)
@@ -37,7 +37,7 @@
 #include "macros.h"
 #include "enums.h"
 
-static void upload_cc_vp( struct brw_context *brw )
+static void prepare_cc_vp( struct brw_context *brw )
 {
    struct brw_cc_viewport ccv;
 
@@ -46,7 +46,8 @@ static void upload_cc_vp( struct brw_context *brw )
    ccv.min_depth = 0.0;
    ccv.max_depth = 1.0;
 
-   brw->cc.vp_gs_offset = brw_cache_data( &brw->cache[BRW_CC_VP], &ccv );
+   dri_bo_unreference(brw->cc.vp_bo);
+   brw->cc.vp_bo = brw_cache_data( &brw->cache, BRW_CC_VP, &ccv, NULL, 0 );
 }
 
 const struct brw_tracked_state brw_cc_vp = {
@@ -55,57 +56,148 @@ const struct brw_tracked_state brw_cc_vp = {
       .brw = BRW_NEW_CONTEXT,
       .cache = 0
    },
-   .update = upload_cc_vp
+   .prepare = prepare_cc_vp
 };
 
+struct brw_cc_unit_key {
+   GLboolean stencil, stencil_two_side, color_blend, alpha_enabled;
 
-static void upload_cc_unit( struct brw_context *brw )
+   GLenum stencil_func[2], stencil_fail_op[2];
+   GLenum stencil_pass_depth_fail_op[2], stencil_pass_depth_pass_op[2];
+   GLubyte stencil_ref[2], stencil_write_mask[2], stencil_test_mask[2];
+   GLenum logic_op;
+
+   GLenum blend_eq_rgb, blend_eq_a;
+   GLenum blend_src_rgb, blend_src_a;
+   GLenum blend_dst_rgb, blend_dst_a;
+
+   GLenum alpha_func;
+   GLclampf alpha_ref;
+
+   GLboolean dither;
+
+   GLboolean depth_test, depth_write;
+   GLenum depth_func;
+};
+
+static void
+cc_unit_populate_key(struct brw_context *brw, struct brw_cc_unit_key *key)
+{
+   struct gl_stencil_attrib *stencil = brw->attribs.Stencil;
+
+   memset(key, 0, sizeof(*key));
+
+   key->stencil = stencil->Enabled;
+   key->stencil_two_side = stencil->_TestTwoSide;
+
+   if (key->stencil) {
+      key->stencil_func[0] = stencil->Function[0];
+      key->stencil_fail_op[0] = stencil->FailFunc[0];
+      key->stencil_pass_depth_fail_op[0] = stencil->ZFailFunc[0];
+      key->stencil_pass_depth_pass_op[0] = stencil->ZPassFunc[0];
+      key->stencil_ref[0] = stencil->Ref[0];
+      key->stencil_write_mask[0] = stencil->WriteMask[0];
+      key->stencil_test_mask[0] = stencil->ValueMask[0];
+   }
+   if (key->stencil_two_side) {
+      key->stencil_func[1] = stencil->Function[1];
+      key->stencil_fail_op[1] = stencil->FailFunc[1];
+      key->stencil_pass_depth_fail_op[1] = stencil->ZFailFunc[1];
+      key->stencil_pass_depth_pass_op[1] = stencil->ZPassFunc[1];
+      key->stencil_ref[1] = stencil->Ref[1];
+      key->stencil_write_mask[1] = stencil->WriteMask[1];
+      key->stencil_test_mask[1] = stencil->ValueMask[1];
+   }
+
+   if (brw->attribs.Color->_LogicOpEnabled)
+      key->logic_op = brw->attribs.Color->LogicOp;
+   else
+      key->logic_op = GL_COPY;
+
+   key->color_blend = brw->attribs.Color->BlendEnabled;
+   if (key->color_blend) {
+      key->blend_eq_rgb = brw->attribs.Color->BlendEquationRGB;
+      key->blend_eq_a = brw->attribs.Color->BlendEquationA;
+      key->blend_src_rgb = brw->attribs.Color->BlendSrcRGB;
+      key->blend_dst_rgb = brw->attribs.Color->BlendDstRGB;
+      key->blend_src_a = brw->attribs.Color->BlendSrcA;
+      key->blend_dst_a = brw->attribs.Color->BlendDstA;
+   }
+
+   key->alpha_enabled = brw->attribs.Color->AlphaEnabled;
+   if (key->alpha_enabled) {
+      key->alpha_func = brw->attribs.Color->AlphaFunc;
+      key->alpha_ref = brw->attribs.Color->AlphaRef;
+   }
+
+   key->dither = brw->attribs.Color->DitherFlag;
+
+   key->depth_test = brw->attribs.Depth->Test;
+   if (key->depth_test) {
+      key->depth_func = brw->attribs.Depth->Func;
+      key->depth_write = brw->attribs.Depth->Mask;
+   }
+}
+
+/**
+ * Creates the state cache entry for the given CC unit key.
+ */
+static dri_bo *
+cc_unit_create_from_key(struct brw_context *brw, struct brw_cc_unit_key *key)
 {
    struct brw_cc_unit_state cc;
-   
+   dri_bo *bo;
+
    memset(&cc, 0, sizeof(cc));
 
    /* _NEW_STENCIL */
-   if (brw->attribs.Stencil->Enabled) {
-      cc.cc0.stencil_enable = brw->attribs.Stencil->Enabled;
-      cc.cc0.stencil_func = intel_translate_compare_func(brw->attribs.Stencil->Function[0]);
-      cc.cc0.stencil_fail_op = intel_translate_stencil_op(brw->attribs.Stencil->FailFunc[0]);
-      cc.cc0.stencil_pass_depth_fail_op = intel_translate_stencil_op(brw->attribs.Stencil->ZFailFunc[0]);
-      cc.cc0.stencil_pass_depth_pass_op = intel_translate_stencil_op(brw->attribs.Stencil->ZPassFunc[0]);
-      cc.cc1.stencil_ref = brw->attribs.Stencil->Ref[0];
-      cc.cc1.stencil_write_mask = brw->attribs.Stencil->WriteMask[0];
-      cc.cc1.stencil_test_mask = brw->attribs.Stencil->ValueMask[0];
-
-      if (brw->attribs.Stencil->TestTwoSide) {
-        cc.cc0.bf_stencil_enable = brw->attribs.Stencil->TestTwoSide;
-        cc.cc0.bf_stencil_func = intel_translate_compare_func(brw->attribs.Stencil->Function[1]);
-        cc.cc0.bf_stencil_fail_op = intel_translate_stencil_op(brw->attribs.Stencil->FailFunc[1]);
-        cc.cc0.bf_stencil_pass_depth_fail_op = intel_translate_stencil_op(brw->attribs.Stencil->ZFailFunc[1]);
-        cc.cc0.bf_stencil_pass_depth_pass_op = intel_translate_stencil_op(brw->attribs.Stencil->ZPassFunc[1]);
-        cc.cc1.bf_stencil_ref = brw->attribs.Stencil->Ref[1];
-        cc.cc2.bf_stencil_write_mask = brw->attribs.Stencil->WriteMask[1];
-        cc.cc2.bf_stencil_test_mask = brw->attribs.Stencil->ValueMask[1];
+   if (key->stencil) {
+      cc.cc0.stencil_enable = 1;
+      cc.cc0.stencil_func =
+        intel_translate_compare_func(key->stencil_func[0]);
+      cc.cc0.stencil_fail_op =
+        intel_translate_stencil_op(key->stencil_fail_op[0]);
+      cc.cc0.stencil_pass_depth_fail_op =
+        intel_translate_stencil_op(key->stencil_pass_depth_fail_op[0]);
+      cc.cc0.stencil_pass_depth_pass_op =
+        intel_translate_stencil_op(key->stencil_pass_depth_pass_op[0]);
+      cc.cc1.stencil_ref = key->stencil_ref[0];
+      cc.cc1.stencil_write_mask = key->stencil_write_mask[0];
+      cc.cc1.stencil_test_mask = key->stencil_test_mask[0];
+
+      if (key->stencil_two_side) {
+        cc.cc0.bf_stencil_enable = 1;
+        cc.cc0.bf_stencil_func =
+           intel_translate_compare_func(key->stencil_func[1]);
+        cc.cc0.bf_stencil_fail_op =
+           intel_translate_stencil_op(key->stencil_fail_op[1]);
+        cc.cc0.bf_stencil_pass_depth_fail_op =
+           intel_translate_stencil_op(key->stencil_pass_depth_fail_op[1]);
+        cc.cc0.bf_stencil_pass_depth_pass_op =
+           intel_translate_stencil_op(key->stencil_pass_depth_pass_op[1]);
+        cc.cc1.bf_stencil_ref = key->stencil_ref[1];
+        cc.cc2.bf_stencil_write_mask = key->stencil_write_mask[1];
+        cc.cc2.bf_stencil_test_mask = key->stencil_test_mask[1];
       }
 
       /* Not really sure about this:
        */
-      if (brw->attribs.Stencil->WriteMask[0] ||
-         (brw->attribs.Stencil->TestTwoSide && brw->attribs.Stencil->WriteMask[1]))
+      if (key->stencil_write_mask[0] ||
+         (key->stencil_two_side && key->stencil_write_mask[1]))
         cc.cc0.stencil_write_enable = 1;
    }
 
    /* _NEW_COLOR */
-   if (brw->attribs.Color->_LogicOpEnabled) {
+   if (key->logic_op != GL_COPY) {
       cc.cc2.logicop_enable = 1;
-      cc.cc5.logicop_func = intel_translate_logic_op( brw->attribs.Color->LogicOp );
-   }
-   else if (brw->attribs.Color->BlendEnabled) {
-      GLenum eqRGB = brw->attribs.Color->BlendEquationRGB;
-      GLenum eqA = brw->attribs.Color->BlendEquationA;
-      GLenum srcRGB = brw->attribs.Color->BlendSrcRGB;
-      GLenum dstRGB = brw->attribs.Color->BlendDstRGB;
-      GLenum srcA = brw->attribs.Color->BlendSrcA;
-      GLenum dstA = brw->attribs.Color->BlendDstA;
+      cc.cc5.logicop_func = intel_translate_logic_op(key->logic_op);
+   } else if (key->color_blend) {
+      GLenum eqRGB = key->blend_eq_rgb;
+      GLenum eqA = key->blend_eq_a;
+      GLenum srcRGB = key->blend_src_rgb;
+      GLenum dstRGB = key->blend_dst_rgb;
+      GLenum srcA = key->blend_src_a;
+      GLenum dstA = key->blend_dst_a;
 
       if (eqRGB == GL_MIN || eqRGB == GL_MAX) {
         srcRGB = dstRGB = GL_ONE;
@@ -115,49 +207,78 @@ static void upload_cc_unit( struct brw_context *brw )
         srcA = dstA = GL_ONE;
       }
 
-      cc.cc6.dest_blend_factor = brw_translate_blend_factor(dstRGB); 
-      cc.cc6.src_blend_factor = brw_translate_blend_factor(srcRGB); 
-      cc.cc6.blend_function = brw_translate_blend_equation( eqRGB );
+      cc.cc6.dest_blend_factor = brw_translate_blend_factor(dstRGB);
+      cc.cc6.src_blend_factor = brw_translate_blend_factor(srcRGB);
+      cc.cc6.blend_function = brw_translate_blend_equation(eqRGB);
 
-      cc.cc5.ia_dest_blend_factor = brw_translate_blend_factor(dstA); 
-      cc.cc5.ia_src_blend_factor = brw_translate_blend_factor(srcA); 
-      cc.cc5.ia_blend_function = brw_translate_blend_equation( eqA );
+      cc.cc5.ia_dest_blend_factor = brw_translate_blend_factor(dstA);
+      cc.cc5.ia_src_blend_factor = brw_translate_blend_factor(srcA);
+      cc.cc5.ia_blend_function = brw_translate_blend_equation(eqA);
 
       cc.cc3.blend_enable = 1;
-      cc.cc3.ia_blend_enable = (srcA != srcRGB || 
-                               dstA != dstRGB || 
+      cc.cc3.ia_blend_enable = (srcA != srcRGB ||
+                               dstA != dstRGB ||
                                eqA != eqRGB);
    }
 
-   if (brw->attribs.Color->AlphaEnabled) {
+   if (key->alpha_enabled) {
       cc.cc3.alpha_test = 1;
-      cc.cc3.alpha_test_func = intel_translate_compare_func(brw->attribs.Color->AlphaFunc);
-
-      UNCLAMPED_FLOAT_TO_UBYTE(cc.cc7.alpha_ref.ub[0], brw->attribs.Color->AlphaRef);
-
+      cc.cc3.alpha_test_func = intel_translate_compare_func(key->alpha_func);
       cc.cc3.alpha_test_format = BRW_ALPHATEST_FORMAT_UNORM8;
+
+      UNCLAMPED_FLOAT_TO_UBYTE(cc.cc7.alpha_ref.ub[0], key->alpha_ref);
    }
 
-   if (brw->attribs.Color->DitherFlag) {
+   if (key->dither) {
       cc.cc5.dither_enable = 1;
-      cc.cc6.y_dither_offset = 0; 
-      cc.cc6.x_dither_offset = 0;     
+      cc.cc6.y_dither_offset = 0;
+      cc.cc6.x_dither_offset = 0;
    }
 
    /* _NEW_DEPTH */
-   if (brw->attribs.Depth->Test) {
-      cc.cc2.depth_test = brw->attribs.Depth->Test;
-      cc.cc2.depth_test_function = intel_translate_compare_func(brw->attribs.Depth->Func);
-      cc.cc2.depth_write_enable = brw->attribs.Depth->Mask;
+   if (key->depth_test) {
+      cc.cc2.depth_test = 1;
+      cc.cc2.depth_test_function = intel_translate_compare_func(key->depth_func);
+      cc.cc2.depth_write_enable = key->depth_write;
    }
+
    /* CACHE_NEW_CC_VP */
-   cc.cc4.cc_viewport_state_offset =  brw->cc.vp_gs_offset >> 5;
+   cc.cc4.cc_viewport_state_offset = brw->cc.vp_bo->offset >> 5; /* reloc */
+
    if (INTEL_DEBUG & DEBUG_STATS)
-      cc.cc5.statistics_enable = 1; 
+      cc.cc5.statistics_enable = 1;
+
+   bo = brw_upload_cache(&brw->cache, BRW_CC_UNIT,
+                        key, sizeof(*key),
+                        &brw->cc.vp_bo, 1,
+                        &cc, sizeof(cc),
+                        NULL, NULL);
+
+   /* Emit CC viewport relocation */
+   dri_bo_emit_reloc(bo,
+                    I915_GEM_DOMAIN_INSTRUCTION,
+                    0,
+                    0,
+                    offsetof(struct brw_cc_unit_state, cc4),
+                    brw->cc.vp_bo);
+
+   return bo;
+}
+
+static void prepare_cc_unit( struct brw_context *brw )
+{
+   struct brw_cc_unit_key key;
+
+   cc_unit_populate_key(brw, &key);
+
+   dri_bo_unreference(brw->cc.state_bo);
+   brw->cc.state_bo = brw_search_cache(&brw->cache, BRW_CC_UNIT,
+                                      &key, sizeof(key),
+                                      &brw->cc.vp_bo, 1,
+                                      NULL);
 
-   brw->cc.state_gs_offset = brw_cache_data( &brw->cache[BRW_CC_UNIT], &cc );
+   if (brw->cc.state_bo == NULL)
+      brw->cc.state_bo = cc_unit_create_from_key(brw, &key);
 }
 
 const struct brw_tracked_state brw_cc_unit = {
@@ -166,7 +287,7 @@ const struct brw_tracked_state brw_cc_unit = {
       .brw = 0,
       .cache = CACHE_NEW_CC_VP
    },
-   .update = upload_cc_unit
+   .prepare = prepare_cc_unit,
 };
 
 
index 3bec153075a3112c262d9f8ef72e463bde2db820..22981fd2d929eba098694a0e0300bc6165ef9ad9 100644 (file)
@@ -60,7 +60,7 @@ static void compile_clip_prog( struct brw_context *brw,
    
    /* Begin the compilation:
     */
-   brw_init_compile(&c.func);
+   brw_init_compile(brw, &c.func);
 
    c.func.single_program_flow = 1;
 
@@ -119,31 +119,19 @@ static void compile_clip_prog( struct brw_context *brw,
 
    /* Upload
     */
-   brw->clip.prog_gs_offset = brw_upload_cache( &brw->cache[BRW_CLIP_PROG],
-                                               &c.key,
-                                               sizeof(c.key),
-                                               program,
-                                               program_size,
-                                               &c.prog_data,
-                                               &brw->clip.prog_data );
+   dri_bo_unreference(brw->clip.prog_bo);
+   brw->clip.prog_bo = brw_upload_cache( &brw->cache,
+                                        BRW_CLIP_PROG,
+                                        &c.key, sizeof(c.key),
+                                        NULL, 0,
+                                        program, program_size,
+                                        &c.prog_data,
+                                        &brw->clip.prog_data );
 }
 
-
-static GLboolean search_cache( struct brw_context *brw, 
-                              struct brw_clip_prog_key *key )
-{
-   return brw_search_cache(&brw->cache[BRW_CLIP_PROG], 
-                          key, sizeof(*key),
-                          &brw->clip.prog_data,
-                          &brw->clip.prog_gs_offset);
-}
-
-
-
-
 /* Calculate interpolants for triangle and line rasterization.
  */
-static void upload_clip_prog( struct brw_context *brw )
+static void upload_clip_prog(struct brw_context *brw)
 {
    GLcontext *ctx = &brw->intel.ctx;
    struct brw_clip_prog_key key;
@@ -180,12 +168,10 @@ static void upload_clip_prog( struct brw_context *brw )
               offset_front = 0;
               break;
            case GL_LINE:
-              key.do_unfilled = 1;
               fill_front = CLIP_LINE;
               offset_front = brw->attribs.Polygon->OffsetLine;
               break;
            case GL_POINT:
-              key.do_unfilled = 1;
               fill_front = CLIP_POINT;
               offset_front = brw->attribs.Polygon->OffsetPoint;
               break;
@@ -200,22 +186,23 @@ static void upload_clip_prog( struct brw_context *brw )
               offset_back = 0;
               break;
            case GL_LINE:
-              key.do_unfilled = 1;
               fill_back = CLIP_LINE;
               offset_back = brw->attribs.Polygon->OffsetLine;
               break;
            case GL_POINT:
-              key.do_unfilled = 1;
               fill_back = CLIP_POINT;
               offset_back = brw->attribs.Polygon->OffsetPoint;
               break;
            }
         }
 
-        /* Most cases the fixed function units will handle.  Cases where
-         * one or more polygon faces are unfilled will require help:
-         */
-        if (key.do_unfilled) {
+        if (brw->attribs.Polygon->BackMode != GL_FILL ||
+            brw->attribs.Polygon->FrontMode != GL_FILL) {
+           key.do_unfilled = 1;
+
+           /* Most cases the fixed function units will handle.  Cases where
+            * one or more polygon faces are unfilled will require help:
+            */
            key.clip_mode = BRW_CLIPMODE_CLIP_NON_REJECTED;
 
            if (offset_back || offset_front) {
@@ -248,7 +235,12 @@ static void upload_clip_prog( struct brw_context *brw )
       }
    }
 
-   if (!search_cache(brw, &key))
+   dri_bo_unreference(brw->clip.prog_bo);
+   brw->clip.prog_bo = brw_search_cache(&brw->cache, BRW_CLIP_PROG,
+                                       &key, sizeof(key),
+                                       NULL, 0,
+                                       &brw->clip.prog_data);
+   if (brw->clip.prog_bo == NULL)
       compile_clip_prog( brw, &key );
 }
 
@@ -262,5 +254,5 @@ const struct brw_tracked_state brw_clip_prog = {
       .brw   = (BRW_NEW_REDUCED_PRIMITIVE),
       .cache = CACHE_NEW_VS_PROG
    },
-   .update = upload_clip_prog
+   .prepare = upload_clip_prog
 };
index 49b2770a514c4a8036e8dd885764c92ff1b131c2..e06747864b5c223a3c4efdddef71e1da82aa2eba 100644 (file)
@@ -42,7 +42,7 @@
  * up polygon offset and flatshading at this point:
  */
 struct brw_clip_prog_key {
-   GLuint attrs:16;            
+   GLuint attrs:32;            
    GLuint primitive:4;
    GLuint nr_userclip:3;
    GLuint do_flat_shading:1;
@@ -51,7 +51,7 @@ struct brw_clip_prog_key {
    GLuint fill_ccw:2;          /* includes cull information */
    GLuint offset_cw:1;
    GLuint offset_ccw:1;
-   GLuint pad0:1;
+   GLuint pad0:17;
 
    GLuint copy_bfc_cw:1;
    GLuint copy_bfc_ccw:1;
@@ -167,4 +167,9 @@ void brw_clip_copy_colors( struct brw_clip_compile *c,
 
 void brw_clip_init_clipmask( struct brw_clip_compile *c );
 
+struct brw_reg get_tmp( struct brw_clip_compile *c );
+
+void brw_clip_project_position(struct brw_clip_compile *c,
+             struct brw_reg pos );
+
 #endif
index 83182270eac6f2b7f17720362a440e960e70869e..0930e6a57393344ce07519b95d200bd4b851d4fc 100644 (file)
@@ -130,6 +130,7 @@ static void clip_and_emit_line( struct brw_clip_compile *c )
    struct brw_instruction *plane_loop;
    struct brw_instruction *plane_active;
    struct brw_instruction *is_negative;
+   struct brw_instruction *is_neg2;
    struct brw_instruction *not_culled;
    struct brw_reg v1_null_ud = retype(vec1(brw_null_reg()), BRW_REGISTER_TYPE_UD);
 
@@ -146,6 +147,16 @@ static void clip_and_emit_line( struct brw_clip_compile *c )
    brw_clip_init_planes(c);
    brw_clip_init_clipmask(c);
 
+   /* -ve rhw workaround */
+   if (!(BRW_IS_GM45(p->brw) || BRW_IS_G4X(p->brw))) {
+      brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
+      brw_AND(p, brw_null_reg(), get_element_ud(c->reg.R0, 2),
+              brw_imm_ud(1<<20));
+      brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud(0x3f));
+   }
+
+   brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+
    plane_loop = brw_DO(p, BRW_EXECUTE_1);
    {
       /* if (planemask & 1)
@@ -183,13 +194,20 @@ static void clip_and_emit_line( struct brw_clip_compile *c )
            /* Coming back in.  We know that both cannot be negative
             * because the line would have been culled in that case.
             */
-           brw_ADD(p, c->reg.t, c->reg.dp0, negate(c->reg.dp1));
-           brw_math_invert(p, c->reg.t, c->reg.t);
-           brw_MUL(p, c->reg.t, c->reg.t, c->reg.dp0);
 
-           brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_G, c->reg.t, c->reg.t0 );
-           brw_MOV(p, c->reg.t0, c->reg.t);
-           brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+           /* If both are positive, do nothing */
+             brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_L, c->reg.dp0, brw_imm_f(0.0));
+             is_neg2 = brw_IF(p, BRW_EXECUTE_1);
+             {
+               brw_ADD(p, c->reg.t, c->reg.dp0, negate(c->reg.dp1));
+               brw_math_invert(p, c->reg.t, c->reg.t);
+               brw_MUL(p, c->reg.t, c->reg.t, c->reg.dp0);
+
+               brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_G, c->reg.t, c->reg.t0 );
+               brw_MOV(p, c->reg.t0, c->reg.t);
+               brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+            }
+            brw_ENDIF(p, is_neg2);
         }
         brw_ENDIF(p, is_negative);      
       }
index 1e6d6fa176285f88cd6efe68c907bf27dcf87ffa..51045f91880328d54bbc1a66b44e7da566e74d96 100644 (file)
 #include "brw_defines.h"
 #include "macros.h"
 
+struct brw_clip_unit_key {
+   unsigned int total_grf;
+   unsigned int urb_entry_read_length;
+   unsigned int curb_entry_read_length;
+   unsigned int clip_mode;
 
+   unsigned int curbe_offset;
 
-static void upload_clip_unit( struct brw_context *brw )
-{
-   struct brw_clip_unit_state clip;
+   unsigned int nr_urb_entries, urb_size;
+};
 
-   memset(&clip, 0, sizeof(clip));
+static void
+clip_unit_populate_key(struct brw_context *brw, struct brw_clip_unit_key *key)
+{
+   memset(key, 0, sizeof(*key));
 
    /* CACHE_NEW_CLIP_PROG */
-   clip.thread0.grf_reg_count = ((brw->clip.prog_data->total_grf-1) & ~15) / 16;
-   clip.thread0.kernel_start_pointer = brw->clip.prog_gs_offset >> 6;
-   clip.thread3.urb_entry_read_length = brw->clip.prog_data->urb_read_length;
-   clip.thread3.const_urb_entry_read_length = brw->clip.prog_data->curb_read_length;
-   clip.clip5.clip_mode = brw->clip.prog_data->clip_mode;
+   key->total_grf = brw->clip.prog_data->total_grf;
+   key->urb_entry_read_length = brw->clip.prog_data->urb_read_length;
+   key->curb_entry_read_length = brw->clip.prog_data->curb_read_length;
+   key->clip_mode = brw->clip.prog_data->clip_mode;
 
    /* BRW_NEW_CURBE_OFFSETS */
-   clip.thread3.const_urb_entry_read_offset = brw->curbe.clip_start * 2;
+   key->curbe_offset = brw->curbe.clip_start;
 
    /* BRW_NEW_URB_FENCE */
-   clip.thread4.nr_urb_entries = brw->urb.nr_clip_entries; 
-   clip.thread4.urb_entry_allocation_size = brw->urb.vsize - 1;
-   clip.thread4.max_threads = 0; /* Hmm, maybe the max is 1 or 2 threads */
+   key->nr_urb_entries = brw->urb.nr_clip_entries;
+   key->urb_size = brw->urb.vsize;
+}
 
-   if (INTEL_DEBUG & DEBUG_STATS)
-      clip.thread4.stats_enable = 1; 
+static dri_bo *
+clip_unit_create_from_key(struct brw_context *brw,
+                         struct brw_clip_unit_key *key)
+{
+   struct brw_clip_unit_state clip;
+   dri_bo *bo;
+
+   memset(&clip, 0, sizeof(clip));
+
+   clip.thread0.grf_reg_count = ALIGN(key->total_grf, 16) / 16 - 1;
+   /* reloc */
+   clip.thread0.kernel_start_pointer = brw->clip.prog_bo->offset >> 6;
 
-   /* CONSTANT */
    clip.thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
    clip.thread1.single_program_flow = 1;
+
+   clip.thread3.urb_entry_read_length = key->urb_entry_read_length;
+   clip.thread3.const_urb_entry_read_length = key->curb_entry_read_length;
+   clip.thread3.const_urb_entry_read_offset = key->curbe_offset * 2;
    clip.thread3.dispatch_grf_start_reg = 1;
    clip.thread3.urb_entry_read_offset = 0;
+
+   clip.thread4.nr_urb_entries = key->nr_urb_entries;
+   clip.thread4.urb_entry_allocation_size = key->urb_size - 1;
+   clip.thread4.max_threads = 1; /* 2 threads */
+
+   if (INTEL_DEBUG & DEBUG_STATS)
+      clip.thread4.stats_enable = 1;
+
    clip.clip5.userclip_enable_flags = 0x7f;
    clip.clip5.userclip_must_clip = 1;
    clip.clip5.guard_band_enable = 0;
    clip.clip5.viewport_z_clip_enable = 1;
    clip.clip5.viewport_xy_clip_enable = 1;
    clip.clip5.vertex_position_space = BRW_CLIP_NDCSPACE;
-   clip.clip5.api_mode = BRW_CLIP_API_OGL;   
+   clip.clip5.api_mode = BRW_CLIP_API_OGL;
+   clip.clip5.clip_mode = key->clip_mode;
+
+   if (BRW_IS_GM45(brw) || BRW_IS_G4X(brw))
+      clip.clip5.negative_w_clip_test = 1;
+
    clip.clip6.clipper_viewport_state_ptr = 0;
    clip.viewport_xmin = -1;
    clip.viewport_xmax = 1;
    clip.viewport_ymin = -1;
    clip.viewport_ymax = 1;
 
-   brw->clip.state_gs_offset = brw_cache_data( &brw->cache[BRW_CLIP_UNIT], &clip );
+   bo = brw_upload_cache(&brw->cache, BRW_CLIP_UNIT,
+                        key, sizeof(*key),
+                        &brw->clip.prog_bo, 1,
+                        &clip, sizeof(clip),
+                        NULL, NULL);
+
+   /* Emit clip program relocation */
+   assert(brw->clip.prog_bo);
+   dri_bo_emit_reloc(bo,
+                    I915_GEM_DOMAIN_INSTRUCTION,
+                    0,
+                    clip.thread0.grf_reg_count << 1,
+                    offsetof(struct brw_clip_unit_state, thread0),
+                    brw->clip.prog_bo);
+
+   return bo;
 }
 
+static void upload_clip_unit( struct brw_context *brw )
+{
+   struct brw_clip_unit_key key;
+
+   clip_unit_populate_key(brw, &key);
+
+   dri_bo_unreference(brw->clip.state_bo);
+   brw->clip.state_bo = brw_search_cache(&brw->cache, BRW_CLIP_UNIT,
+                                        &key, sizeof(key),
+                                        &brw->clip.prog_bo, 1,
+                                        NULL);
+   if (brw->clip.state_bo == NULL) {
+      brw->clip.state_bo = clip_unit_create_from_key(brw, &key);
+   }
+}
 
 const struct brw_tracked_state brw_clip_unit = {
    .dirty = {
@@ -89,5 +152,5 @@ const struct brw_tracked_state brw_clip_unit = {
                BRW_NEW_URB_FENCE),
       .cache = CACHE_NEW_CLIP_PROG
    },
-   .update = upload_clip_unit
+   .prepare = upload_clip_unit,
 };
index f62b02cedfd62c737da6a8105e7a7833659698a2..00039011b94e4fcf66e34c38554463195f05d240 100644 (file)
 #include "brw_util.h"
 #include "brw_clip.h"
 
+static void release_tmps( struct brw_clip_compile *c )
+{
+   c->last_tmp = c->first_tmp;
+}
 
 
 void brw_clip_tri_alloc_regs( struct brw_clip_compile *c, 
@@ -78,7 +82,7 @@ void brw_clip_tri_alloc_regs( struct brw_clip_compile *c,
    }
 
    c->reg.t          = brw_vec1_grf(i, 0);
-   c->reg.loopcount  = retype(brw_vec1_grf(i, 1), BRW_REGISTER_TYPE_UD);
+   c->reg.loopcount  = retype(brw_vec1_grf(i, 1), BRW_REGISTER_TYPE_D);
    c->reg.nr_verts   = retype(brw_vec1_grf(i, 2), BRW_REGISTER_TYPE_UD);
    c->reg.planemask  = retype(brw_vec1_grf(i, 3), BRW_REGISTER_TYPE_UD);
    c->reg.plane_equation = brw_vec4_grf(i, 4);
@@ -435,15 +439,103 @@ static void maybe_do_clip_tri( struct brw_clip_compile *c )
    brw_ENDIF(p, do_clip);
 }
 
-
+static void brw_clip_test( struct brw_clip_compile *c )
+{
+    struct brw_reg t = retype(get_tmp(c), BRW_REGISTER_TYPE_UD);
+    struct brw_reg t1 = retype(get_tmp(c), BRW_REGISTER_TYPE_UD);
+    struct brw_reg t2 = retype(get_tmp(c), BRW_REGISTER_TYPE_UD);
+    struct brw_reg t3 = retype(get_tmp(c), BRW_REGISTER_TYPE_UD);
+
+    struct brw_reg v0 = get_tmp(c);
+    struct brw_reg v1 = get_tmp(c);
+    struct brw_reg v2 = get_tmp(c);
+
+    struct brw_indirect vt0 = brw_indirect(0, 0);
+    struct brw_indirect vt1 = brw_indirect(1, 0);
+    struct brw_indirect vt2 = brw_indirect(2, 0);
+
+    struct brw_compile *p = &c->func;
+
+    brw_MOV(p, get_addr_reg(vt0), brw_address(c->reg.vertex[0]));
+    brw_MOV(p, get_addr_reg(vt1), brw_address(c->reg.vertex[1]));
+    brw_MOV(p, get_addr_reg(vt2), brw_address(c->reg.vertex[2]));
+    brw_MOV(p, v0, deref_4f(vt0, c->offset[VERT_RESULT_HPOS]));
+    brw_MOV(p, v1, deref_4f(vt1, c->offset[VERT_RESULT_HPOS]));
+    brw_MOV(p, v2, deref_4f(vt2, c->offset[VERT_RESULT_HPOS]));
+
+    /* test nearz, xmin, ymin plane */
+    brw_CMP(p, t1, BRW_CONDITIONAL_LE, negate(v0), get_element(v0, 3)); 
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+    brw_CMP(p, t2, BRW_CONDITIONAL_LE, negate(v1), get_element(v1, 3)); 
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+    brw_CMP(p, t3, BRW_CONDITIONAL_LE, negate(v2), get_element(v2, 3)); 
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+    brw_XOR(p, t, t1, t2);
+    brw_XOR(p, t1, t2, t3);
+    brw_OR(p, t, t, t1);
+
+    brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ, 
+           get_element(t, 0), brw_imm_ud(0));
+    brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<5)));
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+    brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ, 
+           get_element(t, 1), brw_imm_ud(0));
+    brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<3)));
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+    brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ, 
+           get_element(t, 2), brw_imm_ud(0));
+    brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<1)));
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+
+    /* test farz, xmax, ymax plane */
+    brw_CMP(p, t1, BRW_CONDITIONAL_L, v0, get_element(v0, 3)); 
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+    brw_CMP(p, t2, BRW_CONDITIONAL_L, v1, get_element(v1, 3)); 
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+    brw_CMP(p, t3, BRW_CONDITIONAL_L, v2, get_element(v2, 3)); 
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+
+    brw_XOR(p, t, t1, t2);
+    brw_XOR(p, t1, t2, t3);
+    brw_OR(p, t, t, t1);
+
+    brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ, 
+           get_element(t, 0), brw_imm_ud(0));
+    brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<4)));
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+    brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ, 
+           get_element(t, 1), brw_imm_ud(0));
+    brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<2)));
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+    brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ, 
+           get_element(t, 2), brw_imm_ud(0));
+    brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<0)));
+    brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+
+    release_tmps(c);
+}
 
 
 void brw_emit_tri_clip( struct brw_clip_compile *c )
 {
+   struct brw_instruction *neg_rhw;
+   struct brw_compile *p = &c->func;
    brw_clip_tri_alloc_regs(c, 3 + c->key.nr_userclip + 6);
    brw_clip_tri_init_vertices(c);
    brw_clip_init_clipmask(c);
 
+   /* if -ve rhw workaround bit is set, 
+      do cliptest */
+   if (!(BRW_IS_GM45(p->brw) || BRW_IS_G4X(p->brw))) {
+      brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
+      brw_AND(p, brw_null_reg(), get_element_ud(c->reg.R0, 2), 
+              brw_imm_ud(1<<20));
+      neg_rhw = brw_IF(p, BRW_EXECUTE_1); 
+      {
+         brw_clip_test(c);
+      }
+      brw_ENDIF(p, neg_rhw);
+   }
    /* Can't push into do_clip_tri because with polygon (or quad)
     * flatshading, need to apply the flatshade here because we don't
     * respect the PV when converting to trifan for emit:
@@ -462,6 +554,3 @@ void brw_emit_tri_clip( struct brw_clip_compile *c )
     */
    brw_clip_kill_thread(c);
 }
-
-
-
index 918e0001870d5448d7cb0f2299720acfa29066e9..6f20d798d84f31a18f5dd962f35947b36fab5c3a 100644 (file)
@@ -58,10 +58,30 @@ static void compute_tri_direction( struct brw_clip_compile *c )
    struct brw_reg v2 = byte_offset(c->reg.vertex[2], c->offset[VERT_RESULT_HPOS]); 
 
 
+   struct brw_reg v0n = get_tmp(c);
+   struct brw_reg v1n = get_tmp(c);
+   struct brw_reg v2n = get_tmp(c);
+
+   /* Convert to NDC.
+    * NOTE: We can't modify the original vertex coordinates,
+    * as it may impact further operations.
+    * So, we have to keep normalized coordinates in temp registers.
+    *
+    * TBD-KC
+    * Try to optimize unnecessary MOV's.
+    */
+   brw_MOV(p, v0n, v0);
+   brw_MOV(p, v1n, v1);
+   brw_MOV(p, v2n, v2);
+
+   brw_clip_project_position(c, v0n);
+   brw_clip_project_position(c, v1n);
+   brw_clip_project_position(c, v2n);
+
    /* Calculate the vectors of two edges of the triangle:
     */
-   brw_ADD(p, e, v0, negate(v2)); 
-   brw_ADD(p, f, v1, negate(v2)); 
+   brw_ADD(p, e, v0n, negate(v2n)); 
+   brw_ADD(p, f, v1n, negate(v2n)); 
 
    /* Take their crossproduct:
     */
@@ -220,8 +240,8 @@ static void apply_one_offset( struct brw_clip_compile *c,
                          struct brw_indirect vert )
 {
    struct brw_compile *p = &c->func;
-   struct brw_reg pos = deref_4f(vert, c->offset[VERT_RESULT_HPOS]);
-   struct brw_reg z = get_element(pos, 2);
+   struct brw_reg z = deref_1f(vert, c->header_position_offset +
+                              2 * type_sz(BRW_REGISTER_TYPE_F));
 
    brw_ADD(p, z, z, vec1(c->reg.offset));
 }
index 19bef19801a14d3aee9f99f00db82d438168ea51..c32bd4ec24f5e970b43415abf215924df13f2e43 100644 (file)
@@ -46,8 +46,7 @@
 
 
 
-
-static struct brw_reg get_tmp( struct brw_clip_compile *c )
+struct brw_reg get_tmp( struct brw_clip_compile *c )
 {
    struct brw_reg tmp = brw_vec4_grf(c->last_tmp, 0);
 
@@ -90,7 +89,7 @@ void brw_clip_init_planes( struct brw_clip_compile *c )
 
 /* Project 'pos' to screen space (or back again), overwrite with results:
  */
-static void brw_clip_project_position(struct brw_clip_compile *c, struct brw_reg pos )
+void brw_clip_project_position(struct brw_clip_compile *c, struct brw_reg pos )
 {
    struct brw_compile *p = &c->func;
 
@@ -262,7 +261,7 @@ void brw_clip_kill_thread(struct brw_clip_compile *c)
                 c->reg.R0,
                 0,             /* allocate */
                 0,             /* used */
-                0,             /* msg len */
+                1,             /* msg len */
                 0,             /* response len */
                 1,             /* eot */
                 1,             /* writes complete */
@@ -272,6 +271,7 @@ void brw_clip_kill_thread(struct brw_clip_compile *c)
 
 
 
+
 struct brw_reg brw_clip_plane0_address( struct brw_clip_compile *c )
 {
    return brw_address(c->reg.fixed_planes);
@@ -327,8 +327,7 @@ void brw_clip_init_clipmask( struct brw_clip_compile *c )
    
    /* Shift so that lowest outcode bit is rightmost: 
     */
-   brw_MOV(p, c->reg.planemask, incoming);
-   brw_SHR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud(26));
+   brw_SHR(p, c->reg.planemask, incoming, brw_imm_ud(26));
 
    if (c->key.nr_userclip) {
       struct brw_reg tmp = retype(vec1(get_tmp(c)), BRW_REGISTER_TYPE_UD);
@@ -342,13 +341,5 @@ void brw_clip_init_clipmask( struct brw_clip_compile *c )
       
       release_tmp(c, tmp);
    }
-
-   /* Test for -ve rhw workaround 
-    */
-   brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
-   brw_AND(p, vec1(brw_null_reg()), incoming, brw_imm_ud(1<<20));
-   brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud(0x3f));
-   brw_set_predicate_control(p, BRW_PREDICATE_NONE);
-
 }
 
index 397a9bd3f5cd2c36abf60d26929d566117533783..b4e2619929aaab05c92b8b36eb86d1bd2ff85c14 100644 (file)
@@ -31,7 +31,6 @@
 
 
 #include "brw_context.h"
-#include "brw_aub.h"
 #include "brw_defines.h"
 #include "brw_draw.h"
 #include "brw_vs.h"
 #include "intel_tex.h"
 #include "intel_blit.h"
 #include "intel_batchbuffer.h"
+#include "intel_pixel.h"
+#include "intel_span.h"
+#include "tnl/t_pipeline.h"
 
 #include "utils.h"
 #include "api_noop.h"
 #include "vtxfmt.h"
 
+#include "shader/shader_api.h"
+
 /***************************************
  * Mesa's Driver Functions
  ***************************************/
 
-static const struct dri_extension brw_extensions[] =
+static void brwUseProgram(GLcontext *ctx, GLuint program)
 {
-    { "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 },
-    { "GL_ARB_texture_env_crossbar",       NULL },
-    { NULL,                                NULL }
-};
-
+   _mesa_use_program(ctx, program);
+}
 
+static void brwInitProgFuncs( struct dd_function_table *functions )
+{
+   functions->UseProgram = brwUseProgram;
+}
 static void brwInitDriverFunctions( struct dd_function_table *functions )
 {
    intelInitDriverFunctions( functions );
-   brwInitTextureFuncs( functions );
+
    brwInitFragProgFuncs( functions );
+   brwInitProgFuncs( functions );
 }
 
 
@@ -116,10 +117,15 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis,
       return GL_FALSE;
    }
 
+   /* Initialize swrast, tnl driver tables: */
+   intelInitSpanFuncs(ctx);
+
+   TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline;
+
    ctx->Const.MaxTextureUnits = BRW_MAX_TEX_UNIT;
    ctx->Const.MaxTextureImageUnits = BRW_MAX_TEX_UNIT;
    ctx->Const.MaxTextureCoordUnits = BRW_MAX_TEX_UNIT;
-
+   ctx->Const.MaxVertexTextureImageUnits = 0; /* no vertex shader textures */
 
    /* Advertise the full hardware capabilities.  The new memory
     * manager should cope much better with overload situations:
@@ -128,15 +134,9 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis,
    ctx->Const.Max3DTextureLevels = 9;
    ctx->Const.MaxCubeTextureLevels = 12;
    ctx->Const.MaxTextureRectSize = (1<<11);
-   ctx->Const.MaxTextureUnits = BRW_MAX_TEX_UNIT;
    
 /*    ctx->Const.MaxNativeVertexProgramTemps = 32; */
 
-
-   driInitExtensions( ctx, brw_extensions, GL_FALSE );
-
-   brw_aub_init( brw );
-
    brw_init_attribs( brw );
    brw_init_metaops( brw );
    brw_init_state( brw );
@@ -144,8 +144,6 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis,
    brw->state.dirty.mesa = ~0;
    brw->state.dirty.brw = ~0;
 
-   memset(&brw->wm.bind, ~0, sizeof(brw->wm.bind));
-
    brw->emit_state_always = 0;
 
    ctx->FragmentProgram._MaintainTexEnvProgram = 1;
@@ -154,16 +152,6 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis,
 
    brw_ProgramCacheInit( ctx );
 
-   brw_FrameBufferTexInit( brw );
-
-   {
-      const char *filename = getenv("INTEL_REPLAY");
-      if (filename) {
-        brw_playback_aubfile(brw, filename);
-        exit(0);
-      }
-   }
-
    return GL_TRUE;
 }
 
index 08fdc545205c2dda9a869f14b990138975637d11..330d5714da28f1e8e70e2e08677dfedca4dc0da6 100644 (file)
@@ -135,13 +135,25 @@ struct brw_context;
 #define BRW_NEW_METAOPS                 0x1000
 #define BRW_NEW_FENCE                   0x2000
 #define BRW_NEW_LOCK                    0x4000
-
-
+#define BRW_NEW_INDICES                        0x8000
+#define BRW_NEW_VERTICES               0x10000
+/**
+ * Used for any batch entry with a relocated pointer that will be used
+ * by any 3D rendering.
+ */
+#define BRW_NEW_BATCH                  0x8000
+/** brw->depth_region updated */
+#define BRW_NEW_DEPTH_BUFFER           0x10000
 
 struct brw_state_flags {
+   /** State update flags signalled by mesa internals */
    GLuint mesa;
-   GLuint cache;
+   /**
+    * State update flags signalled as the result of brw_tracked_state updates
+    */
    GLuint brw;
+   /** State update flags signalled by brw_state_cache.c searches */
+   GLuint cache;
 };
 
 struct brw_vertex_program {
@@ -230,32 +242,46 @@ struct brw_vs_ouput_sizes {
 
 
 #define BRW_MAX_TEX_UNIT 8
-#define BRW_WM_MAX_SURF BRW_MAX_TEX_UNIT + 1
-
-/* Create a fixed sized struct for caching binding tables:
- */
-struct brw_surface_binding_table {
-   GLuint surf_ss_offset[BRW_WM_MAX_SURF];
-};
-
-
-struct brw_cache;
+#define BRW_WM_MAX_SURF BRW_MAX_TEX_UNIT + MAX_DRAW_BUFFERS
 
-struct brw_mem_pool {
-   struct buffer *buffer;
-
-   GLuint size;
-   GLuint offset;              /* offset of first free byte */
+enum brw_cache_id {
+   BRW_CC_VP,
+   BRW_CC_UNIT,
+   BRW_WM_PROG,
+   BRW_SAMPLER_DEFAULT_COLOR,
+   BRW_SAMPLER,
+   BRW_WM_UNIT,
+   BRW_SF_PROG,
+   BRW_SF_VP,
+   BRW_SF_UNIT,
+   BRW_VS_UNIT,
+   BRW_VS_PROG,
+   BRW_GS_UNIT,
+   BRW_GS_PROG,
+   BRW_CLIP_VP,
+   BRW_CLIP_UNIT,
+   BRW_CLIP_PROG,
+   BRW_SS_SURFACE,
+   BRW_SS_SURF_BIND,
 
-   struct brw_context *brw;
+   BRW_MAX_CACHE
 };
 
 struct brw_cache_item {
+   /**
+    * Effectively part of the key, cache_id identifies what kind of state
+    * buffer is involved, and also which brw->state.dirty.cache flag should
+    * be set when this cache item is chosen.
+    */
+   enum brw_cache_id cache_id;
+   /** 32-bit hash of the key data */
    GLuint hash;
    GLuint key_size;            /* for variable-sized keys */
    const void *key;
+   dri_bo **reloc_bufs;
+   GLuint nr_reloc_bufs;
 
-   GLuint offset;              /* offset within pool's buffer */
+   dri_bo *bo;
    GLuint data_size;
 
    struct brw_cache_item *next;
@@ -264,23 +290,19 @@ struct brw_cache_item {
 
 
 struct brw_cache {
-   GLuint id;
-
-   const char *name;
-
    struct brw_context *brw;
-   struct brw_mem_pool *pool;
 
    struct brw_cache_item **items;
    GLuint size, n_items;
-   
-   GLuint key_size;            /* for fixed-size keys */
-   GLuint aux_size;
 
-   GLuint aub_type;
-   GLuint aub_sub_type;
-   
-   GLuint last_addr;                   /* offset of active item */
+   GLuint key_size[BRW_MAX_CACHE];             /* for fixed-size keys */
+   GLuint aux_size[BRW_MAX_CACHE];
+   char *name[BRW_MAX_CACHE];
+
+   /* Record of the last BOs chosen for each cache_id.  Used to set
+    * brw->state.dirty.cache when a new cache item is chosen.
+    */
+   dri_bo *last_bo[BRW_MAX_CACHE];
 };
 
 
@@ -312,34 +334,8 @@ struct brw_state_pointers {
  */
 struct brw_tracked_state {
    struct brw_state_flags dirty;
-   void (*update)( struct brw_context *brw );
-};
-
-
-enum brw_cache_id {
-   BRW_CC_VP,
-   BRW_CC_UNIT,
-   BRW_WM_PROG,
-   BRW_SAMPLER_DEFAULT_COLOR,
-   BRW_SAMPLER,
-   BRW_WM_UNIT,
-   BRW_SF_PROG,
-   BRW_SF_VP,
-   BRW_SF_UNIT,
-   BRW_VS_UNIT,
-   BRW_VS_PROG,
-   BRW_GS_UNIT,
-   BRW_GS_PROG,
-   BRW_CLIP_VP,
-   BRW_CLIP_UNIT,
-   BRW_CLIP_PROG,
-
-   /* These two are in the SS pool:
-    */
-   BRW_SS_SURFACE,
-   BRW_SS_SURF_BIND,
-
-   BRW_MAX_CACHE
+   void (*prepare)( struct brw_context *brw );
+   void (*emit)( struct brw_context *brw );
 };
 
 /* Flags for brw->state.cache.
@@ -363,16 +359,6 @@ enum brw_cache_id {
 #define CACHE_NEW_SURFACE                (1<<BRW_SS_SURFACE)
 #define CACHE_NEW_SURF_BIND              (1<<BRW_SS_SURF_BIND)
 
-
-
-
-enum brw_mempool_id {
-   BRW_GS_POOL,
-   BRW_SS_POOL,
-   BRW_MAX_POOL
-};
-
-
 struct brw_cached_batch_item {
    struct header *header;
    GLuint sz;
@@ -389,12 +375,16 @@ struct brw_cached_batch_item {
 struct brw_vertex_element {
    const struct gl_client_array *glarray;
 
-   struct brw_vertex_element_state *vep;
-
-   GLuint index;
+   /** Size of a complete element */
    GLuint element_size;
+   /** Number of uploaded elements for this input. */
    GLuint count;
-   GLuint vbo_rebase_offset;
+   /** Byte stride between elements in the uploaded array */
+   GLuint stride;
+   /** Offset of the first element within the buffer object */
+   unsigned int offset;
+   /** Buffer object containing the uploaded vertex data */
+   dri_bo *bo;
 };
 
 
@@ -431,48 +421,52 @@ struct brw_context
    GLboolean emit_state_always;
    GLboolean wrap;
    GLboolean tmp_fallback;
+   GLboolean no_batch_wrap;
 
    struct {
       struct brw_state_flags dirty;
       struct brw_tracked_state **atoms;
       GLuint nr_atoms;
 
-
-      struct intel_region *draw_region;
+      GLuint nr_draw_regions;
+      struct intel_region *draw_regions[MAX_DRAW_BUFFERS];
       struct intel_region *depth_region;
    } state;
 
    struct brw_state_pointers attribs;
-   struct brw_mem_pool pool[BRW_MAX_POOL];
-   struct brw_cache cache[BRW_MAX_CACHE];
+   struct brw_cache cache;
    struct brw_cached_batch_item *cached_batch_items;
 
    struct {
-
-      /* Arrays with buffer objects to copy non-bufferobj arrays into
-       * for upload:
-       */
-      struct gl_client_array vbo_array[VERT_ATTRIB_MAX];
-
       struct brw_vertex_element inputs[VERT_ATTRIB_MAX];
 
 #define BRW_NR_UPLOAD_BUFS 17
 #define BRW_UPLOAD_INIT_SIZE (128*1024)
 
       struct {
-        struct gl_buffer_object *vbo[BRW_NR_UPLOAD_BUFS];
-        GLuint buf;
+        dri_bo *bo;
         GLuint offset;
-        GLuint size;
-        GLuint wrap;
       } upload;
 
       /* Summary of size and varying of active arrays, so we can check
        * for changes to this state:
        */
       struct brw_vertex_info info;
+      unsigned int min_index, max_index;
    } vb;
 
+   struct {
+      /**
+       * Index buffer for this draw_prims call.
+       *
+       * Updates are signaled by BRW_NEW_INDICES.
+       */
+      const struct _mesa_index_buffer *ib;
+
+      dri_bo *bo;
+      unsigned int offset;
+   } ib;
+
    struct {
       /* Will be allocated on demand if needed.   
        */
@@ -483,9 +477,12 @@ struct brw_context
       struct gl_buffer_object *vbo;
 
       struct intel_region *saved_draw_region;
+      GLuint saved_nr_draw_regions;
       struct intel_region *saved_depth_region;
 
-      GLuint restore_draw_mask;
+      GLuint restore_draw_buffers[MAX_DRAW_BUFFERS];
+      GLuint restore_num_draw_buffers;
+
       struct gl_fragment_program *restore_fp;
       
       GLboolean active;
@@ -552,7 +549,11 @@ struct brw_context
        */
       struct brw_tracked_state tracked_state;
 
-      GLuint gs_offset;
+      dri_bo *curbe_bo;
+      /** Offset within curbe_bo of space for current curbe entry */
+      GLuint curbe_offset;
+      /** Offset within curbe_bo of space for next curbe entry */
+      GLuint curbe_next_offset;
 
       GLfloat *last_buf;
       GLuint last_bufsz;
@@ -561,33 +562,33 @@ struct brw_context
    struct {
       struct brw_vs_prog_data *prog_data;
 
-      GLuint prog_gs_offset;
-      GLuint state_gs_offset;  
+      dri_bo *prog_bo;
+      dri_bo *state_bo;
    } vs;
 
    struct {
       struct brw_gs_prog_data *prog_data;
 
       GLboolean prog_active;
-      GLuint prog_gs_offset;
-      GLuint state_gs_offset;  
+      dri_bo *prog_bo;
+      dri_bo *state_bo;
    } gs;
 
    struct {
       struct brw_clip_prog_data *prog_data;
 
-      GLuint prog_gs_offset;
-      GLuint vp_gs_offset;
-      GLuint state_gs_offset;  
+      dri_bo *prog_bo;
+      dri_bo *state_bo;
+      dri_bo *vp_bo;
    } clip;
 
 
    struct {
       struct brw_sf_prog_data *prog_data;
 
-      GLuint prog_gs_offset;
-      GLuint vp_gs_offset;
-      GLuint state_gs_offset;
+      dri_bo *prog_bo;
+      dri_bo *state_bo;
+      dri_bo *vp_bo;
    } sf;
 
    struct {
@@ -598,33 +599,31 @@ struct brw_context
        */
       GLuint input_size_masks[4];
 
-
-      /* State structs
-       */
-      struct brw_sampler_default_color sdc[BRW_MAX_TEX_UNIT];
-      struct brw_sampler_state sampler[BRW_MAX_TEX_UNIT];
+      /** Array of surface default colors (texture border color) */
+      dri_bo *sdc_bo[BRW_MAX_TEX_UNIT];
 
       GLuint render_surf;
       GLuint nr_surfaces;      
 
       GLuint max_threads;
-      struct buffer *scratch_buffer;
-      GLuint scratch_buffer_size;
+      dri_bo *scratch_buffer;
 
       GLuint sampler_count;
-      GLuint sampler_gs_offset;
+      dri_bo *sampler_bo;
 
-      struct brw_surface_binding_table bind;
-      GLuint bind_ss_offset;
+      /** Binding table of pointers to surf_bo entries */
+      dri_bo *bind_bo;
+      dri_bo *surf_bo[BRW_WM_MAX_SURF];
 
-      GLuint prog_gs_offset;
-      GLuint state_gs_offset;
+      dri_bo *prog_bo;
+      dri_bo *state_bo;
    } wm;
 
 
    struct {
-      GLuint vp_gs_offset;
-      GLuint state_gs_offset;
+      dri_bo *prog_bo;
+      dri_bo *state_bo;
+      dri_bo *vp_bo;
    } cc;
 
    
@@ -662,14 +661,19 @@ void brw_init_state( struct brw_context *brw );
 void brw_destroy_state( struct brw_context *brw );
 
 
+/*======================================================================
+ * brw_state_dump.c
+ */
+void brw_debug_batch(struct intel_context *intel);
 
 /*======================================================================
  * brw_tex.c
  */
 void brwUpdateTextureState( struct intel_context *intel );
-void brwInitTextureFuncs( struct dd_function_table *functions );
-void brw_FrameBufferTexInit( struct brw_context *brw );
+void brw_FrameBufferTexInit( struct brw_context *brw,
+                            struct intel_region *region );
 void brw_FrameBufferTexDestroy( struct brw_context *brw );
+void brw_validate_textures( struct brw_context *brw );
 
 /*======================================================================
  * brw_metaops.c
@@ -696,11 +700,13 @@ void brw_upload_constant_buffer_state(struct brw_context *brw);
  * Inline conversion functions.  These are better-typed than the
  * macros used previously:
  */
-static inline struct brw_context *
+static INLINE struct brw_context *
 brw_context( GLcontext *ctx )
 {
    return (struct brw_context *)ctx;
 }
 
+#define DO_SETUP_BITS ((1<<(FRAG_ATTRIB_MAX)) - 1)
+
 #endif
 
index 3f0aaa1f86dd67268e68fb9d0abb1ff2cc39911a..0a3600193b297a406f22f95e93149e0edc5dcede 100644 (file)
@@ -42,7 +42,6 @@
 #include "brw_defines.h"
 #include "brw_state.h"
 #include "brw_util.h"
-#include "brw_aub.h"
 
 
 /* Partition the CURBE between the various users of constant values:
@@ -90,7 +89,7 @@ static void calculate_curbe_offsets( struct brw_context *brw )
     */
    if (nr_fp_regs > brw->curbe.wm_size ||
        nr_vp_regs > brw->curbe.vs_size ||
-       nr_clip_regs > brw->curbe.clip_size ||
+       nr_clip_regs != brw->curbe.clip_size ||
        (total_regs < brw->curbe.total_size / 4 &&
        brw->curbe.total_size > 16)) {
 
@@ -127,7 +126,7 @@ const struct brw_tracked_state brw_curbe_offsets = {
       .brw  = BRW_NEW_VERTEX_PROGRAM,
       .cache = CACHE_NEW_WM_PROG
    },
-   .update = calculate_curbe_offsets
+   .prepare = calculate_curbe_offsets
 };
 
 
@@ -156,19 +155,7 @@ void brw_upload_constant_buffer_state(struct brw_context *brw)
 
    assert(brw->urb.nr_cs_entries);
    BRW_CACHED_BATCH_STRUCT(brw, &cbs);
-}      
-
-#if 0
-const struct brw_tracked_state brw_constant_buffer_state = {
-   .dirty = {
-      .mesa = 0,
-      .brw = BRW_NEW_URB_FENCE,
-      .cache = 0
-   },
-   .update = brw_upload_constant_buffer_state
-};
-#endif
-
+}
 
 static GLfloat fixed_plane[6][4] = {
    { 0,    0,   -1, 1 },
@@ -183,12 +170,11 @@ static GLfloat fixed_plane[6][4] = {
  * cache mechanism, but maybe would benefit from a comparison against
  * the current uploaded set of constants.
  */
-static void upload_constant_buffer(struct brw_context *brw)
+static void prepare_constant_buffer(struct brw_context *brw)
 {
    GLcontext *ctx = &brw->intel.ctx;
    struct brw_vertex_program *vp = (struct brw_vertex_program *)brw->vertex_program;
    struct brw_fragment_program *fp = (struct brw_fragment_program *)brw->fragment_program;
-   struct brw_mem_pool *pool = &brw->pool[BRW_GS_POOL];
    GLuint sz = brw->curbe.total_size;
    GLuint bufsz = sz * 16 * sizeof(GLfloat);
    GLfloat *buf;
@@ -202,20 +188,13 @@ static void upload_constant_buffer(struct brw_context *brw)
    brw->curbe.tracked_state.dirty.mesa |= fp->param_state;
 
    if (sz == 0) {
-      struct brw_constant_buffer cb;
-      cb.header.opcode = CMD_CONST_BUFFER;
-      cb.header.length = sizeof(cb)/4 - 2;
-      cb.header.valid = 0;
-      cb.bits0.buffer_length = 0;
-      cb.bits0.buffer_address = 0;
-      BRW_BATCH_STRUCT(brw, &cb);
 
       if (brw->curbe.last_buf) {
         free(brw->curbe.last_buf);
         brw->curbe.last_buf = NULL;
         brw->curbe.last_bufsz  = 0;
       }
-       
+
       return;
    }
 
@@ -290,11 +269,11 @@ static void upload_constant_buffer(struct brw_context *brw)
                   brw->curbe.last_buf ? memcmp(buf, brw->curbe.last_buf, bufsz) : -1);
    }
 
-   if (brw->curbe.last_buf &&
+   if (brw->curbe.curbe_bo != NULL &&
+       brw->curbe.last_buf &&
        bufsz == brw->curbe.last_bufsz &&
        memcmp(buf, brw->curbe.last_buf, bufsz) == 0) {
       free(buf);
-/*       return; */
    } 
    else {
       if (brw->curbe.last_buf)
@@ -302,61 +281,71 @@ static void upload_constant_buffer(struct brw_context *brw)
       brw->curbe.last_buf = buf;
       brw->curbe.last_bufsz = bufsz;
 
-      
-      if (!brw_pool_alloc(pool, 
-                         bufsz,
-                         6,
-                         &brw->curbe.gs_offset)) {
-        _mesa_printf("out of GS memory for curbe\n");
-        assert(0);
-        return;
+      if (brw->curbe.curbe_bo != NULL &&
+         brw->curbe.curbe_next_offset + bufsz > brw->curbe.curbe_bo->size)
+      {
+        dri_bo_unreference(brw->curbe.curbe_bo);
+        brw->curbe.curbe_bo = NULL;
+      }
+
+      if (brw->curbe.curbe_bo == NULL) {
+        /* Allocate a single page for CURBE entries for this batchbuffer.
+         * They're generally around 64b.
+         */
+        brw->curbe.curbe_bo = dri_bo_alloc(brw->intel.bufmgr, "CURBE",
+                                           4096, 1 << 6);
+        brw->curbe.curbe_next_offset = 0;
       }
-            
+
+      brw->curbe.curbe_offset = brw->curbe.curbe_next_offset;
+      brw->curbe.curbe_next_offset += bufsz;
+      brw->curbe.curbe_next_offset = ALIGN(brw->curbe.curbe_next_offset, 64);
 
       /* Copy data to the buffer:
        */
-      bmBufferSubDataAUB(&brw->intel,
-                        pool->buffer,
-                        brw->curbe.gs_offset, 
-                        bufsz, 
-                        buf,
-                        DW_CONSTANT_BUFFER,
-                        0);
+      dri_bo_subdata(brw->curbe.curbe_bo, brw->curbe.curbe_offset, bufsz, buf);
    }
 
-   /* TODO: only emit the constant_buffer packet when necessary, ie:
-      - contents have changed
-      - offset has changed
-      - hw requirements due to other packets emitted.
-   */
-   {
-      struct brw_constant_buffer cb;
-      
-      memset(&cb, 0, sizeof(cb));
-
-      cb.header.opcode = CMD_CONST_BUFFER;
-      cb.header.length = sizeof(cb)/4 - 2;
-      cb.header.valid = 1;
-      cb.bits0.buffer_length = sz - 1;
-      cb.bits0.buffer_address = brw->curbe.gs_offset >> 6;
-      
-      /* Because this provokes an action (ie copy the constants into the
-       * URB), it shouldn't be shortcircuited if identical to the
-       * previous time - because eg. the urb destination may have
-       * changed, or the urb contents different to last time.  
-       *
-       * Note that the data referred to is actually copied internally,
-       * not just used in place according to passed pointer.
-       *
-       * It appears that the CS unit takes care of using each available
-       * URB entry (Const URB Entry == CURBE) in turn, and issuing
-       * flushes as necessary when doublebuffering of CURBEs isn't
-       * possible.
-       */
-/*       intel_batchbuffer_align(brw->intel.batch, 64, sizeof(cb)); */
-      BRW_BATCH_STRUCT(brw, &cb);
-/*       intel_batchbuffer_align(brw->intel.batch, 64, 0); */
+
+   /* Because this provokes an action (ie copy the constants into the
+    * URB), it shouldn't be shortcircuited if identical to the
+    * previous time - because eg. the urb destination may have
+    * changed, or the urb contents different to last time.
+    *
+    * Note that the data referred to is actually copied internally,
+    * not just used in place according to passed pointer.
+    *
+    * It appears that the CS unit takes care of using each available
+    * URB entry (Const URB Entry == CURBE) in turn, and issuing
+    * flushes as necessary when doublebuffering of CURBEs isn't
+    * possible.
+    */
+}
+
+
+static void emit_constant_buffer(struct brw_context *brw)
+{
+   struct intel_context *intel = &brw->intel;
+   GLuint sz = brw->curbe.total_size;
+   dri_bo *aper_array[] = {
+      brw->intel.batch->buf,
+      brw->curbe.curbe_bo,
+   };
+
+   if (dri_bufmgr_check_aperture_space(aper_array, ARRAY_SIZE(aper_array)))
+      intel_batchbuffer_flush(intel->batch);
+
+   BEGIN_BATCH(2, IGNORE_CLIPRECTS);
+   if (sz == 0) {
+      OUT_BATCH((CMD_CONST_BUFFER << 16) | (2 - 2));
+      OUT_BATCH(0);
+   } else {
+      OUT_BATCH((CMD_CONST_BUFFER << 16) | (1 << 8) | (2 - 2));
+      OUT_RELOC(brw->curbe.curbe_bo,
+               I915_GEM_DOMAIN_INSTRUCTION, 0,
+               (sz - 1) + brw->curbe.curbe_offset);
    }
+   ADVANCE_BATCH();
 }
 
 /* This tracked state is unique in that the state it monitors varies
@@ -372,9 +361,11 @@ const struct brw_tracked_state brw_constant_buffer = {
               BRW_NEW_VERTEX_PROGRAM |
               BRW_NEW_URB_FENCE | /* Implicit - hardware requires this, not used above */
               BRW_NEW_PSP | /* Implicit - hardware requires this, not used above */
-              BRW_NEW_CURBE_OFFSETS),
+              BRW_NEW_CURBE_OFFSETS |
+              BRW_NEW_BATCH),
       .cache = (CACHE_NEW_WM_PROG) 
    },
-   .update = upload_constant_buffer
+   .prepare = prepare_constant_buffer,
+   .emit = emit_constant_buffer,
 };
 
index e8f878a70180813ddef1a6c3ec2c1fcbff6070cf..0593e8d5f5ff039e64d4f955496e4ed7a3b4f984 100644 (file)
 #ifndef BRW_DEFINES_H
 #define BRW_DEFINES_H
 
-/*
- */
-#define MI_NOOP                              0x00
-#define MI_USER_INTERRUPT                    0x02
-#define MI_WAIT_FOR_EVENT                    0x03
-#define MI_FLUSH                             0x04
-#define MI_REPORT_HEAD                       0x07
-#define MI_ARB_ON_OFF                        0x08
-#define MI_BATCH_BUFFER_END                  0x0A
-#define MI_OVERLAY_FLIP                      0x11
-#define MI_LOAD_SCAN_LINES_INCL              0x12
-#define MI_LOAD_SCAN_LINES_EXCL              0x13
-#define MI_DISPLAY_BUFFER_INFO               0x14
-#define MI_SET_CONTEXT                       0x18
-#define MI_STORE_DATA_IMM                    0x20
-#define MI_STORE_DATA_INDEX                  0x21
-#define MI_LOAD_REGISTER_IMM                 0x22
-#define MI_STORE_REGISTER_MEM                0x24
-#define MI_BATCH_BUFFER_START                0x31
-
-#define MI_SYNCHRONOUS_FLIP                  0x0 
-#define MI_ASYNCHRONOUS_FLIP                 0x1
-
-#define MI_BUFFER_SECURE                     0x0 
-#define MI_BUFFER_NONSECURE                  0x1
-
-#define MI_ARBITRATE_AT_CHAIN_POINTS         0x0 
-#define MI_ARBITRATE_BETWEEN_INSTS           0x1
-#define MI_NO_ARBITRATION                    0x3 
-
-#define MI_CONDITION_CODE_WAIT_DISABLED      0x0
-#define MI_CONDITION_CODE_WAIT_0             0x1
-#define MI_CONDITION_CODE_WAIT_1             0x2
-#define MI_CONDITION_CODE_WAIT_2             0x3
-#define MI_CONDITION_CODE_WAIT_3             0x4
-#define MI_CONDITION_CODE_WAIT_4             0x5
-
-#define MI_DISPLAY_PIPE_A                    0x0
-#define MI_DISPLAY_PIPE_B                    0x1
-
-#define MI_DISPLAY_PLANE_A                   0x0 
-#define MI_DISPLAY_PLANE_B                   0x1
-#define MI_DISPLAY_PLANE_C                   0x2
-
-#define MI_STANDARD_FLIP                                 0x0
-#define MI_ENQUEUE_FLIP_PERFORM_BASE_FRAME_NUMBER_LOAD   0x1
-#define MI_ENQUEUE_FLIP_TARGET_FRAME_NUMBER_RELATIVE     0x2
-#define MI_ENQUEUE_FLIP_ABSOLUTE_TARGET_FRAME_NUMBER     0x3
-
-#define MI_PHYSICAL_ADDRESS                  0x0
-#define MI_VIRTUAL_ADDRESS                   0x1
-
-#define MI_BUFFER_MEMORY_MAIN                0x0 
-#define MI_BUFFER_MEMORY_GTT                 0x2
-#define MI_BUFFER_MEMORY_PER_PROCESS_GTT     0x3 
-
-#define MI_FLIP_CONTINUE                     0x0
-#define MI_FLIP_ON                           0x1
-#define MI_FLIP_OFF                          0x2
-
-#define MI_UNTRUSTED_REGISTER_SPACE          0x0
-#define MI_TRUSTED_REGISTER_SPACE            0x1
-
 /* 3D state:
  */
 #define _3DOP_3DSTATE_PIPELINED       0x0
 #define _3DSTATE_LINE_STIPPLE                 0x08
 #define _3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP    0x09
 #define _3DCONTROL    0x00
-#define _3DPRIMITIVE  0x00
 
 #define PIPE_CONTROL_NOWRITE          0x00
 #define PIPE_CONTROL_WRITEIMMEDIATE   0x01
 #define BRW_FRONTWINDING_CW      0
 #define BRW_FRONTWINDING_CCW     1
 
+#define BRW_SPRITE_POINT_ENABLE  16
+
 #define BRW_INDEX_BYTE     0
 #define BRW_INDEX_WORD     1
 #define BRW_INDEX_DWORD    2
 #define BRW_VERTEX_SUBPIXEL_PRECISION_8BITS  0
 #define BRW_VERTEX_SUBPIXEL_PRECISION_4BITS  1
 
-#define BRW_VERTEXBUFFER_ACCESS_VERTEXDATA     0
-#define BRW_VERTEXBUFFER_ACCESS_INSTANCEDATA   1
-
-#define BRW_VFCOMPONENT_NOSTORE      0
-#define BRW_VFCOMPONENT_STORE_SRC    1
-#define BRW_VFCOMPONENT_STORE_0      2
-#define BRW_VFCOMPONENT_STORE_1_FLT  3
-#define BRW_VFCOMPONENT_STORE_1_INT  4
-#define BRW_VFCOMPONENT_STORE_VID    5
-#define BRW_VFCOMPONENT_STORE_IID    6
-#define BRW_VFCOMPONENT_STORE_PID    7
-
-
-
 /* Execution Unit (EU) defines
  */
 
 
 #define CMD_STATE_BASE_ADDRESS        0x6101
 #define CMD_STATE_INSN_POINTER        0x6102
-#define CMD_PIPELINE_SELECT           0x6104
+#define CMD_PIPELINE_SELECT_965       0x6104
+#define CMD_PIPELINE_SELECT_GM45      0x6904
 
 #define CMD_PIPELINED_STATE_POINTERS  0x7800
 #define CMD_BINDING_TABLE_PTRS        0x7801
+
 #define CMD_VERTEX_BUFFER             0x7808
+# define BRW_VB0_INDEX_SHIFT           27
+# define BRW_VB0_ACCESS_VERTEXDATA     (0 << 26)
+# define BRW_VB0_ACCESS_INSTANCEDATA   (1 << 26)
+# define BRW_VB0_PITCH_SHIFT           0
+
 #define CMD_VERTEX_ELEMENT            0x7809
+# define BRW_VE0_INDEX_SHIFT           27
+# define BRW_VE0_FORMAT_SHIFT          16
+# define BRW_VE0_VALID                 (1 << 26)
+# define BRW_VE0_SRC_OFFSET_SHIFT      0
+# define BRW_VE1_COMPONENT_NOSTORE     0
+# define BRW_VE1_COMPONENT_STORE_SRC   1
+# define BRW_VE1_COMPONENT_STORE_0     2
+# define BRW_VE1_COMPONENT_STORE_1_FLT 3
+# define BRW_VE1_COMPONENT_STORE_1_INT 4
+# define BRW_VE1_COMPONENT_STORE_VID   5
+# define BRW_VE1_COMPONENT_STORE_IID   6
+# define BRW_VE1_COMPONENT_STORE_PID   7
+# define BRW_VE1_COMPONENT_0_SHIFT     28
+# define BRW_VE1_COMPONENT_1_SHIFT     24
+# define BRW_VE1_COMPONENT_2_SHIFT     20
+# define BRW_VE1_COMPONENT_3_SHIFT     16
+# define BRW_VE1_DST_OFFSET_SHIFT      0
+
 #define CMD_INDEX_BUFFER              0x780a
-#define CMD_VF_STATISTICS             0x780b
+#define CMD_VF_STATISTICS_965         0x780b
+#define CMD_VF_STATISTICS_GM45        0x680b
 
 #define CMD_DRAW_RECT                 0x7900
 #define CMD_BLEND_CONSTANT_COLOR      0x7901
 #define CMD_POLY_STIPPLE_PATTERN      0x7907
 #define CMD_LINE_STIPPLE_PATTERN      0x7908
 #define CMD_GLOBAL_DEPTH_OFFSET_CLAMP 0x7909
+#define CMD_AA_LINE_PARAMETERS        0x790a
 
 #define CMD_PIPE_CONTROL              0x7a00
 
 #define R02_PRIM_END    0x1
 #define R02_PRIM_START  0x2
 
+#include "intel_chipset.h"
 
+#define BRW_IS_GM45(brw)        (IS_GM45_GM((brw)->intel.intelScreen->deviceID))
+#define BRW_IS_G4X(brw)         (IS_G4X((brw)->intel.intelScreen->deviceID))
+#define CMD_PIPELINE_SELECT(brw)        ((BRW_IS_GM45(brw) || BRW_IS_G4X(brw)) ? CMD_PIPELINE_SELECT_GM45 : CMD_PIPELINE_SELECT_965)
+#define CMD_VF_STATISTICS(brw)          ((BRW_IS_GM45(brw) || BRW_IS_G4X(brw)) ? CMD_VF_STATISTICS_GM45 : CMD_VF_STATISTICS_965)
+#define URB_SIZES(brw)                  ((BRW_IS_GM45(brw) || BRW_IS_G4X(brw)) ? 384 : 256)  /* 512 bit unit */
 
 #endif
index 0c64d7e756dca93369bb14ce211ae6ffcb142e61..95d798238d95adbfe1ff834c88e4ccce60e449b8 100644 (file)
 #include "brw_draw.h"
 #include "brw_defines.h"
 #include "brw_context.h"
-#include "brw_aub.h"
 #include "brw_state.h"
 #include "brw_fallback.h"
 
-#include "intel_ioctl.h"
 #include "intel_batchbuffer.h"
 #include "intel_buffer_objects.h"
 
@@ -49,7 +47,7 @@
 #include "swrast/swrast.h"
 #include "swrast_setup/swrast_setup.h"
 
-
+#define FILE_DEBUG_FLAG DEBUG_BATCH
 
 static GLuint hw_prim[GL_POLYGON+1] = {
    _3DPRIM_POINTLIST,
@@ -124,25 +122,6 @@ static GLuint trim(GLenum prim, GLuint length)
 }
 
 
-static void brw_emit_cliprect( struct brw_context *brw, 
-                              const drm_clip_rect_t *rect )
-{
-   struct brw_drawrect bdr;
-
-   bdr.header.opcode = CMD_DRAW_RECT;
-   bdr.header.length = sizeof(bdr)/4 - 2;
-   bdr.xmin = rect->x1;
-   bdr.xmax = rect->x2 - 1;
-   bdr.ymin = rect->y1;
-   bdr.ymax = rect->y2 - 1;
-   bdr.xorg = brw->intel.drawX;
-   bdr.yorg = brw->intel.drawY;
-
-   intel_batchbuffer_data( brw->intel.batch, &bdr, sizeof(bdr), 
-                          INTEL_BATCH_NO_CLIPRECTS);
-}
-
-
 static void brw_emit_prim( struct brw_context *brw, 
                           const struct _mesa_prim *prim )
 
@@ -165,10 +144,13 @@ static void brw_emit_prim( struct brw_context *brw,
    prim_packet.start_instance_location = 0;
    prim_packet.base_vert_location = 0;
 
+   /* Can't wrap here, since we rely on the validated state. */
+   brw->no_batch_wrap = GL_TRUE;
    if (prim_packet.verts_per_instance) {
-      intel_batchbuffer_data( brw->intel.batch, &prim_packet, sizeof(prim_packet), 
-                             INTEL_BATCH_NO_CLIPRECTS);
+      intel_batchbuffer_data( brw->intel.batch, &prim_packet,
+                             sizeof(prim_packet), LOOP_CLIPRECTS);
    }
+   brw->no_batch_wrap = GL_FALSE;
 }
 
 static void brw_merge_inputs( struct brw_context *brw,
@@ -271,15 +253,23 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx,
    struct intel_context *intel = intel_context(ctx);
    struct brw_context *brw = brw_context(ctx);
    GLboolean retval = GL_FALSE;
-   GLuint i, j;
+   GLuint i;
 
    if (ctx->NewState)
       _mesa_update_state( ctx );
 
+   brw_validate_textures( brw );
+
    /* Bind all inputs, derive varying and size information:
     */
    brw_merge_inputs( brw, arrays );
-      
+
+   brw->ib.ib = ib;
+   brw->state.dirty.brw |= BRW_NEW_INDICES;
+
+   brw->vb.min_index = min_index;
+   brw->vb.max_index = max_index;
+   brw->state.dirty.brw |= BRW_NEW_VERTICES;
    /* Have to validate state quite late.  Will rebuild tnl_program,
     * which depends on varying information.  
     * 
@@ -290,12 +280,23 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx,
    LOCK_HARDWARE(intel);
 
    if (brw->intel.numClipRects == 0) {
-      assert(intel->batch->ptr == intel->batch->map + intel->batch->offset);
       UNLOCK_HARDWARE(intel);
       return GL_TRUE;
    }
 
    {
+      /* Flush the batch if it's approaching full, so that we don't wrap while
+       * we've got validated state that needs to be in the same batch as the
+       * primitives.  This fraction is just a guess (minimal full state plus
+       * a primitive is around 512 bytes), and would be better if we had
+       * an upper bound of how much we might emit in a single
+       * brw_try_draw_prims().
+       */
+      if (intel->batch->ptr - intel->batch->map > intel->batch->size * 3 / 4
+       /* brw_emit_prim may change the cliprect_mode to LOOP_CLIPRECTS */
+         || intel->batch->cliprect_mode != LOOP_CLIPRECTS)
+             intel_batchbuffer_flush(intel->batch);
+
       /* Set the first primitive early, ahead of validate_state:
        */
       brw_set_prim(brw, prim[0].mode);
@@ -311,71 +312,15 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx,
 
       if (check_fallbacks( brw, prim, nr_prims ))
         goto out;
-         
-      /* Upload index, vertex data: 
-       */
-      if (ib)
-        brw_upload_indices( brw, ib );
 
-      if (!brw_upload_vertices( brw, min_index, max_index)) {
-        goto out;
+      for (i = 0; i < nr_prims; i++) {
+        brw_emit_prim(brw, &prim[i]);
       }
 
-      /* For single cliprect, state is already emitted: 
-       */
-      if (brw->intel.numClipRects == 1) {
-        for (i = 0; i < nr_prims; i++) {
-           brw_emit_prim(brw, &prim[i]);   
-        }
-      }
-      else {
-        /* Otherwise, explicitly do the cliprects at this point:
-         */
-        for (j = 0; j < brw->intel.numClipRects; j++) {
-           brw_emit_cliprect(brw, &brw->intel.pClipRects[j]);
-
-           /* Emit prims to batchbuffer: 
-            */
-           for (i = 0; i < nr_prims; i++) {
-              brw_emit_prim(brw, &prim[i]);   
-           }
-        }
-      }
-      
-      intel->need_flush = GL_TRUE;
       retval = GL_TRUE;
    }
 
  out:
-
-   /* Currently have to do this to synchronize with the map/unmap of
-    * the vertex buffer in brw_exec_api.c.  Not sure if there is any
-    * way around this, as not every flush is due to a buffer filling
-    * up.
-    */
-   if (!intel_batchbuffer_flush( brw->intel.batch )) {
-      DBG("%s intel_batchbuffer_flush failed\n", __FUNCTION__);
-      retval = GL_FALSE;
-   }
-
-   if (retval && intel->thrashing) {
-      bmSetFence(intel);
-   }
-
-   /* Free any old data so it doesn't clog up texture memory - we
-    * won't be referencing it again.
-    */
-   while (brw->vb.upload.wrap != brw->vb.upload.buf) {
-      ctx->Driver.BufferData(ctx,
-                            GL_ARRAY_BUFFER_ARB,
-                            BRW_UPLOAD_INIT_SIZE,
-                            NULL,
-                            GL_DYNAMIC_DRAW_ARB,
-                            brw->vb.upload.vbo[brw->vb.upload.wrap]);
-      brw->vb.upload.wrap++;
-      brw->vb.upload.wrap %= BRW_NR_UPLOAD_BUFS;
-   }
-
    UNLOCK_HARDWARE(intel);
 
    if (!retval)
@@ -420,7 +365,6 @@ void brw_draw_prims( GLcontext *ctx,
                     GLuint min_index,
                     GLuint max_index )
 {
-   struct intel_context *intel = intel_context(ctx);
    GLboolean retval;
 
    /* Decide if we want to rebase.  If so we end up recursing once
@@ -440,20 +384,6 @@ void brw_draw_prims( GLcontext *ctx,
     */
    retval = brw_try_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index);
 
-   
-   /* This looks like out-of-memory but potentially we have
-    * situation where there is enough memory but it has become
-    * fragmented.  Clear out all heaps and start from scratch by
-    * faking a contended lock event:  (done elsewhere)
-    */
-   if (!retval && !intel->Fallback && bmError(intel)) {
-      DBG("retrying\n");
-      /* Then try a second time only to upload textures and draw the
-       * primitives:
-       */
-      retval = brw_try_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index);
-   }
-
    /* Otherwise, we really are out of memory.  Pass the drawing
     * command to the software tnl module and which will in turn call
     * swrast to do the drawing.
@@ -462,57 +392,22 @@ void brw_draw_prims( GLcontext *ctx,
        _swsetup_Wakeup(ctx);
       _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index);
    }
-
-   if (intel->aub_file && (INTEL_DEBUG & DEBUG_SYNC)) {
-      intelFinish( &intel->ctx );
-      intel->aub_wrap = 1;
-   }
 }
 
-
-static void brw_invalidate_vbo_cb( struct intel_context *intel, void *ptr )
-{
-   /* nothing to do, we don't rely on the contents being preserved */
-}
-
-
 void brw_draw_init( struct brw_context *brw )
 {
    GLcontext *ctx = &brw->intel.ctx;
    struct vbo_context *vbo = vbo_context(ctx);
-   GLuint i;
-   
+
    /* Register our drawing function: 
     */
    vbo->draw_prims = brw_draw_prims;
-
-   brw->vb.upload.size = BRW_UPLOAD_INIT_SIZE;
-
-   for (i = 0; i < BRW_NR_UPLOAD_BUFS; i++) {
-      brw->vb.upload.vbo[i] = ctx->Driver.NewBufferObject(ctx, 1, GL_ARRAY_BUFFER_ARB);
-      
-      /* NOTE:  These are set to no-backing-store.
-       */
-      bmBufferSetInvalidateCB(&brw->intel,
-                             intel_bufferobj_buffer(intel_buffer_object(brw->vb.upload.vbo[i])),
-                             brw_invalidate_vbo_cb,
-                             &brw->intel,
-                             GL_TRUE);
-   }
-
-   ctx->Driver.BufferData( ctx, 
-                          GL_ARRAY_BUFFER_ARB, 
-                          BRW_UPLOAD_INIT_SIZE,
-                          NULL,
-                          GL_DYNAMIC_DRAW_ARB,
-                          brw->vb.upload.vbo[0] );
 }
 
 void brw_draw_destroy( struct brw_context *brw )
 {
-   GLcontext *ctx = &brw->intel.ctx;
-   GLuint i;
-   
-   for (i = 0; i < BRW_NR_UPLOAD_BUFS; i++)
-      ctx->Driver.DeleteBuffer(ctx, brw->vb.upload.vbo[i]);
+   if (brw->vb.upload.bo != NULL) {
+      dri_bo_unreference(brw->vb.upload.bo);
+      brw->vb.upload.bo = NULL;
+   }
 }
index 0f7b738310284184637fd1f444cc76c700a662c9..e0bba589d5aa95314654a413255a220731ea3bce 100644 (file)
@@ -50,16 +50,4 @@ void brw_draw_destroy( struct brw_context *brw );
 void brw_init_current_values(GLcontext *ctx,
                             struct gl_client_array *arrays);
 
-
-/* brw_draw_upload.c
- */
-void brw_upload_indices( struct brw_context *brw,
-                        const struct _mesa_index_buffer *index_buffer);
-
-GLboolean brw_upload_vertices( struct brw_context *brw,
-                              GLuint min_index,
-                              GLuint max_index );
-
-
-
 #endif
index 6150cac4aa3b4d64e340f87e1627c9250e88798e..465239f195f23b728db3548b9762e6e2c1af5bd0 100644 (file)
 #include "brw_draw.h"
 #include "brw_defines.h"
 #include "brw_context.h"
-#include "brw_aub.h"
 #include "brw_state.h"
 #include "brw_fallback.h"
 
-#include "intel_ioctl.h"
 #include "intel_batchbuffer.h"
 #include "intel_buffer_objects.h"
-
-
-struct brw_array_state {
-   union header_union header;
-
-   struct {
-      union {
-        struct {
-           GLuint pitch:11; 
-           GLuint pad:15;
-           GLuint access_type:1; 
-           GLuint vb_index:5; 
-        } bits;
-        GLuint dword;
-      } vb0;
-   
-      struct buffer *buffer;
-      GLuint offset;
-
-      GLuint max_index;   
-      GLuint instance_data_step_rate;
-
-   } vb[BRW_VBP_MAX];
-};
-
-
-static struct buffer *array_buffer( const struct gl_client_array *array )
-{
-   return intel_bufferobj_buffer(intel_buffer_object(array->BufferObj));
-}
+#include "intel_tex.h"
 
 static GLuint double_types[5] = {
    0,
@@ -247,194 +216,165 @@ static GLuint get_index_type(GLenum type)
    }
 }
 
-static void copy_strided_array( GLubyte *dest, 
-                               const GLubyte *src, 
-                               GLuint size, 
-                               GLuint stride,
-                               GLuint count )
-{
-   if (size == stride) 
-      do_memcpy(dest, src, count * size);
-   else {
-      GLuint i,j;
-   
-      for (i = 0; i < count; i++) {
-        for (j = 0; j < size; j++)
-           *dest++ = *src++;
-        src += (stride - size);
-      }
-   }
-}
-
 static void wrap_buffers( struct brw_context *brw,
                          GLuint size )
 {
-   GLcontext *ctx = &brw->intel.ctx;
-
    if (size < BRW_UPLOAD_INIT_SIZE)
       size = BRW_UPLOAD_INIT_SIZE;
 
-   brw->vb.upload.buf++;
-   brw->vb.upload.buf %= BRW_NR_UPLOAD_BUFS;
    brw->vb.upload.offset = 0;
 
-   ctx->Driver.BufferData(ctx,
-                         GL_ARRAY_BUFFER_ARB,
-                         size,
-                         NULL,
-                         GL_DYNAMIC_DRAW_ARB,
-                         brw->vb.upload.vbo[brw->vb.upload.buf]);
+   if (brw->vb.upload.bo != NULL)
+      dri_bo_unreference(brw->vb.upload.bo);
+   brw->vb.upload.bo = dri_bo_alloc(brw->intel.bufmgr, "temporary VBO",
+                                   size, 1);
+
+   /* Set the internal VBO\ to no-backing-store.  We only use them as a
+    * temporary within a brw_try_draw_prims while the lock is held.
+    */
+   /* DON'T DO THIS AS IF WE HAVE TO RE-ORG MEMORY WE NEED SOMEWHERE WITH
+      FAKE TO PUSH THIS STUFF */
+//   if (!brw->intel.ttm)
+//      dri_bo_fake_disable_backing_store(brw->vb.upload.bo, NULL, NULL);
 }
 
 static void get_space( struct brw_context *brw,
                       GLuint size,
-                      struct gl_buffer_object **vbo_return,
+                      dri_bo **bo_return,
                       GLuint *offset_return )
 {
-   size = (size + 63) & ~63;
-   
-   if (brw->vb.upload.offset + size > BRW_UPLOAD_INIT_SIZE)
+   size = ALIGN(size, 64);
+
+   if (brw->vb.upload.bo == NULL ||
+       brw->vb.upload.offset + size > brw->vb.upload.bo->size) {
       wrap_buffers(brw, size);
+   }
 
-   *vbo_return = brw->vb.upload.vbo[brw->vb.upload.buf];
+   dri_bo_reference(brw->vb.upload.bo);
+   *bo_return = brw->vb.upload.bo;
    *offset_return = brw->vb.upload.offset;
 
    brw->vb.upload.offset += size;
 }
 
-
-
-static struct gl_client_array *
+static void
 copy_array_to_vbo_array( struct brw_context *brw,
-                        GLuint i,
-                        const struct gl_client_array *array,
-                        GLuint element_size,
-                        GLuint count)
+                        struct brw_vertex_element *element,
+                        GLuint dst_stride)
 {
-   GLcontext *ctx = &brw->intel.ctx;
-   struct gl_client_array *vbo_array = &brw->vb.vbo_array[i];
-   GLuint size = count * element_size;
-   struct gl_buffer_object *vbo;
-   GLuint offset;
-   GLuint new_stride;
+   GLuint size = element->count * dst_stride;
 
-   get_space(brw, size, &vbo, &offset);
+   get_space(brw, size, &element->bo, &element->offset);
 
-   if (array->StrideB == 0) {
-      assert(count == 1);
-      new_stride = 0;
+   if (element->glarray->StrideB == 0) {
+      assert(element->count == 1);
+      element->stride = 0;
+   } else {
+      element->stride = dst_stride;
    }
-   else 
-      new_stride = element_size;
-
-   vbo_array->Size = array->Size;
-   vbo_array->Type = array->Type;
-   vbo_array->Stride = new_stride;
-   vbo_array->StrideB = new_stride;   
-   vbo_array->Ptr = (const void *)offset;
-   vbo_array->Enabled = 1;
-   vbo_array->Normalized = array->Normalized;
-   vbo_array->_MaxElement = array->_MaxElement;        /* ? */
-   vbo_array->BufferObj = vbo;
 
-   {
-      GLubyte *map = ctx->Driver.MapBuffer(ctx,
-                                          GL_ARRAY_BUFFER_ARB,
-                                          GL_DYNAMIC_DRAW_ARB,
-                                          vbo);
-   
-      map += offset;
-
-      copy_strided_array( map, 
-                         array->Ptr,
-                         element_size,
-                         array->StrideB,
-                         count);
+   if (dst_stride == element->glarray->StrideB) {
+      dri_bo_subdata(element->bo,
+                    element->offset,
+                    size,
+                    element->glarray->Ptr);
+   } else {
+      void *data;
+      char *dest;
+      const char *src = element->glarray->Ptr;
+      int i;
+
+      data = _mesa_malloc(dst_stride * element->count);
+      dest = data;
+      for (i = 0; i < element->count; i++) {
+        memcpy(dest, src, dst_stride);
+        src += element->glarray->StrideB;
+        dest += dst_stride;
+      }
 
-      ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER_ARB, vbo_array->BufferObj);
+      dri_bo_subdata(element->bo,
+                    element->offset,
+                    size,
+                    data);
+      _mesa_free(data);
    }
-
-   return vbo_array;
 }
 
-
-
-static struct gl_client_array *
-interleaved_vbo_array( struct brw_context *brw,
-                      GLuint i,
-                      const struct gl_client_array *uploaded_array,
-                      const struct gl_client_array *array,
-                      const char *ptr)
-{
-   struct gl_client_array *vbo_array = &brw->vb.vbo_array[i];
-
-   vbo_array->Size = array->Size;
-   vbo_array->Type = array->Type;
-   vbo_array->Stride = array->Stride;
-   vbo_array->StrideB = array->StrideB;   
-   vbo_array->Ptr = (const void *)((const char *)uploaded_array->Ptr + 
-                                  ((const char *)array->Ptr - ptr));
-   vbo_array->Enabled = 1;
-   vbo_array->Normalized = array->Normalized;
-   vbo_array->_MaxElement = array->_MaxElement;        
-   vbo_array->BufferObj = uploaded_array->BufferObj;
-
-   return vbo_array;
-}
-
-
-GLboolean brw_upload_vertices( struct brw_context *brw,
-                              GLuint min_index,
-                              GLuint max_index )
+static void brw_prepare_vertices(struct brw_context *brw)
 {
    GLcontext *ctx = &brw->intel.ctx;
    struct intel_context *intel = intel_context(ctx);
    GLuint tmp = brw->vs.prog_data->inputs_read; 
-   struct brw_vertex_element_packet vep;
-   struct brw_array_state vbp;
    GLuint i;
-   const void *ptr = NULL;
+   const unsigned char *ptr = NULL;
    GLuint interleave = 0;
+   unsigned int min_index = brw->vb.min_index;
+   unsigned int max_index = brw->vb.max_index;
 
    struct brw_vertex_element *enabled[VERT_ATTRIB_MAX];
    GLuint nr_enabled = 0;
 
    struct brw_vertex_element *upload[VERT_ATTRIB_MAX];
    GLuint nr_uploads = 0;
-   
-
-   memset(&vbp, 0, sizeof(vbp));
-   memset(&vep, 0, sizeof(vep));
 
    /* First build an array of pointers to ve's in vb.inputs_read
     */
    if (0)
       _mesa_printf("%s %d..%d\n", __FUNCTION__, min_index, max_index);
-   
+
+   /* Accumulate the list of enabled arrays. */
    while (tmp) {
       GLuint i = _mesa_ffsll(tmp)-1;
       struct brw_vertex_element *input = &brw->vb.inputs[i];
 
       tmp &= ~(1<<i);
       enabled[nr_enabled++] = input;
+   }
+
+   /* XXX: In the rare cases where this happens we fallback all
+    * the way to software rasterization, although a tnl fallback
+    * would be sufficient.  I don't know of *any* real world
+    * cases with > 17 vertex attributes enabled, so it probably
+    * isn't an issue at this point.
+    */
+   if (nr_enabled >= BRW_VEP_MAX) {
+      intel->Fallback = 1;
+      return;
+   }
+
+   for (i = 0; i < nr_enabled; i++) {
+      struct brw_vertex_element *input = enabled[i];
 
-      input->index = i;
       input->element_size = get_size(input->glarray->Type) * input->glarray->Size;
       input->count = input->glarray->StrideB ? max_index + 1 - min_index : 1;
 
-      if (!input->glarray->BufferObj->Name) {
+      if (input->glarray->BufferObj->Name != 0) {
+        struct intel_buffer_object *intel_buffer =
+           intel_buffer_object(input->glarray->BufferObj);
+
+        /* Named buffer object: Just reference its contents directly. */
+        input->bo = intel_bufferobj_buffer(intel, intel_buffer,
+                                           INTEL_READ);
+        dri_bo_reference(input->bo);
+        input->offset = (unsigned long)input->glarray->Ptr;
+        input->stride = input->glarray->StrideB;
+      } else {
+        /* Queue the buffer object up to be uploaded in the next pass,
+         * when we've decided if we're doing interleaved or not.
+         */
         if (i == 0) {
            /* Position array not properly enabled:
             */
            if (input->glarray->StrideB == 0)
-              return GL_FALSE;
+             return;
 
            interleave = input->glarray->StrideB;
            ptr = input->glarray->Ptr;
         }
         else if (interleave != input->glarray->StrideB ||
-                 (const char *)input->glarray->Ptr - (const char *)ptr < 0 ||
-                 (const char *)input->glarray->Ptr - (const char *)ptr > interleave) {
+                 (const unsigned char *)input->glarray->Ptr - ptr < 0 ||
+                 (const unsigned char *)input->glarray->Ptr - ptr > interleave)
+        {
            interleave = 0;
         }
 
@@ -451,131 +391,137 @@ GLboolean brw_upload_vertices( struct brw_context *brw,
       }
    }
 
-   /* Upload interleaved arrays if all uploads are interleaved
-    */
-   if (nr_uploads > 1 && 
-       interleave && 
-       interleave <= 256) {
-      struct brw_vertex_element *input0 = upload[0];
-
-      input0->glarray = copy_array_to_vbo_array(brw, 0,
-                                               input0->glarray, 
-                                               interleave,
-                                               input0->count);
+   /* Handle any arrays to be uploaded. */
+   if (nr_uploads > 1 && interleave && interleave <= 256) {
+      /* All uploads are interleaved, so upload the arrays together as
+       * interleaved.  First, upload the contents and set up upload[0].
+       */
+      copy_array_to_vbo_array(brw, upload[0], interleave);
 
       for (i = 1; i < nr_uploads; i++) {
-        upload[i]->glarray = interleaved_vbo_array(brw,
-                                                   i,
-                                                   input0->glarray,
-                                                   upload[i]->glarray,
-                                                   ptr);
+        /* Then, just point upload[i] at upload[0]'s buffer. */
+        upload[i]->stride = interleave;
+        upload[i]->offset = upload[0]->offset +
+           ((const unsigned char *)upload[i]->glarray->Ptr - ptr);
+        upload[i]->bo = upload[0]->bo;
+        dri_bo_reference(upload[i]->bo);
       }
    }
    else {
+      /* Upload non-interleaved arrays */
       for (i = 0; i < nr_uploads; i++) {
-        struct brw_vertex_element *input = upload[i];
+          copy_array_to_vbo_array(brw, upload[i], upload[i]->element_size);
+      }
+   }
+}
 
-        input->glarray = copy_array_to_vbo_array(brw, i, 
-                                                 input->glarray,
-                                                 input->element_size,
-                                                 input->count);
+static void brw_emit_vertices(struct brw_context *brw)
+{
+   GLcontext *ctx = &brw->intel.ctx;
+   struct intel_context *intel = intel_context(ctx);
+   GLuint tmp = brw->vs.prog_data->inputs_read;
+   struct brw_vertex_element *enabled[VERT_ATTRIB_MAX];
+   GLuint i;
+   GLuint nr_enabled = 0;
 
-      }
+  /* Accumulate the list of enabled arrays. */
+   while (tmp) {
+      i = _mesa_ffsll(tmp)-1;
+      struct brw_vertex_element *input = &brw->vb.inputs[i];
+
+      tmp &= ~(1<<i);
+      enabled[nr_enabled++] = input;
    }
 
-   /* XXX: In the rare cases where this happens we fallback all
-    * the way to software rasterization, although a tnl fallback
-    * would be sufficient.  I don't know of *any* real world
-    * cases with > 17 vertex attributes enabled, so it probably
-    * isn't an issue at this point.
-    */
-   if (nr_enabled >= BRW_VEP_MAX)
-        return GL_FALSE;
 
-   /* This still defines a hardware VB for each input, even if they
+   /* Now emit VB and VEP state packets.
+    *
+    * This still defines a hardware VB for each input, even if they
     * are interleaved or from the same VBO.  TBD if this makes a
     * performance difference.
     */
+   BEGIN_BATCH(1 + nr_enabled * 4, IGNORE_CLIPRECTS);
+   OUT_BATCH((CMD_VERTEX_BUFFER << 16) |
+            ((1 + nr_enabled * 4) - 2));
+
    for (i = 0; i < nr_enabled; i++) {
       struct brw_vertex_element *input = enabled[i];
 
-      input->vep = &vep.ve[i];
-      input->vep->ve0.src_format = get_surface_type(input->glarray->Type, 
-                                                   input->glarray->Size,
-                                                   input->glarray->Normalized);
-      input->vep->ve0.valid = 1;
-      input->vep->ve1.dst_offset = (i) * 4;
-      input->vep->ve1.vfcomponent3 = BRW_VFCOMPONENT_STORE_SRC;
-      input->vep->ve1.vfcomponent2 = BRW_VFCOMPONENT_STORE_SRC;
-      input->vep->ve1.vfcomponent1 = BRW_VFCOMPONENT_STORE_SRC;
-      input->vep->ve1.vfcomponent0 = BRW_VFCOMPONENT_STORE_SRC;
+      OUT_BATCH((i << BRW_VB0_INDEX_SHIFT) |
+               BRW_VB0_ACCESS_VERTEXDATA |
+               (input->stride << BRW_VB0_PITCH_SHIFT));
+      OUT_RELOC(input->bo,
+               I915_GEM_DOMAIN_VERTEX, 0,
+               input->offset);
+      OUT_BATCH(brw->vb.max_index);
+      OUT_BATCH(0); /* Instance data step rate */
+
+      /* Unreference the buffer so it can get freed, now that we won't
+       * touch it any more.
+       */
+      dri_bo_unreference(input->bo);
+      input->bo = NULL;
+   }
+   ADVANCE_BATCH();
+
+   BEGIN_BATCH(1 + nr_enabled * 2, IGNORE_CLIPRECTS);
+   OUT_BATCH((CMD_VERTEX_ELEMENT << 16) | ((1 + nr_enabled * 2) - 2));
+   for (i = 0; i < nr_enabled; i++) {
+      struct brw_vertex_element *input = enabled[i];
+      uint32_t format = get_surface_type(input->glarray->Type,
+                                        input->glarray->Size,
+                                        input->glarray->Normalized);
+      uint32_t comp0 = BRW_VE1_COMPONENT_STORE_SRC;
+      uint32_t comp1 = BRW_VE1_COMPONENT_STORE_SRC;
+      uint32_t comp2 = BRW_VE1_COMPONENT_STORE_SRC;
+      uint32_t comp3 = BRW_VE1_COMPONENT_STORE_SRC;
 
       switch (input->glarray->Size) {
-      case 0: input->vep->ve1.vfcomponent0 = BRW_VFCOMPONENT_STORE_0;
-      case 1: input->vep->ve1.vfcomponent1 = BRW_VFCOMPONENT_STORE_0;
-      case 2: input->vep->ve1.vfcomponent2 = BRW_VFCOMPONENT_STORE_0;
-      case 3: input->vep->ve1.vfcomponent3 = BRW_VFCOMPONENT_STORE_1_FLT;
+      case 0: comp0 = BRW_VE1_COMPONENT_STORE_0;
+      case 1: comp1 = BRW_VE1_COMPONENT_STORE_0;
+      case 2: comp2 = BRW_VE1_COMPONENT_STORE_0;
+      case 3: comp3 = BRW_VE1_COMPONENT_STORE_1_FLT;
         break;
       }
 
-      input->vep->ve0.vertex_buffer_index = i;
-      input->vep->ve0.src_offset = 0;
-
-      vbp.vb[i].vb0.bits.pitch = input->glarray->StrideB;
-      vbp.vb[i].vb0.bits.pad = 0;
-      vbp.vb[i].vb0.bits.access_type = BRW_VERTEXBUFFER_ACCESS_VERTEXDATA;
-      vbp.vb[i].vb0.bits.vb_index = i;
-      vbp.vb[i].offset = (GLuint)input->glarray->Ptr;
-      vbp.vb[i].buffer = array_buffer(input->glarray);
-      vbp.vb[i].max_index = max_index;
-   }
-
-
-
-   /* Now emit VB and VEP state packets:
-    */
-   vbp.header.bits.length = (1 + nr_enabled * 4) - 2;
-   vbp.header.bits.opcode = CMD_VERTEX_BUFFER;
-
-   BEGIN_BATCH(vbp.header.bits.length+2, 0);
-   OUT_BATCH( vbp.header.dword );
-   
-   for (i = 0; i < nr_enabled; i++) {
-      OUT_BATCH( vbp.vb[i].vb0.dword );
-      OUT_BATCH( bmBufferOffset(&brw->intel, vbp.vb[i].buffer) + vbp.vb[i].offset);
-      OUT_BATCH( vbp.vb[i].max_index );
-      OUT_BATCH( vbp.vb[i].instance_data_step_rate );
+      OUT_BATCH((i << BRW_VE0_INDEX_SHIFT) |
+               BRW_VE0_VALID |
+               (format << BRW_VE0_FORMAT_SHIFT) |
+               (0 << BRW_VE0_SRC_OFFSET_SHIFT));
+      OUT_BATCH((comp0 << BRW_VE1_COMPONENT_0_SHIFT) |
+               (comp1 << BRW_VE1_COMPONENT_1_SHIFT) |
+               (comp2 << BRW_VE1_COMPONENT_2_SHIFT) |
+               (comp3 << BRW_VE1_COMPONENT_3_SHIFT) |
+               ((i * 4) << BRW_VE1_DST_OFFSET_SHIFT));
    }
    ADVANCE_BATCH();
-
-   vep.header.length = (1 + nr_enabled * sizeof(vep.ve[0])/4) - 2;
-   vep.header.opcode = CMD_VERTEX_ELEMENT;
-   brw_cached_batch_struct(brw, &vep, 4 + nr_enabled * sizeof(vep.ve[0]));
-
-   return GL_TRUE;
 }
 
+const struct brw_tracked_state brw_vertices = {
+   .dirty = {
+      .mesa = 0,
+      .brw = BRW_NEW_BATCH | BRW_NEW_VERTICES,
+      .cache = 0,
+   },
+   .prepare = brw_prepare_vertices,
+   .emit = brw_emit_vertices,
+};
 
-static GLuint element_size( GLenum type )
-{
-   switch(type) {
-   case GL_UNSIGNED_INT: return 4;
-   case GL_UNSIGNED_SHORT: return 2;
-   case GL_UNSIGNED_BYTE: return 1;
-   default: assert(0); return 0;
-   }
-}
-
-
-
-void brw_upload_indices( struct brw_context *brw,
-                        const struct _mesa_index_buffer *index_buffer )
+static void brw_prepare_indices(struct brw_context *brw)
 {
    GLcontext *ctx = &brw->intel.ctx;
    struct intel_context *intel = &brw->intel;
-   GLuint ib_size = get_size(index_buffer->type) * index_buffer->count;
-   struct gl_buffer_object *bufferobj = index_buffer->obj;
-   GLuint offset = (GLuint)index_buffer->ptr;
+   const struct _mesa_index_buffer *index_buffer = brw->ib.ib;
+   GLuint ib_size;
+   dri_bo *bo;
+   struct gl_buffer_object *bufferobj;
+   GLuint offset;
+
+   if (index_buffer == NULL)
+      return;
+
+   ib_size = get_size(index_buffer->type) * index_buffer->count;
+   bufferobj = index_buffer->obj;;
 
    /* Turn into a proper VBO:
     */
@@ -583,23 +529,56 @@ void brw_upload_indices( struct brw_context *brw,
      
       /* Get new bufferobj, offset:
        */
-      get_space(brw, ib_size, &bufferobj, &offset);
+      get_space(brw, ib_size, &bo, &offset);
 
       /* Straight upload
        */
-      ctx->Driver.BufferSubData( ctx,
-                                GL_ELEMENT_ARRAY_BUFFER_ARB,
-                                offset, 
-                                ib_size,
-                                index_buffer->ptr,
-                                bufferobj);
+      dri_bo_subdata(bo, offset, ib_size, index_buffer->ptr);
+   } else {
+      offset = (GLuint)index_buffer->ptr;
+
+      /* If the index buffer isn't aligned to its element size, we have to
+       * rebase it into a temporary.
+       */
+       if ((get_size(index_buffer->type) - 1) & offset) {
+           GLubyte *map = ctx->Driver.MapBuffer(ctx,
+                                                GL_ELEMENT_ARRAY_BUFFER_ARB,
+                                                GL_DYNAMIC_DRAW_ARB,
+                                                bufferobj);
+           map += offset;
+
+          get_space(brw, ib_size, &bo, &offset);
+
+          dri_bo_subdata(bo, offset, ib_size, map);
+
+           ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, bufferobj);
+       } else {
+         bo = intel_bufferobj_buffer(intel, intel_buffer_object(bufferobj),
+                                     INTEL_READ);
+         dri_bo_reference(bo);
+       }
    }
 
+   dri_bo_unreference(brw->ib.bo);
+   brw->ib.bo = bo;
+   brw->ib.offset = offset;
+}
+
+static void brw_emit_indices(struct brw_context *brw)
+{
+   struct intel_context *intel = &brw->intel;
+   const struct _mesa_index_buffer *index_buffer = brw->ib.ib;
+   GLuint ib_size;
+
+   if (index_buffer == NULL)
+      return;
+
+   ib_size = get_size(index_buffer->type) * index_buffer->count;
+
    /* Emit the indexbuffer packet:
     */
    {
       struct brw_indexbuffer ib;
-      struct buffer *buffer = intel_bufferobj_buffer(intel_buffer_object(bufferobj));
 
       memset(&ib, 0, sizeof(ib));
    
@@ -609,11 +588,25 @@ void brw_upload_indices( struct brw_context *brw,
       ib.header.bits.cut_index_enable = 0;
    
 
-      BEGIN_BATCH(4, 0);
+      BEGIN_BATCH(4, IGNORE_CLIPRECTS);
       OUT_BATCH( ib.header.dword );
-      OUT_BATCH( bmBufferOffset(intel, buffer) + offset );
-      OUT_BATCH( bmBufferOffset(intel, buffer) + offset + ib_size );
+      OUT_RELOC(brw->ib.bo,
+               I915_GEM_DOMAIN_VERTEX, 0,
+               brw->ib.offset);
+      OUT_RELOC(brw->ib.bo,
+               I915_GEM_DOMAIN_VERTEX, 0,
+               brw->ib.offset + ib_size);
       OUT_BATCH( 0 );
       ADVANCE_BATCH();
    }
 }
+
+const struct brw_tracked_state brw_indices = {
+   .dirty = {
+      .mesa = 0,
+      .brw = BRW_NEW_BATCH | BRW_NEW_INDICES,
+      .cache = 0,
+   },
+   .prepare = brw_prepare_indices,
+   .emit = brw_emit_indices,
+};
index d1244befd7817eb5cd39d7f67e22fe077f1dca95..b3ae4eef334959ce7bc26fa6324b84b61a5a1d44 100644 (file)
@@ -101,8 +101,9 @@ void brw_pop_insn_state( struct brw_compile *p )
 
 /***********************************************************************
  */
-void brw_init_compile( struct brw_compile *p )
+void brw_init_compile( struct brw_context *brw, struct brw_compile *p )
 {
+   p->brw = brw;
    p->nr_insn = 0;
    p->current = p->stack;
    memset(p->current, 0, sizeof(p->current[0]));
index 52f89d577ca857a631c6c9e6d7fa8e19543f017f..207b8b7ca3824b55190f16097b4eb97a39691718 100644 (file)
@@ -105,11 +105,12 @@ struct brw_compile {
 
    GLuint flag_value;
    GLboolean single_program_flow;
+   struct brw_context *brw;
 };
 
 
 
-static __inline int type_sz( GLuint type )
+static INLINE int type_sz( GLuint type )
 {
    switch( type ) {
    case BRW_REGISTER_TYPE_UD:
@@ -128,7 +129,7 @@ static __inline int type_sz( GLuint type )
    }
 }
 
-static __inline struct brw_reg brw_reg( GLuint file,
+static INLINE struct brw_reg brw_reg( GLuint file,
                                        GLuint nr,
                                        GLuint subnr,
                                        GLuint type,
@@ -165,7 +166,7 @@ static __inline struct brw_reg brw_reg( GLuint file,
    return reg;
 }
 
-static __inline struct brw_reg brw_vec16_reg( GLuint file,
+static INLINE struct brw_reg brw_vec16_reg( GLuint file,
                                              GLuint nr,
                                              GLuint subnr )
 {
@@ -180,7 +181,7 @@ static __inline struct brw_reg brw_vec16_reg( GLuint file,
                  WRITEMASK_XYZW);
 }
 
-static __inline struct brw_reg brw_vec8_reg( GLuint file,
+static INLINE struct brw_reg brw_vec8_reg( GLuint file,
                                             GLuint nr,
                                             GLuint subnr )
 {
@@ -196,7 +197,7 @@ static __inline struct brw_reg brw_vec8_reg( GLuint file,
 }
 
 
-static __inline struct brw_reg brw_vec4_reg( GLuint file,
+static INLINE struct brw_reg brw_vec4_reg( GLuint file,
                                              GLuint nr,
                                              GLuint subnr )
 {
@@ -212,7 +213,7 @@ static __inline struct brw_reg brw_vec4_reg( GLuint file,
 }
 
 
-static __inline struct brw_reg brw_vec2_reg( GLuint file,
+static INLINE struct brw_reg brw_vec2_reg( GLuint file,
                                              GLuint nr,
                                              GLuint subnr )
 {
@@ -227,7 +228,7 @@ static __inline struct brw_reg brw_vec2_reg( GLuint file,
                  WRITEMASK_XY);
 }
 
-static __inline struct brw_reg brw_vec1_reg( GLuint file,
+static INLINE struct brw_reg brw_vec1_reg( GLuint file,
                                             GLuint nr,
                                             GLuint subnr )
 {
@@ -243,14 +244,14 @@ static __inline struct brw_reg brw_vec1_reg( GLuint file,
 }
 
 
-static __inline struct brw_reg retype( struct brw_reg reg,
+static INLINE struct brw_reg retype( struct brw_reg reg,
                                       GLuint type )
 {
    reg.type = type;
    return reg;
 }
 
-static __inline struct brw_reg suboffset( struct brw_reg reg,
+static INLINE struct brw_reg suboffset( struct brw_reg reg,
                                          GLuint delta )
 {   
    reg.subnr += delta * type_sz(reg.type);
@@ -258,7 +259,7 @@ static __inline struct brw_reg suboffset( struct brw_reg reg,
 }
 
 
-static __inline struct brw_reg offset( struct brw_reg reg,
+static INLINE struct brw_reg offset( struct brw_reg reg,
                                       GLuint delta )
 {
    reg.nr += delta;
@@ -266,7 +267,7 @@ static __inline struct brw_reg offset( struct brw_reg reg,
 }
 
 
-static __inline struct brw_reg byte_offset( struct brw_reg reg,
+static INLINE struct brw_reg byte_offset( struct brw_reg reg,
                                            GLuint bytes )
 {
    GLuint newoffset = reg.nr * REG_SIZE + reg.subnr + bytes;
@@ -276,28 +277,28 @@ static __inline struct brw_reg byte_offset( struct brw_reg reg,
 }
    
 
-static __inline struct brw_reg brw_uw16_reg( GLuint file,
+static INLINE struct brw_reg brw_uw16_reg( GLuint file,
                                             GLuint nr,
                                             GLuint subnr )
 {
    return suboffset(retype(brw_vec16_reg(file, nr, 0), BRW_REGISTER_TYPE_UW), subnr);
 }
 
-static __inline struct brw_reg brw_uw8_reg( GLuint file,
+static INLINE struct brw_reg brw_uw8_reg( GLuint file,
                                            GLuint nr,
                                            GLuint subnr )
 {
    return suboffset(retype(brw_vec8_reg(file, nr, 0), BRW_REGISTER_TYPE_UW), subnr);
 }
 
-static __inline struct brw_reg brw_uw1_reg( GLuint file,
+static INLINE struct brw_reg brw_uw1_reg( GLuint file,
                                            GLuint nr,
                                            GLuint subnr )
 {
    return suboffset(retype(brw_vec1_reg(file, nr, 0), BRW_REGISTER_TYPE_UW), subnr);
 }
 
-static __inline struct brw_reg brw_imm_reg( GLuint type )
+static INLINE struct brw_reg brw_imm_reg( GLuint type )
 {
    return brw_reg( BRW_IMMEDIATE_VALUE,
                   0,
@@ -310,38 +311,38 @@ static __inline struct brw_reg brw_imm_reg( GLuint type )
                   0);      
 }
 
-static __inline struct brw_reg brw_imm_f( GLfloat f )
+static INLINE struct brw_reg brw_imm_f( GLfloat f )
 {
    struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_F);
    imm.dw1.f = f;
    return imm;
 }
 
-static __inline struct brw_reg brw_imm_d( GLint d )
+static INLINE struct brw_reg brw_imm_d( GLint d )
 {
    struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_D);
    imm.dw1.d = d;
    return imm;
 }
 
-static __inline struct brw_reg brw_imm_ud( GLuint ud )
+static INLINE struct brw_reg brw_imm_ud( GLuint ud )
 {
    struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_UD);
    imm.dw1.ud = ud;
    return imm;
 }
 
-static __inline struct brw_reg brw_imm_uw( GLushort uw )
+static INLINE struct brw_reg brw_imm_uw( GLushort uw )
 {
    struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_UW);
-   imm.dw1.ud = uw;
+   imm.dw1.ud = uw | (uw << 16);
    return imm;
 }
 
-static __inline struct brw_reg brw_imm_w( GLshort w )
+static INLINE struct brw_reg brw_imm_w( GLshort w )
 {
    struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_W);
-   imm.dw1.d = w;
+   imm.dw1.d = w | (w << 16);
    return imm;
 }
 
@@ -351,7 +352,7 @@ static __inline struct brw_reg brw_imm_w( GLshort w )
 
 /* Vector of eight signed half-byte values: 
  */
-static __inline struct brw_reg brw_imm_v( GLuint v )
+static INLINE struct brw_reg brw_imm_v( GLuint v )
 {
    struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_V);
    imm.vstride = BRW_VERTICAL_STRIDE_0;
@@ -363,7 +364,7 @@ static __inline struct brw_reg brw_imm_v( GLuint v )
 
 /* Vector of four 8-bit float values:
  */
-static __inline struct brw_reg brw_imm_vf( GLuint v )
+static INLINE struct brw_reg brw_imm_vf( GLuint v )
 {
    struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_VF);
    imm.vstride = BRW_VERTICAL_STRIDE_0;
@@ -377,7 +378,7 @@ static __inline struct brw_reg brw_imm_vf( GLuint v )
 #define VF_ONE  0x30
 #define VF_NEG  (1<<7)
 
-static __inline struct brw_reg brw_imm_vf4( GLuint v0, 
+static INLINE struct brw_reg brw_imm_vf4( GLuint v0, 
                                            GLuint v1, 
                                            GLuint v2,
                                            GLuint v3)
@@ -394,51 +395,51 @@ static __inline struct brw_reg brw_imm_vf4( GLuint v0,
 }
 
 
-static __inline struct brw_reg brw_address( struct brw_reg reg )
+static INLINE struct brw_reg brw_address( struct brw_reg reg )
 {
    return brw_imm_uw(reg.nr * REG_SIZE + reg.subnr);
 }
 
 
-static __inline struct brw_reg brw_vec1_grf( GLuint nr,
+static INLINE struct brw_reg brw_vec1_grf( GLuint nr,
                                               GLuint subnr )
 {
    return brw_vec1_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
 }
 
-static __inline struct brw_reg brw_vec8_grf( GLuint nr,
+static INLINE struct brw_reg brw_vec8_grf( GLuint nr,
                                             GLuint subnr )
 {
    return brw_vec8_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
 }
 
-static __inline struct brw_reg brw_vec4_grf( GLuint nr,
+static INLINE struct brw_reg brw_vec4_grf( GLuint nr,
                                             GLuint subnr )
 {
    return brw_vec4_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
 }
 
 
-static __inline struct brw_reg brw_vec2_grf( GLuint nr,
+static INLINE struct brw_reg brw_vec2_grf( GLuint nr,
                                             GLuint subnr )
 {
    return brw_vec2_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
 }
 
-static __inline struct brw_reg brw_uw8_grf( GLuint nr,
+static INLINE struct brw_reg brw_uw8_grf( GLuint nr,
                                            GLuint subnr )
 {
    return brw_uw8_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
 }
 
-static __inline struct brw_reg brw_null_reg( void )
+static INLINE struct brw_reg brw_null_reg( void )
 {
    return brw_vec8_reg(BRW_ARCHITECTURE_REGISTER_FILE, 
                       BRW_ARF_NULL, 
                       0);
 }
 
-static __inline struct brw_reg brw_address_reg( GLuint subnr )
+static INLINE struct brw_reg brw_address_reg( GLuint subnr )
 {
    return brw_uw1_reg(BRW_ARCHITECTURE_REGISTER_FILE, 
                      BRW_ARF_ADDRESS, 
@@ -449,7 +450,7 @@ static __inline struct brw_reg brw_address_reg( GLuint subnr )
  * aren't xyzw.  This goes against the convention for other scalar
  * regs:
  */
-static __inline struct brw_reg brw_ip_reg( void )
+static INLINE struct brw_reg brw_ip_reg( void )
 {
    return brw_reg(BRW_ARCHITECTURE_REGISTER_FILE, 
                  BRW_ARF_IP, 
@@ -462,7 +463,7 @@ static __inline struct brw_reg brw_ip_reg( void )
                  WRITEMASK_XYZW); /* NOTE! */
 }
 
-static __inline struct brw_reg brw_acc_reg( void )
+static INLINE struct brw_reg brw_acc_reg( void )
 {
    return brw_vec8_reg(BRW_ARCHITECTURE_REGISTER_FILE, 
                       BRW_ARF_ACCUMULATOR, 
@@ -470,7 +471,7 @@ static __inline struct brw_reg brw_acc_reg( void )
 }
 
 
-static __inline struct brw_reg brw_flag_reg( void )
+static INLINE struct brw_reg brw_flag_reg( void )
 {
    return brw_uw1_reg(BRW_ARCHITECTURE_REGISTER_FILE,
                      BRW_ARF_FLAG,
@@ -478,14 +479,14 @@ static __inline struct brw_reg brw_flag_reg( void )
 }
 
 
-static __inline struct brw_reg brw_mask_reg( GLuint subnr )
+static INLINE struct brw_reg brw_mask_reg( GLuint subnr )
 {
    return brw_uw1_reg(BRW_ARCHITECTURE_REGISTER_FILE,
                      BRW_ARF_MASK,
                      subnr);
 }
 
-static __inline struct brw_reg brw_message_reg( GLuint nr )
+static INLINE struct brw_reg brw_message_reg( GLuint nr )
 {
    return brw_vec8_reg(BRW_MESSAGE_REGISTER_FILE,
                       nr,
@@ -498,7 +499,7 @@ static __inline struct brw_reg brw_message_reg( GLuint nr )
 /* This is almost always called with a numeric constant argument, so
  * make things easy to evaluate at compile time:
  */
-static __inline GLuint cvt( GLuint val )
+static INLINE GLuint cvt( GLuint val )
 {
    switch (val) {
    case 0: return 0;
@@ -512,7 +513,7 @@ static __inline GLuint cvt( GLuint val )
    return 0;
 }
 
-static __inline struct brw_reg stride( struct brw_reg reg,
+static INLINE struct brw_reg stride( struct brw_reg reg,
                                       GLuint vstride,
                                       GLuint width,
                                       GLuint hstride )
@@ -524,43 +525,43 @@ static __inline struct brw_reg stride( struct brw_reg reg,
    return reg;
 }
 
-static __inline struct brw_reg vec16( struct brw_reg reg )
+static INLINE struct brw_reg vec16( struct brw_reg reg )
 {
    return stride(reg, 16,16,1);
 }
 
-static __inline struct brw_reg vec8( struct brw_reg reg )
+static INLINE struct brw_reg vec8( struct brw_reg reg )
 {
    return stride(reg, 8,8,1);
 }
 
-static __inline struct brw_reg vec4( struct brw_reg reg )
+static INLINE struct brw_reg vec4( struct brw_reg reg )
 {
    return stride(reg, 4,4,1);
 }
 
-static __inline struct brw_reg vec2( struct brw_reg reg )
+static INLINE struct brw_reg vec2( struct brw_reg reg )
 {
    return stride(reg, 2,2,1);
 }
 
-static __inline struct brw_reg vec1( struct brw_reg reg )
+static INLINE struct brw_reg vec1( struct brw_reg reg )
 {
    return stride(reg, 0,1,0);
 }
 
-static __inline struct brw_reg get_element( struct brw_reg reg, GLuint elt )
+static INLINE struct brw_reg get_element( struct brw_reg reg, GLuint elt )
 {
    return vec1(suboffset(reg, elt));
 }
 
-static __inline struct brw_reg get_element_ud( struct brw_reg reg, GLuint elt )
+static INLINE struct brw_reg get_element_ud( struct brw_reg reg, GLuint elt )
 {
    return vec1(suboffset(retype(reg, BRW_REGISTER_TYPE_UD), elt));
 }
 
 
-static __inline struct brw_reg brw_swizzle( struct brw_reg reg,
+static INLINE struct brw_reg brw_swizzle( struct brw_reg reg,
                                            GLuint x,
                                            GLuint y, 
                                            GLuint z,
@@ -574,33 +575,33 @@ static __inline struct brw_reg brw_swizzle( struct brw_reg reg,
 }
 
 
-static __inline struct brw_reg brw_swizzle1( struct brw_reg reg,
+static INLINE struct brw_reg brw_swizzle1( struct brw_reg reg,
                                             GLuint x )
 {
    return brw_swizzle(reg, x, x, x, x);
 }
 
-static __inline struct brw_reg brw_writemask( struct brw_reg reg,
+static INLINE struct brw_reg brw_writemask( struct brw_reg reg,
                                              GLuint mask )
 {
    reg.dw1.bits.writemask &= mask;
    return reg;
 }
 
-static __inline struct brw_reg brw_set_writemask( struct brw_reg reg,
+static INLINE struct brw_reg brw_set_writemask( struct brw_reg reg,
                                                  GLuint mask )
 {
    reg.dw1.bits.writemask = mask;
    return reg;
 }
 
-static __inline struct brw_reg negate( struct brw_reg reg )
+static INLINE struct brw_reg negate( struct brw_reg reg )
 {
    reg.negate ^= 1;
    return reg;
 }
 
-static __inline struct brw_reg brw_abs( struct brw_reg reg )
+static INLINE struct brw_reg brw_abs( struct brw_reg reg )
 {
    reg.abs = 1;
    return reg;
@@ -608,7 +609,7 @@ static __inline struct brw_reg brw_abs( struct brw_reg reg )
 
 /***********************************************************************
  */
-static __inline struct brw_reg brw_vec4_indirect( GLuint subnr,
+static INLINE struct brw_reg brw_vec4_indirect( GLuint subnr,
                                                  GLint offset )
 {
    struct brw_reg reg =  brw_vec4_grf(0, 0);
@@ -618,7 +619,7 @@ static __inline struct brw_reg brw_vec4_indirect( GLuint subnr,
    return reg;
 }
 
-static __inline struct brw_reg brw_vec1_indirect( GLuint subnr,
+static INLINE struct brw_reg brw_vec1_indirect( GLuint subnr,
                                                  GLint offset )
 {
    struct brw_reg reg =  brw_vec1_grf(0, 0);
@@ -628,38 +629,48 @@ static __inline struct brw_reg brw_vec1_indirect( GLuint subnr,
    return reg;
 }
 
-static __inline struct brw_reg deref_4f(struct brw_indirect ptr, GLint offset)
+static INLINE struct brw_reg deref_4f(struct brw_indirect ptr, GLint offset)
 {
    return brw_vec4_indirect(ptr.addr_subnr, ptr.addr_offset + offset);
 }
 
-static __inline struct brw_reg deref_1f(struct brw_indirect ptr, GLint offset)
+static INLINE struct brw_reg deref_1f(struct brw_indirect ptr, GLint offset)
 {
    return brw_vec1_indirect(ptr.addr_subnr, ptr.addr_offset + offset);
 }
 
-static __inline struct brw_reg deref_4b(struct brw_indirect ptr, GLint offset)
+static INLINE struct brw_reg deref_4b(struct brw_indirect ptr, GLint offset)
 {
    return retype(deref_4f(ptr, offset), BRW_REGISTER_TYPE_B);
 }
 
-static __inline struct brw_reg deref_1uw(struct brw_indirect ptr, GLint offset)
+static INLINE struct brw_reg deref_1uw(struct brw_indirect ptr, GLint offset)
 {
    return retype(deref_1f(ptr, offset), BRW_REGISTER_TYPE_UW);
 }
 
-static __inline struct brw_reg get_addr_reg(struct brw_indirect ptr)
+static INLINE struct brw_reg deref_1d(struct brw_indirect ptr, GLint offset)
+{
+   return retype(deref_1f(ptr, offset), BRW_REGISTER_TYPE_D);
+}
+
+static INLINE struct brw_reg deref_1ud(struct brw_indirect ptr, GLint offset)
+{
+   return retype(deref_1f(ptr, offset), BRW_REGISTER_TYPE_UD);
+}
+
+static INLINE struct brw_reg get_addr_reg(struct brw_indirect ptr)
 {
    return brw_address_reg(ptr.addr_subnr);
 }
 
-static __inline struct brw_indirect brw_indirect_offset( struct brw_indirect ptr, GLint offset )
+static INLINE struct brw_indirect brw_indirect_offset( struct brw_indirect ptr, GLint offset )
 {
    ptr.addr_offset += offset;
    return ptr;
 }
 
-static __inline struct brw_indirect brw_indirect( GLuint addr_subnr, GLint offset )
+static INLINE struct brw_indirect brw_indirect( GLuint addr_subnr, GLint offset )
 {
    struct brw_indirect ptr;
    ptr.addr_subnr = addr_subnr;
@@ -668,7 +679,10 @@ static __inline struct brw_indirect brw_indirect( GLuint addr_subnr, GLint offse
    return ptr;
 }
 
-
+static INLINE struct brw_instruction *current_insn( struct brw_compile *p)
+{
+       return &p->store[p->nr_insn];
+}
 
 void brw_pop_insn_state( struct brw_compile *p );
 void brw_push_insn_state( struct brw_compile *p );
@@ -680,7 +694,7 @@ void brw_set_predicate_control_flag_value( struct brw_compile *p, GLuint value )
 void brw_set_predicate_control( struct brw_compile *p, GLuint pc );
 void brw_set_conditionalmod( struct brw_compile *p, GLuint conditional );
 
-void brw_init_compile( struct brw_compile *p );
+void brw_init_compile( struct brw_context *, struct brw_compile *p );
 const GLuint *brw_get_program( struct brw_compile *p, GLuint *sz );
 
 
@@ -808,9 +822,11 @@ void brw_ENDIF(struct brw_compile *p,
 struct brw_instruction *brw_DO(struct brw_compile *p,
                               GLuint execute_size);
 
-void brw_WHILE(struct brw_compile *p, 
+struct brw_instruction *brw_WHILE(struct brw_compile *p, 
               struct brw_instruction *patch_insn);
 
+struct brw_instruction *brw_BREAK(struct brw_compile *p);
+struct brw_instruction *brw_CONT(struct brw_compile *p);
 /* Forward jumps:
  */
 void brw_land_fwd_jump(struct brw_compile *p, 
@@ -860,5 +876,6 @@ void brw_math_invert( struct brw_compile *p,
                      struct brw_reg dst,
                      struct brw_reg src);
 
-
+void brw_set_src1( struct brw_instruction *insn,
+                          struct brw_reg reg );
 #endif
index 9992b47d8ae3962c2735c7840b552c9001c044ea..0bfbec9d1405f2b59dd80340af8653990e7f6352 100644 (file)
@@ -164,7 +164,7 @@ static void brw_set_src0( struct brw_instruction *insn,
 }
 
 
-static void brw_set_src1( struct brw_instruction *insn,
+void brw_set_src1( struct brw_instruction *insn,
                          struct brw_reg reg )
 {
    assert(reg.file != BRW_MESSAGE_REGISTER_FILE);
@@ -186,7 +186,7 @@ static void brw_set_src1( struct brw_instruction *insn,
        * in the future:
        */
       assert (reg.address_mode == BRW_ADDRESS_DIRECT);
-      assert (reg.file == BRW_GENERAL_REGISTER_FILE);
+      //assert (reg.file == BRW_GENERAL_REGISTER_FILE);
 
       if (insn->header.access_mode == BRW_ALIGN_1) {
         insn->bits3.da1.src1_subreg_nr = reg.subnr;
@@ -318,7 +318,8 @@ static void brw_set_dp_read_message( struct brw_instruction *insn,
    insn->bits3.dp_read.end_of_thread = end_of_thread;
 }
 
-static void brw_set_sampler_message( struct brw_instruction *insn,
+static void brw_set_sampler_message(struct brw_context *brw,
+                 struct brw_instruction *insn,
                                     GLuint binding_table_index,
                                     GLuint sampler,
                                     GLuint msg_type,
@@ -328,14 +329,24 @@ static void brw_set_sampler_message( struct brw_instruction *insn,
 {
    brw_set_src1(insn, brw_imm_d(0));
 
-   insn->bits3.sampler.binding_table_index = binding_table_index;
-   insn->bits3.sampler.sampler = sampler;
-   insn->bits3.sampler.msg_type = msg_type;
-   insn->bits3.sampler.return_format = BRW_SAMPLER_RETURN_FORMAT_FLOAT32;
-   insn->bits3.sampler.response_length = response_length;
-   insn->bits3.sampler.msg_length = msg_length;
-   insn->bits3.sampler.end_of_thread = eot;
-   insn->bits3.sampler.msg_target = BRW_MESSAGE_TARGET_SAMPLER;
+   if (BRW_IS_GM45(brw) || BRW_IS_G4X(brw)) {
+      insn->bits3.sampler_gm45_g4x.binding_table_index = binding_table_index;
+      insn->bits3.sampler_gm45_g4x.sampler = sampler;
+      insn->bits3.sampler_gm45_g4x.msg_type = msg_type;
+      insn->bits3.sampler_gm45_g4x.response_length = response_length;
+      insn->bits3.sampler_gm45_g4x.msg_length = msg_length;
+      insn->bits3.sampler_gm45_g4x.end_of_thread = eot;
+      insn->bits3.sampler_gm45_g4x.msg_target = BRW_MESSAGE_TARGET_SAMPLER;
+   } else {
+      insn->bits3.sampler.binding_table_index = binding_table_index;
+      insn->bits3.sampler.sampler = sampler;
+      insn->bits3.sampler.msg_type = msg_type;
+      insn->bits3.sampler.return_format = BRW_SAMPLER_RETURN_FORMAT_FLOAT32;
+      insn->bits3.sampler.response_length = response_length;
+      insn->bits3.sampler.msg_length = msg_length;
+      insn->bits3.sampler.end_of_thread = eot;
+      insn->bits3.sampler.msg_target = BRW_MESSAGE_TARGET_SAMPLER;
+   }
 }
 
 
@@ -502,6 +513,8 @@ struct brw_instruction *brw_IF(struct brw_compile *p, GLuint execute_size)
    insn->header.compression_control = BRW_COMPRESSION_NONE;
    insn->header.predicate_control = BRW_PREDICATE_NORMAL;
    insn->header.mask_control = BRW_MASK_ENABLE;
+   if (!p->single_program_flow)
+       insn->header.thread_control = BRW_THREAD_SWITCH;
 
    p->current->header.predicate_control = BRW_PREDICATE_NONE;
 
@@ -527,6 +540,8 @@ struct brw_instruction *brw_ELSE(struct brw_compile *p,
    insn->header.compression_control = BRW_COMPRESSION_NONE;
    insn->header.execution_size = if_insn->header.execution_size;
    insn->header.mask_control = BRW_MASK_ENABLE;
+   if (!p->single_program_flow)
+       insn->header.thread_control = BRW_THREAD_SWITCH;
 
    /* Patch the if instruction to point at this instruction.
     */
@@ -568,6 +583,7 @@ void brw_ENDIF(struct brw_compile *p,
       insn->header.compression_control = BRW_COMPRESSION_NONE;
       insn->header.execution_size = patch_insn->header.execution_size;
       insn->header.mask_control = BRW_MASK_ENABLE;
+      insn->header.thread_control = BRW_THREAD_SWITCH;
 
       assert(patch_insn->bits3.if_else.jump_count == 0);
 
@@ -597,6 +613,34 @@ void brw_ENDIF(struct brw_compile *p,
    }
 }
 
+struct brw_instruction *brw_BREAK(struct brw_compile *p)
+{
+   struct brw_instruction *insn;
+   insn = next_insn(p, BRW_OPCODE_BREAK);
+   brw_set_dest(insn, brw_ip_reg());
+   brw_set_src0(insn, brw_ip_reg());
+   brw_set_src1(insn, brw_imm_d(0x0));
+   insn->header.compression_control = BRW_COMPRESSION_NONE;
+   insn->header.execution_size = BRW_EXECUTE_8;
+   /* insn->header.mask_control = BRW_MASK_DISABLE; */
+   insn->bits3.if_else.pad0 = 0;
+   return insn;
+}
+
+struct brw_instruction *brw_CONT(struct brw_compile *p)
+{
+   struct brw_instruction *insn;
+   insn = next_insn(p, BRW_OPCODE_CONTINUE);
+   brw_set_dest(insn, brw_ip_reg());
+   brw_set_src0(insn, brw_ip_reg());
+   brw_set_src1(insn, brw_imm_d(0x0));
+   insn->header.compression_control = BRW_COMPRESSION_NONE;
+   insn->header.execution_size = BRW_EXECUTE_8;
+   /* insn->header.mask_control = BRW_MASK_DISABLE; */
+   insn->bits3.if_else.pad0 = 0;
+   return insn;
+}
+
 /* DO/WHILE loop:
  */
 struct brw_instruction *brw_DO(struct brw_compile *p, GLuint execute_size)
@@ -608,13 +652,15 @@ struct brw_instruction *brw_DO(struct brw_compile *p, GLuint execute_size)
 
       /* Override the defaults for this instruction:
        */
-      brw_set_dest(insn, retype(brw_vec1_grf(0,0), BRW_REGISTER_TYPE_UD));
-      brw_set_src0(insn, retype(brw_vec1_grf(0,0), BRW_REGISTER_TYPE_UD));
-      brw_set_src1(insn, retype(brw_vec1_grf(0,0), BRW_REGISTER_TYPE_UD));
+      brw_set_dest(insn, brw_null_reg());
+      brw_set_src0(insn, brw_null_reg());
+      brw_set_src1(insn, brw_null_reg());
 
       insn->header.compression_control = BRW_COMPRESSION_NONE;
       insn->header.execution_size = execute_size;
+      insn->header.predicate_control = BRW_PREDICATE_NONE;
       /* insn->header.mask_control = BRW_MASK_ENABLE; */
+      /* insn->header.mask_control = BRW_MASK_DISABLE; */
 
       return insn;
    }
@@ -622,7 +668,7 @@ struct brw_instruction *brw_DO(struct brw_compile *p, GLuint execute_size)
 
 
 
-void brw_WHILE(struct brw_compile *p, 
+struct brw_instruction *brw_WHILE(struct brw_compile *p, 
               struct brw_instruction *do_insn)
 {
    struct brw_instruction *insn;
@@ -646,14 +692,16 @@ void brw_WHILE(struct brw_compile *p,
       insn->header.execution_size = do_insn->header.execution_size;
 
       assert(do_insn->header.opcode == BRW_OPCODE_DO);
-      insn->bits3.if_else.jump_count = do_insn - insn;
+      insn->bits3.if_else.jump_count = do_insn - insn + 1;
       insn->bits3.if_else.pop_count = 0;
       insn->bits3.if_else.pad0 = 0;
    }
 
 /*    insn->header.mask_control = BRW_MASK_ENABLE; */
 
+   /* insn->header.mask_control = BRW_MASK_DISABLE; */
    p->current->header.predicate_control = BRW_PREDICATE_NONE;   
+   return insn;
 }
 
 
@@ -985,7 +1033,7 @@ void brw_SAMPLE(struct brw_compile *p,
 
       brw_set_dest(insn, dest);
       brw_set_src0(insn, src0);
-      brw_set_sampler_message(insn,
+      brw_set_sampler_message(p->brw, insn,
                              binding_table_index,
                              sampler,
                              msg_type,
diff --git a/src/mesa/drivers/dri/i965/brw_exec_generic.c b/src/mesa/drivers/dri/i965/brw_exec_generic.c
deleted file mode 100644 (file)
index 11d1ef7..0000000
+++ /dev/null
@@ -1,530 +0,0 @@
-/**************************************************************************
-
-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 "brw_exec.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 );                         \
-   struct brw_exec_context *exec = IMM_CONTEXT(ctx)->exec;                     \
-                                                       \
-   if ((ATTR) == 0) {                                  \
-      GLuint i;                                                \
-                                                       \
-      if (N>0) exec->vtx.vbptr[0] = v[0];              \
-      if (N>1) exec->vtx.vbptr[1] = v[1];              \
-      if (N>2) exec->vtx.vbptr[2] = v[2];              \
-      if (N>3) exec->vtx.vbptr[3] = v[3];              \
-                                                       \
-      for (i = N; i < exec->vtx.vertex_size; i++)      \
-        exec->vtx.vbptr[i] = exec->vtx.vertex[i];      \
-                                                       \
-      exec->vtx.vbptr += exec->vtx.vertex_size;                \
-      exec->ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; \
-                                                       \
-      if (++exec->vtx.vert_count >= exec->vtx.max_vert)        \
-        brw_exec_vtx_wrap( exec );             \
-   }                                                   \
-   else {                                              \
-      GLfloat *dest = exec->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 brw_exec_generic_attr_table_init( brw_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 );                         \
-   struct brw_exec_context *exec = IMM_CONTEXT(ctx)->exec;             \
-   exec->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) )
-
-#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)
-
-
-static void GLAPIENTRY brw_Vertex2f( GLfloat x, GLfloat y )
-{
-   DISPATCH_ATTR2F( BRW_ATTRIB_POS, x, y );
-}
-
-static void GLAPIENTRY brw_Vertex2fv( const GLfloat *v )
-{
-   DISPATCH_ATTR2FV( BRW_ATTRIB_POS, v );
-}
-
-static void GLAPIENTRY brw_Vertex3f( GLfloat x, GLfloat y, GLfloat z )
-{
-   DISPATCH_ATTR3F( BRW_ATTRIB_POS, x, y, z );
-}
-
-static void GLAPIENTRY brw_Vertex3fv( const GLfloat *v )
-{
-   DISPATCH_ATTR3FV( BRW_ATTRIB_POS, v );
-}
-
-static void GLAPIENTRY brw_Vertex4f( GLfloat x, GLfloat y, GLfloat z, 
-                                     GLfloat w )
-{
-   DISPATCH_ATTR4F( BRW_ATTRIB_POS, x, y, z, w );
-}
-
-static void GLAPIENTRY brw_Vertex4fv( const GLfloat *v )
-{
-   DISPATCH_ATTR4FV( BRW_ATTRIB_POS, v );
-}
-
-static void GLAPIENTRY brw_TexCoord1f( GLfloat x )
-{
-   DISPATCH_ATTR1F( BRW_ATTRIB_TEX0, x );
-}
-
-static void GLAPIENTRY brw_TexCoord1fv( const GLfloat *v )
-{
-   DISPATCH_ATTR1FV( BRW_ATTRIB_TEX0, v );
-}
-
-static void GLAPIENTRY brw_TexCoord2f( GLfloat x, GLfloat y )
-{
-   DISPATCH_ATTR2F( BRW_ATTRIB_TEX0, x, y );
-}
-
-static void GLAPIENTRY brw_TexCoord2fv( const GLfloat *v )
-{
-   DISPATCH_ATTR2FV( BRW_ATTRIB_TEX0, v );
-}
-
-static void GLAPIENTRY brw_TexCoord3f( GLfloat x, GLfloat y, GLfloat z )
-{
-   DISPATCH_ATTR3F( BRW_ATTRIB_TEX0, x, y, z );
-}
-
-static void GLAPIENTRY brw_TexCoord3fv( const GLfloat *v )
-{
-   DISPATCH_ATTR3FV( BRW_ATTRIB_TEX0, v );
-}
-
-static void GLAPIENTRY brw_TexCoord4f( GLfloat x, GLfloat y, GLfloat z,
-                                       GLfloat w )
-{
-   DISPATCH_ATTR4F( BRW_ATTRIB_TEX0, x, y, z, w );
-}
-
-static void GLAPIENTRY brw_TexCoord4fv( const GLfloat *v )
-{
-   DISPATCH_ATTR4FV( BRW_ATTRIB_TEX0, v );
-}
-
-static void GLAPIENTRY brw_Normal3f( GLfloat x, GLfloat y, GLfloat z )
-{
-   DISPATCH_ATTR3F( BRW_ATTRIB_NORMAL, x, y, z );
-}
-
-static void GLAPIENTRY brw_Normal3fv( const GLfloat *v )
-{
-   DISPATCH_ATTR3FV( BRW_ATTRIB_NORMAL, v );
-}
-
-static void GLAPIENTRY brw_FogCoordfEXT( GLfloat x )
-{
-   DISPATCH_ATTR1F( BRW_ATTRIB_FOG, x );
-}
-
-static void GLAPIENTRY brw_FogCoordfvEXT( const GLfloat *v )
-{
-   DISPATCH_ATTR1FV( BRW_ATTRIB_FOG, v );
-}
-
-static void GLAPIENTRY brw_Color3f( GLfloat x, GLfloat y, GLfloat z )
-{
-   DISPATCH_ATTR3F( BRW_ATTRIB_COLOR0, x, y, z );
-}
-
-static void GLAPIENTRY brw_Color3fv( const GLfloat *v )
-{
-   DISPATCH_ATTR3FV( BRW_ATTRIB_COLOR0, v );
-}
-
-static void GLAPIENTRY brw_Color4f( GLfloat x, GLfloat y, GLfloat z, 
-                                    GLfloat w )
-{
-   DISPATCH_ATTR4F( BRW_ATTRIB_COLOR0, x, y, z, w );
-}
-
-static void GLAPIENTRY brw_Color4fv( const GLfloat *v )
-{
-   DISPATCH_ATTR4FV( BRW_ATTRIB_COLOR0, v );
-}
-
-static void GLAPIENTRY brw_SecondaryColor3fEXT( GLfloat x, GLfloat y, 
-                                                GLfloat z )
-{
-   DISPATCH_ATTR3F( BRW_ATTRIB_COLOR1, x, y, z );
-}
-
-static void GLAPIENTRY brw_SecondaryColor3fvEXT( const GLfloat *v )
-{
-   DISPATCH_ATTR3FV( BRW_ATTRIB_COLOR1, v );
-}
-
-static void GLAPIENTRY brw_MultiTexCoord1f( GLenum target, GLfloat x  )
-{
-   GLuint attr = (target & 0x7) + BRW_ATTRIB_TEX0;
-   DISPATCH_ATTR1F( attr, x );
-}
-
-static void GLAPIENTRY brw_MultiTexCoord1fv( GLenum target,
-                                             const GLfloat *v )
-{
-   GLuint attr = (target & 0x7) + BRW_ATTRIB_TEX0;
-   DISPATCH_ATTR1FV( attr, v );
-}
-
-static void GLAPIENTRY brw_MultiTexCoord2f( GLenum target, GLfloat x, 
-                                            GLfloat y )
-{
-   GLuint attr = (target & 0x7) + BRW_ATTRIB_TEX0;
-   DISPATCH_ATTR2F( attr, x, y );
-}
-
-static void GLAPIENTRY brw_MultiTexCoord2fv( GLenum target, 
-                                             const GLfloat *v )
-{
-   GLuint attr = (target & 0x7) + BRW_ATTRIB_TEX0;
-   DISPATCH_ATTR2FV( attr, v );
-}
-
-static void GLAPIENTRY brw_MultiTexCoord3f( GLenum target, GLfloat x, 
-                                            GLfloat y, GLfloat z)
-{
-   GLuint attr = (target & 0x7) + BRW_ATTRIB_TEX0;
-   DISPATCH_ATTR3F( attr, x, y, z );
-}
-
-static void GLAPIENTRY brw_MultiTexCoord3fv( GLenum target, 
-                                             const GLfloat *v )
-{
-   GLuint attr = (target & 0x7) + BRW_ATTRIB_TEX0;
-   DISPATCH_ATTR3FV( attr, v );
-}
-
-static void GLAPIENTRY brw_MultiTexCoord4f( GLenum target, GLfloat x, 
-                                            GLfloat y, GLfloat z,
-                                            GLfloat w )
-{
-   GLuint attr = (target & 0x7) + BRW_ATTRIB_TEX0;
-   DISPATCH_ATTR4F( attr, x, y, z, w );
-}
-
-static void GLAPIENTRY brw_MultiTexCoord4fv( GLenum target, 
-                                             const GLfloat *v )
-{
-   GLuint attr = (target & 0x7) + BRW_ATTRIB_TEX0;
-   DISPATCH_ATTR4FV( attr, v );
-}
-
-
-static void GLAPIENTRY brw_VertexAttrib1fNV( GLuint index, GLfloat x )
-{
-   if (index >= BRW_ATTRIB_FIRST_MATERIAL) index = ERROR_ATTRIB;
-   DISPATCH_ATTR1F( index, x );
-}
-
-static void GLAPIENTRY brw_VertexAttrib1fvNV( GLuint index, 
-                                              const GLfloat *v )
-{
-   if (index >= BRW_ATTRIB_FIRST_MATERIAL) index = ERROR_ATTRIB;
-   DISPATCH_ATTR1FV( index, v );
-}
-
-static void GLAPIENTRY brw_VertexAttrib2fNV( GLuint index, GLfloat x, 
-                                             GLfloat y )
-{
-   if (index >= BRW_ATTRIB_FIRST_MATERIAL) index = ERROR_ATTRIB;
-   DISPATCH_ATTR2F( index, x, y );
-}
-
-static void GLAPIENTRY brw_VertexAttrib2fvNV( GLuint index,
-                                              const GLfloat *v )
-{
-   if (index >= BRW_ATTRIB_FIRST_MATERIAL) index = ERROR_ATTRIB;
-   DISPATCH_ATTR2FV( index, v );
-}
-
-static void GLAPIENTRY brw_VertexAttrib3fNV( GLuint index, GLfloat x,
-                                             GLfloat y, GLfloat z )
-{
-   if (index >= BRW_ATTRIB_FIRST_MATERIAL) index = ERROR_ATTRIB;
-   DISPATCH_ATTR3F( index, x, y, z );
-}
-
-static void GLAPIENTRY brw_VertexAttrib3fvNV( GLuint index,
-                                              const GLfloat *v )
-{
-   if (index >= BRW_ATTRIB_FIRST_MATERIAL) index = ERROR_ATTRIB;
-   DISPATCH_ATTR3FV( index, v );
-}
-
-static void GLAPIENTRY brw_VertexAttrib4fNV( GLuint index, GLfloat x,
-                                             GLfloat y, GLfloat z,
-                                             GLfloat w )
-{
-   if (index >= BRW_ATTRIB_FIRST_MATERIAL) index = ERROR_ATTRIB;
-   DISPATCH_ATTR4F( index, x, y, z, w );
-}
-
-static void GLAPIENTRY brw_VertexAttrib4fvNV( GLuint index, 
-                                              const GLfloat *v )
-{
-   if (index >= BRW_ATTRIB_FIRST_MATERIAL) index = ERROR_ATTRIB;
-   DISPATCH_ATTR4FV( index, v );
-}
-
-
-/*
- * XXX adjust index
- */
-
-static void GLAPIENTRY brw_VertexAttrib1fARB( GLuint index, GLfloat x )
-{
-   if (index >= BRW_ATTRIB_FIRST_MATERIAL) index = ERROR_ATTRIB;
-   DISPATCH_ATTR1F( index, x );
-}
-
-static void GLAPIENTRY brw_VertexAttrib1fvARB( GLuint index, 
-                                              const GLfloat *v )
-{
-   if (index >= BRW_ATTRIB_FIRST_MATERIAL) index = ERROR_ATTRIB;
-   DISPATCH_ATTR1FV( index, v );
-}
-
-static void GLAPIENTRY brw_VertexAttrib2fARB( GLuint index, GLfloat x, 
-                                             GLfloat y )
-{
-   if (index >= BRW_ATTRIB_FIRST_MATERIAL) index = ERROR_ATTRIB;
-   DISPATCH_ATTR2F( index, x, y );
-}
-
-static void GLAPIENTRY brw_VertexAttrib2fvARB( GLuint index,
-                                              const GLfloat *v )
-{
-   if (index >= BRW_ATTRIB_FIRST_MATERIAL) index = ERROR_ATTRIB;
-   DISPATCH_ATTR2FV( index, v );
-}
-
-static void GLAPIENTRY brw_VertexAttrib3fARB( GLuint index, GLfloat x,
-                                             GLfloat y, GLfloat z )
-{
-   if (index >= BRW_ATTRIB_FIRST_MATERIAL) index = ERROR_ATTRIB;
-   DISPATCH_ATTR3F( index, x, y, z );
-}
-
-static void GLAPIENTRY brw_VertexAttrib3fvARB( GLuint index,
-                                              const GLfloat *v )
-{
-   if (index >= BRW_ATTRIB_FIRST_MATERIAL) index = ERROR_ATTRIB;
-   DISPATCH_ATTR3FV( index, v );
-}
-
-static void GLAPIENTRY brw_VertexAttrib4fARB( GLuint index, GLfloat x,
-                                             GLfloat y, GLfloat z,
-                                             GLfloat w )
-{
-   if (index >= BRW_ATTRIB_FIRST_MATERIAL) index = ERROR_ATTRIB;
-   DISPATCH_ATTR4F( index, x, y, z, w );
-}
-
-static void GLAPIENTRY brw_VertexAttrib4fvARB( GLuint index, 
-                                              const GLfloat *v )
-{
-   if (index >= BRW_ATTRIB_FIRST_MATERIAL) 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 brw_exec_vtx_generic_init( struct brw_exec_context *exec )
-{
-   GLvertexformat *vfmt = &exec->vtxfmt;
-
-   vfmt->Color3f = brw_Color3f;
-   vfmt->Color3fv = brw_Color3fv;
-   vfmt->Color4f = brw_Color4f;
-   vfmt->Color4fv = brw_Color4fv;
-   vfmt->FogCoordfEXT = brw_FogCoordfEXT;
-   vfmt->FogCoordfvEXT = brw_FogCoordfvEXT;
-   vfmt->MultiTexCoord1fARB = brw_MultiTexCoord1f;
-   vfmt->MultiTexCoord1fvARB = brw_MultiTexCoord1fv;
-   vfmt->MultiTexCoord2fARB = brw_MultiTexCoord2f;
-   vfmt->MultiTexCoord2fvARB = brw_MultiTexCoord2fv;
-   vfmt->MultiTexCoord3fARB = brw_MultiTexCoord3f;
-   vfmt->MultiTexCoord3fvARB = brw_MultiTexCoord3fv;
-   vfmt->MultiTexCoord4fARB = brw_MultiTexCoord4f;
-   vfmt->MultiTexCoord4fvARB = brw_MultiTexCoord4fv;
-   vfmt->Normal3f = brw_Normal3f;
-   vfmt->Normal3fv = brw_Normal3fv;
-   vfmt->SecondaryColor3fEXT = brw_SecondaryColor3fEXT;
-   vfmt->SecondaryColor3fvEXT = brw_SecondaryColor3fvEXT;
-   vfmt->TexCoord1f = brw_TexCoord1f;
-   vfmt->TexCoord1fv = brw_TexCoord1fv;
-   vfmt->TexCoord2f = brw_TexCoord2f;
-   vfmt->TexCoord2fv = brw_TexCoord2fv;
-   vfmt->TexCoord3f = brw_TexCoord3f;
-   vfmt->TexCoord3fv = brw_TexCoord3fv;
-   vfmt->TexCoord4f = brw_TexCoord4f;
-   vfmt->TexCoord4fv = brw_TexCoord4fv;
-   vfmt->Vertex2f = brw_Vertex2f;
-   vfmt->Vertex2fv = brw_Vertex2fv;
-   vfmt->Vertex3f = brw_Vertex3f;
-   vfmt->Vertex3fv = brw_Vertex3fv;
-   vfmt->Vertex4f = brw_Vertex4f;
-   vfmt->Vertex4fv = brw_Vertex4fv;
-   vfmt->VertexAttrib1fNV = brw_VertexAttrib1fNV;
-   vfmt->VertexAttrib1fvNV = brw_VertexAttrib1fvNV;
-   vfmt->VertexAttrib2fNV = brw_VertexAttrib2fNV;
-   vfmt->VertexAttrib2fvNV = brw_VertexAttrib2fvNV;
-   vfmt->VertexAttrib3fNV = brw_VertexAttrib3fNV;
-   vfmt->VertexAttrib3fvNV = brw_VertexAttrib3fvNV;
-   vfmt->VertexAttrib4fNV = brw_VertexAttrib4fNV;
-   vfmt->VertexAttrib4fvNV = brw_VertexAttrib4fvNV;
-   vfmt->VertexAttrib1fARB = brw_VertexAttrib1fARB;
-   vfmt->VertexAttrib1fvARB = brw_VertexAttrib1fvARB;
-   vfmt->VertexAttrib2fARB = brw_VertexAttrib2fARB;
-   vfmt->VertexAttrib2fvARB = brw_VertexAttrib2fvARB;
-   vfmt->VertexAttrib3fARB = brw_VertexAttrib3fARB;
-   vfmt->VertexAttrib3fvARB = brw_VertexAttrib3fvARB;
-   vfmt->VertexAttrib4fARB = brw_VertexAttrib4fARB;
-   vfmt->VertexAttrib4fvARB = brw_VertexAttrib4fvARB;
-}
index 86464b2ec5ffe3eceb50ec622f86c53df14a2956..693f68f32aca34496c94e4c754515c956fdddaa0 100644 (file)
 #include "macros.h"
 #include "mtypes.h"
 
-
-
-
-
-
+#define FILE_DEBUG_FLAG DEBUG_FALLBACKS
 
 static GLboolean do_check_fallback(struct brw_context *brw)
 {
    GLcontext *ctx = &brw->intel.ctx;
    GLuint i;
-   
+
    /* BRW_NEW_METAOPS
     */
    if (brw->metaops.active)
       return GL_FALSE;
 
-   if (brw->intel.no_rast)
-      return GL_TRUE;
-   
-   /* _NEW_BUFFERS
-    */
-   if (ctx->DrawBuffer->_ColorDrawBufferMask[0] != BUFFER_BIT_FRONT_LEFT &&
-       ctx->DrawBuffer->_ColorDrawBufferMask[0] != BUFFER_BIT_BACK_LEFT)
+   if (brw->intel.no_rast) {
+      DBG("FALLBACK: rasterization disabled\n");
       return GL_TRUE;
+   }
 
    /* _NEW_RENDERMODE
     *
     * XXX: need to save/restore RenderMode in metaops state, or
     * somehow move to a new attribs pointer:
     */
-   if (ctx->RenderMode != GL_RENDER)
+   if (ctx->RenderMode != GL_RENDER) {
+      DBG("FALLBACK: render mode\n");
       return GL_TRUE;
+   }
 
    /* _NEW_TEXTURE:
     */
@@ -79,8 +73,13 @@ static GLboolean do_check_fallback(struct brw_context *brw)
       if (texUnit->_ReallyEnabled) {
         struct intel_texture_object *intelObj = intel_texture_object(texUnit->_Current);
         struct gl_texture_image *texImage = intelObj->base.Image[0][intelObj->firstLevel];
-        if (texImage->Border)
+        if (texImage->Border ||
+         ((texImage->_BaseFormat == GL_DEPTH_COMPONENT) &&
+          ((texImage->TexObject->WrapS == GL_CLAMP_TO_BORDER) || 
+           (texImage->TexObject->WrapT == GL_CLAMP_TO_BORDER)))) {
+           DBG("FALLBACK: texture border\n");
            return GL_TRUE;
+        }
       }
    }
    
@@ -88,6 +87,7 @@ static GLboolean do_check_fallback(struct brw_context *brw)
     */
    if (brw->attribs.Stencil->Enabled && 
        !brw->intel.hw_stencil) {
+      DBG("FALLBACK: stencil\n");
       return GL_TRUE;
    }
 
@@ -106,7 +106,7 @@ const struct brw_tracked_state brw_check_fallback = {
       .brw  = BRW_NEW_METAOPS,
       .cache = 0
    },
-   .update = check_fallback
+   .prepare = check_fallback
 };
 
 
index 73263a5fff4ba2ca7b76c54973f184cb605a203b..2daef0093b56f366e57889a5cf80485039014029 100644 (file)
@@ -65,7 +65,7 @@ static void compile_gs_prog( struct brw_context *brw,
    
    /* Begin the compilation:
     */
-   brw_init_compile(&c.func);
+   brw_init_compile(brw, &c.func);
 
    c.func.single_program_flow = 1;
 
@@ -119,26 +119,15 @@ static void compile_gs_prog( struct brw_context *brw,
 
    /* Upload
     */
-   brw->gs.prog_gs_offset = brw_upload_cache( &brw->cache[BRW_GS_PROG],
-                                             &c.key,
-                                             sizeof(c.key),
-                                             program,
-                                             program_size,
-                                             &c.prog_data,
-                                             &brw->gs.prog_data );
+   dri_bo_unreference(brw->gs.prog_bo);
+   brw->gs.prog_bo = brw_upload_cache( &brw->cache, BRW_GS_PROG,
+                                      &c.key, sizeof(c.key),
+                                      NULL, 0,
+                                      program, program_size,
+                                      &c.prog_data,
+                                      &brw->gs.prog_data );
 }
 
-
-static GLboolean search_cache( struct brw_context *brw, 
-                              struct brw_gs_prog_key *key )
-{
-   return brw_search_cache(&brw->cache[BRW_GS_PROG], 
-                          key, sizeof(*key),
-                          &brw->gs.prog_data,
-                          &brw->gs.prog_gs_offset);
-}
-
-
 static const GLenum gs_prim[GL_POLYGON+1] = {  
    GL_POINTS,
    GL_LINES,
@@ -173,10 +162,9 @@ static void populate_key( struct brw_context *brw,
 
 /* Calculate interpolants for triangle and line rasterization.
  */
-static void upload_gs_prog( struct brw_context *brw )
+static void prepare_gs_prog(struct brw_context *brw)
 {
    struct brw_gs_prog_key key;
-
    /* Populate the key:
     */
    populate_key(brw, &key);
@@ -187,7 +175,12 @@ static void upload_gs_prog( struct brw_context *brw )
    }
 
    if (brw->gs.prog_active) {
-      if (!search_cache(brw, &key))
+      dri_bo_unreference(brw->gs.prog_bo);
+      brw->gs.prog_bo = brw_search_cache(&brw->cache, BRW_GS_PROG,
+                                        &key, sizeof(key),
+                                        NULL, 0,
+                                        &brw->gs.prog_data);
+      if (brw->gs.prog_bo == NULL)
         compile_gs_prog( brw, &key );
    }
 }
@@ -199,5 +192,5 @@ const struct brw_tracked_state brw_gs_prog = {
       .brw   = BRW_NEW_PRIMITIVE,
       .cache = CACHE_NEW_VS_PROG
    },
-   .update = upload_gs_prog
+   .prepare = prepare_gs_prog
 };
index 29a4e80ce1be4b242b57940b15250568a8acdd2e..18a4537c323dda2804281a402400757fd8c072b7 100644 (file)
 #define MAX_GS_VERTS (4)            
 
 struct brw_gs_prog_key {
+   GLuint attrs:32;
    GLuint primitive:4;
-   GLuint attrs:16;            
    GLuint hint_gs_always:1;
    GLuint need_gs_prog:1;
-   GLuint pad:10;
+   GLuint pad:26;
 };
 
 struct brw_gs_compile {
index 5826c01d4f912064aa9ad42165e61f6bc7758c88..633e17cc9d27f93171179478234e1ea958f65457 100644 (file)
 #include "brw_defines.h"
 #include "macros.h"
 
+struct brw_gs_unit_key {
+   unsigned int total_grf;
+   unsigned int urb_entry_read_length;
 
+   unsigned int curbe_offset;
 
-static void upload_gs_unit( struct brw_context *brw )
-{
-   struct brw_gs_unit_state gs;
+   unsigned int nr_urb_entries, urb_size;
+   GLboolean prog_active;
+};
 
-   memset(&gs, 0, sizeof(gs));
+static void
+gs_unit_populate_key(struct brw_context *brw, struct brw_gs_unit_key *key)
+{
+   memset(key, 0, sizeof(*key));
 
    /* CACHE_NEW_GS_PROG */
-   if (brw->gs.prog_active) {
-      gs.thread0.grf_reg_count = ((brw->gs.prog_data->total_grf-1) & ~15) / 16;
-      gs.thread0.kernel_start_pointer = brw->gs.prog_gs_offset >> 6;
-      gs.thread3.urb_entry_read_length = brw->gs.prog_data->urb_read_length;
-   }
-   else {
-      gs.thread0.grf_reg_count = 0;
-      gs.thread0.kernel_start_pointer = 0;
-      gs.thread3.urb_entry_read_length = 1;
+   key->prog_active = brw->gs.prog_active;
+   if (key->prog_active) {
+      key->total_grf = brw->gs.prog_data->total_grf;
+      key->urb_entry_read_length = brw->gs.prog_data->urb_read_length;
+   } else {
+      key->total_grf = 1;
+      key->urb_entry_read_length = 1;
    }
 
+   /* BRW_NEW_CURBE_OFFSETS */
+   key->curbe_offset = brw->curbe.clip_start;
+
    /* BRW_NEW_URB_FENCE */
-   gs.thread4.nr_urb_entries = brw->urb.nr_gs_entries; 
-   gs.thread4.urb_entry_allocation_size = brw->urb.vsize - 1;
+   key->nr_urb_entries = brw->urb.nr_gs_entries;
+   key->urb_size = brw->urb.vsize;
+}
 
-   gs.thread4.max_threads = 0; /* Hardware requirement */
+static dri_bo *
+gs_unit_create_from_key(struct brw_context *brw, struct brw_gs_unit_key *key)
+{
+   struct brw_gs_unit_state gs;
+   dri_bo *bo;
 
-   if (INTEL_DEBUG & DEBUG_STATS)
-      gs.thread4.stats_enable = 1; 
+   memset(&gs, 0, sizeof(gs));
+
+   gs.thread0.grf_reg_count = ALIGN(key->total_grf, 16) / 16 - 1;
+   if (key->prog_active) /* reloc */
+      gs.thread0.kernel_start_pointer = brw->gs.prog_bo->offset >> 6;
 
-   /* CONSTANT */
    gs.thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
    gs.thread1.single_program_flow = 1;
+
    gs.thread3.dispatch_grf_start_reg = 1;
    gs.thread3.const_urb_entry_read_offset = 0;
    gs.thread3.const_urb_entry_read_length = 0;
    gs.thread3.urb_entry_read_offset = 0;
-   
+   gs.thread3.urb_entry_read_length = key->urb_entry_read_length;
+
+   gs.thread4.nr_urb_entries = key->nr_urb_entries;
+   gs.thread4.urb_entry_allocation_size = key->urb_size - 1;
+
+   gs.thread4.max_threads = 0; /* Hardware requirement */
+
+   if (INTEL_DEBUG & DEBUG_STATS)
+      gs.thread4.stats_enable = 1;
+
+   bo = brw_upload_cache(&brw->cache, BRW_GS_UNIT,
+                        key, sizeof(*key),
+                        &brw->gs.prog_bo, 1,
+                        &gs, sizeof(gs),
+                        NULL, NULL);
 
-   brw->gs.state_gs_offset = brw_cache_data( &brw->cache[BRW_GS_UNIT], &gs );
+   if (key->prog_active) {
+      /* Emit GS program relocation */
+      dri_bo_emit_reloc(bo,
+                       I915_GEM_DOMAIN_INSTRUCTION, 0,
+                       gs.thread0.grf_reg_count << 1,
+                       offsetof(struct brw_gs_unit_state, thread0),
+                       brw->gs.prog_bo);
+   }
+
+   return bo;
 }
 
+static void prepare_gs_unit(struct brw_context *brw)
+{
+   struct brw_gs_unit_key key;
+
+   gs_unit_populate_key(brw, &key);
+
+   dri_bo_unreference(brw->gs.state_bo);
+   brw->gs.state_bo = brw_search_cache(&brw->cache, BRW_GS_UNIT,
+                                      &key, sizeof(key),
+                                      &brw->gs.prog_bo, 1,
+                                      NULL);
+   if (brw->gs.state_bo == NULL) {
+      brw->gs.state_bo = gs_unit_create_from_key(brw, &key);
+   }
+}
 
 const struct brw_tracked_state brw_gs_unit = {
    .dirty = {
@@ -85,5 +139,5 @@ const struct brw_tracked_state brw_gs_unit = {
                BRW_NEW_URB_FENCE),
       .cache = CACHE_NEW_GS_PROG
    },
-   .update = upload_gs_unit
+   .prepare = prepare_gs_unit,
 };
diff --git a/src/mesa/drivers/dri/i965/brw_hal.c b/src/mesa/drivers/dri/i965/brw_hal.c
deleted file mode 100644 (file)
index 3126102..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- Copyright (C) Intel Corp.  2006.  All Rights Reserved.
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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 "intel_batchbuffer.h"
-#include "brw_context.h"
-#include "brw_state.h"
-#include "brw_defines.h"
-#include "brw_hal.h"
-#include <dlfcn.h>
-
-static void *brw_hal_lib;
-static GLboolean brw_hal_tried;
-
-void *
-brw_hal_find_symbol (char *symbol)
-{
-    if (!brw_hal_tried)
-    {
-       char *brw_hal_name = getenv ("INTEL_HAL");
-    
-       if (!brw_hal_name)
-           brw_hal_name = "/usr/lib/xorg/modules/drivers/intel_hal.so";
-
-       brw_hal_lib = dlopen (brw_hal_name, RTLD_LAZY|RTLD_LOCAL);
-       brw_hal_tried = 1;
-    }
-    if (!brw_hal_lib)
-       return NULL;
-    return dlsym (brw_hal_lib, symbol);
-}
diff --git a/src/mesa/drivers/dri/i965/brw_hal.h b/src/mesa/drivers/dri/i965/brw_hal.h
deleted file mode 100644 (file)
index cd86e39..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- Copyright (C) Intel Corp.  2006.  All Rights Reserved.
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
- **********************************************************************/
-
-void *
-brw_hal_find_symbol (char *symbol);
index 6e030f191efeb12bc98a905d557cc890c92f1647..252a8996e26067dc2beb187a39c066373223df55 100644 (file)
@@ -41,6 +41,7 @@
 #include "intel_screen.h"
 #include "intel_batchbuffer.h"
 #include "intel_regions.h"
+#include "intel_buffers.h"
 
 #include "brw_context.h"
 #include "brw_defines.h"
@@ -156,7 +157,7 @@ static const char *fp_tex_prog =
  *   FragmentProgram->_Current
  *   VertexProgram->_Enabled
  *   brw->vertex_program
- *   DrawBuffer->_ColorDrawBufferMask[0]
+ *   DrawBuffer->_ColorDrawBufferIndexes[0]
  * 
  *
  * More if drawpixels-through-texture is added.  
@@ -195,7 +196,7 @@ static void init_metaops_state( struct brw_context *brw )
                                  vp_prog, strlen(vp_prog),
                                  brw->metaops.vp);
 
-   brw->metaops.attribs.VertexProgram->Current = brw->metaops.vp;
+   brw->metaops.attribs.VertexProgram->_Current = brw->metaops.vp;
    brw->metaops.attribs.VertexProgram->_Enabled = GL_TRUE;
 
    brw->metaops.attribs.FragmentProgram->_Current = brw->metaops.fp;
@@ -361,13 +362,21 @@ static void meta_draw_region( struct intel_context *intel,
    struct brw_context *brw = brw_context(&intel->ctx);
 
    if (!brw->metaops.saved_draw_region) {
-      brw->metaops.saved_draw_region = brw->state.draw_region;
+      brw->metaops.saved_draw_region = brw->state.draw_regions[0];
+      brw->metaops.saved_nr_draw_regions = brw->state.nr_draw_regions;
       brw->metaops.saved_depth_region = brw->state.depth_region;
    }
 
-   brw->state.draw_region = draw_region;
+   brw->state.draw_regions[0] = draw_region;
+   brw->state.nr_draw_regions = 1;
    brw->state.depth_region = depth_region;
 
+   if (intel->frame_buffer_texobj != NULL)
+      brw_FrameBufferTexDestroy(brw);
+
+   if (draw_region)
+       brw_FrameBufferTexInit(brw, draw_region);
+
    brw->state.dirty.mesa |= _NEW_BUFFERS;
 }
 
@@ -376,8 +385,7 @@ static void meta_draw_quad(struct intel_context *intel,
                           GLfloat x0, GLfloat x1,
                           GLfloat y0, GLfloat y1, 
                           GLfloat z,
-                          GLubyte red, GLubyte green,
-                          GLubyte blue, GLubyte alpha,
+                          GLuint color,
                           GLfloat s0, GLfloat s1,
                           GLfloat t0, GLfloat t1)
 {
@@ -388,7 +396,6 @@ static void meta_draw_quad(struct intel_context *intel,
    struct gl_client_array *attribs[VERT_ATTRIB_MAX];
    struct _mesa_prim prim[1];
    GLfloat pos[4][3];
-   GLubyte color[4];
 
    ctx->Driver.BufferData(ctx,
                          GL_ARRAY_BUFFER_ARB,
@@ -413,7 +420,6 @@ static void meta_draw_quad(struct intel_context *intel,
    pos[3][1] = y1;
    pos[3][2] = z;
 
-
    ctx->Driver.BufferSubData(ctx,
                             GL_ARRAY_BUFFER_ARB,
                             0,
@@ -421,16 +427,15 @@ static void meta_draw_quad(struct intel_context *intel,
                             pos,
                             brw->metaops.vbo);
 
-   color[0] = red;
-   color[1] = green;
-   color[2] = blue;
-   color[3] = alpha;
+   /* Convert incoming ARGB to required RGBA */
+   /* Note this color is stored as GL_UNSIGNED_BYTE */
+   color = (color & 0xff00ff00) | (((color >> 16) | (color << 16)) & 0xff00ff);
 
    ctx->Driver.BufferSubData(ctx,
                             GL_ARRAY_BUFFER_ARB,
                             sizeof(pos),
                             sizeof(color),
-                            color,
+                            &color,
                             brw->metaops.vbo);
 
    /* Ignoring texture coords. 
@@ -486,6 +491,7 @@ static void install_meta_state( struct intel_context *intel )
 {
    GLcontext *ctx = &intel->ctx;
    struct brw_context *brw = brw_context(ctx);
+   GLuint i;
 
    if (!brw->metaops.vbo) {
       init_metaops_state(brw);
@@ -495,12 +501,18 @@ static void install_meta_state( struct intel_context *intel )
    
    meta_no_texture(&brw->intel);
    meta_flat_shade(&brw->intel);
-   brw->metaops.restore_draw_mask = ctx->DrawBuffer->_ColorDrawBufferMask[0];
+   for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
+      brw->metaops.restore_draw_buffers[i]
+         = ctx->DrawBuffer->_ColorDrawBufferIndexes[i];
+   }
+   brw->metaops.restore_num_draw_buffers = ctx->DrawBuffer->_NumColorDrawBuffers;
+
    brw->metaops.restore_fp = ctx->FragmentProgram.Current;
 
    /* This works without adjusting refcounts.  Fix later? 
     */
-   brw->metaops.saved_draw_region = brw->state.draw_region;
+   brw->metaops.saved_draw_region = brw->state.draw_regions[0];
+   brw->metaops.saved_nr_draw_regions = brw->state.nr_draw_regions;
    brw->metaops.saved_depth_region = brw->state.depth_region;
    brw->metaops.active = 1;
    
@@ -511,13 +523,20 @@ static void leave_meta_state( struct intel_context *intel )
 {
    GLcontext *ctx = &intel->ctx;
    struct brw_context *brw = brw_context(ctx);
+   GLuint i;
 
    restore_attribs(brw);
 
-   ctx->DrawBuffer->_ColorDrawBufferMask[0] = brw->metaops.restore_draw_mask;
+   for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
+      ctx->DrawBuffer->_ColorDrawBufferIndexes[i]
+         = brw->metaops.restore_draw_buffers[i];
+   }
+   ctx->DrawBuffer->_NumColorDrawBuffers = brw->metaops.restore_num_draw_buffers;
+
    ctx->FragmentProgram.Current = brw->metaops.restore_fp;
 
-   brw->state.draw_region = brw->metaops.saved_draw_region;
+   brw->state.draw_regions[0] = brw->metaops.saved_draw_region;
+   brw->state.nr_draw_regions = brw->metaops.saved_nr_draw_regions;
    brw->state.depth_region = brw->metaops.saved_depth_region;
    brw->metaops.saved_draw_region = NULL;
    brw->metaops.saved_depth_region = NULL;
index d5779680ffc8f60083fada813485dca29ab20eb8..487c638ce21f44c5475dbbdfa343c4bfef12e892 100644 (file)
@@ -68,160 +68,102 @@ const struct brw_tracked_state brw_blend_constant_color = {
       .brw = 0,
       .cache = 0
    },
-   .update = upload_blend_constant_color
+   .emit = upload_blend_constant_color
 };
 
-/***********************************************************************
- * Drawing rectangle -- Need for AUB file only.
+/**
+ * Upload the binding table pointers, which point each stage's array of surface
+ * state pointers.
+ *
+ * The binding table pointers are relative to the surface state base address,
+ * which is 0.
  */
-static void upload_drawing_rect(struct brw_context *brw)
-{
-   struct intel_context *intel = &brw->intel;
-   __DRIdrawablePrivate *dPriv = intel->driDrawable;
-   struct brw_drawrect bdr;
-   int x1, y1;
-   int x2, y2;
-
-   /* If there is a single cliprect, set it here.  Otherwise iterate
-    * over them in brw_draw_prim().
-    */
-   if (brw->intel.numClipRects > 1) 
-      return; 
-   x1 = brw->intel.pClipRects[0].x1;
-   y1 = brw->intel.pClipRects[0].y1;
-   x2 = brw->intel.pClipRects[0].x2;
-   y2 = brw->intel.pClipRects[0].y2;
-        
-   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;
-
-   memset(&bdr, 0, sizeof(bdr));
-   bdr.header.opcode = CMD_DRAW_RECT;
-   bdr.header.length = sizeof(bdr)/4 - 2;
-   bdr.xmin = x1;
-   bdr.ymin = y1;
-   bdr.xmax = x2;
-   bdr.ymax = y2;
-   bdr.xorg = dPriv->x;
-   bdr.yorg = dPriv->y;
-
-   /* Can't use BRW_CACHED_BATCH_STRUCT because this is also emitted
-    * uncached in brw_draw.c:
-    */
-   BRW_BATCH_STRUCT(brw, &bdr);
-}
-
-const struct brw_tracked_state brw_drawing_rect = {
-   .dirty = {
-      .mesa = _NEW_WINDOW_POS,
-      .brw = 0,
-      .cache = 0
-   },
-   .update = upload_drawing_rect
-};
-
-/***********************************************************************
- * Binding table pointers
- */
-
 static void upload_binding_table_pointers(struct brw_context *brw)
 {
-   struct brw_binding_table_pointers btp;
-   memset(&btp, 0, sizeof(btp));
-
-   /* The binding table has been emitted to the SS pool already, so we
-    * know what its offset is.  When the batch buffer is fired, the
-    * binding table and surface structs will get fixed up to point to
-    * where the textures actually landed, but that won't change the
-    * value of the offsets here:
-    */
-   btp.header.opcode = CMD_BINDING_TABLE_PTRS;
-   btp.header.length = sizeof(btp)/4 - 2;
-   btp.vs = 0;
-   btp.gs = 0;
-   btp.clp = 0;
-   btp.sf = 0;
-   btp.wm = brw->wm.bind_ss_offset;
-
-   BRW_CACHED_BATCH_STRUCT(brw, &btp);
+   struct intel_context *intel = &brw->intel;
+   dri_bo *aper_array[] = {
+      intel->batch->buf,
+      brw->wm.bind_bo,
+   };
+
+   if (dri_bufmgr_check_aperture_space(aper_array, ARRAY_SIZE(aper_array)))
+      intel_batchbuffer_flush(intel->batch);
+
+   BEGIN_BATCH(6, IGNORE_CLIPRECTS);
+   OUT_BATCH(CMD_BINDING_TABLE_PTRS << 16 | (6 - 2));
+   OUT_BATCH(0); /* vs */
+   OUT_BATCH(0); /* gs */
+   OUT_BATCH(0); /* clip */
+   OUT_BATCH(0); /* sf */
+   OUT_RELOC(brw->wm.bind_bo,
+            I915_GEM_DOMAIN_SAMPLER, 0,
+            0);
+   ADVANCE_BATCH();
 }
 
 const struct brw_tracked_state brw_binding_table_pointers = {
    .dirty = {
       .mesa = 0,
-      .brw = 0,
-      .cache = CACHE_NEW_SURF_BIND 
+      .brw = BRW_NEW_BATCH,
+      .cache = CACHE_NEW_SURF_BIND,
    },
-   .update = upload_binding_table_pointers
+   .emit = upload_binding_table_pointers,
 };
 
 
-/***********************************************************************
- * Pipelined state pointers.  This is the key state packet from which
- * the hardware chases pointers to all the uploaded state in VRAM.
+/**
+ * Upload pointers to the per-stage state.
+ *
+ * The state pointers in this packet are all relative to the general state
+ * base address set by CMD_STATE_BASE_ADDRESS, which is 0.
  */
-   
 static void upload_pipelined_state_pointers(struct brw_context *brw )
 {
-   struct brw_pipelined_state_pointers psp;
-   memset(&psp, 0, sizeof(psp));
-
-   psp.header.opcode = CMD_PIPELINED_STATE_POINTERS;
-   psp.header.length = sizeof(psp)/4 - 2;
-
-   psp.vs.offset = brw->vs.state_gs_offset >> 5;
-   psp.sf.offset = brw->sf.state_gs_offset >> 5;
-   psp.wm.offset = brw->wm.state_gs_offset >> 5;
-   psp.cc.offset = brw->cc.state_gs_offset >> 5;
-
-   /* GS gets turned on and off regularly.  Need to re-emit URB fence
-    * after this occurs.  
-    */
-   if (brw->gs.prog_active) {
-      psp.gs.offset = brw->gs.state_gs_offset >> 5;
-      psp.gs.enable = 1;
-   }
-
-   if (!brw->metaops.active) {
-      psp.clp.offset = brw->clip.state_gs_offset >> 5;
-      psp.clp.enable = 1;
-   }
-
+   struct intel_context *intel = &brw->intel;
 
-   if (BRW_CACHED_BATCH_STRUCT(brw, &psp))
-      brw->state.dirty.brw |= BRW_NEW_PSP;
+   BEGIN_BATCH(7, IGNORE_CLIPRECTS);
+   OUT_BATCH(CMD_PIPELINED_STATE_POINTERS << 16 | (7 - 2));
+   OUT_RELOC(brw->vs.state_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
+   if (brw->gs.prog_active)
+      OUT_RELOC(brw->gs.state_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 1);
+   else
+      OUT_BATCH(0);
+   if (!brw->metaops.active)
+      OUT_RELOC(brw->clip.state_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 1);
+   else
+      OUT_BATCH(0);
+   OUT_RELOC(brw->sf.state_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
+   OUT_RELOC(brw->wm.state_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
+   OUT_RELOC(brw->cc.state_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
+   ADVANCE_BATCH();
+
+   brw->state.dirty.brw |= BRW_NEW_PSP;
 }
 
-const struct brw_tracked_state brw_pipelined_state_pointers = {
-   .dirty = {
-      .mesa = 0,
-      .brw = BRW_NEW_METAOPS,
-      .cache = (CACHE_NEW_VS_UNIT | 
-               CACHE_NEW_GS_UNIT | 
-               CACHE_NEW_GS_PROG | 
-               CACHE_NEW_CLIP_UNIT | 
-               CACHE_NEW_SF_UNIT | 
-               CACHE_NEW_WM_UNIT | 
-               CACHE_NEW_CC_UNIT)
-   },
-   .update = upload_pipelined_state_pointers
-};
-
 static void upload_psp_urb_cbs(struct brw_context *brw )
 {
+   struct intel_context *intel = &brw->intel;
+   dri_bo *aper_array[] = {
+      intel->batch->buf,
+      brw->vs.state_bo,
+      brw->gs.state_bo,
+      brw->clip.state_bo,
+      brw->wm.state_bo,
+      brw->cc.state_bo,
+   };
+
+   if (dri_bufmgr_check_aperture_space(aper_array, ARRAY_SIZE(aper_array)))
+      intel_batchbuffer_flush(intel->batch);
+
    upload_pipelined_state_pointers(brw);
    brw_upload_urb_fence(brw);
    brw_upload_constant_buffer_state(brw);
 }
 
-
 const struct brw_tracked_state brw_psp_urb_cbs = {
    .dirty = {
       .mesa = 0,
-      .brw = BRW_NEW_URB_FENCE | BRW_NEW_METAOPS,
+      .brw = BRW_NEW_URB_FENCE | BRW_NEW_METAOPS | BRW_NEW_BATCH,
       .cache = (CACHE_NEW_VS_UNIT | 
                CACHE_NEW_GS_UNIT | 
                CACHE_NEW_GS_PROG | 
@@ -230,74 +172,82 @@ const struct brw_tracked_state brw_psp_urb_cbs = {
                CACHE_NEW_WM_UNIT | 
                CACHE_NEW_CC_UNIT)
    },
-   .update = upload_psp_urb_cbs
+   .emit = upload_psp_urb_cbs,
 };
 
-
-
-
-/***********************************************************************
- * Depthbuffer - currently constant, but rotation would change that.
- */
-
-static void upload_depthbuffer(struct brw_context *brw)
+static void emit_depthbuffer(struct brw_context *brw)
 {
-   /* 0x79050003  Depth Buffer */
    struct intel_context *intel = &brw->intel;
    struct intel_region *region = brw->state.depth_region;
-   struct brw_depthbuffer bd;
-   memset(&bd, 0, sizeof(bd));
-
-   bd.header.bits.opcode = CMD_DEPTH_BUFFER;
-   bd.header.bits.length = sizeof(bd)/4-2;
-   bd.dword1.bits.pitch = (region->pitch * region->cpp) - 1;
-   
-   switch (region->cpp) {
-   case 2:
-      bd.dword1.bits.format = BRW_DEPTHFORMAT_D16_UNORM;
-      break;
-   case 4:
-      if (intel->depth_buffer_is_float)
-        bd.dword1.bits.format = BRW_DEPTHFORMAT_D32_FLOAT;
-      else
-        bd.dword1.bits.format = BRW_DEPTHFORMAT_D24_UNORM_S8_UINT;
-      break;
-   default:
-      assert(0);
-      return;
+   unsigned int len = (BRW_IS_GM45(brw) || BRW_IS_G4X(brw)) ? sizeof(struct brw_depthbuffer_gm45_g4x) / 4 : sizeof(struct brw_depthbuffer) / 4;
+
+   if (region == NULL) {
+      BEGIN_BATCH(len, IGNORE_CLIPRECTS);
+      OUT_BATCH(CMD_DEPTH_BUFFER << 16 | (len - 2));
+      OUT_BATCH((BRW_DEPTHFORMAT_D32_FLOAT << 18) |
+               (BRW_SURFACE_NULL << 29));
+      OUT_BATCH(0);
+      OUT_BATCH(0);
+      OUT_BATCH(0);
+
+      if (BRW_IS_GM45(brw) || BRW_IS_G4X(brw))
+         OUT_BATCH(0);
+
+      ADVANCE_BATCH();
+   } else {
+      unsigned int format;
+      dri_bo *aper_array[] = {
+        intel->batch->buf,
+        region->buffer
+      };
+
+      switch (region->cpp) {
+      case 2:
+        format = BRW_DEPTHFORMAT_D16_UNORM;
+        break;
+      case 4:
+        if (intel->depth_buffer_is_float)
+           format = BRW_DEPTHFORMAT_D32_FLOAT;
+        else
+           format = BRW_DEPTHFORMAT_D24_UNORM_S8_UINT;
+        break;
+      default:
+        assert(0);
+        return;
+      }
+
+      if (dri_bufmgr_check_aperture_space(aper_array, ARRAY_SIZE(aper_array)))
+        intel_batchbuffer_flush(intel->batch);
+
+      BEGIN_BATCH(len, IGNORE_CLIPRECTS);
+      OUT_BATCH(CMD_DEPTH_BUFFER << 16 | (len - 2));
+      OUT_BATCH(((region->pitch * region->cpp) - 1) |
+               (format << 18) |
+               (BRW_TILEWALK_YMAJOR << 26) |
+               ((region->tiling != I915_TILING_NONE) << 27) |
+               (BRW_SURFACE_2D << 29));
+      OUT_RELOC(region->buffer,
+               I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
+               0);
+      OUT_BATCH((BRW_SURFACE_MIPMAPLAYOUT_BELOW << 1) |
+               ((region->pitch - 1) << 6) |
+               ((region->height - 1) << 19));
+      OUT_BATCH(0);
+
+      if (BRW_IS_GM45(brw) || BRW_IS_G4X(brw))
+         OUT_BATCH(0);
+
+      ADVANCE_BATCH();
    }
-
-   bd.dword1.bits.depth_offset_disable = 0; /* coordinate offset */
-
-   /* The depthbuffer can only use YMAJOR tiling...  This is a bit of
-    * a shame as it clashes with the 2d blitter which only supports
-    * XMAJOR tiling...  
-    */
-   bd.dword1.bits.tile_walk = BRW_TILEWALK_YMAJOR;
-   bd.dword1.bits.tiled_surface = intel->depth_region->tiled;
-   bd.dword1.bits.surface_type = BRW_SURFACE_2D;
-
-   /* BRW_NEW_LOCK */
-   bd.dword2_base_addr = bmBufferOffset(intel, region->buffer);    
-
-   bd.dword3.bits.mipmap_layout = BRW_SURFACE_MIPMAPLAYOUT_BELOW;
-   bd.dword3.bits.lod = 0;
-   bd.dword3.bits.width = region->pitch - 1; /* XXX: width ? */
-   bd.dword3.bits.height = region->height - 1;
-
-   bd.dword4.bits.min_array_element = 0;
-   bd.dword4.bits.depth = 0;
-      
-   BRW_CACHED_BATCH_STRUCT(brw, &bd);
 }
 
 const struct brw_tracked_state brw_depthbuffer = {
    .dirty = {
       .mesa = 0,
-      .brw = BRW_NEW_CONTEXT | BRW_NEW_LOCK,
-      .cache = 0
+      .brw = BRW_NEW_DEPTH_BUFFER | BRW_NEW_BATCH,
+      .cache = 0,
    },
-   .update = upload_depthbuffer
+   .emit = emit_depthbuffer,
 };
 
 
@@ -327,7 +277,7 @@ const struct brw_tracked_state brw_polygon_stipple = {
       .brw = 0,
       .cache = 0
    },
-   .update = upload_polygon_stipple
+   .emit = upload_polygon_stipple
 };
 
 
@@ -350,13 +300,42 @@ static void upload_polygon_stipple_offset(struct brw_context *brw)
    BRW_CACHED_BATCH_STRUCT(brw, &bpso);
 }
 
+#define _NEW_WINDOW_POS 0x40000000
+
 const struct brw_tracked_state brw_polygon_stipple_offset = {
    .dirty = {
       .mesa = _NEW_WINDOW_POS,
       .brw = 0,
       .cache = 0
    },
-   .update = upload_polygon_stipple_offset
+   .emit = upload_polygon_stipple_offset
+};
+
+/**********************************************************************
+ * AA Line parameters
+ */
+static void upload_aa_line_parameters(struct brw_context *brw)
+{
+   struct brw_aa_line_parameters balp;
+   
+   if (!(BRW_IS_GM45(brw) || BRW_IS_G4X(brw)))
+      return;
+
+   /* use legacy aa line coverage computation */
+   memset(&balp, 0, sizeof(balp));
+   balp.header.opcode = CMD_AA_LINE_PARAMETERS;
+   balp.header.length = sizeof(balp) / 4 - 2;
+   
+   BRW_CACHED_BATCH_STRUCT(brw, &balp);
+}
+
+const struct brw_tracked_state brw_aa_line_parameters = {
+   .dirty = {
+      .mesa = 0,
+      .brw = BRW_NEW_CONTEXT,
+      .cache = 0
+   },
+   .emit = upload_aa_line_parameters
 };
 
 /***********************************************************************
@@ -391,41 +370,7 @@ const struct brw_tracked_state brw_line_stipple = {
       .brw = 0,
       .cache = 0
    },
-   .update = upload_line_stipple
-};
-
-
-
-/***********************************************************************
- * Misc constant state packets
- */
-
-static void upload_pipe_control(struct brw_context *brw)
-{
-   struct brw_pipe_control pc;
-
-   return;
-
-   memset(&pc, 0, sizeof(pc));
-
-   pc.header.opcode = CMD_PIPE_CONTROL;
-   pc.header.length = sizeof(pc)/4 - 2;
-   pc.header.post_sync_operation = PIPE_CONTROL_NOWRITE;
-
-   pc.header.instruction_state_cache_flush_enable = 1;
-
-   pc.bits1.dest_addr_type = PIPE_CONTROL_GTTWRITE_GLOBAL;
-
-   BRW_BATCH_STRUCT(brw, &pc);
-}
-
-const struct brw_tracked_state brw_pipe_control = {
-   .dirty = {
-      .mesa = 0,
-      .brw = BRW_NEW_CONTEXT,
-      .cache = 0
-   },
-   .update = upload_pipe_control
+   .emit = upload_line_stipple
 };
 
 
@@ -441,7 +386,7 @@ static void upload_invarient_state( struct brw_context *brw )
       struct brw_pipeline_select ps;
 
       memset(&ps, 0, sizeof(ps));
-      ps.header.opcode = CMD_PIPELINE_SELECT;
+      ps.header.opcode = CMD_PIPELINE_SELECT(brw);
       ps.header.pipeline_select = 0;
       BRW_BATCH_STRUCT(brw, &ps);
    }
@@ -477,7 +422,7 @@ static void upload_invarient_state( struct brw_context *brw )
       struct brw_vf_statistics vfs;
       memset(&vfs, 0, sizeof(vfs));
 
-      vfs.opcode = CMD_VF_STATISTICS;
+      vfs.opcode = CMD_VF_STATISTICS(brw);
       if (INTEL_DEBUG & DEBUG_STATS)
         vfs.statistics_enable = 1; 
 
@@ -491,43 +436,39 @@ const struct brw_tracked_state brw_invarient_state = {
       .brw = BRW_NEW_CONTEXT,
       .cache = 0
    },
-   .update = upload_invarient_state
+   .emit = upload_invarient_state
 };
 
-
-/* State pool addresses:
+/**
+ * Define the base addresses which some state is referenced from.
+ *
+ * This allows us to avoid having to emit relocations in many places for
+ * cached state, and instead emit pointers inside of large, mostly-static
+ * state pools.  This comes at the expense of memory, and more expensive cache
+ * misses.
  */
 static void upload_state_base_address( struct brw_context *brw )
 {
    struct intel_context *intel = &brw->intel;
-   struct brw_state_base_address sba;
-      
-   memset(&sba, 0, sizeof(sba));
-
-   sba.header.opcode = CMD_STATE_BASE_ADDRESS;
-   sba.header.length = 0x4;
-
-   /* BRW_NEW_LOCK */
-   sba.bits0.general_state_address = bmBufferOffset(intel, brw->pool[BRW_GS_POOL].buffer) >> 5;
-   sba.bits0.modify_enable = 1;
 
-   /* BRW_NEW_LOCK */
-   sba.bits1.surface_state_address = bmBufferOffset(intel, brw->pool[BRW_SS_POOL].buffer) >> 5;
-   sba.bits1.modify_enable = 1;
-
-   sba.bits2.modify_enable = 1;
-   sba.bits3.modify_enable = 1;
-   sba.bits4.modify_enable = 1;
-
-   BRW_CACHED_BATCH_STRUCT(brw, &sba);
+   /* Output the structure (brw_state_base_address) directly to the
+    * batchbuffer, so we can emit relocations inline.
+    */
+   BEGIN_BATCH(6, IGNORE_CLIPRECTS);
+   OUT_BATCH(CMD_STATE_BASE_ADDRESS << 16 | (6 - 2));
+   OUT_BATCH(1); /* General state base address */
+   OUT_BATCH(1); /* Surface state base address */
+   OUT_BATCH(1); /* Indirect object base address */
+   OUT_BATCH(1); /* General state upper bound */
+   OUT_BATCH(1); /* Indirect object upper bound */
+   ADVANCE_BATCH();
 }
 
-
 const struct brw_tracked_state brw_state_base_address = {
    .dirty = {
       .mesa = 0,
-      .brw = BRW_NEW_CONTEXT | BRW_NEW_LOCK,
-      .cache = 0
+      .brw = BRW_NEW_CONTEXT,
+      .cache = 0,
    },
-   .update = upload_state_base_address
+   .emit = upload_state_base_address
 };
index 752fe49bcbf6dfd2b5389c22145e11356ee8e1df..c38610b24ed3c5aa8f4ff600bb2aceeda23c9cdc 100644 (file)
   *   Keith Whitwell <keith@tungstengraphics.com>
   */
   
+#include "main/imports.h"
+#include "main/enums.h"
 #include "shader/prog_parameter.h"
-#include "brw_context.h"
-#include "brw_aub.h"
-#include "brw_util.h"
-#include "program.h"
-#include "imports.h"
-#include "enums.h"
+#include "shader/program.h"
+#include "shader/programopt.h"
 #include "tnl/tnl.h"
 
+#include "brw_context.h"
+#include "brw_util.h"
 
 static void brwBindProgram( GLcontext *ctx,
                            GLenum target, 
@@ -125,6 +125,9 @@ static void brwProgramStringNotify( GLcontext *ctx,
       struct brw_vertex_program *vp = (struct brw_vertex_program *)brw->vertex_program;
       if (p == vp)
         brw->state.dirty.brw |= BRW_NEW_VERTEX_PROGRAM;
+      if (p->program.IsPositionInvariant) {
+        _mesa_insert_mvp_code(ctx, &p->program);
+      }
       p->id = brw->program_id++;      
       p->param_state = p->program.Base.Parameters->StateFlags;
 
index d5175399d6c71907184f9be624b919d5000a8e67..5bb9e11310b6264141a2503cdc144f0ff6656905 100644 (file)
@@ -43,8 +43,6 @@
 #include "brw_sf.h"
 #include "brw_state.h"
 
-#define DO_SETUP_BITS ((1<<FRAG_ATTRIB_MAX)-1)
-
 static void compile_sf_prog( struct brw_context *brw,
                             struct brw_sf_prog_key *key )
 {
@@ -57,7 +55,7 @@ static void compile_sf_prog( struct brw_context *brw,
 
    /* Begin the compilation:
     */
-   brw_init_compile(&c.func);
+   brw_init_compile(brw, &c.func);
 
    c.key = *key;
    c.nr_attrs = brw_count_bits(c.key.attrs);
@@ -74,6 +72,11 @@ static void compile_sf_prog( struct brw_context *brw,
       if (c.key.attrs & (1<<i)) {
         c.attr_to_idx[i] = idx;
         c.idx_to_attr[idx] = i;
+        if (i >= VERT_RESULT_TEX0 && i <= VERT_RESULT_TEX7) {
+                c.point_attrs[i].CoordReplace = 
+                       brw->attribs.Point->CoordReplace[i - VERT_RESULT_TEX0];
+        } else
+                c.point_attrs[i].CoordReplace = GL_FALSE;
         idx++;
       }
    
@@ -82,15 +85,18 @@ static void compile_sf_prog( struct brw_context *brw,
    switch (key->primitive) {
    case SF_TRIANGLES:
       c.nr_verts = 3;
-      brw_emit_tri_setup( &c );
+      brw_emit_tri_setup( &c, GL_TRUE );
       break;
    case SF_LINES:
       c.nr_verts = 2;
-      brw_emit_line_setup( &c );
+      brw_emit_line_setup( &c, GL_TRUE );
       break;
    case SF_POINTS:
       c.nr_verts = 1;
-      brw_emit_point_setup( &c );
+      if (key->do_point_sprite)
+         brw_emit_point_sprite_setup( &c, GL_TRUE );
+      else
+         brw_emit_point_setup( &c, GL_TRUE );
       break;
    case SF_UNFILLED_TRIS:
       c.nr_verts = 3;
@@ -108,29 +114,18 @@ static void compile_sf_prog( struct brw_context *brw,
 
    /* Upload
     */
-   brw->sf.prog_gs_offset = brw_upload_cache( &brw->cache[BRW_SF_PROG],
-                                             &c.key,
-                                             sizeof(c.key),
-                                             program,
-                                             program_size,
-                                             &c.prog_data,
-                                             &brw->sf.prog_data );
+   dri_bo_unreference(brw->sf.prog_bo);
+   brw->sf.prog_bo = brw_upload_cache( &brw->cache, BRW_SF_PROG,
+                                      &c.key, sizeof(c.key),
+                                      NULL, 0,
+                                      program, program_size,
+                                      &c.prog_data,
+                                      &brw->sf.prog_data );
 }
 
-
-static GLboolean search_cache( struct brw_context *brw, 
-                              struct brw_sf_prog_key *key )
-{
-   return brw_search_cache(&brw->cache[BRW_SF_PROG], 
-                          key, sizeof(*key),
-                          &brw->sf.prog_data,
-                          &brw->sf.prog_gs_offset);
-}
-
-
 /* Calculate interpolants for triangle and line rasterization.
  */
-static void upload_sf_prog( struct brw_context *brw )
+static void upload_sf_prog(struct brw_context *brw)
 {
    struct brw_sf_prog_key key;
 
@@ -162,7 +157,8 @@ static void upload_sf_prog( struct brw_context *brw )
       break;
    }
 
-
+   key.do_point_sprite = brw->attribs.Point->PointSprite;
+   key.SpriteOrigin = brw->attribs.Point->SpriteOrigin;
    /* _NEW_LIGHT */
    key.do_flat_shading = (brw->attribs.Light->ShadeModel == GL_FLAT);
    key.do_twoside_color = (brw->attribs.Light->Enabled && brw->attribs.Light->Model.TwoSide);
@@ -171,18 +167,22 @@ static void upload_sf_prog( struct brw_context *brw )
    if (key.do_twoside_color)
       key.frontface_ccw = (brw->attribs.Polygon->FrontFace == GL_CCW);
 
-
-   if (!search_cache(brw, &key))
+   dri_bo_unreference(brw->sf.prog_bo);
+   brw->sf.prog_bo = brw_search_cache(&brw->cache, BRW_SF_PROG,
+                                     &key, sizeof(key),
+                                     NULL, 0,
+                                     &brw->sf.prog_data);
+   if (brw->sf.prog_bo == NULL)
       compile_sf_prog( brw, &key );
 }
 
 
 const struct brw_tracked_state brw_sf_prog = {
    .dirty = {
-      .mesa  = (_NEW_LIGHT|_NEW_POLYGON),
+      .mesa  = (_NEW_LIGHT|_NEW_POLYGON|_NEW_POINT),
       .brw   = (BRW_NEW_REDUCED_PRIMITIVE),
       .cache = CACHE_NEW_VS_PROG
    },
-   .update = upload_sf_prog
+   .prepare = upload_sf_prog
 };
 
index fb72b84ba8a7344b2fd9523dfba8cbe6a792232f..1c0fb70fe069218c1ceeef991172be301dbcc52d 100644 (file)
@@ -34,9 +34,9 @@
 #define BRW_SF_H
 
 
+#include "shader/program.h"
 #include "brw_context.h"
 #include "brw_eu.h"
-#include "program.h"
 
 
 #define SF_POINTS    0
 #define SF_UNFILLED_TRIS   3
 
 struct brw_sf_prog_key {
+   GLuint attrs:32;
    GLuint primitive:2;
    GLuint do_twoside_color:1;
    GLuint do_flat_shading:1;
-   GLuint attrs:16;
    GLuint frontface_ccw:1;
-   GLuint pad:11;
+   GLuint do_point_sprite:1;
+   GLuint pad:10;
+   GLenum SpriteOrigin;
 };
 
+struct brw_sf_point_tex {
+       GLboolean CoordReplace; 
+};
 
 struct brw_sf_compile {
    struct brw_compile func;
@@ -94,12 +99,14 @@ struct brw_sf_compile {
 
    GLubyte attr_to_idx[VERT_RESULT_MAX];   
    GLubyte idx_to_attr[VERT_RESULT_MAX];   
+   struct brw_sf_point_tex point_attrs[VERT_RESULT_MAX];
 };
 
  
-void brw_emit_tri_setup( struct brw_sf_compile *c );
-void brw_emit_line_setup( struct brw_sf_compile *c );
-void brw_emit_point_setup( struct brw_sf_compile *c );
+void brw_emit_tri_setup( struct brw_sf_compile *c, GLboolean allocate );
+void brw_emit_line_setup( struct brw_sf_compile *c, GLboolean allocate );
+void brw_emit_point_setup( struct brw_sf_compile *c, GLboolean allocate );
+void brw_emit_point_sprite_setup( struct brw_sf_compile *c, GLboolean allocate );
 void brw_emit_anyprim_setup( struct brw_sf_compile *c );
 
 #endif
index cbaf018c44a868a4e6ba42f7fd4731306ffbdb6b..6fba8c890835b3b6a8cbad1d95b462d2ef1d7e7e 100644 (file)
@@ -59,6 +59,35 @@ static GLboolean have_attr(struct brw_sf_compile *c,
    return (c->key.attrs & (1<<attr)) ? 1 : 0;
 }
 
+/**
+ * Sets VERT_RESULT_FOGC.Y  for gl_FrontFacing
+ *
+ * This is currently executed if the fragment program uses VERT_RESULT_FOGC
+ * at all, but this could be eliminated with a scan of the FP contents.
+ */
+static void
+do_front_facing( struct brw_sf_compile *c )
+{
+   struct brw_compile *p = &c->func; 
+   int i;
+
+   if (!have_attr(c, VERT_RESULT_FOGC))
+      return;
+
+   brw_push_insn_state(p);
+   brw_CMP(p, brw_null_reg(), 
+        c->key.frontface_ccw ? BRW_CONDITIONAL_G : BRW_CONDITIONAL_L,
+        c->det, brw_imm_f(0));
+   brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+   for (i = 0; i < 3; i++) {
+       struct brw_reg fogc = get_vert_attr(c, c->vert[i],FRAG_ATTRIB_FOGC);
+       brw_MOV(p, get_element(fogc, 1), brw_imm_f(0));
+       brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
+       brw_MOV(p, get_element(fogc, 1), brw_imm_f(1));
+       brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+   }
+   brw_pop_insn_state(p);
+}
 
                         
 /*********************************************************************** 
@@ -343,15 +372,19 @@ static GLboolean calculate_masks( struct brw_sf_compile *c,
 
 
 
-void brw_emit_tri_setup( struct brw_sf_compile *c )
+void brw_emit_tri_setup( struct brw_sf_compile *c, GLboolean allocate)
 {
    struct brw_compile *p = &c->func;
    GLuint i;
 
    c->nr_verts = 3;
-   alloc_regs(c);
+
+   if (allocate)
+      alloc_regs(c);
+
    invert_det(c);
    copy_z_inv_w(c);
+   do_front_facing(c);
 
    if (c->key.do_twoside_color) 
       do_twoside_color(c);
@@ -428,14 +461,17 @@ void brw_emit_tri_setup( struct brw_sf_compile *c )
 
 
 
-void brw_emit_line_setup( struct brw_sf_compile *c )
+void brw_emit_line_setup( struct brw_sf_compile *c, GLboolean allocate)
 {
    struct brw_compile *p = &c->func;
    GLuint i;
 
 
    c->nr_verts = 2;
-   alloc_regs(c);
+
+   if (allocate)
+      alloc_regs(c);
+
    invert_det(c);
    copy_z_inv_w(c);
 
@@ -497,17 +533,103 @@ void brw_emit_line_setup( struct brw_sf_compile *c )
    } 
 }
 
+void brw_emit_point_sprite_setup( struct brw_sf_compile *c, GLboolean allocate)
+{
+   struct brw_compile *p = &c->func;
+   GLuint i;
+
+   c->nr_verts = 1;
+
+   if (allocate)
+      alloc_regs(c);
+
+   copy_z_inv_w(c);
+   for (i = 0; i < c->nr_setup_regs; i++)
+   {
+      struct brw_sf_point_tex *tex = &c->point_attrs[c->idx_to_attr[2*i]];
+      struct brw_reg a0 = offset(c->vert[0], i);
+      GLushort pc, pc_persp, pc_linear;
+      GLboolean last = calculate_masks(c, i, &pc, &pc_persp, &pc_linear);
+            
+      if (pc_persp)
+      {                                
+         if (!tex->CoordReplace) {
+             brw_set_predicate_control_flag_value(p, pc_persp);
+             brw_MUL(p, a0, a0, c->inv_w[0]);
+         }
+      }
+
+      if (tex->CoordReplace) {
+         /* Caculate 1.0/PointWidth */
+         brw_math(&c->func,
+                 c->tmp,
+                 BRW_MATH_FUNCTION_INV,
+                 BRW_MATH_SATURATE_NONE,
+                 0,
+                 c->dx0,
+                 BRW_MATH_DATA_SCALAR,
+                 BRW_MATH_PRECISION_FULL);
+
+         if (c->key.SpriteOrigin == GL_LOWER_LEFT) {
+               brw_MUL(p, c->m1Cx, c->tmp, c->inv_w[0]);
+               brw_MOV(p, vec1(suboffset(c->m1Cx, 1)), brw_imm_f(0.0));
+               brw_MUL(p, c->m2Cy, c->tmp, negate(c->inv_w[0]));
+               brw_MOV(p, vec1(suboffset(c->m2Cy, 0)), brw_imm_f(0.0));
+         } else {
+               brw_MUL(p, c->m1Cx, c->tmp, c->inv_w[0]);
+               brw_MOV(p, vec1(suboffset(c->m1Cx, 1)), brw_imm_f(0.0));
+               brw_MUL(p, c->m2Cy, c->tmp, c->inv_w[0]);
+               brw_MOV(p, vec1(suboffset(c->m2Cy, 0)), brw_imm_f(0.0));
+         }
+      } else {
+         brw_MOV(p, c->m1Cx, brw_imm_ud(0));
+         brw_MOV(p, c->m2Cy, brw_imm_ud(0));
+      }
+
+      {
+        brw_set_predicate_control_flag_value(p, pc); 
+        if (tex->CoordReplace) {
+            if (c->key.SpriteOrigin == GL_LOWER_LEFT) {
+                brw_MUL(p, c->m3C0, c->inv_w[0], brw_imm_f(1.0));
+                brw_MOV(p, vec1(suboffset(c->m3C0, 0)), brw_imm_f(0.0));
+            }
+            else
+                brw_MOV(p, c->m3C0, brw_imm_f(0.0));
+        } else {
+               brw_MOV(p, c->m3C0, a0); /* constant value */
+        }
+
+        /* Copy m0..m3 to URB. 
+         */
+        brw_urb_WRITE(p, 
+                      brw_null_reg(),
+                      0,
+                      brw_vec8_grf(0, 0),
+                      0,       /* allocate */
+                      1,       /* used */
+                      4,       /* msg len */
+                      0,       /* response len */
+                      last,    /* eot */
+                      last,    /* writes complete */
+                      i*4,     /* urb destination offset */
+                      BRW_URB_SWIZZLE_TRANSPOSE);
+      }
+   }
+}
 
 /* Points setup - several simplifications as all attributes are
  * constant across the face of the point (point sprites excluded!)
  */
-void brw_emit_point_setup( struct brw_sf_compile *c )
+void brw_emit_point_setup( struct brw_sf_compile *c, GLboolean allocate)
 {
    struct brw_compile *p = &c->func;
    GLuint i;
 
    c->nr_verts = 1;
-   alloc_regs(c);
+   
+   if (allocate)
+      alloc_regs(c);
+
    copy_z_inv_w(c);
 
    brw_MOV(p, c->m1Cx, brw_imm_ud(0)); /* zero - move out of loop */
@@ -561,10 +683,14 @@ void brw_emit_anyprim_setup( struct brw_sf_compile *c )
    struct brw_compile *p = &c->func;
    struct brw_reg ip = brw_ip_reg();
    struct brw_reg payload_prim = brw_uw1_reg(BRW_GENERAL_REGISTER_FILE, 1, 0);
+   struct brw_reg payload_attr = get_element_ud(brw_vec1_reg(BRW_GENERAL_REGISTER_FILE, 1, 0), 0); 
    struct brw_reg primmask;
    struct brw_instruction *jmp;
    struct brw_reg v1_null_ud = vec1(retype(brw_null_reg(), BRW_REGISTER_TYPE_UD));
+   
+   GLuint saveflag;
 
+   c->nr_verts = 3;
    alloc_regs(c);
 
    primmask = retype(get_element(c->tmp, 0), BRW_REGISTER_TYPE_UD);
@@ -582,8 +708,15 @@ void brw_emit_anyprim_setup( struct brw_sf_compile *c )
                                               (1<<_3DPRIM_TRIFAN_NOSTIPPLE)));
    jmp = brw_JMPI(p, ip, ip, brw_imm_w(0));
    {
-      brw_emit_tri_setup( c );
-      /* note - thread killed in subroutine */
+      saveflag = p->flag_value;
+      brw_push_insn_state(p); 
+      brw_emit_tri_setup( c, GL_FALSE );
+      brw_pop_insn_state(p);
+      p->flag_value = saveflag;
+      /* note - thread killed in subroutine, so must
+       * restore the flag which is changed when building
+       * the subroutine. fix #13240
+       */
    }
    brw_land_fwd_jump(p, jmp);
 
@@ -596,12 +729,28 @@ void brw_emit_anyprim_setup( struct brw_sf_compile *c )
                                               (1<<_3DPRIM_LINESTRIP_CONT_BF)));
    jmp = brw_JMPI(p, ip, ip, brw_imm_w(0));
    {
-      brw_emit_line_setup( c );
+      saveflag = p->flag_value;
+      brw_push_insn_state(p); 
+      brw_emit_line_setup( c, GL_FALSE );
+      brw_pop_insn_state(p);
+      p->flag_value = saveflag;
       /* note - thread killed in subroutine */
    }
    brw_land_fwd_jump(p, jmp); 
 
-   brw_emit_point_setup( c );
+   brw_set_conditionalmod(p, BRW_CONDITIONAL_Z);
+   brw_AND(p, v1_null_ud, payload_attr, brw_imm_ud(1<<BRW_SPRITE_POINT_ENABLE));
+   jmp = brw_JMPI(p, ip, ip, brw_imm_w(0));
+   {
+      saveflag = p->flag_value;
+      brw_push_insn_state(p); 
+      brw_emit_point_sprite_setup( c, GL_FALSE );
+      brw_pop_insn_state(p);
+      p->flag_value = saveflag;
+   }
+   brw_land_fwd_jump(p, jmp); 
+
+   brw_emit_point_setup( c, GL_FALSE );
 }
 
 
index 9a6e5f5f192ae7097e5069bf43dde34756d94162..07d0b4c798a0a50136b42cc364015b482336a2c0 100644 (file)
 #include "brw_state.h"
 #include "brw_defines.h"
 #include "macros.h"
+#include "intel_fbo.h"
 
 static void upload_sf_vp(struct brw_context *brw)
 {
+   GLcontext *ctx = &brw->intel.ctx;
+   const GLfloat depth_scale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
    struct brw_sf_viewport sfv;
+   struct intel_renderbuffer *irb =
+      intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]);
+   GLfloat y_scale, y_bias;
 
    memset(&sfv, 0, sizeof(sfv));
-   
-   if (brw->intel.driDrawable) 
-   {
-      /* _NEW_VIEWPORT, BRW_NEW_METAOPS */
-
-      if (!brw->metaops.active) {
-        const GLfloat *v = brw->intel.ctx.Viewport._WindowMap.m;
-        
-        sfv.viewport.m00 =   v[MAT_SX];
-        sfv.viewport.m11 = - v[MAT_SY];
-        sfv.viewport.m22 =   v[MAT_SZ] * brw->intel.depth_scale;
-        sfv.viewport.m30 =   v[MAT_TX];
-        sfv.viewport.m31 = - v[MAT_TY] + brw->intel.driDrawable->h;
-        sfv.viewport.m32 =   v[MAT_TZ] * brw->intel.depth_scale;
-      }
-      else {
-        sfv.viewport.m00 =   1;
-        sfv.viewport.m11 = - 1;
-        sfv.viewport.m22 =   1;
-        sfv.viewport.m30 =   0;
-        sfv.viewport.m31 =   brw->intel.driDrawable->h;
-        sfv.viewport.m32 =   0;
+
+   if (ctx->DrawBuffer->Name) {
+      /* User-created FBO */
+      if (irb && !irb->RenderToTexture) {
+        y_scale = -1.0;
+        y_bias = ctx->DrawBuffer->Height;
+      } else {
+        y_scale = 1.0;
+        y_bias = 0;
       }
+   } else {
+      y_scale = -1.0;
+      y_bias = ctx->DrawBuffer->Height;
    }
 
-   /* XXX: what state for this? */
-   if (brw->intel.driDrawable)
-   {
-      intelScreenPrivate *screen = brw->intel.intelScreen;
-      /* _NEW_SCISSOR */
-      GLint x = brw->attribs.Scissor->X;
-      GLint y = brw->attribs.Scissor->Y;
-      GLuint w = brw->attribs.Scissor->Width;
-      GLuint h = brw->attribs.Scissor->Height;
-
-      GLint x1 = x;
-      GLint y1 = brw->intel.driDrawable->h - (y + h);
-      GLint x2 = x + w - 1;
-      GLint y2 = y1 + h - 1;
-
-      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;
-      
-      sfv.scissor.xmin = x1;
-      sfv.scissor.xmax = x2;
-      sfv.scissor.ymin = y1;
-      sfv.scissor.ymax = y2;
+   /* _NEW_VIEWPORT, BRW_NEW_METAOPS */
+
+   if (!brw->metaops.active) {
+      const GLfloat *v = ctx->Viewport._WindowMap.m;
+
+      sfv.viewport.m00 = v[MAT_SX];
+      sfv.viewport.m11 = v[MAT_SY] * y_scale;
+      sfv.viewport.m22 = v[MAT_SZ] * depth_scale;
+      sfv.viewport.m30 = v[MAT_TX];
+      sfv.viewport.m31 = v[MAT_TY] * y_scale + y_bias;
+      sfv.viewport.m32 = v[MAT_TZ] * depth_scale;
+   } else {
+      sfv.viewport.m00 =   1;
+      sfv.viewport.m11 = - 1;
+      sfv.viewport.m22 =   1;
+      sfv.viewport.m30 =   0;
+      sfv.viewport.m31 =   ctx->DrawBuffer->Height;
+      sfv.viewport.m32 =   0;
    }
 
-   brw->sf.vp_gs_offset = brw_cache_data( &brw->cache[BRW_SF_VP], &sfv );
+   /* _NEW_SCISSOR */
+
+   /* The scissor only needs to handle the intersection of drawable and
+    * scissor rect.  Clipping to the boundaries of static shared buffers
+    * for front/back/depth is covered by looping over cliprects in brw_draw.c.
+    *
+    * Note that the hardware's coordinates are inclusive, while Mesa's min is
+    * inclusive but max is exclusive.
+    */
+   sfv.scissor.xmin = ctx->DrawBuffer->_Xmin;
+   sfv.scissor.xmax = ctx->DrawBuffer->_Xmax - 1;
+   sfv.scissor.ymin = ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymax;
+   sfv.scissor.ymax = ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymin - 1;
+
+   dri_bo_unreference(brw->sf.vp_bo);
+   brw->sf.vp_bo = brw_cache_data( &brw->cache, BRW_SF_VP, &sfv, NULL, 0 );
 }
 
 const struct brw_tracked_state brw_sf_vp = {
@@ -107,87 +107,131 @@ const struct brw_tracked_state brw_sf_vp = {
       .brw   = BRW_NEW_METAOPS,
       .cache = 0
    },
-   .update = upload_sf_vp
+   .prepare = upload_sf_vp
 };
 
+struct brw_sf_unit_key {
+   unsigned int total_grf;
+   unsigned int urb_entry_read_length;
 
+   unsigned int nr_urb_entries, urb_size, sfsize;
 
-static void upload_sf_unit( struct brw_context *brw )
+   GLenum front_face, cull_face;
+   GLboolean scissor, line_smooth, point_sprite, point_attenuated;
+   float line_width;
+   float point_size;
+};
+
+static void
+sf_unit_populate_key(struct brw_context *brw, struct brw_sf_unit_key *key)
+{
+   memset(key, 0, sizeof(*key));
+
+   /* CACHE_NEW_SF_PROG */
+   key->total_grf = brw->sf.prog_data->total_grf;
+   key->urb_entry_read_length = brw->sf.prog_data->urb_read_length;
+
+   /* BRW_NEW_URB_FENCE */
+   key->nr_urb_entries = brw->urb.nr_sf_entries;
+   key->urb_size = brw->urb.vsize;
+   key->sfsize = brw->urb.sfsize;
+
+   key->scissor = brw->attribs.Scissor->Enabled;
+   key->front_face = brw->attribs.Polygon->FrontFace;
+
+   if (brw->attribs.Polygon->CullFlag)
+      key->cull_face = brw->attribs.Polygon->CullFaceMode;
+   else
+      key->cull_face = GL_NONE;
+
+   key->line_width = brw->attribs.Line->Width;
+   key->line_smooth = brw->attribs.Line->SmoothFlag;
+
+   key->point_sprite = brw->attribs.Point->PointSprite;
+   key->point_size = brw->attribs.Point->Size;
+   key->point_attenuated = brw->attribs.Point->_Attenuated;
+}
+
+static dri_bo *
+sf_unit_create_from_key(struct brw_context *brw, struct brw_sf_unit_key *key,
+                       dri_bo **reloc_bufs)
 {
    struct brw_sf_unit_state sf;
+   dri_bo *bo;
+
    memset(&sf, 0, sizeof(sf));
 
-   /* CACHE_NEW_SF_PROG */
-   sf.thread0.grf_reg_count = ((brw->sf.prog_data->total_grf-1) & ~15) / 16;
-   sf.thread0.kernel_start_pointer = brw->sf.prog_gs_offset >> 6;
-   sf.thread3.urb_entry_read_length = brw->sf.prog_data->urb_read_length;
+   sf.thread0.grf_reg_count = ALIGN(key->total_grf, 16) / 16 - 1;
+   sf.thread0.kernel_start_pointer = brw->sf.prog_bo->offset >> 6; /* reloc */
 
    sf.thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
+
    sf.thread3.dispatch_grf_start_reg = 3;
    sf.thread3.urb_entry_read_offset = 1;
+   sf.thread3.urb_entry_read_length = key->urb_entry_read_length;
 
-   /* BRW_NEW_URB_FENCE */
-   sf.thread4.nr_urb_entries = brw->urb.nr_sf_entries;
-   sf.thread4.urb_entry_allocation_size = brw->urb.sfsize - 1;
-   sf.thread4.max_threads = MIN2(12, brw->urb.nr_sf_entries / 2) - 1;
+   sf.thread4.nr_urb_entries = key->nr_urb_entries;
+   sf.thread4.urb_entry_allocation_size = key->sfsize - 1;
+   sf.thread4.max_threads = MIN2(12, key->nr_urb_entries / 2) - 1;
 
    if (INTEL_DEBUG & DEBUG_SINGLE_THREAD)
-      sf.thread4.max_threads = 0; 
+      sf.thread4.max_threads = 0;
 
    if (INTEL_DEBUG & DEBUG_STATS)
-      sf.thread4.stats_enable = 1; 
+      sf.thread4.stats_enable = 1;
 
    /* CACHE_NEW_SF_VP */
-   sf.sf5.sf_viewport_state_offset = brw->sf.vp_gs_offset >> 5;
-   
+   sf.sf5.sf_viewport_state_offset = brw->sf.vp_bo->offset >> 5; /* reloc */
+
    sf.sf5.viewport_transform = 1;
-   
+
    /* _NEW_SCISSOR */
-   if (brw->attribs.Scissor->Enabled) 
-      sf.sf6.scissor = 1;  
+   if (key->scissor)
+      sf.sf6.scissor = 1;
 
    /* _NEW_POLYGON */
-   if (brw->attribs.Polygon->FrontFace == GL_CCW)
+   if (key->front_face == GL_CCW)
       sf.sf5.front_winding = BRW_FRONTWINDING_CCW;
    else
       sf.sf5.front_winding = BRW_FRONTWINDING_CW;
 
-   if (brw->attribs.Polygon->CullFlag) {
-      switch (brw->attribs.Polygon->CullFaceMode) {
-      case GL_FRONT:
-        sf.sf6.cull_mode = BRW_CULLMODE_FRONT;
-        break;
-      case GL_BACK:
-        sf.sf6.cull_mode = BRW_CULLMODE_BACK;
-        break;
-      case GL_FRONT_AND_BACK:
-        sf.sf6.cull_mode = BRW_CULLMODE_BOTH;
-        break;
-      default:
-        assert(0);
-        break;
-      }
-   }
-   else
+   switch (key->cull_face) {
+   case GL_FRONT:
+      sf.sf6.cull_mode = BRW_CULLMODE_FRONT;
+      break;
+   case GL_BACK:
+      sf.sf6.cull_mode = BRW_CULLMODE_BACK;
+      break;
+   case GL_FRONT_AND_BACK:
+      sf.sf6.cull_mode = BRW_CULLMODE_BOTH;
+      break;
+   case GL_NONE:
       sf.sf6.cull_mode = BRW_CULLMODE_NONE;
-      
+      break;
+   default:
+      assert(0);
+      break;
+   }
 
    /* _NEW_LINE */
    /* XXX use ctx->Const.Min/MaxLineWidth here */
-   sf.sf6.line_width = CLAMP(brw->attribs.Line->Width, 1.0, 5.0) * (1<<1);
+   sf.sf6.line_width = CLAMP(key->line_width, 1.0, 5.0) * (1<<1);
 
    sf.sf6.line_endcap_aa_region_width = 1;
-   if (brw->attribs.Line->SmoothFlag)
+   if (key->line_smooth)
       sf.sf6.aa_enable = 1;
-   else if (sf.sf6.line_width <= 0x2) 
-       sf.sf6.line_width = 0; 
+   else if (sf.sf6.line_width <= 0x2)
+       sf.sf6.line_width = 0;
 
    /* _NEW_POINT */
-   sf.sf6.point_rast_rule = 1; /* opengl conventions */
+   sf.sf6.point_rast_rule = BRW_RASTRULE_UPPER_RIGHT;  /* opengl conventions */
    /* XXX clamp max depends on AA vs. non-AA */
-   sf.sf7.point_size = CLAMP(brw->attribs.Point->Size, 1.0, 3.0) * (1<<3);
-   sf.sf7.use_point_size_state = !brw->attribs.Point->_Attenuated;
-      
+
+   sf.sf7.sprite_point = key->point_sprite;
+   sf.sf7.point_size = CLAMP(nearbyint(key->point_size), 1, 255) * (1<<3);
+   sf.sf7.use_point_size_state = !key->point_attenuated;
+   sf.sf7.aa_line_distance_mode = 0;
+
    /* might be BRW_NEW_PRIMITIVE if we have to adjust pv for polygons:
     */
    sf.sf7.trifan_pv = 2;
@@ -200,9 +244,48 @@ static void upload_sf_unit( struct brw_context *brw )
    sf.sf6.dest_org_vbias = 0x8;
    sf.sf6.dest_org_hbias = 0x8;
 
-   brw->sf.state_gs_offset = brw_cache_data( &brw->cache[BRW_SF_UNIT], &sf );
+   bo = brw_upload_cache(&brw->cache, BRW_SF_UNIT,
+                        key, sizeof(*key),
+                        reloc_bufs, 2,
+                        &sf, sizeof(sf),
+                        NULL, NULL);
+
+   /* Emit SF program relocation */
+   dri_bo_emit_reloc(bo,
+                    I915_GEM_DOMAIN_INSTRUCTION, 0,
+                    sf.thread0.grf_reg_count << 1,
+                    offsetof(struct brw_sf_unit_state, thread0),
+                    brw->sf.prog_bo);
+
+   /* Emit SF viewport relocation */
+   dri_bo_emit_reloc(bo,
+                    I915_GEM_DOMAIN_INSTRUCTION, 0,
+                    sf.sf5.front_winding | (sf.sf5.viewport_transform << 1),
+                    offsetof(struct brw_sf_unit_state, sf5),
+                    brw->sf.vp_bo);
+
+   return bo;
 }
 
+static void upload_sf_unit( struct brw_context *brw )
+{
+   struct brw_sf_unit_key key;
+   dri_bo *reloc_bufs[2];
+
+   sf_unit_populate_key(brw, &key);
+
+   reloc_bufs[0] = brw->sf.prog_bo;
+   reloc_bufs[1] = brw->sf.vp_bo;
+
+   dri_bo_unreference(brw->sf.state_bo);
+   brw->sf.state_bo = brw_search_cache(&brw->cache, BRW_SF_UNIT,
+                                      &key, sizeof(key),
+                                      reloc_bufs, 2,
+                                      NULL);
+   if (brw->sf.state_bo == NULL) {
+      brw->sf.state_bo = sf_unit_create_from_key(brw, &key, reloc_bufs);
+   }
+}
 
 const struct brw_tracked_state brw_sf_unit = {
    .dirty = {
@@ -215,7 +298,5 @@ const struct brw_tracked_state brw_sf_unit = {
       .cache = (CACHE_NEW_SF_VP |
                CACHE_NEW_SF_PROG)
    },
-   .update = upload_sf_unit
+   .prepare = upload_sf_unit,
 };
-
-
index b4cbdd7a380c13ef8c651c40545fed43b303546f..3ea6151ae9563a581c9b51612f7a7fe3b8d7a83a 100644 (file)
@@ -48,8 +48,8 @@ const struct brw_tracked_state brw_curbe_offsets;
 const struct brw_tracked_state brw_invarient_state;
 const struct brw_tracked_state brw_gs_prog;
 const struct brw_tracked_state brw_gs_unit;
-const struct brw_tracked_state brw_drawing_rect;
 const struct brw_tracked_state brw_line_stipple;
+const struct brw_tracked_state brw_aa_line_parameters;
 const struct brw_tracked_state brw_pipelined_state_pointers;
 const struct brw_tracked_state brw_binding_table_pointers;
 const struct brw_tracked_state brw_depthbuffer;
@@ -80,67 +80,58 @@ const struct brw_tracked_state brw_pipe_control;
 const struct brw_tracked_state brw_clear_surface_cache;
 const struct brw_tracked_state brw_clear_batch_cache;
 
+const struct brw_tracked_state brw_indices;
+const struct brw_tracked_state brw_vertices;
+
 /***********************************************************************
  * brw_state_cache.c
  */
-GLuint brw_cache_data(struct brw_cache *cache,
-                     const void *data );
-
-GLuint brw_cache_data_sz(struct brw_cache *cache,
-                        const void *data,
-                        GLuint data_sz);
-
-GLuint brw_upload_cache( struct brw_cache *cache,
-                        const void *key,
-                        GLuint key_sz,
-                        const void *data,
-                        GLuint data_sz,
-                        const void *aux,
-                        void *aux_return );
-
-GLboolean brw_search_cache( struct brw_cache *cache,
-                           const void *key,
-                           GLuint key_size,
-                           void *aux_return,
-                           GLuint *offset_return);
-
-void brw_init_caches( struct brw_context *brw );
-void brw_destroy_caches( struct brw_context *brw );
+dri_bo *brw_cache_data(struct brw_cache *cache,
+                      enum brw_cache_id cache_id,
+                      const void *data,
+                      dri_bo **reloc_bufs,
+                      GLuint nr_reloc_bufs);
+
+dri_bo *brw_cache_data_sz(struct brw_cache *cache,
+                         enum brw_cache_id cache_id,
+                         const void *data,
+                         GLuint data_size,
+                         dri_bo **reloc_bufs,
+                         GLuint nr_reloc_bufs);
+
+dri_bo *brw_upload_cache( struct brw_cache *cache,
+                         enum brw_cache_id cache_id,
+                         const void *key,
+                         GLuint key_sz,
+                         dri_bo **reloc_bufs,
+                         GLuint nr_reloc_bufs,
+                         const void *data,
+                         GLuint data_sz,
+                         const void *aux,
+                         void *aux_return );
+
+dri_bo *brw_search_cache( struct brw_cache *cache,
+                         enum brw_cache_id cache_id,
+                         const void *key,
+                         GLuint key_size,
+                         dri_bo **reloc_bufs,
+                         GLuint nr_reloc_bufs,
+                         void *aux_return);
+void brw_state_cache_check_size( struct brw_context *brw );
+
+void brw_init_cache( struct brw_context *brw );
+void brw_destroy_cache( struct brw_context *brw );
 
 /***********************************************************************
  * brw_state_batch.c
  */
-#define BRW_BATCH_STRUCT(brw, s) intel_batchbuffer_data( brw->intel.batch, (s), sizeof(*(s)), 0)
+#define BRW_BATCH_STRUCT(brw, s) intel_batchbuffer_data( brw->intel.batch, (s), sizeof(*(s)), IGNORE_CLIPRECTS)
 #define BRW_CACHED_BATCH_STRUCT(brw, s) brw_cached_batch_struct( brw, (s), sizeof(*(s)) )
 
 GLboolean brw_cached_batch_struct( struct brw_context *brw,
                                   const void *data,
                                   GLuint sz );
-
 void brw_destroy_batch_cache( struct brw_context *brw );
-
-
-/***********************************************************************
- * brw_state_pool.c
- */
-void brw_init_pools( struct brw_context *brw );
-void brw_destroy_pools( struct brw_context *brw );
-
-GLboolean brw_pool_alloc( struct brw_mem_pool *pool,
-                         GLuint size,
-                         GLuint alignment,
-                         GLuint *offset_return);
-
-void brw_pool_fence( struct brw_context *brw,
-                    struct brw_mem_pool *pool,
-                    GLuint fence );
-
-
-void brw_pool_check_wrap( struct brw_context *brw,
-                         struct brw_mem_pool *pool );
-
-void brw_clear_all_caches( struct brw_context *brw );
-void brw_invalidate_pools( struct brw_context *brw );
 void brw_clear_batch_cache_flush( struct brw_context *brw );
 
 #endif
index 909b0acd12199e5b79e85a4de26fd0feea52ed6b..77e2736d11115ca32889aa52958fbcc0029e3747 100644 (file)
@@ -32,7 +32,6 @@
 
 
 #include "brw_state.h"
-#include "brw_aub.h"
 #include "intel_batchbuffer.h"
 #include "imports.h"
 
@@ -49,7 +48,7 @@ GLboolean brw_cached_batch_struct( struct brw_context *brw,
    struct header *newheader = (struct header *)data;
 
    if (brw->emit_state_always) {
-      intel_batchbuffer_data(brw->intel.batch, data, sz, 0);
+      intel_batchbuffer_data(brw->intel.batch, data, sz, IGNORE_CLIPRECTS);
       return GL_TRUE;
    }
 
@@ -76,7 +75,7 @@ GLboolean brw_cached_batch_struct( struct brw_context *brw,
 
  emit:
    memcpy(item->header, newheader, sz);
-   intel_batchbuffer_data(brw->intel.batch, data, sz, 0);
+   intel_batchbuffer_data(brw->intel.batch, data, sz, IGNORE_CLIPRECTS);
    return GL_TRUE;
 }
 
@@ -92,13 +91,6 @@ static void clear_batch_cache( struct brw_context *brw )
    }
 
    brw->cached_batch_items = NULL;
-
-
-   brw_clear_all_caches(brw);
-
-   bmReleaseBuffers(&brw->intel);
-   
-   brw_invalidate_pools(brw);
 }
 
 void brw_clear_batch_cache_flush( struct brw_context *brw )
index 71c6938f9a3a445dbd3c30933164908e8837e6f2..fc0c3bd9ffdd964ff6f6f56cdabdcc0790174e16 100644 (file)
   * Authors:
   *   Keith Whitwell <keith@tungstengraphics.com>
   */
-      
+
+/** @file brw_state_cache.c
+ *
+ * This file implements a simple static state cache for 965.  The consumers
+ * can query the hash table of state using a cache_id, opaque key data,
+ * and list of buffers that will be used in relocations, and receive the
+ * corresponding state buffer object of state (plus associated auxiliary
+ * data) in return.
+ *
+ * The inner workings are a simple hash table based on a CRC of the key data.
+ * The cache_id and relocation target buffers associated with the state
+ * buffer are included as auxiliary key data, but are not part of the hash
+ * value (this should be fixed, but will likely be fixed instead by making
+ * consumers use structured keys).
+ *
+ * Replacement is not implemented.  Instead, when the cache gets too big, at
+ * a safe point (unlock) we throw out all of the cache data and let it
+ * regenerate for the next rendering operation.
+ *
+ * The reloc_buf pointers need to be included as key data, otherwise the
+ * non-unique values stuffed in the offset in key data through
+ * brw_cache_data() may result in successful probe for state buffers
+ * even when the buffer being referenced doesn't match.  The result would be
+ * that the same state cache entry is used twice for different buffers,
+ * only one of the two buffers referenced gets put into the offset, and the
+ * incorrect program is run for the other instance.
+ */
 
 #include "brw_state.h"
-#include "brw_aub.h"
 #include "intel_batchbuffer.h"
 #include "imports.h"
 
 #include "brw_sf.h"
 #include "brw_gs.h"
 
-
-/***********************************************************************
- * Check cache for uploaded version of struct, else upload new one.
- * Fail when memory is exhausted.
- *
- * XXX: FIXME: Currently search is so slow it would be quicker to
- * regenerate the data every time...
- */
-
-static GLuint hash_key( const void *key, GLuint key_size )
+static GLuint hash_key( const void *key, GLuint key_size,
+                       dri_bo **reloc_bufs, GLuint nr_reloc_bufs)
 {
    GLuint *ikey = (GLuint *)key;
    GLuint hash = 0, i;
@@ -62,23 +79,63 @@ static GLuint hash_key( const void *key, GLuint key_size )
 
    /* I'm sure this can be improved on:
     */
-   for (i = 0; i < key_size/4; i++)
+   for (i = 0; i < key_size/4; i++) {
       hash ^= ikey[i];
+      hash = (hash << 5) | (hash >> 27);
+   }
+
+   /* Include the BO pointers as key data as well */
+   ikey = (GLuint *)reloc_bufs;
+   key_size = nr_reloc_bufs * sizeof(dri_bo *);
+   for (i = 0; i < key_size/4; i++) {
+      hash ^= ikey[i];
+      hash = (hash << 5) | (hash >> 27);
+   }
 
    return hash;
 }
 
-static struct brw_cache_item *search_cache( struct brw_cache *cache,
-                                            GLuint hash,
-                                            const void *key,
-                                            GLuint key_size)
+/**
+ * Marks a new buffer as being chosen for the given cache id.
+ */
+static void
+update_cache_last(struct brw_cache *cache, enum brw_cache_id cache_id,
+                 dri_bo *bo)
+{
+   if (bo == cache->last_bo[cache_id])
+      return; /* no change */
+
+   dri_bo_unreference(cache->last_bo[cache_id]);
+   cache->last_bo[cache_id] = bo;
+   dri_bo_reference(cache->last_bo[cache_id]);
+   cache->brw->state.dirty.cache |= 1 << cache_id;
+}
+
+static struct brw_cache_item *
+search_cache(struct brw_cache *cache, enum brw_cache_id cache_id,
+            GLuint hash, const void *key, GLuint key_size,
+            dri_bo **reloc_bufs, GLuint nr_reloc_bufs)
 {
    struct brw_cache_item *c;
 
+#if 0
+   int bucketcount = 0;
+
+   for (c = cache->items[hash % cache->size]; c; c = c->next)
+      bucketcount++;
+
+   fprintf(stderr, "bucket %d/%d = %d/%d items\n", hash % cache->size,
+          cache->size, bucketcount, cache->n_items);
+#endif
+
    for (c = cache->items[hash % cache->size]; c; c = c->next) {
-      if (c->hash == hash && 
+      if (c->cache_id == cache_id &&
+         c->hash == hash &&
          c->key_size == key_size &&
-         memcmp(c->key, key, key_size) == 0)
+         memcmp(c->key, key, key_size) == 0 &&
+         c->nr_reloc_bufs == nr_reloc_bufs &&
+         memcmp(c->reloc_bufs, reloc_bufs,
+                nr_reloc_bufs * sizeof(dri_bo *)) == 0)
         return c;
    }
 
@@ -93,8 +150,7 @@ static void rehash( struct brw_cache *cache )
    GLuint size, i;
 
    size = cache->size * 3;
-   items = (struct brw_cache_item**) _mesa_malloc(size * sizeof(*items));
-   _mesa_memset(items, 0, size * sizeof(*items));
+   items = (struct brw_cache_item**) _mesa_calloc(size * sizeof(*items));
 
    for (i = 0; i < cache->size; i++)
       for (c = cache->items[i]; c; c = next) {
@@ -108,142 +164,180 @@ static void rehash( struct brw_cache *cache )
    cache->size = size;
 }
 
-
-GLboolean brw_search_cache( struct brw_cache *cache,
-                           const void *key,
-                           GLuint key_size,
-                           void *aux_return,
-                           GLuint *offset_return)
+/**
+ * Returns the buffer object matching cache_id and key, or NULL.
+ */
+dri_bo *brw_search_cache( struct brw_cache *cache,
+                         enum brw_cache_id cache_id,
+                         const void *key,
+                         GLuint key_size,
+                         dri_bo **reloc_bufs, GLuint nr_reloc_bufs,
+                         void *aux_return )
 {
    struct brw_cache_item *item;
-   GLuint addr = 0;
-   GLuint hash = hash_key(key, key_size);
+   GLuint hash = hash_key(key, key_size, reloc_bufs, nr_reloc_bufs);
 
-   item = search_cache(cache, hash, key, key_size);
+   item = search_cache(cache, cache_id, hash, key, key_size,
+                      reloc_bufs, nr_reloc_bufs);
 
-   if (item) {
-      if (aux_return) 
-        *(void **)aux_return = (void *)((char *)item->key + item->key_size);
-      
-      *offset_return = addr = item->offset;
-   }    
-    
-   if (item == NULL || addr != cache->last_addr) {
-      cache->brw->state.dirty.cache |= 1<<cache->id;
-      cache->last_addr = addr;
-   }
-   
-   return item != NULL;
+   if (item == NULL)
+      return NULL;
+
+   if (aux_return)
+      *(void **)aux_return = (void *)((char *)item->key + item->key_size);
+
+   update_cache_last(cache, cache_id, item->bo);
+
+   dri_bo_reference(item->bo);
+   return item->bo;
 }
 
-GLuint brw_upload_cache( struct brw_cache *cache,
-                        const void *key,
-                        GLuint key_size,
-                        const void *data,
-                        GLuint data_size,
-                        const void *aux,
-                        void *aux_return )
-{   
-   GLuint offset;
+dri_bo *
+brw_upload_cache( struct brw_cache *cache,
+                 enum brw_cache_id cache_id,
+                 const void *key,
+                 GLuint key_size,
+                 dri_bo **reloc_bufs,
+                 GLuint nr_reloc_bufs,
+                 const void *data,
+                 GLuint data_size,
+                 const void *aux,
+                 void *aux_return )
+{
    struct brw_cache_item *item = CALLOC_STRUCT(brw_cache_item);
-   GLuint hash = hash_key(key, key_size);
-   void *tmp = _mesa_malloc(key_size + cache->aux_size);
-   
-   if (!brw_pool_alloc(cache->pool, data_size, 6, &offset)) {
-      /* Should not be possible: 
-       */
-      _mesa_printf("brw_pool_alloc failed\n");
-      exit(1);
-   }
+   GLuint hash = hash_key(key, key_size, reloc_bufs, nr_reloc_bufs);
+   GLuint relocs_size = nr_reloc_bufs * sizeof(dri_bo *);
+   GLuint aux_size = cache->aux_size[cache_id];
+   void *tmp;
+   dri_bo *bo;
+   int i;
+
+   /* Create the buffer object to contain the data */
+   bo = dri_bo_alloc(cache->brw->intel.bufmgr,
+                    cache->name[cache_id], data_size, 1 << 6);
+
+
+   /* Set up the memory containing the key, aux_data, and reloc_bufs */
+   tmp = _mesa_malloc(key_size + aux_size + relocs_size);
 
    memcpy(tmp, key, key_size);
+   memcpy(tmp + key_size, aux, cache->aux_size[cache_id]);
+   memcpy(tmp + key_size + aux_size, reloc_bufs, relocs_size);
+   for (i = 0; i < nr_reloc_bufs; i++) {
+      if (reloc_bufs[i] != NULL)
+        dri_bo_reference(reloc_bufs[i]);
+   }
 
-   if (cache->aux_size)
-      memcpy(tmp+key_size, aux, cache->aux_size);
-        
+   item->cache_id = cache_id;
    item->key = tmp;
    item->hash = hash;
    item->key_size = key_size;
-   item->offset = offset;
+   item->reloc_bufs = tmp + key_size + aux_size;
+   item->nr_reloc_bufs = nr_reloc_bufs;
+
+   item->bo = bo;
+   dri_bo_reference(bo);
    item->data_size = data_size;
 
-   if (++cache->n_items > cache->size * 1.5)
+   if (cache->n_items > cache->size * 1.5)
       rehash(cache);
-   
+
    hash %= cache->size;
    item->next = cache->items[hash];
    cache->items[hash] = item;
-      
+   cache->n_items++;
+
    if (aux_return) {
-      assert(cache->aux_size);
+      assert(cache->aux_size[cache_id]);
       *(void **)aux_return = (void *)((char *)item->key + item->key_size);
    }
 
    if (INTEL_DEBUG & DEBUG_STATE)
-      _mesa_printf("upload %s: %d bytes to pool buffer %d offset %x\n",
-                  cache->name,
-                  data_size, 
-                  cache->pool->buffer,
-                  offset);
+      _mesa_printf("upload %s: %d bytes to cache id %d\n",
+                  cache->name[cache_id],
+                  data_size, cache_id);
 
-   /* Copy data to the buffer:
-    */
-   bmBufferSubDataAUB(&cache->brw->intel,
-                     cache->pool->buffer,
-                     offset, 
-                     data_size, 
-                     data,
-                     cache->aub_type,
-                     cache->aub_sub_type);
-   
-
-   cache->brw->state.dirty.cache |= 1<<cache->id;
-   cache->last_addr = offset;
-
-   return offset;
+   /* Copy data to the buffer */
+   dri_bo_subdata(bo, 0, data_size, data);
+
+   update_cache_last(cache, cache_id, bo);
+
+   return bo;
 }
 
 /* This doesn't really work with aux data.  Use search/upload instead
  */
-GLuint brw_cache_data_sz(struct brw_cache *cache,
-                        const void *data,
-                        GLuint data_size)
+dri_bo *
+brw_cache_data_sz(struct brw_cache *cache,
+                 enum brw_cache_id cache_id,
+                 const void *data,
+                 GLuint data_size,
+                 dri_bo **reloc_bufs,
+                 GLuint nr_reloc_bufs)
 {
-   GLuint addr;
+   dri_bo *bo;
+   struct brw_cache_item *item;
+   GLuint hash = hash_key(data, data_size, reloc_bufs, nr_reloc_bufs);
 
-   if (!brw_search_cache(cache, data, data_size, NULL, &addr)) {
-      addr = brw_upload_cache(cache, 
-                             data, data_size, 
-                             data, data_size, 
-                             NULL, NULL);
+   item = search_cache(cache, cache_id, hash, data, data_size,
+                      reloc_bufs, nr_reloc_bufs);
+   if (item) {
+      update_cache_last(cache, cache_id, item->bo);
+      dri_bo_reference(item->bo);
+      return item->bo;
    }
 
-   return addr;
+   bo = brw_upload_cache(cache, cache_id,
+                        data, data_size,
+                        reloc_bufs, nr_reloc_bufs,
+                        data, data_size,
+                        NULL, NULL);
+
+   return bo;
 }
 
-GLuint brw_cache_data(struct brw_cache *cache,
-                     const void *data)
+/**
+ * Wrapper around brw_cache_data_sz using the cache_id's canonical key size.
+ *
+ * If nr_reloc_bufs is nonzero, brw_search_cache()/brw_upload_cache() would be
+ * better to use, as the potentially changing offsets in the data-used-as-key
+ * will result in excessive cache misses.
+ */
+dri_bo *
+brw_cache_data(struct brw_cache *cache,
+              enum brw_cache_id cache_id,
+              const void *data,
+              dri_bo **reloc_bufs,
+              GLuint nr_reloc_bufs)
 {
-   return brw_cache_data_sz(cache, data, cache->key_size);
+   return brw_cache_data_sz(cache, cache_id, data, cache->key_size[cache_id],
+                           reloc_bufs, nr_reloc_bufs);
 }
 
+enum pool_type {
+   DW_SURFACE_STATE,
+   DW_GENERAL_STATE
+};
+
+static void
+brw_init_cache_id( struct brw_context *brw,
+               const char *name,
+               enum brw_cache_id id,
+               GLuint key_size,
+               GLuint aux_size)
+{
+   struct brw_cache *cache = &brw->cache;
 
+   cache->name[id] = strdup(name);
+   cache->key_size[id] = key_size;
+   cache->aux_size[id] = aux_size;
+}
 
-
-
-static void brw_init_cache( struct brw_context *brw, 
-                           const char *name,
-                           GLuint id,
-                           GLuint key_size,
-                           GLuint aux_size,
-                           GLuint aub_type,
-                           GLuint aub_sub_type )
+void brw_init_cache( struct brw_context *brw )
 {
-   struct brw_cache *cache = &brw->cache[id];
+   struct brw_cache *cache = &brw->cache;
+
    cache->brw = brw;
-   cache->id = id;
-   cache->name = name;
-   cache->items = NULL;
 
    cache->size = 7;
    cache->n_items = 0;
@@ -251,200 +345,133 @@ static void brw_init_cache( struct brw_context *brw,
       _mesa_calloc(cache->size * 
                   sizeof(struct brw_cache_item));
 
-
-   cache->key_size = key_size;
-   cache->aux_size = aux_size;
-   cache->aub_type = aub_type;
-   cache->aub_sub_type = aub_sub_type;
-   switch (aub_type) {
-   case DW_GENERAL_STATE: cache->pool = &brw->pool[BRW_GS_POOL]; break;
-   case DW_SURFACE_STATE: cache->pool = &brw->pool[BRW_SS_POOL]; break;
-   default: assert(0); break;
-   }
-}
-
-void brw_init_caches( struct brw_context *brw )
-{
-
-   brw_init_cache(brw,
-                 "CC_VP",
-                 BRW_CC_VP,
-                 sizeof(struct brw_cc_viewport),
-                 0,
-                 DW_GENERAL_STATE,
-                 DWGS_COLOR_CALC_VIEWPORT_STATE);
-
-   brw_init_cache(brw,
-                 "CC_UNIT",
-                 BRW_CC_UNIT,
-                 sizeof(struct brw_cc_unit_state),
-                 0,
-                 DW_GENERAL_STATE,
-                 DWGS_COLOR_CALC_STATE);
-
-   brw_init_cache(brw,
-                 "WM_PROG",
-                 BRW_WM_PROG,
-                 sizeof(struct brw_wm_prog_key),
-                 sizeof(struct brw_wm_prog_data),
-                 DW_GENERAL_STATE,
-                 DWGS_KERNEL_INSTRUCTIONS);
-
-   brw_init_cache(brw,
-                 "SAMPLER_DEFAULT_COLOR",
-                 BRW_SAMPLER_DEFAULT_COLOR,
-                 sizeof(struct brw_sampler_default_color),
-                 0,
-                 DW_GENERAL_STATE,
-                 DWGS_SAMPLER_DEFAULT_COLOR);
-
-   brw_init_cache(brw,
-                 "SAMPLER",
-                 BRW_SAMPLER,
-                 0,            /* variable key/data size */
-                 0,
-                 DW_GENERAL_STATE,
-                 DWGS_SAMPLER_STATE);
-
-   brw_init_cache(brw,
-                 "WM_UNIT",
-                 BRW_WM_UNIT,
-                 sizeof(struct brw_wm_unit_state),
-                 0,
-                 DW_GENERAL_STATE,
-                 DWGS_WINDOWER_IZ_STATE);
-
-   brw_init_cache(brw,
-                 "SF_PROG",
-                 BRW_SF_PROG,
-                 sizeof(struct brw_sf_prog_key),
-                 sizeof(struct brw_sf_prog_data),
-                 DW_GENERAL_STATE,
-                 DWGS_KERNEL_INSTRUCTIONS);
-
-   brw_init_cache(brw,
-                 "SF_VP",
-                 BRW_SF_VP,
-                 sizeof(struct brw_sf_viewport),
-                 0,
-                 DW_GENERAL_STATE,
-                 DWGS_STRIPS_FANS_VIEWPORT_STATE);
-
-   brw_init_cache(brw,
-                 "SF_UNIT",
-                 BRW_SF_UNIT,
-                 sizeof(struct brw_sf_unit_state),
-                 0,
-                 DW_GENERAL_STATE,
-                 DWGS_STRIPS_FANS_STATE);
-
-   brw_init_cache(brw,
-                 "VS_UNIT",
-                 BRW_VS_UNIT,
-                 sizeof(struct brw_vs_unit_state),
-                 0,
-                 DW_GENERAL_STATE,
-                 DWGS_VERTEX_SHADER_STATE);
-
-   brw_init_cache(brw,
-                 "VS_PROG",
-                 BRW_VS_PROG,
-                 sizeof(struct brw_vs_prog_key),
-                 sizeof(struct brw_vs_prog_data),
-                 DW_GENERAL_STATE,
-                 DWGS_KERNEL_INSTRUCTIONS);
-
-   brw_init_cache(brw,
-                 "CLIP_UNIT",
-                 BRW_CLIP_UNIT,
-                 sizeof(struct brw_clip_unit_state),
-                 0,
-                 DW_GENERAL_STATE,
-                 DWGS_CLIPPER_STATE);
-
-   brw_init_cache(brw,
-                 "CLIP_PROG",
-                 BRW_CLIP_PROG,
-                 sizeof(struct brw_clip_prog_key),
-                 sizeof(struct brw_clip_prog_data),
-                 DW_GENERAL_STATE,
-                 DWGS_KERNEL_INSTRUCTIONS);
-
-   brw_init_cache(brw,
-                 "GS_UNIT",
-                 BRW_GS_UNIT,
-                 sizeof(struct brw_gs_unit_state),
-                 0,
-                 DW_GENERAL_STATE,
-                 DWGS_GEOMETRY_SHADER_STATE);
-
-   brw_init_cache(brw,
-                 "GS_PROG",
-                 BRW_GS_PROG,
-                 sizeof(struct brw_gs_prog_key),
-                 sizeof(struct brw_gs_prog_data),
-                 DW_GENERAL_STATE,
-                 DWGS_KERNEL_INSTRUCTIONS);
-
-   brw_init_cache(brw,
-                 "SS_SURFACE",
-                 BRW_SS_SURFACE,
-                 sizeof(struct brw_surface_state),
-                 0,
-                 DW_SURFACE_STATE,
-                 DWSS_SURFACE_STATE);
-
-   brw_init_cache(brw,
-                 "SS_SURF_BIND",
-                 BRW_SS_SURF_BIND,
-                 sizeof(struct brw_surface_binding_table),
-                 0,
-                 DW_SURFACE_STATE,
-                 DWSS_BINDING_TABLE_STATE);
+   brw_init_cache_id(brw,
+                    "CC_VP",
+                    BRW_CC_VP,
+                    sizeof(struct brw_cc_viewport),
+                    0);
+
+   brw_init_cache_id(brw,
+                    "CC_UNIT",
+                    BRW_CC_UNIT,
+                    sizeof(struct brw_cc_unit_state),
+                    0);
+
+   brw_init_cache_id(brw,
+                    "WM_PROG",
+                    BRW_WM_PROG,
+                    sizeof(struct brw_wm_prog_key),
+                    sizeof(struct brw_wm_prog_data));
+
+   brw_init_cache_id(brw,
+                    "SAMPLER_DEFAULT_COLOR",
+                    BRW_SAMPLER_DEFAULT_COLOR,
+                    sizeof(struct brw_sampler_default_color),
+                    0);
+
+   brw_init_cache_id(brw,
+                    "SAMPLER",
+                    BRW_SAMPLER,
+                    0,         /* variable key/data size */
+                    0);
+
+   brw_init_cache_id(brw,
+                    "WM_UNIT",
+                    BRW_WM_UNIT,
+                    sizeof(struct brw_wm_unit_state),
+                    0);
+
+   brw_init_cache_id(brw,
+                    "SF_PROG",
+                    BRW_SF_PROG,
+                    sizeof(struct brw_sf_prog_key),
+                    sizeof(struct brw_sf_prog_data));
+
+   brw_init_cache_id(brw,
+                    "SF_VP",
+                    BRW_SF_VP,
+                    sizeof(struct brw_sf_viewport),
+                    0);
+
+   brw_init_cache_id(brw,
+                    "SF_UNIT",
+                    BRW_SF_UNIT,
+                    sizeof(struct brw_sf_unit_state),
+                    0);
+
+   brw_init_cache_id(brw,
+                    "VS_UNIT",
+                    BRW_VS_UNIT,
+                    sizeof(struct brw_vs_unit_state),
+                    0);
+
+   brw_init_cache_id(brw,
+                    "VS_PROG",
+                    BRW_VS_PROG,
+                    sizeof(struct brw_vs_prog_key),
+                    sizeof(struct brw_vs_prog_data));
+
+   brw_init_cache_id(brw,
+                    "CLIP_UNIT",
+                    BRW_CLIP_UNIT,
+                    sizeof(struct brw_clip_unit_state),
+                    0);
+
+   brw_init_cache_id(brw,
+                    "CLIP_PROG",
+                    BRW_CLIP_PROG,
+                    sizeof(struct brw_clip_prog_key),
+                    sizeof(struct brw_clip_prog_data));
+
+   brw_init_cache_id(brw,
+                    "GS_UNIT",
+                    BRW_GS_UNIT,
+                    sizeof(struct brw_gs_unit_state),
+                    0);
+
+   brw_init_cache_id(brw,
+                    "GS_PROG",
+                    BRW_GS_PROG,
+                    sizeof(struct brw_gs_prog_key),
+                    sizeof(struct brw_gs_prog_data));
+
+   brw_init_cache_id(brw,
+                    "SS_SURFACE",
+                    BRW_SS_SURFACE,
+                    sizeof(struct brw_surface_state),
+                    0);
+
+   brw_init_cache_id(brw,
+                    "SS_SURF_BIND",
+                    BRW_SS_SURF_BIND,
+                    0,
+                    0);
 }
 
-
-/* When we lose hardware context, need to invalidate the surface cache
- * as these structs must be explicitly re-uploaded.  They are subject
- * to fixup by the memory manager as they contain absolute agp
- * offsets, so we need to ensure there is a fresh version of the
- * struct available to receive the fixup.
- *
- * XXX: Need to ensure that there aren't two versions of a surface or
- * bufferobj with different backing data active in the same buffer at
- * once?  Otherwise the cache could confuse them.  Maybe better not to
- * cache at all?
- * 
- * --> Isn't this the same as saying need to ensure batch is flushed
- *         before new data is uploaded to an existing buffer?  We
- *         already try to make sure of that.
- */
-static void clear_cache( struct brw_cache *cache )
+static void
+brw_clear_cache( struct brw_context *brw )
 {
    struct brw_cache_item *c, *next;
    GLuint i;
 
-   for (i = 0; i < cache->size; i++) {
-      for (c = cache->items[i]; c; c = next) {
+   if (INTEL_DEBUG & DEBUG_STATE)
+      _mesa_printf("%s\n", __FUNCTION__);
+
+   for (i = 0; i < brw->cache.size; i++) {
+      for (c = brw->cache.items[i]; c; c = next) {
+        int j;
+
         next = c->next;
+        for (j = 0; j < c->nr_reloc_bufs; j++)
+           dri_bo_unreference(c->reloc_bufs[j]);
+        dri_bo_unreference(c->bo);
         free((void *)c->key);
         free(c);
       }
-      cache->items[i] = NULL;
+      brw->cache.items[i] = NULL;
    }
 
-   cache->n_items = 0;
-}
-
-void brw_clear_all_caches( struct brw_context *brw )
-{
-   GLint i;
-
-   if (INTEL_DEBUG & DEBUG_STATE)
-      _mesa_printf("%s\n", __FUNCTION__);
-
-   for (i = 0; i < BRW_MAX_CACHE; i++)
-      clear_cache(&brw->cache[i]);      
+   brw->cache.n_items = 0;
 
    if (brw->curbe.last_buf) {
       _mesa_free(brw->curbe.last_buf);
@@ -456,14 +483,24 @@ void brw_clear_all_caches( struct brw_context *brw )
    brw->state.dirty.cache |= ~0;
 }
 
+void brw_state_cache_check_size( struct brw_context *brw )
+{
+   /* un-tuned guess.  We've got around 20 state objects for a total of around
+    * 32k, so 1000 of them is around 1.5MB.
+    */
+   if (brw->cache.n_items > 1000)
+      brw_clear_cache(brw);
+}
 
-
-
-
-void brw_destroy_caches( struct brw_context *brw )
+void brw_destroy_cache( struct brw_context *brw )
 {
    GLuint i;
 
+   brw_clear_cache(brw);
    for (i = 0; i < BRW_MAX_CACHE; i++)
-      clear_cache(&brw->cache[i]);      
+      free(brw->cache.name[i]);
+
+   free(brw->cache.items);
+   brw->cache.items = NULL;
+   brw->cache.size = 0;
 }
diff --git a/src/mesa/drivers/dri/i965/brw_state_dump.c b/src/mesa/drivers/dri/i965/brw_state_dump.c
new file mode 100644 (file)
index 0000000..3a93f9f
--- /dev/null
@@ -0,0 +1,200 @@
+/*
+ * Copyright Â© 2007 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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:
+ *    Eric Anholt <eric@anholt.net>
+ *
+ */
+
+#include "mtypes.h"
+
+#include "brw_context.h"
+#include "brw_state.h"
+#include "brw_defines.h"
+
+/**
+ * Prints out a header, the contents, and the message associated with
+ * the hardware state data given.
+ *
+ * \param name Name of the state object
+ * \param data Pointer to the base of the state object
+ * \param hw_offset Hardware offset of the base of the state data.
+ * \param index Index of the DWORD being output.
+ */
+static void
+state_out(const char *name, void *data, uint32_t hw_offset, int index,
+         char *fmt, ...)
+{
+    va_list va;
+
+    fprintf(stderr, "%8s: 0x%08x: 0x%08x: ",
+           name, hw_offset + index * 4, ((uint32_t *)data)[index]);
+    va_start(va, fmt);
+    vfprintf(stderr, fmt, va);
+    va_end(va);
+}
+
+/** Generic, undecoded state buffer debug printout */
+static void
+state_struct_out(const char *name, dri_bo *buffer, unsigned int state_size)
+{
+   int i;
+
+   if (buffer == NULL)
+      return;
+
+   dri_bo_map(buffer, GL_FALSE);
+   for (i = 0; i < state_size / 4; i++) {
+      state_out(name, buffer->virtual, buffer->offset, i,
+               "dword %d\n", i);
+   }
+   dri_bo_unmap(buffer);
+}
+
+static const char *
+get_965_surfacetype(unsigned int surfacetype)
+{
+    switch (surfacetype) {
+    case 0: return "1D";
+    case 1: return "2D";
+    case 2: return "3D";
+    case 3: return "CUBE";
+    case 4: return "BUFFER";
+    case 7: return "NULL";
+    default: return "unknown";
+    }
+}
+
+static void dump_wm_surface_state(struct brw_context *brw)
+{
+   int i;
+
+   for (i = 0; i < brw->wm.nr_surfaces; i++) {
+      dri_bo *surf_bo = brw->wm.surf_bo[i];
+      unsigned int surfoff;
+      struct brw_surface_state *surf;
+      char name[20];
+
+      if (surf_bo == NULL) {
+        fprintf(stderr, "WM SS%d: NULL\n", i);
+        continue;
+      }
+      dri_bo_map(surf_bo, GL_FALSE);
+      surfoff = surf_bo->offset;
+      surf = (struct brw_surface_state *)(surf_bo->virtual);
+
+      sprintf(name, "WM SS%d", i);
+      state_out(name, surf, surfoff, 0, "%s\n",
+               get_965_surfacetype(surf->ss0.surface_type));
+      state_out(name, surf, surfoff, 1, "offset\n");
+      state_out(name, surf, surfoff, 2, "%dx%d size, %d mips\n",
+               surf->ss2.width + 1, surf->ss2.height + 1, surf->ss2.mip_count);
+      state_out(name, surf, surfoff, 3, "pitch %d, %stiled\n",
+               surf->ss3.pitch + 1, surf->ss3.tiled_surface ? "" : "not ");
+      state_out(name, surf, surfoff, 4, "mip base %d\n",
+               surf->ss4.min_lod);
+
+      dri_bo_unmap(surf_bo);
+   }
+}
+
+static void dump_sf_viewport_state(struct brw_context *brw)
+{
+   const char *name = "SF VP";
+   struct brw_sf_viewport *vp;
+   uint32_t vp_off;
+
+   if (brw->sf.vp_bo == NULL)
+      return;
+
+   dri_bo_map(brw->sf.vp_bo, GL_FALSE);
+
+   vp = brw->sf.vp_bo->virtual;
+   vp_off = brw->sf.vp_bo->offset;
+
+   state_out(name, vp, vp_off, 0, "m00 = %f\n", vp->viewport.m00);
+   state_out(name, vp, vp_off, 1, "m11 = %f\n", vp->viewport.m11);
+   state_out(name, vp, vp_off, 2, "m22 = %f\n", vp->viewport.m22);
+   state_out(name, vp, vp_off, 3, "m30 = %f\n", vp->viewport.m30);
+   state_out(name, vp, vp_off, 4, "m31 = %f\n", vp->viewport.m31);
+   state_out(name, vp, vp_off, 5, "m32 = %f\n", vp->viewport.m32);
+
+   state_out(name, vp, vp_off, 6, "top left = %d,%d\n",
+            vp->scissor.xmin, vp->scissor.ymin);
+   state_out(name, vp, vp_off, 7, "bottom right = %d,%d\n",
+            vp->scissor.xmax, vp->scissor.ymax);
+
+   dri_bo_unmap(brw->sf.vp_bo);
+}
+
+static void brw_debug_prog(const char *name, dri_bo *prog)
+{
+   unsigned int i;
+   uint32_t *data;
+
+   if (prog == NULL)
+      return;
+
+   dri_bo_map(prog, GL_FALSE);
+
+   data = prog->virtual;
+
+   for (i = 0; i < prog->size / 4 / 4; i++) {
+      fprintf(stderr, "%8s: 0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
+             name, (unsigned int)prog->offset + i * 4 * 4,
+             data[i * 4], data[i * 4 + 1], data[i * 4 + 2], data[i * 4 + 3]);
+   }
+
+   dri_bo_unmap(prog);
+}
+
+
+/**
+ * Print additional debug information associated with the batchbuffer
+ * when DEBUG_BATCH is set.
+ *
+ * For 965, this means mapping the state buffers that would have been referenced
+ * by the batchbuffer and dumping them.
+ *
+ * The buffer offsets printed rely on the buffer containing the last offset
+ * it was validated at.
+ */
+void brw_debug_batch(struct intel_context *intel)
+{
+   struct brw_context *brw = brw_context(&intel->ctx);
+
+   state_struct_out("WM bind", brw->wm.bind_bo, 4 * brw->wm.nr_surfaces);
+   dump_wm_surface_state(brw);
+
+   state_struct_out("VS", brw->vs.state_bo, sizeof(struct brw_vs_unit_state));
+   brw_debug_prog("VS prog", brw->vs.prog_bo);
+
+   state_struct_out("GS", brw->gs.state_bo, sizeof(struct brw_gs_unit_state));
+   brw_debug_prog("GS prog", brw->gs.prog_bo);
+
+   state_struct_out("SF", brw->sf.state_bo, sizeof(struct brw_sf_unit_state));
+   dump_sf_viewport_state(brw);
+   brw_debug_prog("SF prog", brw->sf.prog_bo);
+
+   state_struct_out("WM", brw->wm.state_bo, sizeof(struct brw_wm_unit_state));
+   brw_debug_prog("WM prog", brw->wm.prog_bo);
+}
diff --git a/src/mesa/drivers/dri/i965/brw_state_pool.c b/src/mesa/drivers/dri/i965/brw_state_pool.c
deleted file mode 100644 (file)
index b9926f2..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- Copyright (C) Intel Corp.  2006.  All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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 "brw_state.h"
-#include "imports.h"
-
-#include "intel_ioctl.h"
-#include "bufmgr.h"
-
-GLboolean brw_pool_alloc( struct brw_mem_pool *pool,
-                         GLuint size,
-                         GLuint align,
-                         GLuint *offset_return)
-{
-   GLuint align_mask = (1<<align)-1;
-   GLuint fixup = ((pool->offset + align_mask) & ~align_mask) - pool->offset;
-
-   size = (size + 3) & ~3;
-
-   if (pool->offset + fixup + size >= pool->size) {
-      _mesa_printf("%s failed\n", __FUNCTION__);
-      assert(0);
-      exit(0);
-   }
-
-   pool->offset += fixup;
-   *offset_return = pool->offset;
-   pool->offset += size; 
-  
-   return GL_TRUE;
-}
-
-static
-void brw_invalidate_pool( struct intel_context *intel,
-                         struct brw_mem_pool *pool )
-{
-   if (INTEL_DEBUG & DEBUG_STATE)
-      _mesa_printf("\n\n\n %s \n\n\n", __FUNCTION__);
-   
-   bmBufferData(intel,
-               pool->buffer,
-               pool->size,
-               NULL,
-               0); 
-
-   pool->offset = 0;
-
-   brw_clear_all_caches(pool->brw);
-}
-
-static void brw_invalidate_pool_cb( struct intel_context *intel, void *ptr )
-{
-   struct brw_mem_pool *pool = (struct brw_mem_pool *) ptr;
-
-   pool->offset = 0;
-   brw_clear_all_caches(pool->brw);
-}
-
-
-
-static void brw_init_pool( struct brw_context *brw,
-                          GLuint pool_id,
-                          GLuint size )
-{
-   struct brw_mem_pool *pool = &brw->pool[pool_id];
-
-   pool->size = size;   
-   pool->brw = brw;
-   
-   bmGenBuffers(&brw->intel, "pool", 1, &pool->buffer, 12);
-
-   /* Also want to say not to wait on fences when data is presented
-    */
-   bmBufferSetInvalidateCB(&brw->intel, pool->buffer, 
-                          brw_invalidate_pool_cb, 
-                          pool,
-                          GL_TRUE);   
-
-   bmBufferData(&brw->intel,
-               pool->buffer,
-               pool->size,
-               NULL,
-               0); 
-
-}
-
-static void brw_destroy_pool( struct brw_context *brw,
-                             GLuint pool_id )
-{
-   struct brw_mem_pool *pool = &brw->pool[pool_id];
-   
-   bmDeleteBuffers(&brw->intel, 1, &pool->buffer);
-}
-
-
-void brw_pool_check_wrap( struct brw_context *brw,
-                         struct brw_mem_pool *pool )
-{
-   if (pool->offset > (pool->size * 3) / 4) {
-      if (brw->intel.aub_file)
-        brw->intel.aub_wrap = 1;
-      else
-        brw->state.dirty.brw |= BRW_NEW_CONTEXT;
-   }
-
-}
-
-void brw_init_pools( struct brw_context *brw )
-{
-   brw_init_pool(brw, BRW_GS_POOL, 0x80000);
-   brw_init_pool(brw, BRW_SS_POOL, 0x80000);
-}
-
-void brw_destroy_pools( struct brw_context *brw )
-{
-   brw_destroy_pool(brw, BRW_GS_POOL);
-   brw_destroy_pool(brw, BRW_SS_POOL);
-}
-
-
-void brw_invalidate_pools( struct brw_context *brw )
-{
-   brw_invalidate_pool(&brw->intel, &brw->pool[BRW_GS_POOL]);
-   brw_invalidate_pool(&brw->intel, &brw->pool[BRW_SS_POOL]);
-}
index 92c07c29624e9bbda05ae1805e5975bf36118785..7d4fd467b1cb320bf1dc8aeb6cf019c9492219ba 100644 (file)
@@ -33,7 +33,6 @@
 
 #include "brw_context.h"
 #include "brw_state.h"
-#include "bufmgr.h"
 #include "intel_batchbuffer.h"
 
 /* This is used to initialize brw->state.atoms[].  We could use this
@@ -80,19 +79,17 @@ const struct brw_tracked_state *atoms[] =
     */
    &brw_invarient_state,
    &brw_state_base_address,
-   &brw_pipe_control,
 
    &brw_binding_table_pointers,
    &brw_blend_constant_color,
 
-   &brw_drawing_rect,
    &brw_depthbuffer,
 
    &brw_polygon_stipple,
    &brw_polygon_stipple_offset,
 
    &brw_line_stipple,
-
+   &brw_aa_line_parameters,
    /* Ordering of the commands below is documented as fixed.  
     */
 #if 0
@@ -103,6 +100,8 @@ const struct brw_tracked_state *atoms[] =
    &brw_psp_urb_cbs,
 #endif
 
+   &brw_indices,
+   &brw_vertices,
 
    NULL,                       /* brw_constant_buffer */
 };
@@ -112,8 +111,7 @@ void brw_init_state( struct brw_context *brw )
 {
    GLuint i;
 
-   brw_init_pools(brw);
-   brw_init_caches(brw);
+   brw_init_cache(brw);
 
    brw->state.atoms = _mesa_malloc(sizeof(atoms));
    brw->state.nr_atoms = sizeof(atoms)/sizeof(*atoms);
@@ -138,9 +136,8 @@ void brw_destroy_state( struct brw_context *brw )
       brw->state.atoms = NULL;
    }
 
-   brw_destroy_caches(brw);
+   brw_destroy_cache(brw);
    brw_destroy_batch_cache(brw);
-   brw_destroy_pools(brw);   
 }
 
 /***********************************************************************
@@ -178,8 +175,10 @@ static void xor_states( struct brw_state_flags *result,
  */
 void brw_validate_state( struct brw_context *brw )
 {
+   struct intel_context *intel = &brw->intel;
    struct brw_state_flags *state = &brw->state.dirty;
-   GLuint i;
+   GLuint i, count, pass = 0;
+   dri_bo *last_batch_bo = NULL;
 
    state->mesa |= brw->intel.NewGLState;
    brw->intel.NewGLState = 0;
@@ -210,13 +209,36 @@ void brw_validate_state( struct brw_context *brw )
    if (brw->state.dirty.brw & BRW_NEW_CONTEXT)
       brw_clear_batch_cache_flush(brw);
 
+   brw->intel.Fallback = 0;
+
+   count = 0;
+
+   /* do prepare stage for all atoms */
+   for (i = 0; i < Elements(atoms); i++) {
+      const struct brw_tracked_state *atom = brw->state.atoms[i];
+
+      if (brw->intel.Fallback)
+         break;
 
-   /* Make an early reference to the state pools, as we don't cope
-    * well with them being evicted from here down.
+      if (check_state(state, &atom->dirty)) {
+         if (atom->prepare) {
+            atom->prepare(brw);
+        }
+      }
+   }
+
+   if (brw->intel.Fallback)
+      return;
+
+   /* We're about to try to set up a coherent state in the batchbuffer for
+    * the emission of primitives.  If we exceed the aperture size in any of the
+    * emit() calls, we need to go back to square 1 and try setting up again.
     */
-   (void)bmBufferOffset(&brw->intel, brw->pool[BRW_GS_POOL].buffer);
-   (void)bmBufferOffset(&brw->intel, brw->pool[BRW_SS_POOL].buffer);
-   (void)bmBufferOffset(&brw->intel, brw->intel.batch->buffer);
+got_flushed:
+   dri_bo_unreference(last_batch_bo);
+   last_batch_bo = intel->batch->buf;
+   dri_bo_reference(last_batch_bo);
+   assert(pass++ <= 2);
 
    if (INTEL_DEBUG) {
       /* Debug version which enforces various sanity checks on the
@@ -234,12 +256,16 @@ void brw_validate_state( struct brw_context *brw )
         assert(atom->dirty.mesa ||
                atom->dirty.brw ||
                atom->dirty.cache);
-        assert(atom->update);
+
+        if (brw->intel.Fallback)
+           break;
 
         if (check_state(state, &atom->dirty)) {
-           brw->state.atoms[i]->update( brw );
-           
-/*         emit_foo(brw); */
+           if (atom->emit) {
+              atom->emit( brw );
+              if (intel->batch->buf != last_batch_bo)
+                 goto got_flushed;
+           }
         }
 
         accumulate_state(&examined, &atom->dirty);
@@ -255,10 +281,23 @@ void brw_validate_state( struct brw_context *brw )
    }
    else {
       for (i = 0; i < Elements(atoms); i++) {   
-        if (check_state(state, &brw->state.atoms[i]->dirty))
-           brw->state.atoms[i]->update( brw );
+        const struct brw_tracked_state *atom = brw->state.atoms[i];
+
+        if (brw->intel.Fallback)
+           break;
+
+        if (check_state(state, &atom->dirty)) {
+           if (atom->emit) {
+              atom->emit( brw );
+              if (intel->batch->buf != last_batch_bo)
+                 goto got_flushed;
+           }
+        }
       }
    }
 
-   memset(state, 0, sizeof(*state));
+   dri_bo_unreference(last_batch_bo);
+
+   if (!brw->intel.Fallback)
+      memset(state, 0, sizeof(*state));
 }
index 10fee944e8d519b1ee1b52a2f9fde435aa7bbd4b..ec865c925a79dbbf830641d20a630be87efca2cb 100644 (file)
@@ -141,7 +141,8 @@ struct brw_depthbuffer
       struct {
         GLuint pitch:18; 
         GLuint format:3; 
-        GLuint pad:4;
+        GLuint pad:2;
+        GLuint software_tiled_rendering_mode:2;
         GLuint depth_offset_disable:1; 
         GLuint tile_walk:1; 
         GLuint tiled_surface:1; 
@@ -166,14 +167,64 @@ struct brw_depthbuffer
 
    union {
       struct {
-        GLuint pad:12;
-        GLuint min_array_element:9
+        GLuint pad:10;
+        GLuint min_array_element:11
         GLuint depth:11; 
       } bits;
       GLuint dword;
    } dword4;
 };
 
+struct brw_depthbuffer_gm45_g4x
+{
+   union header_union header;
+   
+   union {
+      struct {
+        GLuint pitch:18; 
+        GLuint format:3; 
+        GLuint pad:2;
+        GLuint software_tiled_rendering_mode:2;
+        GLuint depth_offset_disable:1; 
+        GLuint tile_walk:1; 
+        GLuint tiled_surface:1; 
+        GLuint pad2:1;
+        GLuint surface_type:3; 
+      } bits;
+      GLuint dword;
+   } dword1;
+   
+   GLuint dword2_base_addr; 
+   union {
+      struct {
+        GLuint pad:1;
+        GLuint mipmap_layout:1; 
+        GLuint lod:4; 
+        GLuint width:13; 
+        GLuint height:13; 
+      } bits;
+      GLuint dword;
+   } dword3;
+
+   union {
+      struct {
+        GLuint pad:10;
+        GLuint min_array_element:11; 
+        GLuint depth:11; 
+      } bits;
+      GLuint dword;
+   } dword4;
+
+   union {
+      struct {
+         GLuint xoffset:16;
+         GLuint yoffset:16;
+      } bits;
+      GLuint dword;
+   } dword5;   /* NEW in Integrated Graphics Device */
+};
+
 struct brw_drawrect
 {
    struct header header;
@@ -213,6 +264,25 @@ struct brw_indexbuffer
    GLuint buffer_end; 
 };
 
+/* NEW in Integrated Graphics Device */
+struct brw_aa_line_parameters
+{
+   struct header header;
+
+   struct {
+      GLuint aa_coverage_scope:8;
+      GLuint pad0:8;
+      GLuint aa_coverage_bias:8;
+      GLuint pad1:8;
+   } bits0;
+
+   struct {
+      GLuint aa_coverage_endcap_slope:8;
+      GLuint pad0:8;
+      GLuint aa_coverage_endcap_bias:8;
+      GLuint pad1:8;
+   } bits1;
+};
 
 struct brw_line_stipple
 {   
@@ -239,39 +309,39 @@ struct brw_pipelined_state_pointers
    
    struct {
       GLuint pad:5;
-      GLuint offset:27; 
+      GLuint offset:27; /* Offset from GENERAL_STATE_BASE */
    } vs;
    
    struct
    {
       GLuint enable:1;
       GLuint pad:4;
-      GLuint offset:27; 
+      GLuint offset:27; /* Offset from GENERAL_STATE_BASE */
    } gs;
    
    struct
    {
       GLuint enable:1;
       GLuint pad:4;
-      GLuint offset:27; 
+      GLuint offset:27; /* Offset from GENERAL_STATE_BASE */
    } clp;
    
    struct
    {
       GLuint pad:5;
-      GLuint offset:27; 
+      GLuint offset:27; /* Offset from GENERAL_STATE_BASE */
    } sf;
 
    struct
    {
       GLuint pad:5;
-      GLuint offset:27; 
+      GLuint offset:27; /* Offset from GENERAL_STATE_BASE */
    } wm;
    
    struct
    {
       GLuint pad:5;
-      GLuint offset:27; /* KW: check me! */
+      GLuint offset:27; /* Offset from GENERAL_STATE_BASE. KW: check me! */
    } cc;
 };
 
@@ -315,7 +385,8 @@ struct brw_pipe_control
    {
       GLuint length:8;
       GLuint notify_enable:1;
-      GLuint pad:2;
+      GLuint texture_cache_flush_enable:1;
+      GLuint indirect_state_pointers_disable:1;
       GLuint instruction_state_cache_flush_enable:1;
       GLuint write_cache_flush_enable:1;
       GLuint depth_stall_enable:1;
@@ -473,7 +544,7 @@ struct thread0
    GLuint pad0:1;
    GLuint grf_reg_count:3; 
    GLuint pad1:2;
-   GLuint kernel_start_pointer:26; 
+   GLuint kernel_start_pointer:26; /* Offset from GENERAL_STATE_BASE */
 };
 
 struct thread1
@@ -547,8 +618,8 @@ struct brw_clip_unit_state
       GLuint pad1:1;
       GLuint urb_entry_allocation_size:5; 
       GLuint pad2:1;
-      GLuint max_threads:1;    /* may be less */
-      GLuint pad3:6;
+      GLuint max_threads:5;    /* may be less */
+      GLuint pad3:2;
    } thread4;   
       
    struct
@@ -557,7 +628,7 @@ struct brw_clip_unit_state
       GLuint clip_mode:3; 
       GLuint userclip_enable_flags:8; 
       GLuint userclip_must_clip:1; 
-      GLuint pad1:1;
+      GLuint negative_w_clip_test:1;
       GLuint guard_band_enable:1; 
       GLuint viewport_z_clip_enable:1; 
       GLuint viewport_xy_clip_enable:1; 
@@ -637,7 +708,7 @@ struct brw_cc_unit_state
    struct
    {
       GLuint pad0:5; 
-      GLuint cc_viewport_state_offset:27; 
+      GLuint cc_viewport_state_offset:27; /* Offset from GENERAL_STATE_BASE */
    } cc4;
    
    struct
@@ -699,7 +770,7 @@ struct brw_sf_unit_state
       GLuint front_winding:1; 
       GLuint viewport_transform:1; 
       GLuint pad0:3;
-      GLuint sf_viewport_state_offset:27; 
+      GLuint sf_viewport_state_offset:27; /* Offset from GENERAL_STATE_BASE */
    } sf5;
    
    struct
@@ -724,7 +795,8 @@ struct brw_sf_unit_state
       GLuint use_point_size_state:1; 
       GLuint subpixel_precision:1; 
       GLuint sprite_point:1; 
-      GLuint pad0:11;
+      GLuint pad0:10;
+      GLuint aa_line_distance_mode:1;
       GLuint trifan_pv:2; 
       GLuint linestrip_pv:2; 
       GLuint tristrip_pv:2; 
@@ -749,8 +821,8 @@ struct brw_gs_unit_state
       GLuint pad1:1;
       GLuint urb_entry_allocation_size:5; 
       GLuint pad2:1;
-      GLuint max_threads:1
-      GLuint pad3:6;
+      GLuint max_threads:5
+      GLuint pad3:2;
    } thread4;   
       
    struct
@@ -764,9 +836,14 @@ struct brw_gs_unit_state
    struct
    {
       GLuint max_vp_index:4; 
-      GLuint pad0:26;
-      GLuint reorder_enable:1; 
+      GLuint pad0:12;
+      GLuint svbi_post_inc_value:10;
       GLuint pad1:1;
+      GLuint svbi_post_inc_enable:1;
+      GLuint svbi_payload:1;
+      GLuint discard_adjaceny:1;
+      GLuint reorder_enable:1; 
+      GLuint pad2:1;
    } gs6;
 };
 
@@ -786,8 +863,8 @@ struct brw_vs_unit_state
       GLuint pad1:1;
       GLuint urb_entry_allocation_size:5; 
       GLuint pad2:1;
-      GLuint max_threads:4
-      GLuint pad3:3;
+      GLuint max_threads:6
+      GLuint pad3:1;
    } thread4;   
 
    struct
@@ -815,7 +892,7 @@ struct brw_wm_unit_state
    
    struct {
       GLuint stats_enable:1; 
-      GLuint pad0:1;
+      GLuint depth_buffer_clear:1;
       GLuint sampler_count:3; 
       GLuint sampler_state_pointer:27; 
    } wm4;
@@ -825,7 +902,9 @@ struct brw_wm_unit_state
       GLuint enable_8_pix:1; 
       GLuint enable_16_pix:1; 
       GLuint enable_32_pix:1; 
-      GLuint pad0:7;
+      GLuint enable_con_32_pix:1;
+      GLuint enable_con_64_pix:1;
+      GLuint pad0:5;
       GLuint legacy_global_depth_bias:1; 
       GLuint line_stipple:1; 
       GLuint depth_offset:1; 
@@ -838,9 +917,8 @@ struct brw_wm_unit_state
       GLuint program_computes_depth:1; 
       GLuint program_uses_killpixel:1; 
       GLuint legacy_line_rast: 1; 
-      GLuint pad1:1; 
-      GLuint max_threads:6; 
-      GLuint pad2:1;
+      GLuint transposed_urb_read_enable:1; 
+      GLuint max_threads:7; 
    } wm5;
    
    GLfloat global_depth_offset_constant;  
@@ -924,6 +1002,7 @@ struct brw_sf_viewport
       GLfloat m32;  
    } viewport;
 
+   /* scissor coordinates are inclusive */
    struct {
       GLshort xmin;
       GLshort ymin;
@@ -978,10 +1057,26 @@ struct brw_surface_state
    } ss3;
    
    struct {
-      GLuint pad:19;
-      GLuint min_array_elt:9; 
+      GLuint multisample_position_palette_index:3;
+      GLuint pad1:1;
+      GLuint num_multisamples:3;
+      GLuint pad0:1;
+      GLuint render_target_view_extent:9;
+      GLuint min_array_elt:11;
       GLuint min_lod:4; 
    } ss4;
+
+   struct {
+      GLuint pad1:16;
+      GLuint llc_mapping:1;
+      GLuint mlc_mapping:1;
+      GLuint gfdt:1;
+      GLuint gfdt_src:1;
+      GLuint y_offset:4;
+      GLuint pad0:1;
+      GLuint x_offset:7;
+   } ss5;   /* NEW in Integrated Graphics Device */
+
 };
 
 
@@ -1301,6 +1396,17 @@ struct brw_instruction
         GLuint end_of_thread:1;
       } sampler;
 
+      struct {
+         GLuint binding_table_index:8;
+         GLuint sampler:4;
+         GLuint msg_type:4;
+         GLuint response_length:4;
+         GLuint msg_length:4;
+         GLuint msg_target:4;
+         GLuint pad1:3;
+         GLuint end_of_thread:1;
+      } sampler_gm45_g4x; 
+
       struct brw_urb_immediate urb;
 
       struct {
index 9d4b9867d24e7e1509be67ac3dd86e06a526f9ca..ab6393420a8402b4e55d223b10d2fa0415de06ee 100644 (file)
 #include "texmem.h"
 
 #include "intel_context.h"
-#include "intel_ioctl.h"
 #include "intel_regions.h"
+#include "intel_tex.h"
 #include "brw_context.h"
 #include "brw_defines.h"
 
 
-
-
-static const struct gl_texture_format *
-brwChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
-                        GLenum srcFormat, GLenum srcType )
-{
-   switch ( internalFormat ) {
-   case 4:
-   case GL_RGBA:
-   case GL_COMPRESSED_RGBA:
-      if (srcFormat == GL_BGRA && srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV)
-        return &_mesa_texformat_argb4444;
-      else if (srcFormat == GL_BGRA && srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV)
-        return &_mesa_texformat_argb1555;
-      else if ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
-              (srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE) ||
-              (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8)) 
-        return &_mesa_texformat_rgba8888_rev;
-      else
-        return &_mesa_texformat_argb8888;
-
-   case GL_RGBA8:
-   case GL_RGB10_A2:
-   case GL_RGBA12:
-   case GL_RGBA16:
-      return &_mesa_texformat_argb8888; 
-
-   case GL_RGB8:
-   case GL_RGB10:
-   case GL_RGB12:
-   case GL_RGB16:
-      /* Broadwater doesn't support RGB888 textures, so these must be
-       * stored as ARGB.
-       */
-      return &_mesa_texformat_argb8888;
-
-   case 3:
-   case GL_COMPRESSED_RGB:
-   case GL_RGB:
-      if (srcFormat == GL_RGB &&
-         srcType == GL_UNSIGNED_SHORT_5_6_5)
-        return &_mesa_texformat_rgb565;
-      else
-        return &_mesa_texformat_argb8888;
-
-
-   case GL_RGB5:
-   case GL_RGB5_A1:
-      return &_mesa_texformat_argb1555;
-
-   case GL_R3_G3_B2:
-   case GL_RGBA2:
-   case GL_RGBA4:
-   case GL_RGB4:
-      return &_mesa_texformat_argb4444;
-
-   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 (srcType == GL_UNSIGNED_SHORT_8_8_MESA ||
-         srcType == 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_RGBA_S3TC:
-   case GL_RGBA4_S3TC:
-   case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
-   case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
-   case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
-   case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
-     return &_mesa_texformat_rgb_dxt1; /* there is no rgba support? */
-
-   case GL_DEPTH_COMPONENT:
-   case GL_DEPTH_COMPONENT16:
-   case GL_DEPTH_COMPONENT24:
-   case GL_DEPTH_COMPONENT32:
-      return &_mesa_texformat_z16;
-
-   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 brwInitTextureFuncs( struct dd_function_table *functions )
-{
-   functions->ChooseTextureFormat = brwChooseTextureFormat;
-}
-
-void brw_FrameBufferTexInit( struct brw_context *brw )
+void brw_FrameBufferTexInit( struct brw_context *brw,
+                            struct intel_region *region )
 {
    struct intel_context *intel = &brw->intel;
    GLcontext *ctx = &intel->ctx;
-   struct intel_region *region = intel->front_region;
    struct gl_texture_object *obj;
    struct gl_texture_image *img;
    
@@ -209,6 +73,26 @@ void brw_FrameBufferTexInit( struct brw_context *brw )
 
 void brw_FrameBufferTexDestroy( struct brw_context *brw )
 {
-   brw->intel.ctx.Driver.DeleteTexture( &brw->intel.ctx,
-                                       brw->intel.frame_buffer_texobj );
+   if (brw->intel.frame_buffer_texobj != NULL)
+      brw->intel.ctx.Driver.DeleteTexture( &brw->intel.ctx,
+                                          brw->intel.frame_buffer_texobj );
+   brw->intel.frame_buffer_texobj = NULL;
+}
+
+/**
+ * Finalizes all textures, completing any rendering that needs to be done
+ * to prepare them.
+ */
+void brw_validate_textures( struct brw_context *brw )
+{
+   struct intel_context *intel = &brw->intel;
+   int i;
+
+   for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {
+      struct gl_texture_unit *texUnit = &brw->attribs.Texture->Unit[i];
+
+      if (texUnit->_ReallyEnabled) {
+        intel_finalize_mipmap_tree(intel, i);
+      }
+   }
 }
index af1ad0f1ef1bc3e1da07d65bb9ffda88b77732b5..e437c411dde7e4a518933af83ec07fbfc1b4c218 100644 (file)
 
 #include "intel_mipmap_tree.h"
 #include "intel_tex_layout.h"
+#include "intel_context.h"
 #include "macros.h"
 
+#define FILE_DEBUG_FLAG DEBUG_MIPTREE
 
-GLboolean brw_miptree_layout( struct intel_mipmap_tree *mt )
+GLboolean brw_miptree_layout( struct intel_context *intel, struct intel_mipmap_tree *mt )
 {
    /* XXX: these vary depending on image format: 
     */
@@ -53,11 +55,20 @@ GLboolean brw_miptree_layout( struct intel_mipmap_tree *mt )
       GLuint pack_x_pitch, pack_x_nr;
       GLuint pack_y_pitch;
       GLuint level;
+      GLuint align_h = 2;
+      GLuint align_w = 4;
 
-      mt->pitch = ((mt->width0 * mt->cpp + 3) & ~3) / mt->cpp;
       mt->total_height = 0;
+      
+      if (mt->compressed) {
+          align_w = intel_compressed_alignment(mt->internal_format);
+          mt->pitch = ALIGN(width, align_w);
+          pack_y_pitch = (height + 3) / 4;
+      } else {
+          mt->pitch = intel_miptree_pitch_align (intel, mt, mt->width0);
+          pack_y_pitch = ALIGN(mt->height0, align_h);
+      }
 
-      pack_y_pitch = MAX2(mt->height0, 2);
       pack_x_pitch = mt->pitch;
       pack_x_nr = 1;
 
@@ -83,26 +94,36 @@ GLboolean brw_miptree_layout( struct intel_mipmap_tree *mt )
 
 
         mt->total_height += y;
-
-        if (pack_x_pitch > 4) {
-           pack_x_pitch >>= 1;
-           pack_x_nr <<= 1;
-           assert(pack_x_pitch * pack_x_nr <= mt->pitch);
-        }
-
-        if (pack_y_pitch > 2) {
-           pack_y_pitch >>= 1;
-        }
-
         width  = minify(width);
         height = minify(height);
         depth  = minify(depth);
+
+    if (mt->compressed) {
+        pack_y_pitch = (height + 3) / 4;
+        
+        if (pack_x_pitch > ALIGN(width, align_w)) {
+            pack_x_pitch = ALIGN(width, align_w);
+            pack_x_nr <<= 1;
+        }
+    } else {
+        if (pack_x_pitch > 4) {
+            pack_x_pitch >>= 1;
+            pack_x_nr <<= 1;
+            assert(pack_x_pitch * pack_x_nr <= mt->pitch);
+        }
+
+        if (pack_y_pitch > 2) {
+            pack_y_pitch >>= 1;
+            pack_y_pitch = ALIGN(pack_y_pitch, align_h);
+        }
+    }
+
       }
       break;
    }
 
    default:
-      i945_miptree_layout_2d(mt);
+      i945_miptree_layout_2d(intel, mt);
       break;
    }
    DBG("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__, 
index 64f5904ac687cd157aa9f9d66c9d5bd8655f27a5..1116ade0a47074598f3608ee6e2b3b2b11a66e29 100644 (file)
@@ -35,7 +35,6 @@
 #include "brw_context.h"
 #include "brw_state.h"
 #include "brw_defines.h"
-#include "brw_hal.h"
 
 #define VS 0
 #define GS 1
@@ -53,7 +52,7 @@ static const struct {
    GLuint min_entry_size;
    GLuint max_entry_size;
 } limits[CS+1] = {
-   { 8, 32, 1, 5 },                    /* vs */
+   { 16, 32, 1, 5 },                   /* vs */
    { 4, 8,  1, 5 },                    /* gs */
    { 6, 8,  1, 5 },                    /* clp */
    { 1, 8,  1, 12 },                   /* sf */
@@ -69,7 +68,7 @@ static GLboolean check_urb_layout( struct brw_context *brw )
    brw->urb.sf_start = brw->urb.clip_start + brw->urb.nr_clip_entries * brw->urb.vsize;
    brw->urb.cs_start = brw->urb.sf_start + brw->urb.nr_sf_entries * brw->urb.sfsize;
 
-   return brw->urb.cs_start + brw->urb.nr_cs_entries * brw->urb.csize <= 256;
+   return brw->urb.cs_start + brw->urb.nr_cs_entries * brw->urb.csize <= URB_SIZES(brw);
 }
 
 /* Most minimal update, forces re-emit of URB fence packet after GS
@@ -81,20 +80,6 @@ static void recalculate_urb_fence( struct brw_context *brw )
    GLuint vsize = brw->vs.prog_data->urb_entry_size;
    GLuint sfsize = brw->sf.prog_data->urb_entry_size;
 
-   static GLboolean (*hal_recalculate_urb_fence) (struct brw_context *brw);
-   static GLboolean hal_tried;
-
-   if (!hal_tried)
-   {
-      hal_recalculate_urb_fence = brw_hal_find_symbol ("intel_hal_recalculate_urb_fence");
-      hal_tried = 1;
-   }
-   if (hal_recalculate_urb_fence)
-   {
-      if ((*hal_recalculate_urb_fence) (brw))
-        return;
-   }
-   
    if (csize < limits[CS].min_entry_size)
       csize = limits[CS].min_entry_size;
 
@@ -153,7 +138,7 @@ static void recalculate_urb_fence( struct brw_context *brw )
                      brw->urb.clip_start,
                      brw->urb.sf_start,
                      brw->urb.cs_start, 
-                     256);
+                     URB_SIZES(brw));
       
       brw->state.dirty.brw |= BRW_NEW_URB_FENCE;
    }
@@ -167,7 +152,7 @@ const struct brw_tracked_state brw_recalculate_urb_fence = {
       .cache = (CACHE_NEW_VS_PROG |
                CACHE_NEW_SF_PROG)
    },
-   .update = recalculate_urb_fence
+   .prepare = recalculate_urb_fence
 };
 
 
@@ -191,25 +176,13 @@ void brw_upload_urb_fence(struct brw_context *brw)
    /* The ordering below is correct, not the layout in the
     * instruction.
     *
-    * There are 256 urb reg pairs in total.
+    * There are 256/384 urb reg pairs in total.
     */
    uf.bits0.vs_fence  = brw->urb.gs_start;
    uf.bits0.gs_fence  = brw->urb.clip_start; 
    uf.bits0.clp_fence = brw->urb.sf_start; 
    uf.bits1.sf_fence  = brw->urb.cs_start; 
-   uf.bits1.cs_fence  = 256;
+   uf.bits1.cs_fence  = URB_SIZES(brw);
 
    BRW_BATCH_STRUCT(brw, &uf);
 }
-
-
-#if 0
-const struct brw_tracked_state brw_urb_fence = {
-   .dirty = {
-      .mesa = 0,
-      .brw = BRW_NEW_URB_FENCE | BRW_NEW_PSP,
-      .cache = 0
-   },
-   .update = brw_upload_urb_fence
-};
-#endif
index b6deee2376955b257f8fbb664190da3d798f1fef..d8d35c574e7de4106a19f3b194f4e102ae0a0860 100644 (file)
@@ -45,86 +45,6 @@ GLuint brw_count_bits( GLuint val )
 }
 
 
-static GLuint brw_parameter_state_flags(const gl_state_index state[])
-{
-   switch (state[0]) {
-   case STATE_MATERIAL:
-   case STATE_LIGHT:
-   case STATE_LIGHTMODEL_AMBIENT:
-   case STATE_LIGHTMODEL_SCENECOLOR:
-   case STATE_LIGHTPROD:
-      return _NEW_LIGHT;
-
-   case STATE_TEXGEN:
-   case STATE_TEXENV_COLOR:
-      return _NEW_TEXTURE;
-
-   case STATE_FOG_COLOR:
-   case STATE_FOG_PARAMS:
-      return _NEW_FOG;
-
-   case STATE_CLIPPLANE:
-      return _NEW_TRANSFORM;
-
-   case STATE_POINT_SIZE:
-   case STATE_POINT_ATTENUATION:
-      return _NEW_POINT;
-
-   case STATE_MODELVIEW_MATRIX:
-      return _NEW_MODELVIEW;
-   case STATE_PROJECTION_MATRIX:
-      return _NEW_PROJECTION;
-   case STATE_MVP_MATRIX:
-      return _NEW_MODELVIEW | _NEW_PROJECTION;
-   case STATE_TEXTURE_MATRIX:
-      return _NEW_TEXTURE_MATRIX;
-   case STATE_PROGRAM_MATRIX:
-      return _NEW_TRACK_MATRIX;
-
-   case STATE_DEPTH_RANGE:
-      return _NEW_VIEWPORT;
-
-   case STATE_FRAGMENT_PROGRAM:
-   case STATE_VERTEX_PROGRAM:
-      return _NEW_PROGRAM;
-
-   case STATE_INTERNAL:
-      switch (state[1]) {
-      case STATE_NORMAL_SCALE:
-        return _NEW_MODELVIEW;
-      case STATE_TEXRECT_SCALE:
-        return _NEW_TEXTURE;
-      default:
-        assert(0);
-        return 0;
-      }
-
-   default:
-      assert(0);
-      return 0;
-   }
-}
-
-
-GLuint
-brw_parameter_list_state_flags(struct gl_program_parameter_list *paramList)
-{
-   GLuint i;
-   GLuint result = 0;
-
-   if (!paramList)
-      return 0;
-
-   for (i = 0; i < paramList->NumParameters; i++) {
-      if (paramList->Parameters[i].Type == PROGRAM_STATE_VAR) {
-         result |= brw_parameter_state_flags(paramList->Parameters[i].StateIndexes);
-      }
-   }
-
-   return result;
-}
-
-
 GLuint brw_translate_blend_equation( GLenum mode )
 {
    switch (mode) {
index e173f6fce3e8b6ec0c2abb3c7d5b8ab387ba1f58..1db7ceebcfbb566292f04aa5bf45a2d4d47ffe41 100644 (file)
@@ -49,7 +49,7 @@ static void do_vs_prog( struct brw_context *brw,
    memset(&c, 0, sizeof(c));
    memcpy(&c.key, key, sizeof(*key));
 
-   brw_init_compile(&c.func);
+   brw_init_compile(brw, &c.func);
    c.vp = vp;
 
    c.prog_data.outputs_written = vp->program.Base.OutputsWritten;
@@ -73,19 +73,17 @@ static void do_vs_prog( struct brw_context *brw,
     */
    program = brw_get_program(&c.func, &program_size);
 
-   /*
-    */
-   brw->vs.prog_gs_offset = brw_upload_cache( &brw->cache[BRW_VS_PROG],
-                                             &c.key,
-                                             sizeof(c.key),
-                                             program,
-                                             program_size,
-                                             &c.prog_data,
-                                             &brw->vs.prog_data);
+   dri_bo_unreference(brw->vs.prog_bo);
+   brw->vs.prog_bo = brw_upload_cache( &brw->cache, BRW_VS_PROG,
+                                      &c.key, sizeof(c.key),
+                                      NULL, 0,
+                                      program, program_size,
+                                      &c.prog_data,
+                                      &brw->vs.prog_data );
 }
 
 
-static void brw_upload_vs_prog( struct brw_context *brw )
+static void brw_upload_vs_prog(struct brw_context *brw)
 {
    struct brw_vs_prog_key key;
    struct brw_vertex_program *vp = 
@@ -110,13 +108,13 @@ static void brw_upload_vs_prog( struct brw_context *brw )
 
    /* Make an early check for the key.
     */
-   if (brw_search_cache(&brw->cache[BRW_VS_PROG], 
-                       &key, sizeof(key),
-                       &brw->vs.prog_data,
-                       &brw->vs.prog_gs_offset))
-       return;
-
-   do_vs_prog(brw, vp, &key);
+   dri_bo_unreference(brw->vs.prog_bo);
+   brw->vs.prog_bo = brw_search_cache(&brw->cache, BRW_VS_PROG,
+                                     &key, sizeof(key),
+                                     NULL, 0,
+                                     &brw->vs.prog_data);
+   if (brw->vs.prog_bo == NULL)
+      do_vs_prog(brw, vp, &key);
 }
 
 
@@ -128,5 +126,5 @@ const struct brw_tracked_state brw_vs_prog = {
       .brw   = BRW_NEW_VERTEX_PROGRAM | BRW_NEW_METAOPS,
       .cache = 0
    },
-   .update = brw_upload_vs_prog
+   .prepare = brw_upload_vs_prog
 };
index fdb5785d67d267fb6bceb44a4d518e4738637271..41a33ffe387f2d3dc49ea377224019818980a590 100644 (file)
@@ -36,7 +36,7 @@
 
 #include "brw_context.h"
 #include "brw_eu.h"
-#include "program.h"
+#include "shader/program.h"
 
 
 struct brw_vs_prog_key {
@@ -67,6 +67,12 @@ struct brw_vs_compile {
    struct brw_reg r1;
    struct brw_reg regs[PROGRAM_ADDRESS+1][128];
    struct brw_reg tmp;
+   struct brw_reg stack;
+
+   struct {    
+       GLboolean used_in_src;
+       struct brw_reg reg;
+   } output_regs[128];
 
    struct brw_reg userplane[6];
 
index caef042f1cdd774c7fc9bdd9f202ba3702e957ee..734a926e968d8458fac92326d03c1ddaed995eba 100644 (file)
@@ -218,6 +218,6 @@ const struct brw_tracked_state brw_wm_input_sizes = {
       .brw   = BRW_NEW_VERTEX_PROGRAM | BRW_NEW_INPUT_DIMENSIONS,
       .cache = 0
    },
-   .update = calc_wm_input_sizes
+   .prepare = calc_wm_input_sizes
 };
 
index 6eb11b19ad2f4f9c4069b9ee00045b06fbdd64f0..8759826e83b3fa489856cf2728e802804c1956dd 100644 (file)
@@ -30,8 +30,8 @@
   */
             
 
-#include "program.h"
-#include "macros.h"
+#include "main/macros.h"
+#include "shader/program.h"
 #include "shader/prog_parameter.h"
 #include "shader/prog_print.h"
 #include "brw_context.h"
@@ -134,6 +134,16 @@ static void brw_vs_alloc_regs( struct brw_vs_compile *c )
                                             WRITEMASK_X);
       reg++;
    }
+
+   for (i = 0; i < 128; i++) {
+       if (c->output_regs[i].used_in_src) {
+            c->output_regs[i].reg = brw_vec8_grf(reg, 0);
+            reg++;
+        }
+   }
+
+   c->stack =  brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, reg, 0);
+   reg += 2;
  
    
    /* Some opcodes need an internal temporary:
@@ -201,7 +211,7 @@ static void unalias2( struct brw_vs_compile *c,
                                    struct brw_reg,
                                    struct brw_reg ))
 {
-   if ((dst.file == arg0.file && dst.nr == arg0.nr) &&
+   if ((dst.file == arg0.file && dst.nr == arg0.nr) ||
        (dst.file == arg1.file && dst.nr == arg1.nr)) {
       struct brw_compile *p = &c->func;
       struct brw_reg tmp = brw_writemask(get_tmp(c), dst.dw1.bits.writemask);
@@ -213,57 +223,65 @@ static void unalias2( struct brw_vs_compile *c,
    }
 }
 
+static void emit_sop( struct brw_compile *p,
+                      struct brw_reg dst,
+                      struct brw_reg arg0,
+                      struct brw_reg arg1, 
+                     GLuint cond)
+{
+   brw_MOV(p, dst, brw_imm_f(0.0f));
+   brw_CMP(p, brw_null_reg(), cond, arg0, arg1);
+   brw_MOV(p, dst, brw_imm_f(1.0f));
+   brw_set_predicate_control_flag_value(p, 0xff);
+}
 
+static void emit_seq( struct brw_compile *p,
+                      struct brw_reg dst,
+                      struct brw_reg arg0,
+                      struct brw_reg arg1 )
+{
+   emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_EQ);
+}
 
-
+static void emit_sne( struct brw_compile *p,
+                      struct brw_reg dst,
+                      struct brw_reg arg0,
+                      struct brw_reg arg1 )
+{
+   emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_NEQ);
+}
 static void emit_slt( struct brw_compile *p, 
                      struct brw_reg dst,
                      struct brw_reg arg0,
                      struct brw_reg arg1 )
 {
-   /* Could be done with an if/else/endif, but this method uses half
-    * the instructions.  Note that we are careful to reference the
-    * arguments before writing the dest.  That means we emit the
-    * instructions in an odd order and have to play with the flag
-    * values.
-    */
-   brw_push_insn_state(p);
-   brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_GE, arg0, arg1);
-
-   /* Write all values to 1:
-    */
-   brw_set_predicate_control(p, BRW_PREDICATE_NONE);
-   brw_MOV(p, dst, brw_imm_f(1.0));
+   emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_L);
+}
 
-   /* Where the test succeeded, overwite with zero:
-    */
-   brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
-   brw_MOV(p, dst, brw_imm_f(0.0));
-   brw_pop_insn_state(p);
+static void emit_sle( struct brw_compile *p, 
+                     struct brw_reg dst,
+                     struct brw_reg arg0,
+                     struct brw_reg arg1 )
+{
+   emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_LE);
 }
 
+static void emit_sgt( struct brw_compile *p, 
+                     struct brw_reg dst,
+                     struct brw_reg arg0,
+                     struct brw_reg arg1 )
+{
+   emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_G);
+}
 
 static void emit_sge( struct brw_compile *p, 
                      struct brw_reg dst,
                      struct brw_reg arg0,
                      struct brw_reg arg1 )
 {
-   brw_push_insn_state(p);
-   brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_GE, arg0, arg1);
-
-   /* Write all values to zero:
-    */
-   brw_set_predicate_control(p, BRW_PREDICATE_NONE);
-   brw_MOV(p, dst, brw_imm_f(0));
-
-   /* Where the test succeeded, overwite with 1:
-    */
-   brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
-   brw_MOV(p, dst, brw_imm_f(1.0));
-   brw_pop_insn_state(p);
+  emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_GE);
 }
 
-
 static void emit_max( struct brw_compile *p, 
                      struct brw_reg dst,
                      struct brw_reg arg0,
@@ -592,9 +610,13 @@ static struct brw_reg get_reg( struct brw_vs_compile *c,
    case PROGRAM_TEMPORARY:
    case PROGRAM_INPUT:
    case PROGRAM_OUTPUT:
-   case PROGRAM_STATE_VAR:
       assert(c->regs[file][index].nr != 0);
       return c->regs[file][index];
+   case PROGRAM_STATE_VAR:
+   case PROGRAM_CONSTANT:
+   case PROGRAM_UNIFORM:
+      assert(c->regs[PROGRAM_STATE_VAR][index].nr != 0);
+      return c->regs[PROGRAM_STATE_VAR][index];
    case PROGRAM_ADDRESS:
       assert(index == 0);
       return c->regs[file][index];
@@ -668,28 +690,28 @@ static void emit_arl( struct brw_vs_compile *c,
  * account.
  */
 static struct brw_reg get_arg( struct brw_vs_compile *c,
-                              struct prog_src_register src )
+                              struct prog_src_register *src )
 {
    struct brw_reg reg;
 
-   if (src.File == PROGRAM_UNDEFINED)
+   if (src->File == PROGRAM_UNDEFINED)
       return brw_null_reg();
 
-   if (src.RelAddr) 
-      reg = deref(c, c->regs[PROGRAM_STATE_VAR][0], src.Index);
+   if (src->RelAddr) 
+      reg = deref(c, c->regs[PROGRAM_STATE_VAR][0], src->Index);
    else
-      reg = get_reg(c, src.File, src.Index);
+      reg = get_reg(c, src->File, src->Index);
 
    /* Convert 3-bit swizzle to 2-bit.  
     */
-   reg.dw1.bits.swizzle = BRW_SWIZZLE4(GET_SWZ(src.Swizzle, 0),
-                                      GET_SWZ(src.Swizzle, 1),
-                                      GET_SWZ(src.Swizzle, 2),
-                                      GET_SWZ(src.Swizzle, 3));
+   reg.dw1.bits.swizzle = BRW_SWIZZLE4(GET_SWZ(src->Swizzle, 0),
+                                      GET_SWZ(src->Swizzle, 1),
+                                      GET_SWZ(src->Swizzle, 2),
+                                      GET_SWZ(src->Swizzle, 3));
 
    /* Note this is ok for non-swizzle instructions: 
     */
-   reg.negate = src.NegateBase ? 1 : 0;   
+   reg.negate = src->NegateBase ? 1 : 0;   
 
    return reg;
 }
@@ -845,7 +867,7 @@ static void emit_vertex_write( struct brw_vs_compile *c)
        * Later, clipping will detect ucp[6] and ensure the primitive is
        * clipped against all fixed planes.
        */
-      if (!c->key.know_w_is_one) {
+      if (!(BRW_IS_GM45(p->brw) || BRW_IS_G4X(p->brw)) && !c->key.know_w_is_one) {
         brw_CMP(p,
                 vec8(brw_null_reg()),
                 BRW_CONDITIONAL_L,
@@ -891,17 +913,50 @@ static void emit_vertex_write( struct brw_vs_compile *c)
 
 }
 
-
-
+static void 
+post_vs_emit( struct brw_vs_compile *c, struct brw_instruction *end_inst )
+{
+   GLuint nr_insns = c->vp->program.Base.NumInstructions;
+   GLuint insn, target_insn;
+   struct prog_instruction *inst1, *inst2;
+   struct brw_instruction *brw_inst1, *brw_inst2;
+   int offset;
+   for (insn = 0; insn < nr_insns; insn++) {
+       inst1 = &c->vp->program.Base.Instructions[insn];
+       brw_inst1 = inst1->Data;
+       switch (inst1->Opcode) {
+          case OPCODE_CAL:
+          case OPCODE_BRA:
+              target_insn = inst1->BranchTarget;
+              inst2 = &c->vp->program.Base.Instructions[target_insn];
+              brw_inst2 = inst2->Data;
+              offset = brw_inst2 - brw_inst1;
+              brw_set_src1(brw_inst1, brw_imm_d(offset*16));
+              break;
+          case OPCODE_END:
+              offset = end_inst - brw_inst1;
+              brw_set_src1(brw_inst1, brw_imm_d(offset*16));
+              break;
+          default:
+              break;
+       }
+   }
+}
 
 /* Emit the fragment program instructions here.
  */
-void brw_vs_emit( struct brw_vs_compile *c )
+void brw_vs_emit(struct brw_vs_compile *c )
 {
+#define MAX_IFSN 32
    struct brw_compile *p = &c->func;
    GLuint nr_insns = c->vp->program.Base.NumInstructions;
-   GLuint insn;
+   GLuint insn, if_insn = 0;
+   struct brw_instruction *end_inst;
+   struct brw_instruction *if_inst[MAX_IFSN];
+   struct brw_indirect stack_index = brw_indirect(0, 0);   
 
+   GLuint index;
+   GLuint file;
 
    if (INTEL_DEBUG & DEBUG_VS) {
       _mesa_printf("\n\n\nvs-emit:\n");
@@ -912,9 +967,24 @@ void brw_vs_emit( struct brw_vs_compile *c )
    brw_set_compression_control(p, BRW_COMPRESSION_NONE);
    brw_set_access_mode(p, BRW_ALIGN_16);
    
+   /* Message registers can't be read, so copy the output into GRF register
+      if they are used in source registers */
+   for (insn = 0; insn < nr_insns; insn++) {
+       GLuint i;
+       struct prog_instruction *inst = &c->vp->program.Base.Instructions[insn];
+       for (i = 0; i < 3; i++) {
+          struct prog_src_register *src = &inst->SrcReg[i];
+          GLuint index = src->Index;
+          GLuint file = src->File;     
+          if (file == PROGRAM_OUTPUT && index != VERT_RESULT_HPOS)
+              c->output_regs[index].used_in_src = GL_TRUE;
+       }
+   }
+
    /* Static register allocation
     */
    brw_vs_alloc_regs(c);
+   brw_MOV(p, get_addr_reg(stack_index), brw_address(c->stack));
 
    for (insn = 0; insn < nr_insns; insn++) {
 
@@ -924,17 +994,29 @@ void brw_vs_emit( struct brw_vs_compile *c )
       
       /* Get argument regs.  SWZ is special and does this itself.
        */
+      inst->Data = &p->store[p->nr_insn];
       if (inst->Opcode != OPCODE_SWZ)
-        for (i = 0; i < 3; i++) 
-           args[i] = get_arg(c, inst->SrcReg[i]);
+         for (i = 0; i < 3; i++) {
+             struct prog_src_register *src = &inst->SrcReg[i];
+             index = src->Index;
+             file = src->File; 
+             if (file == PROGRAM_OUTPUT&&c->output_regs[index].used_in_src)
+                 args[i] = c->output_regs[index].reg;
+             else
+                 args[i] = get_arg(c, src);
+         }
 
       /* Get dest regs.  Note that it is possible for a reg to be both
        * dst and arg, given the static allocation of registers.  So
        * care needs to be taken emitting multi-operation instructions.
-       */
-      dst = get_dst(c, inst->DstReg);
+       */ 
+      index = inst->DstReg.Index;
+      file = inst->DstReg.File;
+      if (file == PROGRAM_OUTPUT && c->output_regs[index].used_in_src)
+         dst = c->output_regs[index].reg;
+      else
+         dst = get_dst(c, inst->DstReg);
 
-      
       switch (inst->Opcode) {
       case OPCODE_ABS:
         brw_MOV(p, dst, brw_abs(args[0]));
@@ -1003,12 +1085,25 @@ void brw_vs_emit( struct brw_vs_compile *c )
       case OPCODE_RSQ:
         emit_math1(c, BRW_MATH_FUNCTION_RSQ, dst, args[0], BRW_MATH_PRECISION_FULL);
         break;
+
+      case OPCODE_SEQ:
+         emit_seq(p, dst, args[0], args[1]);
+         break;
+      case OPCODE_SNE:
+         emit_sne(p, dst, args[0], args[1]);
+         break;
       case OPCODE_SGE:
         emit_sge(p, dst, args[0], args[1]);
         break;
+      case OPCODE_SGT:
+         emit_sgt(p, dst, args[0], args[1]);
+        break;
       case OPCODE_SLT:
         emit_slt(p, dst, args[0], args[1]);
         break;
+      case OPCODE_SLE:
+         emit_sle(p, dst, args[0], args[1]);
+         break;
       case OPCODE_SUB:
         brw_ADD(p, dst, args[0], negate(args[1]));
         break;
@@ -1021,21 +1116,82 @@ void brw_vs_emit( struct brw_vs_compile *c )
       case OPCODE_XPD:
         emit_xpd(p, dst, args[0], args[1]);
         break;
+      case OPCODE_IF:
+        assert(if_insn < MAX_IFSN);
+         if_inst[if_insn++] = brw_IF(p, BRW_EXECUTE_8);
+        break;
+      case OPCODE_ELSE:
+        if_inst[if_insn-1] = brw_ELSE(p, if_inst[if_insn-1]);
+        break;
+      case OPCODE_ENDIF:
+         assert(if_insn > 0);
+        brw_ENDIF(p, if_inst[--if_insn]);
+        break;                 
+      case OPCODE_BRA:
+         brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
+         brw_ADD(p, brw_ip_reg(), brw_ip_reg(), brw_imm_d(1*16));
+         brw_set_predicate_control_flag_value(p, 0xff);
+        break;
+      case OPCODE_CAL:
+        brw_set_access_mode(p, BRW_ALIGN_1);
+        brw_ADD(p, deref_1d(stack_index, 0), brw_ip_reg(), brw_imm_d(3*16));
+        brw_set_access_mode(p, BRW_ALIGN_16);
+        brw_ADD(p, get_addr_reg(stack_index),
+                        get_addr_reg(stack_index), brw_imm_d(4));
+        inst->Data = &p->store[p->nr_insn];
+        brw_ADD(p, brw_ip_reg(), brw_ip_reg(), brw_imm_d(1*16));
+        break;
+      case OPCODE_RET:
+        brw_ADD(p, get_addr_reg(stack_index),
+                        get_addr_reg(stack_index), brw_imm_d(-4));
+        brw_set_access_mode(p, BRW_ALIGN_1);
+         brw_MOV(p, brw_ip_reg(), deref_1d(stack_index, 0));
+        brw_set_access_mode(p, BRW_ALIGN_16);
       case OPCODE_END: 
+         brw_ADD(p, brw_ip_reg(), brw_ip_reg(), brw_imm_d(1*16));
+        break;
       case OPCODE_PRINT:
+      case OPCODE_BGNSUB:
+      case OPCODE_ENDSUB:
         break;
       default:
+        _mesa_printf("Unsupport opcode %d in vertex shader\n", inst->Opcode);
         break;
       }
 
+      if ((inst->DstReg.File == PROGRAM_OUTPUT)
+          && (inst->DstReg.Index != VERT_RESULT_HPOS)
+          && c->output_regs[inst->DstReg.Index].used_in_src) {
+         brw_MOV(p, get_dst(c, inst->DstReg), dst);
+      }
+
+      /* Result color clamping.
+       *
+       * When destination register is an output register and
+       * it's primary/secondary front/back color, we have to clamp
+       * the result to [0,1]. This is done by enabling the
+       * saturation bit for the last instruction.
+       *
+       * We don't use brw_set_saturate() as it modifies
+       * p->current->header.saturate, which affects all the subsequent
+       * instructions. Instead, we directly modify the header
+       * of the last (already stored) instruction.
+       */
+      if (inst->DstReg.File == PROGRAM_OUTPUT) {
+         if ((inst->DstReg.Index == VERT_RESULT_COL0)
+             || (inst->DstReg.Index == VERT_RESULT_COL1)
+             || (inst->DstReg.Index == VERT_RESULT_BFC0)
+             || (inst->DstReg.Index == VERT_RESULT_BFC1)) {
+            p->store[p->nr_insn-1].header.saturate = 1;
+         }
+      }
+
       release_tmps(c);
    }
 
+   end_inst = &p->store[p->nr_insn];
    emit_vertex_write(c);
-
+   post_vs_emit(c, end_inst);
+   for (insn = 0; insn < nr_insns; insn++)
+       c->vp->program.Base.Instructions[insn].Data = NULL;
 }
-
-
-
-
-
index c225bf8f5c5cb4c28f5ea6f493603eda9426f608..24bf5567bd08163529489396e1239e58573d624b 100644 (file)
 #include "brw_defines.h"
 #include "macros.h"
 
-static void upload_vs_unit( struct brw_context *brw )
-{
-   struct brw_vs_unit_state vs;
-
-   memset(&vs, 0, sizeof(vs));
-
-   /* CACHE_NEW_VS_PROG */
-   vs.thread0.kernel_start_pointer = brw->vs.prog_gs_offset >> 6;
-   vs.thread0.grf_reg_count = ((brw->vs.prog_data->total_grf-1) & ~15) / 16;
-   vs.thread3.urb_entry_read_length = brw->vs.prog_data->urb_read_length;
-   vs.thread3.const_urb_entry_read_length = brw->vs.prog_data->curb_read_length;
-   vs.thread3.dispatch_grf_start_reg = 1;
+struct brw_vs_unit_key {
+   unsigned int total_grf;
+   unsigned int urb_entry_read_length;
+   unsigned int curb_entry_read_length;
 
+   unsigned int curbe_offset;
 
-   /* BRW_NEW_URB_FENCE  */
-   vs.thread4.nr_urb_entries = brw->urb.nr_vs_entries; 
-   vs.thread4.urb_entry_allocation_size = brw->urb.vsize - 1;
-   vs.thread4.max_threads = MIN2(
-      MAX2(0, (brw->urb.nr_vs_entries - 6) / 2 - 1), 
-      15);
+   unsigned int nr_urb_entries, urb_size;
+};
 
+static void
+vs_unit_populate_key(struct brw_context *brw, struct brw_vs_unit_key *key)
+{
+   memset(key, 0, sizeof(*key));
 
+   /* CACHE_NEW_VS_PROG */
+   key->total_grf = brw->vs.prog_data->total_grf;
+   key->urb_entry_read_length = brw->vs.prog_data->urb_read_length;
+   key->curb_entry_read_length = brw->vs.prog_data->curb_read_length;
 
-   if (INTEL_DEBUG & DEBUG_SINGLE_THREAD)
-      vs.thread4.max_threads = 0; 
+   /* BRW_NEW_URB_FENCE */
+   key->nr_urb_entries = brw->urb.nr_vs_entries;
+   key->urb_size = brw->urb.vsize;
 
    /* BRW_NEW_CURBE_OFFSETS, _NEW_TRANSFORM */
    if (brw->attribs.Transform->ClipPlanesEnabled) {
       /* Note that we read in the userclip planes as well, hence
        * clip_start:
        */
-      vs.thread3.const_urb_entry_read_offset = brw->curbe.clip_start * 2;
+      key->curbe_offset = brw->curbe.clip_start;
    }
    else {
-      vs.thread3.const_urb_entry_read_offset = brw->curbe.vs_start * 2;
+      key->curbe_offset = brw->curbe.vs_start;
    }
+}
+
+static dri_bo *
+vs_unit_create_from_key(struct brw_context *brw, struct brw_vs_unit_key *key)
+{
+   struct brw_vs_unit_state vs;
+   dri_bo *bo;
+
+   memset(&vs, 0, sizeof(vs));
 
+   vs.thread0.kernel_start_pointer = brw->vs.prog_bo->offset >> 6; /* reloc */
+   vs.thread0.grf_reg_count = ALIGN(key->total_grf, 16) / 16 - 1;
    vs.thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
+   vs.thread3.urb_entry_read_length = key->urb_entry_read_length;
+   vs.thread3.const_urb_entry_read_length = key->curb_entry_read_length;
+   vs.thread3.dispatch_grf_start_reg = 1;
    vs.thread3.urb_entry_read_offset = 0;
+   vs.thread3.const_urb_entry_read_offset = key->curbe_offset * 2;
+
+   vs.thread4.nr_urb_entries = key->nr_urb_entries;
+   vs.thread4.urb_entry_allocation_size = key->urb_size - 1;
+   vs.thread4.max_threads = MIN2(MAX2(0, (key->nr_urb_entries - 6) / 2 - 1),
+                                15);
+
+   if (INTEL_DEBUG & DEBUG_SINGLE_THREAD)
+      vs.thread4.max_threads = 0;
 
    /* No samplers for ARB_vp programs:
     */
    vs.vs5.sampler_count = 0;
 
    if (INTEL_DEBUG & DEBUG_STATS)
-      vs.thread4.stats_enable = 1; 
+      vs.thread4.stats_enable = 1;
 
-   /* Vertex program always enabled: 
+   /* Vertex program always enabled:
     */
    vs.vs6.vs_enable = 1;
 
-   brw->vs.state_gs_offset = brw_cache_data( &brw->cache[BRW_VS_UNIT], &vs );
+   bo = brw_upload_cache(&brw->cache, BRW_VS_UNIT,
+                        key, sizeof(*key),
+                        &brw->vs.prog_bo, 1,
+                        &vs, sizeof(vs),
+                        NULL, NULL);
+
+   /* Emit VS program relocation */
+   dri_bo_emit_reloc(bo,
+                    I915_GEM_DOMAIN_INSTRUCTION, 0,
+                    vs.thread0.grf_reg_count << 1,
+                    offsetof(struct brw_vs_unit_state, thread0),
+                    brw->vs.prog_bo);
+
+   return bo;
 }
 
+static void prepare_vs_unit(struct brw_context *brw)
+{
+   struct brw_vs_unit_key key;
+
+   vs_unit_populate_key(brw, &key);
+
+   dri_bo_unreference(brw->vs.state_bo);
+   brw->vs.state_bo = brw_search_cache(&brw->cache, BRW_VS_UNIT,
+                                      &key, sizeof(key),
+                                      &brw->vs.prog_bo, 1,
+                                      NULL);
+   if (brw->vs.state_bo == NULL) {
+      brw->vs.state_bo = vs_unit_create_from_key(brw, &key);
+   }
+}
 
 const struct brw_tracked_state brw_vs_unit = {
    .dirty = {
@@ -98,5 +147,5 @@ const struct brw_tracked_state brw_vs_unit = {
                BRW_NEW_URB_FENCE),
       .cache = CACHE_NEW_VS_PROG
    },
-   .update = upload_vs_unit
+   .prepare = prepare_vs_unit,
 };
index b69be350a92b7bc34c66fd27ddbe783257517bbe..2caa020e611d3e32621af2ea32780f9838054def 100644 (file)
@@ -404,7 +404,7 @@ static struct ureg register_const4f( struct tnl_program *p,
    values[3] = s3;
    idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4,
                                      &swizzle);
-   /* XXX what about swizzle? */
+   assert(swizzle == SWIZZLE_NOOP); /* Need to handle swizzle in reg setup */
    return make_ureg(PROGRAM_STATE_VAR, idx);
 }
 
@@ -524,10 +524,13 @@ static void emit_op3fn(struct tnl_program *p,
    GLuint nr = p->program->Base.NumInstructions++;
       
    if (nr >= p->nr_instructions) {
+      int new_nr_instructions = p->nr_instructions * 2;
+
       p->program->Base.Instructions = 
         _mesa_realloc(p->program->Base.Instructions,
                       sizeof(struct prog_instruction) * p->nr_instructions,
-                      sizeof(struct prog_instruction) * (p->nr_instructions *= 2));
+                      sizeof(struct prog_instruction) * new_nr_instructions);
+      p->nr_instructions = new_nr_instructions;
    }
 
    {      
@@ -1000,13 +1003,19 @@ static void build_lighting( struct tnl_program *p )
                                               STATE_POSITION); 
            struct ureg V = get_eye_position(p);
            struct ureg dist = get_temp(p);
+           struct ureg tmpPpli = get_temp(p);
 
            VPpli = get_temp(p); 
            half = get_temp(p);
+
+           /* In homogeneous object coordinates
+            */
+           emit_op1(p, OPCODE_RCP, dist, 0, swizzle1(Ppli, W));
+           emit_op2(p, OPCODE_MUL, tmpPpli, 0, Ppli, dist);
  
            /* Calulate VPpli vector
             */
-           emit_op2(p, OPCODE_SUB, VPpli, 0, Ppli, V); 
+           emit_op2(p, OPCODE_SUB, VPpli, 0, tmpPpli, V); 
 
            /* Normalize VPpli.  The dist value also used in
             * attenuation below.
@@ -1038,6 +1047,7 @@ static void build_lighting( struct tnl_program *p )
            emit_normalize_vec3(p, half, half);
 
            release_temp(p, dist);
+           release_temp(p, tmpPpli);
         }
 
         /* Calculate dot products:
@@ -1162,6 +1172,11 @@ static void build_fog( struct tnl_program *p )
    }
    else {
       input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X);
+      if (p->state->fog_option &&
+         p->state->tnl_do_vertex_fog)
+         input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X);
+      else
+         input = register_input(p, VERT_ATTRIB_FOG);
    }
 
    if (p->state->fog_option &&
@@ -1566,7 +1581,7 @@ static GLuint hash_key( struct state_key *key )
    return hash;
 }
 
-static void update_tnl_program( struct brw_context *brw )
+static void prepare_tnl_program( struct brw_context *brw )
 {
    GLcontext *ctx = &brw->intel.ctx;
    struct state_key key;
@@ -1574,7 +1589,7 @@ static void update_tnl_program( struct brw_context *brw )
    struct gl_vertex_program *old = brw->tnl_program;
 
    /* _NEW_PROGRAM */
-   if (brw->attribs.VertexProgram->_Enabled
+   if (brw->attribs.VertexProgram->_Current
       return;
       
    /* Grab all the relevent state and put it in a single structure:
@@ -1608,6 +1623,7 @@ static void update_tnl_program( struct brw_context *brw )
 
    if (old != brw->tnl_program)
       brw->state.dirty.brw |= BRW_NEW_TNL_PROGRAM;
+   return;
 }
 
 /* Note: See brw_draw.c - the vertex program must not rely on
@@ -1621,24 +1637,25 @@ const struct brw_tracked_state brw_tnl_vertprog = {
               _NEW_FOG | 
               _NEW_HINT | 
               _NEW_POINT | 
-              _NEW_TEXTURE),
+              _NEW_TEXTURE |
+          _NEW_TEXTURE_MATRIX),
       .brw = (BRW_NEW_FRAGMENT_PROGRAM | 
              BRW_NEW_INPUT_VARYING),
       .cache = 0
    },
-   .update = update_tnl_program
+   .prepare = prepare_tnl_program
 };
 
 
 
 
-static void update_active_vertprog( struct brw_context *brw )
+static void prepare_active_vertprog( struct brw_context *brw )
 {
    const struct gl_vertex_program *prev = brw->vertex_program;
 
    /* NEW_PROGRAM */
-   if (brw->attribs.VertexProgram->_Enabled) {
-      brw->vertex_program = brw->attribs.VertexProgram->Current;
+   if (brw->attribs.VertexProgram->_Current) {
+      brw->vertex_program = brw->attribs.VertexProgram->_Current;
    }
    else {
       /* BRW_NEW_TNL_PROGRAM */
@@ -1657,7 +1674,7 @@ const struct brw_tracked_state brw_active_vertprog = {
       .brw = BRW_NEW_TNL_PROGRAM,
       .cache = 0
    },
-   .update = update_active_vertprog
+   .prepare = prepare_active_vertprog
 };
 
 
index 786f30e641efb23f5182ab7aedd3f0d42cdeabdf..31e96a250ac41ccfff7b848b2457f446009699c1 100644 (file)
 
 #include "brw_draw.h"
 #include "brw_state.h"
-#include "brw_aub.h"
 #include "brw_fallback.h"
 #include "brw_vs.h"
-
+#include <stdarg.h>
 
 
 /* called from intelDestroyContext()
@@ -60,8 +59,6 @@ static void brw_destroy_context( struct intel_context *intel )
    GLcontext *ctx = &intel->ctx;
    struct brw_context *brw = brw_context(&intel->ctx);
 
-   brw_aub_destroy(brw);
-
    brw_destroy_metaops(brw);
    brw_destroy_state(brw);
    brw_draw_destroy( brw );
@@ -73,38 +70,54 @@ static void brw_destroy_context( struct intel_context *intel )
 /* called from intelDrawBuffer()
  */
 static void brw_set_draw_region( struct intel_context *intel, 
-                                 struct intel_region *draw_region,
-                                 struct intel_region *depth_region)
+                                 struct intel_region *draw_regions[],
+                                 struct intel_region *depth_region,
+                               GLuint num_regions)
 {
    struct brw_context *brw = brw_context(&intel->ctx);
-
-   intel_region_release(intel, &brw->state.draw_region);
-   intel_region_release(intel, &brw->state.depth_region);
-   intel_region_reference(&brw->state.draw_region, draw_region);
+   int i;
+   if (brw->state.depth_region != depth_region)
+      brw->state.dirty.brw |= BRW_NEW_DEPTH_BUFFER;
+   for (i = 0; i < brw->state.nr_draw_regions; i++)
+       intel_region_release(&brw->state.draw_regions[i]);
+   intel_region_release(&brw->state.depth_region);
+   for (i = 0; i < num_regions; i++)
+       intel_region_reference(&brw->state.draw_regions[i], draw_regions[i]);
    intel_region_reference(&brw->state.depth_region, depth_region);
+   brw->state.nr_draw_regions = num_regions;
 }
 
 
 /* called from intelFlushBatchLocked
  */
-static void brw_lost_hardware( struct intel_context *intel )
+static void brw_new_batch( struct intel_context *intel )
 {
    struct brw_context *brw = brw_context(&intel->ctx);
 
-   /* Note that we effectively lose the context after this.
-    * 
-    * Setting this flag provokes a state buffer wrap and also flushes
-    * the hardware caches.
-    */
-   brw->state.dirty.brw |= BRW_NEW_CONTEXT;
+   /* Check that we didn't just wrap our batchbuffer at a bad time. */
+   assert(!brw->no_batch_wrap);
+
+   dri_bo_unreference(brw->curbe.curbe_bo);
+   brw->curbe.curbe_bo = NULL;
 
-   /* Which means there shouldn't be any commands already queued:
+   /* Mark all context state as needing to be re-emitted.
+    * This is probably not as severe as on 915, since almost all of our state
+    * is just in referenced buffers.
     */
-   assert(intel->batch->ptr == intel->batch->map + intel->batch->offset);
+   brw->state.dirty.brw |= BRW_NEW_CONTEXT;
 
    brw->state.dirty.mesa |= ~0;
    brw->state.dirty.brw |= ~0;
    brw->state.dirty.cache |= ~0;
+
+   /* Move to the end of the current upload buffer so that we'll force choosing
+    * a new buffer next time.
+    */
+   if (brw->vb.upload.bo != NULL) {
+      dri_bo_unreference(brw->vb.upload.bo);
+      brw->vb.upload.bo = NULL;
+      brw->vb.upload.offset = 0;
+   }
 }
 
 static void brw_note_fence( struct intel_context *intel, 
@@ -115,10 +128,9 @@ static void brw_note_fence( struct intel_context *intel,
  
 static void brw_note_unlock( struct intel_context *intel )
 {
-  struct brw_context *brw = brw_context(&intel->ctx);
+   struct brw_context *brw = brw_context(&intel->ctx);
 
-   brw_pool_check_wrap(brw, &brw->pool[BRW_GS_POOL]);
-   brw_pool_check_wrap(brw, &brw->pool[BRW_SS_POOL]);
+   brw_state_cache_check_size(brw);
 
    brw_context(&intel->ctx)->state.dirty.brw |= BRW_NEW_LOCK;
 }
@@ -156,9 +168,6 @@ static GLuint brw_flush_cmd( void )
    return *(GLuint *)&flush;
 }
 
-
-
-
 static void brw_invalidate_state( struct intel_context *intel, GLuint new_state )
 {
    /* nothing */
@@ -176,10 +185,11 @@ void brwInitVtbl( struct brw_context *brw )
    brw->intel.vtbl.invalidate_state = brw_invalidate_state; 
    brw->intel.vtbl.note_fence = brw_note_fence; 
    brw->intel.vtbl.note_unlock = brw_note_unlock; 
-   brw->intel.vtbl.lost_hardware = brw_lost_hardware;
+   brw->intel.vtbl.new_batch = brw_new_batch;
    brw->intel.vtbl.destroy = brw_destroy_context;
    brw->intel.vtbl.set_draw_region = brw_set_draw_region;
    brw->intel.vtbl.flush_cmd = brw_flush_cmd;
    brw->intel.vtbl.emit_flush = brw_emit_flush;
+   brw->intel.vtbl.debug_batch = brw_debug_batch;
 }
 
index 1497dc79687d0683e056b178a20111be996954c4..361312c2ca1a2df5b8749e736a68dcd82e13c11d 100644 (file)
   *   Keith Whitwell <keith@tungstengraphics.com>
   */
              
-
+#include "main/texformat.h"
 #include "brw_context.h"
 #include "brw_util.h"
 #include "brw_wm.h"
 #include "brw_state.h"
-#include "brw_hal.h"
 
 
 GLuint brw_wm_nr_args( GLuint opcode )
@@ -66,7 +65,11 @@ GLuint brw_wm_nr_args( GLuint opcode )
    case OPCODE_POW:
    case OPCODE_SUB:
    case OPCODE_SGE:
+   case OPCODE_SGT:
+   case OPCODE_SLE:
    case OPCODE_SLT:
+   case OPCODE_SEQ:
+   case OPCODE_SNE:
    case OPCODE_ADD:
    case OPCODE_MAX:
    case OPCODE_MIN:
@@ -116,20 +119,6 @@ GLuint brw_wm_is_scalar_result( GLuint opcode )
 }
 
 
-static void brw_wm_pass_hal (struct brw_wm_compile *c)
-{
-   static void (*hal_wm_pass) (struct brw_wm_compile *c);
-   static GLboolean hal_tried;
-   
-   if (!hal_tried)
-   {
-      hal_wm_pass = brw_hal_find_symbol ("intel_hal_wm_pass");
-      hal_tried = 1;
-   }
-   if (hal_wm_pass)
-      (*hal_wm_pass) (c);
-}
-
 static void do_wm_prog( struct brw_context *brw,
                        struct brw_fragment_program *fp, 
                        struct brw_wm_prog_key *key)
@@ -150,60 +139,53 @@ static void do_wm_prog( struct brw_context *brw,
    c->fp = fp;
    c->env_param = brw->intel.ctx.FragmentProgram.Parameters;
 
-
-   /* Augment fragment program.  Add instructions for pre- and
-    * post-fragment-program tasks such as interpolation and fogging.
-    */
-   brw_wm_pass_fp(c);
-   
-   /* Translate to intermediate representation.  Build register usage
-    * chains.
-    */
-   brw_wm_pass0(c);
-
-   /* Dead code removal.
-    */
-   brw_wm_pass1(c);
-
-   /* Hal optimization
-    */
-   brw_wm_pass_hal (c);
-   
-   /* Register allocation.
-    */
-   c->grf_limit = BRW_WM_MAX_GRF/2;
-
-   /* This is where we start emitting gen4 code:
-    */
-   brw_init_compile(&c->func);    
-
-   brw_wm_pass2(c);
-
-   c->prog_data.total_grf = c->max_wm_grf;
-   if (c->last_scratch) {
-      c->prog_data.total_scratch =
-        c->last_scratch + 0x40;
+    brw_init_compile(brw, &c->func);
+   if (brw_wm_is_glsl(&c->fp->program)) {
+       brw_wm_glsl_emit(brw, c);
    } else {
-      c->prog_data.total_scratch = 0;
+       /* Augment fragment program.  Add instructions for pre- and
+       * post-fragment-program tasks such as interpolation and fogging.
+       */
+       brw_wm_pass_fp(c);
+
+       /* Translate to intermediate representation.  Build register usage
+       * chains.
+       */
+       brw_wm_pass0(c);
+
+       /* Dead code removal.
+       */
+       brw_wm_pass1(c);
+
+       /* Register allocation.
+       */
+       c->grf_limit = BRW_WM_MAX_GRF/2;
+
+       brw_wm_pass2(c);
+
+       c->prog_data.total_grf = c->max_wm_grf;
+       if (c->last_scratch) {
+          c->prog_data.total_scratch =
+              c->last_scratch + 0x40;
+       } else {
+          c->prog_data.total_scratch = 0;
+       }
+
+       /* Emit GEN4 code.
+       */
+       brw_wm_emit(c);
    }
-
-   /* Emit GEN4 code.
-    */
-   brw_wm_emit(c);
-
    /* get the program
     */
    program = brw_get_program(&c->func, &program_size);
 
-   /*
-    */
-   brw->wm.prog_gs_offset = brw_upload_cache( &brw->cache[BRW_WM_PROG],
-                                             &c->key,
-                                             sizeof(c->key),
-                                             program,
-                                             program_size,
-                                             &c->prog_data,
-                                             &brw->wm.prog_data );
+   dri_bo_unreference(brw->wm.prog_bo);
+   brw->wm.prog_bo = brw_upload_cache( &brw->cache, BRW_WM_PROG,
+                                      &c->key, sizeof(c->key),
+                                      NULL, 0,
+                                      program, program_size,
+                                      &c->prog_data,
+                                      &brw->wm.prog_data );
 }
 
 
@@ -243,7 +225,8 @@ static void brw_wm_populate_key( struct brw_context *brw,
       lookup |= IZ_STENCIL_TEST_ENABLE_BIT;
 
       if (brw->attribs.Stencil->WriteMask[0] ||
-         (brw->attribs.Stencil->TestTwoSide && brw->attribs.Stencil->WriteMask[1]))
+         (brw->attribs.Stencil->_TestTwoSide &&
+          brw->attribs.Stencil->WriteMask[1]))
         lookup |= IZ_STENCIL_WRITE_ENABLE_BIT;
    }
 
@@ -285,7 +268,7 @@ static void brw_wm_populate_key( struct brw_context *brw,
 
 
    /* BRW_NEW_WM_INPUT_DIMENSIONS */
-   key->projtex_mask = brw->wm.input_size_masks[4-1]; 
+   key->projtex_mask = brw->wm.input_size_masks[4-1] >> (FRAG_ATTRIB_TEX0 - FRAG_ATTRIB_WPOS)
 
    /* _NEW_LIGHT */
    key->flat_shade = (brw->attribs.Light->ShadeModel == GL_FLAT);
@@ -296,17 +279,41 @@ static void brw_wm_populate_key( struct brw_context *brw,
       const struct gl_texture_object *t = unit->_Current;
 
       if (unit->_ReallyEnabled) {
-
-        if (t->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB &&
-            t->Image[0][t->BaseLevel]->_BaseFormat == GL_DEPTH_COMPONENT) {
-           key->shadowtex_mask |= 1<<i;
-        }
-
-        if (t->Image[0][t->BaseLevel]->InternalFormat == GL_YCBCR_MESA)
+        if (t->Image[0][t->BaseLevel]->InternalFormat == GL_YCBCR_MESA) {
            key->yuvtex_mask |= 1<<i;
+           if (t->Image[0][t->BaseLevel]->TexFormat->MesaFormat == 
+                   MESA_FORMAT_YCBCR)
+               key->yuvtex_swap_mask |= 1<< i;
+        }
       }
    }
-         
+
+   /* Shadow */
+   key->shadowtex_mask = fp->program.Base.ShadowSamplers;
+
+   /* _NEW_BUFFERS */
+   /*
+    * Include the draw buffer origin and height so that we can calculate
+    * fragment position values relative to the bottom left of the drawable,
+    * from the incoming screen origin relative position we get as part of our
+    * payload.
+    *
+    * We could avoid recompiling by including this as a constant referenced by
+    * our program, but if we were to do that it would also be nice to handle
+    * getting that constant updated at batchbuffer submit time (when we
+    * hold the lock and know where the buffer really is) rather than at emit
+    * time when we don't hold the lock and are just guessing.  We could also
+    * just avoid using this as key data if the program doesn't use
+    * fragment.position.
+    *
+    * This pretty much becomes moot with DRI2 and redirected buffers anyway,
+    * as our origins will always be zero then.
+    */
+   if (brw->intel.driDrawable != NULL) {
+      key->origin_x = brw->intel.driDrawable->x;
+      key->origin_y = brw->intel.driDrawable->y;
+      key->drawable_height = brw->intel.driDrawable->h;
+   }
 
    /* Extra info:
     */
@@ -315,7 +322,7 @@ static void brw_wm_populate_key( struct brw_context *brw,
 }
 
 
-static void brw_upload_wm_prog( struct brw_context *brw )
+static void brw_prepare_wm_prog(struct brw_context *brw)
 {
    struct brw_wm_prog_key key;
    struct brw_fragment_program *fp = (struct brw_fragment_program *)
@@ -325,13 +332,13 @@ static void brw_upload_wm_prog( struct brw_context *brw )
 
    /* Make an early check for the key.
     */
-   if (brw_search_cache(&brw->cache[BRW_WM_PROG], 
-                       &key, sizeof(key),
-                       &brw->wm.prog_data,
-                       &brw->wm.prog_gs_offset))
-      return;
-
-   do_wm_prog(brw, fp, &key);
+   dri_bo_unreference(brw->wm.prog_bo);
+   brw->wm.prog_bo = brw_search_cache(&brw->cache, BRW_WM_PROG,
+                                     &key, sizeof(key),
+                                     NULL, 0,
+                                     &brw->wm.prog_data);
+   if (brw->wm.prog_bo == NULL)
+      do_wm_prog(brw, fp, &key);
 }
 
 
@@ -345,12 +352,13 @@ const struct brw_tracked_state brw_wm_prog = {
                _NEW_POLYGON |
                _NEW_LINE |
                _NEW_LIGHT |
+               _NEW_BUFFERS |
                _NEW_TEXTURE),
       .brw   = (BRW_NEW_FRAGMENT_PROGRAM |
                BRW_NEW_WM_INPUT_DIMENSIONS |
                BRW_NEW_REDUCED_PRIMITIVE),
       .cache = 0
    },
-   .update = brw_upload_wm_prog
+   .prepare = brw_prepare_wm_prog
 };
 
index f5fddfdb68a7c9dd5a8170d48c7b8f3c6df8cf19..297617ee2dcf5d6814f101179972fa82611f380a 100644 (file)
@@ -34,9 +34,9 @@
 #define BRW_WM_H
 
 
+#include "shader/prog_instruction.h"
 #include "brw_context.h"
 #include "brw_eu.h"
-#include "prog_instruction.h"
 
 /* A big lookup table is used to figure out which and how many
  * additional regs will inserted before the main payload in the WM
@@ -69,9 +69,12 @@ struct brw_wm_prog_key {
    GLuint runtime_check_aads_emit:1;
    
    GLuint yuvtex_mask:8;
-   GLuint pad1:24;
+   GLuint yuvtex_swap_mask:8;  /* UV swaped */
+   GLuint pad1:16;
 
    GLuint program_string_id:32;
+   GLuint origin_x, origin_y;
+   GLuint drawable_height;
 };
 
 
@@ -140,6 +143,8 @@ struct brw_wm_instruction {
    GLuint writemask:4;
    GLuint tex_unit:4;   /* texture unit for TEX, TXD, TXP instructions */
    GLuint tex_idx:3;    /* TEXTURE_1D,2D,3D,CUBE,RECT_INDEX source target */
+   GLuint eot:1;       /* End of thread indicator for FB_WRITE*/
+   GLuint target:10;    /* target binding table index for FB_WRITE*/
 };
 
 
@@ -194,6 +199,8 @@ struct brw_wm_compile {
    GLuint nr_fp_insns;
    GLuint fp_temp;
    GLuint fp_interp_emitted;
+   GLuint fp_fragcolor_emitted;
+   GLuint fp_deriv_emitted;
 
    struct prog_src_register pixel_xy;
    struct prog_src_register delta_xy;
@@ -231,6 +238,15 @@ struct brw_wm_compile {
    GLuint grf_limit;
    GLuint max_wm_grf;
    GLuint last_scratch;
+
+   struct {
+       GLboolean inited;
+       struct brw_reg reg;
+   } wm_regs[PROGRAM_PAYLOAD+1][256][4];
+   struct brw_reg stack;
+   struct brw_reg emit_mask_reg;
+   GLuint reg_index;
+   GLuint tmp_index;
 };
 
 
@@ -259,4 +275,6 @@ void brw_wm_lookup_iz( GLuint line_aa,
                       GLuint lookup,
                       struct brw_wm_prog_key *key );
 
+GLboolean brw_wm_is_glsl(const struct gl_fragment_program *fp);
+void brw_wm_glsl_emit(struct brw_context *brw, struct brw_wm_compile *c);
 #endif
index fd605159727822c055e0f736ad1ffa0904654ecf..9b919b9cfed32941703b17cc5fa40288dca182df 100644 (file)
@@ -39,7 +39,7 @@
 /* Not quite sure how correct this is - need to understand horiz
  * vs. vertical strides a little better.
  */
-static __inline struct brw_reg sechalf( struct brw_reg reg )
+static INLINE struct brw_reg sechalf( struct brw_reg reg )
 {
    if (reg.vstride)
       reg.nr++;
@@ -122,26 +122,30 @@ static void emit_delta_xy(struct brw_compile *p,
    }
 }
 
-static void emit_wpos_xy(struct brw_compile *p,
-                          const struct brw_reg *dst,
-                          GLuint mask,
-                          const struct brw_reg *arg0)
+static void emit_wpos_xy(struct brw_wm_compile *c,
+                        const struct brw_reg *dst,
+                        GLuint mask,
+                        const struct brw_reg *arg0)
 {
-   /* Calc delta X,Y by subtracting origin in r1 from the pixel
-    * centers.
+   struct brw_compile *p = &c->func;
+
+   /* Calculate the pixel offset from window bottom left into destination
+    * X and Y channels.
     */
    if (mask & WRITEMASK_X) {
-      brw_MOV(p,
+      /* X' = X - origin */
+      brw_ADD(p,
              dst[0],
-             retype(arg0[0], BRW_REGISTER_TYPE_UW));
+             retype(arg0[0], BRW_REGISTER_TYPE_W),
+             brw_imm_d(0 - c->key.origin_x));
    }
 
    if (mask & WRITEMASK_Y) {
-      /* TODO -- window_height - Y */
-      brw_MOV(p,
+      /* Y' = height - (Y - origin_y) = height + origin_y - Y */
+      brw_ADD(p,
              dst[1],
-             negate(retype(arg0[1], BRW_REGISTER_TYPE_UW)));
-
+             negate(retype(arg0[1], BRW_REGISTER_TYPE_W)),
+             brw_imm_d(c->key.origin_y + c->key.drawable_height - 1));
    }
 }
 
@@ -219,6 +223,10 @@ static void emit_pinterp( struct brw_compile *p,
       if (mask & (1<<i)) {
         brw_LINE(p, brw_null_reg(), interp[i], deltas[0]);
         brw_MAC(p, dst[i], suboffset(interp[i],1), deltas[1]);
+      }
+   }
+   for(i = 0; i < 4; i++ ) {
+      if (mask & (1<<i)) {
         brw_MUL(p, dst[i], dst[i], w[3]);
       }
    }
@@ -229,20 +237,20 @@ static void emit_cinterp( struct brw_compile *p,
                         GLuint mask,
                         const struct brw_reg *arg0 )
 {
-   struct brw_reg interp[4];
-   GLuint nr = arg0[0].nr;
-   GLuint i;
-
-   interp[0] = brw_vec1_grf(nr, 0);
-   interp[1] = brw_vec1_grf(nr, 4);
-   interp[2] = brw_vec1_grf(nr+1, 0);
-   interp[3] = brw_vec1_grf(nr+1, 4);
-
-   for(i = 0; i < 4; i++ ) {
-      if (mask & (1<<i)) {
-        brw_MOV(p, dst[i], suboffset(interp[i],3));    /* TODO: optimize away like other moves */
-      }
-   }
+       struct brw_reg interp[4];
+       GLuint nr = arg0[0].nr;
+       GLuint i;
+
+       interp[0] = brw_vec1_grf(nr, 0);
+       interp[1] = brw_vec1_grf(nr, 4);
+       interp[2] = brw_vec1_grf(nr+1, 0);
+       interp[3] = brw_vec1_grf(nr+1, 4);
+
+       for(i = 0; i < 4; i++ ) {
+               if (mask & (1<<i)) {
+                       brw_MOV(p, dst[i], suboffset(interp[i],3));     /* TODO: optimize away like other moves */
+               }
+       }
 }
 
 
@@ -343,11 +351,10 @@ static void emit_lrp( struct brw_compile *p,
       }
    }
 }
-
-
-static void emit_slt( struct brw_compile *p, 
+static void emit_sop( struct brw_compile *p, 
                      const struct brw_reg *dst,
                      GLuint mask,
+                     GLuint cond,
                      const struct brw_reg *arg0,
                      const struct brw_reg *arg1 )
 {
@@ -356,34 +363,66 @@ static void emit_slt( struct brw_compile *p,
    for (i = 0; i < 4; i++) {
       if (mask & (1<<i)) {     
         brw_MOV(p, dst[i], brw_imm_f(0));
-        brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, arg0[i], arg1[i]);
+        brw_CMP(p, brw_null_reg(), cond, arg0[i], arg1[i]);
         brw_MOV(p, dst[i], brw_imm_f(1.0));
         brw_set_predicate_control_flag_value(p, 0xff);
       }
    }
 }
 
-/* Isn't this just the same as the above with the args swapped?
- */
-static void emit_sge( struct brw_compile *p, 
+static void emit_slt( struct brw_compile *p, 
                      const struct brw_reg *dst,
                      GLuint mask,
                      const struct brw_reg *arg0,
                      const struct brw_reg *arg1 )
 {
-   GLuint i;
+        emit_sop(p, dst, mask, BRW_CONDITIONAL_L, arg0, arg1);
+}
 
-   for (i = 0; i < 4; i++) {
-      if (mask & (1<<i)) {     
-        brw_MOV(p, dst[i], brw_imm_f(0));
-        brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_GE, arg0[i], arg1[i]);
-        brw_MOV(p, dst[i], brw_imm_f(1.0));
-        brw_set_predicate_control_flag_value(p, 0xff);
-      }
-   }
+static void emit_sle( struct brw_compile *p, 
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     const struct brw_reg *arg0,
+                     const struct brw_reg *arg1 )
+{
+        emit_sop(p, dst, mask, BRW_CONDITIONAL_LE, arg0, arg1);
 }
 
+static void emit_sgt( struct brw_compile *p, 
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     const struct brw_reg *arg0,
+                     const struct brw_reg *arg1 )
+{
+        emit_sop(p, dst, mask, BRW_CONDITIONAL_G, arg0, arg1);
+}
 
+static void emit_sge( struct brw_compile *p, 
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     const struct brw_reg *arg0,
+                     const struct brw_reg *arg1 )
+{
+        emit_sop(p, dst, mask, BRW_CONDITIONAL_GE, arg0, arg1);
+}
+
+static void emit_seq( struct brw_compile *p, 
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     const struct brw_reg *arg0,
+                     const struct brw_reg *arg1 )
+{
+        emit_sop(p, dst, mask, BRW_CONDITIONAL_EQ, arg0, arg1);
+}
+
+static void emit_sne( struct brw_compile *p, 
+                     const struct brw_reg *dst,
+                     GLuint mask,
+                     const struct brw_reg *arg0,
+                     const struct brw_reg *arg1 )
+{
+        emit_sop(p, dst, mask, BRW_CONDITIONAL_NEQ, arg0, arg1);
+}
 
 static void emit_cmp( struct brw_compile *p, 
                      const struct brw_reg *dst,
@@ -465,6 +504,9 @@ static void emit_dp3( struct brw_compile *p,
                      const struct brw_reg *arg0,
                      const struct brw_reg *arg1 )
 {
+   if (!(mask & WRITEMASK_XYZW))
+      return; /* Do not emit dead code*/
+
    assert((mask & WRITEMASK_XYZW) == WRITEMASK_X);
 
    brw_MUL(p, brw_null_reg(), arg0[0], arg1[0]);
@@ -482,6 +524,9 @@ static void emit_dp4( struct brw_compile *p,
                      const struct brw_reg *arg0,
                      const struct brw_reg *arg1 )
 {
+   if (!(mask & WRITEMASK_XYZW))
+      return; /* Do not emit dead code*/
+
    assert((mask & WRITEMASK_XYZW) == WRITEMASK_X);
 
    brw_MUL(p, brw_null_reg(), arg0[0], arg1[0]);
@@ -500,6 +545,9 @@ static void emit_dph( struct brw_compile *p,
                      const struct brw_reg *arg0,
                      const struct brw_reg *arg1 )
 {
+   if (!(mask & WRITEMASK_XYZW))
+      return; /* Do not emit dead code*/
+
    assert((mask & WRITEMASK_XYZW) == WRITEMASK_X);
 
    brw_MUL(p, brw_null_reg(), arg0[0], arg1[0]);
@@ -543,8 +591,11 @@ static void emit_math1( struct brw_compile *p,
                        GLuint mask,
                        const struct brw_reg *arg0 )
 {
-   assert((mask & WRITEMASK_XYZW) == WRITEMASK_X ||
-         function == BRW_MATH_FUNCTION_SINCOS);
+   if (!(mask & WRITEMASK_XYZW))
+      return; /* Do not emit dead code*/
+
+   //assert((mask & WRITEMASK_XYZW) == WRITEMASK_X ||
+   //    function == BRW_MATH_FUNCTION_SINCOS);
    
    brw_MOV(p, brw_message_reg(2), arg0[0]);
 
@@ -567,6 +618,9 @@ static void emit_math2( struct brw_compile *p,
                        const struct brw_reg *arg0,
                        const struct brw_reg *arg1)
 {
+   if (!(mask & WRITEMASK_XYZW))
+      return; /* Do not emit dead code*/
+
    assert((mask & WRITEMASK_XYZW) == WRITEMASK_X);
 
    brw_push_insn_state(p);
@@ -661,7 +715,7 @@ static void emit_tex( struct brw_wm_compile *c,
              retype(vec16(dst[0]), BRW_REGISTER_TYPE_UW),
              1,
              retype(c->payload.depth[0].hw_reg, BRW_REGISTER_TYPE_UW),
-             inst->tex_unit + 1, /* surface */
+             inst->tex_unit + MAX_DRAW_BUFFERS, /* surface */
              inst->tex_unit,     /* sampler */
              inst->writemask,
              (shadow ? 
@@ -670,7 +724,6 @@ static void emit_tex( struct brw_wm_compile *c,
              responseLength,
              msgLength,
              0);       
-
 }
 
 
@@ -712,7 +765,7 @@ static void emit_txb( struct brw_wm_compile *c,
              retype(vec16(dst[0]), BRW_REGISTER_TYPE_UW),
              1,
              retype(c->payload.depth[0].hw_reg, BRW_REGISTER_TYPE_UW),
-             inst->tex_unit + 1, /* surface */
+             inst->tex_unit + MAX_DRAW_BUFFERS, /* surface */
              inst->tex_unit,     /* sampler */
              inst->writemask,
              BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS,
@@ -777,6 +830,7 @@ static void emit_kil( struct brw_wm_compile *c,
       brw_push_insn_state(p);
       brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_GE, arg0[i], brw_imm_f(0));   
       brw_set_predicate_control_flag_value(p, 0xff);
+      brw_set_compression_control(p, BRW_COMPRESSION_NONE);
       brw_AND(p, r0uw, brw_flag_reg(), r0uw);
       brw_pop_insn_state(p);
    }
@@ -784,7 +838,9 @@ static void emit_kil( struct brw_wm_compile *c,
 
 static void fire_fb_write( struct brw_wm_compile *c,
                           GLuint base_reg,
-                          GLuint nr )
+                          GLuint nr,
+                          GLuint target,
+                          GLuint eot )
 {
    struct brw_compile *p = &c->func;
    
@@ -807,10 +863,10 @@ static void fire_fb_write( struct brw_wm_compile *c,
                retype(vec16(brw_null_reg()), BRW_REGISTER_TYPE_UW),
                base_reg,
                retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UW),
-               0,              /* render surface always 0 */
+               target,         
                nr,
                0, 
-               1);
+               eot);
 }
 
 static void emit_aa( struct brw_wm_compile *c,
@@ -835,7 +891,9 @@ static void emit_aa( struct brw_wm_compile *c,
 static void emit_fb_write( struct brw_wm_compile *c,
                           struct brw_reg *arg0,
                           struct brw_reg *arg1,
-                          struct brw_reg *arg2)
+                          struct brw_reg *arg2,
+                          GLuint target,
+                          GLuint eot)
 {
    struct brw_compile *p = &c->func;
    GLuint nr = 2;
@@ -890,15 +948,16 @@ static void emit_fb_write( struct brw_wm_compile *c,
       GLuint off = c->key.dest_depth_reg % 2;
 
       if (off != 0) {
-        brw_push_insn_state(p);
-        brw_set_compression_control(p, BRW_COMPRESSION_NONE);
-        brw_MOV(p, brw_message_reg(nr), arg1[comp]);
-        /* 2nd half? */
-        brw_MOV(p, brw_message_reg(nr+1), offset(arg1[comp],1));
-        brw_pop_insn_state(p);
+         brw_push_insn_state(p);
+         brw_set_compression_control(p, BRW_COMPRESSION_NONE);
+
+         brw_MOV(p, brw_message_reg(nr), offset(arg1[comp],1));
+         /* 2nd half? */
+         brw_MOV(p, brw_message_reg(nr+1), arg1[comp+1]);
+         brw_pop_insn_state(p);
       }
       else {
-        brw_MOV(p, brw_message_reg(nr), arg1[comp]);
+         brw_MOV(p, brw_message_reg(nr), arg1[comp]);
       }
       nr += 2;
    }
@@ -908,7 +967,7 @@ static void emit_fb_write( struct brw_wm_compile *c,
       if (c->key.aa_dest_stencil_reg)
         emit_aa(c, arg1, 2);
 
-      fire_fb_write(c, 0, nr);
+      fire_fb_write(c, 0, nr, target, eot);
    }
    else {
       struct brw_reg v1_null_ud = vec1(retype(brw_null_reg(), BRW_REGISTER_TYPE_UD));
@@ -925,14 +984,14 @@ static void emit_fb_write( struct brw_wm_compile *c,
       jmp = brw_JMPI(p, ip, ip, brw_imm_w(0));
       {
         emit_aa(c, arg1, 2);
-        fire_fb_write(c, 0, nr);
+        fire_fb_write(c, 0, nr, target, eot);
         /* note - thread killed in subroutine */
       }
       brw_land_fwd_jump(p, jmp);
 
       /* ELSE: Shuffle up one register to fill in the hole left for AA:
        */
-      fire_fb_write(c, 1, nr-1);
+      fire_fb_write(c, 1, nr-1, target, eot);
    }
 }
 
@@ -1080,7 +1139,7 @@ void brw_wm_emit( struct brw_wm_compile *c )
         break;
 
       case WM_WPOSXY:
-        emit_wpos_xy(p, dst, dst_flags, args[0]);
+        emit_wpos_xy(c, dst, dst_flags, args[0]);
         break;
 
       case WM_PIXELW:
@@ -1100,7 +1159,7 @@ void brw_wm_emit( struct brw_wm_compile *c )
         break;
 
       case WM_FB_WRITE:
-        emit_fb_write(c, args[0], args[1], args[2]);
+        emit_fb_write(c, args[0], args[1], args[2], inst->target, inst->eot);
         break;
 
         /* Straightforward arithmetic:
@@ -1208,9 +1267,21 @@ void brw_wm_emit( struct brw_wm_compile *c )
         emit_slt(p, dst, dst_flags, args[0], args[1]);
         break;
 
+      case OPCODE_SLE:
+        emit_sle(p, dst, dst_flags, args[0], args[1]);
+       break;
+      case OPCODE_SGT:
+        emit_sgt(p, dst, dst_flags, args[0], args[1]);
+       break;
       case OPCODE_SGE:
         emit_sge(p, dst, dst_flags, args[0], args[1]);
         break;
+      case OPCODE_SEQ:
+        emit_seq(p, dst, dst_flags, args[0], args[1]);
+       break;
+      case OPCODE_SNE:
+        emit_sne(p, dst, dst_flags, args[0], args[1]);
+       break;
 
       case OPCODE_LIT:
         emit_lit(p, dst, dst_flags, args[0]);
@@ -1231,7 +1302,8 @@ void brw_wm_emit( struct brw_wm_compile *c )
         break;
 
       default:
-        assert(0);
+       _mesa_printf("unsupport opcode %d in fragment program\n", 
+               inst->opcode);
       }
       
       for (i = 0; i < 4; i++)
index ff97d87dc45210f7f4ad1f5209b27e209dbcf62f..bc933fe7e4d060451d49b01f46f1592e05082cbe 100644 (file)
@@ -144,7 +144,7 @@ static struct prog_dst_register dst_undef( void )
 
 static struct prog_dst_register get_temp( struct brw_wm_compile *c )
 {
-   int bit = ffs( ~c->fp_temp );
+   int bit = _mesa_ffs( ~c->fp_temp );
 
    if (!bit) {
       _mesa_printf("%s: out of temporaries\n", __FILE__);
@@ -158,7 +158,7 @@ static struct prog_dst_register get_temp( struct brw_wm_compile *c )
 
 static void release_temp( struct brw_wm_compile *c, struct prog_dst_register temp )
 {
-   c->fp_temp &= ~1<<(temp.Index + 1 - FIRST_INTERNAL_TEMP);
+   c->fp_temp &= ~(1 << (temp.Index - FIRST_INTERNAL_TEMP));
 }
 
 
@@ -176,6 +176,7 @@ static struct prog_instruction *emit_insn(struct brw_wm_compile *c,
 {
    struct prog_instruction *inst = get_fp_inst(c);
    *inst = *inst0;
+   inst->Data = (void *)inst0;
    return inst;
 }
 
@@ -201,7 +202,6 @@ static struct prog_instruction * emit_op(struct brw_wm_compile *c,
    inst->SrcReg[0] = src0;
    inst->SrcReg[1] = src1;
    inst->SrcReg[2] = src2;
-   
    return inst;
 }
    
@@ -361,6 +361,37 @@ static void emit_interp( struct brw_wm_compile *c,
    c->fp_interp_emitted |= 1<<idx;
 }
 
+static void emit_ddx( struct brw_wm_compile *c,
+        const struct prog_instruction *inst )
+{
+    GLuint idx = inst->SrcReg[0].Index;
+    struct prog_src_register interp = src_reg(PROGRAM_PAYLOAD, idx);
+
+    c->fp_deriv_emitted |= 1<<idx;
+    emit_op(c,
+            OPCODE_DDX,
+            inst->DstReg,
+            0, 0, 0,
+            interp,
+            get_pixel_w(c),
+            src_undef());
+}
+
+static void emit_ddy( struct brw_wm_compile *c,
+        const struct prog_instruction *inst )
+{
+    GLuint idx = inst->SrcReg[0].Index;
+    struct prog_src_register interp = src_reg(PROGRAM_PAYLOAD, idx);
+
+    c->fp_deriv_emitted |= 1<<idx;
+    emit_op(c,
+            OPCODE_DDY,
+            inst->DstReg,
+            0, 0, 0,
+            interp,
+            get_pixel_w(c),
+            src_undef());
+}
 
 /***********************************************************************
  * Hacks to extend the program parameter and constant lists.
@@ -433,7 +464,7 @@ static struct prog_src_register search_or_add_const4f( struct brw_wm_compile *c,
    }
    
    idx = _mesa_add_unnamed_constant( paramList, values, 4, &swizzle );
-   /* XXX what about swizzle? */
+   assert(swizzle == SWIZZLE_NOOP); /* Need to handle swizzle in reg setup */
    return src_reg(PROGRAM_STATE_VAR, idx);
 }
 
@@ -463,17 +494,20 @@ static void precalc_dst( struct brw_wm_compile *c,
 
 
    if (dst.WriteMask & WRITEMASK_XZ) {
+      struct prog_instruction *swz;
       GLuint z = GET_SWZ(src0.Swizzle, Z);
 
       /* dst.xz = swz src0.1zzz
        */
-      emit_op(c,
-             OPCODE_SWZ,
-             dst_mask(dst, WRITEMASK_XZ),
-             inst->SaturateMode, 0, 0,
-             src_swizzle(src0, SWIZZLE_ONE, z, z, z),
-             src_undef(),
-             src_undef());
+      swz = emit_op(c,
+                   OPCODE_SWZ,
+                   dst_mask(dst, WRITEMASK_XZ),
+                   inst->SaturateMode, 0, 0,
+                   src_swizzle(src0, SWIZZLE_ONE, z, z, z),
+                   src_undef(),
+                   src_undef());
+      /* Avoid letting negation flag of src0 affect our 1 constant. */
+      swz->SrcReg[0].NegateBase &= ~NEGATE_X;
    }
    if (dst.WriteMask & WRITEMASK_W) {
       /* dst.w = mov src1.w
@@ -496,15 +530,19 @@ static void precalc_lit( struct brw_wm_compile *c,
    struct prog_dst_register dst = inst->DstReg;
    
    if (dst.WriteMask & WRITEMASK_XW) {
+      struct prog_instruction *swz;
+
       /* dst.xw = swz src0.1111
        */
-      emit_op(c,
-             OPCODE_SWZ,
-             dst_mask(dst, WRITEMASK_XW),
-             0, 0, 0,
-             src_swizzle1(src0, SWIZZLE_ONE),
-             src_undef(),
-             src_undef());
+      swz = emit_op(c,
+                   OPCODE_SWZ,
+                   dst_mask(dst, WRITEMASK_XW),
+                   0, 0, 0,
+                   src_swizzle1(src0, SWIZZLE_ONE),
+                   src_undef(),
+                   src_undef());
+      /* Avoid letting the negation flag of src0 affect our 1 constant. */
+      swz->SrcReg[0].NegateBase = 0;
    }
 
 
@@ -524,13 +562,64 @@ static void precalc_tex( struct brw_wm_compile *c,
 {
    struct prog_src_register coord;
    struct prog_dst_register tmpcoord;
-
-   if (inst->TexSrcTarget == TEXTURE_RECT_INDEX) {
+   GLuint unit = c->fp->program.Base.SamplerUnits[inst->TexSrcUnit];
+
+   if (inst->TexSrcTarget == TEXTURE_CUBE_INDEX) {
+       struct prog_instruction *out;
+       struct prog_dst_register tmp0 = get_temp(c);
+       struct prog_src_register tmp0src = src_reg_from_dst(tmp0);
+       struct prog_dst_register tmp1 = get_temp(c);
+       struct prog_src_register tmp1src = src_reg_from_dst(tmp1);
+       struct prog_src_register src0 = inst->SrcReg[0];
+
+       tmpcoord = get_temp(c);
+       coord = src_reg_from_dst(tmpcoord);
+
+       out = emit_op(c, OPCODE_MOV,
+                     tmpcoord,
+                     0, 0, 0,
+                     src0,
+                     src_undef(),
+                     src_undef());
+       out->SrcReg[0].NegateBase = 0;
+       out->SrcReg[0].Abs = 1;
+
+       emit_op(c, OPCODE_MAX,
+               tmp0,
+               0, 0, 0,
+               src_swizzle1(coord, X),
+               src_swizzle1(coord, Y),
+               src_undef());
+
+       emit_op(c, OPCODE_MAX,
+               tmp1,
+               0, 0, 0,
+               tmp0src,
+               src_swizzle1(coord, Z),
+               src_undef());
+
+       emit_op(c, OPCODE_RCP,
+               tmp0,
+               0, 0, 0,
+               tmp1src,
+               src_undef(),
+               src_undef());
+
+       emit_op(c, OPCODE_MUL,
+               tmpcoord,
+               0, 0, 0,
+               src0,
+               tmp0src,
+               src_undef());
+
+       release_temp(c, tmp0);
+       release_temp(c, tmp1);
+   } else if (inst->TexSrcTarget == TEXTURE_RECT_INDEX) {
       struct prog_src_register scale = 
         search_or_add_param5( c, 
                               STATE_INTERNAL, 
                               STATE_TEXRECT_SCALE,
-                              inst->TexSrcUnit,
+                              unit,
                               0,0 );
 
       tmpcoord = get_temp(c);
@@ -556,29 +645,33 @@ static void precalc_tex( struct brw_wm_compile *c,
     * conversion requires allocating a temporary variable which we
     * don't have the facility to do that late in the compilation.
     */
-   if (!(c->key.yuvtex_mask & (1<<inst->TexSrcUnit))) {
+   if (!(c->key.yuvtex_mask & (1<<unit))) {
       emit_op(c, 
              OPCODE_TEX,
              inst->DstReg,
              inst->SaturateMode,
-             inst->TexSrcUnit,
+             unit,
              inst->TexSrcTarget,
              coord,
              src_undef(),
              src_undef());
    }
    else {
+       GLboolean  swap_uv = c->key.yuvtex_swap_mask & (1<<unit);
+
       /* 
         CONST C0 = { -.5, -.0625,  -.5, 1.164 }
         CONST C1 = { 1.596, -0.813, 2.018, -.391 }
         UYV     = TEX ...
         UYV.xyz = ADD UYV,     C0
         UYV.y   = MUL UYV.y,   C0.w
-        RGB.xyz = MAD UYV.xxz, C1,   UYV.y
+        if (UV swaped)
+           RGB.xyz = MAD UYV.zzx, C1,   UYV.y
+        else
+           RGB.xyz = MAD UYV.xxz, C1,   UYV.y 
         RGB.y   = MAD UYV.z,   C1.w, RGB.y
       */
       struct prog_dst_register dst = inst->DstReg;
-      struct prog_src_register src0 = inst->SrcReg[0];
       struct prog_dst_register tmp = get_temp(c);
       struct prog_src_register tmpsrc = src_reg_from_dst(tmp);
       struct prog_src_register C0 = search_or_add_const4f( c,  -.5, -.0625, -.5, 1.164 );
@@ -590,9 +683,9 @@ static void precalc_tex( struct brw_wm_compile *c,
              OPCODE_TEX,
              tmp,
              inst->SaturateMode,
-             inst->TexSrcUnit,
+             unit,
              inst->TexSrcTarget,
-             src0,
+             coord,
              src_undef(),
              src_undef());
 
@@ -608,6 +701,7 @@ static void precalc_tex( struct brw_wm_compile *c,
 
       /* YUV.y   = MUL YUV.y, C0.w
        */
+
       emit_op(c,
              OPCODE_MUL,
              dst_mask(tmp, WRITEMASK_Y),
@@ -616,13 +710,18 @@ static void precalc_tex( struct brw_wm_compile *c,
              src_swizzle1(C0, W),
              src_undef());
 
-      /* RGB.xyz = MAD YUV.xxz, C1, YUV.y
+      /* 
+       * if (UV swaped)
+       *     RGB.xyz = MAD YUV.zzx, C1, YUV.y
+       * else
+       *     RGB.xyz = MAD YUV.xxz, C1, YUV.y
        */
+
       emit_op(c,
              OPCODE_MAD,
              dst_mask(dst, WRITEMASK_XYZ),
              0, 0, 0,
-             src_swizzle(tmpsrc, X,X,Z,Z),
+             swap_uv?src_swizzle(tmpsrc, Z,Z,X,X):src_swizzle(tmpsrc, X,X,Z,Z),
              C1,
              src_swizzle1(tmpsrc, Y));
 
@@ -639,7 +738,8 @@ static void precalc_tex( struct brw_wm_compile *c,
       release_temp(c, tmp);
    }
 
-   if (inst->TexSrcTarget == GL_TEXTURE_RECTANGLE_NV) 
+   if ((inst->TexSrcTarget == TEXTURE_RECT_INDEX) ||
+       (inst->TexSrcTarget == TEXTURE_CUBE_INDEX))
       release_temp(c, tmpcoord);
 }
 
@@ -660,7 +760,7 @@ static GLboolean projtex( struct brw_wm_compile *c,
       return 0;  /* ut2004 gun rendering !?! */
    else if (src.File == PROGRAM_INPUT && 
            GET_SWZ(src.Swizzle, W) == W &&
-           (c->key.projtex_mask & (1<<src.Index)) == 0)
+           (c->key.projtex_mask & (1<<(src.Index + FRAG_ATTRIB_WPOS - FRAG_ATTRIB_TEX0))) == 0)
       return 0;
    else
       return 1;
@@ -770,14 +870,34 @@ static void emit_fb_write( struct brw_wm_compile *c )
    struct prog_src_register outcolor = src_reg(PROGRAM_OUTPUT, FRAG_RESULT_COLR);
    struct prog_src_register payload_r0_depth = src_reg(PROGRAM_PAYLOAD, PAYLOAD_DEPTH);
    struct prog_src_register outdepth = src_reg(PROGRAM_OUTPUT, FRAG_RESULT_DEPR);
+   GLuint i;
 
-   emit_op(c,
-          WM_FB_WRITE,
-          dst_mask(dst_undef(),0),
-          0, 0, 0,
-          outcolor,
-          payload_r0_depth,
-          outdepth);
+   struct prog_instruction *inst, *last_inst;
+   struct brw_context *brw = c->func.brw;
+
+   /* inst->Sampler is not used by backend, 
+      use it for fb write target and eot */
+
+   if (brw->state.nr_draw_regions > 1) {
+       for (i = 0 ; i < brw->state.nr_draw_regions; i++) {
+          outcolor = src_reg(PROGRAM_OUTPUT, FRAG_RESULT_DATA0 + i);
+          last_inst = inst = emit_op(c,
+                  WM_FB_WRITE, dst_mask(dst_undef(),0), 0, 0, 0,
+                  outcolor, payload_r0_depth, outdepth);
+          inst->Sampler = (i<<1);
+          if (c->fp_fragcolor_emitted) {
+              outcolor = src_reg(PROGRAM_OUTPUT, FRAG_RESULT_COLR);
+              last_inst = inst = emit_op(c, WM_FB_WRITE, dst_mask(dst_undef(),0),
+                      0, 0, 0, outcolor, payload_r0_depth, outdepth);
+              inst->Sampler = (i<<1);
+          }
+       }
+       last_inst->Sampler |= 1; //eot
+   }else {
+       inst = emit_op(c, WM_FB_WRITE, dst_mask(dst_undef(),0),
+              0, 0, 0, outcolor, payload_r0_depth, outdepth);
+       inst->Sampler = 1|(0<<1);
+   }
 }
 
 
@@ -803,7 +923,15 @@ static void validate_src_regs( struct brw_wm_compile *c,
    }
 }
         
-
+static void validate_dst_regs( struct brw_wm_compile *c,
+                              const struct prog_instruction *inst )
+{
+   if (inst->DstReg.File == PROGRAM_OUTPUT) {
+       GLuint idx = inst->DstReg.Index;
+       if (idx == FRAG_RESULT_COLR)
+          c->fp_fragcolor_emitted = 1;
+   }
+}
 
 static void print_insns( const struct prog_instruction *insn,
                         GLuint nr )
@@ -846,6 +974,11 @@ void brw_wm_pass_fp( struct brw_wm_compile *c )
     */
 
 
+   for (insn = 0; insn < fp->program.Base.NumInstructions; insn++) {
+      const struct prog_instruction *inst = &fp->program.Base.Instructions[insn];
+      validate_src_regs(c, inst);
+      validate_dst_regs(c, inst);
+   }
    for (insn = 0; insn < fp->program.Base.NumInstructions; insn++) {
       const struct prog_instruction *inst = &fp->program.Base.Instructions[insn];
       struct prog_instruction *out;
@@ -853,7 +986,6 @@ void brw_wm_pass_fp( struct brw_wm_compile *c )
       /* Check for INPUT values, emit INTERP instructions where
        * necessary:
        */
-      validate_src_regs(c, inst);
 
 
       switch (inst->Opcode) {
@@ -889,11 +1021,20 @@ void brw_wm_pass_fp( struct brw_wm_compile *c )
       case OPCODE_LIT:
         precalc_lit(c, inst);
         break;
-     
+
+      case OPCODE_TEX:
+        precalc_tex(c, inst);
+        break;
+
       case OPCODE_TXP:
         precalc_txp(c, inst);
         break;
 
+      case OPCODE_TXB:
+        out = emit_insn(c, inst);
+        out->TexSrcUnit = fp->program.Base.SamplerUnits[inst->TexSrcUnit];
+        break;
+
       case OPCODE_XPD: 
         out = emit_insn(c, inst);
         /* This should probably be done in the parser. 
@@ -907,8 +1048,16 @@ void brw_wm_pass_fp( struct brw_wm_compile *c )
          */
         out->DstReg.WriteMask = 0;
         break;
-
+      case OPCODE_DDX:
+        emit_ddx(c, inst);
+        break;
+      case OPCODE_DDY:
+         emit_ddy(c, inst);
+       break;
       case OPCODE_END:
+        emit_fog(c);
+        emit_fb_write(c);
+        break;
       case OPCODE_PRINT:
         break;
         
@@ -917,15 +1066,11 @@ void brw_wm_pass_fp( struct brw_wm_compile *c )
         break;
       }
    }
-   
-   emit_fog(c);
-   emit_fb_write(c);
-
 
    if (INTEL_DEBUG & DEBUG_WM) {
-      _mesa_printf("\n\n\npass_fp:\n");
-      print_insns( c->prog_instructions, c->nr_fp_insns );
-      _mesa_printf("\n");
+          _mesa_printf("\n\n\npass_fp:\n");
+          print_insns( c->prog_instructions, c->nr_fp_insns );
+          _mesa_printf("\n");
    }
 }
 
diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c
new file mode 100644 (file)
index 0000000..8dce40f
--- /dev/null
@@ -0,0 +1,1375 @@
+#include "macros.h"
+#include "shader/prog_parameter.h"
+#include "brw_context.h"
+#include "brw_eu.h"
+#include "brw_wm.h"
+
+/* Only guess, need a flag in gl_fragment_program later */
+GLboolean brw_wm_is_glsl(const struct gl_fragment_program *fp)
+{
+    int i;
+    for (i = 0; i < fp->Base.NumInstructions; i++) {
+       struct prog_instruction *inst = &fp->Base.Instructions[i];
+       switch (inst->Opcode) {
+           case OPCODE_IF:
+           case OPCODE_INT:
+           case OPCODE_ENDIF:
+           case OPCODE_CAL:
+           case OPCODE_BRK:
+           case OPCODE_RET:
+           case OPCODE_DDX:
+           case OPCODE_DDY:
+           case OPCODE_BGNLOOP:
+               return GL_TRUE; 
+           default:
+               break;
+       }
+    }
+    return GL_FALSE; 
+}
+
+static void set_reg(struct brw_wm_compile *c, int file, int index, 
+       int component, struct brw_reg reg)
+{
+    c->wm_regs[file][index][component].reg = reg;
+    c->wm_regs[file][index][component].inited = GL_TRUE;
+}
+
+static int get_scalar_dst_index(struct prog_instruction *inst)
+{
+    int i;
+    for (i = 0; i < 4; i++)
+       if (inst->DstReg.WriteMask & (1<<i))
+           break;
+    return i;
+}
+
+static struct brw_reg alloc_tmp(struct brw_wm_compile *c)
+{
+    struct brw_reg reg;
+    reg = brw_vec8_grf(c->tmp_index--, 0);
+    return reg;
+}
+
+static void release_tmps(struct brw_wm_compile *c)
+{
+    c->tmp_index = 127;
+}
+
+static struct brw_reg 
+get_reg(struct brw_wm_compile *c, int file, int index, int component, int nr, GLuint neg, GLuint abs)
+{
+    struct brw_reg reg;
+    switch (file) {
+       case PROGRAM_STATE_VAR:
+       case PROGRAM_CONSTANT:
+       case PROGRAM_UNIFORM:
+           file = PROGRAM_STATE_VAR;
+           break;
+       case PROGRAM_UNDEFINED:
+           return brw_null_reg();      
+       default:
+           break;
+    }
+
+    if(c->wm_regs[file][index][component].inited)
+       reg = c->wm_regs[file][index][component].reg;
+    else 
+       reg = brw_vec8_grf(c->reg_index, 0);
+
+    if(!c->wm_regs[file][index][component].inited) {
+       set_reg(c, file, index, component, reg);
+       c->reg_index++;
+    }
+
+    if (neg & (1<< component)) {
+       reg = negate(reg);
+    }
+    if (abs)
+       reg = brw_abs(reg);
+    return reg;
+}
+
+static void prealloc_reg(struct brw_wm_compile *c)
+{
+    int i, j;
+    struct brw_reg reg;
+    int nr_interp_regs = 0;
+    GLuint inputs = FRAG_BIT_WPOS | c->fp_interp_emitted | c->fp_deriv_emitted;
+
+    for (i = 0; i < 4; i++) {
+       reg = (i < c->key.nr_depth_regs) 
+           ? brw_vec8_grf(i*2, 0) : brw_vec8_grf(0, 0);
+       set_reg(c, PROGRAM_PAYLOAD, PAYLOAD_DEPTH, i, reg);
+    }
+    c->reg_index += 2*c->key.nr_depth_regs;
+    {
+       int nr_params = c->fp->program.Base.Parameters->NumParameters;
+       struct gl_program_parameter_list *plist = 
+           c->fp->program.Base.Parameters;
+       int index = 0;
+       c->prog_data.nr_params = 4*nr_params;
+       for (i = 0; i < nr_params; i++) {
+           for (j = 0; j < 4; j++, index++) {
+               reg = brw_vec1_grf(c->reg_index + index/8, 
+                       index%8);
+               c->prog_data.param[index] = 
+                   &plist->ParameterValues[i][j];
+               set_reg(c, PROGRAM_STATE_VAR, i, j, reg);
+           }
+       }
+       c->nr_creg = 2*((4*nr_params+15)/16);
+       c->reg_index += c->nr_creg;
+    }
+    for (i = 0; i < FRAG_ATTRIB_MAX; i++) {
+       if (inputs & (1<<i)) {
+           nr_interp_regs++;
+           reg = brw_vec8_grf(c->reg_index, 0);
+           for (j = 0; j < 4; j++)
+               set_reg(c, PROGRAM_PAYLOAD, i, j, reg);
+           c->reg_index += 2;
+
+       }
+    }
+    c->prog_data.first_curbe_grf = c->key.nr_depth_regs * 2;
+    c->prog_data.urb_read_length = nr_interp_regs * 2;
+    c->prog_data.curb_read_length = c->nr_creg;
+    c->emit_mask_reg = brw_uw1_reg(BRW_GENERAL_REGISTER_FILE, c->reg_index, 0);
+    c->reg_index++;
+    c->stack =  brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, c->reg_index, 0);
+    c->reg_index += 2;
+}
+
+static struct brw_reg get_dst_reg(struct brw_wm_compile *c, 
+       struct prog_instruction *inst, int component, int nr)
+{
+    return get_reg(c, inst->DstReg.File, inst->DstReg.Index, component, nr,
+           0, 0);
+}
+
+static struct brw_reg get_src_reg(struct brw_wm_compile *c, 
+       struct prog_src_register *src, int index, int nr)
+{
+    int component = GET_SWZ(src->Swizzle, index);
+    return get_reg(c, src->File, src->Index, component, nr, 
+           src->NegateBase, src->Abs);
+}
+
+static void emit_abs( struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    int i;
+    struct brw_compile *p = &c->func;
+    brw_set_saturate(p, inst->SaturateMode != SATURATE_OFF);
+    for (i = 0; i < 4; i++) {
+       if (inst->DstReg.WriteMask & (1<<i)) {
+           struct brw_reg src, dst;
+           dst = get_dst_reg(c, inst, i, 1);
+           src = get_src_reg(c, &inst->SrcReg[0], i, 1);
+           brw_MOV(p, dst, brw_abs(src));
+       }
+    }
+    brw_set_saturate(p, 0);
+}
+
+static void emit_int( struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    int i;
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    brw_set_saturate(p, inst->SaturateMode != SATURATE_OFF);
+    for (i = 0; i < 4; i++) {
+       if (mask & (1<<i)) {
+           struct brw_reg src, dst;
+           dst = get_dst_reg(c, inst, i, 1) ;
+           src = get_src_reg(c, &inst->SrcReg[0], i, 1);
+           brw_RNDD(p, dst, src);
+       }
+    }
+    brw_set_saturate(p, 0);
+}
+
+static void emit_mov( struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    int i;
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    brw_set_saturate(p, inst->SaturateMode != SATURATE_OFF);
+    for (i = 0; i < 4; i++) {
+       if (mask & (1<<i)) {
+           struct brw_reg src, dst;
+           dst = get_dst_reg(c, inst, i, 1);
+           src = get_src_reg(c, &inst->SrcReg[0], i, 1);
+           brw_MOV(p, dst, src);
+       }
+    }
+    brw_set_saturate(p, 0);
+}
+
+static void emit_pixel_xy(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    struct brw_reg r1 = brw_vec1_grf(1, 0);
+    struct brw_reg r1_uw = retype(r1, BRW_REGISTER_TYPE_UW);
+
+    struct brw_reg dst0, dst1;
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+
+    dst0 = get_dst_reg(c, inst, 0, 1);
+    dst1 = get_dst_reg(c, inst, 1, 1);
+    /* Calculate pixel centers by adding 1 or 0 to each of the
+     * micro-tile coordinates passed in r1.
+     */
+    if (mask & WRITEMASK_X) {
+       brw_ADD(p,
+               vec8(retype(dst0, BRW_REGISTER_TYPE_UW)),
+               stride(suboffset(r1_uw, 4), 2, 4, 0),
+               brw_imm_v(0x10101010));
+    }
+
+    if (mask & WRITEMASK_Y) {
+       brw_ADD(p,
+               vec8(retype(dst1, BRW_REGISTER_TYPE_UW)),
+               stride(suboffset(r1_uw, 5), 2, 4, 0),
+               brw_imm_v(0x11001100));
+    }
+
+}
+
+static void emit_delta_xy(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    struct brw_reg r1 = brw_vec1_grf(1, 0);
+    struct brw_reg dst0, dst1, src0, src1;
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+
+    dst0 = get_dst_reg(c, inst, 0, 1);
+    dst1 = get_dst_reg(c, inst, 1, 1);
+    src0 = get_src_reg(c, &inst->SrcReg[0], 0, 1);
+    src1 = get_src_reg(c, &inst->SrcReg[0], 1, 1);
+    /* Calc delta X,Y by subtracting origin in r1 from the pixel
+     * centers.
+     */
+    if (mask & WRITEMASK_X) {
+       brw_ADD(p,
+               dst0,
+               retype(src0, BRW_REGISTER_TYPE_UW),
+               negate(r1));
+    }
+
+    if (mask & WRITEMASK_Y) {
+       brw_ADD(p,
+               dst1,
+               retype(src1, BRW_REGISTER_TYPE_UW),
+               negate(suboffset(r1,1)));
+
+    }
+
+}
+
+
+static void fire_fb_write( struct brw_wm_compile *c,
+                           GLuint base_reg,
+                           GLuint nr,
+                           GLuint target,
+                           GLuint eot)
+{
+    struct brw_compile *p = &c->func;
+    /* Pass through control information:
+     */
+    /*  mov (8) m1.0<1>:ud   r1.0<8;8,1>:ud   { Align1 NoMask } */
+    {
+       brw_push_insn_state(p);
+       brw_set_mask_control(p, BRW_MASK_DISABLE); /* ? */
+       brw_MOV(p,
+               brw_message_reg(base_reg + 1),
+               brw_vec8_grf(1, 0));
+       brw_pop_insn_state(p);
+    }
+    /* Send framebuffer write message: */
+    brw_fb_WRITE(p,
+           retype(vec8(brw_null_reg()), BRW_REGISTER_TYPE_UW),
+           base_reg,
+           retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UW),
+           target,              
+           nr,
+           0,
+           eot);
+}
+
+static void emit_fb_write(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    int nr = 2;
+    int channel;
+    GLuint target, eot;
+    struct brw_reg src0;
+
+    /* Reserve a space for AA - may not be needed:
+     */
+    if (c->key.aa_dest_stencil_reg)
+       nr += 1;
+    {
+       brw_push_insn_state(p);
+       for (channel = 0; channel < 4; channel++) {
+           src0 = get_src_reg(c,  &inst->SrcReg[0], channel, 1);
+           /*  mov (8) m2.0<1>:ud   r28.0<8;8,1>:ud  { Align1 } */
+           /*  mov (8) m6.0<1>:ud   r29.0<8;8,1>:ud  { Align1 SecHalf } */
+           brw_MOV(p, brw_message_reg(nr + channel), src0);
+       }
+       /* skip over the regs populated above: */
+       nr += 8;
+       brw_pop_insn_state(p);
+    }
+
+   if (c->key.source_depth_to_render_target)
+   {
+      if (c->key.computes_depth) {
+         src0 = get_src_reg(c, &inst->SrcReg[2], 2, 1);
+         brw_MOV(p, brw_message_reg(nr), src0);
+      } else {
+         src0 = get_src_reg(c, &inst->SrcReg[1], 1, 1);
+         brw_MOV(p, brw_message_reg(nr), src0);
+      }
+
+      nr += 2;
+   }
+    target = inst->Sampler >> 1;
+    eot = inst->Sampler & 1;
+    fire_fb_write(c, 0, nr, target, eot);
+}
+
+static void emit_pixel_w( struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    if (mask & WRITEMASK_W) {
+       struct brw_reg dst, src0, delta0, delta1;
+       struct brw_reg interp3;
+
+       dst = get_dst_reg(c, inst, 3, 1);
+       src0 = get_src_reg(c, &inst->SrcReg[0], 0, 1);
+       delta0 = get_src_reg(c, &inst->SrcReg[1], 0, 1);
+       delta1 = get_src_reg(c, &inst->SrcReg[1], 1, 1);
+
+       interp3 = brw_vec1_grf(src0.nr+1, 4);
+       /* Calc 1/w - just linterp wpos[3] optimized by putting the
+        * result straight into a message reg.
+        */
+       brw_LINE(p, brw_null_reg(), interp3, delta0);
+       brw_MAC(p, brw_message_reg(2), suboffset(interp3, 1), delta1);
+
+       /* Calc w */
+       brw_math_16( p, dst,
+               BRW_MATH_FUNCTION_INV,
+               BRW_MATH_SATURATE_NONE,
+               2, brw_null_reg(),
+               BRW_MATH_PRECISION_FULL);
+    }
+}
+
+static void emit_linterp(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    struct brw_reg interp[4];
+    struct brw_reg dst, delta0, delta1;
+    struct brw_reg src0;
+
+    src0 = get_src_reg(c, &inst->SrcReg[0], 0, 1);
+    delta0 = get_src_reg(c, &inst->SrcReg[1], 0, 1);
+    delta1 = get_src_reg(c, &inst->SrcReg[1], 1, 1);
+    GLuint nr = src0.nr;
+    int i;
+
+    interp[0] = brw_vec1_grf(nr, 0);
+    interp[1] = brw_vec1_grf(nr, 4);
+    interp[2] = brw_vec1_grf(nr+1, 0);
+    interp[3] = brw_vec1_grf(nr+1, 4);
+
+    for(i = 0; i < 4; i++ ) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i, 1);
+           brw_LINE(p, brw_null_reg(), interp[i], delta0);
+           brw_MAC(p, dst, suboffset(interp[i],1), delta1);
+       }
+    }
+}
+
+static void emit_cinterp(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+
+    struct brw_reg interp[4];
+    struct brw_reg dst, src0;
+
+    src0 = get_src_reg(c, &inst->SrcReg[0], 0, 1);
+    GLuint nr = src0.nr;
+    int i;
+
+    interp[0] = brw_vec1_grf(nr, 0);
+    interp[1] = brw_vec1_grf(nr, 4);
+    interp[2] = brw_vec1_grf(nr+1, 0);
+    interp[3] = brw_vec1_grf(nr+1, 4);
+
+    for(i = 0; i < 4; i++ ) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i, 1);
+           brw_MOV(p, dst, suboffset(interp[i],3));
+       }
+    }
+}
+
+static void emit_pinterp(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+
+    struct brw_reg interp[4];
+    struct brw_reg dst, delta0, delta1;
+    struct brw_reg src0, w;
+
+    src0 = get_src_reg(c, &inst->SrcReg[0], 0, 1);
+    delta0 = get_src_reg(c, &inst->SrcReg[1], 0, 1);
+    delta1 = get_src_reg(c, &inst->SrcReg[1], 1, 1);
+    w = get_src_reg(c, &inst->SrcReg[2], 3, 1);
+    GLuint nr = src0.nr;
+    int i;
+
+    interp[0] = brw_vec1_grf(nr, 0);
+    interp[1] = brw_vec1_grf(nr, 4);
+    interp[2] = brw_vec1_grf(nr+1, 0);
+    interp[3] = brw_vec1_grf(nr+1, 4);
+
+    for(i = 0; i < 4; i++ ) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i, 1);
+           brw_LINE(p, brw_null_reg(), interp[i], delta0);
+           brw_MAC(p, dst, suboffset(interp[i],1), 
+                   delta1);
+           brw_MUL(p, dst, dst, w);
+       }
+    }
+}
+
+static void emit_xpd(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    int i;
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    for (i = 0; i < 4; i++) {
+       GLuint i2 = (i+2)%3;
+       GLuint i1 = (i+1)%3;
+       if (mask & (1<<i)) {
+           struct brw_reg src0, src1, dst;
+           dst = get_dst_reg(c, inst, i, 1);
+           src0 = negate(get_src_reg(c, &inst->SrcReg[0], i2, 1));
+           src1 = get_src_reg(c, &inst->SrcReg[1], i1, 1);
+           brw_MUL(p, brw_null_reg(), src0, src1);
+           src0 = get_src_reg(c, &inst->SrcReg[0], i1, 1);
+           src1 = get_src_reg(c, &inst->SrcReg[1], i2, 1);
+           brw_set_saturate(p, inst->SaturateMode != SATURATE_OFF);
+           brw_MAC(p, dst, src0, src1);
+           brw_set_saturate(p, 0);
+       }
+    }
+    brw_set_saturate(p, 0);
+}
+
+static void emit_dp3(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    struct brw_reg src0[3], src1[3], dst;
+    int i;
+    struct brw_compile *p = &c->func;
+    for (i = 0; i < 3; i++) {
+       src0[i] = get_src_reg(c, &inst->SrcReg[0], i, 1);
+       src1[i] = get_src_reg(c, &inst->SrcReg[1], i, 1);
+    }
+
+    dst = get_dst_reg(c, inst, get_scalar_dst_index(inst), 1);
+    brw_MUL(p, brw_null_reg(), src0[0], src1[0]);
+    brw_MAC(p, brw_null_reg(), src0[1], src1[1]);
+    brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+    brw_MAC(p, dst, src0[2], src1[2]);
+    brw_set_saturate(p, 0);
+}
+
+static void emit_dp4(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    struct brw_reg src0[4], src1[4], dst;
+    int i;
+    struct brw_compile *p = &c->func;
+    for (i = 0; i < 4; i++) {
+       src0[i] = get_src_reg(c, &inst->SrcReg[0], i, 1);
+       src1[i] = get_src_reg(c, &inst->SrcReg[1], i, 1);
+    }
+    dst = get_dst_reg(c, inst, get_scalar_dst_index(inst), 1);
+    brw_MUL(p, brw_null_reg(), src0[0], src1[0]);
+    brw_MAC(p, brw_null_reg(), src0[1], src1[1]);
+    brw_MAC(p, brw_null_reg(), src0[2], src1[2]);
+    brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+    brw_MAC(p, dst, src0[3], src1[3]);
+    brw_set_saturate(p, 0);
+}
+
+static void emit_dph(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    struct brw_reg src0[4], src1[4], dst;
+    int i;
+    struct brw_compile *p = &c->func;
+    for (i = 0; i < 4; i++) {
+       src0[i] = get_src_reg(c, &inst->SrcReg[0], i, 1);
+       src1[i] = get_src_reg(c, &inst->SrcReg[1], i, 1);
+    }
+    dst = get_dst_reg(c, inst, get_scalar_dst_index(inst), 1);
+    brw_MUL(p, brw_null_reg(), src0[0], src1[0]);
+    brw_MAC(p, brw_null_reg(), src0[1], src1[1]);
+    brw_MAC(p, dst, src0[2], src1[2]);
+    brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+    brw_ADD(p, dst, src0[3], src1[3]);
+    brw_set_saturate(p, 0);
+}
+
+static void emit_math1(struct brw_wm_compile *c,
+               struct prog_instruction *inst, GLuint func)
+{
+    struct brw_compile *p = &c->func;
+    struct brw_reg src0, dst;
+
+    src0 = get_src_reg(c, &inst->SrcReg[0], 0, 1);
+    dst = get_dst_reg(c, inst, get_scalar_dst_index(inst), 1);
+    brw_MOV(p, brw_message_reg(2), src0);
+    brw_math(p,
+           dst,
+           func,
+           (inst->SaturateMode != SATURATE_OFF) ? BRW_MATH_SATURATE_SATURATE : BRW_MATH_SATURATE_NONE,
+           2,
+           brw_null_reg(),
+           BRW_MATH_DATA_VECTOR,
+           BRW_MATH_PRECISION_FULL);
+}
+
+static void emit_rcp(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    emit_math1(c, inst, BRW_MATH_FUNCTION_INV);
+}
+
+static void emit_rsq(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    emit_math1(c, inst, BRW_MATH_FUNCTION_RSQ);
+}
+
+static void emit_sin(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    emit_math1(c, inst, BRW_MATH_FUNCTION_SIN);
+}
+
+static void emit_cos(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    emit_math1(c, inst, BRW_MATH_FUNCTION_COS);
+}
+
+static void emit_ex2(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    emit_math1(c, inst, BRW_MATH_FUNCTION_EXP);
+}
+
+static void emit_lg2(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    emit_math1(c, inst, BRW_MATH_FUNCTION_LOG);
+}
+
+static void emit_add(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    struct brw_reg src0, src1, dst;
+    GLuint mask = inst->DstReg.WriteMask;
+    int i;
+    brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+    for (i = 0 ; i < 4; i++) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i, 1);
+           src0 = get_src_reg(c, &inst->SrcReg[0], i, 1);
+           src1 = get_src_reg(c, &inst->SrcReg[1], i, 1);
+           brw_ADD(p, dst, src0, src1);
+       }
+    }
+    brw_set_saturate(p, 0);
+}
+
+static void emit_sub(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    struct brw_reg src0, src1, dst;
+    GLuint mask = inst->DstReg.WriteMask;
+    int i;
+    brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+    for (i = 0 ; i < 4; i++) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i, 1);
+           src0 = get_src_reg(c, &inst->SrcReg[0], i, 1);
+           src1 = get_src_reg(c, &inst->SrcReg[1], i, 1);
+           brw_ADD(p, dst, src0, negate(src1));
+       }
+    }
+    brw_set_saturate(p, 0);
+}
+
+static void emit_mul(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    struct brw_reg src0, src1, dst;
+    GLuint mask = inst->DstReg.WriteMask;
+    int i;
+    brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+    for (i = 0 ; i < 4; i++) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i, 1);
+           src0 = get_src_reg(c, &inst->SrcReg[0], i, 1);
+           src1 = get_src_reg(c, &inst->SrcReg[1], i, 1);
+           brw_MUL(p, dst, src0, src1);
+       }
+    }
+    brw_set_saturate(p, 0);
+}
+
+static void emit_frc(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    struct brw_reg src0, dst;
+    GLuint mask = inst->DstReg.WriteMask;
+    int i;
+    brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+    for (i = 0 ; i < 4; i++) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i, 1);
+           src0 = get_src_reg(c, &inst->SrcReg[0], i, 1);
+           brw_FRC(p, dst, src0);
+       }
+    }
+    if (inst->SaturateMode != SATURATE_OFF)
+       brw_set_saturate(p, 0);
+}
+
+static void emit_flr(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    struct brw_reg src0, dst;
+    GLuint mask = inst->DstReg.WriteMask;
+    int i;
+    brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+    for (i = 0 ; i < 4; i++) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i, 1);
+           src0 = get_src_reg(c, &inst->SrcReg[0], i, 1);
+           brw_RNDD(p, dst, src0);
+       }
+    }
+    brw_set_saturate(p, 0);
+}
+
+static void emit_max(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    struct brw_reg src0, src1, dst;
+    int i;
+    brw_push_insn_state(p);
+    for (i = 0; i < 4; i++) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i, 1);
+           src0 = get_src_reg(c, &inst->SrcReg[0], i, 1);
+           src1 = get_src_reg(c, &inst->SrcReg[1], i, 1);
+           brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+           brw_MOV(p, dst, src0);
+           brw_set_saturate(p, 0);
+
+           brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, src0, src1);
+           brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+           brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
+           brw_MOV(p, dst, src1);
+           brw_set_saturate(p, 0);
+           brw_set_predicate_control_flag_value(p, 0xff);
+       }
+    }
+    brw_pop_insn_state(p);
+}
+
+static void emit_min(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    struct brw_reg src0, src1, dst;
+    int i;
+    brw_push_insn_state(p);
+    for (i = 0; i < 4; i++) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i, 1);
+           src0 = get_src_reg(c, &inst->SrcReg[0], i, 1);
+           src1 = get_src_reg(c, &inst->SrcReg[1], i, 1);
+           brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+           brw_MOV(p, dst, src0);
+           brw_set_saturate(p, 0);
+
+           brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, src1, src0);
+           brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+           brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
+           brw_MOV(p, dst, src1);
+           brw_set_saturate(p, 0);
+           brw_set_predicate_control_flag_value(p, 0xff);
+       }
+    }
+    brw_pop_insn_state(p);
+}
+
+static void emit_pow(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    struct brw_reg dst, src0, src1;
+    dst = get_dst_reg(c, inst, get_scalar_dst_index(inst), 1);
+    src0 = get_src_reg(c, &inst->SrcReg[0], 0, 1);
+    src1 = get_src_reg(c, &inst->SrcReg[1], 0, 1);
+
+    brw_MOV(p, brw_message_reg(2), src0);
+    brw_MOV(p, brw_message_reg(3), src1);
+
+    brw_math(p,
+           dst,
+           BRW_MATH_FUNCTION_POW,
+           (inst->SaturateMode != SATURATE_OFF) ? BRW_MATH_SATURATE_SATURATE : BRW_MATH_SATURATE_NONE,
+           2,
+           brw_null_reg(),
+           BRW_MATH_DATA_VECTOR,
+           BRW_MATH_PRECISION_FULL);
+}
+
+static void emit_lrp(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    struct brw_reg dst, tmp1, tmp2, src0, src1, src2;
+    int i;
+    for (i = 0; i < 4; i++) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i, 1);
+           src0 = get_src_reg(c, &inst->SrcReg[0], i, 1);
+
+           src1 = get_src_reg(c, &inst->SrcReg[1], i, 1);
+
+           if (src1.nr == dst.nr) {
+               tmp1 = alloc_tmp(c);
+               brw_MOV(p, tmp1, src1);
+           } else
+               tmp1 = src1;
+
+           src2 = get_src_reg(c, &inst->SrcReg[2], i, 1);
+           if (src2.nr == dst.nr) {
+               tmp2 = alloc_tmp(c);
+               brw_MOV(p, tmp2, src2);
+           } else
+               tmp2 = src2;
+
+           brw_ADD(p, dst, negate(src0), brw_imm_f(1.0));
+           brw_MUL(p, brw_null_reg(), dst, tmp2);
+           brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+           brw_MAC(p, dst, src0, tmp1);
+           brw_set_saturate(p, 0);
+       }
+       release_tmps(c);
+    }
+}
+
+static void emit_kil(struct brw_wm_compile *c)
+{
+       struct brw_compile *p = &c->func;
+       struct brw_reg depth = retype(brw_vec1_grf(0, 0), BRW_REGISTER_TYPE_UW);
+       brw_push_insn_state(p);
+       brw_set_mask_control(p, BRW_MASK_DISABLE);
+       brw_NOT(p, c->emit_mask_reg, brw_mask_reg(1)); //IMASK
+       brw_AND(p, depth, c->emit_mask_reg, depth);
+       brw_pop_insn_state(p);
+}
+
+static void emit_mad(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    struct brw_reg dst, src0, src1, src2;
+    int i;
+
+    for (i = 0; i < 4; i++) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i, 1);
+           src0 = get_src_reg(c, &inst->SrcReg[0], i, 1);
+           src1 = get_src_reg(c, &inst->SrcReg[1], i, 1);
+           src2 = get_src_reg(c, &inst->SrcReg[2], i, 1);
+           brw_MUL(p, dst, src0, src1);
+
+           brw_set_saturate(p, (inst->SaturateMode != SATURATE_OFF) ? 1 : 0);
+           brw_ADD(p, dst, dst, src2);
+           brw_set_saturate(p, 0);
+       }
+    }
+}
+
+static void emit_sop(struct brw_wm_compile *c,
+               struct prog_instruction *inst, GLuint cond)
+{
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    struct brw_reg dst, src0, src1;
+    int i;
+
+    for (i = 0; i < 4; i++) {
+       if (mask & (1<<i)) {
+           dst = get_dst_reg(c, inst, i, 1);
+           src0 = get_src_reg(c, &inst->SrcReg[0], i, 1);
+           src1 = get_src_reg(c, &inst->SrcReg[1], i, 1);
+           brw_push_insn_state(p);
+           brw_CMP(p, brw_null_reg(), cond, src0, src1);
+           brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+           brw_MOV(p, dst, brw_imm_f(0.0));
+           brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
+           brw_MOV(p, dst, brw_imm_f(1.0));
+           brw_pop_insn_state(p);
+       }
+    }
+}
+
+static void emit_slt(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    emit_sop(c, inst, BRW_CONDITIONAL_L);
+}
+
+static void emit_sle(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    emit_sop(c, inst, BRW_CONDITIONAL_LE);
+}
+
+static void emit_sgt(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    emit_sop(c, inst, BRW_CONDITIONAL_G);
+}
+
+static void emit_sge(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    emit_sop(c, inst, BRW_CONDITIONAL_GE);
+}
+
+static void emit_seq(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    emit_sop(c, inst, BRW_CONDITIONAL_EQ);
+}
+
+static void emit_sne(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    emit_sop(c, inst, BRW_CONDITIONAL_NEQ);
+}
+
+static void emit_ddx(struct brw_wm_compile *c,
+                struct prog_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    struct brw_reg interp[4];
+    struct brw_reg dst;
+    struct brw_reg src0, w;
+    GLuint nr, i;
+    src0 = get_src_reg(c, &inst->SrcReg[0], 0, 1);
+    w = get_src_reg(c, &inst->SrcReg[1], 3, 1);
+    nr = src0.nr;
+    interp[0] = brw_vec1_grf(nr, 0);
+    interp[1] = brw_vec1_grf(nr, 4);
+    interp[2] = brw_vec1_grf(nr+1, 0);
+    interp[3] = brw_vec1_grf(nr+1, 4);
+    brw_set_saturate(p, inst->SaturateMode != SATURATE_OFF);
+    for(i = 0; i < 4; i++ ) {
+        if (mask & (1<<i)) {
+            dst = get_dst_reg(c, inst, i, 1);
+            brw_MOV(p, dst, interp[i]);
+            brw_MUL(p, dst, dst, w);
+        }
+    }
+    brw_set_saturate(p, 0);
+}
+
+static void emit_ddy(struct brw_wm_compile *c,
+                struct prog_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    struct brw_reg interp[4];
+    struct brw_reg dst;
+    struct brw_reg src0, w;
+    GLuint nr, i;
+
+    src0 = get_src_reg(c, &inst->SrcReg[0], 0, 1);
+    nr = src0.nr;
+    w = get_src_reg(c, &inst->SrcReg[1], 3, 1);
+    interp[0] = brw_vec1_grf(nr, 0);
+    interp[1] = brw_vec1_grf(nr, 4);
+    interp[2] = brw_vec1_grf(nr+1, 0);
+    interp[3] = brw_vec1_grf(nr+1, 4);
+    brw_set_saturate(p, inst->SaturateMode != SATURATE_OFF);
+    for(i = 0; i < 4; i++ ) {
+        if (mask & (1<<i)) {
+            dst = get_dst_reg(c, inst, i, 1);
+            brw_MOV(p, dst, suboffset(interp[i], 1));
+            brw_MUL(p, dst, dst, w);
+        }
+    }
+    brw_set_saturate(p, 0);
+}
+
+static void emit_wpos_xy(struct brw_wm_compile *c,
+                struct prog_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    GLuint mask = inst->DstReg.WriteMask;
+    struct brw_reg src0[2], dst[2];
+
+    dst[0] = get_dst_reg(c, inst, 0, 1);
+    dst[1] = get_dst_reg(c, inst, 1, 1);
+
+    src0[0] = get_src_reg(c, &inst->SrcReg[0], 0, 1);
+    src0[1] = get_src_reg(c, &inst->SrcReg[0], 1, 1);
+
+    /* Calculate the pixel offset from window bottom left into destination
+     * X and Y channels.
+     */
+    if (mask & WRITEMASK_X) {
+       /* X' = X - origin_x */
+       brw_ADD(p,
+               dst[0],
+               retype(src0[0], BRW_REGISTER_TYPE_W),
+               brw_imm_d(0 - c->key.origin_x));
+    }
+
+    if (mask & WRITEMASK_Y) {
+       /* Y' = height - (Y - origin_y) = height + origin_y - Y */
+       brw_ADD(p,
+               dst[1],
+               negate(retype(src0[1], BRW_REGISTER_TYPE_W)),
+               brw_imm_d(c->key.origin_y + c->key.drawable_height - 1));
+    }
+}
+
+/* TODO
+   BIAS on SIMD8 not workind yet...
+ */    
+static void emit_txb(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    struct brw_reg dst[4], src[4], payload_reg;
+    GLuint unit = c->fp->program.Base.SamplerUnits[inst->TexSrcUnit];
+
+    GLuint i;
+    payload_reg = get_reg(c, PROGRAM_PAYLOAD, PAYLOAD_DEPTH, 0, 1, 0, 0);
+    for (i = 0; i < 4; i++) 
+       dst[i] = get_dst_reg(c, inst, i, 1);
+    for (i = 0; i < 4; i++)
+       src[i] = get_src_reg(c, &inst->SrcReg[0], i, 1);
+
+    switch (inst->TexSrcTarget) {
+       case TEXTURE_1D_INDEX:
+           brw_MOV(p, brw_message_reg(2), src[0]);
+           brw_MOV(p, brw_message_reg(3), brw_imm_f(0));
+           brw_MOV(p, brw_message_reg(4), brw_imm_f(0));
+           break;
+       case TEXTURE_2D_INDEX:
+       case TEXTURE_RECT_INDEX:
+           brw_MOV(p, brw_message_reg(2), src[0]);
+           brw_MOV(p, brw_message_reg(3), src[1]);
+           brw_MOV(p, brw_message_reg(4), brw_imm_f(0));
+           break;
+       default:
+           brw_MOV(p, brw_message_reg(2), src[0]);
+           brw_MOV(p, brw_message_reg(3), src[1]);
+           brw_MOV(p, brw_message_reg(4), src[2]);
+           break;
+    }
+    brw_MOV(p, brw_message_reg(5), src[3]);
+    brw_MOV(p, brw_message_reg(6), brw_imm_f(0));
+    brw_SAMPLE(p,
+           retype(vec8(dst[0]), BRW_REGISTER_TYPE_UW),
+           1,
+           retype(payload_reg, BRW_REGISTER_TYPE_UW),
+           unit + MAX_DRAW_BUFFERS, /* surface */
+           unit,     /* sampler */
+           inst->DstReg.WriteMask,
+           BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS,
+           4,
+           4,
+           0);
+}
+
+static void emit_tex(struct brw_wm_compile *c,
+               struct prog_instruction *inst)
+{
+    struct brw_compile *p = &c->func;
+    struct brw_reg dst[4], src[4], payload_reg;
+    GLuint unit = c->fp->program.Base.SamplerUnits[inst->TexSrcUnit];
+
+    GLuint msg_len;
+    GLuint i, nr;
+    GLuint emit;
+    GLboolean shadow = (c->key.shadowtex_mask & (1<<unit)) ? 1 : 0;
+
+    payload_reg = get_reg(c, PROGRAM_PAYLOAD, PAYLOAD_DEPTH, 0, 1, 0, 0);
+
+    for (i = 0; i < 4; i++) 
+       dst[i] = get_dst_reg(c, inst, i, 1);
+    for (i = 0; i < 4; i++)
+       src[i] = get_src_reg(c, &inst->SrcReg[0], i, 1);
+
+
+    switch (inst->TexSrcTarget) {
+       case TEXTURE_1D_INDEX:
+           emit = WRITEMASK_X;
+           nr = 1;
+           break;
+       case TEXTURE_2D_INDEX:
+       case TEXTURE_RECT_INDEX:
+           emit = WRITEMASK_XY;
+           nr = 2;
+           break;
+       default:
+           emit = WRITEMASK_XYZ;
+           nr = 3;
+           break;
+    }
+    msg_len = 1;
+
+    for (i = 0; i < nr; i++) {
+       static const GLuint swz[4] = {0,1,2,2};
+       if (emit & (1<<i))
+           brw_MOV(p, brw_message_reg(msg_len+1), src[swz[i]]);
+       else
+           brw_MOV(p, brw_message_reg(msg_len+1), brw_imm_f(0));
+       msg_len += 1;
+    }
+
+    if (shadow) {
+       brw_MOV(p, brw_message_reg(5), brw_imm_f(0));
+       brw_MOV(p, brw_message_reg(6), src[2]);
+    }
+
+    brw_SAMPLE(p,
+           retype(vec8(dst[0]), BRW_REGISTER_TYPE_UW),
+           1,
+           retype(payload_reg, BRW_REGISTER_TYPE_UW),
+           unit + MAX_DRAW_BUFFERS, /* surface */
+           unit,     /* sampler */
+           inst->DstReg.WriteMask,
+           BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE,
+           4,
+           shadow ? 6 : 4,
+           0);
+
+    if (shadow)
+       brw_MOV(p, dst[3], brw_imm_f(1.0));
+}
+
+static void post_wm_emit( struct brw_wm_compile *c )
+{
+    GLuint nr_insns = c->fp->program.Base.NumInstructions;
+    GLuint insn, target_insn;
+    struct prog_instruction *inst1, *inst2;
+    struct brw_instruction *brw_inst1, *brw_inst2;
+    int offset;
+    for (insn = 0; insn < nr_insns; insn++) {
+       inst1 = &c->fp->program.Base.Instructions[insn];
+       brw_inst1 = inst1->Data;
+       switch (inst1->Opcode) {
+           case OPCODE_CAL:
+               target_insn = inst1->BranchTarget;
+               inst2 = &c->fp->program.Base.Instructions[target_insn];
+               brw_inst2 = inst2->Data;
+               offset = brw_inst2 - brw_inst1;
+               brw_set_src1(brw_inst1, brw_imm_d(offset*16));
+               break;
+           default:
+               break;
+       }
+    }
+}
+
+static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c)
+{
+#define MAX_IFSN 32
+#define MAX_LOOP_DEPTH 32
+    struct brw_instruction *if_inst[MAX_IFSN], *loop_inst[MAX_LOOP_DEPTH];
+    struct brw_instruction *inst0, *inst1;
+    int i, if_insn = 0, loop_insn = 0;
+    struct brw_compile *p = &c->func;
+    struct brw_indirect stack_index = brw_indirect(0, 0);
+
+    c->reg_index = 0;
+    prealloc_reg(c);
+    brw_set_compression_control(p, BRW_COMPRESSION_NONE);
+    brw_MOV(p, get_addr_reg(stack_index), brw_address(c->stack));
+
+    for (i = 0; i < c->nr_fp_insns; i++) {
+       struct prog_instruction *inst = &c->prog_instructions[i];
+       struct prog_instruction *orig_inst;
+
+       if ((orig_inst = inst->Data) != 0)
+           orig_inst->Data = current_insn(p);
+
+       if (inst->CondUpdate)
+           brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
+       else
+           brw_set_conditionalmod(p, BRW_CONDITIONAL_NONE);
+
+       switch (inst->Opcode) {
+           case WM_PIXELXY:
+               emit_pixel_xy(c, inst);
+               break;
+           case WM_DELTAXY: 
+               emit_delta_xy(c, inst);
+               break;
+           case WM_PIXELW:
+               emit_pixel_w(c, inst);
+               break;  
+           case WM_LINTERP:
+               emit_linterp(c, inst);
+               break;
+           case WM_PINTERP:
+               emit_pinterp(c, inst);
+               break;
+           case WM_CINTERP:
+               emit_cinterp(c, inst);
+               break;
+           case WM_WPOSXY:
+               emit_wpos_xy(c, inst);
+               break;
+           case WM_FB_WRITE:
+               emit_fb_write(c, inst);
+               break;
+           case OPCODE_ABS:
+               emit_abs(c, inst);
+               break;
+           case OPCODE_ADD:
+               emit_add(c, inst);
+               break;
+           case OPCODE_SUB:
+               emit_sub(c, inst);
+               break;
+           case OPCODE_FRC:
+               emit_frc(c, inst);
+               break;
+           case OPCODE_FLR:
+               emit_flr(c, inst);
+               break;
+           case OPCODE_LRP:
+               emit_lrp(c, inst);
+               break;
+           case OPCODE_INT:
+               emit_int(c, inst);
+               break;
+           case OPCODE_MOV:
+               emit_mov(c, inst);
+               break;
+           case OPCODE_DP3:
+               emit_dp3(c, inst);
+               break;
+           case OPCODE_DP4:
+               emit_dp4(c, inst);
+               break;
+           case OPCODE_XPD:
+               emit_xpd(c, inst);
+               break;
+           case OPCODE_DPH:
+               emit_dph(c, inst);
+               break;
+           case OPCODE_RCP:
+               emit_rcp(c, inst);
+               break;
+           case OPCODE_RSQ:
+               emit_rsq(c, inst);
+               break;
+           case OPCODE_SIN:
+               emit_sin(c, inst);
+               break;
+           case OPCODE_COS:
+               emit_cos(c, inst);
+               break;
+           case OPCODE_EX2:
+               emit_ex2(c, inst);
+               break;
+           case OPCODE_LG2:
+               emit_lg2(c, inst);
+               break;
+           case OPCODE_MAX:    
+               emit_max(c, inst);
+               break;
+           case OPCODE_MIN:    
+               emit_min(c, inst);
+               break;
+           case OPCODE_DDX:
+               emit_ddx(c, inst);
+               break;
+           case OPCODE_DDY:
+                emit_ddy(c, inst);
+                break;
+           case OPCODE_SLT:
+               emit_slt(c, inst);
+               break;
+           case OPCODE_SLE:
+               emit_sle(c, inst);
+               break;
+           case OPCODE_SGT:
+               emit_sgt(c, inst);
+               break;
+           case OPCODE_SGE:
+               emit_sge(c, inst);
+               break;
+           case OPCODE_SEQ:
+               emit_seq(c, inst);
+               break;
+           case OPCODE_SNE:
+               emit_sne(c, inst);
+               break;
+           case OPCODE_MUL:
+               emit_mul(c, inst);
+               break;
+           case OPCODE_POW:
+               emit_pow(c, inst);
+               break;
+           case OPCODE_MAD:
+               emit_mad(c, inst);
+               break;
+           case OPCODE_TEX:
+               emit_tex(c, inst);
+               break;
+           case OPCODE_TXB:
+               emit_txb(c, inst);
+               break;
+           case OPCODE_KIL_NV:
+               emit_kil(c);
+               break;
+           case OPCODE_IF:
+               assert(if_insn < MAX_IFSN);
+               if_inst[if_insn++] = brw_IF(p, BRW_EXECUTE_8);
+               break;
+           case OPCODE_ELSE:
+               if_inst[if_insn-1]  = brw_ELSE(p, if_inst[if_insn-1]);
+               break;
+           case OPCODE_ENDIF:
+               assert(if_insn > 0);
+               brw_ENDIF(p, if_inst[--if_insn]);
+               break;
+           case OPCODE_BGNSUB:
+           case OPCODE_ENDSUB:
+               break;
+           case OPCODE_CAL: 
+               brw_push_insn_state(p);
+               brw_set_mask_control(p, BRW_MASK_DISABLE);
+                brw_set_access_mode(p, BRW_ALIGN_1);
+                brw_ADD(p, deref_1ud(stack_index, 0), brw_ip_reg(), brw_imm_d(3*16));
+                brw_set_access_mode(p, BRW_ALIGN_16);
+                brw_ADD(p, get_addr_reg(stack_index),
+                         get_addr_reg(stack_index), brw_imm_d(4));
+                orig_inst = inst->Data;
+                orig_inst->Data = &p->store[p->nr_insn];
+                brw_ADD(p, brw_ip_reg(), brw_ip_reg(), brw_imm_d(1*16));
+                brw_pop_insn_state(p);
+               break;
+
+           case OPCODE_RET:
+               brw_push_insn_state(p);
+               brw_set_mask_control(p, BRW_MASK_DISABLE);
+                brw_ADD(p, get_addr_reg(stack_index),
+                        get_addr_reg(stack_index), brw_imm_d(-4));
+                brw_set_access_mode(p, BRW_ALIGN_1);
+                brw_MOV(p, brw_ip_reg(), deref_1ud(stack_index, 0));
+                brw_set_access_mode(p, BRW_ALIGN_16);
+               brw_pop_insn_state(p);
+
+               break;
+           case OPCODE_BGNLOOP:
+               loop_inst[loop_insn++] = brw_DO(p, BRW_EXECUTE_8);
+               break;
+           case OPCODE_BRK:
+               brw_BREAK(p);
+               brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+               break;
+           case OPCODE_CONT:
+               brw_CONT(p);
+               brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+               break;
+           case OPCODE_ENDLOOP: 
+               loop_insn--;
+               inst0 = inst1 = brw_WHILE(p, loop_inst[loop_insn]);
+               /* patch all the BREAK instructions from
+                  last BEGINLOOP */
+               while (inst0 > loop_inst[loop_insn]) {
+                   inst0--;
+                   if (inst0->header.opcode == BRW_OPCODE_BREAK) {
+                       inst0->bits3.if_else.jump_count = inst1 - inst0 + 1;
+                       inst0->bits3.if_else.pop_count = 0;
+                   } else if (inst0->header.opcode == BRW_OPCODE_CONTINUE) {
+                        inst0->bits3.if_else.jump_count = inst1 - inst0;
+                        inst0->bits3.if_else.pop_count = 0;
+                    }
+               }
+               break;
+           default:
+               _mesa_printf("unsupported IR in fragment shader %d\n",
+                       inst->Opcode);
+       }
+       if (inst->CondUpdate)
+           brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
+       else
+           brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+    }
+    post_wm_emit(c);
+    for (i = 0; i < c->fp->program.Base.NumInstructions; i++)
+       c->fp->program.Base.Instructions[i].Data = NULL;
+}
+
+void brw_wm_glsl_emit(struct brw_context *brw, struct brw_wm_compile *c)
+{
+    brw_wm_pass_fp(c);
+    c->tmp_index = 127;
+    brw_wm_emit_glsl(brw, c);
+    c->prog_data.total_grf = c->reg_index;
+    c->prog_data.total_scratch = 0;
+}
index 00f6f6b9a4f778bb5549c1da75e5d50f9d2eed88..205a7160d3900849a9ed71d82673604e58f65d86 100644 (file)
@@ -168,6 +168,7 @@ static const struct brw_wm_ref *pass0_get_reg( struct brw_wm_compile *c,
       case PROGRAM_PAYLOAD:
       case PROGRAM_TEMPORARY:
       case PROGRAM_OUTPUT:
+      case PROGRAM_VARYING:
         break;
 
       case PROGRAM_LOCAL_PARAM:
@@ -179,6 +180,8 @@ static const struct brw_wm_ref *pass0_get_reg( struct brw_wm_compile *c,
         break;
 
       case PROGRAM_STATE_VAR:
+      case PROGRAM_UNIFORM:
+      case PROGRAM_CONSTANT:
       case PROGRAM_NAMED_PARAM: {
         struct gl_program_parameter_list *plist = c->fp->program.Base.Parameters;
         
@@ -197,6 +200,7 @@ static const struct brw_wm_ref *pass0_get_reg( struct brw_wm_compile *c,
            break;
            
         case PROGRAM_STATE_VAR:
+        case PROGRAM_UNIFORM:
            /* These may change from run to run:
             */
            ref = get_param_ref(c, &plist->ParameterValues[idx][component] );
@@ -344,6 +348,8 @@ static struct brw_wm_instruction *translate_insn( struct brw_wm_compile *c,
    out->saturate = (inst->SaturateMode != SATURATE_OFF);
    out->tex_unit = inst->TexSrcUnit;
    out->tex_idx = inst->TexSrcTarget;
+   out->eot = inst->Sampler & 1;
+   out->target = inst->Sampler>>1;
 
    /* Args:
     */
index d668def7007ea9aabec22664f2abdf0783211244..f6f3a38e9e000e57f15e535ea78390f30470d527 100644 (file)
@@ -150,12 +150,17 @@ void brw_wm_pass1( struct brw_wm_compile *c )
       case OPCODE_FLR:
       case OPCODE_FRC:
       case OPCODE_MOV:
+      case OPCODE_SWZ:
         read0 = writemask;
         break;
 
       case OPCODE_SUB:
       case OPCODE_SLT:
+      case OPCODE_SLE:
       case OPCODE_SGE:
+      case OPCODE_SGT:
+      case OPCODE_SEQ:
+      case OPCODE_SNE:
       case OPCODE_ADD:
       case OPCODE_MAX:
       case OPCODE_MIN:
@@ -253,11 +258,9 @@ void brw_wm_pass1( struct brw_wm_compile *c )
         read0 = WRITEMASK_XYW;
         break;
 
-      case OPCODE_SWZ:
       case OPCODE_DST:
       case OPCODE_TXP:
       default:
-        assert(0);
         break;
       }
 
index a1edbd6168d7bafa3fe621822b6c77305e3e2584..6fca9ad220afbf444a5304b6bf70361fe23ed87b 100644 (file)
@@ -69,7 +69,8 @@ static void prealloc_reg(struct brw_wm_compile *c,
  */
 static void init_registers( struct brw_wm_compile *c )
 {
-   GLuint inputs = FRAG_BIT_WPOS | c->fp_interp_emitted;
+   struct brw_context *brw = c->func.brw;
+   GLuint inputs = (brw->vs.prog_data->outputs_written & DO_SETUP_BITS);
    GLuint nr_interp_regs = 0;
    GLuint i = 0;
    GLuint j;
@@ -85,8 +86,15 @@ static void init_registers( struct brw_wm_compile *c )
 
    for (j = 0; j < FRAG_ATTRIB_MAX; j++) 
       if (inputs & (1<<j)) {
+        /* index for vs output and ps input are not the same 
+           in shader varying */
+        GLuint index;
+        if (j > FRAG_ATTRIB_VAR0)
+            index = j - (VERT_RESULT_VAR0 - FRAG_ATTRIB_VAR0);
+        else
+            index = j;
         nr_interp_regs++;
-        prealloc_reg(c, &c->payload.input_interp[j], i++);
+        prealloc_reg(c, &c->payload.input_interp[index], i++);
       }
 
    assert(nr_interp_regs >= 1);
@@ -328,7 +336,7 @@ void brw_wm_pass2( struct brw_wm_compile *c )
    c->state = PASS2_DONE;
 
    if (INTEL_DEBUG & DEBUG_WM) {
-      brw_wm_print_program(c, "pass2/done");
+       brw_wm_print_program(c, "pass2/done");
    }
 }
 
index 93d4cfc3a5f2d739b7599a049f3c3f637761727f..e47dbe8b10126e47c6828725c7146b031ac05695 100644 (file)
@@ -54,7 +54,7 @@ static GLuint translate_wrap_mode( GLenum wrap )
    case GL_REPEAT: 
       return BRW_TEXCOORDMODE_WRAP;
    case GL_CLAMP:  
-      return BRW_TEXCOORDMODE_CLAMP_BORDER; /* conform likes it this way */
+      return BRW_TEXCOORDMODE_CLAMP;
    case GL_CLAMP_TO_EDGE: 
       return BRW_TEXCOORDMODE_CLAMP; /* conform likes it this way */
    case GL_CLAMP_TO_BORDER: 
@@ -79,27 +79,43 @@ static GLint S_FIXED(GLfloat value, GLuint frac_bits)
 }
 
 
-static GLuint upload_default_color( struct brw_context *brw,
-                                   const GLfloat *color )
+static dri_bo *upload_default_color( struct brw_context *brw,
+                                    const GLfloat *color )
 {
    struct brw_sampler_default_color sdc;
 
    COPY_4V(sdc.color, color); 
    
-   return brw_cache_data( &brw->cache[BRW_SAMPLER_DEFAULT_COLOR], &sdc );
+   return brw_cache_data( &brw->cache, BRW_SAMPLER_DEFAULT_COLOR, &sdc,
+                         NULL, 0 );
 }
 
 
-/*
+struct wm_sampler_key {
+   int sampler_count;
+
+   struct wm_sampler_entry {
+      GLenum wrap_r, wrap_s, wrap_t;
+      float maxlod, minlod;
+      float lod_bias;
+      float max_aniso;
+      GLenum minfilter, magfilter;
+      GLenum comparemode, comparefunc;
+      dri_bo *sdc_bo;
+   } sampler[BRW_MAX_TEX_UNIT];
+};
+
+/**
+ * Sets the sampler state for a single unit based off of the sampler key
+ * entry.
  */
-static void brw_update_sampler_state( struct gl_texture_unit *texUnit,
-                                     struct gl_texture_object *texObj,
-                                     GLuint sdc_gs_offset,
-                                     struct brw_sampler_state *sampler)
-{   
+static void brw_update_sampler_state(struct wm_sampler_entry *key,
+                                    dri_bo *sdc_bo,
+                                    struct brw_sampler_state *sampler)
+{
    _mesa_memset(sampler, 0, sizeof(*sampler));
 
-   switch (texObj->MinFilter) {
+   switch (key->minfilter) {
    case GL_NEAREST:
       sampler->ss0.min_filter = BRW_MAPFILTER_NEAREST;
       sampler->ss0.mip_filter = BRW_MIPFILTER_NONE;
@@ -130,17 +146,17 @@ static void brw_update_sampler_state( struct gl_texture_unit *texUnit,
 
    /* Set Anisotropy: 
     */
-   if ( texObj->MaxAnisotropy > 1.0 ) {
+   if (key->max_aniso > 1.0) {
       sampler->ss0.min_filter = BRW_MAPFILTER_ANISOTROPIC; 
       sampler->ss0.mag_filter = BRW_MAPFILTER_ANISOTROPIC;
 
-      if (texObj->MaxAnisotropy > 2.0) {
-        sampler->ss3.max_aniso = MAX2((texObj->MaxAnisotropy - 2) / 2,
+      if (key->max_aniso > 2.0) {
+        sampler->ss3.max_aniso = MAX2((key->max_aniso - 2) / 2,
                                       BRW_ANISORATIO_16);
       }
    }
    else {
-      switch (texObj->MagFilter) {
+      switch (key->magfilter) {
       case GL_NEAREST:
         sampler->ss0.mag_filter = BRW_MAPFILTER_NEAREST;
         break;
@@ -152,9 +168,9 @@ static void brw_update_sampler_state( struct gl_texture_unit *texUnit,
       }  
    }
 
-   sampler->ss1.r_wrap_mode = translate_wrap_mode(texObj->WrapR);
-   sampler->ss1.s_wrap_mode = translate_wrap_mode(texObj->WrapS);
-   sampler->ss1.t_wrap_mode = translate_wrap_mode(texObj->WrapT);
+   sampler->ss1.r_wrap_mode = translate_wrap_mode(key->wrap_r);
+   sampler->ss1.s_wrap_mode = translate_wrap_mode(key->wrap_s);
+   sampler->ss1.t_wrap_mode = translate_wrap_mode(key->wrap_t);
 
    /* Fulsim complains if I don't do this.  Hardware doesn't mind:
     */
@@ -168,17 +184,18 @@ static void brw_update_sampler_state( struct gl_texture_unit *texUnit,
 
    /* Set shadow function: 
     */
-   if (texObj->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB) {
+   if (key->comparemode == GL_COMPARE_R_TO_TEXTURE_ARB) {
       /* Shadowing is "enabled" by emitting a particular sampler
        * message (sample_c).  So need to recompile WM program when
        * shadow comparison is enabled on each/any texture unit.
        */
-      sampler->ss0.shadow_function = intel_translate_compare_func(texObj->CompareFunc);
+      sampler->ss0.shadow_function =
+        intel_translate_shadow_compare_func(key->comparefunc);
    }
 
    /* Set LOD bias: 
     */
-   sampler->ss0.lod_bias = S_FIXED(texUnit->LodBias + texObj->LodBias, 6);
+   sampler->ss0.lod_bias = S_FIXED(CLAMP(key->lod_bias, -16, 15), 6);
 
    sampler->ss0.lod_preclamp = 1; /* OpenGL mode */
    sampler->ss0.default_color_mode = 0; /* OpenGL/DX10 mode */
@@ -192,54 +209,109 @@ static void brw_update_sampler_state( struct gl_texture_unit *texUnit,
     */
    sampler->ss0.base_level = U_FIXED(0, 1);
 
-   sampler->ss1.max_lod = U_FIXED(MAX2(texObj->MaxLod, 0), 6);
-   sampler->ss1.min_lod = U_FIXED(MAX2(texObj->MinLod, 0), 6);
+   sampler->ss1.max_lod = U_FIXED(MIN2(MAX2(key->maxlod, 0), 13), 6);
+   sampler->ss1.min_lod = U_FIXED(MIN2(MAX2(key->minlod, 0), 13), 6);
    
-   sampler->ss2.default_color_pointer = sdc_gs_offset >> 5;
+   sampler->ss2.default_color_pointer = sdc_bo->offset >> 5; /* reloc */
 }
 
-
-
-/* All samplers must be uploaded in a single contiguous array, which
- * complicates various things.  However, this is still too confusing -
- * FIXME: simplify all the different new texture state flags.
- */
-static void upload_wm_samplers( struct brw_context *brw )
+/** Sets up the cache key for sampler state for all texture units */
+static void
+brw_wm_sampler_populate_key(struct brw_context *brw,
+                           struct wm_sampler_key *key)
 {
-   GLuint unit;
-   GLuint sampler_count = 0;
+   int unit;
+
+   memset(key, 0, sizeof(*key));
 
-   /* _NEW_TEXTURE */
    for (unit = 0; unit < BRW_MAX_TEX_UNIT; unit++) {
-      if (brw->attribs.Texture->Unit[unit]._ReallyEnabled) {    
+      if (brw->attribs.Texture->Unit[unit]._ReallyEnabled) {
+        struct wm_sampler_entry *entry = &key->sampler[unit];
         struct gl_texture_unit *texUnit = &brw->attribs.Texture->Unit[unit];
         struct gl_texture_object *texObj = texUnit->_Current;
 
-        GLuint sdc_gs_offset = upload_default_color(brw, texObj->BorderColor);
+        entry->wrap_r = texObj->WrapR;
+        entry->wrap_s = texObj->WrapS;
+        entry->wrap_t = texObj->WrapT;
 
-        brw_update_sampler_state(texUnit,
-                                 texObj, 
-                                 sdc_gs_offset,
-                                 &brw->wm.sampler[unit]);
+        entry->maxlod = texObj->MaxLod;
+        entry->minlod = texObj->MinLod;
+        entry->lod_bias = texUnit->LodBias + texObj->LodBias;
+        entry->max_aniso = texObj->MaxAnisotropy;
+        entry->minfilter = texObj->MinFilter;
+        entry->magfilter = texObj->MagFilter;
+        entry->comparemode = texObj->CompareMode;
+    entry->comparefunc = texObj->CompareFunc;
 
-        sampler_count = unit + 1;
+        dri_bo_unreference(brw->wm.sdc_bo[unit]);
+        brw->wm.sdc_bo[unit] = upload_default_color(brw, texObj->BorderColor);
+
+        key->sampler_count = unit + 1;
       }
    }
-   
-   if (brw->wm.sampler_count != sampler_count) {
-      brw->wm.sampler_count = sampler_count;
+}
+
+/* All samplers must be uploaded in a single contiguous array, which
+ * complicates various things.  However, this is still too confusing -
+ * FIXME: simplify all the different new texture state flags.
+ */
+static void upload_wm_samplers( struct brw_context *brw )
+{
+   struct wm_sampler_key key;
+   int i;
+
+   brw_wm_sampler_populate_key(brw, &key);
+
+   if (brw->wm.sampler_count != key.sampler_count) {
+      brw->wm.sampler_count = key.sampler_count;
       brw->state.dirty.cache |= CACHE_NEW_SAMPLER;
    }
 
-   brw->wm.sampler_gs_offset = 0;
+   dri_bo_unreference(brw->wm.sampler_bo);
+   brw->wm.sampler_bo = NULL;
+   if (brw->wm.sampler_count == 0)
+      return;
 
-   if (brw->wm.sampler_count) 
-      brw->wm.sampler_gs_offset = 
-        brw_cache_data_sz(&brw->cache[BRW_SAMPLER],
-                          brw->wm.sampler,
-                          sizeof(struct brw_sampler_state) * brw->wm.sampler_count);
-}
+   brw->wm.sampler_bo = brw_search_cache(&brw->cache, BRW_SAMPLER,
+                                        &key, sizeof(key),
+                                        brw->wm.sdc_bo, key.sampler_count,
+                                        NULL);
 
+   /* If we didnt find it in the cache, compute the state and put it in the
+    * cache.
+    */
+   if (brw->wm.sampler_bo == NULL) {
+      struct brw_sampler_state sampler[BRW_MAX_TEX_UNIT];
+
+      memset(sampler, 0, sizeof(sampler));
+      for (i = 0; i < key.sampler_count; i++) {
+        if (brw->wm.sdc_bo[i] == NULL)
+           continue;
+
+        brw_update_sampler_state(&key.sampler[i], brw->wm.sdc_bo[i],
+                                 &sampler[i]);
+      }
+
+      brw->wm.sampler_bo = brw_upload_cache(&brw->cache, BRW_SAMPLER,
+                                           &key, sizeof(key),
+                                           brw->wm.sdc_bo, key.sampler_count,
+                                           &sampler, sizeof(sampler),
+                                           NULL, NULL);
+
+      /* Emit SDC relocations */
+      for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {
+        if (!brw->attribs.Texture->Unit[i]._ReallyEnabled)
+           continue;
+
+        dri_bo_emit_reloc(brw->wm.sampler_bo,
+                          I915_GEM_DOMAIN_INSTRUCTION, 0,
+                          0,
+                          i * sizeof(struct brw_sampler_state) +
+                          offsetof(struct brw_sampler_state, ss2),
+                          brw->wm.sdc_bo[i]);
+      }
+   }
+}
 
 const struct brw_tracked_state brw_wm_samplers = {
    .dirty = {
@@ -247,7 +319,7 @@ const struct brw_tracked_state brw_wm_samplers = {
       .brw = 0,
       .cache = 0
    },
-   .update = upload_wm_samplers
+   .prepare = upload_wm_samplers,
 };
 
 
index ff5cb31bdd148fb749c9b5b14aa2a25525482f18..61fe97a4634bb615c339c0dc1c5f0b02c227fd15 100644 (file)
 #include "brw_context.h"
 #include "brw_state.h"
 #include "brw_defines.h"
-#include "bufmgr.h"
+#include "brw_wm.h"
 
 /***********************************************************************
  * WM unit - fragment programs and rasterization
  */
 
-static void invalidate_scratch_cb( struct intel_context *intel,
-                                  void *unused )
-{
-   /* nothing */
-}
+struct brw_wm_unit_key {
+   unsigned int total_grf, total_scratch;
+   unsigned int urb_entry_read_length;
+   unsigned int curb_entry_read_length;
+   unsigned int dispatch_grf_start_reg;
+
+   unsigned int curbe_offset;
+   unsigned int urb_size;
+
+   unsigned int max_threads;
 
+   unsigned int nr_surfaces, sampler_count;
+   GLboolean uses_depth, computes_depth, uses_kill, is_glsl;
+   GLboolean polygon_stipple, stats_wm, line_stipple, offset_enable;
+   GLfloat offset_units, offset_factor;
+};
 
-static void upload_wm_unit(struct brw_context *brw )
+static void
+wm_unit_populate_key(struct brw_context *brw, struct brw_wm_unit_key *key)
 {
+   const struct gl_fragment_program *fp = brw->fragment_program;
    struct intel_context *intel = &brw->intel;
-   struct brw_wm_unit_state wm;
-   GLuint max_threads;
+
+   memset(key, 0, sizeof(*key));
 
    if (INTEL_DEBUG & DEBUG_SINGLE_THREAD)
-      max_threads = 0; 
+      key->max_threads = 1;
    else
-      max_threads = 31;
-
-
-   memset(&wm, 0, sizeof(wm));
+      key->max_threads = 32;
 
    /* CACHE_NEW_WM_PROG */
-   wm.thread0.grf_reg_count = ((brw->wm.prog_data->total_grf-1) & ~15) / 16;
-   wm.thread0.kernel_start_pointer = brw->wm.prog_gs_offset >> 6;
-   wm.thread3.dispatch_grf_start_reg = brw->wm.prog_data->first_curbe_grf;
-   wm.thread3.urb_entry_read_length = brw->wm.prog_data->urb_read_length;
-   wm.thread3.const_urb_entry_read_length = brw->wm.prog_data->curb_read_length;
-
-   wm.wm5.max_threads = max_threads;      
-
-   if (brw->wm.prog_data->total_scratch) {
-      GLuint per_thread = (brw->wm.prog_data->total_scratch + 1023) / 1024;
-      GLuint total = per_thread * (max_threads + 1);
-
-      /* Scratch space -- just have to make sure there is sufficient
-       * allocated for the active program and current number of threads.
-       */      
-
-      if (!brw->wm.scratch_buffer) {
-        bmGenBuffers(intel, "wm scratch", 1, &brw->wm.scratch_buffer, 12);
-        bmBufferSetInvalidateCB(intel,
-                                brw->wm.scratch_buffer,
-                                invalidate_scratch_cb,
-                                NULL,
-                                GL_FALSE);
-      }
+   key->total_grf = brw->wm.prog_data->total_grf;
+   key->urb_entry_read_length = brw->wm.prog_data->urb_read_length;
+   key->curb_entry_read_length = brw->wm.prog_data->curb_read_length;
+   key->dispatch_grf_start_reg = brw->wm.prog_data->first_curbe_grf;
+   key->total_scratch = ALIGN(brw->wm.prog_data->total_scratch, 1024);
 
-      if (total > brw->wm.scratch_buffer_size) {
-        brw->wm.scratch_buffer_size = total;
-        bmBufferData(intel,
-                     brw->wm.scratch_buffer,
-                     brw->wm.scratch_buffer_size,
-                     NULL,
-                     0);
-      }
-                  
-      assert(per_thread <= 12 * 1024);
-      wm.thread2.per_thread_scratch_space = (per_thread / 1024) - 1;
+   /* BRW_NEW_URB_FENCE */
+   key->urb_size = brw->urb.vsize;
 
-      /* XXX: could make this dynamic as this is so rarely active:
-       */
-      /* BRW_NEW_LOCK */
-      wm.thread2.scratch_space_base_pointer = 
-        bmBufferOffset(intel, brw->wm.scratch_buffer) >> 10;
-   }
+   /* BRW_NEW_CURBE_OFFSETS */
+   key->curbe_offset = brw->curbe.wm_start;
 
    /* CACHE_NEW_SURFACE */
-   wm.thread1.binding_table_entry_count = brw->wm.nr_surfaces;
+   key->nr_surfaces = brw->wm.nr_surfaces;
 
-   /* BRW_NEW_CURBE_OFFSETS */
-   wm.thread3.const_urb_entry_read_offset = brw->curbe.wm_start * 2;
+   /* CACHE_NEW_SAMPLER */
+   key->sampler_count = brw->wm.sampler_count;
 
-   wm.thread3.urb_entry_read_offset = 0;
+   /* _NEW_POLYGONSTIPPLE */
+   key->polygon_stipple = brw->attribs.Polygon->StippleFlag;
+
+   /* BRW_NEW_FRAGMENT_PROGRAM */
+   key->uses_depth = (fp->Base.InputsRead & (1 << FRAG_ATTRIB_WPOS)) != 0;
+
+   /* as far as we can tell */
+   key->computes_depth =
+      (fp->Base.OutputsWritten & (1 << FRAG_RESULT_DEPR)) != 0;
+
+   /* _NEW_COLOR */
+   key->uses_kill = fp->UsesKill || brw->attribs.Color->AlphaEnabled;
+   key->is_glsl = brw_wm_is_glsl(fp);
+
+   /* XXX: This needs a flag to indicate when it changes. */
+   key->stats_wm = intel->stats_wm;
+
+   /* _NEW_LINE */
+   key->line_stipple = brw->attribs.Line->StippleFlag;
+
+   /* _NEW_POLYGON */
+   key->offset_enable = brw->attribs.Polygon->OffsetFill;
+   key->offset_units = brw->attribs.Polygon->OffsetUnits;
+   key->offset_factor = brw->attribs.Polygon->OffsetFactor;
+}
+
+static dri_bo *
+wm_unit_create_from_key(struct brw_context *brw, struct brw_wm_unit_key *key,
+                       dri_bo **reloc_bufs)
+{
+   struct brw_wm_unit_state wm;
+   dri_bo *bo;
+
+   memset(&wm, 0, sizeof(wm));
+
+   wm.thread0.grf_reg_count = ALIGN(key->total_grf, 16) / 16 - 1;
+   wm.thread0.kernel_start_pointer = brw->wm.prog_bo->offset >> 6; /* reloc */
    wm.thread1.depth_coef_urb_read_offset = 1;
    wm.thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
+   wm.thread1.binding_table_entry_count = key->nr_surfaces;
+
+   if (key->total_scratch != 0) {
+      wm.thread2.scratch_space_base_pointer =
+        brw->wm.scratch_buffer->offset >> 10; /* reloc */
+      wm.thread2.per_thread_scratch_space = key->total_scratch / 1024 - 1;
+   } else {
+      wm.thread2.scratch_space_base_pointer = 0;
+      wm.thread2.per_thread_scratch_space = 0;
+   }
 
-   /* CACHE_NEW_SAMPLER */
-   wm.wm4.sampler_count = brw->wm.sampler_count;
-   wm.wm4.sampler_state_pointer = brw->wm.sampler_gs_offset >> 5;
+   wm.thread3.dispatch_grf_start_reg = key->dispatch_grf_start_reg;
+   wm.thread3.urb_entry_read_length = key->urb_entry_read_length;
+   wm.thread3.const_urb_entry_read_length = key->curb_entry_read_length;
+   wm.thread3.const_urb_entry_read_offset = key->curbe_offset * 2;
+   wm.thread3.urb_entry_read_offset = 0;
 
-   /* BRW_NEW_FRAGMENT_PROGRAM */
-   {
-      const struct gl_fragment_program *fp = brw->fragment_program; 
-
-      if (fp->Base.InputsRead & (1<<FRAG_ATTRIB_WPOS)) 
-        wm.wm5.program_uses_depth = 1; /* as far as we can tell */
-   
-      if (fp->Base.OutputsWritten & (1<<FRAG_RESULT_DEPR)) 
-        wm.wm5.program_computes_depth = 1;
-   
-      /* _NEW_COLOR */
-      if (fp->UsesKill || 
-         brw->attribs.Color->AlphaEnabled) 
-        wm.wm5.program_uses_killpixel = 1; 
+   wm.wm4.sampler_count = (key->sampler_count + 1) / 4;
+   if (brw->wm.sampler_bo != NULL) {
+      /* reloc */
+      wm.wm4.sampler_state_pointer = brw->wm.sampler_bo->offset >> 5;
+   } else {
+      wm.wm4.sampler_state_pointer = 0;
    }
 
-   wm.wm5.enable_16_pix = 1;
+   wm.wm5.program_uses_depth = key->uses_depth;
+   wm.wm5.program_computes_depth = key->computes_depth;
+   wm.wm5.program_uses_killpixel = key->uses_kill;
+
+   if (key->is_glsl)
+      wm.wm5.enable_8_pix = 1;
+   else
+      wm.wm5.enable_16_pix = 1;
+
+   wm.wm5.max_threads = key->max_threads - 1;
    wm.wm5.thread_dispatch_enable = 1;  /* AKA: color_write */
    wm.wm5.legacy_line_rast = 0;
    wm.wm5.legacy_global_depth_bias = 0;
@@ -144,34 +170,101 @@ static void upload_wm_unit(struct brw_context *brw )
    wm.wm5.line_aa_region_width = 0;
    wm.wm5.line_endcap_aa_region_width = 1;
 
-   /* _NEW_POLYGONSTIPPLE */
-   if (brw->attribs.Polygon->StippleFlag) 
-      wm.wm5.polygon_stipple = 1;
+   wm.wm5.polygon_stipple = key->polygon_stipple;
 
-   /* _NEW_POLYGON */
-   if (brw->attribs.Polygon->OffsetFill) {
+   if (key->offset_enable) {
       wm.wm5.depth_offset = 1;
       /* Something wierd going on with legacy_global_depth_bias,
        * offset_constant, scaling and MRD.  This value passes glean
        * but gives some odd results elsewere (eg. the
        * quad-offset-units test).
        */
-      wm.global_depth_offset_constant = brw->attribs.Polygon->OffsetUnits * 2;
+      wm.global_depth_offset_constant = key->offset_units * 2;
 
       /* This is the only value that passes glean:
        */
-      wm.global_depth_offset_scale = brw->attribs.Polygon->OffsetFactor;
+      wm.global_depth_offset_scale = key->offset_factor;
    }
 
-   /* _NEW_LINE */
-   if (brw->attribs.Line->StippleFlag) {
-      wm.wm5.line_stipple = 1;
-   }
+   wm.wm5.line_stipple = key->line_stipple;
 
-   if (INTEL_DEBUG & DEBUG_STATS || intel->stats_wm)
+   if (INTEL_DEBUG & DEBUG_STATS || key->stats_wm)
       wm.wm4.stats_enable = 1;
 
-   brw->wm.state_gs_offset = brw_cache_data( &brw->cache[BRW_WM_UNIT], &wm );
+   bo = brw_upload_cache(&brw->cache, BRW_WM_UNIT,
+                        key, sizeof(*key),
+                        reloc_bufs, 3,
+                        &wm, sizeof(wm),
+                        NULL, NULL);
+
+   /* Emit WM program relocation */
+   dri_bo_emit_reloc(bo,
+                    I915_GEM_DOMAIN_INSTRUCTION, 0,
+                    wm.thread0.grf_reg_count << 1,
+                    offsetof(struct brw_wm_unit_state, thread0),
+                    brw->wm.prog_bo);
+
+   /* Emit scratch space relocation */
+   if (key->total_scratch != 0) {
+      dri_bo_emit_reloc(bo,
+                       0, 0,
+                       wm.thread2.per_thread_scratch_space,
+                       offsetof(struct brw_wm_unit_state, thread2),
+                       brw->wm.scratch_buffer);
+   }
+
+   /* Emit sampler state relocation */
+   if (key->sampler_count != 0) {
+      dri_bo_emit_reloc(bo,
+                       I915_GEM_DOMAIN_INSTRUCTION, 0,
+                       wm.wm4.stats_enable | (wm.wm4.sampler_count << 2),
+                       offsetof(struct brw_wm_unit_state, wm4),
+                       brw->wm.sampler_bo);
+   }
+
+   return bo;
+}
+
+
+static void upload_wm_unit( struct brw_context *brw )
+{
+   struct intel_context *intel = &brw->intel;
+   struct brw_wm_unit_key key;
+   dri_bo *reloc_bufs[3];
+   wm_unit_populate_key(brw, &key);
+
+   /* Allocate the necessary scratch space if we haven't already.  Don't
+    * bother reducing the allocation later, since we use scratch so
+    * rarely.
+    */
+   assert(key.total_scratch <= 12 * 1024);
+   if (key.total_scratch) {
+      GLuint total = key.total_scratch * key.max_threads;
+
+      if (brw->wm.scratch_buffer && total > brw->wm.scratch_buffer->size) {
+        dri_bo_unreference(brw->wm.scratch_buffer);
+        brw->wm.scratch_buffer = NULL;
+      }
+      if (brw->wm.scratch_buffer == NULL) {
+        brw->wm.scratch_buffer = dri_bo_alloc(intel->bufmgr,
+                                              "wm scratch",
+                                              total,
+                                              4096);
+      }
+   }
+
+   reloc_bufs[0] = brw->wm.prog_bo;
+   reloc_bufs[1] = brw->wm.scratch_buffer;
+   reloc_bufs[2] = brw->wm.sampler_bo;
+
+   dri_bo_unreference(brw->wm.state_bo);
+   brw->wm.state_bo = brw_search_cache(&brw->cache, BRW_WM_UNIT,
+                                      &key, sizeof(key),
+                                      reloc_bufs, 3,
+                                      NULL);
+   if (brw->wm.state_bo == NULL) {
+      brw->wm.state_bo = wm_unit_create_from_key(brw, &key, reloc_bufs);
+   }
 }
 
 const struct brw_tracked_state brw_wm_unit = {
@@ -189,6 +282,6 @@ const struct brw_tracked_state brw_wm_unit = {
                CACHE_NEW_WM_PROG | 
                CACHE_NEW_SAMPLER)
    },
-   .update = upload_wm_unit
+   .prepare = upload_wm_unit,
 };
 
index d24c618a668b6ba950f10ae8175e414c37938b6b..8fcd50924f3de38a21526395719d7a9bbb33b41f 100644 (file)
@@ -69,7 +69,7 @@ static GLuint translate_tex_target( GLenum target )
 }
 
 
-static GLuint translate_tex_format( GLuint mesa_format )
+static GLuint translate_tex_format( GLuint mesa_format, GLenum depth_mode )
 {
    switch( mesa_format ) {
    case MESA_FORMAT_L8:
@@ -114,11 +114,32 @@ static GLuint translate_tex_format( GLuint mesa_format )
       return BRW_SURFACEFORMAT_FXT1;
 
    case MESA_FORMAT_Z16:
-      return BRW_SURFACEFORMAT_L16_UNORM;
+      if (depth_mode == GL_INTENSITY) 
+         return BRW_SURFACEFORMAT_I16_UNORM;
+      else if (depth_mode == GL_ALPHA)
+         return BRW_SURFACEFORMAT_A16_UNORM;
+      else
+         return BRW_SURFACEFORMAT_L16_UNORM;
 
-   case MESA_FORMAT_RGBA_DXT1:
    case MESA_FORMAT_RGB_DXT1:
-      return BRW_SURFACEFORMAT_DXT1_RGB;
+       return BRW_SURFACEFORMAT_DXT1_RGB;
+
+   case MESA_FORMAT_RGBA_DXT1:
+       return BRW_SURFACEFORMAT_BC1_UNORM;
+       
+   case MESA_FORMAT_RGBA_DXT3:
+       return BRW_SURFACEFORMAT_BC2_UNORM;
+       
+   case MESA_FORMAT_RGBA_DXT5:
+       return BRW_SURFACEFORMAT_BC3_UNORM;
+
+   case MESA_FORMAT_SRGBA8:
+      return BRW_SURFACEFORMAT_R8G8B8A8_UNORM_SRGB;
+   case MESA_FORMAT_SRGB_DXT1:
+      return BRW_SURFACEFORMAT_BC1_UNORM_SRGB;
+
+   case MESA_FORMAT_S8_Z24:
+      return BRW_SURFACEFORMAT_I24X8_UNORM;
 
    default:
       assert(0);
@@ -126,142 +147,343 @@ static GLuint translate_tex_format( GLuint mesa_format )
    }
 }
 
-static
-void brw_update_texture_surface( GLcontext *ctx, 
-                                GLuint unit,
-                                struct brw_surface_state *surf )
-{
-   struct intel_context *intel = intel_context(ctx);
-   struct brw_context *brw = brw_context(ctx);
-   struct gl_texture_object *tObj = brw->attribs.Texture->Unit[unit]._Current;
-   struct intel_texture_object *intelObj = intel_texture_object(tObj);
-   struct gl_texture_image *firstImage = tObj->Image[0][intelObj->firstLevel];
+struct brw_wm_surface_key {
+   GLenum target, depthmode;
+   dri_bo *bo;
+   GLint format;
+   GLint first_level, last_level;
+   GLint width, height, depth;
+   GLint pitch, cpp;
+   uint32_t tiling;
+   GLuint offset;
+};
 
-   memset(surf, 0, sizeof(*surf));
+static void
+brw_set_surface_tiling(struct brw_surface_state *surf, uint32_t tiling)
+{
+   switch (tiling) {
+   case I915_TILING_NONE:
+      surf->ss3.tiled_surface = 0;
+      surf->ss3.tile_walk = 0;
+      break;
+   case I915_TILING_X:
+      surf->ss3.tiled_surface = 1;
+      surf->ss3.tile_walk = BRW_TILEWALK_XMAJOR;
+      break;
+   case I915_TILING_Y:
+      surf->ss3.tiled_surface = 1;
+      surf->ss3.tile_walk = BRW_TILEWALK_YMAJOR;
+      break;
+   }
+}
 
-   surf->ss0.mipmap_layout_mode = BRW_SURFACE_MIPMAPLAYOUT_BELOW;   
-   surf->ss0.surface_type = translate_tex_target(tObj->Target);
-   surf->ss0.surface_format = translate_tex_format(firstImage->TexFormat->MesaFormat);
+static dri_bo *
+brw_create_texture_surface( struct brw_context *brw,
+                           struct brw_wm_surface_key *key )
+{
+   struct brw_surface_state surf;
+   dri_bo *bo;
+
+   memset(&surf, 0, sizeof(surf));
+
+   surf.ss0.mipmap_layout_mode = BRW_SURFACE_MIPMAPLAYOUT_BELOW;
+   surf.ss0.surface_type = translate_tex_target(key->target);
+
+   if (key->bo) 
+      surf.ss0.surface_format = translate_tex_format(key->format, key->depthmode);
+   else {
+     switch(key->depth) {
+     case 32: surf.ss0.surface_format = BRW_SURFACEFORMAT_B8G8R8A8_UNORM; break;
+     default:
+     case 24: surf.ss0.surface_format = BRW_SURFACEFORMAT_B8G8R8X8_UNORM; break;
+     case 16: surf.ss0.surface_format = BRW_SURFACEFORMAT_B5G6R5_UNORM; break;
+     }
+   }
 
    /* This is ok for all textures with channel width 8bit or less:
     */
-/*    surf->ss0.data_return_format = BRW_SURFACERETURNFORMAT_S1; */
-
-   /* BRW_NEW_LOCK */
-   surf->ss1.base_addr = bmBufferOffset(intel,
-                                       intelObj->mt->region->buffer);
-
-   surf->ss2.mip_count = intelObj->lastLevel - intelObj->firstLevel;
-   surf->ss2.width = firstImage->Width - 1;
-   surf->ss2.height = firstImage->Height - 1;
-
-   surf->ss3.tile_walk = BRW_TILEWALK_XMAJOR;
-   surf->ss3.tiled_surface = intelObj->mt->region->tiled; /* always zero */
-   surf->ss3.pitch = (intelObj->mt->pitch * intelObj->mt->cpp) - 1;
-   surf->ss3.depth = firstImage->Depth - 1;
-
-   surf->ss4.min_lod = 0;
+/*    surf.ss0.data_return_format = BRW_SURFACERETURNFORMAT_S1; */
+   if (key->bo)
+     surf.ss1.base_addr = key->bo->offset; /* reloc */
+   else
+     surf.ss1.base_addr = key->offset;
+
+   surf.ss2.mip_count = key->last_level - key->first_level;
+   surf.ss2.width = key->width - 1;
+   surf.ss2.height = key->height - 1;
+   brw_set_surface_tiling(&surf, key->tiling);
+   surf.ss3.pitch = (key->pitch * key->cpp) - 1;
+   surf.ss3.depth = key->depth - 1;
+
+   surf.ss4.min_lod = 0;
  
-   if (tObj->Target == GL_TEXTURE_CUBE_MAP) {
-      surf->ss0.cube_pos_x = 1;
-      surf->ss0.cube_pos_y = 1;
-      surf->ss0.cube_pos_z = 1;
-      surf->ss0.cube_neg_x = 1;
-      surf->ss0.cube_neg_y = 1;
-      surf->ss0.cube_neg_z = 1;
+   if (key->target == GL_TEXTURE_CUBE_MAP) {
+      surf.ss0.cube_pos_x = 1;
+      surf.ss0.cube_pos_y = 1;
+      surf.ss0.cube_pos_z = 1;
+      surf.ss0.cube_neg_x = 1;
+      surf.ss0.cube_neg_y = 1;
+      surf.ss0.cube_neg_z = 1;
    }
-}
-
 
+   bo = brw_upload_cache(&brw->cache, BRW_SS_SURFACE,
+                        key, sizeof(*key),
+                        &key->bo, key->bo ? 1 : 0,
+                        &surf, sizeof(surf),
+                        NULL, NULL);
+
+   if (key->bo) {
+      /* Emit relocation to surface contents */
+      dri_bo_emit_reloc(bo,
+                       I915_GEM_DOMAIN_SAMPLER, 0,
+                       0,
+                       offsetof(struct brw_surface_state, ss1),
+                       key->bo);
+   }
+   return bo;
+}
 
-#define OFFSET(TYPE, FIELD) ( (GLuint)&(((TYPE *)0)->FIELD) )
+static void
+brw_update_texture_surface( GLcontext *ctx, GLuint unit )
+{
+   struct brw_context *brw = brw_context(ctx);
+   struct gl_texture_object *tObj = brw->attribs.Texture->Unit[unit]._Current;
+   struct intel_texture_object *intelObj = intel_texture_object(tObj);
+   struct gl_texture_image *firstImage = tObj->Image[0][intelObj->firstLevel];
+   struct brw_wm_surface_key key;
+
+   memset(&key, 0, sizeof(key));
+
+   if (intelObj->imageOverride) {
+      key.pitch = intelObj->pitchOverride / intelObj->mt->cpp;
+      key.depth = intelObj->depthOverride;
+      key.bo = NULL;
+      key.offset = intelObj->textureOffset;
+   } else {
+      key.format = firstImage->TexFormat->MesaFormat;
+      key.pitch = intelObj->mt->pitch;
+      key.depth = firstImage->Depth;
+      key.bo = intelObj->mt->region->buffer;
+      key.offset = 0;
+   }
 
+   key.target = tObj->Target;
+   key.depthmode = tObj->DepthMode;
+   key.first_level = intelObj->firstLevel;
+   key.last_level = intelObj->lastLevel;
+   key.width = firstImage->Width;
+   key.height = firstImage->Height;
+   key.cpp = intelObj->mt->cpp;
+   key.depth = firstImage->Depth;
+   key.tiling = intelObj->mt->region->tiling;
+
+   dri_bo_unreference(brw->wm.surf_bo[unit + MAX_DRAW_BUFFERS]);
+   brw->wm.surf_bo[unit + MAX_DRAW_BUFFERS] = brw_search_cache(&brw->cache, BRW_SS_SURFACE,
+                                                              &key, sizeof(key),
+                                                              &key.bo, key.bo ? 1 : 0,
+                                                              NULL);
+   if (brw->wm.surf_bo[unit + MAX_DRAW_BUFFERS] == NULL) {
+      brw->wm.surf_bo[unit + MAX_DRAW_BUFFERS] = brw_create_texture_surface(brw, &key);
+   }
+}
 
-static void upload_wm_surfaces(struct brw_context *brw )
+/**
+ * Sets up a surface state structure to point at the given region.
+ * While it is only used for the front/back buffer currently, it should be
+ * usable for further buffers when doing ARB_draw_buffer support.
+ */
+static void
+brw_update_region_surface(struct brw_context *brw, struct intel_region *region,
+                         unsigned int unit, GLboolean cached)
 {
-   GLcontext *ctx = &brw->intel.ctx;
-   struct intel_context *intel = &brw->intel;
-   struct brw_surface_binding_table bind;
-   GLuint i;
-
-   memcpy(&bind, &brw->wm.bind, sizeof(bind));
-      
-   {
+   dri_bo *region_bo = NULL;
+   struct {
+      unsigned int surface_type;
+      unsigned int surface_format;
+      unsigned int width, height, cpp;
+      GLubyte color_mask[4];
+      GLboolean color_blend;
+      uint32_t tiling;
+   } key;
+
+   memset(&key, 0, sizeof(key));
+
+   if (region != NULL) {
+      region_bo = region->buffer;
+
+      key.surface_type = BRW_SURFACE_2D;
+      if (region->cpp == 4)
+        key.surface_format = BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
+      else
+        key.surface_format = BRW_SURFACEFORMAT_B5G6R5_UNORM;
+      key.tiling = region->tiling;
+      key.width = region->pitch; /* XXX: not really! */
+      key.height = region->height;
+      key.cpp = region->cpp;
+   } else {
+      key.surface_type = BRW_SURFACE_NULL;
+      key.surface_format = BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
+      key.tiling = 0;
+      key.width = 1;
+      key.height = 1;
+      key.cpp = 4;
+   }
+   memcpy(key.color_mask, brw->attribs.Color->ColorMask,
+         sizeof(key.color_mask));
+   key.color_blend = (!brw->attribs.Color->_LogicOpEnabled &&
+                     brw->attribs.Color->BlendEnabled);
+
+   dri_bo_unreference(brw->wm.surf_bo[unit]);
+   brw->wm.surf_bo[unit] = NULL;
+   if (cached) 
+       brw->wm.surf_bo[unit] = brw_search_cache(&brw->cache, BRW_SS_SURFACE,
+              &key, sizeof(key),
+              &region_bo, 1,
+              NULL);
+
+   if (brw->wm.surf_bo[unit] == NULL) {
       struct brw_surface_state surf;
-      struct intel_region *region = brw->state.draw_region;
 
       memset(&surf, 0, sizeof(surf));
 
-      if (region->cpp == 4)
-        surf.ss0.surface_format = BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
-      else 
-        surf.ss0.surface_format = BRW_SURFACEFORMAT_B5G6R5_UNORM;
+      surf.ss0.surface_format = key.surface_format;
+      surf.ss0.surface_type = key.surface_type;
+      if (region_bo != NULL)
+        surf.ss1.base_addr = region_bo->offset; /* reloc */
 
-      surf.ss0.surface_type = BRW_SURFACE_2D;
+      surf.ss2.width = key.width - 1;
+      surf.ss2.height = key.height - 1;
+      brw_set_surface_tiling(&surf, key.tiling);
+      surf.ss3.pitch = (key.width * key.cpp) - 1;
 
       /* _NEW_COLOR */
-      surf.ss0.color_blend = (!brw->attribs.Color->_LogicOpEnabled &&
-                             brw->attribs.Color->BlendEnabled);
+      surf.ss0.color_blend = key.color_blend;
+      surf.ss0.writedisable_red =   !key.color_mask[0];
+      surf.ss0.writedisable_green = !key.color_mask[1];
+      surf.ss0.writedisable_blue =  !key.color_mask[2];
+      surf.ss0.writedisable_alpha = !key.color_mask[3];
+
+      /* Key size will never match key size for textures, so we're safe. */
+      brw->wm.surf_bo[unit] = brw_upload_cache(&brw->cache, BRW_SS_SURFACE,
+                                             &key, sizeof(key),
+                                              &region_bo, 1,
+                                              &surf, sizeof(surf),
+                                              NULL, NULL);
+      if (region_bo != NULL) {
+        /* We might sample from it, and we might render to it, so flag
+         * them both.  We might be able to figure out from other state
+         * a more restrictive relocation to emit.
+         */
+        dri_bo_emit_reloc(brw->wm.surf_bo[unit],
+                          I915_GEM_DOMAIN_RENDER |
+                          I915_GEM_DOMAIN_SAMPLER,
+                          I915_GEM_DOMAIN_RENDER,
+                          0,
+                          offsetof(struct brw_surface_state, ss1),
+                          region_bo);
+      }
+   }
+}
 
 
-      surf.ss0.writedisable_red =   !brw->attribs.Color->ColorMask[0];
-      surf.ss0.writedisable_green = !brw->attribs.Color->ColorMask[1];
-      surf.ss0.writedisable_blue =  !brw->attribs.Color->ColorMask[2];
-      surf.ss0.writedisable_alpha = !brw->attribs.Color->ColorMask[3];
+/**
+ * Constructs the binding table for the WM surface state, which maps unit
+ * numbers to surface state objects.
+ */
+static dri_bo *
+brw_wm_get_binding_table(struct brw_context *brw)
+{
+   dri_bo *bind_bo;
+
+   bind_bo = brw_search_cache(&brw->cache, BRW_SS_SURF_BIND,
+                             NULL, 0,
+                             brw->wm.surf_bo, brw->wm.nr_surfaces,
+                             NULL);
+
+   if (bind_bo == NULL) {
+      GLuint data_size = brw->wm.nr_surfaces * sizeof(GLuint);
+      uint32_t *data = malloc(data_size);
+      int i;
+
+      for (i = 0; i < brw->wm.nr_surfaces; i++)
+         if (brw->wm.surf_bo[i])
+            data[i] = brw->wm.surf_bo[i]->offset;
+         else
+            data[i] = 0;
+
+      bind_bo = brw_upload_cache( &brw->cache, BRW_SS_SURF_BIND,
+                                 NULL, 0,
+                                 brw->wm.surf_bo, brw->wm.nr_surfaces,
+                                 data, data_size,
+                                 NULL, NULL);
+
+      /* Emit binding table relocations to surface state */
+      for (i = 0; i < BRW_WM_MAX_SURF; i++) {
+        if (brw->wm.surf_bo[i] != NULL) {
+           dri_bo_emit_reloc(bind_bo,
+                             I915_GEM_DOMAIN_INSTRUCTION, 0,
+                             0,
+                             i * sizeof(GLuint),
+                             brw->wm.surf_bo[i]);
+        }
+      }
 
-      /* BRW_NEW_LOCK */
-      surf.ss1.base_addr = bmBufferOffset(&brw->intel, region->buffer);
+      free(data);
+   }
 
+   return bind_bo;
+}
 
-      surf.ss2.width = region->pitch - 1; /* XXX: not really! */
-      surf.ss2.height = region->height - 1;
-      surf.ss3.tile_walk = BRW_TILEWALK_XMAJOR;
-      surf.ss3.tiled_surface = region->tiled;
-      surf.ss3.pitch = (region->pitch * region->cpp) - 1;
+static void prepare_wm_surfaces(struct brw_context *brw )
+{
+   GLcontext *ctx = &brw->intel.ctx;
+   struct intel_context *intel = &brw->intel;
+   GLuint i;
 
-      brw->wm.bind.surf_ss_offset[0] = brw_cache_data( &brw->cache[BRW_SS_SURFACE], &surf );
-      brw->wm.nr_surfaces = 1;
+   if (brw->state.nr_draw_regions  > 1) {
+      for (i = 0; i < brw->state.nr_draw_regions; i++) {
+         brw_update_region_surface(brw, brw->state.draw_regions[i], i,
+                                  GL_FALSE);
+      }
+   }else {
+      brw_update_region_surface(brw, brw->state.draw_regions[0], 0, GL_TRUE);
    }
 
+   brw->wm.nr_surfaces = MAX_DRAW_BUFFERS;
 
    for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {
       struct gl_texture_unit *texUnit = &brw->attribs.Texture->Unit[i];
 
-      /* _NEW_TEXTURE, BRW_NEW_TEXDATA 
-       */
-      if (texUnit->_ReallyEnabled &&
-         intel_finalize_mipmap_tree(intel,texUnit->_Current)) {
-
-        struct brw_surface_state surf;
-
-        brw_update_texture_surface(ctx, i, &surf);
-
-        brw->wm.bind.surf_ss_offset[i+1] = brw_cache_data( &brw->cache[BRW_SS_SURFACE], &surf );
-        brw->wm.nr_surfaces = i+2;
-      }
-      else if( texUnit->_ReallyEnabled &&
-              texUnit->_Current == intel->frame_buffer_texobj )
-      {
-        brw->wm.bind.surf_ss_offset[i+1] = brw->wm.bind.surf_ss_offset[0];
-        brw->wm.nr_surfaces = i+2;
-      }    
-      else {
-        brw->wm.bind.surf_ss_offset[i+1] = 0;
+      /* _NEW_TEXTURE, BRW_NEW_TEXDATA */
+      if(texUnit->_ReallyEnabled) {
+         if (texUnit->_Current == intel->frame_buffer_texobj) {
+            dri_bo_unreference(brw->wm.surf_bo[i+MAX_DRAW_BUFFERS]);
+            brw->wm.surf_bo[i+MAX_DRAW_BUFFERS] = brw->wm.surf_bo[0];
+            dri_bo_reference(brw->wm.surf_bo[i+MAX_DRAW_BUFFERS]);
+            brw->wm.nr_surfaces = i + MAX_DRAW_BUFFERS + 1;
+         } else {
+            brw_update_texture_surface(ctx, i);
+            brw->wm.nr_surfaces = i + MAX_DRAW_BUFFERS + 1;
+         }
+      } else {
+         dri_bo_unreference(brw->wm.surf_bo[i+MAX_DRAW_BUFFERS]);
+         brw->wm.surf_bo[i+MAX_DRAW_BUFFERS] = NULL;
       }
+
    }
 
-   brw->wm.bind_ss_offset = brw_cache_data( &brw->cache[BRW_SS_SURF_BIND],
-                                           &brw->wm.bind );
+   dri_bo_unreference(brw->wm.bind_bo);
+   brw->wm.bind_bo = brw_wm_get_binding_table(brw);
 }
 
+
 const struct brw_tracked_state brw_wm_surfaces = {
    .dirty = {
       .mesa = _NEW_COLOR | _NEW_TEXTURE | _NEW_BUFFERS,
-      .brw = (BRW_NEW_CONTEXT | 
-             BRW_NEW_LOCK),    /* required for bmBufferOffset */
+      .brw = BRW_NEW_CONTEXT,
       .cache = 0
    },
-   .update = upload_wm_surfaces
+   .prepare = prepare_wm_surfaces,
 };
 
 
diff --git a/src/mesa/drivers/dri/i965/bufmgr.h b/src/mesa/drivers/dri/i965/bufmgr.h
deleted file mode 100644 (file)
index e748c0d..0000000
+++ /dev/null
@@ -1,215 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2006 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 BUFMGR_H
-#define BUFMGR_H
-
-#include "intel_context.h"
-
-
-/* The buffer manager context.  Opaque.
- */
-struct bufmgr;
-struct buffer;
-
-
-struct bufmgr *bm_fake_intel_Attach( struct intel_context *intel ); 
-
-/* Flags for validate and other calls.  If both NO_UPLOAD and NO_EVICT
- * are specified, ValidateBuffers is essentially a query.
- */
-#define BM_MEM_LOCAL   0x1
-#define BM_MEM_AGP     0x2
-#define BM_MEM_VRAM    0x4     /* not yet used */
-#define BM_WRITE       0x8     /* not yet used */
-#define BM_READ        0x10    /* not yet used */
-#define BM_NO_UPLOAD   0x20
-#define BM_NO_EVICT    0x40
-#define BM_NO_MOVE     0x80    /* not yet used */
-#define BM_NO_ALLOC    0x100   /* legacy "fixed" buffers only */
-#define BM_CLIENT      0x200   /* for map - pointer will be accessed
-                                * without dri lock */
-
-#define BM_MEM_MASK (BM_MEM_LOCAL|BM_MEM_AGP|BM_MEM_VRAM)
-
-
-
-
-/* Create a pool of a given memory type, from a certain offset and a
- * certain size.  
- *
- * Also passed in is a virtual pointer to the start of the pool.  This
- * is useful in the faked-out version in i915 so that MapBuffer can
- * return a pointer to a buffer residing in AGP space.  
- *
- * Flags passed into a pool are inherited by all buffers allocated in
- * that pool.  So pools representing the static front,back,depth
- * buffer allocations should have MEM_AGP|NO_UPLOAD|NO_EVICT|NO_MOVE to match
- * the behaviour of the legacy allocations.
- *
- * Returns -1 for failure, pool number for success.
- */
-int bmInitPool( struct intel_context *, 
-               unsigned long low_offset,
-               void *low_virtual,
-               unsigned long size,
-               unsigned flags);
-
-
-/* Stick closely to ARB_vbo semantics - they're well defined and
- * understood, and drivers can just pass the calls through without too
- * much thunking.
- */
-void bmGenBuffers(struct intel_context *, const char *, unsigned n, struct buffer **buffers,
-                 int align );
-void bmDeleteBuffers(struct intel_context *, unsigned n, struct buffer **buffers);
-
-
-/* Hook to inform faked buffer manager about fixed-position
- * front,depth,back buffers.  These may move to a fully memory-managed
- * scheme, or they may continue to be managed as is.
- */
-struct buffer *bmGenBufferStatic(struct intel_context *,
-                                unsigned pool);
-
-/* On evict, buffer manager will call invalidate_cb() to note that the
- * buffer needs to be reloaded.
- *
- * Buffer is uploaded by calling bmMapBuffer() and copying data into
- * the returned pointer.
- *
- * This is basically a big hack to get some more performance by
- * turning off backing store for buffers where we either have it
- * already (textures) or don't need it (batch buffers, temporary
- * vbo's).
- */
-void bmBufferSetInvalidateCB(struct intel_context *,
-                            struct buffer *buf,
-                            void (*invalidate_cb)( struct intel_context *, void *ptr ),
-                            void *ptr,
-                            GLboolean dont_fence_subdata);
-
-
-/* The driver has more intimate knowledge of the hardare than a GL
- * client would, so flags here is more proscriptive than the usage
- * values in the ARB_vbo interface:
- */
-int bmBufferData(struct intel_context *, 
-                 struct buffer *buf, 
-                 unsigned size, 
-                 const void *data, 
-                 unsigned flags );
-
-int bmBufferSubData(struct intel_context *, 
-                    struct buffer *buf, 
-                    unsigned offset, 
-                    unsigned size, 
-                    const void *data );
-
-
-int bmBufferDataAUB(struct intel_context *, 
-                    struct buffer *buf, 
-                    unsigned size, 
-                    const void *data, 
-                    unsigned flags,
-                    unsigned aubtype,
-                    unsigned aubsubtype );
-
-int bmBufferSubDataAUB(struct intel_context *, 
-                       struct buffer *buf, 
-                       unsigned offset, 
-                       unsigned size, 
-                       const void *data,
-                       unsigned aubtype,
-                       unsigned aubsubtype );
-
-
-/* In this version, taking the offset will provoke an upload on
- * buffers not already resident in AGP:
- */
-unsigned bmBufferOffset(struct intel_context *, 
-                       struct buffer *buf);
-
-
-/* Extract data from the buffer:
- */
-void bmBufferGetSubData(struct intel_context *, 
-                       struct buffer *buf, 
-                       unsigned offset, 
-                       unsigned size, 
-                       void *data );
-
-void *bmMapBuffer( struct intel_context *,
-                  struct buffer *buf, 
-                  unsigned access );
-
-void bmUnmapBuffer( struct intel_context *,
-                   struct buffer *buf );
-
-void bmUnmapBufferAUB( struct intel_context *,
-                      struct buffer *buf,
-                      unsigned aubtype,
-                      unsigned aubsubtype );
-
-
-/* Pertains to all buffers who's offset has been taken since the last
- * fence or release.
- */
-int bmValidateBuffers( struct intel_context * );
-void bmReleaseBuffers( struct intel_context * );
-
-GLuint bmCtxId( struct intel_context *intel );
-
-
-GLboolean bmError( struct intel_context * );
-void bmEvictAll( struct intel_context * );
-
-void *bmFindVirtual( struct intel_context *intel,
-                    unsigned int offset,
-                    size_t sz );
-
-/* This functionality is used by the buffer manager, not really sure
- * if we need to be exposing it in this way, probably libdrm will
- * offer equivalent calls.
- *
- * For now they can stay, but will likely change/move before final:
- */
-unsigned bmSetFence( struct intel_context * );
-unsigned bmSetFenceLock( struct intel_context * );
-unsigned bmLockAndFence( struct intel_context *intel );
-int bmTestFence( struct intel_context *, unsigned fence );
-void bmFinishFence( struct intel_context *, unsigned fence );
-void bmFinishFenceLock( struct intel_context *, unsigned fence );
-
-void bm_fake_NotifyContendedLockTake( struct intel_context * );
-
-extern int INTEL_DEBUG;
-#define DEBUG_BUFMGR 0x10000000
-
-#define DBG(...)  do { if (INTEL_DEBUG & DEBUG_BUFMGR) _mesa_printf(__VA_ARGS__); } while(0)
-
-#endif
diff --git a/src/mesa/drivers/dri/i965/bufmgr_fake.c b/src/mesa/drivers/dri/i965/bufmgr_fake.c
deleted file mode 100644 (file)
index 24ee11e..0000000
+++ /dev/null
@@ -1,1460 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2006 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.
- * 
- **************************************************************************/
-
-/* Originally a fake version of the buffer manager so that we can
- * prototype the changes in a driver fairly quickly, has been fleshed
- * out to a fully functional interim solution.
- *
- * Basically wraps the old style memory management in the new
- * programming interface, but is more expressive and avoids many of
- * the bugs in the old texture manager.
- */
-#include "bufmgr.h"
-
-#include "intel_context.h"
-#include "intel_ioctl.h"
-#include "intel_batchbuffer.h"
-
-#include "simple_list.h"
-#include "mm.h"
-#include "imports.h"
-
-#define BM_POOL_MAX 8
-
-/* Internal flags:
- */
-#define BM_NO_BACKING_STORE   0x2000
-#define BM_NO_FENCE_SUBDATA   0x4000
-
-
-static int check_fenced( struct intel_context *intel );
-
-static int nr_attach = 0;
-
-/* Wrapper around mm.c's mem_block, which understands that you must
- * wait for fences to expire before memory can be freed.  This is
- * specific to our use of memcpy for uploads - an upload that was
- * processed through the command queue wouldn't need to care about
- * fences.
- */
-struct block {
-   struct block *next, *prev;
-   struct pool *pool;          /* BM_MEM_AGP */
-   struct mem_block *mem;      /* BM_MEM_AGP */
-
-   unsigned referenced:1;
-   unsigned on_hardware:1;
-   unsigned fenced:1;  
-   
-
-   unsigned fence;             /* BM_MEM_AGP, Split to read_fence, write_fence */
-
-   struct buffer *buf;
-   void *virtual;
-};
-
-
-struct buffer {
-   unsigned id;                        /* debug only */
-   const char *name;
-   unsigned size;
-
-   unsigned mapped:1;          
-   unsigned dirty:1;           
-   unsigned aub_dirty:1;       
-   unsigned alignment:13;
-   unsigned flags:16;
-
-   struct block *block;
-   void *backing_store;
-   void (*invalidate_cb)( struct intel_context *, void * );
-   void *invalidate_ptr;
-};
-
-struct pool {
-   unsigned size;
-   unsigned low_offset;
-   struct buffer *static_buffer;
-   unsigned flags;
-   struct mem_block *heap;
-   void *virtual;
-   struct block lru;           /* only allocated, non-fence-pending blocks here */
-};
-
-struct bufmgr {
-   _glthread_Mutex mutex;      /**< for thread safety */
-   struct pool pool[BM_POOL_MAX];
-   unsigned nr_pools;
-
-   unsigned buf_nr;            /* for generating ids */
-
-   struct block referenced;    /* after bmBufferOffset */
-   struct block on_hardware;   /* after bmValidateBuffers */
-   struct block fenced;                /* after bmFenceBuffers (mi_flush, emit irq, write dword) */
-                                /* then to pool->lru or free() */
-
-   unsigned ctxId;
-   unsigned last_fence;
-   unsigned free_on_hardware;
-
-   unsigned fail:1;
-   unsigned need_fence:1;
-};
-
-#define MAXFENCE 0x7fffffff
-
-static GLboolean FENCE_LTE( unsigned a, unsigned b )
-{
-   if (a == b)
-      return GL_TRUE;
-
-   if (a < b && b - a < (1<<24))
-      return GL_TRUE;
-
-   if (a > b && MAXFENCE - a + b < (1<<24))
-      return GL_TRUE;
-
-   return GL_FALSE;
-}
-
-int bmTestFence( struct intel_context *intel, unsigned fence )
-{
-   /* Slight problem with wrap-around:
-    */
-   return fence == 0 || FENCE_LTE(fence, intel->sarea->last_dispatch);
-}
-
-#define LOCK(bm) \
-  int dolock = nr_attach > 1; \
-  if (dolock) _glthread_LOCK_MUTEX(bm->mutex)
-
-#define UNLOCK(bm) \
-  if (dolock) _glthread_UNLOCK_MUTEX(bm->mutex)
-
-
-
-static GLboolean alloc_from_pool( struct intel_context *intel,                         
-                                 unsigned pool_nr,
-                                 struct buffer *buf )
-{
-   struct bufmgr *bm = intel->bm;
-   struct pool *pool = &bm->pool[pool_nr];
-   struct block *block = (struct block *)calloc(sizeof *block, 1);
-   GLuint sz, align = (1<<buf->alignment);
-
-   if (!block)
-      return GL_FALSE;
-
-   sz = (buf->size + align-1) & ~(align-1);
-
-   block->mem = mmAllocMem(pool->heap, 
-                          sz, 
-                          buf->alignment, 0);
-   if (!block->mem) {
-      free(block);
-      return GL_FALSE;
-   }
-
-   make_empty_list(block);
-
-   /* Insert at head or at tail???   
-    */
-   insert_at_tail(&pool->lru, block);
-
-   block->pool = pool;
-   block->virtual = pool->virtual + block->mem->ofs;
-   block->buf = buf;
-
-   buf->block = block;
-
-   return GL_TRUE;
-}
-
-
-
-
-
-
-
-
-/* Release the card storage associated with buf:
- */
-static void free_block( struct intel_context *intel, struct block *block )
-{
-   DBG("free block %p\n", block);
-
-   if (!block) 
-      return;
-
-   check_fenced(intel);
-
-   if (block->referenced) {
-      _mesa_printf("tried to free block on referenced list\n");
-      assert(0);
-   }
-   else if (block->on_hardware) {
-      block->buf = NULL;
-      intel->bm->free_on_hardware += block->mem->size;
-   }
-   else if (block->fenced) {
-      block->buf = NULL;
-   }
-   else {
-      DBG("    - free immediately\n");
-      remove_from_list(block);
-
-      mmFreeMem(block->mem);
-      free(block);
-   }
-}
-
-
-static void alloc_backing_store( struct intel_context *intel, struct buffer *buf )
-{
-   assert(!buf->backing_store);
-   assert(!(buf->flags & (BM_NO_EVICT|BM_NO_BACKING_STORE)));
-
-   buf->backing_store = ALIGN_MALLOC(buf->size, 64);
-}
-
-static void free_backing_store( struct intel_context *intel, struct buffer *buf )
-{
-   assert(!(buf->flags & (BM_NO_EVICT|BM_NO_BACKING_STORE)));
-         
-   if (buf->backing_store) {
-      ALIGN_FREE(buf->backing_store);
-      buf->backing_store = NULL;
-   }
-}
-
-
-
-
-
-
-static void set_dirty( struct intel_context *intel,
-                             struct buffer *buf )
-{
-   if (buf->flags & BM_NO_BACKING_STORE)
-      buf->invalidate_cb(intel, buf->invalidate_ptr);
-
-   assert(!(buf->flags & BM_NO_EVICT));
-
-   DBG("set_dirty - buf %d\n", buf->id);
-   buf->dirty = 1;
-}
-
-
-static int evict_lru( struct intel_context *intel, GLuint max_fence, GLuint *pool )
-{
-   struct bufmgr *bm = intel->bm;
-   struct block *block, *tmp;
-   int i;
-
-   DBG("%s\n", __FUNCTION__);
-
-   for (i = 0; i < bm->nr_pools; i++) {
-      if (!(bm->pool[i].flags & BM_NO_EVICT)) {
-        foreach_s(block, tmp, &bm->pool[i].lru) {
-
-           if (block->buf &&
-               (block->buf->flags & BM_NO_FENCE_SUBDATA))
-              continue;
-
-           if (block->fence && max_fence &&
-               !FENCE_LTE(block->fence, max_fence))
-              return 0;
-
-           set_dirty(intel, block->buf);
-           block->buf->block = NULL;
-
-           free_block(intel, block);
-           *pool = i;
-           return 1;
-        }
-      }
-   }
-
-
-   return 0;
-}
-
-
-#define foreach_s_rev(ptr, t, list)   \
-        for(ptr=(list)->prev,t=(ptr)->prev; list != ptr; ptr=t, t=(t)->prev)
-
-static int evict_mru( struct intel_context *intel, GLuint *pool )
-{
-   struct bufmgr *bm = intel->bm;
-   struct block *block, *tmp;
-   int i;
-
-   DBG("%s\n", __FUNCTION__);
-
-   for (i = 0; i < bm->nr_pools; i++) {
-      if (!(bm->pool[i].flags & BM_NO_EVICT)) {
-        foreach_s_rev(block, tmp, &bm->pool[i].lru) {
-
-           if (block->buf &&
-               (block->buf->flags & BM_NO_FENCE_SUBDATA))
-              continue;
-
-           set_dirty(intel, block->buf);
-           block->buf->block = NULL;
-
-           free_block(intel, block);
-           *pool = i;
-           return 1;
-        }
-      }
-   }
-
-
-   return 0;
-}
-
-
-static int check_fenced( struct intel_context *intel )
-{
-   struct bufmgr *bm = intel->bm;
-   struct block *block, *tmp;
-   int ret = 0;
-
-   foreach_s(block, tmp, &bm->fenced ) {
-      assert(block->fenced);
-
-      if (bmTestFence(intel, block->fence)) {
-
-        block->fenced = 0;
-
-        if (!block->buf) {
-           DBG("delayed free: offset %x sz %x\n", block->mem->ofs, block->mem->size);
-           remove_from_list(block);
-           mmFreeMem(block->mem);
-           free(block);
-        }
-        else {
-           DBG("return to lru: offset %x sz %x\n", block->mem->ofs, block->mem->size);
-           move_to_tail(&block->pool->lru, block);
-        }
-
-        ret = 1;
-      }
-      else {
-        /* Blocks are ordered by fence, so if one fails, all from
-         * here will fail also:
-         */
-        break;
-      }
-   }
-
-   /* Also check the referenced list: 
-    */
-   foreach_s(block, tmp, &bm->referenced ) {
-      if (block->fenced &&
-         bmTestFence(intel, block->fence)) {
-        block->fenced = 0;
-      }
-   }
-
-   
-   DBG("%s: %d\n", __FUNCTION__, ret);
-   return ret;
-}
-
-
-
-static void fence_blocks( struct intel_context *intel,
-                         unsigned fence )
-{
-   struct bufmgr *bm = intel->bm;
-   struct block *block, *tmp;
-
-   foreach_s (block, tmp, &bm->on_hardware) {
-      DBG("Fence block %p (sz 0x%x buf %p) with fence %d\n", block, 
-         block->mem->size, block->buf, fence);
-      block->fence = fence;
-
-      block->on_hardware = 0;
-      block->fenced = 1;
-
-      /* Move to tail of pending list here
-       */
-      move_to_tail(&bm->fenced, block);
-   }
-
-   /* Also check the referenced list:
-    */  
-   foreach_s (block, tmp, &bm->referenced) {
-      if (block->on_hardware) {
-        DBG("Fence block %p (sz 0x%x buf %p) with fence %d\n", block, 
-            block->mem->size, block->buf, fence);
-        
-        block->fence = fence;
-        block->on_hardware = 0;
-        block->fenced = 1;
-      }
-   }
-
-
-   bm->last_fence = fence;
-   assert(is_empty_list(&bm->on_hardware));
-}
-
-
-
-
-static GLboolean alloc_block( struct intel_context *intel,
-                             struct buffer *buf )
-{
-   struct bufmgr *bm = intel->bm;
-   int i;
-
-   assert(intel->locked);
-
-   DBG("%s 0x%x bytes (%s)\n", __FUNCTION__, buf->size, buf->name);
-
-   for (i = 0; i < bm->nr_pools; i++) {
-      if (!(bm->pool[i].flags & BM_NO_ALLOC) &&
-         alloc_from_pool(intel, i, buf)) {
-
-        DBG("%s --> 0x%x (sz %x)\n", __FUNCTION__, 
-            buf->block->mem->ofs, buf->block->mem->size);
-        
-        return GL_TRUE;
-      }
-   }
-
-   DBG("%s --> fail\n", __FUNCTION__);
-   return GL_FALSE;   
-}
-
-
-static GLboolean evict_and_alloc_block( struct intel_context *intel,
-                                       struct buffer *buf )
-{
-   GLuint pool;
-   struct bufmgr *bm = intel->bm;
-
-   assert(buf->block == NULL);
-
-   /* Put a cap on the amount of free memory we'll allow to accumulate
-    * before emitting a fence.
-    */
-   if (bm->free_on_hardware > 1 * 1024 * 1024) {
-      DBG("fence for free space: %x\n", bm->free_on_hardware);
-      bmSetFence(intel);
-   }
-
-   /* Search for already free memory:
-    */
-   if (alloc_block(intel, buf))
-      return GL_TRUE;
-
-   /* Look for memory that may have become free: 
-    */
-   if (check_fenced(intel) &&
-       alloc_block(intel, buf))
-      return GL_TRUE;
-
-   /* Look for memory blocks not used for >1 frame:
-    */
-   while (evict_lru(intel, intel->second_last_swap_fence, &pool))
-      if (alloc_from_pool(intel, pool, buf))
-        return GL_TRUE;
-
-   /* If we're not thrashing, allow lru eviction to dig deeper into
-    * recently used textures.  We'll probably be thrashing soon:
-    */
-   if (!intel->thrashing) {
-      while (evict_lru(intel, 0, &pool))
-        if (alloc_from_pool(intel, pool, buf))
-           return GL_TRUE;
-   }
-
-   /* Keep thrashing counter alive?
-    */
-   if (intel->thrashing)
-      intel->thrashing = 20;
-
-   /* Wait on any already pending fences - here we are waiting for any
-    * freed memory that has been submitted to hardware and fenced to
-    * become available:
-    */
-   while (!is_empty_list(&bm->fenced)) {
-      GLuint fence = bm->fenced.next->fence;
-      bmFinishFence(intel, fence);
-
-      if (alloc_block(intel, buf))
-        return GL_TRUE;
-   }
-
-
-   /* 
-    */
-   if (!is_empty_list(&bm->on_hardware)) {
-      bmSetFence(intel);
-
-      while (!is_empty_list(&bm->fenced)) {
-        GLuint fence = bm->fenced.next->fence;
-        bmFinishFence(intel, fence);
-      }
-
-      if (!intel->thrashing) {  
-        DBG("thrashing\n");
-      }
-      intel->thrashing = 20; 
-
-      if (alloc_block(intel, buf))
-        return GL_TRUE;
-   }
-
-   while (evict_mru(intel, &pool))
-      if (alloc_from_pool(intel, pool, buf))
-        return GL_TRUE;
-
-   DBG("%s 0x%x bytes failed\n", __FUNCTION__, buf->size);
-
-   assert(is_empty_list(&bm->on_hardware));
-   assert(is_empty_list(&bm->fenced));
-
-   return GL_FALSE;
-}
-
-
-
-
-
-
-
-
-
-
-/***********************************************************************
- * Public functions
- */
-
-
-/* The initialization functions are skewed in the fake implementation.
- * This call would be to attach to an existing manager, rather than to
- * create a local one.
- */
-struct bufmgr *bm_fake_intel_Attach( struct intel_context *intel )
-{
-   _glthread_DECLARE_STATIC_MUTEX(initMutex);   
-   static struct bufmgr bm;
-   
-   /* This function needs a mutex of its own...
-    */
-   _glthread_LOCK_MUTEX(initMutex);
-
-   if (nr_attach == 0) {
-      _glthread_INIT_MUTEX(bm.mutex);
-
-      make_empty_list(&bm.referenced);
-      make_empty_list(&bm.fenced);
-      make_empty_list(&bm.on_hardware);
-      
-      /* The context id of any of the share group.  This won't be used
-       * in communication with the kernel, so it doesn't matter if
-       * this context is eventually deleted.
-       */
-      bm.ctxId = intel->hHWContext;
-   }
-
-   nr_attach++;
-
-   _glthread_UNLOCK_MUTEX(initMutex);
-
-   return &bm;
-}
-
-
-
-/* The virtual pointer would go away in a true implementation.
- */
-int bmInitPool( struct intel_context *intel, 
-               unsigned long low_offset,
-               void *low_virtual,
-               unsigned long size,
-               unsigned flags)
-{
-   struct bufmgr *bm = intel->bm;
-   int retval = 0;
-
-   LOCK(bm);
-   {
-      GLuint i;
-
-      for (i = 0; i < bm->nr_pools; i++) {
-        if (bm->pool[i].low_offset == low_offset &&
-            bm->pool[i].size == size) {
-           retval = i;
-           goto out;
-        }
-      }
-
-
-      if (bm->nr_pools >= BM_POOL_MAX)
-        retval = -1;
-      else {
-        i = bm->nr_pools++;
-   
-        DBG("bmInitPool %d low_offset %x sz %x\n",
-            i, low_offset, size);
-   
-        bm->pool[i].low_offset = low_offset;
-        bm->pool[i].size = size;
-        bm->pool[i].heap = mmInit( low_offset, size );
-        bm->pool[i].virtual = low_virtual - low_offset;
-        bm->pool[i].flags = flags;
-   
-        make_empty_list(&bm->pool[i].lru);
-        
-        retval = i;
-      }
-   }
- out:
-   UNLOCK(bm);
-   return retval;
-}
-
-static struct buffer *do_GenBuffer(struct intel_context *intel, const char *name, int align)
-{
-   struct bufmgr *bm = intel->bm;
-   struct buffer *buf = calloc(sizeof(*buf), 1);
-
-   buf->id = ++bm->buf_nr;
-   buf->name = name;
-   buf->alignment = align;     
-   buf->flags = BM_MEM_AGP|BM_MEM_VRAM|BM_MEM_LOCAL;
-
-   return buf;
-}
-
-
-void *bmFindVirtual( struct intel_context *intel,
-                    unsigned int offset,
-                    size_t sz )
-{
-   struct bufmgr *bm = intel->bm;
-   int i;
-
-   for (i = 0; i < bm->nr_pools; i++)
-      if (offset >= bm->pool[i].low_offset &&
-         offset + sz <= bm->pool[i].low_offset + bm->pool[i].size)
-        return bm->pool[i].virtual + offset;
-
-   return NULL;
-}
-
-void bmGenBuffers(struct intel_context *intel, 
-                 const char *name, unsigned n, 
-                 struct buffer **buffers,
-                 int align )
-{
-   struct bufmgr *bm = intel->bm;
-   LOCK(bm);
-   {
-      int i;
-
-      for (i = 0; i < n; i++)
-        buffers[i] = do_GenBuffer(intel, name, align);
-   }
-   UNLOCK(bm);
-}
-
-
-void bmDeleteBuffers(struct intel_context *intel, unsigned n, struct buffer **buffers)
-{
-   struct bufmgr *bm = intel->bm;
-
-   LOCK(bm);
-   {
-      unsigned i;
-   
-      for (i = 0; i < n; i++) {
-        struct buffer *buf = buffers[i];
-
-        if (buf && buf->block)
-           free_block(intel, buf->block);
-
-        if (buf) 
-           free(buf);   
-      }
-   }
-   UNLOCK(bm);
-}
-
-
-
-
-/* Hook to inform faked buffer manager about fixed-position
- * front,depth,back buffers.  These may move to a fully memory-managed
- * scheme, or they may continue to be managed as is.  It will probably
- * be useful to pass a fixed offset here one day.
- */
-struct buffer *bmGenBufferStatic(struct intel_context *intel,
-                                unsigned pool )
-{
-   struct bufmgr *bm = intel->bm;
-   struct buffer *buf;
-   LOCK(bm);
-   {
-      assert(bm->pool[pool].flags & BM_NO_EVICT);
-      assert(bm->pool[pool].flags & BM_NO_MOVE);
-
-      if (bm->pool[pool].static_buffer)
-        buf = bm->pool[pool].static_buffer;
-      else {
-        buf = do_GenBuffer(intel, "static", 12);
-   
-        bm->pool[pool].static_buffer = buf;
-        assert(!buf->block);
-
-        buf->size = bm->pool[pool].size;
-        buf->flags = bm->pool[pool].flags;
-        buf->alignment = 12;
-        
-        if (!alloc_from_pool(intel, pool, buf))
-           assert(0);
-      }
-   }
-   UNLOCK(bm);
-   return buf;
-}
-
-
-static void wait_quiescent(struct intel_context *intel,
-                          struct block *block)
-{
-   if (block->on_hardware) {
-      assert(intel->bm->need_fence);
-      bmSetFence(intel);
-      assert(!block->on_hardware);
-   }
-
-
-   if (block->fenced) {
-      bmFinishFence(intel, block->fence);
-   }
-
-   assert(!block->on_hardware);
-   assert(!block->fenced);
-}
-
-
-
-/* If buffer size changes, free and reallocate.  Otherwise update in
- * place.
- */
-int bmBufferData(struct intel_context *intel, 
-                struct buffer *buf, 
-                unsigned size, 
-                const void *data, 
-                unsigned flags )
-{
-   struct bufmgr *bm = intel->bm;
-   int retval = 0;
-
-   LOCK(bm);
-   {
-      DBG("bmBufferData %d sz 0x%x data: %p\n", buf->id, size, data);
-
-      assert(!buf->mapped);
-
-      if (buf->block) {
-        struct block *block = buf->block;
-
-        /* Optimistic check to see if we can reuse the block -- not
-         * required for correctness:
-         */
-        if (block->fenced)
-           check_fenced(intel);
-
-        if (block->on_hardware ||
-            block->fenced ||
-            (buf->size && buf->size != size) || 
-            (data == NULL)) {
-
-           assert(!block->referenced);
-
-           free_block(intel, block);
-           buf->block = NULL;
-           buf->dirty = 1;
-        }
-      }
-
-      buf->size = size;
-      if (buf->block) {
-        assert (buf->block->mem->size >= size);
-      }
-
-      if (buf->flags & (BM_NO_BACKING_STORE|BM_NO_EVICT)) {
-
-        assert(intel->locked || data == NULL);
-
-        if (data != NULL) {
-           if (!buf->block && !evict_and_alloc_block(intel, buf)) {
-              bm->fail = 1;
-              retval = -1;
-              goto out;
-           }
-
-           wait_quiescent(intel, buf->block);
-
-           DBG("bmBufferData %d offset 0x%x sz 0x%x\n", 
-               buf->id, buf->block->mem->ofs, size);
-
-           assert(buf->block->virtual == buf->block->pool->virtual + buf->block->mem->ofs);
-
-           do_memcpy(buf->block->virtual, data, size);
-        }
-        buf->dirty = 0;
-      }
-      else {
-              DBG("%s - set buf %d dirty\n", __FUNCTION__, buf->id);
-        set_dirty(intel, buf);
-        free_backing_store(intel, buf);
-   
-        if (data != NULL) {      
-           alloc_backing_store(intel, buf);
-           do_memcpy(buf->backing_store, data, size);
-        }
-      }
-   }
- out:
-   UNLOCK(bm);
-   return retval;
-}
-
-
-/* Update the buffer in place, in whatever space it is currently resident:
- */
-int bmBufferSubData(struct intel_context *intel, 
-                    struct buffer *buf, 
-                    unsigned offset, 
-                    unsigned size, 
-                    const void *data )
-{
-   struct bufmgr *bm = intel->bm;
-   int retval = 0;
-
-   if (size == 0) 
-      return 0;
-
-   LOCK(bm); 
-   {
-      DBG("bmBufferSubdata %d offset 0x%x sz 0x%x\n", buf->id, offset, size);
-      
-      assert(offset+size <= buf->size);
-
-      if (buf->flags & (BM_NO_EVICT|BM_NO_BACKING_STORE)) {
-
-        assert(intel->locked);
-
-        if (!buf->block && !evict_and_alloc_block(intel, buf)) {
-           bm->fail = 1;
-           retval = -1;
-           goto out;
-        }
-        
-        if (!(buf->flags & BM_NO_FENCE_SUBDATA))
-           wait_quiescent(intel, buf->block);
-
-        buf->dirty = 0;
-
-        do_memcpy(buf->block->virtual + offset, data, size);
-      }
-      else {
-        DBG("%s - set buf %d dirty\n", __FUNCTION__, buf->id);
-        set_dirty(intel, buf);
-
-        if (buf->backing_store == NULL)
-           alloc_backing_store(intel, buf);
-
-        do_memcpy(buf->backing_store + offset, data, size); 
-      }
-   }
- out:
-   UNLOCK(bm);
-   return retval;
-}
-
-
-
-int bmBufferDataAUB(struct intel_context *intel, 
-                    struct buffer *buf, 
-                    unsigned size, 
-                    const void *data, 
-                    unsigned flags,
-                    unsigned aubtype,
-                    unsigned aubsubtype )
-{
-   int retval = bmBufferData(intel, buf, size, data, flags);
-   
-
-   /* This only works because in this version of the buffer manager we
-    * allocate all buffers statically in agp space and so can emit the
-    * uploads to the aub file with the correct offsets as they happen.
-    */
-   if (retval == 0 && data && intel->aub_file) {
-
-      if (buf->block && !buf->dirty) {
-        intel->vtbl.aub_gtt_data(intel,
-                                     buf->block->mem->ofs,
-                                     buf->block->virtual,
-                                     size,
-                                     aubtype,
-                                     aubsubtype);
-        buf->aub_dirty = 0;
-      }
-   }
-   
-   return retval;
-}
-                      
-
-int bmBufferSubDataAUB(struct intel_context *intel, 
-                       struct buffer *buf, 
-                       unsigned offset, 
-                       unsigned size, 
-                       const void *data,
-                       unsigned aubtype,
-                       unsigned aubsubtype )
-{
-   int retval = bmBufferSubData(intel, buf, offset, size, data);
-   
-
-   /* This only works because in this version of the buffer manager we
-    * allocate all buffers statically in agp space and so can emit the
-    * uploads to the aub file with the correct offsets as they happen.
-    */
-   if (intel->aub_file) {
-      if (retval == 0 && buf->block && !buf->dirty)
-        intel->vtbl.aub_gtt_data(intel,
-                                     buf->block->mem->ofs + offset,
-                                     ((const char *)buf->block->virtual) + offset,
-                                     size,
-                                     aubtype,
-                                     aubsubtype);
-   }
-
-   return retval;
-}
-
-void bmUnmapBufferAUB( struct intel_context *intel, 
-                      struct buffer *buf,
-                      unsigned aubtype,
-                      unsigned aubsubtype )
-{
-   bmUnmapBuffer(intel, buf);
-
-   if (intel->aub_file) {
-      /* Hack - exclude the framebuffer mappings.  If you removed
-       * this, you'd get very big aubfiles, but you *would* be able to
-       * see fallback rendering.
-       */
-      if (buf->block  && !buf->dirty && buf->block->pool == &intel->bm->pool[0]) {
-        buf->aub_dirty = 1;
-      }
-   }
-}
-
-unsigned bmBufferOffset(struct intel_context *intel, 
-                       struct buffer *buf)
-{
-   struct bufmgr *bm = intel->bm;
-   unsigned retval = 0;
-
-   LOCK(bm);
-   {
-      assert(intel->locked);
-
-      if (!buf->block &&
-         !evict_and_alloc_block(intel, buf)) {
-        bm->fail = 1;
-        retval = ~0;
-      }
-      else {
-        assert(buf->block);
-        assert(buf->block->buf == buf);
-
-        DBG("Add buf %d (block %p, dirty %d) to referenced list\n", buf->id, buf->block,
-            buf->dirty);
-
-        move_to_tail(&bm->referenced, buf->block);
-        buf->block->referenced = 1;
-
-        retval = buf->block->mem->ofs;
-      }
-   }
-   UNLOCK(bm);
-
-   return retval;
-}
-
-
-
-/* Extract data from the buffer:
- */
-void bmBufferGetSubData(struct intel_context *intel, 
-                       struct buffer *buf, 
-                       unsigned offset, 
-                       unsigned size, 
-                       void *data )
-{
-   struct bufmgr *bm = intel->bm;
-
-   LOCK(bm);
-   {
-      DBG("bmBufferSubdata %d offset 0x%x sz 0x%x\n", buf->id, offset, size);
-
-      if (buf->flags & (BM_NO_EVICT|BM_NO_BACKING_STORE)) {
-        if (buf->block && size) {
-           wait_quiescent(intel, buf->block);
-           do_memcpy(data, buf->block->virtual + offset, size); 
-        }
-      }
-      else {
-        if (buf->backing_store && size) {
-           do_memcpy(data, buf->backing_store + offset, size); 
-        }
-      }
-   }
-   UNLOCK(bm);
-}
-
-
-/* Return a pointer to whatever space the buffer is currently resident in:
- */
-void *bmMapBuffer( struct intel_context *intel,
-                  struct buffer *buf, 
-                  unsigned flags )
-{
-   struct bufmgr *bm = intel->bm;
-   void *retval = NULL;
-
-   LOCK(bm);
-   {
-      DBG("bmMapBuffer %d\n", buf->id);
-
-      if (buf->mapped) {
-        _mesa_printf("%s: already mapped\n", __FUNCTION__);
-        retval = NULL;
-      }
-      else if (buf->flags & (BM_NO_BACKING_STORE|BM_NO_EVICT)) {
-
-        assert(intel->locked);
-
-        if (!buf->block && !evict_and_alloc_block(intel, buf)) {
-           DBG("%s: alloc failed\n", __FUNCTION__);
-           bm->fail = 1;
-           retval = NULL;
-        }
-        else {
-           assert(buf->block);
-           buf->dirty = 0;
-
-           if (!(buf->flags & BM_NO_FENCE_SUBDATA)) 
-              wait_quiescent(intel, buf->block);
-
-           buf->mapped = 1;
-           retval = buf->block->virtual;
-        }
-      }
-      else {
-        DBG("%s - set buf %d dirty\n", __FUNCTION__, buf->id);
-        set_dirty(intel, buf);
-
-        if (buf->backing_store == 0)
-           alloc_backing_store(intel, buf);
-
-        buf->mapped = 1;
-        retval = buf->backing_store;
-      }
-   }
-   UNLOCK(bm);
-   return retval;
-}
-
-void bmUnmapBuffer( struct intel_context *intel, struct buffer *buf )
-{
-   struct bufmgr *bm = intel->bm;
-
-   LOCK(bm);
-   {
-      DBG("bmUnmapBuffer %d\n", buf->id);
-      buf->mapped = 0;
-   }
-   UNLOCK(bm);
-}
-
-
-
-
-/* This is the big hack that turns on BM_NO_BACKING_STORE.  Basically
- * says that an external party will maintain the backing store, eg
- * Mesa's local copy of texture data.
- */
-void bmBufferSetInvalidateCB(struct intel_context *intel,
-                            struct buffer *buf,
-                            void (*invalidate_cb)( struct intel_context *, void *ptr ),
-                            void *ptr,
-                            GLboolean dont_fence_subdata)
-{
-   struct bufmgr *bm = intel->bm;
-
-   LOCK(bm);
-   {
-      if (buf->backing_store)
-        free_backing_store(intel, buf);
-
-      buf->flags |= BM_NO_BACKING_STORE;
-      
-      if (dont_fence_subdata)
-        buf->flags |= BM_NO_FENCE_SUBDATA;
-
-      DBG("bmBufferSetInvalidateCB set buf %d dirty\n", buf->id);
-      buf->dirty = 1;
-      buf->invalidate_cb = invalidate_cb;
-      buf->invalidate_ptr = ptr;
-
-      /* Note that it is invalid right from the start.  Also note
-       * invalidate_cb is called with the bufmgr locked, so cannot
-       * itself make bufmgr calls.
-       */
-      invalidate_cb( intel, ptr );
-   }
-   UNLOCK(bm);
-}
-
-
-
-
-
-
-
-/* This is only protected against thread interactions by the DRI lock
- * and the policy of ensuring that all dma is flushed prior to
- * releasing that lock.  Otherwise you might have two threads building
- * up a list of buffers to validate at once.
- */
-int bmValidateBuffers( struct intel_context *intel )
-{
-   struct bufmgr *bm = intel->bm;
-   int retval = 0;
-
-   LOCK(bm);
-   {
-      DBG("%s fail %d\n", __FUNCTION__, bm->fail);
-      assert(intel->locked);
-
-      if (!bm->fail) {
-        struct block *block, *tmp;
-
-        foreach_s(block, tmp, &bm->referenced) {
-           struct buffer *buf = block->buf;
-
-           DBG("Validate buf %d / block %p / dirty %d\n", buf->id, block, buf->dirty);
-
-           /* Upload the buffer contents if necessary:
-            */
-           if (buf->dirty) {
-              DBG("Upload dirty buf %d (%s) sz %d offset 0x%x\n", buf->id, 
-                  buf->name, buf->size, block->mem->ofs);
-
-              assert(!(buf->flags & (BM_NO_BACKING_STORE|BM_NO_EVICT)));
-
-              wait_quiescent(intel, buf->block);
-
-              do_memcpy(buf->block->virtual,
-                        buf->backing_store, 
-                        buf->size);
-
-              if (intel->aub_file) {
-                 intel->vtbl.aub_gtt_data(intel,
-                                              buf->block->mem->ofs,
-                                              buf->backing_store,
-                                              buf->size,
-                                              0,
-                                              0);
-              }
-
-              buf->dirty = 0;
-              buf->aub_dirty = 0;
-           }
-           else if (buf->aub_dirty) {
-              intel->vtbl.aub_gtt_data(intel,
-                                           buf->block->mem->ofs,
-                                           buf->block->virtual,
-                                           buf->size,
-                                           0,
-                                           0);
-              buf->aub_dirty = 0;
-           }
-
-           block->referenced = 0;
-           block->on_hardware = 1;
-           move_to_tail(&bm->on_hardware, block);
-        }
-
-        bm->need_fence = 1;
-      }
-
-      retval = bm->fail ? -1 : 0;
-   }
-   UNLOCK(bm);
-
-
-   if (retval != 0)
-      DBG("%s failed\n", __FUNCTION__);
-
-   return retval;
-}
-
-
-
-
-void bmReleaseBuffers( struct intel_context *intel )
-{
-   struct bufmgr *bm = intel->bm;
-
-   LOCK(bm);
-   {
-      struct block *block, *tmp;
-
-      foreach_s (block, tmp, &bm->referenced) {
-
-        DBG("remove block %p from referenced list\n", block);
-
-        if (block->on_hardware) {
-           /* Return to the on-hardware list.
-            */
-           move_to_tail(&bm->on_hardware, block);          
-        }
-        else if (block->fenced) {
-           struct block *s;
-
-           /* Hmm - have to scan the fenced list to insert the
-            * buffers in order.  This is O(nm), but rare and the
-            * numbers are low.
-            */
-           foreach (s, &bm->fenced) {
-              if (FENCE_LTE(block->fence, s->fence))
-                 break;
-           }
-           
-           move_to_tail(s, block);
-        }
-        else {                 
-           /* Return to the lru list:
-            */
-           move_to_tail(&block->pool->lru, block);
-        }
-
-        block->referenced = 0;
-      }
-   }
-   UNLOCK(bm);
-}
-
-
-/* This functionality is used by the buffer manager, not really sure
- * if we need to be exposing it in this way, probably libdrm will
- * offer equivalent calls.
- *
- * For now they can stay, but will likely change/move before final:
- */
-unsigned bmSetFence( struct intel_context *intel )
-{
-   assert(intel->locked);
-
-   /* Emit MI_FLUSH here:
-    */
-   if (intel->bm->need_fence) {
-
-      /* Emit a flush without using a batchbuffer.  Can't rely on the
-       * batchbuffer at this level really.  Would really prefer that
-       * the IRQ ioctly emitted the flush at the same time.
-       */
-      GLuint dword[2];
-      dword[0] = intel->vtbl.flush_cmd();
-      dword[1] = 0;
-      intel_cmd_ioctl(intel, (char *)&dword, sizeof(dword));
-      
-      intel->bm->last_fence = intelEmitIrqLocked( intel );
-      
-      fence_blocks(intel, intel->bm->last_fence);
-
-      intel->vtbl.note_fence(intel, intel->bm->last_fence);
-      intel->bm->need_fence = 0;
-
-      if (intel->thrashing) {
-        intel->thrashing--;
-        if (!intel->thrashing)
-           DBG("not thrashing\n");
-      }
-      
-      intel->bm->free_on_hardware = 0;
-   }
-   
-   return intel->bm->last_fence;
-}
-
-unsigned bmSetFenceLock( struct intel_context *intel )
-{
-  unsigned last;
-  LOCK(intel->bm);
-  last = bmSetFence(intel);
-  UNLOCK(intel->bm);
-  return last;
-}
-unsigned bmLockAndFence( struct intel_context *intel )
-{
-   if (intel->bm->need_fence) {
-      LOCK_HARDWARE(intel);
-      LOCK(intel->bm);
-      bmSetFence(intel);
-      UNLOCK(intel->bm);
-      UNLOCK_HARDWARE(intel);
-   }
-
-   return intel->bm->last_fence;
-}
-
-
-void bmFinishFence( struct intel_context *intel, unsigned fence )
-{
-   if (!bmTestFence(intel, fence)) {
-      DBG("...wait on fence %d\n", fence);
-      intelWaitIrq( intel, fence );
-   }
-   assert(bmTestFence(intel, fence));
-   check_fenced(intel);
-}
-
-void bmFinishFenceLock( struct intel_context *intel, unsigned fence )
-{
-   LOCK(intel->bm);
-   bmFinishFence(intel, fence);
-   UNLOCK(intel->bm);
-}
-
-
-/* Specifically ignore texture memory sharing.
- *  -- just evict everything
- *  -- and wait for idle
- */
-void bm_fake_NotifyContendedLockTake( struct intel_context *intel )
-{
-   struct bufmgr *bm = intel->bm;
-
-   LOCK(bm);
-   {
-      struct block *block, *tmp;
-      GLuint i;
-
-      assert(is_empty_list(&bm->referenced));
-
-      bm->need_fence = 1;
-      bm->fail = 0;
-      bmFinishFence(intel, bmSetFence(intel));
-
-      assert(is_empty_list(&bm->fenced));
-      assert(is_empty_list(&bm->on_hardware));
-
-      for (i = 0; i < bm->nr_pools; i++) {
-        if (!(bm->pool[i].flags & BM_NO_EVICT)) {
-           foreach_s(block, tmp, &bm->pool[i].lru) {
-              assert(bmTestFence(intel, block->fence));
-              set_dirty(intel, block->buf);
-           }
-        }
-      }
-   }
-   UNLOCK(bm);
-}
-
-
-
-void bmEvictAll( struct intel_context *intel )
-{
-   struct bufmgr *bm = intel->bm;
-
-   LOCK(bm);
-   {
-      struct block *block, *tmp;
-      GLuint i;
-
-      DBG("%s\n", __FUNCTION__);
-
-      assert(is_empty_list(&bm->referenced));
-
-      bm->need_fence = 1;
-      bm->fail = 0;
-      bmFinishFence(intel, bmSetFence(intel));
-
-      assert(is_empty_list(&bm->fenced));
-      assert(is_empty_list(&bm->on_hardware));
-
-      for (i = 0; i < bm->nr_pools; i++) {
-        if (!(bm->pool[i].flags & BM_NO_EVICT)) {
-           foreach_s(block, tmp, &bm->pool[i].lru) {
-              assert(bmTestFence(intel, block->fence));
-              set_dirty(intel, block->buf);
-              block->buf->block = NULL;
-
-              free_block(intel, block);
-           }
-        }
-      }
-   }
-   UNLOCK(bm);
-}
-
-
-GLboolean bmError( struct intel_context *intel )
-{
-   struct bufmgr *bm = intel->bm;
-   GLboolean retval;
-
-   LOCK(bm);
-   {
-      retval = bm->fail;
-   }
-   UNLOCK(bm);
-
-   return retval;
-}
-
-
-GLuint bmCtxId( struct intel_context *intel )
-{
-   return intel->bm->ctxId;
-}
deleted file mode 100644 (file)
index 64885ed9b4b73ff0fd8195c06919a6dc38408914..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,243 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2006 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 "imports.h"
-#include "intel_batchbuffer.h"
-#include "intel_ioctl.h"
-#include "bufmgr.h"
-
-
-static void intel_batchbuffer_reset( struct intel_batchbuffer *batch )
-{
-   assert(batch->map == NULL);
-
-   batch->offset = (unsigned long)batch->ptr;
-   batch->offset = (batch->offset + 63) & ~63;
-   batch->ptr = (unsigned char *) batch->offset;
-
-   if (BATCH_SZ - batch->offset < BATCH_REFILL) {
-      bmBufferData(batch->intel, 
-                  batch->buffer,
-                  BATCH_SZ, 
-                  NULL, 
-                  0); 
-      batch->offset = 0;
-      batch->ptr = NULL;
-   }
-               
-   batch->flags = 0;
-}
-
-static void intel_batchbuffer_reset_cb( struct intel_context *intel,
-                                       void *ptr )
-{
-   struct intel_batchbuffer *batch = (struct intel_batchbuffer *)ptr;
-   assert(batch->map == NULL);
-   batch->flags = 0;
-   batch->offset = 0;
-   batch->ptr = NULL;
-}
-
-GLubyte *intel_batchbuffer_map( struct intel_batchbuffer *batch )
-{
-   if (!batch->map) {
-      batch->map = bmMapBuffer(batch->intel, batch->buffer, 
-                              BM_MEM_AGP|BM_MEM_LOCAL|BM_CLIENT|BM_WRITE);
-      batch->ptr += (unsigned long)batch->map;
-   }
-
-   return batch->map;
-}
-
-void intel_batchbuffer_unmap( struct intel_batchbuffer *batch )
-{
-   if (batch->map) {
-      batch->ptr -= (unsigned long)batch->map;
-      batch->map = NULL;
-      bmUnmapBuffer(batch->intel, batch->buffer);
-   }
-}
-
-
-
-/*======================================================================
- * Public functions
- */
-struct intel_batchbuffer *intel_batchbuffer_alloc( struct intel_context *intel )
-{
-   struct intel_batchbuffer *batch = calloc(sizeof(*batch), 1);
-
-   batch->intel = intel;
-
-   bmGenBuffers(intel, "batch", 1, &batch->buffer, 12);
-
-   bmBufferSetInvalidateCB(intel, batch->buffer,
-                          intel_batchbuffer_reset_cb,
-                          batch,
-                          GL_TRUE);
-
-   bmBufferData(batch->intel,
-               batch->buffer,
-               BATCH_SZ,
-               NULL,
-               0);
-
-
-   return batch;
-}
-
-void intel_batchbuffer_free( struct intel_batchbuffer *batch )
-{
-   if (batch->map) 
-      bmUnmapBuffer(batch->intel, batch->buffer);
-   
-   bmDeleteBuffers(batch->intel, 1, &batch->buffer);
-   free(batch);
-}
-
-
-#define MI_BATCH_BUFFER_END    (0xA<<23)
-
-
-GLboolean intel_batchbuffer_flush( struct intel_batchbuffer *batch )
-{
-   struct intel_context *intel = batch->intel;
-   GLuint used = batch->ptr - (batch->map + batch->offset);
-   GLuint offset;
-   GLint retval = GL_TRUE;
-
-   assert(intel->locked);
-
-   if (used == 0) {
-      bmReleaseBuffers( batch->intel );
-      return GL_TRUE;
-   }
-
-   /* Add the MI_BATCH_BUFFER_END.  Always add an MI_FLUSH - this is a
-    * performance drain that we would like to avoid.
-    */
-   if (used & 4) {
-      ((int *)batch->ptr)[0] = MI_BATCH_BUFFER_END;
-      batch->ptr += 4;
-      used += 4;
-   }
-   else {
-      ((int *)batch->ptr)[0] = 0;
-      ((int *)batch->ptr)[1] = MI_BATCH_BUFFER_END;
-
-      batch->ptr += 8;
-      used += 8;
-   }
-
-   intel_batchbuffer_unmap(batch);
-
-   /* Get the batch buffer offset: Must call bmBufferOffset() before
-    * bmValidateBuffers(), otherwise the buffer won't be on the inuse
-    * list.
-    */
-   offset = bmBufferOffset(batch->intel, batch->buffer);
-
-   if (bmValidateBuffers( batch->intel ) != 0) {
-      assert(intel->locked);
-      bmReleaseBuffers( batch->intel );
-      retval = GL_FALSE;
-      goto out;
-   }
-
-
-   if (intel->aub_file) {
-      /* Send buffered commands to aubfile as a single packet. 
-       */
-      intel_batchbuffer_map(batch);
-      ((int *)batch->ptr)[-1] = intel->vtbl.flush_cmd();
-      intel->vtbl.aub_commands(intel,
-                              offset, /* Fulsim wierdness - don't adjust */
-                              batch->map + batch->offset,
-                              used);
-      ((int *)batch->ptr)[-1] = MI_BATCH_BUFFER_END;
-      intel_batchbuffer_unmap(batch);
-   }
-
-
-   /* Fire the batch buffer, which was uploaded above:
-    */
-   intel_batch_ioctl(batch->intel, 
-                    offset + batch->offset,
-                    used);
-
-   if (intel->aub_file && 
-       intel->ctx.DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT)
-      intel->vtbl.aub_dump_bmp( intel, 0 );
-
-   /* Reset the buffer:
-    */
- out:
-   intel_batchbuffer_reset( batch );
-   intel_batchbuffer_map( batch );
-
-   if (!retval)
-      DBG("%s failed\n", __FUNCTION__);
-
-   return retval;
-}
-
-
-
-
-
-
-
-void intel_batchbuffer_align( struct intel_batchbuffer *batch,
-                             GLuint align,
-                             GLuint sz )
-{
-   unsigned long ptr = (unsigned long) batch->ptr;
-   unsigned long aptr = (ptr + align) & ~((unsigned long)align-1);
-   GLuint fixup = aptr - ptr;
-
-   if (intel_batchbuffer_space(batch) < fixup + sz)
-      intel_batchbuffer_flush(batch);
-   else {
-      memset(batch->ptr, 0, fixup);      
-      batch->ptr += fixup;
-   }
-}
-
-
-
-
-void intel_batchbuffer_data(struct intel_batchbuffer *batch,
-                           const void *data,
-                           GLuint bytes,
-                           GLuint flags)
-{
-   assert((bytes & 3) == 0);
-   intel_batchbuffer_require_space(batch, bytes, flags);
-   __memcpy(batch->ptr, data, bytes);
-   batch->ptr += bytes;
-}
-
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..d38cdf31cc6c2d95a6f2970a9bbba75736bf2e3c
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_batchbuffer.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.h b/src/mesa/drivers/dri/i965/intel_batchbuffer.h
deleted file mode 100644 (file)
index 25e0a65..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2006 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 "mtypes.h"
-#include "bufmgr.h"
-
-struct intel_context;
-
-#define BATCH_SZ (16 * 1024)
-#define BATCH_REFILL 4096
-#define BATCH_RESERVED 16
-
-#define INTEL_BATCH_NO_CLIPRECTS 0x1
-#define INTEL_BATCH_CLIPRECTS    0x2
-
-struct intel_batchbuffer {
-   struct intel_context *intel;
-
-   struct buffer *buffer;
-
-   GLuint flags;
-   unsigned long offset;
-
-   GLubyte *map;
-   GLubyte *ptr; 
-};
-
-struct intel_batchbuffer *intel_batchbuffer_alloc( struct intel_context *intel );
-
-void intel_batchbuffer_free( struct intel_batchbuffer *batch );
-
-
-GLboolean intel_batchbuffer_flush( struct intel_batchbuffer *batch );
-
-void intel_batchbuffer_unmap( struct intel_batchbuffer *batch );
-GLubyte *intel_batchbuffer_map( struct intel_batchbuffer *batch );
-
-
-/* Unlike bmBufferData, this currently requires the buffer be mapped.
- * Consider it a convenience function wrapping multple
- * intel_buffer_dword() calls.
- */
-void intel_batchbuffer_data(struct intel_batchbuffer *batch,
-                           const void *data,
-                           GLuint bytes,
-                           GLuint flags);
-
-void intel_batchbuffer_release_space(struct intel_batchbuffer *batch,
-                                  GLuint bytes);
-
-
-/* Inline functions - might actually be better off with these
- * non-inlined.  Certainly better off switching all command packets to
- * be passed as structs rather than dwords, but that's a little bit of
- * work...
- */
-static inline GLuint 
-intel_batchbuffer_space( struct intel_batchbuffer *batch )
-{
-   return (BATCH_SZ - BATCH_RESERVED) - (batch->ptr - (batch->map + batch->offset));
-}
-
-
-static inline void 
-intel_batchbuffer_emit_dword(struct intel_batchbuffer *batch,
-                            GLuint dword)
-{
-   assert(batch->map);
-   assert(intel_batchbuffer_space(batch) >= 4);
-   *(GLuint *)(batch->ptr) = dword;
-   batch->ptr += 4;
-}
-
-static inline void 
-intel_batchbuffer_require_space(struct intel_batchbuffer *batch,
-                               GLuint sz,
-                               GLuint flags)
-{
-   assert(sz < BATCH_SZ - 8);
-   if (intel_batchbuffer_space(batch) < sz ||
-       (batch->flags != 0 && flags != 0 && batch->flags != flags))
-      intel_batchbuffer_flush(batch);
-   
-   batch->flags |= flags;
-}
-
-void intel_batchbuffer_align( struct intel_batchbuffer *batch,
-                             GLuint align,
-                             GLuint sz );
-
-
-/* Here are the crusty old macros, to be removed:
- */
-#define BATCH_LOCALS 
-#define BEGIN_BATCH(n, flags) intel_batchbuffer_require_space(intel->batch, n*4, flags)
-#define OUT_BATCH(d)  intel_batchbuffer_emit_dword(intel->batch, d)
-#define ADVANCE_BATCH() do { } while(0)
-
-
-#endif
deleted file mode 100644 (file)
index f88cbb2328dfc3e2a35bff2d6da2ee97ba966000..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,617 +0,0 @@
-/**************************************************************************
- * 
- * 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 "vblank.h"
-
-#include "intel_reg.h"
-#include "intel_batchbuffer.h"
-#include "intel_context.h"
-#include "intel_blit.h"
-#include "intel_regions.h"
-#include "intel_structs.h"
-
-#include "bufmgr.h"
-
-
-
-
-/*
- * Copy the back buffer to the front buffer. 
- */
-void intelCopyBuffer( const __DRIdrawablePrivate *dPriv,
-                     const drm_clip_rect_t *rect ) 
-{
-   struct intel_context *intel;
-   GLboolean   missed_target;
-   int64_t ust;
-
-   DBG("%s\n", __FUNCTION__);
-
-   assert(dPriv);
-   assert(dPriv->driContextPriv);
-   assert(dPriv->driContextPriv->driverPrivate);
-
-   intel = (struct intel_context *) dPriv->driContextPriv->driverPrivate;
-   intelFlush( &intel->ctx );
-
-
-   bmFinishFenceLock(intel, intel->last_swap_fence);
-
-   /* The LOCK_HARDWARE is required for the cliprects.  Buffer offsets
-    * should work regardless.
-    */
-   LOCK_HARDWARE( intel );
-
-   if (!rect)
-   {
-       UNLOCK_HARDWARE( intel );
-       driWaitForVBlank( dPriv, &intel->vbl_seq, intel->vblank_flags, & missed_target );
-       LOCK_HARDWARE( intel );
-   }
-
-   {
-      intelScreenPrivate *intelScreen = intel->intelScreen;
-      __DRIdrawablePrivate *dPriv = intel->driDrawable;
-      int nbox = dPriv->numClipRects;
-      drm_clip_rect_t *pbox = dPriv->pClipRects;
-      int cpp = intelScreen->cpp;
-      struct intel_region *src, *dst;
-      int BR13, CMD;
-      int i;
-      int src_pitch, dst_pitch;
-
-      if (intel->sarea->pf_current_page == 0) {
-        dst = intel->front_region;
-        src = intel->back_region;
-      }
-      else {
-        assert(0);
-        src = intel->front_region;
-        dst = intel->back_region;
-      }
-
-      src_pitch = src->pitch * src->cpp;
-      dst_pitch = dst->pitch * dst->cpp;
-
-      if (cpp == 2) {
-        BR13 = (0xCC << 16) | (1<<24);
-        CMD = XY_SRC_COPY_BLT_CMD;
-      } 
-      else {
-        BR13 = (0xCC << 16) | (1<<24) | (1<<25);
-        CMD = (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA |
-               XY_SRC_COPY_BLT_WRITE_RGB);
-      }
-
-      if (src->tiled) {
-        CMD |= XY_SRC_TILED;
-        src_pitch /= 4;
-      }
-      
-      if (dst->tiled) {
-        CMD |= XY_DST_TILED;
-        dst_pitch /= 4;
-      }
-  
-      for (i = 0 ; i < nbox; i++, pbox++) 
-      {
-        drm_clip_rect_t tmp = *pbox;
-
-        if (rect) {
-           if (!intel_intersect_cliprects(&tmp, &tmp, rect))
-              continue;
-        }
-
-
-        if (tmp.x1 > tmp.x2 ||
-            tmp.y1 > tmp.y2 ||
-            tmp.x2 > intelScreen->width ||
-            tmp.y2 > intelScreen->height)
-           continue;
-        BEGIN_BATCH(8, INTEL_BATCH_NO_CLIPRECTS);
-        OUT_BATCH( CMD );
-        OUT_BATCH( dst_pitch | BR13 );
-        OUT_BATCH( (tmp.y1 << 16) | tmp.x1 );
-        OUT_BATCH( (tmp.y2 << 16) | tmp.x2 );
-        OUT_BATCH( bmBufferOffset(intel, dst->buffer) );
-        OUT_BATCH( (tmp.y1 << 16) | tmp.x1 );
-        OUT_BATCH( src_pitch );
-        OUT_BATCH( bmBufferOffset(intel, src->buffer) ); 
-        ADVANCE_BATCH();
-      }
-   }
-
-   intel_batchbuffer_flush( intel->batch );
-   intel->second_last_swap_fence = intel->last_swap_fence;
-   intel->last_swap_fence = bmSetFenceLock( intel );
-   UNLOCK_HARDWARE( intel );
-
-   if (!rect)
-   {
-       intel->swap_count++;
-       (*dri_interface->getUST)(&ust);
-       if (missed_target) {
-          intel->swap_missed_count++;
-          intel->swap_missed_ust = ust -  intel->swap_ust;
-       }
-   
-       intel->swap_ust = ust;
-   }
-
-}
-
-
-
-
-void intelEmitFillBlit( struct intel_context *intel,
-                       GLuint cpp,
-                       GLshort dst_pitch,
-                       struct buffer *dst_buffer,
-                       GLuint dst_offset,
-                       GLboolean dst_tiled,
-                       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 = (0xF0 << 16) | (1<<24);
-      CMD = XY_COLOR_BLT_CMD;
-      break;
-   case 4:
-      BR13 = (0xF0 << 16) | (1<<24) | (1<<25);
-      CMD = (XY_COLOR_BLT_CMD | XY_COLOR_BLT_WRITE_ALPHA |
-            XY_COLOR_BLT_WRITE_RGB);
-      break;
-   default:
-      return;
-   }
-
-   if (dst_tiled) {
-      CMD |= XY_DST_TILED;
-      dst_pitch /= 4;
-   }
-
-   BEGIN_BATCH(6, INTEL_BATCH_NO_CLIPRECTS);
-   OUT_BATCH( CMD );
-   OUT_BATCH( dst_pitch | BR13 );
-   OUT_BATCH( (y << 16) | x );
-   OUT_BATCH( ((y+h) << 16) | (x+w) );
-   OUT_BATCH( bmBufferOffset(intel, dst_buffer) + dst_offset );
-   OUT_BATCH( color );
-   ADVANCE_BATCH();
-}
-
-static GLuint translate_raster_op(GLenum logicop)
-{
-   switch(logicop) {
-   case GL_CLEAR: return 0x00;
-   case GL_AND: return 0x88;
-   case GL_AND_REVERSE: return 0x44;
-   case GL_COPY: return 0xCC;
-   case GL_AND_INVERTED: return 0x22;
-   case GL_NOOP: return 0xAA;
-   case GL_XOR: return 0x66;
-   case GL_OR: return 0xEE;
-   case GL_NOR: return 0x11;
-   case GL_EQUIV: return 0x99;
-   case GL_INVERT: return 0x55;
-   case GL_OR_REVERSE: return 0xDD;
-   case GL_COPY_INVERTED: return 0x33;
-   case GL_OR_INVERTED: return 0xBB;
-   case GL_NAND: return 0x77;
-   case GL_SET: return 0xFF;
-   default: return 0;
-   }
-}
-
-
-/* Copy BitBlt
- */
-void intelEmitCopyBlit( struct intel_context *intel,
-                       GLuint cpp,
-                       GLshort src_pitch,
-                       struct buffer *src_buffer,
-                       GLuint  src_offset,
-                       GLboolean src_tiled,
-                       GLshort dst_pitch,
-                       struct buffer *dst_buffer,
-                       GLuint  dst_offset,
-                       GLboolean dst_tiled,
-                       GLshort src_x, GLshort src_y,
-                       GLshort dst_x, GLshort dst_y,
-                       GLshort w, GLshort h,
-                       GLenum logic_op )
-{
-   GLuint CMD, BR13;
-   int dst_y2 = dst_y + h;
-   int dst_x2 = dst_x + w;
-   BATCH_LOCALS;
-
-
-   DBG("%s src:buf(%d)/%d %d,%d dst:buf(%d)/%d %d,%d sz:%dx%d op:%d\n",
-       __FUNCTION__,
-       src_buffer, src_pitch, src_x, src_y,
-       dst_buffer, dst_pitch, dst_x, dst_y,
-       w,h,logic_op);
-
-   assert( logic_op - GL_CLEAR >= 0 );
-   assert( logic_op - GL_CLEAR < 0x10 );
-      
-   src_pitch *= cpp;
-   dst_pitch *= cpp;
-
-   switch(cpp) {
-   case 1: 
-   case 2: 
-   case 3: 
-      BR13 = (translate_raster_op(logic_op) << 16) | (1<<24);
-      CMD = XY_SRC_COPY_BLT_CMD;
-      break;
-   case 4:
-      BR13 = (translate_raster_op(logic_op) << 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 (src_tiled) {
-      CMD |= XY_SRC_TILED;
-      src_pitch /= 4;
-   }
-   
-   if (dst_tiled) {
-      CMD |= XY_DST_TILED;
-      dst_pitch /= 4;
-   }
-
-   if (dst_y2 < dst_y ||
-       dst_x2 < dst_x) {
-      return;
-   }
-
-   dst_pitch &= 0xffff;
-   src_pitch &= 0xffff;
-
-   /* Initial y values don't seem to work with negative pitches.  If
-    * we adjust the offsets manually (below), it seems to work fine.
-    *
-    * On the other hand, if we always adjust, the hardware doesn't
-    * know which blit directions to use, so overlapping copypixels get
-    * the wrong result.
-    */
-   if (dst_pitch > 0 && src_pitch > 0) {
-      BEGIN_BATCH(8, INTEL_BATCH_NO_CLIPRECTS);
-      OUT_BATCH( CMD );
-      OUT_BATCH( dst_pitch | BR13 );
-      OUT_BATCH( (dst_y << 16) | dst_x );
-      OUT_BATCH( (dst_y2 << 16) | dst_x2 );
-      OUT_BATCH( bmBufferOffset(intel, dst_buffer) + dst_offset );     
-      OUT_BATCH( (src_y << 16) | src_x );
-      OUT_BATCH( src_pitch );
-      OUT_BATCH( bmBufferOffset(intel, src_buffer) + src_offset ); 
-      ADVANCE_BATCH();
-   }
-   else {
-      BEGIN_BATCH(8, INTEL_BATCH_NO_CLIPRECTS);
-      OUT_BATCH( CMD );
-      OUT_BATCH( (dst_pitch & 0xffff) | BR13 );
-      OUT_BATCH( (0 << 16) | dst_x );
-      OUT_BATCH( (h << 16) | dst_x2 );
-      OUT_BATCH( bmBufferOffset(intel, dst_buffer) + dst_offset + dst_y * dst_pitch ); 
-      OUT_BATCH( (0 << 16) | src_x );
-      OUT_BATCH( (src_pitch & 0xffff) );
-      OUT_BATCH( bmBufferOffset(intel, src_buffer) + src_offset + src_y * src_pitch ); 
-      ADVANCE_BATCH();
-   }
-}
-
-
-
-void intelClearWithBlit(GLcontext *ctx, GLbitfield flags)
-{
-   struct intel_context *intel = intel_context( ctx );
-   intelScreenPrivate *intelScreen = intel->intelScreen;
-   GLuint clear_depth, clear_color;
-   GLint cx, cy, cw, ch;
-   GLint cpp = intelScreen->cpp;
-   GLboolean all;
-   GLint i;
-   struct intel_region *front = intel->front_region;
-   struct intel_region *back = intel->back_region;
-   struct intel_region *depth = intel->depth_region;
-   GLuint BR13, FRONT_CMD, BACK_CMD, DEPTH_CMD;
-   GLuint front_pitch;
-   GLuint back_pitch;
-   GLuint depth_pitch;
-   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) | (1<<24);
-      BACK_CMD  = FRONT_CMD = XY_COLOR_BLT_CMD;
-      DEPTH_CMD = XY_COLOR_BLT_CMD;
-      break;
-   case 4:
-      BR13 = (0xF0 << 16) | (1<<24) | (1<<25);
-      BACK_CMD = FRONT_CMD = (XY_COLOR_BLT_CMD |
-                             XY_COLOR_BLT_WRITE_ALPHA | 
-                             XY_COLOR_BLT_WRITE_RGB);
-      DEPTH_CMD = XY_COLOR_BLT_CMD;
-      if (flags & BUFFER_BIT_DEPTH) DEPTH_CMD |= XY_COLOR_BLT_WRITE_RGB;
-      if (flags & BUFFER_BIT_STENCIL) DEPTH_CMD |= XY_COLOR_BLT_WRITE_ALPHA;
-      break;
-   default:
-      return;
-   }
-
-
-
-   intelFlush( &intel->ctx );
-   LOCK_HARDWARE( intel );
-   {
-      /* get clear bounds after locking */
-      cx = ctx->DrawBuffer->_Xmin;
-      cy = ctx->DrawBuffer->_Ymin;
-      ch = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
-      cw = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
-      all = (cw == ctx->DrawBuffer->Width && ch == ctx->DrawBuffer->Height);
-
-      /* flip top to bottom */
-      cy = intel->driDrawable->h - cy - ch;
-      cx = cx + intel->drawX;
-      cy += intel->drawY;
-
-      /* adjust for page flipping */
-      if ( intel->sarea->pf_current_page == 0 ) {
-        front = intel->front_region;
-        back = intel->back_region;
-      } 
-      else {
-        back = intel->front_region;
-        front = intel->back_region;
-      }
-      
-      front_pitch = front->pitch * front->cpp;
-      back_pitch = back->pitch * back->cpp;
-      depth_pitch = depth->pitch * depth->cpp;
-      
-      if (front->tiled) {
-        FRONT_CMD |= XY_DST_TILED;
-        front_pitch /= 4;
-      }
-
-      if (back->tiled) {
-        BACK_CMD |= XY_DST_TILED;
-        back_pitch /= 4;
-      }
-
-      if (depth->tiled) {
-        DEPTH_CMD |= XY_DST_TILED;
-        depth_pitch /= 4;
-      }
-
-      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->x1;
-           GLint y = box->y1;
-           GLint w = box->x2 - x;
-           GLint h = box->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, INTEL_BATCH_NO_CLIPRECTS);
-           OUT_BATCH( FRONT_CMD );
-           OUT_BATCH( front_pitch | BR13 );
-           OUT_BATCH( (b.y1 << 16) | b.x1 );
-           OUT_BATCH( (b.y2 << 16) | b.x2 );
-           OUT_BATCH( bmBufferOffset(intel, front->buffer) );
-           OUT_BATCH( clear_color );
-           ADVANCE_BATCH();
-        }
-
-        if ( flags & BUFFER_BIT_BACK_LEFT ) {
-           BEGIN_BATCH(6, INTEL_BATCH_NO_CLIPRECTS); 
-           OUT_BATCH( BACK_CMD );
-           OUT_BATCH( back_pitch | BR13 );
-           OUT_BATCH( (b.y1 << 16) | b.x1 );
-           OUT_BATCH( (b.y2 << 16) | b.x2 );
-           OUT_BATCH( bmBufferOffset(intel, back->buffer) );
-           OUT_BATCH( clear_color );
-           ADVANCE_BATCH();
-        }
-
-        if ( flags & (BUFFER_BIT_STENCIL | BUFFER_BIT_DEPTH) ) {
-           BEGIN_BATCH(6, INTEL_BATCH_NO_CLIPRECTS);
-           OUT_BATCH( DEPTH_CMD );
-           OUT_BATCH( depth_pitch | BR13 );
-           OUT_BATCH( (b.y1 << 16) | b.x1 );
-           OUT_BATCH( (b.y2 << 16) | b.x2 );
-           OUT_BATCH( bmBufferOffset(intel, depth->buffer) );
-           OUT_BATCH( clear_depth );
-           ADVANCE_BATCH();
-        }      
-      }
-   }
-   intel_batchbuffer_flush( intel->batch );
-   UNLOCK_HARDWARE( intel );
-}
-
-
-
-#define BR13_565  0x1
-#define BR13_8888 0x3
-
-
-void
-intelEmitImmediateColorExpandBlit(struct intel_context *intel,
-                                 GLuint cpp,
-                                 GLubyte *src_bits, GLuint src_size,
-                                 GLuint fg_color,
-                                 GLshort dst_pitch,
-                                 struct buffer *dst_buffer,
-                                 GLuint dst_offset,
-                                 GLboolean dst_tiled,
-                                 GLshort x, GLshort y, 
-                                 GLshort w, GLshort h,
-                                 GLenum logic_op)
-{
-   struct xy_setup_blit setup;
-   struct xy_text_immediate_blit text;
-   int dwords = ((src_size + 7) & ~7) / 4;
-
-   assert( logic_op - GL_CLEAR >= 0 );
-   assert( logic_op - GL_CLEAR < 0x10 );
-
-   if (w < 0 || h < 0) 
-      return;
-
-   dst_pitch *= cpp;
-
-   if (dst_tiled) 
-      dst_pitch /= 4;
-
-   DBG("%s dst:buf(%p)/%d+%d %d,%d sz:%dx%d, %d bytes %d dwords\n",
-       __FUNCTION__,
-       dst_buffer, dst_pitch, dst_offset, x, y, w, h, src_size, dwords);
-
-   memset(&setup, 0, sizeof(setup));
-   
-   setup.br0.client = CLIENT_2D;
-   setup.br0.opcode = OPCODE_XY_SETUP_BLT;
-   setup.br0.write_alpha = (cpp == 4);
-   setup.br0.write_rgb = (cpp == 4);
-   setup.br0.dst_tiled = dst_tiled;
-   setup.br0.length = (sizeof(setup) / sizeof(int)) - 2;
-      
-   setup.br13.dest_pitch = dst_pitch;
-   setup.br13.rop = translate_raster_op(logic_op);
-   setup.br13.color_depth = (cpp == 4) ? BR13_8888 : BR13_565;
-   setup.br13.clipping_enable = 0;
-   setup.br13.mono_source_transparency = 1;
-
-   setup.dw2.clip_y1 = 0;
-   setup.dw2.clip_x1 = 0;
-   setup.dw3.clip_y2 = 100;
-   setup.dw3.clip_x2 = 100;
-
-   setup.dest_base_addr = bmBufferOffset(intel, dst_buffer) + dst_offset;
-   setup.background_color = 0;
-   setup.foreground_color = fg_color;
-   setup.pattern_base_addr = 0;
-
-   memset(&text, 0, sizeof(text));
-   text.dw0.client = CLIENT_2D;
-   text.dw0.opcode = OPCODE_XY_TEXT_IMMEDIATE_BLT;
-   text.dw0.pad0 = 0;
-   text.dw0.byte_packed = 1;   /* ?maybe? */
-   text.dw0.pad1 = 0;
-   text.dw0.dst_tiled = dst_tiled;
-   text.dw0.pad2 = 0;
-   text.dw0.length = (sizeof(text)/sizeof(int)) - 2 + dwords;
-   text.dw1.dest_y1 = y;       /* duplicates info in setup blit */
-   text.dw1.dest_x1 = x;
-   text.dw2.dest_y2 = y + h;
-   text.dw2.dest_x2 = x + w;
-
-   intel_batchbuffer_require_space( intel->batch,
-                                   sizeof(setup) + 
-                                   sizeof(text) + 
-                                   dwords,
-                                   INTEL_BATCH_NO_CLIPRECTS );
-
-   intel_batchbuffer_data( intel->batch,
-                          &setup,
-                          sizeof(setup),
-                          INTEL_BATCH_NO_CLIPRECTS );
-
-   intel_batchbuffer_data( intel->batch,
-                          &text,
-                          sizeof(text),
-                          INTEL_BATCH_NO_CLIPRECTS );
-
-   intel_batchbuffer_data( intel->batch,
-                          src_bits,
-                          dwords * 4,
-                          INTEL_BATCH_NO_CLIPRECTS );
-}
-
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..dd6c8d17c2802ce43ddd3e96f326963284d2d6f6
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_blit.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i965/intel_blit.h b/src/mesa/drivers/dri/i965/intel_blit.h
deleted file mode 100644 (file)
index e361545..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/**************************************************************************
- * 
- * 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_BLIT_H
-#define INTEL_BLIT_H
-
-#include "intel_context.h"
-#include "intel_ioctl.h"
-
-struct buffer;
-
-extern void intelCopyBuffer( const __DRIdrawablePrivate *dpriv,
-                            const drm_clip_rect_t *rect );
-extern void intelClearWithBlit(GLcontext *ctx, GLbitfield mask);
-
-extern void intelEmitCopyBlit( struct intel_context *intel,
-                              GLuint cpp,
-                              GLshort src_pitch,
-                              struct buffer *src_buffer,
-                              GLuint  src_offset,
-                              GLboolean src_tiled,
-                              GLshort dst_pitch,
-                              struct buffer *dst_buffer,
-                              GLuint  dst_offset,
-                              GLboolean dst_tiled,
-                              GLshort srcx, GLshort srcy,
-                              GLshort dstx, GLshort dsty,
-                              GLshort w, GLshort h,
-                              GLenum logic_op );
-
-extern void intelEmitFillBlit( struct intel_context *intel,
-                              GLuint cpp,
-                              GLshort dst_pitch,
-                              struct buffer *dst_buffer,
-                              GLuint dst_offset,
-                              GLboolean dst_tiled,
-                              GLshort x, GLshort y, 
-                              GLshort w, GLshort h,
-                              GLuint color );
-
-void
-intelEmitImmediateColorExpandBlit(struct intel_context *intel,
-                                 GLuint cpp,
-                                 GLubyte *src_bits, GLuint src_size,
-                                 GLuint fg_color,
-                                 GLshort dst_pitch,
-                                 struct buffer *dst_buffer,
-                                 GLuint dst_offset,
-                                 GLboolean dst_tiled,
-                                 GLshort dst_x, GLshort dst_y, 
-                                 GLshort w, GLshort h,
-                                 GLenum logic_op );
-
-#endif
deleted file mode 100644 (file)
index 015e433fd7a701866c0727e03b495eb29376a07b..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,207 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2006 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 "imports.h"
-#include "mtypes.h"
-#include "bufferobj.h"
-
-#include "intel_context.h"
-#include "intel_buffer_objects.h"
-#include "bufmgr.h"
-
-
-/**
- * There is some duplication between mesa's bufferobjects and our
- * bufmgr buffers.  Both have an integer handle and a hashtable to
- * lookup an opaque structure.  It would be nice if the handles and
- * internal structure where somehow shared.
- */
-static struct gl_buffer_object *intel_bufferobj_alloc( GLcontext *ctx, 
-                                                      GLuint name, 
-                                                      GLenum target )
-{
-   struct intel_context *intel = intel_context(ctx);
-   struct intel_buffer_object *obj = MALLOC_STRUCT(intel_buffer_object);
-
-   _mesa_initialize_buffer_object(&obj->Base, name, target);
-
-   /* XXX:  We generate our own handle, which is different to 'name' above.
-    */
-   bmGenBuffers(intel, "bufferobj", 1, &obj->buffer, 6);
-   assert(obj->buffer);
-
-   return &obj->Base;
-}
-
-
-/**
- * Deallocate/free a vertex/pixel buffer object.
- * Called via glDeleteBuffersARB().
- */
-static void intel_bufferobj_free( GLcontext *ctx, 
-                                 struct gl_buffer_object *obj )
-{ 
-   struct intel_context *intel = intel_context(ctx);
-   struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
-
-   assert(intel_obj);
-
-   if (intel_obj->buffer) 
-      bmDeleteBuffers( intel, 1, &intel_obj->buffer );
-  
-   _mesa_free(intel_obj);
-}
-
-
-
-/**
- * Allocate space for and store data in a buffer object.  Any data that was
- * previously stored in the buffer object is lost.  If data is NULL,
- * memory will be allocated, but no copy will occur.
- * Called via glBufferDataARB().
- */
-static void intel_bufferobj_data( GLcontext *ctx, 
-                                 GLenum target, 
-                                 GLsizeiptrARB size,
-                                 const GLvoid *data, 
-                                 GLenum usage,
-                                 struct gl_buffer_object *obj )
-{
-   struct intel_context *intel = intel_context(ctx);
-   struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
-
-   /* XXX: do something useful with 'usage' (eg. populate flags
-    * argument below)
-    */
-   assert(intel_obj);
-
-   obj->Size = size;
-   obj->Usage = usage;
-
-   bmBufferDataAUB(intel, intel_obj->buffer, size, data, 0,
-                  0, 0);
-}
-
-
-/**
- * Replace data in a subrange of buffer object.  If the data range
- * specified by size + offset extends beyond the end of the buffer or
- * if data is NULL, no copy is performed.
- * Called via glBufferSubDataARB().
- */
-static void intel_bufferobj_subdata( GLcontext *ctx, 
-                                    GLenum target, 
-                                    GLintptrARB offset,
-                                    GLsizeiptrARB size, 
-                                    const GLvoid * data,
-                                    struct gl_buffer_object * obj )
-{
-   struct intel_context *intel = intel_context(ctx);
-   struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
-
-   assert(intel_obj);
-   bmBufferSubDataAUB(intel, intel_obj->buffer, offset, size, data, 0, 0);
-}
-
-
-/**
- * Called via glGetBufferSubDataARB().
- */
-static void intel_bufferobj_get_subdata( GLcontext *ctx, 
-                                        GLenum target, 
-                                        GLintptrARB offset,
-                                        GLsizeiptrARB size, 
-                                        GLvoid * data,
-                                        struct gl_buffer_object * obj )
-{
-   struct intel_context *intel = intel_context(ctx);
-   struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
-
-   assert(intel_obj);
-   bmBufferGetSubData(intel, intel_obj->buffer, offset, size, data);
-}
-
-
-
-/**
- * Called via glMapBufferARB().
- */
-static void *intel_bufferobj_map( GLcontext *ctx, 
-                                 GLenum target, 
-                                 GLenum access,
-                                 struct gl_buffer_object *obj )
-{
-   struct intel_context *intel = intel_context(ctx);
-   struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
-
-   /* XXX: Translate access to flags arg below:
-    */
-   assert(intel_obj);
-   assert(intel_obj->buffer);
-   obj->Pointer = bmMapBuffer(intel, intel_obj->buffer, 0);
-   return obj->Pointer;
-}
-
-
-/**
- * Called via glMapBufferARB().
- */
-static GLboolean intel_bufferobj_unmap( GLcontext *ctx,
-                                       GLenum target,
-                                       struct gl_buffer_object *obj )
-{
-   struct intel_context *intel = intel_context(ctx);
-   struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
-
-   assert(intel_obj);
-   assert(intel_obj->buffer);
-   assert(obj->Pointer);
-   bmUnmapBufferAUB(intel, intel_obj->buffer, 0, 0);
-   obj->Pointer = NULL;
-   return GL_TRUE;
-}
-
-struct buffer *intel_bufferobj_buffer( const struct intel_buffer_object *intel_obj )
-{
-   assert(intel_obj->Base.Name);
-   assert(intel_obj->buffer);
-   return intel_obj->buffer;
-}  
-
-void intel_bufferobj_init( struct intel_context *intel )
-{
-   GLcontext *ctx = &intel->ctx;
-
-   ctx->Driver.NewBufferObject = intel_bufferobj_alloc;
-   ctx->Driver.DeleteBuffer = intel_bufferobj_free;
-   ctx->Driver.BufferData = intel_bufferobj_data;
-   ctx->Driver.BufferSubData = intel_bufferobj_subdata;
-   ctx->Driver.GetBufferSubData = intel_bufferobj_get_subdata;
-   ctx->Driver.MapBuffer = intel_bufferobj_map;
-   ctx->Driver.UnmapBuffer = intel_bufferobj_unmap;
-}
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..e06dd3c8d3c54014cf16e795a8c3d139b2ebfb59
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_buffer_objects.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i965/intel_buffer_objects.h b/src/mesa/drivers/dri/i965/intel_buffer_objects.h
deleted file mode 100644 (file)
index 4b38803..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
- /**************************************************************************
- * 
- * Copyright 2006 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_BUFFEROBJ_H
-#define INTEL_BUFFEROBJ_H
-
-#include "mtypes.h"
-
-struct intel_context;
-struct gl_buffer_object;
-
-
-/**
- * Intel vertex/pixel buffer object, derived from Mesa's gl_buffer_object.
- */
-struct intel_buffer_object {
-   struct gl_buffer_object Base;
-   struct buffer *buffer;   /* the low-level buffer manager's buffer handle */
-};
-
-
-/* Get the bm buffer associated with a GL bufferobject:
- */
-struct buffer *intel_bufferobj_buffer( const struct intel_buffer_object *obj );
-
-/* Hook the bufferobject implementation into mesa: 
- */
-void intel_bufferobj_init( struct intel_context *intel );
-
-
-
-/* Are the obj->Name tests necessary?  Unfortunately yes, mesa
- * allocates a couple of gl_buffer_object structs statically, and
- * the Name == 0 test is the only way to identify them and avoid
- * casting them erroneously to our structs.
- */
-static inline struct intel_buffer_object *
-intel_buffer_object( struct gl_buffer_object *obj )
-{
-   if (obj->Name)
-      return (struct intel_buffer_object *)obj;
-   else
-      return NULL;
-}
-
-#endif
deleted file mode 100644 (file)
index d155c039d77872017e943b20df8ce262e5ed0249..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,547 +0,0 @@
-/**************************************************************************
- * 
- * 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 "intel_screen.h"
-#include "intel_context.h"
-#include "intel_blit.h"
-#include "intel_regions.h"
-#include "intel_batchbuffer.h"
-#include "context.h"
-#include "framebuffer.h"
-#include "macros.h"
-#include "swrast/swrast.h"
-
-GLboolean intel_intersect_cliprects( drm_clip_rect_t *dst,
-                                    const drm_clip_rect_t *a,
-                                    const drm_clip_rect_t *b )
-{
-   dst->x1 = MAX2(a->x1, b->x1);
-   dst->x2 = MIN2(a->x2, b->x2);
-   dst->y1 = MAX2(a->y1, b->y1);
-   dst->y2 = MIN2(a->y2, b->y2);
-
-   return (dst->x1 <= dst->x2 &&
-          dst->y1 <= dst->y2);
-}
-
-struct intel_region *intel_drawbuf_region( struct intel_context *intel )
-{
-   switch (intel->ctx.DrawBuffer->_ColorDrawBufferMask[0]) {
-   case BUFFER_BIT_FRONT_LEFT:
-      return intel->front_region;
-   case BUFFER_BIT_BACK_LEFT:
-      return intel->back_region;
-   default:
-      /* Not necessary to fallback - could handle either NONE or
-       * FRONT_AND_BACK cases below.
-       */
-      return NULL;             
-   }
-}
-
-struct intel_region *intel_readbuf_region( struct intel_context *intel )
-{
-   GLcontext *ctx = &intel->ctx;
-
-   /* This will have to change to support EXT_fbo's, but is correct
-    * for now:
-    */
-   switch (ctx->ReadBuffer->_ColorReadBufferIndex) {
-   case BUFFER_FRONT_LEFT:
-      return intel->front_region;
-   case BUFFER_BACK_LEFT:
-      return intel->back_region;
-   default:
-      assert(0);
-      return NULL;
-   }
-}
-
-
-
-static void intelBufferSize(GLframebuffer *buffer,
-                           GLuint *width, 
-                           GLuint *height)
-{
-   GET_CURRENT_CONTEXT(ctx);
-   struct intel_context *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);
-   if (intel->driDrawable) {
-      *width = intel->driDrawable->w;
-      *height = intel->driDrawable->h;
-   }
-   else {
-      *width = 0;
-      *height = 0;
-   }
-   UNLOCK_HARDWARE(intel);
-}
-
-
-static void intelSetFrontClipRects( struct intel_context *intel )
-{
-   __DRIdrawablePrivate *dPriv = intel->driDrawable;
-
-   if (!dPriv) return;
-
-   intel->numClipRects = dPriv->numClipRects;
-   intel->pClipRects = dPriv->pClipRects;
-   intel->drawX = dPriv->x;
-   intel->drawY = dPriv->y;
-}
-
-
-static void intelSetBackClipRects( struct intel_context *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( struct intel_context *intel )
-{
-   __DRIdrawablePrivate *dPriv = intel->driDrawable;
-
-   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 );
-      }
-   }
-
-   _mesa_resize_framebuffer(&intel->ctx,
-                           (GLframebuffer*)dPriv->driverPrivate,
-                           dPriv->w, dPriv->h);
-
-   /* Set state we know depends on drawable parameters:
-    */
-   {
-      GLcontext *ctx = &intel->ctx;
-
-      if (ctx->Driver.Scissor)
-        ctx->Driver.Scissor( ctx, ctx->Scissor.X, ctx->Scissor.Y,
-                             ctx->Scissor.Width, ctx->Scissor.Height );
-      
-      if (ctx->Driver.DepthRange)
-        ctx->Driver.DepthRange( ctx, 
-                                ctx->Viewport.Near,
-                                ctx->Viewport.Far );
-
-      intel->NewGLState |= _NEW_SCISSOR;
-   }
-
-   /* This works because the lock is always grabbed before emitting
-    * commands and commands are always flushed prior to releasing
-    * the lock.
-    */
-   intel->NewGLState |= _NEW_WINDOW_POS; 
-}
-
-
-
-/* A true meta version of this would be very simple and additionally
- * machine independent.  Maybe we'll get there one day.
- */
-static void intelClearWithTris(struct intel_context *intel, 
-                              GLbitfield mask)
-{
-   GLcontext *ctx = &intel->ctx;
-   drm_clip_rect_t clear;
-   GLint cx, cy, cw, ch;
-
-   if (INTEL_DEBUG & DEBUG_DRI)
-      _mesa_printf("%s %x\n", __FUNCTION__, mask);
-
-   {
-
-      intel->vtbl.install_meta_state(intel);
-
-      /* Get clear bounds after locking */
-      cx = ctx->DrawBuffer->_Xmin;
-      cy = ctx->DrawBuffer->_Ymin;
-      cw = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
-      ch = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
-
-      clear.x1 = cx;
-      clear.y1 = cy;
-      clear.x2 = cx + cw;
-      clear.y2 = cy + ch;
-
-      /* Back and stencil cliprects are the same.  Try and do both
-       * buffers at once:
-       */
-      if (mask & (BUFFER_BIT_BACK_LEFT|BUFFER_BIT_STENCIL|BUFFER_BIT_DEPTH)) { 
-        intel->vtbl.meta_draw_region(intel, 
-                                     intel->back_region,
-                                     intel->depth_region );
-
-        if (mask & BUFFER_BIT_BACK_LEFT)
-           intel->vtbl.meta_color_mask(intel, GL_TRUE );
-        else
-           intel->vtbl.meta_color_mask(intel, GL_FALSE );
-
-        if (mask & BUFFER_BIT_STENCIL) 
-           intel->vtbl.meta_stencil_replace( intel, 
-                                             intel->ctx.Stencil.WriteMask[0], 
-                                             intel->ctx.Stencil.Clear);
-        else
-           intel->vtbl.meta_no_stencil_write(intel);
-
-        if (mask & BUFFER_BIT_DEPTH) 
-           intel->vtbl.meta_depth_replace( intel );
-        else
-           intel->vtbl.meta_no_depth_write(intel);
-      
-        /* XXX: Using INTEL_BATCH_NO_CLIPRECTS here is dangerous as the
-         * drawing origin may not be correctly emitted.
-         */
-        intel->vtbl.meta_draw_quad(intel, 
-                                   clear.x1, clear.x2, 
-                                   clear.y1, clear.y2, 
-                                   intel->ctx.Depth.Clear,
-                                   intel->clear_chan[0], 
-                                   intel->clear_chan[1], 
-                                   intel->clear_chan[2], 
-                                   intel->clear_chan[3], 
-                                   0, 0, 0, 0);
-      }
-
-      /* Front may have different cliprects: 
-       */
-      if (mask & BUFFER_BIT_FRONT_LEFT) {
-        intel->vtbl.meta_no_depth_write(intel);
-        intel->vtbl.meta_no_stencil_write(intel);
-        intel->vtbl.meta_color_mask(intel, GL_TRUE );
-        intel->vtbl.meta_draw_region(intel, 
-                                     intel->front_region,
-                                     intel->depth_region);
-
-        /* XXX: Using INTEL_BATCH_NO_CLIPRECTS here is dangerous as the
-         * drawing origin may not be correctly emitted.
-         */
-        intel->vtbl.meta_draw_quad(intel, 
-                                   clear.x1, clear.x2, 
-                                   clear.y1, clear.y2, 
-                                   0,
-                                   intel->clear_chan[0], 
-                                   intel->clear_chan[1], 
-                                   intel->clear_chan[2], 
-                                   intel->clear_chan[3], 
-                                   0, 0, 0, 0);
-      }
-
-      intel->vtbl.leave_meta_state( intel );
-   }
-}
-
-
-
-
-
-static void intelClear(GLcontext *ctx, GLbitfield mask)
-{
-   struct intel_context *intel = intel_context( ctx );
-   const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
-   GLbitfield tri_mask = 0;
-   GLbitfield blit_mask = 0;
-   GLbitfield swrast_mask = 0;
-
-   if (INTEL_DEBUG & DEBUG_DRI)
-      fprintf(stderr, "%s %x\n", __FUNCTION__, mask);
-
-
-   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_STENCIL) {
-      if (!intel->hw_stencil) {
-        swrast_mask |= BUFFER_BIT_STENCIL;
-      }
-      else if ((ctx->Stencil.WriteMask[0] & 0xff) != 0xff ||
-              intel->depth_region->tiled) {
-        tri_mask |= BUFFER_BIT_STENCIL;
-      } 
-      else {
-        blit_mask |= BUFFER_BIT_STENCIL;
-      }
-   }
-
-   /* Do depth with stencil if possible to avoid 2nd pass over the
-    * same buffer.
-    */
-   if (mask & BUFFER_BIT_DEPTH) {
-      if ((tri_mask & BUFFER_BIT_STENCIL) ||
-         intel->depth_region->tiled)
-        tri_mask |= BUFFER_BIT_DEPTH;
-      else 
-        blit_mask |= BUFFER_BIT_DEPTH;
-   }
-
-   swrast_mask |= (mask & BUFFER_BIT_ACCUM);
-
-   intelFlush( ctx );
-
-   if (blit_mask)
-      intelClearWithBlit( ctx, blit_mask );
-
-   if (tri_mask) 
-      intelClearWithTris( intel, tri_mask );
-
-   if (swrast_mask)
-      _swrast_Clear( ctx, swrast_mask );
-}
-
-
-
-
-
-
-
-/* Flip the front & back buffers
- */
-static void intelPageFlip( const __DRIdrawablePrivate *dPriv )
-{
-#if 0
-   struct intel_context *intel;
-   int tmp, ret;
-
-   if (INTEL_DEBUG & DEBUG_IOCTL)
-      fprintf(stderr, "%s\n", __FUNCTION__);
-
-   assert(dPriv);
-   assert(dPriv->driContextPriv);
-   assert(dPriv->driContextPriv->driverPrivate);
-
-   intel = (struct intel_context *) 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
-}
-
-
-void intelSwapBuffers( __DRIdrawablePrivate *dPriv )
-{
-   if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
-      struct intel_context *intel;
-      GLcontext *ctx;
-      intel = (struct intel_context *) 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, NULL );
-        }
-        if (intel->aub_file) {
-           intelFlush(ctx);
-           intel->vtbl.aub_dump_bmp( intel, 1 );
-
-           intel->aub_wrap = 1;
-        }
-      }
-   } 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 intelCopySubBuffer( __DRIdrawablePrivate *dPriv,
-                        int x, int y, int w, int h )
-{
-   if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
-      struct intel_context *intel = dPriv->driContextPriv->driverPrivate;
-      GLcontext *ctx = &intel->ctx;
-
-      if (ctx->Visual.doubleBufferMode) {
-        drm_clip_rect_t rect;
-        rect.x1 = x + dPriv->x;
-        rect.y1 = (dPriv->h - y - h) + dPriv->y;
-        rect.x2 = rect.x1 + w;
-        rect.y2 = rect.y1 + h;
-        _mesa_notifySwapBuffers( ctx );  /* flush pending rendering comands */
-        intelCopyBuffer( dPriv, &rect );
-      }
-   } 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__);
-   }
-}
-
-
-static void intelDrawBuffer(GLcontext *ctx, GLenum mode )
-{
-   struct intel_context *intel = intel_context(ctx);
-   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;
-   }
-
-   if ( intel->sarea->pf_current_page == 1 ) 
-      front ^= 1;
-   
-   intelSetFrontClipRects( intel );
-
-
-   if (front) {
-      if (intel->draw_region != intel->front_region) {
-        intel_region_release(intel, &intel->draw_region);
-        intel_region_reference(&intel->draw_region, intel->front_region);
-      }
-   } else {
-      if (intel->draw_region != intel->back_region) {
-        intel_region_release(intel, &intel->draw_region);
-        intel_region_reference(&intel->draw_region, intel->back_region);
-      }
-   }
-
-   intel->vtbl.set_draw_region( intel, 
-                               intel->draw_region,
-                               intel->depth_region);
-}
-
-static void intelReadBuffer( GLcontext *ctx, GLenum mode )
-{
-   /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */
-}
-
-
-
-void intelInitBufferFuncs( struct dd_function_table *functions )
-{
-   functions->Clear = intelClear;
-   functions->GetBufferSize = intelBufferSize;
-   functions->DrawBuffer = intelDrawBuffer;
-   functions->ReadBuffer = intelReadBuffer;
-}
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..c86daa49f47cd6f633b2ac0da20838a6ac12f6dd
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_buffers.c
\ No newline at end of file
deleted file mode 100644 (file)
index 4f51fefe0f64ddabe661e0ef78a0c54b862caaba..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,712 +0,0 @@
-/**************************************************************************
- * 
- * 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 "points.h"
-
-#include "swrast/swrast.h"
-#include "swrast_setup/swrast_setup.h"
-#include "tnl/tnl.h"
-#include "vbo/vbo.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_ioctl.h"
-#include "intel_batchbuffer.h"
-#include "intel_blit.h"
-#include "intel_regions.h"
-#include "intel_buffer_objects.h"
-
-#include "bufmgr.h"
-
-#include "utils.h"
-#include "vblank.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_ARB_occlusion_query
-#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
-#include "extension_helper.h"
-
-#ifndef VERBOSE
-int VERBOSE = 0;
-#endif
-
-/***************************************
- * Mesa's Driver Functions
- ***************************************/
-
-#define DRIVER_VERSION                     "4.1.3002"
-
-static 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_I965_Q:
-        chipset = "Intel(R) 965Q";
-         break;
-      case PCI_CHIP_I965_G:
-      case PCI_CHIP_I965_G_1:
-        chipset = "Intel(R) 965G";
-         break;
-      case PCI_CHIP_I946_GZ:
-        chipset = "Intel(R) 946GZ";
-         break;
-      case PCI_CHIP_I965_GM:
-        chipset = "Intel(R) 965GM";
-         break;
-      case PCI_CHIP_I965_GME:
-        chipset = "Intel(R) 965GME/GLE";
-         break;
-      default:
-        chipset = "Unknown Intel Chipset";
-      }
-
-      (void) driGetRendererString( buffer, chipset, DRIVER_VERSION, 0 );
-      return (GLubyte *) buffer;
-
-   default:
-      return NULL;
-   }
-}
-
-
-/**
- * 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_non_power_of_two",   NULL },
-    { "GL_ARB_texture_rectangle",          NULL },
-    { "GL_NV_texture_rectangle",           NULL },
-    { "GL_EXT_texture_rectangle",          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_logic_op",             NULL },
-    { "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_SGIS_generate_mipmap",           NULL },
-    { NULL,                                NULL }
-};
-
-const struct dri_extension arb_oc_extension = 
-    { "GL_ARB_occlusion_query",            GL_ARB_occlusion_query_functions};
-
-void intelInitExtensions(GLcontext *ctx, GLboolean enable_imaging)
-{           
-       struct intel_context *intel = ctx?intel_context(ctx):NULL;
-       driInitExtensions(ctx, card_extensions, enable_imaging);
-       if (!ctx || intel->intelScreen->drmMinor >= 8)
-               driInitSingleExtension (ctx, &arb_oc_extension);
-}
-
-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 },
-    { "buf",   DEBUG_BUFMGR },
-    { "stats", DEBUG_STATS },
-    { "tile",  DEBUG_TILE },
-    { "sing",  DEBUG_SINGLE_THREAD },
-    { "thre",  DEBUG_SINGLE_THREAD },
-    { "wm",    DEBUG_WM },
-    { "vs",    DEBUG_VS },
-    { NULL,    0 }
-};
-
-
-static void intelInvalidateState( GLcontext *ctx, GLuint new_state )
-{
-   struct intel_context *intel = intel_context(ctx);
-
-   _swrast_InvalidateState( ctx, new_state );
-   _swsetup_InvalidateState( ctx, new_state );
-   _vbo_InvalidateState( ctx, new_state );
-   _tnl_InvalidateState( ctx, new_state );
-   _tnl_invalidate_vertex_state( ctx, new_state );
-   
-   intel->NewGLState |= new_state;
-
-   if (intel->vtbl.invalidate_state)
-      intel->vtbl.invalidate_state( intel, new_state );
-}
-
-
-void intelFlush( GLcontext *ctx )
-{
-   struct intel_context *intel = intel_context( ctx );
-
-   bmLockAndFence(intel);
-}
-
-void intelFinish( GLcontext *ctx ) 
-{
-   struct intel_context *intel = intel_context( ctx );
-
-   bmFinishFence(intel, bmLockAndFence(intel));
-}
-
-static void
-intelBeginQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q)
-{
-       struct intel_context *intel = intel_context( ctx );
-       drmI830MMIO io = {
-               .read_write = MMIO_READ,
-               .reg = MMIO_REGS_PS_DEPTH_COUNT,
-               .data = &q->Result 
-       };
-       intel->stats_wm++;
-       intelFinish(&intel->ctx);
-       drmCommandRead(intel->driFd, DRM_I830_MMIO, &io, sizeof(io));
-}
-
-static void
-intelEndQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q)
-{
-       struct intel_context *intel = intel_context( ctx );
-       GLuint64EXT tmp;        
-       drmI830MMIO io = {
-               .read_write = MMIO_READ,
-               .reg = MMIO_REGS_PS_DEPTH_COUNT,
-               .data = &tmp
-       };
-       intelFinish(&intel->ctx);
-       drmCommandRead(intel->driFd, DRM_I830_MMIO, &io, sizeof(io));
-       q->Result = tmp - q->Result;
-       q->Ready = GL_TRUE;
-       intel->stats_wm--;
-}
-
-
-void intelInitDriverFunctions( struct dd_function_table *functions )
-{
-   _mesa_init_driver_functions( functions );
-
-   functions->Flush = intelFlush;
-   functions->Finish = intelFinish;
-   functions->GetString = intelGetString;
-   functions->UpdateState = intelInvalidateState;
-   functions->BeginQuery = intelBeginQuery;
-   functions->EndQuery = intelEndQuery;
-
-   /* CopyPixels can be accelerated even with the current memory
-    * manager:
-    */
-   if (!getenv("INTEL_NO_BLIT")) {
-      functions->CopyPixels = intelCopyPixels;
-      functions->Bitmap = intelBitmap;
-   }
-
-   intelInitTextureFuncs( functions );
-   intelInitStateFuncs( functions );
-   intelInitBufferFuncs( functions );
-}
-
-
-
-GLboolean intelInitContext( struct intel_context *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;
-   volatile drmI830Sarea *saPriv = (volatile drmI830Sarea *)
-      (((GLubyte *)sPriv->pSAREA)+intelScreen->sarea_priv_offset);
-
-   if (!_mesa_initialize_context(&intel->ctx,
-                                mesaVis, shareCtx, 
-                                functions,
-                                (void*) intel)) {
-      _mesa_printf("%s: failed to init mesa context\n", __FUNCTION__);
-      return GL_FALSE;
-   }
-
-   driContextPriv->driverPrivate = intel;
-   intel->intelScreen = intelScreen;
-   intel->driScreen = sPriv;
-   intel->sarea = saPriv;
-
-   driParseConfigFiles (&intel->optionCache, &intelScreen->optionCache,
-                  intel->driScreen->myNum, "i965");
-
-   intel->vblank_flags = (intel->intelScreen->irq_active != 0)
-          ? driGetDefaultVBlankFlags(&intel->optionCache) : VBLANK_FLAG_NO_IRQ;
-
-   ctx->Const.MaxTextureMaxAnisotropy = 2.0;
-
-   if (getenv("INTEL_STRICT_CONFORMANCE")) {
-      intel->strict_conformance = 1;
-   }
-
-   if (intel->strict_conformance) {
-      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;
-   }
-   else {
-      ctx->Const.MinLineWidth = 1.0;
-      ctx->Const.MinLineWidthAA = 1.0;
-      ctx->Const.MaxLineWidth = 5.0;
-      ctx->Const.MaxLineWidthAA = 5.0;
-      ctx->Const.LineWidthGranularity = 0.5;
-   }
-
-   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;
-
-   /* reinitialize the context point state.
-    * It depend on constants in __GLcontextRec::Const
-    */
-   _mesa_init_point(ctx);
-
-   /* Initialize the software rasterizer and helper modules. */
-   _swrast_CreateContext( ctx );
-   _vbo_CreateContext( ctx );
-   _tnl_CreateContext( ctx );
-   _swsetup_CreateContext( ctx );
-
-   TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_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 );
-
-   intel->no_hw = getenv("INTEL_NO_HW") != NULL;
-
-   if (!intel->intelScreen->irq_active) {
-      _mesa_printf("IRQs not active.  Exiting\n");
-      exit(1);
-   }
-   intelInitExtensions(ctx, GL_TRUE); 
-
-   INTEL_DEBUG  = driParseDebugString( getenv( "INTEL_DEBUG" ),
-                                      debug_control );
-
-
-   /* Buffer manager: 
-    */
-   intel->bm = bm_fake_intel_Attach( intel );
-
-
-   bmInitPool(intel,
-             intel->intelScreen->tex.offset, /* low offset */
-             intel->intelScreen->tex.map, /* low virtual */
-             intel->intelScreen->tex.size,
-             BM_MEM_AGP);
-
-   /* These are still static, but create regions for them.  
-    */
-   intel->front_region = 
-      intel_region_create_static(intel,
-                                BM_MEM_AGP,
-                                intelScreen->front.offset,
-                                intelScreen->front.map,
-                                intelScreen->cpp,
-                                intelScreen->front.pitch / intelScreen->cpp,
-                                intelScreen->height,
-                                intelScreen->front.size,
-                                intelScreen->front.tiled != 0);
-
-   intel->back_region = 
-      intel_region_create_static(intel,
-                                BM_MEM_AGP,
-                                intelScreen->back.offset,
-                                intelScreen->back.map,
-                                intelScreen->cpp,
-                                intelScreen->back.pitch / intelScreen->cpp,
-                                intelScreen->height,
-                                intelScreen->back.size,
-                                 intelScreen->back.tiled != 0);
-
-   /* Still assuming front.cpp == depth.cpp
-    *
-    * XXX: Setting tiling to false because Depth tiling only supports
-    * YMAJOR but the blitter only supports XMAJOR tiling.  Have to
-    * resolve later.
-    */
-   intel->depth_region = 
-      intel_region_create_static(intel,
-                                BM_MEM_AGP,
-                                intelScreen->depth.offset,
-                                intelScreen->depth.map,
-                                intelScreen->cpp,
-                                intelScreen->depth.pitch / intelScreen->cpp,
-                                intelScreen->height,
-                                intelScreen->depth.size,
-                                 intelScreen->depth.tiled != 0);
-   
-   intel_bufferobj_init( intel );
-   intel->batch = intel_batchbuffer_alloc( intel );
-
-   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 ); */
-
-
-   if (getenv("INTEL_NO_RAST")) {
-      fprintf(stderr, "disabling 3D rasterization\n");
-      intel->no_rast = 1;
-   }
-
-
-   return GL_TRUE;
-}
-
-void intelDestroyContext(__DRIcontextPrivate *driContextPriv)
-{
-   struct intel_context *intel = (struct intel_context *) 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);
-      _vbo_DestroyContext (&intel->ctx);
-
-      _swrast_DestroyContext (&intel->ctx);
-      intel->Fallback = 0;     /* don't call _swrast_Flush later */
-      intel_batchbuffer_free(intel->batch);
-      intel->batch = NULL;
-      
-
-      if ( release_texture_heaps ) {
-         /* This share group is about to go away, free our private
-          * texture object data.
-          */
-
-        /* XXX: destroy the shared bufmgr struct here?
-         */
-      }
-
-      /* Free the regions created to describe front/back/depth
-       * buffers:
-       */
-#if 0
-      intel_region_release(intel, &intel->front_region);
-      intel_region_release(intel, &intel->back_region);
-      intel_region_release(intel, &intel->depth_region);
-      intel_region_release(intel, &intel->draw_region);
-#endif
-
-      /* free the Mesa context */
-      _mesa_destroy_context(&intel->ctx);
-   }
-
-   driContextPriv->driverPrivate = NULL;
-}
-
-GLboolean intelUnbindContext(__DRIcontextPrivate *driContextPriv)
-{
-   return GL_TRUE;
-}
-
-GLboolean intelMakeCurrent(__DRIcontextPrivate *driContextPriv,
-                         __DRIdrawablePrivate *driDrawPriv,
-                         __DRIdrawablePrivate *driReadPriv)
-{
-
-   if (driContextPriv) {
-      struct intel_context *intel = (struct intel_context *) driContextPriv->driverPrivate;
-
-      if ( intel->driDrawable != driDrawPriv ) {
-        /* Shouldn't the readbuffer be stored also? */
-        driDrawableInitVBlank( driDrawPriv, intel->vblank_flags,
-                     &intel->vbl_seq );
-
-        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;
-}
-
-
-static void intelContendedLock( struct intel_context *intel, GLuint flags )
-{
-   __DRIdrawablePrivate *dPriv = intel->driDrawable;
-   __DRIscreenPrivate *sPriv = intel->driScreen;
-   volatile drmI830Sarea * sarea = intel->sarea;
-   int me = intel->hHWContext;
-   int my_bufmgr = bmCtxId(intel);
-
-   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);
-
-
-   intel->locked = 1;
-   intel->need_flush = 1;
-
-   /* Lost context?
-    */
-   if (sarea->ctxOwner != me) {
-      DBG("Lost Context: sarea->ctxOwner %x me %x\n", sarea->ctxOwner, me);
-      sarea->ctxOwner = me;
-      intel->vtbl.lost_hardware( intel );
-   }
-
-   /* As above, but don't evict the texture data on transitions
-    * between contexts which all share a local buffer manager.
-    */
-   if (sarea->texAge != my_bufmgr) {
-      DBG("Lost Textures: sarea->texAge %x my_bufmgr %x\n", sarea->ctxOwner, my_bufmgr);
-      sarea->texAge = my_bufmgr;
-      bm_fake_NotifyContendedLockTake( intel ); 
-   }
-
-   /* Drawable changed?
-    */
-   if (dPriv && intel->lastStamp != dPriv->lastStamp) {
-      intelWindowMoved( intel );
-      intel->lastStamp = dPriv->lastStamp;
-   }
-}
-
-_glthread_DECLARE_STATIC_MUTEX(lockMutex);
-
-/* Lock the hardware and validate our state.  
- */
-void LOCK_HARDWARE( struct intel_context *intel )
-{
-    char __ret=0;
-
-    _glthread_LOCK_MUTEX(lockMutex);
-    assert(!intel->locked);
-
-
-    DRM_CAS(intel->driHwLock, intel->hHWContext,
-           (DRM_LOCK_HELD|intel->hHWContext), __ret);
-    if (__ret)
-        intelContendedLock( intel, 0 );
-
-   intel->locked = 1;
-
-   if (intel->aub_wrap) {
-      bm_fake_NotifyContendedLockTake( intel ); 
-      intel->vtbl.lost_hardware( intel );
-      intel->vtbl.aub_wrap(intel);
-      intel->aub_wrap = 0;
-   }
-
-   if (bmError(intel)) {
-      bmEvictAll(intel);
-      intel->vtbl.lost_hardware( intel );
-   }
-
-   /* Make sure nothing has been emitted prior to getting the lock: 
-    */
-   assert(intel->batch->map == 0);
-
-   /* XXX: postpone, may not be needed:
-    */
-   if (!intel_batchbuffer_map(intel->batch)) {
-      bmEvictAll(intel);
-      intel->vtbl.lost_hardware( intel );
-
-      /* This could only fail if the batchbuffer was greater in size
-       * than the available texture memory:
-       */
-      if (!intel_batchbuffer_map(intel->batch)) {
-        _mesa_printf("double failure to map batchbuffer\n");
-        assert(0);
-      }
-   }
-}
-  
-/* Unlock the hardware using the global current context 
- */
-void UNLOCK_HARDWARE( struct intel_context *intel )
-{
-   /* Make sure everything has been released: 
-    */
-   assert(intel->batch->ptr == intel->batch->map + intel->batch->offset);
-
-   intel_batchbuffer_unmap(intel->batch);
-   intel->vtbl.note_unlock( intel );
-   intel->locked = 0;
-
-
-
-   DRM_UNLOCK(intel->driFd, intel->driHwLock, intel->hHWContext);
-   _glthread_UNLOCK_MUTEX(lockMutex); 
-}
-
-
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..27a1cbb255e69228f67acb1a50cb0f51622074ca
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_context.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i965/intel_context.h b/src/mesa/drivers/dri/i965/intel_context.h
deleted file mode 100644 (file)
index 406f848..0000000
+++ /dev/null
@@ -1,528 +0,0 @@
-/**************************************************************************
- * 
- * 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 "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)
-
-struct intel_region;
-struct intel_context;
-
-typedef void (*intel_tri_func)(struct intel_context *, intelVertex *, intelVertex *,
-                                                         intelVertex *);
-typedef void (*intel_line_func)(struct intel_context *, intelVertex *, intelVertex *);
-typedef void (*intel_point_func)(struct intel_context *, intelVertex *);
-
-#define INTEL_FALLBACK_DRAW_BUFFER      0x1
-#define INTEL_FALLBACK_READ_BUFFER      0x2
-#define INTEL_FALLBACK_USER             0x4
-#define INTEL_FALLBACK_RENDERMODE       0x8
-#define INTEL_FALLBACK_TEXTURE          0x10
-
-extern void intelFallback( struct intel_context *intel, GLuint bit, GLboolean mode );
-#define FALLBACK( intel, bit, mode ) intelFallback( intel, bit, mode )
-
-
-
-struct intel_texture_object
-{
-   struct gl_texture_object base; /* The "parent" object */
-
-   /* The mipmap tree must include at least these levels once
-    * validated:
-    */
-   GLuint firstLevel;
-   GLuint lastLevel;
-
-   GLuint dirty_images[6];
-   GLuint dirty;
-
-   /* On validation any active images held in main memory or in other
-    * regions will be copied to this region and the old storage freed.
-    */
-   struct intel_mipmap_tree *mt;
-};
-
-
-
-struct intel_context
-{
-   GLcontext ctx;              /* the parent class */
-
-   struct {
-      void (*destroy)( struct intel_context *intel ); 
-      void (*emit_state)( struct intel_context *intel );
-      void (*emit_invarient_state)( struct intel_context *intel );
-      void (*lost_hardware)( struct intel_context *intel );
-      void (*note_fence)( struct intel_context *intel, GLuint fence );
-      void (*note_unlock)( struct intel_context *intel );
-      void (*update_texture_state)( struct intel_context *intel );
-
-      void (*render_start)( struct intel_context *intel );
-      void (*set_draw_region)( struct intel_context *intel, 
-                              struct intel_region *draw_region,
-                              struct intel_region *depth_region );
-
-      GLuint (*flush_cmd)( void );
-
-      void (*emit_flush)( struct intel_context *intel,
-                         GLuint unused );
-
-      void (*aub_commands)( struct intel_context *intel, 
-                           GLuint offset,
-                           const void *buf,
-                           GLuint sz );
-      void (*aub_dump_bmp)( struct intel_context *intel, GLuint buffer );
-      void (*aub_wrap)( struct intel_context *intel );
-      void (*aub_gtt_data)( struct intel_context *intel, 
-                           GLuint offset,
-                           const void *src,
-                           GLuint size,
-                           GLuint aubtype, 
-                           GLuint aubsubtype);
-
-
-      void (*reduced_primitive_state)( struct intel_context *intel, GLenum rprim );
-
-      GLboolean (*check_vertex_size)( struct intel_context *intel, GLuint expected );
-
-      void (*invalidate_state)( struct intel_context *intel, GLuint new_state );
-
-      /* Metaops: 
-       */
-      void (*install_meta_state)( struct intel_context *intel );
-      void (*leave_meta_state)( struct intel_context *intel );
-
-      void (*meta_draw_region)( struct intel_context *intel,
-                               struct intel_region *draw_region,
-                               struct intel_region *depth_region );
-
-      void (*meta_color_mask)( struct intel_context *intel,
-                              GLboolean );
-      
-      void (*meta_stencil_replace)( struct intel_context *intel,
-                                   GLuint mask,
-                                   GLuint clear );
-
-      void (*meta_depth_replace)( struct intel_context *intel );
-
-      void (*meta_texture_blend_replace) (struct intel_context * intel);
-      
-      void (*meta_no_stencil_write)( struct intel_context *intel );
-      void (*meta_no_depth_write)( struct intel_context *intel );
-      void (*meta_no_texture)( struct intel_context *intel );
-      void (*meta_import_pixel_state) (struct intel_context * intel);
-      void (*meta_frame_buffer_texture)( struct intel_context *intel,
-                                        GLint xoff, GLint yoff );
-
-      void (*meta_draw_quad)(struct intel_context *intel, 
-                            GLfloat x0, GLfloat x1,
-                            GLfloat y0, GLfloat y1, 
-                            GLfloat z,
-                            GLubyte red, GLubyte green,
-                            GLubyte blue, GLubyte alpha,
-                            GLfloat s0, GLfloat s1,
-                            GLfloat t0, GLfloat t1);
-
-
-
-   } vtbl;
-
-   GLint refcount;   
-   GLuint Fallback;
-   GLuint NewGLState;
-   
-   GLuint last_swap_fence;
-   GLuint second_last_swap_fence;
-   
-   GLboolean aub_wrap;
-   GLuint stats_wm;
-
-   struct intel_batchbuffer *batch;
-
-   GLubyte clear_chan[4];
-   GLuint ClearColor;
-   GLuint ClearDepth;
-
-   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;
-   GLboolean depth_buffer_is_float;
-   GLboolean no_hw;
-   GLboolean no_rast;
-   GLboolean thrashing;
-   GLboolean locked;
-   GLboolean strict_conformance;
-   GLboolean need_flush;
-
-
-   
-   /* AGP memory buffer manager:
-    */
-   struct bufmgr *bm;
-
-
-   /* State for intelvb.c and inteltris.c.
-    */
-   GLenum render_primitive;
-   GLenum reduced_primitive;
-
-   struct intel_region *front_region;
-   struct intel_region *back_region;
-   struct intel_region *draw_region;
-   struct intel_region *depth_region;
-
-   /* These refer to the current draw (front vs. back) buffer:
-    */
-   int drawX;                  /* origin of drawable in draw buffer */
-   int drawY;
-   GLuint numClipRects;                /* cliprects for that buffer */
-   drm_clip_rect_t *pClipRects;
-   struct gl_texture_object *frame_buffer_texobj;
-
-   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; 
-   volatile drmI830Sarea *sarea; 
-   
-   FILE *aub_file;
-
-   GLuint lastStamp;
-
-   /**
-    * Configuration cache
-    */
-   driOptionCache optionCache;
-
-   /* VBI
-    */
-   GLuint vbl_seq;
-   GLuint vblank_flags;
-
-   int64_t swap_ust;
-   int64_t swap_missed_ust;
-
-   GLuint swap_count;
-   GLuint swap_missed_count;
-};
-
-/* These are functions now:
- */
-void LOCK_HARDWARE( struct intel_context *intel );
-void UNLOCK_HARDWARE( struct intel_context *intel );
-
-
-#define SUBPIXEL_X 0.125
-#define SUBPIXEL_Y 0.125
-
-/* ================================================================
- * 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
-
-
-/* The system memcpy (at least on ubuntu 5.10) has problems copying
- * to agp (writecombined) memory from a source which isn't 64-byte
- * aligned - there is a 4x performance falloff.
- *
- * The x86 __memcpy is immune to this but is slightly slower
- * (10%-ish) than the system memcpy.
- *
- * The sse_memcpy seems to have a slight cliff at 64/32 bytes, but
- * isn't much faster than x86_memcpy for agp copies.
- * 
- * TODO: switch dynamically.
- */
-static inline void *do_memcpy( void *dest, const void *src, size_t n )
-{
-   if ( (((unsigned long)src) & 63) ||
-       (((unsigned long)dest) & 63)) {
-      return  __memcpy(dest, src, n);  
-   }
-   else
-      return memcpy(dest, src, n);
-}
-
-
-
-
-
-/* ================================================================
- * Debugging:
- */
-extern int INTEL_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_STATS     0x2000
-#define DEBUG_TILE      0x4000
-#define DEBUG_SINGLE_THREAD   0x8000
-#define DEBUG_WM        0x10000
-#define DEBUG_URB       0x20000
-#define DEBUG_VS        0x40000
-
-
-#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
-#define PCI_CHIP_I965_G                        0x29A2
-#define PCI_CHIP_I965_Q                        0x2992
-#define PCI_CHIP_I965_G_1              0x2982
-#define PCI_CHIP_I946_GZ               0x2972
-#define PCI_CHIP_I965_GM                0x2A02
-#define PCI_CHIP_I965_GME               0x2A12
-
-
-/* ================================================================
- * intel_context.c:
- */
-
-extern GLboolean intelInitContext( struct intel_context *intel, 
-                                  const __GLcontextModes *mesaVis,
-                                  __DRIcontextPrivate *driContextPriv,
-                                  void *sharedContextPrivate,
-                                  struct dd_function_table *functions );
-
-extern void intelGetLock(struct intel_context *intel, GLuint flags);
-
-extern void intelFinish( GLcontext *ctx );
-extern void intelFlush( GLcontext *ctx );
-
-extern void intelInitDriverFunctions( struct dd_function_table *functions );
-
-
-/* ================================================================
- * 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_buffers.c:
- */
-void intelInitBufferFuncs( struct dd_function_table *functions );
-
-struct intel_region *intel_readbuf_region( struct intel_context *intel );
-struct intel_region *intel_drawbuf_region( struct intel_context *intel );
-
-extern void intelWindowMoved( struct intel_context *intel );
-
-extern GLboolean intel_intersect_cliprects( drm_clip_rect_t *dest,
-                                           const drm_clip_rect_t *a,
-                                           const drm_clip_rect_t *b );
-
-
-/* ================================================================
- * intel_pixel_copy.c:
- */
-void intelCopyPixels(GLcontext * ctx,
-                     GLint srcx, GLint srcy,
-                     GLsizei width, GLsizei height,
-                     GLint destx, GLint desty, GLenum type);
-
-GLboolean intel_check_blit_fragment_ops(GLcontext * ctx);
-
-void intelBitmap(GLcontext * ctx,
-                GLint x, GLint y,
-                GLsizei width, GLsizei height,
-                const struct gl_pixelstore_attrib *unpack,
-                const GLubyte * pixels);
-
-void intelInitExtensions(GLcontext *ctx, GLboolean enable_imaging);
-#define _NEW_WINDOW_POS 0x40000000
-
-
-/*======================================================================
- * Inline conversion functions.  
- * These are better-typed than the macros used previously:
- */
-static inline struct intel_context *intel_context( GLcontext *ctx )
-{
-   return (struct intel_context *)ctx;
-}
-
-static inline struct intel_texture_object *intel_texture_object( struct gl_texture_object *obj )
-{
-   return (struct intel_texture_object *)obj;
-}
-
-static inline struct intel_texture_image *intel_texture_image( struct gl_texture_image *img )
-{
-   return (struct intel_texture_image *)img;
-}
-
-#endif
-
diff --git a/src/mesa/drivers/dri/i965/intel_decode.c b/src/mesa/drivers/dri/i965/intel_decode.c
new file mode 120000 (symlink)
index 0000000..f671b6c
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_decode.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i965/intel_depthstencil.c b/src/mesa/drivers/dri/i965/intel_depthstencil.c
new file mode 120000 (symlink)
index 0000000..4ac4ae6
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_depthstencil.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i965/intel_fbo.c b/src/mesa/drivers/dri/i965/intel_fbo.c
new file mode 120000 (symlink)
index 0000000..a19f86d
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_fbo.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i965/intel_ioctl.c b/src/mesa/drivers/dri/i965/intel_ioctl.c
deleted file mode 100644 (file)
index 0a8e976..0000000
+++ /dev/null
@@ -1,205 +0,0 @@
-/**************************************************************************
- * 
- * 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 "intel_blit.h"
-#include "intel_regions.h"
-#include "drm.h"
-#include "bufmgr.h"
-
-static int intelWaitIdleLocked( struct intel_context *intel )
-{
-   static int in_wait_idle = 0;
-   unsigned int fence;
-
-   if (!in_wait_idle) {
-      if (INTEL_DEBUG & DEBUG_SYNC) {
-        fprintf(stderr, "waiting for idle\n");
-      }
-
-      in_wait_idle = 1;
-      fence = bmSetFence(intel);
-      intelWaitIrq(intel, fence);
-      in_wait_idle = 0;
-
-      return bmTestFence(intel, fence);
-   } else {
-      return 1;
-   }
-}
-
-int intelEmitIrqLocked( struct intel_context *intel )
-{
-   int seq = 1;
-
-   if (!intel->no_hw) {
-      drmI830IrqEmit ie;
-      int ret;
-      
-      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;
-}
-
-void intelWaitIrq( struct intel_context *intel, int seq )
-{
-   if (!intel->no_hw) {
-      drmI830IrqWait iw;
-      int ret, lastdispatch;
-      
-      if (0)
-        fprintf(stderr, "%s %d\n", __FUNCTION__, seq );
-
-      iw.irq_seq = seq;
-       
-      do {
-        lastdispatch = intel->sarea->last_dispatch;
-        ret = drmCommandWrite( intel->driFd, DRM_I830_IRQ_WAIT, &iw, sizeof(iw) );
-
-        /* This seems quite often to return before it should!?! 
-         */
-      } while (ret == -EAGAIN || ret == -EINTR || (ret == -EBUSY && lastdispatch != intel->sarea->last_dispatch) || (ret == 0 && seq > intel->sarea->last_dispatch)
-              || (ret == 0 && intel->sarea->last_dispatch - seq >= (1 << 24)));
-      
-
-      if ( ret ) {
-        fprintf( stderr, "%s: drmI830IrqWait: %d\n", __FUNCTION__, ret );
-
-        if (intel->aub_file) {
-           intel->vtbl.aub_dump_bmp( intel, intel->ctx.Visual.doubleBufferMode ? 1 : 0 );
-        }
-
-        exit(1);
-      }
-   }
-}
-
-
-void intel_batch_ioctl( struct intel_context *intel, 
-                       GLuint start_offset,
-                       GLuint used)
-{
-   drmI830BatchBuffer batch;
-
-   assert(intel->locked);
-   assert(used);
-
-   if (0)
-      fprintf(stderr, "%s used %d offset %x..%x\n",
-             __FUNCTION__, 
-             used, 
-             start_offset,
-             start_offset + used);
-
-   batch.start = start_offset;
-   batch.used = used;
-   batch.cliprects = NULL;
-   batch.num_cliprects = 0;
-   batch.DR1 = 0;
-   batch.DR4 = 0;
-      
-   if (INTEL_DEBUG & DEBUG_DMA)
-      fprintf(stderr, "%s: 0x%x..0x%x\n",
-             __FUNCTION__, 
-             batch.start, 
-             batch.start + batch.used * 4);
-
-   if (!intel->no_hw) {
-      if (drmCommandWrite (intel->driFd, DRM_I830_BATCHBUFFER, &batch, 
-                          sizeof(batch))) {
-        fprintf(stderr, "DRM_I830_BATCHBUFFER: %d\n",  -errno);
-        UNLOCK_HARDWARE(intel);
-        exit(1);
-      }
-
-      if (INTEL_DEBUG & DEBUG_SYNC) {
-       intelWaitIdleLocked(intel);
-      }
-   }
-}
-
-void intel_cmd_ioctl( struct intel_context *intel, 
-                     char *buf,
-                     GLuint used)
-{
-   drmI830CmdBuffer cmd;
-
-   assert(intel->locked);
-   assert(used);
-
-   cmd.buf = buf;
-   cmd.sz = used;
-   cmd.cliprects = intel->pClipRects;
-   cmd.num_cliprects = 0;
-   cmd.DR1 = 0;
-   cmd.DR4 = 0;
-      
-   if (INTEL_DEBUG & DEBUG_DMA)
-      fprintf(stderr, "%s: 0x%x..0x%x\n",
-             __FUNCTION__, 
-             0, 
-             0 + cmd.sz);
-
-   if (!intel->no_hw) {
-      if (drmCommandWrite (intel->driFd, DRM_I830_CMDBUFFER, &cmd, 
-                          sizeof(cmd))) {
-        fprintf(stderr, "DRM_I830_CMDBUFFER: %d\n",  -errno);
-        UNLOCK_HARDWARE(intel);
-        exit(1);
-      }
-
-      if (INTEL_DEBUG & DEBUG_SYNC) {
-       intelWaitIdleLocked(intel);
-      }
-   }
-}
diff --git a/src/mesa/drivers/dri/i965/intel_ioctl.h b/src/mesa/drivers/dri/i965/intel_ioctl.h
deleted file mode 100644 (file)
index df27659..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/**************************************************************************
- * 
- * 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"
-
-void intelWaitIrq( struct intel_context *intel, int seq );
-int intelEmitIrqLocked( struct intel_context *intel );
-
-void intel_batch_ioctl( struct intel_context *intel, 
-                       GLuint start_offset,
-                       GLuint used);
-
-void intel_cmd_ioctl( struct intel_context *intel, 
-                     char *buf,
-                     GLuint used);
-
-#endif
deleted file mode 100644 (file)
index 8486086b274d5cdb5ff7a4279ece19a78963e49a..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,247 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2006 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 "intel_context.h"
-#include "intel_mipmap_tree.h"
-#include "intel_regions.h"
-#include "bufmgr.h"
-#include "enums.h"
-#include "imports.h"
-
-static GLenum target_to_target( GLenum target )
-{
-   switch (target) {
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
-      return GL_TEXTURE_CUBE_MAP_ARB;
-   default:
-      return target;
-   }
-}
-
-struct intel_mipmap_tree *intel_miptree_create( struct intel_context *intel,
-                                               GLenum target,
-                                               GLenum internal_format,
-                                               GLuint first_level,
-                                               GLuint last_level,
-                                               GLuint width0,
-                                               GLuint height0,
-                                               GLuint depth0,
-                                               GLuint cpp,
-                                               GLboolean compressed)
-{
-   GLboolean ok;
-   struct intel_mipmap_tree *mt = calloc(sizeof(*mt), 1);
-
-   if (INTEL_DEBUG & DEBUG_TEXTURE)
-      _mesa_printf("%s target %s format %s level %d..%d\n", __FUNCTION__,
-                  _mesa_lookup_enum_by_nr(target),
-                  _mesa_lookup_enum_by_nr(internal_format),
-                  first_level,
-                  last_level);
-
-   mt->target = target_to_target(target);
-   mt->internal_format = internal_format;
-   mt->first_level = first_level;
-   mt->last_level = last_level;
-   mt->width0 = width0;
-   mt->height0 = height0;
-   mt->depth0 = depth0;
-   mt->cpp = compressed ? 2 : cpp;
-   mt->compressed = compressed;
-
-   switch (intel->intelScreen->deviceID) {
-#if 0
-   case PCI_CHIP_I945_G:
-      ok = i945_miptree_layout( mt );
-      break;
-   case PCI_CHIP_I915_G:
-   case PCI_CHIP_I915_GM:
-      ok = i915_miptree_layout( mt );
-      break;
-#endif
-   default:
-      if (INTEL_DEBUG & DEBUG_TEXTURE)
-        _mesa_printf("assuming BRW texture layouts\n");
-      ok = brw_miptree_layout( mt );
-      break;
-   }
-
-   if (ok)
-      mt->region = intel_region_alloc( intel, 
-                                      mt->cpp,
-                                      mt->pitch, 
-                                      mt->total_height );
-
-   if (!mt->region) {
-      free(mt);
-      return NULL;
-   }
-
-   return mt;
-}
-
-
-
-void intel_miptree_destroy( struct intel_context *intel,
-                           struct intel_mipmap_tree *mt )
-{
-   if (mt) {
-      GLuint i;
-
-      intel_region_release(intel, &(mt->region));
-
-      for (i = 0; i < MAX_TEXTURE_LEVELS; i++)
-        if (mt->level[i].image_offset)
-           free(mt->level[i].image_offset);
-
-      free(mt);
-   }
-}
-
-
-
-
-void intel_miptree_set_level_info(struct intel_mipmap_tree *mt,
-                                 GLuint level,
-                                 GLuint nr_images,
-                                 GLuint x, GLuint y,
-                                 GLuint w, GLuint h, GLuint d)
-{
-   mt->level[level].width = w;
-   mt->level[level].height = h;
-   mt->level[level].depth = d;
-   mt->level[level].level_offset = (x + y * mt->pitch) * mt->cpp;
-   mt->level[level].nr_images = nr_images;
-
-   if (INTEL_DEBUG & DEBUG_TEXTURE)
-      _mesa_printf("%s level %d img size: %d,%d level_offset 0x%x\n", __FUNCTION__, level, w, h, 
-                  mt->level[level].level_offset);
-
-   /* Not sure when this would happen, but anyway: 
-    */
-   if (mt->level[level].image_offset) {
-      free(mt->level[level].image_offset);
-      mt->level[level].image_offset = NULL;
-   }
-
-   if (nr_images > 1) {
-      mt->level[level].image_offset = malloc(nr_images * sizeof(GLuint));
-      mt->level[level].image_offset[0] = 0;
-   }
-}
-
-
-
-void intel_miptree_set_image_offset(struct intel_mipmap_tree *mt,
-                                   GLuint level,
-                                   GLuint img,
-                                   GLuint x, GLuint y)
-{
-   if (INTEL_DEBUG & DEBUG_TEXTURE)
-      _mesa_printf("%s level %d img %d pos %d,%d\n", __FUNCTION__, level, img, x, y);
-
-   if (img == 0)
-      assert(x == 0 && y == 0);
-
-   if (img > 0)
-      mt->level[level].image_offset[img] = (x + y * mt->pitch) * mt->cpp;
-}
-
-
-/* Although we use the image_offset[] array to store relative offsets
- * to cube faces, Mesa doesn't know anything about this and expects
- * each cube face to be treated as a separate image.
- *
- * These functions present that view to mesa:
- */
-const GLuint *intel_miptree_depth_offsets(struct intel_mipmap_tree *mt,
-                                         GLuint level)
-{
-   static const GLuint zero = 0;
-
-   if (mt->target != GL_TEXTURE_3D ||
-       mt->level[level].nr_images == 1)
-      return &zero;
-   else
-      return mt->level[level].image_offset;
-}
-
-
-GLuint intel_miptree_image_offset(struct intel_mipmap_tree *mt,
-                                 GLuint face,
-                                 GLuint level)
-{
-   if (mt->target == GL_TEXTURE_CUBE_MAP_ARB)
-      return (mt->level[level].level_offset +
-             mt->level[level].image_offset[face]);
-   else
-      return mt->level[level].level_offset;
-}
-
-
-
-
-
-
-/* Upload data for a particular image.
- */
-GLboolean intel_miptree_image_data(struct intel_context *intel, 
-                                  struct intel_mipmap_tree *dst,
-                                  GLuint face,
-                                  GLuint level,
-                                  const void *src, 
-                                  GLuint src_row_pitch,
-                                  GLuint src_image_pitch)
-{
-   GLuint depth = dst->level[level].depth;
-   GLuint dst_offset = intel_miptree_image_offset(dst, face, level);
-   const GLuint *dst_depth_offset = intel_miptree_depth_offsets(dst, level);
-   GLuint i;
-
-   DBG("%s\n", __FUNCTION__);
-   for (i = 0; i < depth; i++) {
-      if (!intel_region_data(intel,
-                            dst->region, 
-                            dst_offset + dst_depth_offset[i],
-                            0,
-                            0,
-                            src,
-                            src_row_pitch,
-                            0, 0,      /* source x,y */
-                            dst->level[level].width,
-                            dst->level[level].height))
-        return GL_FALSE;
-      src += src_image_pitch;
-   }
-   return GL_TRUE;
-}
-
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..242fed0b6aea3103f34d47677242be8804cf0b31
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_mipmap_tree.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
deleted file mode 100644 (file)
index dbd7167..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2006 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_MIPMAP_TREE_H
-#define INTEL_MIPMAP_TREE_H
-
-#include "intel_regions.h"
-
-/* A layer on top of the intel_regions code which adds:
- *
- * - Code to size and layout a region to hold a set of mipmaps.
- * - Query to determine if a new image fits in an existing tree.
- *
- * The fixed mipmap layout of intel hardware where one offset
- * specifies the position of all images in a mipmap hierachy
- * complicates the implementation of GL texture image commands,
- * compared to hardware where each image is specified with an
- * independent offset.
- *
- * In an ideal world, each texture object would be associated with a
- * single bufmgr buffer or 2d intel_region, and all the images within
- * the texture object would slot into the tree as they arrive.  The
- * reality can be a little messier, as images can arrive from the user
- * with sizes that don't fit in the existing tree, or in an order
- * where the tree layout cannot be guessed immediately.  
- * 
- * This structure encodes an idealized mipmap tree.  The GL image
- * commands build these where possible, otherwise store the images in
- * temporary system buffers.
- */
-
-
-struct intel_mipmap_level {
-   GLuint level_offset;
-   GLuint width;
-   GLuint height;
-   GLuint depth;
-   GLuint nr_images;
-
-   /* Explicitly store the offset of each image for each cube face or
-    * depth value.  Pretty much have to accept that hardware formats
-    * are going to be so diverse that there is no unified way to
-    * compute the offsets of depth/cube images within a mipmap level,
-    * so have to store them as a lookup table:
-    */
-   GLuint *image_offset;
-};
-
-struct intel_mipmap_tree {
-   /* Effectively the key:
-    */
-   GLenum target;
-   GLenum internal_format;
-
-   GLuint first_level;
-   GLuint last_level;
-
-   GLuint width0, height0, depth0;
-   GLuint cpp;
-   GLboolean compressed;
-
-   /* Derived from the above:
-    */   
-   GLuint pitch;
-   GLuint depth_pitch;         /* per-image on i945? */
-   GLuint total_height;
-   
-   /* Includes image offset tables:
-    */
-   struct intel_mipmap_level level[MAX_TEXTURE_LEVELS];
-
-   /* The data is held here:
-    */
-   struct intel_region *region;
-
-   /* These are also refcounted:
-    */
-   GLuint refcount;
-};
-
-
-
-struct intel_mipmap_tree *intel_miptree_create( struct intel_context *intel,
-                                               GLenum target,
-                                               GLenum internal_format,
-                                               GLuint first_level,
-                                               GLuint last_level,
-                                               GLuint width0,
-                                               GLuint height0,
-                                               GLuint depth0,
-                                               GLuint cpp,
-                                               GLboolean compressed);
-
-void intel_miptree_destroy( struct intel_context *intel,
-                           struct intel_mipmap_tree *mt );
-
-
-/* Return the linear offset of an image relative to the start of the
- * tree:
- */
-GLuint intel_miptree_image_offset( struct intel_mipmap_tree *mt,
-                                  GLuint face,
-                                  GLuint level );
-
-/* Return pointers to each 2d slice within an image.  Indexed by depth
- * value.
- */
-const GLuint *intel_miptree_depth_offsets(struct intel_mipmap_tree *mt,
-                                         GLuint level);
-
-
-void intel_miptree_set_level_info(struct intel_mipmap_tree *mt,
-                                 GLuint level,
-                                 GLuint nr_images,
-                                 GLuint x, GLuint y,
-                                 GLuint w, GLuint h, GLuint d);
-
-void intel_miptree_set_image_offset(struct intel_mipmap_tree *mt,
-                                   GLuint level,
-                                   GLuint img,
-                                   GLuint x, GLuint y);
-
-
-/* Upload an image into a tree
- */
-GLboolean intel_miptree_image_data(struct intel_context *intel, 
-                                  struct intel_mipmap_tree *dst,
-                                  GLuint face,
-                                  GLuint level,
-                                  const void *src, 
-                                  GLuint src_row_pitch,
-                                  GLuint src_image_pitch);
-
-/* i915_mipmap_tree.c:
- */
-GLboolean i915_miptree_layout( struct intel_mipmap_tree *mt );
-GLboolean i945_miptree_layout( struct intel_mipmap_tree *mt );
-GLboolean brw_miptree_layout( struct intel_mipmap_tree *mt );
-
-
-
-#endif
diff --git a/src/mesa/drivers/dri/i965/intel_pixel.c b/src/mesa/drivers/dri/i965/intel_pixel.c
new file mode 120000 (symlink)
index 0000000..d733c5e
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_pixel.c
\ No newline at end of file
deleted file mode 100644 (file)
index 421fcc5e511651ae96845a1f5ccdf0bf53ad686d..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,353 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2006 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 portionsalloc
- * of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 "image.h"
-#include "colormac.h"
-#include "mtypes.h"
-#include "macros.h"
-#include "bufferobj.h"
-#include "swrast/swrast.h"
-
-#include "intel_screen.h"
-#include "intel_context.h"
-#include "intel_ioctl.h"
-#include "intel_batchbuffer.h"
-#include "intel_blit.h"
-#include "intel_regions.h"
-#include "intel_buffer_objects.h"
-
-
-
-#define FILE_DEBUG_FLAG DEBUG_PIXEL
-
-
-/* Unlike the other intel_pixel_* functions, the expectation here is
- * that the incoming data is not in a PBO.  With the XY_TEXT blit
- * method, there's no benefit haveing it in a PBO, but we could
- * implement a path based on XY_MONO_SRC_COPY_BLIT which might benefit
- * PBO bitmaps.  I think they are probably pretty rare though - I
- * wonder if Xgl uses them?
- */
-static const GLubyte *map_pbo( GLcontext *ctx,
-                              GLsizei width, GLsizei height,
-                              const struct gl_pixelstore_attrib *unpack,
-                              const GLubyte *bitmap )
-{
-   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 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, "glBitmap(PBO is mapped)");
-      return NULL;
-   }
-
-   return ADD_POINTERS(buf, bitmap);
-}
-
-static GLboolean test_bit( const GLubyte *src,
-                           GLuint bit )
-{
-   return (src[bit/8] & (1<<(bit % 8))) ? 1 : 0;
-}
-
-static void set_bit( GLubyte *dest,
-                         GLuint bit )
-{
-   dest[bit/8] |= 1 << (bit % 8);
-}
-
-static int align(int x, int align)
-{
-   return (x + align - 1) & ~(align - 1);
-}
-
-/* Extract a rectangle's worth of data from the bitmap.  Called
- * per-cliprect.
- */
-static GLuint get_bitmap_rect(GLsizei width, GLsizei height,
-                             const struct gl_pixelstore_attrib *unpack,
-                             const GLubyte *bitmap,
-                             GLuint x, GLuint y, 
-                             GLuint w, GLuint h,
-                             GLubyte *dest,
-                             GLuint row_align,
-                             GLboolean invert)
-{
-   GLuint src_offset = (x + unpack->SkipPixels) & 0x7;
-   GLuint mask = unpack->LsbFirst ? 0 : 7;
-   GLuint bit = 0;
-   GLint row, col;
-   GLint first, last;
-   GLint incr;
-   GLuint count = 0;
-
-   if (INTEL_DEBUG & DEBUG_PIXEL)
-      _mesa_printf("%s %d,%d %dx%d bitmap %dx%d skip %d src_offset %d mask %d\n",
-                  __FUNCTION__, x,y,w,h,width,height,unpack->SkipPixels, src_offset, mask);
-
-   if (invert) {
-      first = h-1;
-      last = 0;
-      incr = -1;
-   }
-   else {
-      first = 0;
-      last = h-1;
-      incr = 1;
-   }
-
-   /* Require that dest be pre-zero'd.
-    */
-   for (row = first; row != (last+incr); row += incr) {
-      const GLubyte *rowsrc = _mesa_image_address2d(unpack, bitmap, 
-                                                   width, height, 
-                                                   GL_COLOR_INDEX, GL_BITMAP, 
-                                                   y + row, x);
-
-      for (col = 0; col < w; col++, bit++) {
-        if (test_bit(rowsrc, (col + src_offset) ^ mask)) {
-           set_bit(dest, bit ^ 7);
-           count++;
-        }
-      }
-
-      if (row_align)
-        bit = (bit + row_align - 1) & ~(row_align - 1);
-   }
-
-   return count;
-}
-
-
-
-
-/*
- * Render a bitmap.
- */
-static GLboolean
-do_blit_bitmap( GLcontext *ctx, 
-               GLint dstx, GLint dsty,
-               GLsizei width, GLsizei height,
-               const struct gl_pixelstore_attrib *unpack,
-               const GLubyte *bitmap )
-{
-   struct intel_context *intel = intel_context(ctx);
-   struct intel_region *dst = intel_drawbuf_region(intel);
-   
-   union {
-      GLuint ui;
-      GLubyte ub[4];
-   } color;
-
-
-   if (unpack->BufferObj->Name) {
-      bitmap = map_pbo(ctx, width, height, unpack, bitmap);
-      if (bitmap == NULL)
-        return GL_TRUE;        /* even though this is an error, we're done */
-   }
-
-   UNCLAMPED_FLOAT_TO_CHAN(color.ub[0], ctx->Current.RasterColor[2]);
-   UNCLAMPED_FLOAT_TO_CHAN(color.ub[1], ctx->Current.RasterColor[1]);
-   UNCLAMPED_FLOAT_TO_CHAN(color.ub[2], ctx->Current.RasterColor[0]);
-   UNCLAMPED_FLOAT_TO_CHAN(color.ub[3], ctx->Current.RasterColor[3]);
-
-   /* Does zoom apply to bitmaps?
-    */
-   if (!intel_check_blit_fragment_ops(ctx) ||
-       ctx->Pixel.ZoomX != 1.0F || 
-       ctx->Pixel.ZoomY != 1.0F)
-      return GL_FALSE;
-
-   LOCK_HARDWARE(intel);
-
-   if (intel->driDrawable->numClipRects) {
-      __DRIdrawablePrivate *dPriv = intel->driDrawable;
-      drm_clip_rect_t *box = dPriv->pClipRects;
-      drm_clip_rect_t dest_rect;
-      GLint nbox = dPriv->numClipRects;
-      GLint srcx = 0, srcy = 0;
-      GLint orig_screen_x1, orig_screen_y2;
-      GLuint i;
-
-
-      orig_screen_x1 = dPriv->x + dstx;
-      orig_screen_y2 = dPriv->y + (dPriv->h - dsty);
-
-      /* Do scissoring in GL coordinates:
-       */
-      if (ctx->Scissor.Enabled)
-      {
-        GLint x = ctx->Scissor.X;
-        GLint y = ctx->Scissor.Y;
-        GLuint w = ctx->Scissor.Width;
-        GLuint h = ctx->Scissor.Height;
-
-         if (!_mesa_clip_to_region(x, y, x+w-1, y+h-1, &dstx, &dsty, &width, &height))
-            goto out;
-      }
-
-      /* Convert from GL to hardware coordinates:
-       */
-      dsty = dPriv->y + (dPriv->h - dsty - height);  
-      dstx = dPriv->x + dstx;
-
-      dest_rect.x1 = dstx;
-      dest_rect.y1 = dsty;
-      dest_rect.x2 = dstx + width;
-      dest_rect.y2 = dsty + height;
-
-      for (i = 0; i < nbox; i++) {
-         drm_clip_rect_t rect;
-        int box_w, box_h;
-        GLint px, py;
-        GLuint stipple[32];  
-
-         if (!intel_intersect_cliprects(&rect, &dest_rect, &box[i]))
-            continue;
-
-        /* Now go back to GL coordinates to figure out what subset of
-         * the bitmap we are uploading for this cliprect:
-         */
-        box_w = rect.x2 - rect.x1;
-        box_h = rect.y2 - rect.y1;
-        srcx = rect.x1 - orig_screen_x1;
-        srcy = orig_screen_y2 - rect.y2;
-
-
-#define DY 32
-#define DX 32
-
-        /* Then, finally, chop it all into chunks that can be
-         * digested by hardware:
-         */
-        for (py = 0; py < box_h; py += DY) { 
-           for (px = 0; px < box_w; px += DX) { 
-              int h = MIN2(DY, box_h - py);
-              int w = MIN2(DX, box_w - px); 
-              GLuint sz = align(align(w,8) * h, 64)/8;
-              GLenum logic_op = ctx->Color.ColorLogicOpEnabled ?
-                 ctx->Color.LogicOp : GL_COPY;
-
-              assert(sz <= sizeof(stipple));
-              memset(stipple, 0, sz);
-
-              /* May need to adjust this when padding has been introduced in
-               * sz above:
-               */
-              if (get_bitmap_rect(width, height, unpack, 
-                                  bitmap,
-                                  srcx + px, srcy + py, w, h,
-                                  (GLubyte *)stipple,
-                                  8,
-                                  GL_TRUE) == 0)
-                 continue;
-
-              /* 
-               */
-              intelEmitImmediateColorExpandBlit( intel,
-                                                 dst->cpp,
-                                                 (GLubyte *)stipple, 
-                                                 sz,
-                                                 color.ui,
-                                                 dst->pitch,
-                                                 dst->buffer,
-                                                 0,
-                                                 dst->tiled,
-                                                 rect.x1 + px,
-                                                 rect.y2 - (py + h),
-                                                 w, h,
-                                                 logic_op);
-           } 
-        } 
-      }
-      intel->need_flush = GL_TRUE;
-   out:
-      intel_batchbuffer_flush(intel->batch);
-   }
-   UNLOCK_HARDWARE(intel);
-
-
-   if (unpack->BufferObj->Name) {
-      /* done with PBO so unmap it now */
-      ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
-                              unpack->BufferObj);
-   }
-
-   return GL_TRUE;
-}
-
-
-
-
-
-/* There are a large number of possible ways to implement bitmap on
- * this hardware, most of them have some sort of drawback.  Here are a
- * few that spring to mind:
- * 
- * Blit:
- *    - XY_MONO_SRC_BLT_CMD
- *         - use XY_SETUP_CLIP_BLT for cliprect clipping.
- *    - XY_TEXT_BLT
- *    - XY_TEXT_IMMEDIATE_BLT
- *         - blit per cliprect, subject to maximum immediate data size.
- *    - XY_COLOR_BLT 
- *         - per pixel or run of pixels
- *    - XY_PIXEL_BLT
- *         - good for sparse bitmaps
- *
- * 3D engine:
- *    - Point per pixel
- *    - Translate bitmap to an alpha texture and render as a quad
- *    - Chop bitmap up into 32x32 squares and render w/polygon stipple.
- */
-void
-intelBitmap(GLcontext * ctx,
-           GLint x, GLint y,
-           GLsizei width, GLsizei height,
-           const struct gl_pixelstore_attrib *unpack,
-           const GLubyte * pixels)
-{
-   if (do_blit_bitmap(ctx, x, y, width, height,
-                          unpack, pixels))
-      return;
-
-   if (INTEL_DEBUG & DEBUG_PIXEL)
-      _mesa_printf("%s: fallback to swrast\n", __FUNCTION__);
-
-   _swrast_Bitmap(ctx, x, y, width, height, unpack, pixels);
-}
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..9085c7b0397448a2e3ab47ca0b803921d9175469
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_pixel_bitmap.c
\ No newline at end of file
deleted file mode 100644 (file)
index 58dc49505fea7a3833cc26721275056a63581cdc..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,343 +0,0 @@
-/**************************************************************************
- * 
- * 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 "image.h"
-#include "mtypes.h"
-#include "macros.h"
-#include "state.h"
-#include "swrast/swrast.h"
-
-#include "intel_screen.h"
-#include "intel_context.h"
-#include "intel_ioctl.h"
-#include "intel_batchbuffer.h"
-#include "intel_blit.h"
-#include "intel_regions.h"
-
-
-static struct intel_region *
-copypix_src_region(struct intel_context *intel, GLenum type)
-{
-   switch (type) {
-   case GL_COLOR:
-      return intel_readbuf_region(intel);
-   case GL_DEPTH:
-      /* Don't think this is really possible execpt at 16bpp, when we have no stencil.
-       */
-      if (intel->depth_region && intel->depth_region->cpp == 2)
-         return intel->depth_region;
-   case GL_STENCIL:
-      /* Don't think this is really possible. 
-       */
-      break;
-   case GL_DEPTH_STENCIL_EXT:
-      /* Does it matter whether it is stencil/depth or depth/stencil?
-       */
-      return intel->depth_region;
-   default:
-      break;
-   }
-
-   return NULL;
-}
-
-
-
-
-/**
- * Check if any fragment operations are in effect which might effect
- * glDraw/CopyPixels.
- */
-GLboolean
-intel_check_blit_fragment_ops(GLcontext * ctx)
-{
-   if (ctx->NewState)
-      _mesa_update_state(ctx);
-
-   return !(ctx->_ImageTransferState ||
-           ctx->RenderMode != GL_RENDER ||
-            ctx->Color.AlphaEnabled ||
-            ctx->Depth.Test ||
-            ctx->Fog.Enabled ||
-            ctx->Stencil.Enabled ||
-            !ctx->Color.ColorMask[0] ||
-            !ctx->Color.ColorMask[1] ||
-            !ctx->Color.ColorMask[2] ||
-            !ctx->Color.ColorMask[3] ||        /* can do this! */
-            ctx->Texture._EnabledUnits ||
-           ctx->FragmentProgram._Enabled ||
-           ctx->Color.BlendEnabled);
-}
-
-/* Doesn't work for overlapping regions.  Could do a double copy or
- * just fallback.
- */
-static GLboolean
-do_texture_copypixels(GLcontext * ctx,
-                      GLint srcx, GLint srcy,
-                      GLsizei width, GLsizei height,
-                      GLint dstx, GLint dsty, GLenum type)
-{
-   struct intel_context *intel = intel_context(ctx);
-   struct intel_region *dst = intel_drawbuf_region(intel);
-   struct intel_region *src = copypix_src_region(intel, type);
-   GLenum src_format;
-   GLenum src_type;
-
-   DBG("%s %d,%d %dx%d --> %d,%d\n", __FUNCTION__, 
-       srcx, srcy, width, height, dstx, dsty);
-
-   if (!src || !dst || type != GL_COLOR ||
-       ctx->_ImageTransferState ||
-       ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F ||
-       ctx->RenderMode != GL_RENDER ||
-       ctx->Texture._EnabledUnits ||
-       ctx->FragmentProgram._Enabled ||
-       src != dst )
-       return GL_FALSE;
-   
-   /* Can't handle overlapping regions.  Don't have sufficient control
-    * over rasterization to pull it off in-place.  Punt on these for
-    * now.
-    * 
-    * XXX: do a copy to a temporary. 
-    */
-   if (src->buffer == dst->buffer) {
-      drm_clip_rect_t srcbox;
-      drm_clip_rect_t dstbox;
-      drm_clip_rect_t tmp;
-
-      srcbox.x1 = srcx;
-      srcbox.y1 = srcy;
-      srcbox.x2 = srcx + width - 1;
-      srcbox.y2 = srcy + height - 1;
-
-      dstbox.x1 = dstx;
-      dstbox.y1 = dsty;
-      dstbox.x2 = dstx + width - 1;
-      dstbox.y2 = dsty + height - 1;
-
-      DBG("src %d,%d %d,%d\n", srcbox.x1, srcbox.y1, srcbox.x2, srcbox.y2);
-      DBG("dst %d,%d %d,%d (%dx%d) (%f,%f)\n", dstbox.x1, dstbox.y1, dstbox.x2, dstbox.y2,
-         width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY);
-
-      if (intel_intersect_cliprects(&tmp, &srcbox, &dstbox)) {
-         DBG("%s: regions overlap\n", __FUNCTION__);
-         return GL_FALSE;
-      }
-   }
-
-   intelFlush(&intel->ctx);
-
-   intel->vtbl.install_meta_state(intel);
-
-   /* Is this true?  Also will need to turn depth testing on according
-    * to state:
-    */
-   intel->vtbl.meta_no_stencil_write(intel);
-   intel->vtbl.meta_no_depth_write(intel);
-
-   /* Set the 3d engine to draw into the destination region:
-    */
-   intel->vtbl.meta_draw_region(intel, dst, intel->depth_region);
-
-   intel->vtbl.meta_import_pixel_state(intel);
-
-   if (src->cpp == 2) {
-      src_format = GL_RGB;
-      src_type = GL_UNSIGNED_SHORT_5_6_5;
-   }
-   else {
-      src_format = GL_BGRA;
-      src_type = GL_UNSIGNED_BYTE;
-   }
-
-   /* Set the frontbuffer up as a large rectangular texture.
-    */
-   intel->vtbl.meta_frame_buffer_texture( intel, srcx - dstx, srcy - dsty );
-
-   intel->vtbl.meta_texture_blend_replace(intel);
-   
-   if (intel->driDrawable->numClipRects)
-      intel->vtbl.meta_draw_quad( intel,
-                                 dstx, dstx + width,
-                                 dsty, dsty + height,
-                                 ctx->Current.RasterPos[ 2 ],
-                                 0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0 );
-   
-   intel->vtbl.leave_meta_state( intel );
-   
-   DBG("%s: success\n", __FUNCTION__);
-   return GL_TRUE;
-}
-
-/**
- * CopyPixels with the blitter.  Don't support zooming, pixel transfer, etc.
- */
-static GLboolean
-do_blit_copypixels(GLcontext * ctx,
-                   GLint srcx, GLint srcy,
-                   GLsizei width, GLsizei height,
-                   GLint dstx, GLint dsty, GLenum type)
-{
-   struct intel_context *intel = intel_context(ctx);
-   struct intel_region *dst = intel_drawbuf_region(intel);
-   struct intel_region *src = copypix_src_region(intel, type);
-
-   /* Copypixels can be more than a straight copy.  Ensure all the
-    * extra operations are disabled:
-    */
-   if (!intel_check_blit_fragment_ops(ctx) ||
-       ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F)
-      return GL_FALSE;
-
-   if (!src || !dst)
-      return GL_FALSE;
-
-
-
-   intelFlush(&intel->ctx);
-
-/*    intel->vtbl.render_start(intel); */
-/*    intel->vtbl.emit_state(intel); */
-
-   LOCK_HARDWARE(intel);
-
-   if (intel->driDrawable->numClipRects) {
-      __DRIdrawablePrivate *dPriv = intel->driDrawable;
-      drm_clip_rect_t *box = dPriv->pClipRects;
-      drm_clip_rect_t dest_rect;
-      GLint nbox = dPriv->numClipRects;
-      GLint delta_x = 0;
-      GLint delta_y = 0;
-      GLuint i;
-
-      /* Do scissoring in GL coordinates:
-       */
-      if (ctx->Scissor.Enabled)
-      {
-        GLint x = ctx->Scissor.X;
-        GLint y = ctx->Scissor.Y;
-        GLuint w = ctx->Scissor.Width;
-        GLuint h = ctx->Scissor.Height;
-        GLint dx = dstx - srcx;
-         GLint dy = dsty - srcy;
-
-         if (!_mesa_clip_to_region(x, y, x+w-1, y+h-1, &dstx, &dsty, &width, &height))
-            goto out;
-        
-         srcx = dstx - dx;
-         srcy = dsty - dy;
-      }
-
-      /* Convert from GL to hardware coordinates:
-       */
-      dsty = dPriv->h - dsty - height;  
-      srcy = dPriv->h - srcy - height;  
-      dstx += dPriv->x;
-      dsty += dPriv->y;
-      srcx += dPriv->x;
-      srcy += dPriv->y;
-
-      /* Clip against the source region.  This is the only source
-       * clipping we do.  Dst is clipped with cliprects below.
-       */
-      {
-         delta_x = srcx - dstx;
-         delta_y = srcy - dsty;
-
-         if (!_mesa_clip_to_region(0, 0, src->pitch, src->height,
-                                   &srcx, &srcy, &width, &height))
-            goto out;
-
-         dstx = srcx - delta_x;
-         dsty = srcy - delta_y;
-      }
-
-      dest_rect.x1 = dstx;
-      dest_rect.y1 = dsty;
-      dest_rect.x2 = dstx + width;
-      dest_rect.y2 = dsty + height;
-
-/*       intel->vtbl.emit_flush(intel, 0); */
-
-      /* Could do slightly more clipping: Eg, take the intersection of
-       * the existing set of cliprects and those cliprects translated
-       * by delta_x, delta_y:
-       * 
-       * This code will not overwrite other windows, but will
-       * introduce garbage when copying from obscured window regions.
-       */
-      for (i = 0; i < nbox; i++) {
-         drm_clip_rect_t rect;
-
-         if (!intel_intersect_cliprects(&rect, &dest_rect, &box[i]))
-            continue;
-
-
-         intelEmitCopyBlit(intel, 
-                          dst->cpp, 
-                          src->pitch, src->buffer, 0, src->tiled,
-                          dst->pitch, dst->buffer, 0, dst->tiled,
-                          rect.x1 + delta_x, 
-                          rect.y1 + delta_y,       /* srcx, srcy */
-                           rect.x1, rect.y1,    /* dstx, dsty */
-                           rect.x2 - rect.x1, rect.y2 - rect.y1,
-                          ctx->Color.ColorLogicOpEnabled ?
-                          ctx->Color.LogicOp : GL_COPY);
-      }
-
-      intel->need_flush = GL_TRUE;
-   out:
-      intel_batchbuffer_flush(intel->batch);
-   }
-   UNLOCK_HARDWARE(intel);
-   return GL_TRUE;
-}
-
-void
-intelCopyPixels(GLcontext * ctx,
-                GLint srcx, GLint srcy,
-                GLsizei width, GLsizei height,
-                GLint destx, GLint desty, GLenum type)
-{
-   if (INTEL_DEBUG & DEBUG_PIXEL)
-      fprintf(stderr, "%s\n", __FUNCTION__);
-
-   if (do_blit_copypixels(ctx, srcx, srcy, width, height, destx, desty, type))
-      return;
-
-   if (do_texture_copypixels(ctx, srcx, srcy, width, height, destx, desty, type))
-      return;
-   
-   if (INTEL_DEBUG & DEBUG_PIXEL)
-      _mesa_printf("fallback to _swrast_CopyPixels\n");
-
-   _swrast_CopyPixels(ctx, srcx, srcy, width, height, destx, desty, type);
-}
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..ee433605904902ff085b72bc2fb82e107820fb02
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_pixel_copy.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i965/intel_reg.h b/src/mesa/drivers/dri/i965/intel_reg.h
deleted file mode 100644 (file)
index 3c448b3..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/**************************************************************************
- * 
- * 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)
-
-#define XY_SRC_TILED  (1<<15)
-#define XY_DST_TILED  (1<<11)
-
-#define FENCE_LINEAR 0
-#define FENCE_XMAJOR 1
-#define FENCE_YMAJOR 2
-
-#endif
deleted file mode 100644 (file)
index 835ecdd725768951858e1462309ed78bbc845953..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,295 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2006 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.
- * 
- **************************************************************************/
-
-/* Provide additional functionality on top of bufmgr buffers:
- *   - 2d semantics and blit operations
- *   - refcounting of buffers for multiple images in a buffer.
- *   - refcounting of buffer mappings.
- *   - some logic for moving the buffers to the best memory pools for
- *     given operations.
- *
- * Most of this is to make it easier to implement the fixed-layout
- * mipmap tree required by intel hardware in the face of GL's
- * programming interface where each image can be specifed in random
- * order and it isn't clear what layout the tree should have until the
- * last moment.
- */
-
-#include "intel_context.h"
-#include "intel_regions.h"
-#include "intel_blit.h"
-#include "bufmgr.h"
-#include "imports.h"
-
-/* XXX: Thread safety?
- */
-GLubyte *intel_region_map(struct intel_context *intel, struct intel_region *region)
-{
-   DBG("%s\n", __FUNCTION__);
-   if (!region->map_refcount++) {
-      region->map = bmMapBuffer(intel, region->buffer, 0);
-      if (!region->map)
-        region->map_refcount--;
-   }
-
-   return region->map;
-}
-
-void intel_region_unmap(struct intel_context *intel, 
-                       struct intel_region *region)
-{
-   DBG("%s\n", __FUNCTION__);
-   if (!--region->map_refcount) {
-      bmUnmapBufferAUB(intel, region->buffer, 0, 0);
-      region->map = NULL;
-   }
-}
-
-struct intel_region *intel_region_alloc( struct intel_context *intel, 
-                                        GLuint cpp,
-                                        GLuint pitch, 
-                                        GLuint height )
-{
-   struct intel_region *region = calloc(sizeof(*region), 1);
-
-   DBG("%s %dx%dx%d == 0x%x bytes\n", __FUNCTION__,
-       cpp, pitch, height, cpp*pitch*height);
-
-   region->cpp = cpp;
-   region->pitch = pitch;
-   region->height = height;    /* needed? */
-   region->refcount = 1;
-
-   bmGenBuffers(intel, "tex", 1, &region->buffer, 6);
-   bmBufferData(intel, region->buffer, pitch * cpp * height, NULL, 0);
-
-   return region;
-}
-
-void intel_region_reference( struct intel_region **dst,
-                            struct intel_region *src)
-{
-   src->refcount++;
-   assert(*dst == NULL);
-   *dst = src;
-}
-
-void intel_region_release( struct intel_context *intel,
-                          struct intel_region **region )
-{
-   if (!*region)
-      return;
-
-   DBG("%s %d\n", __FUNCTION__, (*region)->refcount-1);
-   
-   if (--(*region)->refcount == 0) {
-      assert((*region)->map_refcount == 0);
-      bmDeleteBuffers(intel, 1, &(*region)->buffer);
-      free(*region);
-   }
-   *region = NULL;
-}
-
-
-struct intel_region *intel_region_create_static( struct intel_context *intel, 
-                                                GLuint mem_type,
-                                                GLuint offset,
-                                                void *virtual,
-                                                GLuint cpp,
-                                                GLuint pitch, 
-                                                GLuint height,
-                                                GLuint size,
-                                                GLboolean tiled )
-{
-   struct intel_region *region = calloc(sizeof(*region), 1);
-   GLint pool;
-
-   DBG("%s\n", __FUNCTION__);
-
-   region->cpp = cpp;
-   region->pitch = pitch;
-   region->height = height;    /* needed? */
-   region->refcount = 1;
-   region->tiled = tiled;
-
-   /* Recipe for creating a static buffer - create a static pool with
-    * the right offset and size, generate a buffer and use a special
-    * call to bind it to all of the memory in that pool.
-    */
-   pool = bmInitPool(intel, offset, virtual, size, 
-                    (BM_MEM_AGP |
-                     BM_NO_UPLOAD | 
-                     BM_NO_EVICT | 
-                     BM_NO_MOVE));
-   if (pool < 0) {
-      _mesa_printf("bmInitPool failed for static region\n");
-      exit(1);
-   }
-
-   region->buffer = bmGenBufferStatic(intel, pool);
-
-   return region;
-}
-
-
-
-
-void _mesa_copy_rect( GLubyte *dst,
-                     GLuint cpp,
-                     GLuint dst_pitch,
-                     GLuint dst_x, 
-                     GLuint dst_y,
-                     GLuint width,
-                     GLuint height,
-                     const GLubyte *src,
-                     GLuint src_pitch,
-                     GLuint src_x,
-                     GLuint src_y )
-{
-   GLuint i;
-
-   dst_pitch *= cpp;
-   src_pitch *= cpp;
-   dst += dst_x * cpp;
-   src += src_x * cpp;
-   dst += dst_y * dst_pitch;
-   src += src_y * dst_pitch;
-   width *= cpp;
-
-   if (width == dst_pitch && 
-       width == src_pitch)
-      do_memcpy(dst, src, height * width);
-   else {
-      for (i = 0; i < height; i++) {
-        do_memcpy(dst, src, width);
-        dst += dst_pitch;
-        src += src_pitch;
-      }
-   }
-}
-
-
-/* Upload data to a rectangular sub-region.  Lots of choices how to do this:
- *
- * - memcpy by span to current destination
- * - upload data as new buffer and blit
- *
- * Currently always memcpy.
- */
-GLboolean intel_region_data(struct intel_context *intel, 
-                           struct intel_region *dst,
-                           GLuint dst_offset,
-                           GLuint dstx, GLuint dsty,
-                           const void *src, GLuint src_pitch,
-                           GLuint srcx, GLuint srcy,
-                           GLuint width, GLuint height)
-{
-   DBG("%s\n", __FUNCTION__);
-
-   if (width == dst->pitch && 
-       width == src_pitch &&
-       dst_offset == 0 &&
-       height == dst->height &&
-       srcx == 0 &&
-       srcy == 0) 
-   {
-      return (bmBufferDataAUB(intel,
-                             dst->buffer,
-                             dst->cpp * width * dst->height,
-                             src, 0, 0, 0) == 0);
-   }
-   else {
-      GLubyte *map = intel_region_map(intel, dst);
-
-      if (map) {
-        assert (dst_offset + dstx + width + 
-                (dsty + height - 1) * dst->pitch * dst->cpp <= 
-                dst->pitch * dst->cpp * dst->height);
-        
-        _mesa_copy_rect(map + dst_offset,
-                        dst->cpp,
-                        dst->pitch,
-                        dstx, dsty,
-                        width, height,
-                        src,
-                        src_pitch,
-                        srcx, srcy);      
-        
-        intel_region_unmap(intel, dst);
-        return GL_TRUE;
-      }
-      else 
-        return GL_FALSE;
-   }
-}
-                         
-/* Copy rectangular sub-regions. Need better logic about when to
- * push buffers into AGP - will currently do so whenever possible.
- */
-void intel_region_copy( struct intel_context *intel,
-                       struct intel_region *dst,
-                       GLuint dst_offset,
-                       GLuint dstx, GLuint dsty,
-                       struct intel_region *src,
-                       GLuint src_offset,
-                       GLuint srcx, GLuint srcy,
-                       GLuint width, GLuint height )
-{
-   DBG("%s\n", __FUNCTION__);
-
-   assert(src->cpp == dst->cpp);
-
-   intelEmitCopyBlit(intel,
-                    dst->cpp,
-                    src->pitch, src->buffer, src_offset, src->tiled,
-                    dst->pitch, dst->buffer, dst_offset, dst->tiled,
-                    srcx, srcy,
-                    dstx, dsty,
-                    width, height,
-                    GL_COPY );
-}
-
-/* Fill a rectangular sub-region.  Need better logic about when to
- * push buffers into AGP - will currently do so whenever possible.
- */
-void intel_region_fill( struct intel_context *intel,
-                       struct intel_region *dst,
-                       GLuint dst_offset,
-                       GLuint dstx, GLuint dsty,
-                       GLuint width, GLuint height,
-                       GLuint color )
-{
-   DBG("%s\n", __FUNCTION__);
-   
-   intelEmitFillBlit(intel,
-                    dst->cpp,
-                    dst->pitch, dst->buffer, dst_offset, dst->tiled,
-                    dstx, dsty,
-                    width, height,
-                    color );
-}
-
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..89b2f15c10f04dac958fd90355dc7f7cb84f58dd
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_regions.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i965/intel_regions.h b/src/mesa/drivers/dri/i965/intel_regions.h
deleted file mode 100644 (file)
index d2235f1..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2006 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_REGIONS_H
-#define INTEL_REGIONS_H
-
-#include "mtypes.h"
-#include "bufmgr.h"            /* for DBG! */
-struct intel_context;
-
-/* A layer on top of the bufmgr buffers that adds a few useful things:
- *
- * - Refcounting for local buffer references.
- * - Refcounting for buffer maps
- * - Buffer dimensions - pitch and height.
- * - Blitter commands for copying 2D regions between buffers.
- */
-struct intel_region {
-   struct buffer *buffer;
-   GLuint refcount;
-   GLuint cpp;
-   GLuint pitch;
-   GLuint height;
-   GLboolean tiled;
-   GLubyte *map;
-   GLuint map_refcount;
-};
-
-/* Allocate a refcounted region.  Pointers to regions should only be
- * copied by calling intel_reference_region().
- *
- * No support for dynamically allocating tiled regions at this point.
- */
-struct intel_region *intel_region_alloc( struct intel_context *intel,
-                                        GLuint cpp,
-                                        GLuint pitch, 
-                                        GLuint height );
-
-void intel_region_reference( struct intel_region **dst, 
-                            struct intel_region *src );
-
-void intel_region_release(struct intel_context *intel,
-                         struct intel_region **ib );
-
-/* Static regions may be tiled.  The assumption is that the X server
- * has set up fence registers to define tiled zones in agp and these
- * buffers are within those zones.  Tiling regions without fence
- * registers is more work.
- */
-struct intel_region *intel_region_create_static( struct intel_context *intel,
-                                                GLuint mem_type,
-                                                GLuint offset,
-                                                void *virtual,
-                                                GLuint cpp,
-                                                GLuint pitch,
-                                                GLuint height,
-                                                GLuint size,
-                                                GLboolean tiled );
-
-/* Map/unmap regions.  This is refcounted also: 
- */
-GLubyte *intel_region_map(struct intel_context *intel, 
-                      struct intel_region *ib);
-
-void intel_region_unmap(struct intel_context *intel,
-                       struct intel_region *ib);
-
-
-/* Upload data to a rectangular sub-region
- */
-GLboolean intel_region_data(struct intel_context *intel, 
-                           struct intel_region *dest,
-                           GLuint dest_offset,
-                           GLuint destx, GLuint desty,
-                           const void *src, GLuint src_stride,
-                           GLuint srcx, GLuint srcy,
-                           GLuint width, GLuint height);
-                         
-/* Copy rectangular sub-regions
- */
-void intel_region_copy( struct intel_context *intel,
-                       struct intel_region *dest,
-                       GLuint dest_offset,
-                       GLuint destx, GLuint desty,
-                       struct intel_region *src,
-                       GLuint src_offset,
-                       GLuint srcx, GLuint srcy,
-                       GLuint width, GLuint height );
-
-/* Fill a rectangular sub-region
- */
-void intel_region_fill( struct intel_context *intel,
-                       struct intel_region *dest,
-                       GLuint dest_offset,
-                       GLuint destx, GLuint desty,
-                       GLuint width, GLuint height,
-                       GLuint color );
-
-
-/***********************************************************************
- * Misc utilities: move to somewhere generic
- */
-void _mesa_copy_rect( GLubyte *dst,
-                     GLuint cpp,
-                     GLuint dst_pitch,
-                     GLuint dst_x, 
-                     GLuint dst_y,
-                     GLuint width,
-                     GLuint height,
-                     const GLubyte *src,
-                     GLuint src_pitch,
-                     GLuint src_x,
-                     GLuint src_y );
-
-
-#endif
diff --git a/src/mesa/drivers/dri/i965/intel_screen.h b/src/mesa/drivers/dri/i965/intel_screen.h
deleted file mode 100644 (file)
index bf9a716..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/**************************************************************************
- * 
- * 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"
-#include "i830_common.h"
-
-/* XXX: change name or eliminate to avoid conflict with "struct
- * intel_region"!!!
- */
-typedef struct {
-   drm_handle_t handle;
-   drmSize size;        /* region size in bytes */
-   char *map;           /* memory map */
-   int offset;          /* from start of video mem, in bytes */
-   int pitch;           /* row stride, in pixels */
-   unsigned int tiled; 
-} intelRegion;
-
-typedef struct 
-{
-   intelRegion front;
-   intelRegion back;
-   intelRegion rotated;
-   intelRegion depth;
-   intelRegion tex;
-   
-   int deviceID;
-   int width;
-   int height;
-   int mem;         /* unused */
-
-   int cpp;         /* for front and back buffers */
-   int fbFormat;
-
-   int logTextureGranularity;
-   
-   __DRIscreenPrivate *driScrnPriv;
-   unsigned int sarea_priv_offset;
-
-   int drmMinor;
-
-   int irq_active;
-   int allow_batchbuffer;
-
-/*    struct matrix23 rotMatrix; */
-
-   int current_rotation;  /* 0, 90, 180 or 270 */
-   int rotatedWidth, rotatedHeight;
-
-   /**
-    * Configuration cache with default values for all contexts 
-    */
-   driOptionCache optionCache;
-} intelScreenPrivate;
-
-
-extern GLboolean
-intelMapScreenRegions(__DRIscreenPrivate *sPriv);
-
-extern void
-intelUnmapScreenRegions(intelScreenPrivate *intelScreen);
-
-extern void
-intelUpdateScreenFromSAREA(intelScreenPrivate *intelScreen,
-                           volatile drmI830Sarea *sarea);
-
-extern void
-intelDestroyContext(__DRIcontextPrivate *driContextPriv);
-
-extern GLboolean
-intelUnbindContext(__DRIcontextPrivate *driContextPriv);
-
-extern GLboolean
-intelMakeCurrent(__DRIcontextPrivate *driContextPriv,
-                 __DRIdrawablePrivate *driDrawPriv,
-                 __DRIdrawablePrivate *driReadPriv);
-
-extern void
-intelSwapBuffers(__DRIdrawablePrivate *dPriv);
-
-extern void 
-intelCopySubBuffer( __DRIdrawablePrivate *dPriv,
-                   int x, int y, int w, int h );
-
-#endif
deleted file mode 100644 (file)
index 60fbeccdc546cc3f42d3429f66dfbb17ae290a0d..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,283 +0,0 @@
-/**************************************************************************
- * 
- * 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_regions.h"
-#include "intel_span.h"
-#include "intel_ioctl.h"
-#include "intel_tex.h"
-#include "intel_batchbuffer.h"
-#include "swrast/swrast.h"
-
-#undef DBG
-#define DBG 0
-
-#define LOCAL_VARS                                             \
-   struct intel_context *intel = intel_context(ctx);                    \
-   __DRIdrawablePrivate *dPriv = intel->driDrawable;           \
-   driRenderbuffer *drb = (driRenderbuffer *) rb;              \
-   GLuint pitch = drb->pitch;                                  \
-   GLuint height = dPriv->h;                                   \
-   char *buf = (char *) drb->Base.Data +                       \
-                       dPriv->x * drb->cpp +                   \
-                       dPriv->y * pitch;                       \
-   GLushort p;                                                 \
-   (void) buf; (void) p
-
-#define LOCAL_DEPTH_VARS                                       \
-   struct intel_context *intel = intel_context(ctx);                    \
-   __DRIdrawablePrivate *dPriv = intel->driDrawable;           \
-   driRenderbuffer *drb = (driRenderbuffer *) rb;              \
-   GLuint pitch = drb->pitch;                                  \
-   GLuint height = dPriv->h;                                   \
-   char *buf = (char *) drb->Base.Data +                       \
-                       dPriv->x * drb->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 *)(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 *)(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##_z16
-#include "depthtmp.h"
-
-
-#undef LOCAL_VARS
-#define LOCAL_VARS                                             \
-   struct intel_context *intel = intel_context(ctx);                   \
-   __DRIdrawablePrivate *dPriv = intel->driDrawable;           \
-   driRenderbuffer *drb = (driRenderbuffer *) rb;              \
-   GLuint pitch = drb->pitch;                                  \
-   GLuint height = dPriv->h;                                   \
-   char *buf = (char *)drb->Base.Data +                                \
-                       dPriv->x * drb->cpp +                   \
-                       dPriv->y * pitch;                       \
-   GLuint p;                                                   \
-   (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 *)(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##_z24_s8
-#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##_z24_s8
-#include "stenciltmp.h"
-
-
-/* Move locking out to get reasonable span performance.
- */
-void intelSpanRenderStart( GLcontext *ctx )
-{
-   struct intel_context *intel = intel_context(ctx);
-
-   if (intel->need_flush) {
-      LOCK_HARDWARE(intel);
-      intel->vtbl.emit_flush(intel, 0);
-      intel_batchbuffer_flush(intel->batch);
-      intel->need_flush = 0;
-      UNLOCK_HARDWARE(intel);
-      intelFinish(&intel->ctx);
-   }
-
-
-   LOCK_HARDWARE(intel);
-
-   /* Just map the framebuffer and all textures.  Bufmgr code will
-    * take care of waiting on the necessary fences:
-    */
-   intel_region_map(intel, intel->front_region);
-   intel_region_map(intel, intel->back_region);
-   intel_region_map(intel, intel->depth_region);
-}
-
-void intelSpanRenderFinish( GLcontext *ctx )
-{
-   struct intel_context *intel = intel_context( ctx );
-
-   _swrast_flush( ctx );
-
-   /* Now unmap the framebuffer:
-    */
-   intel_region_unmap(intel, intel->front_region);
-   intel_region_unmap(intel, intel->back_region);
-   intel_region_unmap(intel, intel->depth_region);
-
-   UNLOCK_HARDWARE( intel );
-}
-
-void intelInitSpanFuncs( GLcontext *ctx )
-{
-   struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
-   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) {
-         intelInitPointers_555(&drb->Base);
-      }
-      else if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
-         intelInitPointers_565(&drb->Base);
-      }
-      else {
-         assert(vis->redBits == 8);
-         assert(vis->greenBits == 8);
-         assert(vis->blueBits == 8);
-         intelInitPointers_8888(&drb->Base);
-      }
-   }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
-      intelInitDepthPointers_z16(&drb->Base);
-   }
-   else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
-      intelInitDepthPointers_z24_s8(&drb->Base);
-   }
-   else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
-      intelInitStencilPointers_z24_s8(&drb->Base);
-   }
-}
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..05e5e8e58338a4d3c83c4b7b79fc7d573d333082
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_span.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i965/intel_span.h b/src/mesa/drivers/dri/i965/intel_span.h
deleted file mode 100644 (file)
index 2d4f858..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/**************************************************************************
- * 
- * 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
index 2e442db6198bc0138a29193621b2592dc6498cb1..0fba5a771c0f86fe84cb5ed7d93ffc312f3c8a1a 100644 (file)
 #include "intel_regions.h"
 #include "swrast/swrast.h"
 
+int intel_translate_shadow_compare_func( GLenum func )
+{
+   switch(func) {
+   case GL_NEVER: 
+       return COMPAREFUNC_ALWAYS; 
+   case GL_LESS: 
+       return COMPAREFUNC_LEQUAL; 
+   case GL_LEQUAL: 
+       return COMPAREFUNC_LESS;
+   case GL_GREATER: 
+       return COMPAREFUNC_GEQUAL; 
+   case GL_GEQUAL: 
+      return COMPAREFUNC_GREATER; 
+   case GL_NOTEQUAL: 
+      return COMPAREFUNC_EQUAL; 
+   case GL_EQUAL: 
+      return COMPAREFUNC_NOTEQUAL; 
+   case GL_ALWAYS: 
+       return COMPAREFUNC_NEVER; 
+   }
+
+   fprintf(stderr, "Unknown value in %s: %x\n", __FUNCTION__, func);
+   return COMPAREFUNC_NEVER; 
+}
+
 int intel_translate_compare_func( GLenum func )
 {
    switch(func) {
@@ -170,15 +195,16 @@ int intel_translate_logic_op( GLenum opcode )
 static void intelClearColor(GLcontext *ctx, const GLfloat color[4])
 {
    struct intel_context *intel = intel_context(ctx);
-   intelScreenPrivate *screen = intel->intelScreen;
 
    UNCLAMPED_FLOAT_TO_RGBA_CHAN(intel->clear_chan, color);
 
-   intel->ClearColor = INTEL_PACKCOLOR(screen->fbFormat,
-                                      intel->clear_chan[0], 
-                                      intel->clear_chan[1], 
-                                      intel->clear_chan[2], 
-                                      intel->clear_chan[3]);
+   intel->ClearColor8888 = INTEL_PACKCOLOR8888(intel->clear_chan[0],
+                                              intel->clear_chan[1],
+                                              intel->clear_chan[2],
+                                              intel->clear_chan[3]);
+   intel->ClearColor565 = INTEL_PACKCOLOR565(intel->clear_chan[0],
+                                            intel->clear_chan[1],
+                                            intel->clear_chan[2]);
 }
 
 
deleted file mode 100644 (file)
index 4523969bfa5e4fd378ae063c00fffd3aace88afa..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,315 +0,0 @@
-/**************************************************************************
- * 
- * 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 "mtypes.h"
-#include "image.h"
-#include "texstore.h"
-#include "texformat.h"
-#include "teximage.h"
-#include "texobj.h"
-#include "swrast/swrast.h"
-
-
-#include "intel_context.h"
-#include "intel_tex.h"
-#include "intel_mipmap_tree.h"
-
-
-static GLuint target_to_face( GLenum target )
-{
-   switch (target) {
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
-   case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
-   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
-      return ((GLuint) target - 
-             (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X);
-   default:
-      return 0;
-   }
-}
-
-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 )
-{
-   struct intel_texture_object *intelObj = intel_texture_object(texObj);
-
-   _mesa_store_teximage1d( ctx, target, level, internalFormat,
-                          width, border, format, type,
-                          pixels, packing, texObj, texImage );
-
-   intelObj->dirty_images[0] |= (1 << level);
-   intelObj->dirty |= 1;
-}
-
-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 )
-{
-   struct intel_texture_object *intelObj = intel_texture_object(texObj);
-
-   _mesa_store_texsubimage1d(ctx, target, level, xoffset, width, 
-                            format, type, pixels, packing, texObj,
-                            texImage);
-
-   intelObj->dirty_images[0] |= (1 << level);
-   intelObj->dirty |= 1;
-}
-
-
-/* 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 )
-{
-   struct intel_texture_object *intelObj = intel_texture_object(texObj);
-   GLuint face = target_to_face(target);
-
-   _mesa_store_teximage2d( ctx, target, level, internalFormat,
-                          width, height, border, format, type,
-                          pixels, packing, texObj, texImage );
-
-   intelObj->dirty_images[face] |= (1 << level);
-   intelObj->dirty |= 1 << face;
-}
-
-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 )
-{
-   struct intel_texture_object *intelObj = intel_texture_object(texObj);
-   GLuint face = target_to_face(target);
-
-   _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width, 
-                            height, format, type, pixels, packing, texObj,
-                            texImage);
-
-   intelObj->dirty_images[face] |= (1 << level);
-   intelObj->dirty |= 1 << face;
-}
-
-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 )
-{
-   struct intel_texture_object *intelObj = intel_texture_object(texObj);
-   GLuint face = target_to_face(target);
-
-   _mesa_store_compressed_teximage2d(ctx, target, level, internalFormat, width,
-                                    height, border, imageSize, data, texObj, texImage);
-   
-   intelObj->dirty_images[face] |= (1 << level);
-   intelObj->dirty |= 1 << face;
-}
-
-
-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 )
-{
-   struct intel_texture_object *intelObj = intel_texture_object(texObj);
-   GLuint face = target_to_face(target);
-
-   _mesa_store_compressed_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
-                                       height, format, imageSize, data, texObj, texImage);
-   
-   intelObj->dirty_images[face] |= (1 << level);
-   intelObj->dirty |= 1 << face;
-}
-
-
-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 )
-{
-   struct intel_texture_object *intelObj = intel_texture_object(texObj);
-
-   _mesa_store_teximage3d(ctx, target, level, internalFormat,
-                         width, height, depth, border,
-                         format, type, pixels,
-                         &ctx->Unpack, texObj, texImage);
-   
-   intelObj->dirty_images[0] |= (1 << level);
-   intelObj->dirty |= 1 << 0;
-}
-
-
-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 )
-{
-   struct intel_texture_object *intelObj = intel_texture_object(texObj);
-
-   _mesa_store_texsubimage3d(ctx, target, level, xoffset, yoffset, zoffset,
-                             width, height, depth,
-                             format, type, pixels, packing, texObj, texImage);
-
-   intelObj->dirty_images[0] |= (1 << level);
-   intelObj->dirty |= 1 << 0;
-}
-
-
-
-
-static struct gl_texture_object *intelNewTextureObject( GLcontext *ctx, 
-                                                       GLuint name, 
-                                                       GLenum target )
-{
-   struct intel_texture_object *obj = CALLOC_STRUCT(intel_texture_object);
-
-   _mesa_initialize_texture_object(&obj->base, name, target);
-
-   return &obj->base;
-}
-
-static GLboolean intelIsTextureResident(GLcontext *ctx,
-                                      struct gl_texture_object *texObj)
-{
-#if 0
-   struct intel_context *intel = intel_context(ctx);
-   struct intel_texture_object *intelObj = intel_texture_object(texObj);
-   
-   return 
-      intelObj->mt && 
-      intelObj->mt->region && 
-      intel_is_region_resident(intel, intelObj->mt->region);
-#endif
-   return 1;
-}
-
-
-
-static void intelTexParameter( GLcontext *ctx, 
-                              GLenum target,
-                              struct gl_texture_object *texObj,
-                              GLenum pname, 
-                              const GLfloat *params )
-{
-   struct intel_texture_object *intelObj = intel_texture_object(texObj);
-   switch (pname) {
-      /* Anything which can affect the calculation of firstLevel and
-       * lastLevel, as changes to these may invalidate the miptree.
-       */
-   case GL_TEXTURE_MIN_FILTER:
-   case GL_TEXTURE_MAG_FILTER:
-   case GL_TEXTURE_BASE_LEVEL:
-   case GL_TEXTURE_MAX_LEVEL:
-   case GL_TEXTURE_MIN_LOD:
-   case GL_TEXTURE_MAX_LOD:
-      intelObj->dirty |= 1;
-      break;
-
-   default:
-      break;
-   }
-}
-
-
-static void
-intel_delete_texture_object( GLcontext *ctx, struct gl_texture_object *texObj )
-{
-   struct intel_context *intel = intel_context(ctx);
-   struct intel_texture_object *intelObj = intel_texture_object(texObj);
-
-   if (intelObj->mt)
-      intel_miptree_destroy(intel, intelObj->mt);
-
-   _mesa_delete_texture_object( ctx, texObj );
-}
-
-void intelInitTextureFuncs( struct dd_function_table *functions )
-{
-   functions->NewTextureObject          = intelNewTextureObject;
-   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             = intel_delete_texture_object;
-   functions->UpdateTexturePalette      = NULL;
-   functions->IsTextureResident = intelIsTextureResident;
-   functions->TestProxyTexImage         = _mesa_test_proxy_teximage;
-   functions->CompressedTexImage2D      = intelCompressedTexImage2D;
-   functions->CompressedTexSubImage2D   = intelCompressedTexSubImage2D;
-   functions->TexParameter              = intelTexParameter;
-}
-
-
-
-
-
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..d77ce749a3e0a9b2a6eacae06e9b1177af3775fb
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_tex.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i965/intel_tex.h b/src/mesa/drivers/dri/i965/intel_tex.h
deleted file mode 100644 (file)
index e389d52..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/**************************************************************************
- * 
- * 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"
-
-
-void intelInitTextureFuncs( struct dd_function_table *functions );
-
-
-GLuint intel_finalize_mipmap_tree( struct intel_context *intel,
-                                  struct gl_texture_object *tObj );
-
-
-#endif
diff --git a/src/mesa/drivers/dri/i965/intel_tex_copy.c b/src/mesa/drivers/dri/i965/intel_tex_copy.c
new file mode 120000 (symlink)
index 0000000..87196c5
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_tex_copy.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i965/intel_tex_format.c b/src/mesa/drivers/dri/i965/intel_tex_format.c
new file mode 120000 (symlink)
index 0000000..3415f75
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_tex_format.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c b/src/mesa/drivers/dri/i965/intel_tex_image.c
new file mode 120000 (symlink)
index 0000000..567abe4
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_tex_image.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i965/intel_tex_subimage.c b/src/mesa/drivers/dri/i965/intel_tex_subimage.c
new file mode 120000 (symlink)
index 0000000..b3a8a3d
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_tex_subimage.c
\ No newline at end of file
deleted file mode 100644 (file)
index 44ee94614d58822c5aa8d2c1f05b83b272c5eaa6..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1,256 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2006 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 "mtypes.h"
-#include "macros.h"
-
-#include "intel_context.h"
-#include "intel_mipmap_tree.h"
-#include "intel_tex.h"
-#include "bufmgr.h"
-
-/**
- * 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.
- */
-static void intel_calculate_first_last_level( struct intel_texture_object *intelObj )
-{
-   struct gl_texture_object *tObj = &intelObj->base;
-   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 {
-        /* Currently not taking min/max lod into account here, those
-         * values are programmed as sampler state elsewhere and we
-         * upload the same mipmap levels regardless.  Not sure if
-         * this makes sense as it means it isn't possible for the app
-         * to use min/max lod to reduce texture memory pressure:
-         */
-        firstLevel = tObj->BaseLevel;
-        lastLevel = MIN2(tObj->BaseLevel + baseImage->MaxLog2, 
-                         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 */
-   intelObj->firstLevel = firstLevel;
-   intelObj->lastLevel = lastLevel;
-}
-
-static GLboolean copy_image_data_to_tree( struct intel_context *intel,
-                                         struct intel_texture_object *intelObj,
-                                         struct gl_texture_image *texImage,
-                                         GLuint face,
-                                         GLuint level)
-{
-   return intel_miptree_image_data(intel,
-                                  intelObj->mt,
-                                  face,
-                                  level,
-                                  texImage->Data,
-                                  texImage->RowStride,
-                                  (texImage->RowStride * 
-                                   texImage->Height * 
-                                   texImage->TexFormat->TexelBytes));
-}
-
-static void intel_texture_invalidate( struct intel_texture_object *intelObj )
-{
-   GLint nr_faces, face;
-   intelObj->dirty = ~0;
-
-   nr_faces = (intelObj->base.Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
-   for (face = 0; face < nr_faces; face++) 
-      intelObj->dirty_images[face] = ~0;
-}
-
-static void intel_texture_invalidate_cb( struct intel_context *intel,
-                                        void *ptr )
-{
-   intel_texture_invalidate( (struct intel_texture_object *) ptr );
-}
-
-
-/*  
- */
-GLuint intel_finalize_mipmap_tree( struct intel_context *intel,
-                                  struct gl_texture_object *tObj )
-{
-   struct intel_texture_object *intelObj = intel_texture_object(tObj);
-   GLuint face, i;
-   GLuint nr_faces = 0;
-   struct gl_texture_image *firstImage;
-
-   if( tObj == intel->frame_buffer_texobj )
-      return GL_FALSE;
-   
-   /* We know/require this is true by now: 
-    */
-   assert(intelObj->base._Complete);
-
-   /* What levels must the tree include at a minimum?
-    */
-   if (intelObj->dirty) {
-      intel_calculate_first_last_level( intelObj );
-/*       intel_miptree_destroy(intel, intelObj->mt); */
-/*       intelObj->mt = NULL; */
-   }
-
-   firstImage = intelObj->base.Image[0][intelObj->firstLevel];
-
-   /* Fallback case:
-    */
-   if (firstImage->Border) {
-      if (intelObj->mt) {
-        intel_miptree_destroy(intel, intelObj->mt);
-        intelObj->mt = NULL;
-        /* Set all images dirty:
-         */
-        intel_texture_invalidate(intelObj);
-      }
-      return GL_FALSE;
-   }
-
-
-
-   /* Check tree can hold all active levels.  Check tree matches
-    * target, imageFormat, etc.
-    */
-   if (intelObj->mt &&
-       (intelObj->mt->target != intelObj->base.Target ||
-       intelObj->mt->internal_format != firstImage->InternalFormat ||
-       intelObj->mt->first_level != intelObj->firstLevel ||
-       intelObj->mt->last_level != intelObj->lastLevel ||
-       intelObj->mt->width0 != firstImage->Width ||
-       intelObj->mt->height0 != firstImage->Height ||
-       intelObj->mt->depth0 != firstImage->Depth ||
-       intelObj->mt->cpp != firstImage->TexFormat->TexelBytes ||
-       intelObj->mt->compressed != firstImage->IsCompressed)) 
-   {
-      intel_miptree_destroy(intel, intelObj->mt);
-      intelObj->mt = NULL;
-      
-      /* Set all images dirty:
-       */
-      intel_texture_invalidate(intelObj);
-   }
-      
-
-   /* May need to create a new tree:
-    */
-   if (!intelObj->mt) {
-      intelObj->mt = intel_miptree_create(intel,
-                                         intelObj->base.Target,
-                                         firstImage->InternalFormat,
-                                         intelObj->firstLevel,
-                                         intelObj->lastLevel,
-                                         firstImage->Width,
-                                         firstImage->Height,
-                                         firstImage->Depth,
-                                         firstImage->TexFormat->TexelBytes,
-                                         firstImage->IsCompressed);
-
-      /* Tell the buffer manager that we will manage the backing
-       * store, but we still want it to do fencing for us.
-       */
-      bmBufferSetInvalidateCB(intel, 
-                             intelObj->mt->region->buffer,
-                             intel_texture_invalidate_cb,
-                             intelObj,
-                             GL_FALSE);
-   }
-
-   /* Pull in any images not in the object's tree:
-    */
-   if (intelObj->dirty) {
-      nr_faces = (intelObj->base.Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
-      for (face = 0; face < nr_faces; face++) {
-        if (intelObj->dirty_images[face]) {
-           for (i = intelObj->firstLevel; i <= intelObj->lastLevel; i++) {
-              struct gl_texture_image *texImage = intelObj->base.Image[face][i];
-
-              /* Need to import images in main memory or held in other trees.
-               */
-              if (intelObj->dirty_images[face] & (1<<i) &&
-                  texImage) {
-
-                 if (INTEL_DEBUG & DEBUG_TEXTURE)
-                    _mesa_printf("copy data from image %d (%p) into object miptree\n",
-                                 i,
-                                 texImage->Data);
-
-                 if (!copy_image_data_to_tree(intel,
-                                              intelObj,
-                                              texImage,
-                                              face,
-                                              i))
-                    return GL_FALSE;
-
-              }
-           }
-        }
-      }
-
-      /* Only clear the dirty flags if everything went ok:
-       */
-      for (face = 0; face < nr_faces; face++) {
-        intelObj->dirty_images[face] = 0;
-      }
-
-      intelObj->dirty = 0;
-   }
-
-   return GL_TRUE;
-}
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..41a75674c275b6c88ccd379c7a5a656a856ce46f
--- /dev/null
@@ -0,0 +1 @@
+../intel/intel_tex_validate.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/i965/server/intel.h b/src/mesa/drivers/dri/i965/server/intel.h
deleted file mode 100644 (file)
index d7858a2..0000000
+++ /dev/null
@@ -1,328 +0,0 @@
-#ifndef _INTEL_H_
-#define _INTEL_H_
-
-#include "xf86drm.h"           /* drm_handle_t, etc */
-
-/* Intel */
-#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
-#define PCI_CHIP_I810_BRIDGE       0x7120
-#define PCI_CHIP_I810_DC100_BRIDGE 0x7122
-#define PCI_CHIP_I810_E_BRIDGE     0x7124
-#define PCI_CHIP_I815_BRIDGE       0x1130
-#endif
-
-#define PCI_CHIP_845_G                 0x2562
-#define PCI_CHIP_I830_M                        0x3577
-
-#ifndef PCI_CHIP_I855_GM
-#define PCI_CHIP_I855_GM          0x3582
-#define PCI_CHIP_I855_GM_BRIDGE           0x3580
-#endif
-
-#ifndef PCI_CHIP_I865_G
-#define PCI_CHIP_I865_G                   0x2572
-#define PCI_CHIP_I865_G_BRIDGE    0x2570
-#endif
-
-#ifndef PCI_CHIP_I915_G
-#define PCI_CHIP_I915_G                   0x2582
-#define PCI_CHIP_I915_G_BRIDGE    0x2580
-#endif
-
-#ifndef PCI_CHIP_I915_GM
-#define PCI_CHIP_I915_GM          0x2592
-#define PCI_CHIP_I915_GM_BRIDGE           0x2590
-#endif
-
-#ifndef PCI_CHIP_E7221_G
-#define PCI_CHIP_E7221_G          0x258A
-/* Same as I915_G_BRIDGE */
-#define PCI_CHIP_E7221_G_BRIDGE           0x2580
-#endif
-
-#ifndef PCI_CHIP_I945_G
-#define PCI_CHIP_I945_G        0x2772
-#define PCI_CHIP_I945_G_BRIDGE 0x2770
-#endif
-
-#ifndef PCI_CHIP_I945_GM
-#define PCI_CHIP_I945_GM        0x27A2
-#define PCI_CHIP_I945_GM_BRIDGE 0x27A0
-#endif
-
-#define IS_I810(pI810) (pI810->Chipset == PCI_CHIP_I810 ||     \
-                       pI810->Chipset == PCI_CHIP_I810_DC100 || \
-                       pI810->Chipset == PCI_CHIP_I810_E)
-#define IS_I815(pI810) (pI810->Chipset == PCI_CHIP_I815)
-#define IS_I830(pI810) (pI810->Chipset == PCI_CHIP_I830_M)
-#define IS_845G(pI810) (pI810->Chipset == PCI_CHIP_845_G)
-#define IS_I85X(pI810)  (pI810->Chipset == PCI_CHIP_I855_GM)
-#define IS_I852(pI810)  (pI810->Chipset == PCI_CHIP_I855_GM && (pI810->variant == I852_GM || pI810->variant == I852_GME))
-#define IS_I855(pI810)  (pI810->Chipset == PCI_CHIP_I855_GM && (pI810->variant == I855_GM || pI810->variant == I855_GME))
-#define IS_I865G(pI810) (pI810->Chipset == PCI_CHIP_I865_G)
-
-#define IS_I915G(pI810) (pI810->Chipset == PCI_CHIP_I915_G || pI810->Chipset == PCI_CHIP_E7221_G)
-#define IS_I915GM(pI810) (pI810->Chipset == PCI_CHIP_I915_GM)
-#define IS_I945G(pI810) (pI810->Chipset == PCI_CHIP_I945_G)
-#define IS_I945GM(pI810) (pI810->Chipset == PCI_CHIP_I945_GM)
-#define IS_I9XX(pI810) (IS_I915G(pI810) || IS_I915GM(pI810) || IS_I945G(pI810) || IS_I945GM(pI810))
-
-#define IS_MOBILE(pI810) (IS_I830(pI810) || IS_I85X(pI810) || IS_I915GM(pI810) || IS_I945GM(pI810))
-
-#define I830_GMCH_CTRL         0x52
-
-
-#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 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 I915G_GMCH_GMS_STOLEN_48M              (0x6 << 4)
-#define I915G_GMCH_GMS_STOLEN_64M              (0x7 << 4)
-
-typedef unsigned char Bool;
-#define TRUE 1
-#define FALSE 0
-
-#define PIPE_NONE      0<<0
-#define PIPE_CRT       1<<0
-#define PIPE_TV                1<<1
-#define PIPE_DFP       1<<2
-#define PIPE_LFP       1<<3
-#define PIPE_CRT2      1<<4
-#define PIPE_TV2       1<<5
-#define PIPE_DFP2      1<<6
-#define PIPE_LFP2      1<<7
-
-typedef struct _I830MemPool *I830MemPoolPtr;
-typedef struct _I830MemRange *I830MemRangePtr;
-typedef struct _I830MemRange {
-   long Start;
-   long End;
-   long Size;
-   unsigned long Physical;
-   unsigned long Offset;               /* Offset of AGP-allocated portion */
-   unsigned long Alignment;
-   drm_handle_t Key;
-   unsigned long Pitch; // add pitch
-   I830MemPoolPtr Pool;
-} I830MemRange;
-
-typedef struct _I830MemPool {
-   I830MemRange Total;
-   I830MemRange Free;
-   I830MemRange Fixed;
-   I830MemRange Allocated;
-} I830MemPool;
-
-typedef struct {
-   int tail_mask;
-   I830MemRange mem;
-   unsigned char *virtual_start;
-   int head;
-   int tail;
-   int space;
-} I830RingBuffer;
-
-typedef struct _I830Rec {
-   unsigned char *MMIOBase;
-   unsigned char *FbBase;
-   int cpp;
-
-   unsigned int bios_version;
-
-   /* These are set in PreInit and never changed. */
-   long FbMapSize;
-   long TotalVideoRam;
-   I830MemRange StolenMemory;          /* pre-allocated memory */
-   long BIOSMemorySize;                        /* min stolen pool size */
-   int BIOSMemSizeLoc;
-
-   /* These change according to what has been allocated. */
-   long FreeMemory;
-   I830MemRange MemoryAperture;
-   I830MemPool StolenPool;
-   long allocatedMemory;
-
-   /* Regions allocated either from the above pools, or from agpgart. */
-   /* for single and dual head configurations */
-   I830MemRange FrontBuffer;
-   I830MemRange FrontBuffer2;
-   I830MemRange Scratch;
-   I830MemRange Scratch2;
-
-   I830RingBuffer *LpRing;
-
-   I830MemRange BackBuffer;
-   I830MemRange DepthBuffer;
-   I830MemRange TexMem;
-   int TexGranularity;
-   I830MemRange ContextMem;
-   int drmMinor;
-   Bool have3DWindows;
-
-   Bool NeedRingBufferLow;
-   Bool allowPageFlip;
-   Bool disableTiling;
-
-   int Chipset;
-   unsigned long LinearAddr;
-   unsigned long MMIOAddr;
-
-   drmSize           registerSize;     /**< \brief MMIO register map size */
-   drm_handle_t         registerHandle;   /**< \brief MMIO register map handle */
-  //   IOADDRESS ioBase;
-   int               irq;              /**< \brief IRQ number */
-   int GttBound;
-
-   drm_handle_t ring_map;
-   unsigned int Fence[8];
-
-} I830Rec;
-
-/*
- * 12288 is set as the maximum, chosen because it is enough for
- * 1920x1440@32bpp with a 2048 pixel line pitch with some to spare.
- */
-#define I830_MAXIMUM_VBIOS_MEM         12288
-#define I830_DEFAULT_VIDEOMEM_2D       (MB(32) / 1024)
-#define I830_DEFAULT_VIDEOMEM_3D       (MB(64) / 1024)
-
-/* Flags for memory allocation function */
-#define FROM_ANYWHERE                  0x00000000
-#define FROM_POOL_ONLY                 0x00000001
-#define FROM_NEW_ONLY                  0x00000002
-#define FROM_MASK                      0x0000000f
-
-#define ALLOCATE_AT_TOP                        0x00000010
-#define ALLOCATE_AT_BOTTOM             0x00000020
-#define FORCE_GAPS                     0x00000040
-
-#define NEED_PHYSICAL_ADDR             0x00000100
-#define ALIGN_BOTH_ENDS                        0x00000200
-#define FORCE_LOW                      0x00000400
-
-#define ALLOC_NO_TILING                        0x00001000
-#define ALLOC_INITIAL                  0x00002000
-
-#define ALLOCATE_DRY_RUN               0x80000000
-
-/* Chipset registers for VIDEO BIOS memory RW access */
-#define _855_DRAM_RW_CONTROL 0x58
-#define _845_DRAM_RW_CONTROL 0x90
-#define DRAM_WRITE    0x33330000
-
-#define KB(x) ((x) * 1024)
-#define MB(x) ((x) * KB(1024))
-
-#define GTT_PAGE_SIZE                  KB(4)
-#define ROUND_TO(x, y)                 (((x) + (y) - 1) / (y) * (y))
-#define ROUND_DOWN_TO(x, y)            ((x) / (y) * (y))
-#define ROUND_TO_PAGE(x)               ROUND_TO((x), GTT_PAGE_SIZE)
-#define ROUND_TO_MB(x)                 ROUND_TO((x), MB(1))
-#define PRIMARY_RINGBUFFER_SIZE                KB(128)
-
-
-/* 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          0x03FFFFF8
-#define I830_RING_START_MASK   0xFFFFF000
-
-#define RING_LEN       0x0C
-#define RING_NR_PAGES       0x001FF000 
-#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
-
-
-/* Fence/Tiling ranges [0..7]
- */
-#define FENCE            0x2000
-#define FENCE_NR         8
-
-#define I915G_FENCE_START_MASK 0x0ff00000
-
-#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 I915G_FENCE_SIZE_1M       0x00000000
-#define I915G_FENCE_SIZE_2M       0x00000100
-#define I915G_FENCE_SIZE_4M       0x00000200
-#define I915G_FENCE_SIZE_8M       0x00000300
-#define I915G_FENCE_SIZE_16M      0x00000400
-#define I915G_FENCE_SIZE_32M      0x00000500
-#define I915G_FENCE_SIZE_64M   0x00000600
-#define I915G_FENCE_SIZE_128M  0x00000700
-#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
-
-#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(MMIO, addr)
-#define INREG(addr)         MMIO_IN32(MMIO, addr)
-#define OUTREG8(addr, val)  MMIO_OUT8(MMIO, addr, val)
-#define OUTREG(addr, val)   MMIO_OUT32(MMIO, addr, val)
-
-#define DSPABASE               0x70184
-
-#endif
deleted file mode 100644 (file)
index 169fdbece3047234f06b85196668c4a3c01a564a..0000000000000000000000000000000000000000
+++ /dev/null
-/**
- * \file server/intel_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) 2006 Dave Airlie (airlied@linux.ie)
-
- Permission is hereby granted, free of charge, to any person obtaining a
- copy of this software and 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 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-
-#include "driver.h"
-#include "drm.h"
-
-#include "intel.h"
-#include "i830_dri.h"
-
-#include "memops.h"
-#include "pciaccess.h"
-
-static size_t drm_page_size;
-static int nextTile = 0;
-#define xf86DrvMsg(...) do {} while(0)
-
-static const int pitches[] = {
-  128 * 8,
-  128 * 16,
-  128 * 32,
-  128 * 64,
-  0
-};
-
-static Bool I830DRIDoMappings(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea);
-
-static unsigned long
-GetBestTileAlignment(unsigned long size)
-{
-   unsigned long i;
-
-   for (i = KB(512); i < size; i <<= 1)
-      ;
-
-   if (i > MB(64))
-      i = MB(64);
-
-   return i;
-}
-
-static void SetFenceRegs(const DRIDriverContext *ctx, I830Rec *pI830)
-{
-  int i;
-  unsigned char *MMIO = ctx->MMIOAddress;
-
-  for (i = 0; i < 8; i++) {
-    OUTREG(FENCE + i * 4, pI830->Fence[i]);
-    //    if (I810_DEBUG & DEBUG_VERBOSE_VGA)
-    fprintf(stderr,"Fence Register : %x\n", pI830->Fence[i]);
-  }
-}
-
-/* Tiled memory is good... really, really good...
- *
- * Need to make it less likely that we miss out on this - probably
- * need to move the frontbuffer away from the 'guarenteed' alignment
- * of the first memory segment, or perhaps allocate a discontigous
- * framebuffer to get more alignment 'sweet spots'.
- */
-static void
-SetFence(const DRIDriverContext *ctx, I830Rec *pI830,
-        int nr, unsigned int start, unsigned int pitch,
-         unsigned int size)
-{
-   unsigned int val;
-   unsigned int fence_mask = 0;
-   unsigned int fence_pitch;
-
-   if (nr < 0 || nr > 7) {
-      fprintf(stderr,
-                "SetFence: fence %d out of range\n",nr);
-      return;
-   }
-
-   pI830->Fence[nr] = 0;
-
-   if (IS_I9XX(pI830))
-       fence_mask = ~I915G_FENCE_START_MASK;
-   else
-       fence_mask = ~I830_FENCE_START_MASK;
-
-   if (start & fence_mask) {
-      fprintf(stderr,
-                "SetFence: %d: start (0x%08x) is not %s aligned\n",
-                nr, start, (IS_I9XX(pI830)) ? "1MB" : "512k");
-      return;
-   }
-
-   if (start % size) {
-      fprintf(stderr,
-                "SetFence: %d: start (0x%08x) is not size (%dk) aligned\n",
-                nr, start, size / 1024);
-      return;
-   }
-
-   if (pitch & 127) {
-      fprintf(stderr,
-                "SetFence: %d: pitch (%d) not a multiple of 128 bytes\n",
-                nr, pitch);
-      return;
-   }
-
-   val = (start | FENCE_X_MAJOR | FENCE_VALID);
-
-   if (IS_I9XX(pI830)) {
-       switch (size) {
-          case MB(1):
-               val |= I915G_FENCE_SIZE_1M;
-               break;
-          case MB(2):
-               val |= I915G_FENCE_SIZE_2M;
-               break;
-          case MB(4):
-               val |= I915G_FENCE_SIZE_4M;
-               break;
-          case MB(8):
-               val |= I915G_FENCE_SIZE_8M;
-               break;
-          case MB(16):
-               val |= I915G_FENCE_SIZE_16M;
-               break;
-          case MB(32):
-               val |= I915G_FENCE_SIZE_32M;
-               break;
-          case MB(64):
-               val |= I915G_FENCE_SIZE_64M;
-               break;
-          default:
-               fprintf(stderr,
-                "SetFence: %d: illegal size (%d kByte)\n", nr, size / 1024);
-               return;
-       }
-    } else {
-       switch (size) {
-          case KB(512):
-               val |= FENCE_SIZE_512K;
-               break;
-          case MB(1):
-               val |= FENCE_SIZE_1M;
-               break;
-          case MB(2):
-               val |= FENCE_SIZE_2M;
-               break;
-          case MB(4):
-               val |= FENCE_SIZE_4M;
-               break;
-          case MB(8):
-               val |= FENCE_SIZE_8M;
-               break;
-          case MB(16):
-               val |= FENCE_SIZE_16M;
-               break;
-          case MB(32):
-               val |= FENCE_SIZE_32M;
-               break;
-          case MB(64):
-               val |= FENCE_SIZE_64M;
-               break;
-          default:
-               fprintf(stderr,
-                "SetFence: %d: illegal size (%d kByte)\n", nr, size / 1024);
-               return;
-       }
-   }
-
-   if (IS_I9XX(pI830))
-       fence_pitch = pitch / 512;
-   else
-       fence_pitch = pitch / 128;
-
-   switch (fence_pitch) {
-   case 1:
-      val |= FENCE_PITCH_1;
-      break;
-   case 2:
-      val |= FENCE_PITCH_2;
-      break;
-   case 4:
-      val |= FENCE_PITCH_4;
-      break;
-   case 8:
-      val |= FENCE_PITCH_8;
-      break;
-   case 16:
-      val |= FENCE_PITCH_16;
-      break;
-   case 32:
-      val |= FENCE_PITCH_32;
-      break;
-   case 64:
-      val |= FENCE_PITCH_64;
-      break;
-   default:
-      fprintf(stderr,
-                "SetFence: %d: illegal pitch (%d)\n", nr, pitch);
-      return;
-   }
-
-   pI830->Fence[nr] = val;
-}
-
-static Bool
-MakeTiles(const DRIDriverContext *ctx, I830Rec *pI830, I830MemRange *pMem)
-{
-   int pitch, ntiles, i;
-
-   pitch = pMem->Pitch * ctx->cpp;
-   /*
-    * Simply try to break the region up into at most four pieces of size
-    * equal to the alignment.
-    */
-   ntiles = ROUND_TO(pMem->Size, pMem->Alignment) / pMem->Alignment;
-   if (ntiles >= 4) {
-      return FALSE;
-   }
-
-   for (i = 0; i < ntiles; i++, nextTile++) {
-     SetFence(ctx, pI830, nextTile, pMem->Start + i * pMem->Alignment,
-              pitch, pMem->Alignment);
-   }
-   return TRUE;
-}
-
-static void I830SetupMemoryTiling(const DRIDriverContext *ctx, I830Rec *pI830)
-{
-  int i;
-
-  /* Clear out */
-  for (i = 0; i < 8; i++)
-    pI830->Fence[i] = 0;
-  
-  nextTile = 0;
-
-  if (pI830->BackBuffer.Alignment >= KB(512)) {
-    if (MakeTiles(ctx, pI830, &(pI830->BackBuffer))) {
-      fprintf(stderr,
-                "Activating tiled memory for the back buffer.\n");
-    } else {
-      fprintf(stderr,
-                "MakeTiles failed for the back buffer.\n");
-      pI830->allowPageFlip = FALSE;
-    }
-  }
-  
-  if (pI830->DepthBuffer.Alignment >= KB(512)) {
-    if (MakeTiles(ctx, pI830, &(pI830->DepthBuffer))) {
-      fprintf(stderr,
-                "Activating tiled memory for the depth buffer.\n");
-    } else {
-      fprintf(stderr,
-                "MakeTiles failed for the depth buffer.\n");
-    }
-  }
-
-  return;
-}
-
-static int I830DetectMemory(const DRIDriverContext *ctx, I830Rec *pI830)
-{
-  struct pci_device host_bridge;
-  uint32_t gmch_ctrl;
-  int memsize = 0;
-  int range;
-
-  memset(&host_bridge, 0, sizeof(host_bridge));
-
-  pci_device_cfg_read_u32(&host_bridge, &gmch_ctrl, I830_GMCH_CTRL);
-  
-  /* We need to reduce the stolen size, by the GTT and the popup.
-   * The GTT varying according the the FbMapSize and the popup is 4KB */
-  range = (ctx->shared.fbSize / (1024*1024)) + 4;
-
-   if (IS_I85X(pI830) || IS_I865G(pI830) || IS_I9XX(pI830)) {
-      switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
-      case I855_GMCH_GMS_STOLEN_1M:
-        memsize = MB(1) - KB(range);
-        break;
-      case I855_GMCH_GMS_STOLEN_4M:
-        memsize = MB(4) - KB(range);
-        break;
-      case I855_GMCH_GMS_STOLEN_8M:
-        memsize = MB(8) - KB(range);
-        break;
-      case I855_GMCH_GMS_STOLEN_16M:
-        memsize = MB(16) - KB(range);
-        break;
-      case I855_GMCH_GMS_STOLEN_32M:
-        memsize = MB(32) - KB(range);
-        break;
-      case I915G_GMCH_GMS_STOLEN_48M:
-        if (IS_I9XX(pI830))
-           memsize = MB(48) - KB(range);
-        break;
-      case I915G_GMCH_GMS_STOLEN_64M:
-        if (IS_I9XX(pI830))
-           memsize = MB(64) - KB(range);
-        break;
-      }
-   } else {
-      switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
-      case I830_GMCH_GMS_STOLEN_512:
-        memsize = KB(512) - KB(range);
-        break;
-      case I830_GMCH_GMS_STOLEN_1024:
-        memsize = MB(1) - KB(range);
-        break;
-      case I830_GMCH_GMS_STOLEN_8192:
-        memsize = MB(8) - KB(range);
-        break;
-      case I830_GMCH_GMS_LOCAL:
-        memsize = 0;
-        xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-                   "Local memory found, but won't be used.\n");
-        break;
-      }
-   }
-   if (memsize > 0) {
-     fprintf(stderr,
-                "detected %d kB stolen memory.\n", memsize / 1024);
-   } else {
-     fprintf(stderr,
-                "no video memory detected.\n");
-   }
-   return memsize;
-}
-
-static int AgpInit(const DRIDriverContext *ctx, I830Rec *info)
-{
-  unsigned long mode = 0x4;
-
-  if (drmAgpAcquire(ctx->drmFD) < 0) {
-    fprintf(stderr, "[gart] AGP not available\n");
-    return 0;
-  }
-  
-  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);
-
-  return 1;
-}
-
-/*
- * Allocate memory from the given pool.  Grow the pool if needed and if
- * possible.
- */
-static unsigned long
-AllocFromPool(const DRIDriverContext *ctx, I830Rec *pI830, 
-             I830MemRange *result, I830MemPool *pool,
-             long size, unsigned long alignment, int flags)
-{
-   long needed, start, end;
-
-   if (!result || !pool || !size)
-      return 0;
-
-   /* Calculate how much space is needed. */
-   if (alignment <= GTT_PAGE_SIZE)
-      needed = size;
-   else {
-        start = ROUND_TO(pool->Free.Start, alignment);
-        end = ROUND_TO(start + size, alignment);
-        needed = end - pool->Free.Start;
-   }
-   if (needed > pool->Free.Size) {
-     return 0;
-   }
-
-   result->Start = ROUND_TO(pool->Free.Start, alignment);
-   pool->Free.Start += needed;
-   result->End = pool->Free.Start;
-
-   pool->Free.Size = pool->Free.End - pool->Free.Start;
-   result->Size = result->End - result->Start;
-   result->Pool = pool;
-   result->Alignment = alignment;
-   return needed;
-}
-
-static unsigned long AllocFromAGP(const DRIDriverContext *ctx, I830Rec *pI830, long size, unsigned long alignment, I830MemRange  *result)
-{
-   unsigned long start, end;
-   unsigned long newApStart, newApEnd;
-   int ret;
-   if (!result || !size)
-      return 0;
-   
-   if (!alignment)
-     alignment = 4;
-
-   start = ROUND_TO(pI830->MemoryAperture.Start, alignment);
-   end = ROUND_TO(start + size, alignment);
-   newApStart = end;
-   newApEnd = pI830->MemoryAperture.End;
-
-   ret=drmAgpAlloc(ctx->drmFD, size, 0, &(result->Physical), (drm_handle_t *)&(result->Key));
-   
-   if (ret)
-   {
-     fprintf(stderr,"drmAgpAlloc failed %d\n", ret);
-     return 0;
-   }
-   pI830->allocatedMemory += size;
-   pI830->MemoryAperture.Start = newApStart;
-   pI830->MemoryAperture.End = newApEnd;
-   pI830->MemoryAperture.Size = newApEnd - newApStart;
-   //   pI830->FreeMemory -= size;
-   result->Start = start;
-   result->End = start + size;
-   result->Size = size;
-   result->Offset = start;
-   result->Alignment = alignment;
-   result->Pool = NULL;
-  
-   return size;
-}
-
-unsigned long
-I830AllocVidMem(const DRIDriverContext *ctx, I830Rec *pI830, I830MemRange *result, I830MemPool *pool, long size, unsigned long alignment, int flags)
-{
-  int ret;
-
-  if (!result)
-    return 0;
-
-   /* Make sure these are initialised. */
-   result->Size = 0;
-   result->Key = -1;
-
-   if (!size) {
-      return 0;
-   }
-
-   if (pool->Free.Size < size)
-     return AllocFromAGP(ctx, pI830, size, alignment, result);
-   else
-   {
-     ret = AllocFromPool(ctx, pI830, result, pool, size, alignment, flags);
-
-     if (ret==0)
-       return AllocFromAGP(ctx, pI830, size, alignment, result);
-     return ret;
-   }
-}
-
-static Bool BindAgpRange(const DRIDriverContext *ctx, I830MemRange *mem)
-{
-  if (!mem)
-    return FALSE;
-  
-  if (mem->Key == -1)
-    return TRUE;
-
-  return !drmAgpBind(ctx->drmFD, mem->Key, mem->Offset);
-}
-
-/* simple memory allocation routines needed */
-/* put ring buffer in low memory */
-/* need to allocate front, back, depth buffers aligned correctly,
-   allocate ring buffer, 
-*/
-
-/* */
-static Bool
-I830AllocateMemory(const DRIDriverContext *ctx, I830Rec *pI830)
-{
-  unsigned long size, ret;
-  unsigned long lines, lineSize, align;
-
-  /* allocate ring buffer */
-  memset(pI830->LpRing, 0, sizeof(I830RingBuffer));
-  pI830->LpRing->mem.Key = -1;
-
-  size = PRIMARY_RINGBUFFER_SIZE;
-  
-  ret = I830AllocVidMem(ctx, pI830, &pI830->LpRing->mem, &pI830->StolenPool, size, 0x1000, 0);
-  
-  if (ret != size)
-  {
-    fprintf(stderr,"unable to allocate ring buffer %ld\n", ret);
-    return FALSE;
-  }
-
-  pI830->LpRing->tail_mask = pI830->LpRing->mem.Size - 1;
-
-  
-  /* allocate front buffer */
-  memset(&(pI830->FrontBuffer), 0, sizeof(pI830->FrontBuffer));
-  pI830->FrontBuffer.Key = -1;
-  pI830->FrontBuffer.Pitch = ctx->shared.virtualWidth;
-
-  align = KB(512);  
-
-  lineSize = ctx->shared.virtualWidth * ctx->cpp;
-  lines = (ctx->shared.virtualHeight + 15) / 16 * 16;
-  size = lineSize * lines;
-  size = ROUND_TO_PAGE(size);
-
-  align = GetBestTileAlignment(size);
-
-  ret = I830AllocVidMem(ctx, pI830, &pI830->FrontBuffer, &pI830->StolenPool, size, align, 0);
-  if (ret < size)
-  {
-    fprintf(stderr,"unable to allocate front buffer %ld\n", ret);
-    return FALSE;
-  }
-
-  memset(&(pI830->BackBuffer), 0, sizeof(pI830->BackBuffer));
-  pI830->BackBuffer.Key = -1;
-  pI830->BackBuffer.Pitch = ctx->shared.virtualWidth;
-
-  ret = I830AllocVidMem(ctx, pI830, &pI830->BackBuffer, &pI830->StolenPool, size, align, 0);
-  if (ret < size)
-  {
-    fprintf(stderr,"unable to allocate back buffer %ld\n", ret);
-    return FALSE;
-  }
-  
-  memset(&(pI830->DepthBuffer), 0, sizeof(pI830->DepthBuffer));
-  pI830->DepthBuffer.Key = -1;
-  pI830->DepthBuffer.Pitch = ctx->shared.virtualWidth;
-
-  ret = I830AllocVidMem(ctx, pI830, &pI830->DepthBuffer, &pI830->StolenPool, size, align, 0);
-  if (ret < size)
-  {
-    fprintf(stderr,"unable to allocate depth buffer %ld\n", ret);
-    return FALSE;
-  }
-
-  memset(&(pI830->ContextMem), 0, sizeof(pI830->ContextMem));
-  pI830->ContextMem.Key = -1;
-  size = KB(32);
-
-  ret = I830AllocVidMem(ctx, pI830, &pI830->ContextMem, &pI830->StolenPool, size, align, 0);
-  if (ret < size)
-  {
-    fprintf(stderr,"unable to allocate context buffer %ld\n", ret);
-    return FALSE;
-  }
-  
-  memset(&(pI830->TexMem), 0, sizeof(pI830->TexMem));
-  pI830->TexMem.Key = -1;
-
-  size = 32768 * 1024;
-  ret = AllocFromAGP(ctx, pI830, size, align, &pI830->TexMem);
-  if (ret < size)
-  {
-    fprintf(stderr,"unable to allocate texture memory %ld\n", ret);
-    return FALSE;
-  }
-
-  return TRUE;
-}
-
-static Bool
-I830BindMemory(const DRIDriverContext *ctx, I830Rec *pI830)
-{
-  if (!BindAgpRange(ctx, &pI830->LpRing->mem))
-    return FALSE;
-  if (!BindAgpRange(ctx, &pI830->FrontBuffer))
-    return FALSE;
-  if (!BindAgpRange(ctx, &pI830->BackBuffer))
-    return FALSE;
-  if (!BindAgpRange(ctx, &pI830->DepthBuffer))
-    return FALSE;
-  if (!BindAgpRange(ctx, &pI830->ContextMem))
-    return FALSE;
-  if (!BindAgpRange(ctx, &pI830->TexMem))
-    return FALSE;
-
-  return TRUE;
-}
-
-static Bool
-I830CleanupDma(const DRIDriverContext *ctx)
-{
-   drmI830Init info;
-
-   memset(&info, 0, sizeof(drmI830Init));
-   info.func = I830_CLEANUP_DMA;
-
-   if (drmCommandWrite(ctx->drmFD, DRM_I830_INIT,
-                      &info, sizeof(drmI830Init))) {
-     fprintf(stderr, "I830 Dma Cleanup Failed\n");
-      return FALSE;
-   }
-
-   return TRUE;
-}
-
-static Bool
-I830InitDma(const DRIDriverContext *ctx, I830Rec *pI830)
-{
-   I830RingBuffer *ring = pI830->LpRing;
-   drmI830Init info;
-
-   memset(&info, 0, sizeof(drmI830Init));
-   info.func = I830_INIT_DMA;
-
-   info.ring_start = ring->mem.Start + pI830->LinearAddr;
-   info.ring_end = ring->mem.End + pI830->LinearAddr;
-   info.ring_size = ring->mem.Size;
-
-   info.mmio_offset = (unsigned int)ctx->MMIOStart;
-
-   info.sarea_priv_offset = sizeof(drm_sarea_t);
-
-   info.front_offset = pI830->FrontBuffer.Start;
-   info.back_offset = pI830->BackBuffer.Start;
-   info.depth_offset = pI830->DepthBuffer.Start;
-   info.w = ctx->shared.virtualWidth;
-   info.h = ctx->shared.virtualHeight;
-   info.pitch = ctx->shared.virtualWidth;
-   info.back_pitch = pI830->BackBuffer.Pitch;
-   info.depth_pitch = pI830->DepthBuffer.Pitch;
-   info.cpp = ctx->cpp;
-
-   if (drmCommandWrite(ctx->drmFD, DRM_I830_INIT,
-                      &info, sizeof(drmI830Init))) {
-      fprintf(stderr,
-                "I830 Dma Initialization Failed\n");
-      return FALSE;
-   }
-
-   return TRUE;
-}
-
-static int I830CheckDRMVersion( const DRIDriverContext *ctx,
-                                 I830Rec *pI830 )
-{
-   drmVersionPtr  version;
-
-   version = drmGetVersion(ctx->drmFD);
-
-   if (version) {
-     int req_minor, req_patch;
-
-     req_minor = 4;
-     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] I830DRIScreenInit failed because of a version "
-              "mismatch.\n"
-              "[dri] i915.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;
-     }
-     
-     pI830->drmMinor = version->version_minor;
-     drmFreeVersion(version);
-   }
-   return 1;
-}
-
-static void
-I830SetRingRegs(const DRIDriverContext *ctx, I830Rec *pI830)
-{
-  unsigned int itemp;
-  unsigned char *MMIO = ctx->MMIOAddress;
-
-   OUTREG(LP_RING + RING_LEN, 0);
-   OUTREG(LP_RING + RING_TAIL, 0);
-   OUTREG(LP_RING + RING_HEAD, 0);
-
-   if ((long)(pI830->LpRing->mem.Start & I830_RING_START_MASK) !=
-       pI830->LpRing->mem.Start) {
-      fprintf(stderr,
-                "I830SetRingRegs: Ring buffer start (%lx) violates its "
-                "mask (%x)\n", pI830->LpRing->mem.Start, I830_RING_START_MASK);
-   }
-   /* Don't care about the old value.  Reserved bits must be zero anyway. */
-   itemp = pI830->LpRing->mem.Start & I830_RING_START_MASK;
-   OUTREG(LP_RING + RING_START, itemp);
-
-   if (((pI830->LpRing->mem.Size - 4096) & I830_RING_NR_PAGES) !=
-       pI830->LpRing->mem.Size - 4096) {
-      fprintf(stderr,
-                "I830SetRingRegs: Ring buffer size - 4096 (%lx) violates its "
-                "mask (%x)\n", pI830->LpRing->mem.Size - 4096,
-                I830_RING_NR_PAGES);
-   }
-   /* Don't care about the old value.  Reserved bits must be zero anyway. */
-   itemp = (pI830->LpRing->mem.Size - 4096) & I830_RING_NR_PAGES;
-   itemp |= (RING_NO_REPORT | RING_VALID);
-   OUTREG(LP_RING + RING_LEN, itemp);
-
-   pI830->LpRing->head = INREG(LP_RING + RING_HEAD) & I830_HEAD_MASK;
-   pI830->LpRing->tail = INREG(LP_RING + RING_TAIL);
-   pI830->LpRing->space = pI830->LpRing->head - (pI830->LpRing->tail + 8);
-   if (pI830->LpRing->space < 0)
-      pI830->LpRing->space += pI830->LpRing->mem.Size;
-
-   SetFenceRegs(ctx, pI830);
-   
-   /* RESET THE DISPLAY PIPE TO POINT TO THE FRONTBUFFER - hacky
-      hacky hacky */
-   OUTREG(DSPABASE, pI830->FrontBuffer.Start + pI830->LinearAddr);
-
-}
-
-static Bool
-I830SetParam(const DRIDriverContext *ctx, int param, int value)
-{
-   drmI830SetParam sp;
-
-   memset(&sp, 0, sizeof(sp));
-   sp.param = param;
-   sp.value = value;
-
-   if (drmCommandWrite(ctx->drmFD, DRM_I830_SETPARAM, &sp, sizeof(sp))) {
-      fprintf(stderr, "I830 SetParam Failed\n");
-      return FALSE;
-   }
-
-   return TRUE;
-}
-
-static Bool
-I830DRIMapScreenRegions(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea)
-{
-   fprintf(stderr,
-              "[drm] Mapping front buffer\n");
-
-   if (drmAddMap(ctx->drmFD,
-                 (drm_handle_t)(sarea->front_offset + pI830->LinearAddr),
-                 sarea->front_size,
-                 DRM_FRAME_BUFFER,  /*DRM_AGP,*/
-                 0,
-                 &sarea->front_handle) < 0) {
-     fprintf(stderr,
-            "[drm] drmAddMap(front_handle) failed. Disabling DRI\n");
-      return FALSE;
-   }
-   ctx->shared.hFrameBuffer = sarea->front_handle;
-   ctx->shared.fbSize = sarea->front_size;
-   fprintf(stderr, "[drm] Front Buffer = 0x%08x\n",
-          sarea->front_handle);
-
-   if (drmAddMap(ctx->drmFD,
-                 (drm_handle_t)(sarea->back_offset),
-                 sarea->back_size, DRM_AGP, 0,
-                 &sarea->back_handle) < 0) {
-      fprintf(stderr,
-                 "[drm] drmAddMap(back_handle) failed. Disabling DRI\n");
-      return FALSE;
-   }
-   fprintf(stderr, "[drm] Back Buffer = 0x%08x\n",
-              sarea->back_handle);
-
-   if (drmAddMap(ctx->drmFD,
-                 (drm_handle_t)sarea->depth_offset,
-                 sarea->depth_size, DRM_AGP, 0,
-                 &sarea->depth_handle) < 0) {
-      fprintf(stderr,
-                 "[drm] drmAddMap(depth_handle) failed. Disabling DRI\n");
-      return FALSE;
-   }
-   fprintf(stderr, "[drm] Depth Buffer = 0x%08x\n",
-              sarea->depth_handle);
-
-   if (drmAddMap(ctx->drmFD,
-                (drm_handle_t)sarea->tex_offset,
-                sarea->tex_size, DRM_AGP, 0,
-                &sarea->tex_handle) < 0) {
-      fprintf(stderr,
-                "[drm] drmAddMap(tex_handle) failed. Disabling DRI\n");
-      return FALSE;
-   }
-   fprintf(stderr, "[drm] textures = 0x%08x\n",
-             sarea->tex_handle);
-
-   return TRUE;
-}
-
-
-static void
-I830DRIUnmapScreenRegions(const DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea)
-{
-#if 1
-   if (sarea->front_handle) {
-      drmRmMap(ctx->drmFD, sarea->front_handle);
-      sarea->front_handle = 0;
-   }
-#endif
-   if (sarea->back_handle) {
-      drmRmMap(ctx->drmFD, sarea->back_handle);
-      sarea->back_handle = 0;
-   }
-   if (sarea->depth_handle) {
-      drmRmMap(ctx->drmFD, sarea->depth_handle);
-      sarea->depth_handle = 0;
-   }
-   if (sarea->tex_handle) {
-      drmRmMap(ctx->drmFD, sarea->tex_handle);
-      sarea->tex_handle = 0;
-   }
-}
-
-static void
-I830InitTextureHeap(const DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea)
-{
-   /* Start up the simple memory manager for agp space */
-   drmI830MemInitHeap drmHeap;
-   drmHeap.region = I830_MEM_REGION_AGP;
-   drmHeap.start  = 0;
-   drmHeap.size   = sarea->tex_size;
-      
-   if (drmCommandWrite(ctx->drmFD, DRM_I830_INIT_HEAP,
-                         &drmHeap, sizeof(drmHeap))) {
-      fprintf(stderr,
-                   "[drm] Failed to initialized agp heap manager\n");
-   } else {
-      fprintf(stderr,
-                   "[drm] Initialized kernel agp heap manager, %d\n",
-                   sarea->tex_size);
-
-      I830SetParam(ctx, I830_SETPARAM_TEX_LRU_LOG_GRANULARITY, 
-                     sarea->log_tex_granularity);
-   }
-}
-
-static Bool
-I830DRIDoMappings(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea)
-{
-  if (drmAddMap(ctx->drmFD,
-               (drm_handle_t)pI830->LpRing->mem.Start,
-               pI830->LpRing->mem.Size, DRM_AGP, 0,
-               &pI830->ring_map) < 0) {
-    fprintf(stderr,
-           "[drm] drmAddMap(ring_map) failed. Disabling DRI\n");
-    return FALSE;
-  }
-  fprintf(stderr, "[drm] ring buffer = 0x%08x\n",
-         pI830->ring_map);
-
-  if (I830InitDma(ctx, pI830) == FALSE) {
-    return FALSE;
-  }
-  
-   /* init to zero to be safe */
-
-  I830DRIMapScreenRegions(ctx, pI830, sarea);
-  I830InitTextureHeap(ctx, pI830, sarea);
-
-   if (ctx->pciDevice != PCI_CHIP_845_G &&
-       ctx->pciDevice != PCI_CHIP_I830_M) {
-      I830SetParam(ctx, I830_SETPARAM_USE_MI_BATCHBUFFER_START, 1 );
-   }
-
-   /* Okay now initialize the dma engine */
-   {
-      pI830->irq = drmGetInterruptFromBusID(ctx->drmFD,
-                                           ctx->pciBus,
-                                           ctx->pciDevice,
-                                           ctx->pciFunc);
-
-      if (drmCtlInstHandler(ctx->drmFD, pI830->irq)) {
-        fprintf(stderr,
-                   "[drm] failure adding irq handler\n");
-        pI830->irq = 0;
-        return FALSE;
-      }
-      else
-        fprintf(stderr,
-                   "[drm] dma control initialized, using IRQ %d\n",
-                   pI830->irq);
-   }
-
-   fprintf(stderr, "[dri] visual configs initialized\n");
-
-   return TRUE;
-}
-
-static Bool
-I830ClearScreen(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea)
-{
-  /* need to drmMap front and back buffers and zero them */
-  drmAddress map_addr;
-  int ret;
-
-  ret = drmMap(ctx->drmFD,
-              sarea->front_handle,
-              sarea->front_size,
-              &map_addr);
-
-  if (ret)
-  {
-    fprintf(stderr, "Unable to map front buffer\n");
-    return FALSE;
-  }
-
-  drimemsetio((char *)map_addr,
-             0,
-             sarea->front_size);
-  drmUnmap(map_addr, sarea->front_size);
-
-
-  ret = drmMap(ctx->drmFD,
-              sarea->back_handle,
-              sarea->back_size,
-              &map_addr);
-
-  if (ret)
-  {
-    fprintf(stderr, "Unable to map back buffer\n");
-    return FALSE;
-  }
-
-  drimemsetio((char *)map_addr,
-             0,
-             sarea->back_size);
-  drmUnmap(map_addr, sarea->back_size);
-
-  return TRUE;
-}
-
-static Bool
-I830ScreenInit(DRIDriverContext *ctx, I830Rec *pI830)
-                 
-{
-   I830DRIPtr pI830DRI;
-   drmI830Sarea *pSAREAPriv;
-   int err;
-      
-   drm_page_size = getpagesize();   
-
-   pI830->registerSize = ctx->MMIOSize;
-   /* This is a hack for now.  We have to have more than a 4k page here
-    * because of the size of the state.  However, the state should be
-    * in a per-context mapping.  This will be added in the Mesa 3.5 port
-    * of the I830 driver.
-    */
-   ctx->shared.SAREASize = SAREA_MAX;
-
-   /* Note that drmOpen will try to load the kernel module, if needed. */
-   ctx->drmFD = drmOpen("i915", 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%08x\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%08x 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, 
-                &pI830->registerHandle) < 0) {
-      fprintf(stderr, "[drm] drmAddMap mmio failed\n");        
-      return 0;
-   }
-   fprintf(stderr,
-          "[drm] register handle = 0x%08x\n", pI830->registerHandle);
-
-
-   if (!I830CheckDRMVersion(ctx, pI830)) {
-     return 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 SAREA private data structure */
-   pSAREAPriv = (drmI830Sarea *)(((char*)ctx->pSAREA) + 
-                                sizeof(drm_sarea_t));
-   memset(pSAREAPriv, 0, sizeof(*pSAREAPriv));
-
-   pI830->StolenMemory.Size = I830DetectMemory(ctx, pI830);
-   pI830->StolenMemory.Start = 0;
-   pI830->StolenMemory.End = pI830->StolenMemory.Size;
-
-   pI830->MemoryAperture.Start = pI830->StolenMemory.End;
-   pI830->MemoryAperture.End = KB(40000);
-   pI830->MemoryAperture.Size = pI830->MemoryAperture.End - pI830->MemoryAperture.Start;
-
-   pI830->StolenPool.Fixed = pI830->StolenMemory;
-   pI830->StolenPool.Total = pI830->StolenMemory;
-   pI830->StolenPool.Free = pI830->StolenPool.Total;
-   pI830->FreeMemory = pI830->StolenPool.Total.Size;
-
-   if (!AgpInit(ctx, pI830))
-     return FALSE;
-
-   if (I830AllocateMemory(ctx, pI830) == FALSE)
-   {
-     return FALSE;
-   }
-
-   if (I830BindMemory(ctx, pI830) == FALSE)
-   {
-     return FALSE;
-   }
-
-   pSAREAPriv->front_offset = pI830->FrontBuffer.Start;
-   pSAREAPriv->front_size = pI830->FrontBuffer.Size;
-   pSAREAPriv->width = ctx->shared.virtualWidth;
-   pSAREAPriv->height = ctx->shared.virtualHeight;
-   pSAREAPriv->pitch = ctx->shared.virtualWidth;
-   pSAREAPriv->virtualX = ctx->shared.virtualWidth;
-   pSAREAPriv->virtualY = ctx->shared.virtualHeight;
-   pSAREAPriv->back_offset = pI830->BackBuffer.Start;
-   pSAREAPriv->back_size = pI830->BackBuffer.Size;
-   pSAREAPriv->depth_offset = pI830->DepthBuffer.Start;
-   pSAREAPriv->depth_size = pI830->DepthBuffer.Size;
-   pSAREAPriv->tex_offset = pI830->TexMem.Start;
-   pSAREAPriv->tex_size = pI830->TexMem.Size;
-   pSAREAPriv->log_tex_granularity = pI830->TexGranularity;
-
-   ctx->driverClientMsg = malloc(sizeof(I830DRIRec));
-   ctx->driverClientMsgSize = sizeof(I830DRIRec);
-   pI830DRI = (I830DRIPtr)ctx->driverClientMsg;
-   pI830DRI->deviceID = pI830->Chipset;
-   pI830DRI->regsSize = I830_REG_SIZE;
-   pI830DRI->width = ctx->shared.virtualWidth;
-   pI830DRI->height = ctx->shared.virtualHeight;
-   pI830DRI->mem = ctx->shared.fbSize;
-   pI830DRI->cpp = ctx->cpp;
-   pI830DRI->backOffset = pI830->BackBuffer.Start;
-   pI830DRI->backPitch = pI830->BackBuffer.Pitch; 
-
-   pI830DRI->depthOffset = pI830->DepthBuffer.Start;
-   pI830DRI->depthPitch = pI830->DepthBuffer.Pitch; 
-
-   pI830DRI->fbOffset = pI830->FrontBuffer.Start;
-   pI830DRI->fbStride = pI830->FrontBuffer.Pitch;
-
-   pI830DRI->bitsPerPixel = ctx->bpp;
-   pI830DRI->sarea_priv_offset = sizeof(drm_sarea_t);
-   
-   err = I830DRIDoMappings(ctx, pI830, pSAREAPriv);
-   if (err == FALSE)
-       return FALSE;
-
-   I830SetupMemoryTiling(ctx, pI830);
-
-   /* 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.
-    */
-   I830ClearScreen(ctx, pI830, pSAREAPriv);
-
-   I830SetRingRegs(ctx, pI830);
-
-   return TRUE;
-}
-
-
-/**
- * \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 i830ValidateMode( 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 i810ValidateMode().
- */
-static int i830PostValidateMode( const DRIDriverContext *ctx )
-{
-  I830Rec *pI830 = ctx->driverPrivate;
-
-  I830SetRingRegs(ctx, pI830);
-  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 i830InitFBDev( DRIDriverContext *ctx )
-{
-  I830Rec *pI830 = calloc(1, sizeof(I830Rec));
-  int i;
-
-   {
-      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->shared.Width = ctx->shared.virtualWidth;
-   }
-
-
-   for (i = 0; pitches[i] != 0; i++) {
-     if (pitches[i] >= ctx->shared.virtualWidth) {
-       ctx->shared.virtualWidth = pitches[i];
-       break;
-     }
-   }
-
-   ctx->driverPrivate = (void *)pI830;
-   
-   pI830->LpRing = calloc(1, sizeof(I830RingBuffer));
-   pI830->Chipset = ctx->chipset;
-   pI830->LinearAddr = ctx->FBStart;
-
-   if (!I830ScreenInit( ctx, pI830 ))
-      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 i830HaltFBDev( DRIDriverContext *ctx )
-{
-  drmI830Sarea *pSAREAPriv;
-  I830Rec *pI830 = ctx->driverPrivate;
-
-   if (pI830->irq) {
-       drmCtlUninstHandler(ctx->drmFD);
-       pI830->irq = 0;   }
-
-   I830CleanupDma(ctx);
-
-  pSAREAPriv = (drmI830Sarea *)(((char*)ctx->pSAREA) + 
-                               sizeof(drm_sarea_t));
-
-  I830DRIUnmapScreenRegions(ctx, pI830, pSAREAPriv);
-  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 = {
-   i830ValidateMode,
-   i830PostValidateMode,
-   i830InitFBDev,
-   i830HaltFBDev,
-   NULL,//I830EngineShutdown,
-   NULL, //I830EngineRestore,  
-#ifndef _EMBEDDED
-   0,
-#else
-   i810NotifyFocus, 
-#endif
-};
new file mode 120000 (symlink)
index 0000000000000000000000000000000000000000..effdd26448adc737a4c46b1b500f9a11f1830972
--- /dev/null
@@ -0,0 +1 @@
+../../intel/server/intel_dri.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
new file mode 100644 (file)
index 0000000..7dbc646
--- /dev/null
@@ -0,0 +1,297 @@
+/**************************************************************************
+ * 
+ * Copyright 2006 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 "intel_context.h"
+#include "intel_batchbuffer.h"
+#include "intel_decode.h"
+#include "intel_reg.h"
+#include "intel_bufmgr.h"
+
+/* Relocations in kernel space:
+ *    - pass dma buffer seperately
+ *    - memory manager knows how to patch
+ *    - pass list of dependent buffers
+ *    - pass relocation list
+ *
+ * Either:
+ *    - get back an offset for buffer to fire
+ *    - memory manager knows how to fire buffer
+ *
+ * Really want the buffer to be AGP and pinned.
+ *
+ */
+
+/* Cliprect fence: The highest fence protecting a dma buffer
+ * containing explicit cliprect information.  Like the old drawable
+ * lock but irq-driven.  X server must wait for this fence to expire
+ * before changing cliprects [and then doing sw rendering?].  For
+ * other dma buffers, the scheduler will grab current cliprect info
+ * and mix into buffer.  X server must hold the lock while changing
+ * cliprects???  Make per-drawable.  Need cliprects in shared memory
+ * -- beats storing them with every cmd buffer in the queue.
+ *
+ * ==> X server must wait for this fence to expire before touching the
+ * framebuffer with new cliprects.
+ *
+ * ==> Cliprect-dependent buffers associated with a
+ * cliprect-timestamp.  All of the buffers associated with a timestamp
+ * must go to hardware before any buffer with a newer timestamp.
+ *
+ * ==> Dma should be queued per-drawable for correct X/GL
+ * synchronization.  Or can fences be used for this?
+ *
+ * Applies to: Blit operations, metaops, X server operations -- X
+ * server automatically waits on its own dma to complete before
+ * modifying cliprects ???
+ */
+
+void
+intel_batchbuffer_reset(struct intel_batchbuffer *batch)
+{
+   struct intel_context *intel = batch->intel;
+
+   if (batch->buf != NULL) {
+      dri_bo_unreference(batch->buf);
+      batch->buf = NULL;
+   }
+
+   if (!batch->buffer && intel->ttm == GL_TRUE)
+      batch->buffer = malloc (intel->maxBatchSize);
+
+   batch->buf = dri_bo_alloc(intel->bufmgr, "batchbuffer",
+                            intel->maxBatchSize, 4096);
+   if (batch->buffer)
+      batch->map = batch->buffer;
+   else {
+      dri_bo_map(batch->buf, GL_TRUE);
+      batch->map = batch->buf->virtual;
+   }
+   batch->size = intel->maxBatchSize;
+   batch->ptr = batch->map;
+   batch->dirty_state = ~0;
+   batch->cliprect_mode = IGNORE_CLIPRECTS;
+}
+
+struct intel_batchbuffer *
+intel_batchbuffer_alloc(struct intel_context *intel)
+{
+   struct intel_batchbuffer *batch = calloc(sizeof(*batch), 1);
+
+   batch->intel = intel;
+   intel_batchbuffer_reset(batch);
+
+   return batch;
+}
+
+void
+intel_batchbuffer_free(struct intel_batchbuffer *batch)
+{
+   if (batch->buffer)
+      free (batch->buffer);
+   else {
+      if (batch->map) {
+        dri_bo_unmap(batch->buf);
+        batch->map = NULL;
+      }
+   }
+   dri_bo_unreference(batch->buf);
+   batch->buf = NULL;
+   free(batch);
+}
+
+
+
+/* TODO: Push this whole function into bufmgr.
+ */
+static void
+do_flush_locked(struct intel_batchbuffer *batch,
+               GLuint used, GLboolean allow_unlock)
+{
+   struct intel_context *intel = batch->intel;
+   int ret = 0;
+
+   if (batch->buffer)
+      dri_bo_subdata (batch->buf, 0, used, batch->buffer);
+   else
+      dri_bo_unmap(batch->buf);
+
+   batch->map = NULL;
+   batch->ptr = NULL;
+
+   /* 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 &&
+        batch->cliprect_mode == LOOP_CLIPRECTS) || intel->no_hw) {
+      dri_bo_exec(batch->buf, used,
+                 intel->pClipRects,
+                 batch->cliprect_mode != LOOP_CLIPRECTS ?
+                 0 : intel->numClipRects,
+                 (((GLuint) intel->drawX) & 0xffff) |
+                 (((GLuint) intel->drawY) << 16));
+   }
+
+   if (intel->numClipRects == 0 &&
+       batch->cliprect_mode == LOOP_CLIPRECTS) {
+      if (allow_unlock) {
+        /* If we are not doing any actual user-visible rendering,
+         * do a sched_yield to keep the app from pegging the cpu while
+         * achieving nothing.
+         */
+         UNLOCK_HARDWARE(intel);
+         sched_yield();
+         LOCK_HARDWARE(intel);
+      }
+   }
+
+   if (INTEL_DEBUG & DEBUG_BATCH) {
+      dri_bo_map(batch->buf, GL_FALSE);
+      intel_decode(batch->buf->virtual, used / 4, batch->buf->offset,
+                  intel->intelScreen->deviceID);
+      dri_bo_unmap(batch->buf);
+
+      if (intel->vtbl.debug_batch != NULL)
+        intel->vtbl.debug_batch(intel);
+   }
+
+   if (ret != 0) {
+      UNLOCK_HARDWARE(intel);
+      exit(1);
+   }
+   intel->vtbl.new_batch(intel);
+}
+
+void
+_intel_batchbuffer_flush(struct intel_batchbuffer *batch, const char *file,
+                        int line)
+{
+   struct intel_context *intel = batch->intel;
+   GLuint used = batch->ptr - batch->map;
+   GLboolean was_locked = intel->locked;
+
+   if (used == 0)
+      return;
+
+   if (INTEL_DEBUG & DEBUG_BATCH)
+      fprintf(stderr, "%s:%d: Batchbuffer flush with %db used\n", file, line,
+             used);
+
+   /* Emit a flush if the bufmgr doesn't do it for us. */
+   if (!intel->ttm) {
+      *(GLuint *) (batch->ptr) = intel->vtbl.flush_cmd();
+      batch->ptr += 4;
+      used = batch->ptr - batch->map;
+   }
+
+   /* Round batchbuffer usage to 2 DWORDs. */
+
+   if ((used & 4) == 0) {
+      *(GLuint *) (batch->ptr) = 0; /* noop */
+      batch->ptr += 4;
+      used = batch->ptr - batch->map;
+   }
+
+   /* Mark the end of the buffer. */
+   *(GLuint *) (batch->ptr) = MI_BATCH_BUFFER_END; /* noop */
+   batch->ptr += 4;
+   used = batch->ptr - batch->map;
+
+   /* Workaround for recursive batchbuffer flushing: If the window is
+    * moved, we can get into a case where we try to flush during a
+    * flush.  What happens is that when we try to grab the lock for
+    * the first flush, we detect that the window moved which then
+    * causes another flush (from the intel_draw_buffer() call in
+    * intelUpdatePageFlipping()).  To work around this we reset the
+    * batchbuffer tail pointer before trying to get the lock.  This
+    * prevent the nested buffer flush, but a better fix would be to
+    * avoid that in the first place. */
+   batch->ptr = batch->map;
+
+   if (intel->vtbl.finish_batch)
+      intel->vtbl.finish_batch(intel);
+
+   /* TODO: Just pass the relocation list and dma buffer up to the
+    * kernel.
+    */
+   if (!was_locked)
+      LOCK_HARDWARE(intel);
+
+   do_flush_locked(batch, used, GL_FALSE);
+
+   if (!was_locked)
+      UNLOCK_HARDWARE(intel);
+
+   if (INTEL_DEBUG & DEBUG_SYNC) {
+      fprintf(stderr, "waiting for idle\n");
+      dri_bo_map(batch->buf, GL_TRUE);
+      dri_bo_unmap(batch->buf);
+   }
+
+   /* Reset the buffer:
+    */
+   intel_batchbuffer_reset(batch);
+}
+
+
+/*  This is the only way buffers get added to the validate list.
+ */
+GLboolean
+intel_batchbuffer_emit_reloc(struct intel_batchbuffer *batch,
+                             dri_bo *buffer,
+                             uint32_t read_domains, uint32_t write_domain,
+                            uint32_t delta)
+{
+   int ret;
+
+   if (batch->ptr - batch->map > batch->buf->size)
+    _mesa_printf ("bad relocation ptr %p map %p offset %d size %d\n",
+                 batch->ptr, batch->map, batch->ptr - batch->map, batch->buf->size);
+   ret = dri_bo_emit_reloc(batch->buf, read_domains, write_domain,
+                          delta, batch->ptr - batch->map, buffer);
+
+   /*
+    * Using the old buffer offset, write in what the right data would be, in case
+    * the buffer doesn't move and we can short-circuit the relocation processing
+    * in the kernel
+    */
+   intel_batchbuffer_emit_dword (batch, buffer->offset + delta);
+
+   return GL_TRUE;
+}
+
+void
+intel_batchbuffer_data(struct intel_batchbuffer *batch,
+                       const void *data, GLuint bytes,
+                      enum cliprect_mode cliprect_mode)
+{
+   assert((bytes & 3) == 0);
+   intel_batchbuffer_require_space(batch, bytes, cliprect_mode);
+   __memcpy(batch->ptr, data, bytes);
+   batch->ptr += bytes;
+}
diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.h b/src/mesa/drivers/dri/intel/intel_batchbuffer.h
new file mode 100644 (file)
index 0000000..cf7d4a0
--- /dev/null
@@ -0,0 +1,156 @@
+#ifndef INTEL_BATCHBUFFER_H
+#define INTEL_BATCHBUFFER_H
+
+#include "mtypes.h"
+
+#include "intel_context.h"
+#include "intel_bufmgr.h"
+#include "intel_reg.h"
+
+#define BATCH_SZ 16384
+#define BATCH_RESERVED 16
+
+enum cliprect_mode {
+   /**
+    * Batchbuffer contents may be looped over per cliprect, but do not
+    * require it.
+    */
+   IGNORE_CLIPRECTS,
+   /**
+    * Batchbuffer contents require looping over per cliprect at batch submit
+    * time.
+    */
+   LOOP_CLIPRECTS,
+   /**
+    * Batchbuffer contents contain drawing that should not be executed multiple
+    * times.
+    */
+   NO_LOOP_CLIPRECTS,
+   /**
+    * Batchbuffer contents contain drawing that already handles cliprects, such
+    * as 2D drawing to front/back/depth that doesn't respect DRAWING_RECTANGLE.
+    * Equivalent behavior to NO_LOOP_CLIPRECTS, but may not persist in batch
+    * outside of LOCK/UNLOCK.
+    */
+   REFERENCES_CLIPRECTS
+};
+
+struct intel_batchbuffer
+{
+   struct intel_context *intel;
+
+   dri_bo *buf;
+
+   GLubyte *buffer;
+
+   GLubyte *map;
+   GLubyte *ptr;
+
+   enum cliprect_mode cliprect_mode;
+
+   GLuint size;
+
+   GLuint dirty_state;
+};
+
+struct intel_batchbuffer *intel_batchbuffer_alloc(struct intel_context
+                                                  *intel);
+
+void intel_batchbuffer_free(struct intel_batchbuffer *batch);
+
+
+void _intel_batchbuffer_flush(struct intel_batchbuffer *batch,
+                             const char *file, int line);
+
+#define intel_batchbuffer_flush(batch) \
+       _intel_batchbuffer_flush(batch, __FILE__, __LINE__)
+
+void intel_batchbuffer_reset(struct intel_batchbuffer *batch);
+
+
+/* Unlike bmBufferData, this currently requires the buffer be mapped.
+ * Consider it a convenience function wrapping multple
+ * intel_buffer_dword() calls.
+ */
+void intel_batchbuffer_data(struct intel_batchbuffer *batch,
+                            const void *data, GLuint bytes,
+                           enum cliprect_mode cliprect_mode);
+
+void intel_batchbuffer_release_space(struct intel_batchbuffer *batch,
+                                     GLuint bytes);
+
+GLboolean intel_batchbuffer_emit_reloc(struct intel_batchbuffer *batch,
+                                       dri_bo *buffer,
+                                      uint32_t read_domains,
+                                      uint32_t write_domain,
+                                      uint32_t offset);
+
+/* Inline functions - might actually be better off with these
+ * non-inlined.  Certainly better off switching all command packets to
+ * be passed as structs rather than dwords, but that's a little bit of
+ * work...
+ */
+static INLINE GLint
+intel_batchbuffer_space(struct intel_batchbuffer *batch)
+{
+   return (batch->size - BATCH_RESERVED) - (batch->ptr - batch->map);
+}
+
+
+static INLINE void
+intel_batchbuffer_emit_dword(struct intel_batchbuffer *batch, GLuint dword)
+{
+   assert(batch->map);
+   assert(intel_batchbuffer_space(batch) >= 4);
+   *(GLuint *) (batch->ptr) = dword;
+   batch->ptr += 4;
+}
+
+static INLINE void
+intel_batchbuffer_require_space(struct intel_batchbuffer *batch,
+                                GLuint sz,
+                               enum cliprect_mode cliprect_mode)
+{
+   assert(sz < batch->size - 8);
+   if (intel_batchbuffer_space(batch) < sz)
+      intel_batchbuffer_flush(batch);
+
+   if (cliprect_mode != IGNORE_CLIPRECTS) {
+      if (batch->cliprect_mode == IGNORE_CLIPRECTS) {
+        batch->cliprect_mode = cliprect_mode;
+      } else {
+        if (batch->cliprect_mode != cliprect_mode) {
+           intel_batchbuffer_flush(batch);
+           batch->cliprect_mode = cliprect_mode;
+        }
+      }
+   }
+}
+
+/* Here are the crusty old macros, to be removed:
+ */
+#define BATCH_LOCALS
+
+#define BEGIN_BATCH(n, cliprect_mode) do {                             \
+   intel_batchbuffer_require_space(intel->batch, (n)*4, cliprect_mode); \
+} while (0)
+
+#define OUT_BATCH(d)  intel_batchbuffer_emit_dword(intel->batch, d)
+
+#define OUT_RELOC(buf, read_domains, write_domain, delta) do {         \
+   assert((delta) >= 0);                                               \
+   intel_batchbuffer_emit_reloc(intel->batch, buf,                     \
+                               read_domains, write_domain, delta);     \
+} while (0)
+
+#define ADVANCE_BATCH() do { } while(0)
+
+
+static INLINE void
+intel_batchbuffer_emit_mi_flush(struct intel_batchbuffer *batch)
+{
+   intel_batchbuffer_require_space(batch, 4, IGNORE_CLIPRECTS);
+   intel_batchbuffer_emit_dword(batch, MI_FLUSH);
+}
+
+#endif
diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c
new file mode 100644 (file)
index 0000000..653f485
--- /dev/null
@@ -0,0 +1,642 @@
+/**************************************************************************
+ * 
+ * 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_blit.h"
+#include "intel_buffers.h"
+#include "intel_context.h"
+#include "intel_fbo.h"
+#include "intel_reg.h"
+#include "intel_regions.h"
+#include "intel_batchbuffer.h"
+
+#define FILE_DEBUG_FLAG DEBUG_BLIT
+
+/**
+ * Copy the back color buffer to the front color buffer. 
+ * Used for SwapBuffers().
+ */
+void
+intelCopyBuffer(const __DRIdrawablePrivate * dPriv,
+                const drm_clip_rect_t * rect)
+{
+
+   struct intel_context *intel;
+   const intelScreenPrivate *intelScreen;
+
+   DBG("%s\n", __FUNCTION__);
+
+   assert(dPriv);
+
+   intel = intelScreenContext(dPriv->driScreenPriv->private);
+   if (!intel)
+      return;
+
+   intelScreen = intel->intelScreen;
+
+   /* The LOCK_HARDWARE is required for the cliprects.  Buffer offsets
+    * should work regardless.
+    */
+   LOCK_HARDWARE(intel);
+
+   if (dPriv && dPriv->numClipRects) {
+      struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
+      struct intel_region *src, *dst;
+      int nbox = dPriv->numClipRects;
+      drm_clip_rect_t *pbox = dPriv->pClipRects;
+      int cpp;
+      int src_pitch, dst_pitch;
+      unsigned short src_x, src_y;
+      int BR13, CMD;
+      int i;
+      dri_bo *aper_array[3];
+
+      src = intel_get_rb_region(&intel_fb->Base, BUFFER_BACK_LEFT);
+      dst = intel_get_rb_region(&intel_fb->Base, BUFFER_FRONT_LEFT);
+
+      src_pitch = src->pitch * src->cpp;
+      dst_pitch = dst->pitch * dst->cpp;
+
+      cpp = src->cpp;
+
+      ASSERT(intel_fb);
+      ASSERT(intel_fb->Base.Name == 0);    /* Not a user-created FBO */
+      ASSERT(src);
+      ASSERT(dst);
+      ASSERT(src->cpp == dst->cpp);
+
+      if (cpp == 2) {
+        BR13 = (0xCC << 16) | (1 << 24);
+        CMD = XY_SRC_COPY_BLT_CMD;
+      }
+      else {
+        BR13 = (0xCC << 16) | (1 << 24) | (1 << 25);
+        CMD = XY_SRC_COPY_BLT_CMD | XY_BLT_WRITE_ALPHA | XY_BLT_WRITE_RGB;
+      }
+
+#ifndef I915
+      if (src->tiling != I915_TILING_NONE) {
+        CMD |= XY_SRC_TILED;
+        src_pitch /= 4;
+      }
+      if (dst->tiling != I915_TILING_NONE) {
+        CMD |= XY_DST_TILED;
+        dst_pitch /= 4;
+      }
+#endif
+      /* do space/cliprects check before going any further */
+      intel_batchbuffer_require_space(intel->batch, 8 * 4,
+                                     REFERENCES_CLIPRECTS);
+   again:
+      aper_array[0] = intel->batch->buf;
+      aper_array[1] = dst->buffer;
+      aper_array[2] = src->buffer;
+
+      if (dri_bufmgr_check_aperture_space(aper_array, 3) != 0) {
+       intel_batchbuffer_flush(intel->batch);
+       goto again;
+      }
+
+      for (i = 0; i < nbox; i++, pbox++) {
+        drm_clip_rect_t box = *pbox;
+
+        if (rect) {
+           if (!intel_intersect_cliprects(&box, &box, rect))
+              continue;
+        }
+
+        if (box.x1 >= box.x2 ||
+            box.y1 >= box.y2)
+           continue;
+
+        assert(box.x1 < box.x2);
+        assert(box.y1 < box.y2);
+        src_x = box.x1 - dPriv->x + dPriv->backX;
+        src_y = box.y1 - dPriv->y + dPriv->backY;
+
+        BEGIN_BATCH(8, REFERENCES_CLIPRECTS);
+        OUT_BATCH(CMD);
+        OUT_BATCH(BR13 | dst_pitch);
+        OUT_BATCH((box.y1 << 16) | box.x1);
+        OUT_BATCH((box.y2 << 16) | box.x2);
+
+        OUT_RELOC(dst->buffer,
+                  I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
+                  0);
+        OUT_BATCH((src_y << 16) | src_x);
+        OUT_BATCH(src_pitch);
+        OUT_RELOC(src->buffer,
+                  I915_GEM_DOMAIN_RENDER, 0,
+                  0);
+        ADVANCE_BATCH();
+      }
+
+      /* Flush the rendering and the batch so that the results all land on the
+       * screen in a timely fashion.
+       */
+      intel_batchbuffer_emit_mi_flush(intel->batch);
+      intel_batchbuffer_flush(intel->batch);
+   }
+
+   UNLOCK_HARDWARE(intel);
+}
+
+
+
+
+void
+intelEmitFillBlit(struct intel_context *intel,
+                 GLuint cpp,
+                 GLshort dst_pitch,
+                 dri_bo *dst_buffer,
+                 GLuint dst_offset,
+                 uint32_t dst_tiling,
+                 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 = (0xF0 << 16) | (1 << 24);
+      CMD = XY_COLOR_BLT_CMD;
+      break;
+   case 4:
+      BR13 = (0xF0 << 16) | (1 << 24) | (1 << 25);
+      CMD = XY_COLOR_BLT_CMD | XY_BLT_WRITE_ALPHA | XY_BLT_WRITE_RGB;
+      break;
+   default:
+      return;
+   }
+#ifndef I915
+   if (dst_tiling != I915_TILING_NONE) {
+      CMD |= XY_DST_TILED;
+      dst_pitch /= 4;
+   }
+#endif
+
+   DBG("%s dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n",
+       __FUNCTION__, dst_buffer, dst_pitch, dst_offset, x, y, w, h);
+
+   assert(w > 0);
+   assert(h > 0);
+
+   BEGIN_BATCH(6, NO_LOOP_CLIPRECTS);
+   OUT_BATCH(CMD);
+   OUT_BATCH(BR13 | dst_pitch);
+   OUT_BATCH((y << 16) | x);
+   OUT_BATCH(((y + h) << 16) | (x + w));
+   OUT_RELOC(dst_buffer,
+            I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
+            dst_offset);
+   OUT_BATCH(color);
+   ADVANCE_BATCH();
+}
+
+static GLuint translate_raster_op(GLenum logicop)
+{
+   switch(logicop) {
+   case GL_CLEAR: return 0x00;
+   case GL_AND: return 0x88;
+   case GL_AND_REVERSE: return 0x44;
+   case GL_COPY: return 0xCC;
+   case GL_AND_INVERTED: return 0x22;
+   case GL_NOOP: return 0xAA;
+   case GL_XOR: return 0x66;
+   case GL_OR: return 0xEE;
+   case GL_NOR: return 0x11;
+   case GL_EQUIV: return 0x99;
+   case GL_INVERT: return 0x55;
+   case GL_OR_REVERSE: return 0xDD;
+   case GL_COPY_INVERTED: return 0x33;
+   case GL_OR_INVERTED: return 0xBB;
+   case GL_NAND: return 0x77;
+   case GL_SET: return 0xFF;
+   default: return 0;
+   }
+}
+
+
+/* Copy BitBlt
+ */
+void
+intelEmitCopyBlit(struct intel_context *intel,
+                 GLuint cpp,
+                 GLshort src_pitch,
+                 dri_bo *src_buffer,
+                 GLuint src_offset,
+                 uint32_t src_tiling,
+                 GLshort dst_pitch,
+                 dri_bo *dst_buffer,
+                 GLuint dst_offset,
+                 uint32_t dst_tiling,
+                 GLshort src_x, GLshort src_y,
+                 GLshort dst_x, GLshort dst_y,
+                 GLshort w, GLshort h,
+                 GLenum logic_op)
+{
+   GLuint CMD, BR13;
+   int dst_y2 = dst_y + h;
+   int dst_x2 = dst_x + w;
+   dri_bo *aper_array[3];
+   BATCH_LOCALS;
+
+   /* do space/cliprects check before going any further */
+   intel_batchbuffer_require_space(intel->batch, 8 * 4, NO_LOOP_CLIPRECTS);
+ again:
+   aper_array[0] = intel->batch->buf;
+   aper_array[1] = dst_buffer;
+   aper_array[2] = src_buffer;
+
+   if (dri_bufmgr_check_aperture_space(aper_array, 3) != 0) {
+      intel_batchbuffer_flush(intel->batch);
+      goto again;
+   }
+
+   DBG("%s src:buf(%p)/%d+%d %d,%d dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n",
+       __FUNCTION__,
+       src_buffer, src_pitch, src_offset, src_x, src_y,
+       dst_buffer, dst_pitch, dst_offset, dst_x, dst_y, w, h);
+
+   src_pitch *= cpp;
+   dst_pitch *= cpp;
+
+   BR13 = translate_raster_op(logic_op) << 16;
+
+   switch (cpp) {
+   case 1:
+   case 2:
+   case 3:
+      BR13 |= (1 << 24);
+      CMD = XY_SRC_COPY_BLT_CMD;
+      break;
+   case 4:
+      BR13 |= (1 << 24) | (1 << 25);
+      CMD = XY_SRC_COPY_BLT_CMD | XY_BLT_WRITE_ALPHA | XY_BLT_WRITE_RGB;
+      break;
+   default:
+      return;
+   }
+
+#ifndef I915
+   if (dst_tiling != I915_TILING_NONE) {
+      CMD |= XY_DST_TILED;
+      dst_pitch /= 4;
+   }
+   if (src_tiling != I915_TILING_NONE) {
+      CMD |= XY_SRC_TILED;
+      src_pitch /= 4;
+   }
+#endif
+
+   if (dst_y2 <= dst_y || dst_x2 <= dst_x) {
+      return;
+   }
+
+   /* Initial y values don't seem to work with negative pitches.  If
+    * we adjust the offsets manually (below), it seems to work fine.
+    *
+    * On the other hand, if we always adjust, the hardware doesn't
+    * know which blit directions to use, so overlapping copypixels get
+    * the wrong result.
+    */
+   if (dst_pitch > 0 && src_pitch > 0) {
+      assert(dst_x < dst_x2);
+      assert(dst_y < dst_y2);
+
+      BEGIN_BATCH(8, NO_LOOP_CLIPRECTS);
+      OUT_BATCH(CMD);
+      OUT_BATCH(BR13 | dst_pitch);
+      OUT_BATCH((dst_y << 16) | dst_x);
+      OUT_BATCH((dst_y2 << 16) | dst_x2);
+      OUT_RELOC(dst_buffer,
+               I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
+               dst_offset);
+      OUT_BATCH((src_y << 16) | src_x);
+      OUT_BATCH(src_pitch);
+      OUT_RELOC(src_buffer,
+               I915_GEM_DOMAIN_RENDER, 0,
+               src_offset);
+      ADVANCE_BATCH();
+   }
+   else {
+      assert(dst_x < dst_x2);
+      assert(h > 0);
+
+      BEGIN_BATCH(8, NO_LOOP_CLIPRECTS);
+      OUT_BATCH(CMD);
+      OUT_BATCH(BR13 | ((uint16_t)dst_pitch));
+      OUT_BATCH((0 << 16) | dst_x);
+      OUT_BATCH((h << 16) | dst_x2);
+      OUT_RELOC(dst_buffer,
+               I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
+               dst_offset + dst_y * dst_pitch);
+      OUT_BATCH((0 << 16) | src_x);
+      OUT_BATCH(src_pitch);
+      OUT_RELOC(src_buffer,
+               I915_GEM_DOMAIN_RENDER, 0,
+               src_offset + src_y * src_pitch);
+      ADVANCE_BATCH();
+   }
+   intel_batchbuffer_emit_mi_flush(intel->batch);
+}
+
+
+/**
+ * Use blitting to clear the renderbuffers named by 'flags'.
+ * Note: we can't use the ctx->DrawBuffer->_ColorDrawBufferIndexes field
+ * since that might include software renderbuffers or renderbuffers
+ * which we're clearing with triangles.
+ * \param mask  bitmask of BUFFER_BIT_* values indicating buffers to clear
+ */
+void
+intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
+{
+   struct intel_context *intel = intel_context(ctx);
+   struct gl_framebuffer *fb = ctx->DrawBuffer;
+   GLuint clear_depth;
+   GLbitfield skipBuffers = 0;
+   BATCH_LOCALS;
+
+   /*
+    * Compute values for clearing the buffers.
+    */
+   clear_depth = 0;
+   if (mask & BUFFER_BIT_DEPTH) {
+      clear_depth = (GLuint) (fb->_DepthMax * ctx->Depth.Clear);
+   }
+   if (mask & BUFFER_BIT_STENCIL) {
+      clear_depth |= (ctx->Stencil.Clear & 0xff) << 24;
+   }
+
+   /* If clearing both depth and stencil, skip BUFFER_BIT_STENCIL in
+    * the loop below.
+    */
+   if ((mask & BUFFER_BIT_DEPTH) && (mask & BUFFER_BIT_STENCIL)) {
+      skipBuffers = BUFFER_BIT_STENCIL;
+   }
+
+   /* XXX Move this flush/lock into the following conditional? */
+   intelFlush(&intel->ctx);
+   LOCK_HARDWARE(intel);
+
+   if (intel->numClipRects) {
+      GLint cx, cy, cw, ch;
+      drm_clip_rect_t clear;
+      int i;
+
+      /* Get clear bounds after locking */
+      cx = fb->_Xmin;
+      cy = fb->_Ymin;
+      cw = fb->_Xmax - cx;
+      ch = fb->_Ymax - cy;
+
+      if (fb->Name == 0) {
+         /* clearing a window */
+
+         /* flip top to bottom */
+         clear.x1 = cx + intel->drawX;
+         clear.y1 = intel->driDrawable->y + intel->driDrawable->h - cy - ch;
+         clear.x2 = clear.x1 + cw;
+         clear.y2 = clear.y1 + ch;
+      }
+      else {
+         /* clearing FBO */
+         assert(intel->numClipRects == 1);
+         assert(intel->pClipRects == &intel->fboRect);
+         clear.x1 = cx;
+         clear.y1 = cy;
+         clear.x2 = clear.x1 + cw;
+         clear.y2 = clear.y1 + ch;
+         /* no change to mask */
+      }
+
+      for (i = 0; i < intel->numClipRects; i++) {
+         const drm_clip_rect_t *box = &intel->pClipRects[i];
+         drm_clip_rect_t b;
+         GLuint buf;
+         GLuint clearMask = mask;      /* use copy, since we modify it below */
+         GLboolean all = (cw == fb->Width && ch == fb->Height);
+
+         if (!all) {
+            intel_intersect_cliprects(&b, &clear, box);
+         }
+         else {
+            b = *box;
+         }
+
+         if (b.x1 >= b.x2 || b.y1 >= b.y2)
+            continue;
+
+         if (0)
+            _mesa_printf("clear %d,%d..%d,%d, mask %x\n",
+                         b.x1, b.y1, b.x2, b.y2, mask);
+
+         /* Loop over all renderbuffers */
+         for (buf = 0; buf < BUFFER_COUNT && clearMask; buf++) {
+            const GLbitfield bufBit = 1 << buf;
+            if ((clearMask & bufBit) && !(bufBit & skipBuffers)) {
+               /* OK, clear this renderbuffer */
+               struct intel_region *irb_region =
+                 intel_get_rb_region(fb, buf);
+               dri_bo *write_buffer =
+                  intel_region_buffer(intel, irb_region,
+                                      all ? INTEL_WRITE_FULL :
+                                      INTEL_WRITE_PART);
+
+               GLuint clearVal;
+               GLint pitch, cpp;
+               GLuint BR13, CMD;
+
+               ASSERT(irb_region);
+
+               pitch = irb_region->pitch;
+               cpp = irb_region->cpp;
+
+               DBG("%s dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n",
+                   __FUNCTION__,
+                   irb_region->buffer, (pitch * cpp),
+                   irb_region->draw_offset,
+                   b.x1, b.y1, b.x2 - b.x1, b.y2 - b.y1);
+
+              BR13 = 0xf0 << 16;
+              CMD = XY_COLOR_BLT_CMD;
+
+               /* Setup the blit command */
+               if (cpp == 4) {
+                  BR13 |= (1 << 24) | (1 << 25);
+                  if (buf == BUFFER_DEPTH || buf == BUFFER_STENCIL) {
+                     if (clearMask & BUFFER_BIT_DEPTH)
+                        CMD |= XY_BLT_WRITE_RGB;
+                     if (clearMask & BUFFER_BIT_STENCIL)
+                        CMD |= XY_BLT_WRITE_ALPHA;
+                  }
+                  else {
+                     /* clearing RGBA */
+                     CMD |= XY_BLT_WRITE_ALPHA | XY_BLT_WRITE_RGB;
+                  }
+               }
+               else {
+                  ASSERT(cpp == 2 || cpp == 0);
+                  BR13 |= (1 << 24);
+               }
+
+#ifndef I915
+              if (irb_region->tiling != I915_TILING_NONE) {
+                 CMD |= XY_DST_TILED;
+                 pitch /= 4;
+              }
+#endif
+              BR13 |= (pitch * cpp);
+
+               if (buf == BUFFER_DEPTH || buf == BUFFER_STENCIL) {
+                  clearVal = clear_depth;
+               }
+               else {
+                  clearVal = (cpp == 4)
+                     ? intel->ClearColor8888 : intel->ClearColor565;
+               }
+               /*
+                  _mesa_debug(ctx, "hardware blit clear buf %d rb id %d\n",
+                  buf, irb->Base.Name);
+                */
+              intel_wait_flips(intel);
+
+               assert(b.x1 < b.x2);
+               assert(b.y1 < b.y2);
+
+               BEGIN_BATCH(6, REFERENCES_CLIPRECTS);
+               OUT_BATCH(CMD);
+               OUT_BATCH(BR13);
+               OUT_BATCH((b.y1 << 16) | b.x1);
+               OUT_BATCH((b.y2 << 16) | b.x2);
+               OUT_RELOC(write_buffer,
+                        I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
+                         irb_region->draw_offset);
+               OUT_BATCH(clearVal);
+               ADVANCE_BATCH();
+               clearMask &= ~bufBit;    /* turn off bit, for faster loop exit */
+            }
+         }
+      }
+      intel_batchbuffer_emit_mi_flush(intel->batch);
+   }
+
+   UNLOCK_HARDWARE(intel);
+}
+
+void
+intelEmitImmediateColorExpandBlit(struct intel_context *intel,
+                                 GLuint cpp,
+                                 GLubyte *src_bits, GLuint src_size,
+                                 GLuint fg_color,
+                                 GLshort dst_pitch,
+                                 dri_bo *dst_buffer,
+                                 GLuint dst_offset,
+                                 uint32_t dst_tiling,
+                                 GLshort x, GLshort y,
+                                 GLshort w, GLshort h,
+                                 GLenum logic_op)
+{
+   int dwords = ALIGN(src_size, 8) / 4;
+   uint32_t opcode, br13, blit_cmd;
+
+   assert( logic_op - GL_CLEAR >= 0 );
+   assert( logic_op - GL_CLEAR < 0x10 );
+
+   if (w < 0 || h < 0)
+      return;
+
+   dst_pitch *= cpp;
+
+   DBG("%s dst:buf(%p)/%d+%d %d,%d sz:%dx%d, %d bytes %d dwords\n",
+       __FUNCTION__,
+       dst_buffer, dst_pitch, dst_offset, x, y, w, h, src_size, dwords);
+
+   intel_batchbuffer_require_space( intel->batch,
+                                   (8 * 4) +
+                                   (3 * 4) +
+                                   dwords,
+                                   REFERENCES_CLIPRECTS );
+
+   opcode = XY_SETUP_BLT_CMD;
+   if (cpp == 4)
+      opcode |= XY_BLT_WRITE_ALPHA | XY_BLT_WRITE_RGB;
+#ifndef I915
+   if (dst_tiling != I915_TILING_NONE) {
+      opcode |= XY_DST_TILED;
+      dst_pitch /= 4;
+   }
+#endif
+
+   br13 = dst_pitch | (translate_raster_op(logic_op) << 16) | (1 << 29);
+   if (cpp == 2)
+      br13 |= BR13_565;
+   else
+      br13 |= BR13_8888;
+
+   blit_cmd = XY_TEXT_IMMEDIATE_BLIT_CMD | XY_TEXT_BYTE_PACKED; /* packing? */
+   if (dst_tiling != I915_TILING_NONE)
+      blit_cmd |= XY_DST_TILED;
+
+   BEGIN_BATCH(8 + 3, REFERENCES_CLIPRECTS);
+   OUT_BATCH(opcode);
+   OUT_BATCH(br13);
+   OUT_BATCH((0 << 16) | 0); /* clip x1, y1 */
+   OUT_BATCH((100 << 16) | 100); /* clip x2, y2 */
+   OUT_RELOC(dst_buffer,
+            I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
+            dst_offset);
+   OUT_BATCH(0); /* bg */
+   OUT_BATCH(fg_color); /* fg */
+   OUT_BATCH(0); /* pattern base addr */
+
+   OUT_BATCH(blit_cmd | ((3 - 2) + dwords));
+   OUT_BATCH((y << 16) | x);
+   OUT_BATCH(((y + h) << 16) | (x + w));
+   ADVANCE_BATCH();
+
+   intel_batchbuffer_data( intel->batch,
+                          src_bits,
+                          dwords * 4,
+                          REFERENCES_CLIPRECTS );
+
+   intel_batchbuffer_emit_mi_flush(intel->batch);
+}
diff --git a/src/mesa/drivers/dri/intel/intel_blit.h b/src/mesa/drivers/dri/intel/intel_blit.h
new file mode 100644 (file)
index 0000000..52065b1
--- /dev/null
@@ -0,0 +1,75 @@
+/**************************************************************************
+ * 
+ * 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_BLIT_H
+#define INTEL_BLIT_H
+
+#include "intel_context.h"
+
+extern void intelCopyBuffer(const __DRIdrawablePrivate * dpriv,
+                            const drm_clip_rect_t * rect);
+
+extern void intelClearWithBlit(GLcontext * ctx, GLbitfield mask);
+
+extern void intelEmitCopyBlit(struct intel_context *intel,
+                              GLuint cpp,
+                              GLshort src_pitch,
+                              dri_bo *src_buffer,
+                              GLuint src_offset,
+                             uint32_t src_tiling,
+                              GLshort dst_pitch,
+                              dri_bo *dst_buffer,
+                              GLuint dst_offset,
+                             uint32_t dst_tiling,
+                              GLshort srcx, GLshort srcy,
+                              GLshort dstx, GLshort dsty,
+                              GLshort w, GLshort h,
+                             GLenum logicop );
+
+extern void intelEmitFillBlit(struct intel_context *intel,
+                              GLuint cpp,
+                              GLshort dst_pitch,
+                              dri_bo *dst_buffer,
+                              GLuint dst_offset,
+                             uint32_t dst_tiling,
+                              GLshort x, GLshort y,
+                              GLshort w, GLshort h, GLuint color);
+
+void
+intelEmitImmediateColorExpandBlit(struct intel_context *intel,
+                                 GLuint cpp,
+                                 GLubyte *src_bits, GLuint src_size,
+                                 GLuint fg_color,
+                                 GLshort dst_pitch,
+                                 dri_bo *dst_buffer,
+                                 GLuint dst_offset,
+                                 uint32_t dst_tiling,
+                                 GLshort x, GLshort y,
+                                 GLshort w, GLshort h,
+                                 GLenum logic_op);
+
+#endif
diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.c b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
new file mode 100644 (file)
index 0000000..88484a0
--- /dev/null
@@ -0,0 +1,284 @@
+/**************************************************************************
+ * 
+ * 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 "imports.h"
+#include "mtypes.h"
+#include "bufferobj.h"
+
+#include "intel_context.h"
+#include "intel_buffer_objects.h"
+#include "intel_batchbuffer.h"
+#include "intel_regions.h"
+
+static GLboolean intel_bufferobj_unmap(GLcontext * ctx,
+                                      GLenum target,
+                                      struct gl_buffer_object *obj);
+
+/** Allocates a new dri_bo to store the data for the buffer object. */
+static void
+intel_bufferobj_alloc_buffer(struct intel_context *intel,
+                            struct intel_buffer_object *intel_obj)
+{
+   intel_obj->buffer = dri_bo_alloc(intel->bufmgr, "bufferobj",
+                                   intel_obj->Base.Size, 64);
+}
+
+/**
+ * There is some duplication between mesa's bufferobjects and our
+ * bufmgr buffers.  Both have an integer handle and a hashtable to
+ * lookup an opaque structure.  It would be nice if the handles and
+ * internal structure where somehow shared.
+ */
+static struct gl_buffer_object *
+intel_bufferobj_alloc(GLcontext * ctx, GLuint name, GLenum target)
+{
+   struct intel_buffer_object *obj = CALLOC_STRUCT(intel_buffer_object);
+
+   _mesa_initialize_buffer_object(&obj->Base, name, target);
+
+   obj->buffer = NULL;
+
+   return &obj->Base;
+}
+
+/* Break the COW tie to the region.  The region gets to keep the data.
+ */
+void
+intel_bufferobj_release_region(struct intel_context *intel,
+                               struct intel_buffer_object *intel_obj)
+{
+   assert(intel_obj->region->buffer == intel_obj->buffer);
+   intel_obj->region->pbo = NULL;
+   intel_obj->region = NULL;
+
+   dri_bo_unreference(intel_obj->buffer);
+   intel_obj->buffer = NULL;
+}
+
+/* Break the COW tie to the region.  Both the pbo and the region end
+ * up with a copy of the data.
+ */
+void
+intel_bufferobj_cow(struct intel_context *intel,
+                    struct intel_buffer_object *intel_obj)
+{
+   assert(intel_obj->region);
+   intel_region_cow(intel, intel_obj->region);
+}
+
+
+/**
+ * Deallocate/free a vertex/pixel buffer object.
+ * Called via glDeleteBuffersARB().
+ */
+static void
+intel_bufferobj_free(GLcontext * ctx, struct gl_buffer_object *obj)
+{
+   struct intel_context *intel = intel_context(ctx);
+   struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
+
+   assert(intel_obj);
+
+   /* Buffer objects are automatically unmapped when deleting according
+    * to the spec.
+    */
+   if (obj->Pointer)
+      intel_bufferobj_unmap(ctx, 0, obj);
+
+   if (intel_obj->region) {
+      intel_bufferobj_release_region(intel, intel_obj);
+   }
+   else if (intel_obj->buffer) {
+      dri_bo_unreference(intel_obj->buffer);
+   }
+
+   _mesa_free(intel_obj);
+}
+
+
+
+/**
+ * Allocate space for and store data in a buffer object.  Any data that was
+ * previously stored in the buffer object is lost.  If data is NULL,
+ * memory will be allocated, but no copy will occur.
+ * Called via glBufferDataARB().
+ */
+static void
+intel_bufferobj_data(GLcontext * ctx,
+                     GLenum target,
+                     GLsizeiptrARB size,
+                     const GLvoid * data,
+                     GLenum usage, struct gl_buffer_object *obj)
+{
+   struct intel_context *intel = intel_context(ctx);
+   struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
+
+   intel_obj->Base.Size = size;
+   intel_obj->Base.Usage = usage;
+
+   /* Buffer objects are automatically unmapped when creating new data buffers
+    * according to the spec.
+    */
+   if (obj->Pointer)
+      intel_bufferobj_unmap(ctx, 0, obj);
+
+   if (intel_obj->region)
+      intel_bufferobj_release_region(intel, intel_obj);
+
+   if (intel_obj->buffer != NULL) {
+      dri_bo_unreference(intel_obj->buffer);
+      intel_obj->buffer = NULL;
+   }
+   if (size != 0) {
+      intel_bufferobj_alloc_buffer(intel, intel_obj);
+
+      if (data != NULL)
+        dri_bo_subdata(intel_obj->buffer, 0, size, data);
+   }
+}
+
+
+/**
+ * Replace data in a subrange of buffer object.  If the data range
+ * specified by size + offset extends beyond the end of the buffer or
+ * if data is NULL, no copy is performed.
+ * Called via glBufferSubDataARB().
+ */
+static void
+intel_bufferobj_subdata(GLcontext * ctx,
+                        GLenum target,
+                        GLintptrARB offset,
+                        GLsizeiptrARB size,
+                        const GLvoid * data, struct gl_buffer_object *obj)
+{
+   struct intel_context *intel = intel_context(ctx);
+   struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
+
+   assert(intel_obj);
+
+   if (intel_obj->region)
+      intel_bufferobj_cow(intel, intel_obj);
+
+   dri_bo_subdata(intel_obj->buffer, offset, size, data);
+}
+
+
+/**
+ * Called via glGetBufferSubDataARB().
+ */
+static void
+intel_bufferobj_get_subdata(GLcontext * ctx,
+                            GLenum target,
+                            GLintptrARB offset,
+                            GLsizeiptrARB size,
+                            GLvoid * data, struct gl_buffer_object *obj)
+{
+   struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
+
+   assert(intel_obj);
+   dri_bo_get_subdata(intel_obj->buffer, offset, size, data);
+}
+
+
+
+/**
+ * Called via glMapBufferARB().
+ */
+static void *
+intel_bufferobj_map(GLcontext * ctx,
+                    GLenum target,
+                    GLenum access, struct gl_buffer_object *obj)
+{
+   struct intel_context *intel = intel_context(ctx);
+   struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
+
+   /* XXX: Translate access to flags arg below:
+    */
+   assert(intel_obj);
+
+   if (intel_obj->region)
+      intel_bufferobj_cow(intel, intel_obj);
+
+   if (intel_obj->buffer == NULL) {
+      obj->Pointer = NULL;
+      return NULL;
+   }
+
+   dri_bo_map(intel_obj->buffer, GL_TRUE);
+   obj->Pointer = intel_obj->buffer->virtual;
+   return obj->Pointer;
+}
+
+
+/**
+ * Called via glMapBufferARB().
+ */
+static GLboolean
+intel_bufferobj_unmap(GLcontext * ctx,
+                      GLenum target, struct gl_buffer_object *obj)
+{
+   struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
+
+   assert(intel_obj);
+   if (intel_obj->buffer != NULL) {
+      assert(obj->Pointer);
+      dri_bo_unmap(intel_obj->buffer);
+      obj->Pointer = NULL;
+   }
+   return GL_TRUE;
+}
+
+dri_bo *
+intel_bufferobj_buffer(struct intel_context *intel,
+                       struct intel_buffer_object *intel_obj, GLuint flag)
+{
+   if (intel_obj->region) {
+      if (flag == INTEL_WRITE_PART)
+         intel_bufferobj_cow(intel, intel_obj);
+      else if (flag == INTEL_WRITE_FULL) {
+         intel_bufferobj_release_region(intel, intel_obj);
+        intel_bufferobj_alloc_buffer(intel, intel_obj);
+      }
+   }
+
+   return intel_obj->buffer;
+}
+
+void
+intel_bufferobj_init(struct intel_context *intel)
+{
+   GLcontext *ctx = &intel->ctx;
+
+   ctx->Driver.NewBufferObject = intel_bufferobj_alloc;
+   ctx->Driver.DeleteBuffer = intel_bufferobj_free;
+   ctx->Driver.BufferData = intel_bufferobj_data;
+   ctx->Driver.BufferSubData = intel_bufferobj_subdata;
+   ctx->Driver.GetBufferSubData = intel_bufferobj_get_subdata;
+   ctx->Driver.MapBuffer = intel_bufferobj_map;
+   ctx->Driver.UnmapBuffer = intel_bufferobj_unmap;
+}
diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.h b/src/mesa/drivers/dri/intel/intel_buffer_objects.h
new file mode 100644 (file)
index 0000000..7cecc32
--- /dev/null
@@ -0,0 +1,86 @@
+/**************************************************************************
+ * 
+ * Copyright 2005 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_BUFFEROBJ_H
+#define INTEL_BUFFEROBJ_H
+
+#include "mtypes.h"
+
+struct intel_context;
+struct intel_region;
+struct gl_buffer_object;
+
+
+/**
+ * Intel vertex/pixel buffer object, derived from Mesa's gl_buffer_object.
+ */
+struct intel_buffer_object
+{
+   struct gl_buffer_object Base;
+   dri_bo *buffer;     /* the low-level buffer manager's buffer handle */
+
+   struct intel_region *region; /* Is there a zero-copy texture
+                                   associated with this (pixel)
+                                   buffer object? */
+};
+
+
+/* Get the bm buffer associated with a GL bufferobject:
+ */
+dri_bo *intel_bufferobj_buffer(struct intel_context *intel,
+                              struct intel_buffer_object
+                              *obj, GLuint flag);
+
+/* Hook the bufferobject implementation into mesa: 
+ */
+void intel_bufferobj_init(struct intel_context *intel);
+
+
+
+/* Are the obj->Name tests necessary?  Unfortunately yes, mesa
+ * allocates a couple of gl_buffer_object structs statically, and
+ * the Name == 0 test is the only way to identify them and avoid
+ * casting them erroneously to our structs.
+ */
+static INLINE struct intel_buffer_object *
+intel_buffer_object(struct gl_buffer_object *obj)
+{
+   if (obj->Name)
+      return (struct intel_buffer_object *) obj;
+   else
+      return NULL;
+}
+
+/* Helpers for zerocopy image uploads.  See also intel_regions.h:
+ */
+void intel_bufferobj_cow(struct intel_context *intel,
+                         struct intel_buffer_object *intel_obj);
+void intel_bufferobj_release_region(struct intel_context *intel,
+                                    struct intel_buffer_object *intel_obj);
+
+
+#endif
diff --git a/src/mesa/drivers/dri/intel/intel_buffers.c b/src/mesa/drivers/dri/intel/intel_buffers.c
new file mode 100644 (file)
index 0000000..3fe6746
--- /dev/null
@@ -0,0 +1,1099 @@
+/**************************************************************************
+ * 
+ * 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 "intel_screen.h"
+#include "intel_context.h"
+#include "intel_blit.h"
+#include "intel_buffers.h"
+#include "intel_chipset.h"
+#include "intel_depthstencil.h"
+#include "intel_fbo.h"
+#include "intel_regions.h"
+#include "intel_batchbuffer.h"
+#include "intel_reg.h"
+#include "context.h"
+#include "utils.h"
+#include "drirenderbuffer.h"
+#include "framebuffer.h"
+#include "swrast/swrast.h"
+#include "vblank.h"
+#include "i915_drm.h"
+
+/* This block can be removed when libdrm >= 2.3.1 is required */
+
+#ifndef DRM_IOCTL_I915_FLIP
+
+#define DRM_VBLANK_FLIP 0x8000000
+
+typedef struct drm_i915_flip {
+   int pipes;
+} drm_i915_flip_t;
+
+#undef DRM_IOCTL_I915_FLIP
+#define DRM_IOCTL_I915_FLIP DRM_IOW(DRM_COMMAND_BASE + DRM_I915_FLIP, \
+                                   drm_i915_flip_t)
+
+#endif
+
+#define FILE_DEBUG_FLAG DEBUG_BLIT
+
+/**
+ * XXX move this into a new dri/common/cliprects.c file.
+ */
+GLboolean
+intel_intersect_cliprects(drm_clip_rect_t * dst,
+                          const drm_clip_rect_t * a,
+                          const drm_clip_rect_t * b)
+{
+   GLint bx = b->x1;
+   GLint by = b->y1;
+   GLint bw = b->x2 - bx;
+   GLint bh = b->y2 - by;
+
+   if (bx < a->x1)
+      bw -= a->x1 - bx, bx = a->x1;
+   if (by < a->y1)
+      bh -= a->y1 - by, by = a->y1;
+   if (bx + bw > a->x2)
+      bw = a->x2 - bx;
+   if (by + bh > a->y2)
+      bh = a->y2 - by;
+   if (bw <= 0)
+      return GL_FALSE;
+   if (bh <= 0)
+      return GL_FALSE;
+
+   dst->x1 = bx;
+   dst->y1 = by;
+   dst->x2 = bx + bw;
+   dst->y2 = by + bh;
+
+   return GL_TRUE;
+}
+
+/**
+ * Return pointer to current color drawing region, or NULL.
+ */
+struct intel_region *
+intel_drawbuf_region(struct intel_context *intel)
+{
+   struct intel_renderbuffer *irbColor =
+      intel_renderbuffer(intel->ctx.DrawBuffer->_ColorDrawBuffers[0]);
+   if (irbColor)
+      return irbColor->region;
+   else
+      return NULL;
+}
+
+/**
+ * Return pointer to current color reading region, or NULL.
+ */
+struct intel_region *
+intel_readbuf_region(struct intel_context *intel)
+{
+   struct intel_renderbuffer *irb
+      = intel_renderbuffer(intel->ctx.ReadBuffer->_ColorReadBuffer);
+   if (irb)
+      return irb->region;
+   else
+      return NULL;
+}
+
+
+
+/**
+ * Update the following fields for rendering to a user-created FBO:
+ *   intel->numClipRects
+ *   intel->pClipRects
+ *   intel->drawX
+ *   intel->drawY
+ */
+static void
+intelSetRenderbufferClipRects(struct intel_context *intel)
+{
+   assert(intel->ctx.DrawBuffer->Width > 0);
+   assert(intel->ctx.DrawBuffer->Height > 0);
+   intel->fboRect.x1 = 0;
+   intel->fboRect.y1 = 0;
+   intel->fboRect.x2 = intel->ctx.DrawBuffer->Width;
+   intel->fboRect.y2 = intel->ctx.DrawBuffer->Height;
+   intel->numClipRects = 1;
+   intel->pClipRects = &intel->fboRect;
+   intel->drawX = 0;
+   intel->drawY = 0;
+}
+
+
+/**
+ * As above, but for rendering to front buffer of a window.
+ * \sa intelSetRenderbufferClipRects
+ */
+static void
+intelSetFrontClipRects(struct intel_context *intel)
+{
+   __DRIdrawablePrivate *dPriv = intel->driDrawable;
+
+   if (!dPriv)
+      return;
+
+   intel->numClipRects = dPriv->numClipRects;
+   intel->pClipRects = dPriv->pClipRects;
+   intel->drawX = dPriv->x;
+   intel->drawY = dPriv->y;
+}
+
+
+/**
+ * As above, but for rendering to back buffer of a window.
+ */
+static void
+intelSetBackClipRects(struct intel_context *intel)
+{
+   __DRIdrawablePrivate *dPriv = intel->driDrawable;
+   struct intel_framebuffer *intel_fb;
+
+   if (!dPriv)
+      return;
+
+   intel_fb = dPriv->driverPrivate;
+
+   if (intel_fb->pf_active || dPriv->numBackClipRects == 0) {
+      /* use the front clip rects */
+      intel->numClipRects = dPriv->numClipRects;
+      intel->pClipRects = dPriv->pClipRects;
+      intel->drawX = dPriv->x;
+      intel->drawY = dPriv->y;
+   }
+   else {
+      /* use the back clip rects */
+      intel->numClipRects = dPriv->numBackClipRects;
+      intel->pClipRects = dPriv->pBackClipRects;
+      intel->drawX = dPriv->backX;
+      intel->drawY = dPriv->backY;
+   }
+}
+
+static void
+intelUpdatePageFlipping(struct intel_context *intel,
+                       GLint areaA, GLint areaB)
+{
+   __DRIdrawablePrivate *dPriv = intel->driDrawable;
+   struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
+   GLboolean pf_active;
+   GLint pf_planes;
+
+   /* Update page flipping info */
+   pf_planes = 0;
+
+   if (areaA > 0)
+      pf_planes |= 1;
+
+   if (areaB > 0)
+      pf_planes |= 2;
+
+   intel_fb->pf_current_page = (intel->sarea->pf_current_page >>
+                               (intel_fb->pf_planes & 0x2)) & 0x3;
+
+   intel_fb->pf_num_pages = intel->intelScreen->third.handle ? 3 : 2;
+
+   pf_active = pf_planes && (pf_planes & intel->sarea->pf_active) == pf_planes;
+
+   if (INTEL_DEBUG & DEBUG_LOCK)
+      if (pf_active != intel_fb->pf_active)
+        _mesa_printf("%s - Page flipping %sactive\n", __progname,
+                     pf_active ? "" : "in");
+
+   if (pf_active) {
+      /* Sync pages between planes if flipping on both at the same time */
+      if (pf_planes == 0x3 && pf_planes != intel_fb->pf_planes &&
+         (intel->sarea->pf_current_page & 0x3) !=
+         (((intel->sarea->pf_current_page) >> 2) & 0x3)) {
+        drm_i915_flip_t flip;
+
+        if (intel_fb->pf_current_page ==
+            (intel->sarea->pf_current_page & 0x3)) {
+           /* XXX: This is ugly, but emitting two flips 'in a row' can cause
+            * lockups for unknown reasons.
+            */
+           intel->sarea->pf_current_page =
+              intel->sarea->pf_current_page & 0x3;
+           intel->sarea->pf_current_page |=
+              ((intel_fb->pf_current_page + intel_fb->pf_num_pages - 1) %
+               intel_fb->pf_num_pages) << 2;
+
+           flip.pipes = 0x2;
+        } else {
+           intel->sarea->pf_current_page =
+              intel->sarea->pf_current_page & (0x3 << 2);
+           intel->sarea->pf_current_page |=
+              (intel_fb->pf_current_page + intel_fb->pf_num_pages - 1) %
+              intel_fb->pf_num_pages;
+
+           flip.pipes = 0x1;
+        }
+
+        drmCommandWrite(intel->driFd, DRM_I915_FLIP, &flip, sizeof(flip));
+      }
+
+      intel_fb->pf_planes = pf_planes;
+   }
+
+   intel_fb->pf_active = pf_active;
+   intel_flip_renderbuffers(intel_fb);
+   intel_draw_buffer(&intel->ctx, intel->ctx.DrawBuffer);
+}
+
+/**
+ * This will be called whenever the currently bound window is moved/resized.
+ * XXX: actually, it seems to NOT be called when the window is only moved (BP).
+ */
+void
+intelWindowMoved(struct intel_context *intel)
+{
+   GLcontext *ctx = &intel->ctx;
+   __DRIdrawablePrivate *dPriv = intel->driDrawable;
+   struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
+
+   if (!intel->ctx.DrawBuffer) {
+      /* when would this happen? -BP */
+      intelSetFrontClipRects(intel);
+   }
+   else if (intel->ctx.DrawBuffer->Name != 0) {
+      /* drawing to user-created FBO - do nothing */
+      /* Cliprects would be set from intelDrawBuffer() */
+   }
+   else {
+      /* drawing to a window */
+      switch (intel_fb->Base._ColorDrawBufferIndexes[0]) {
+      case BUFFER_FRONT_LEFT:
+         intelSetFrontClipRects(intel);
+         break;
+      case BUFFER_BACK_LEFT:
+         intelSetBackClipRects(intel);
+         break;
+      default:
+         intelSetFrontClipRects(intel);
+      }
+       
+   }
+
+   if (!intel->intelScreen->driScrnPriv->dri2.enabled &&
+       intel->intelScreen->driScrnPriv->ddx_version.minor >= 7) {
+      volatile struct drm_i915_sarea *sarea = intel->sarea;
+      drm_clip_rect_t drw_rect = { .x1 = dPriv->x, .x2 = dPriv->x + dPriv->w,
+                                  .y1 = dPriv->y, .y2 = dPriv->y + dPriv->h };
+      drm_clip_rect_t planeA_rect = { .x1 = sarea->planeA_x, .y1 = sarea->planeA_y,
+                                    .x2 = sarea->planeA_x + sarea->planeA_w,
+                                    .y2 = sarea->planeA_y + sarea->planeA_h };
+      drm_clip_rect_t planeB_rect = { .x1 = sarea->planeB_x, .y1 = sarea->planeB_y,
+                                    .x2 = sarea->planeB_x + sarea->planeB_w,
+                                    .y2 = sarea->planeB_y + sarea->planeB_h };
+      GLint areaA = driIntersectArea( drw_rect, planeA_rect );
+      GLint areaB = driIntersectArea( drw_rect, planeB_rect );
+      GLuint flags = dPriv->vblFlags;
+
+      intelUpdatePageFlipping(intel, areaA, areaB);
+
+      /* Update vblank info
+       */
+      if (areaB > areaA || (areaA == areaB && areaB > 0)) {
+        flags = dPriv->vblFlags | VBLANK_FLAG_SECONDARY;
+      } else {
+        flags = dPriv->vblFlags & ~VBLANK_FLAG_SECONDARY;
+      }
+
+      /* Check to see if we changed pipes */
+      if (flags != dPriv->vblFlags && dPriv->vblFlags &&
+         !(dPriv->vblFlags & VBLANK_FLAG_NO_IRQ)) {
+        int64_t count;
+        drmVBlank vbl;
+        int i;
+
+        /*
+         * Deal with page flipping
+         */
+        vbl.request.type = DRM_VBLANK_ABSOLUTE;
+
+        if ( dPriv->vblFlags & VBLANK_FLAG_SECONDARY ) {
+           vbl.request.type |= DRM_VBLANK_SECONDARY;
+        }
+
+        for (i = 0; i < intel_fb->pf_num_pages; i++) {
+           if (!intel_fb->color_rb[i] ||
+               (intel_fb->vbl_waited - intel_fb->color_rb[i]->vbl_pending) <=
+               (1<<23))
+              continue;
+
+           vbl.request.sequence = intel_fb->color_rb[i]->vbl_pending;
+           drmWaitVBlank(intel->driFd, &vbl);
+        }
+
+        /*
+         * Update msc_base from old pipe
+         */
+        driDrawableGetMSC32(dPriv->driScreenPriv, dPriv, &count);
+        dPriv->msc_base = count;
+        /*
+         * Then get new vblank_base and vblSeq values
+         */
+        dPriv->vblFlags = flags;
+        driGetCurrentVBlank(dPriv);
+        dPriv->vblank_base = dPriv->vblSeq;
+
+        intel_fb->vbl_waited = dPriv->vblSeq;
+
+        for (i = 0; i < intel_fb->pf_num_pages; i++) {
+           if (intel_fb->color_rb[i])
+              intel_fb->color_rb[i]->vbl_pending = intel_fb->vbl_waited;
+        }
+      }
+   } else {
+      dPriv->vblFlags &= ~VBLANK_FLAG_SECONDARY;
+   }
+
+   /* Update Mesa's notion of window size */
+   driUpdateFramebufferSize(ctx, dPriv);
+   intel_fb->Base.Initialized = GL_TRUE; /* XXX remove someday */
+
+   /* Update hardware scissor */
+   if (ctx->Driver.Scissor != NULL) {
+      ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
+                         ctx->Scissor.Width, ctx->Scissor.Height);
+   }
+
+   /* Re-calculate viewport related state */
+   if (ctx->Driver.DepthRange != NULL)
+      ctx->Driver.DepthRange( ctx, ctx->Viewport.Near, ctx->Viewport.Far );
+}
+
+
+
+/* A true meta version of this would be very simple and additionally
+ * machine independent.  Maybe we'll get there one day.
+ */
+static void
+intelClearWithTris(struct intel_context *intel, GLbitfield mask)
+{
+   GLcontext *ctx = &intel->ctx;
+   struct gl_framebuffer *fb = ctx->DrawBuffer;
+   GLuint buf;
+
+   intel->vtbl.install_meta_state(intel);
+
+   /* Back and stencil cliprects are the same.  Try and do both
+    * buffers at once:
+    */
+   if (mask & (BUFFER_BIT_BACK_LEFT | BUFFER_BIT_STENCIL | BUFFER_BIT_DEPTH)) {
+      struct intel_region *backRegion =
+        intel_get_rb_region(fb, BUFFER_BACK_LEFT);
+      struct intel_region *depthRegion =
+        intel_get_rb_region(fb, BUFFER_DEPTH);
+
+      intel->vtbl.meta_draw_region(intel, backRegion, depthRegion);
+
+      if (mask & BUFFER_BIT_BACK_LEFT)
+        intel->vtbl.meta_color_mask(intel, GL_TRUE);
+      else
+        intel->vtbl.meta_color_mask(intel, GL_FALSE);
+
+      if (mask & BUFFER_BIT_STENCIL)
+        intel->vtbl.meta_stencil_replace(intel,
+                                         intel->ctx.Stencil.WriteMask[0],
+                                         intel->ctx.Stencil.Clear);
+      else
+        intel->vtbl.meta_no_stencil_write(intel);
+
+      if (mask & BUFFER_BIT_DEPTH)
+        intel->vtbl.meta_depth_replace(intel);
+      else
+        intel->vtbl.meta_no_depth_write(intel);
+
+      intel->vtbl.meta_draw_quad(intel,
+                                fb->_Xmin,
+                                fb->_Xmax,
+                                fb->_Ymin,
+                                fb->_Ymax,
+                                intel->ctx.Depth.Clear,
+                                intel->ClearColor8888,
+                                0, 0, 0, 0);   /* texcoords */
+
+      mask &= ~(BUFFER_BIT_BACK_LEFT | BUFFER_BIT_STENCIL | BUFFER_BIT_DEPTH);
+   }
+
+   /* clear the remaining (color) renderbuffers */
+   for (buf = 0; buf < BUFFER_COUNT && mask; buf++) {
+      const GLuint bufBit = 1 << buf;
+      if (mask & bufBit) {
+        struct intel_renderbuffer *irbColor =
+           intel_renderbuffer(fb->Attachment[buf].Renderbuffer);
+
+        ASSERT(irbColor);
+
+        intel->vtbl.meta_no_depth_write(intel);
+        intel->vtbl.meta_no_stencil_write(intel);
+        intel->vtbl.meta_color_mask(intel, GL_TRUE);
+        intel->vtbl.meta_draw_region(intel, irbColor->region, NULL);
+
+        intel->vtbl.meta_draw_quad(intel,
+                                   fb->_Xmin,
+                                   fb->_Xmax,
+                                   fb->_Ymin,
+                                   fb->_Ymax,
+                                   0, intel->ClearColor8888,
+                                   0, 0, 0, 0);   /* texcoords */
+
+        mask &= ~bufBit;
+      }
+   }
+
+   intel->vtbl.leave_meta_state(intel);
+}
+
+static const char *buffer_names[] = {
+   [BUFFER_FRONT_LEFT] = "front",
+   [BUFFER_BACK_LEFT] = "back",
+   [BUFFER_FRONT_RIGHT] = "front right",
+   [BUFFER_BACK_RIGHT] = "back right",
+   [BUFFER_AUX0] = "aux0",
+   [BUFFER_AUX1] = "aux1",
+   [BUFFER_AUX2] = "aux2",
+   [BUFFER_AUX3] = "aux3",
+   [BUFFER_DEPTH] = "depth",
+   [BUFFER_STENCIL] = "stencil",
+   [BUFFER_ACCUM] = "accum",
+   [BUFFER_COLOR0] = "color0",
+   [BUFFER_COLOR1] = "color1",
+   [BUFFER_COLOR2] = "color2",
+   [BUFFER_COLOR3] = "color3",
+   [BUFFER_COLOR4] = "color4",
+   [BUFFER_COLOR5] = "color5",
+   [BUFFER_COLOR6] = "color6",
+   [BUFFER_COLOR7] = "color7",
+};
+
+/**
+ * Called by ctx->Driver.Clear.
+ */
+static void
+intelClear(GLcontext *ctx, GLbitfield mask)
+{
+   struct intel_context *intel = intel_context(ctx);
+   const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask);
+   GLbitfield tri_mask = 0;
+   GLbitfield blit_mask = 0;
+   GLbitfield swrast_mask = 0;
+   struct gl_framebuffer *fb = ctx->DrawBuffer;
+   GLuint i;
+
+   if (0)
+      fprintf(stderr, "%s\n", __FUNCTION__);
+
+   /* HW color buffers (front, back, aux, generic FBO, etc) */
+   if (colorMask == ~0) {
+      /* clear all R,G,B,A */
+      /* XXX FBO: need to check if colorbuffers are software RBOs! */
+      blit_mask |= (mask & BUFFER_BITS_COLOR);
+   }
+   else {
+      /* glColorMask in effect */
+      tri_mask |= (mask & BUFFER_BITS_COLOR);
+   }
+
+   /* HW stencil */
+   if (mask & BUFFER_BIT_STENCIL) {
+      const struct intel_region *stencilRegion
+         = intel_get_rb_region(fb, BUFFER_STENCIL);
+      if (stencilRegion) {
+         /* have hw stencil */
+         if (IS_965(intel->intelScreen->deviceID) ||
+            (ctx->Stencil.WriteMask[0] & 0xff) != 0xff) {
+           /* We have to use the 3D engine if we're clearing a partial mask
+            * of the stencil buffer, or if we're on a 965 which has a tiled
+            * depth/stencil buffer in a layout we can't blit to.
+            */
+            tri_mask |= BUFFER_BIT_STENCIL;
+         }
+         else {
+            /* clearing all stencil bits, use blitting */
+            blit_mask |= BUFFER_BIT_STENCIL;
+         }
+      }
+   }
+
+   /* HW depth */
+   if (mask & BUFFER_BIT_DEPTH) {
+      /* clear depth with whatever method is used for stencil (see above) */
+      if (IS_965(intel->intelScreen->deviceID) ||
+         tri_mask & BUFFER_BIT_STENCIL)
+         tri_mask |= BUFFER_BIT_DEPTH;
+      else
+         blit_mask |= BUFFER_BIT_DEPTH;
+   }
+
+   /* SW fallback clearing */
+   swrast_mask = mask & ~tri_mask & ~blit_mask;
+
+   for (i = 0; i < BUFFER_COUNT; i++) {
+      GLuint bufBit = 1 << i;
+      if ((blit_mask | tri_mask) & bufBit) {
+         if (!fb->Attachment[i].Renderbuffer->ClassID) {
+            blit_mask &= ~bufBit;
+            tri_mask &= ~bufBit;
+            swrast_mask |= bufBit;
+         }
+      }
+   }
+
+   if (blit_mask) {
+      if (INTEL_DEBUG & DEBUG_BLIT) {
+        DBG("blit clear:");
+        for (i = 0; i < BUFFER_COUNT; i++) {
+           if (blit_mask & (1 << i))
+              DBG(" %s", buffer_names[i]);
+        }
+        DBG("\n");
+      }
+      intelClearWithBlit(ctx, blit_mask);
+   }
+
+   if (tri_mask) {
+      if (INTEL_DEBUG & DEBUG_BLIT) {
+        DBG("tri clear:");
+        for (i = 0; i < BUFFER_COUNT; i++) {
+           if (tri_mask & (1 << i))
+              DBG(" %s", buffer_names[i]);
+        }
+        DBG("\n");
+      }
+      intelClearWithTris(intel, tri_mask);
+   }
+
+   if (swrast_mask) {
+      if (INTEL_DEBUG & DEBUG_BLIT) {
+        DBG("swrast clear:");
+        for (i = 0; i < BUFFER_COUNT; i++) {
+           if (swrast_mask & (1 << i))
+              DBG(" %s", buffer_names[i]);
+        }
+        DBG("\n");
+      }
+      _swrast_Clear(ctx, swrast_mask);
+   }
+}
+
+
+/* Emit wait for pending flips */
+void
+intel_wait_flips(struct intel_context *intel)
+{
+   struct intel_framebuffer *intel_fb =
+      (struct intel_framebuffer *) intel->ctx.DrawBuffer;
+   struct intel_renderbuffer *intel_rb =
+      intel_get_renderbuffer(&intel_fb->Base,
+                            intel_fb->Base._ColorDrawBufferIndexes[0] ==
+                            BUFFER_FRONT_LEFT ? BUFFER_FRONT_LEFT :
+                            BUFFER_BACK_LEFT);
+
+   if (intel->intelScreen->driScrnPriv->dri2.enabled)
+      return;
+
+   if (intel_fb->Base.Name == 0 && intel_rb &&
+       intel_rb->pf_pending == intel_fb->pf_seq) {
+      GLint pf_planes = intel_fb->pf_planes;
+      BATCH_LOCALS;
+
+      /* Wait for pending flips to take effect */
+      BEGIN_BATCH(2, NO_LOOP_CLIPRECTS);
+      OUT_BATCH(pf_planes & 0x1 ? (MI_WAIT_FOR_EVENT | MI_WAIT_FOR_PLANE_A_FLIP)
+               : 0);
+      OUT_BATCH(pf_planes & 0x2 ? (MI_WAIT_FOR_EVENT | MI_WAIT_FOR_PLANE_B_FLIP)
+               : 0);
+      ADVANCE_BATCH();
+
+      intel_rb->pf_pending--;
+   }
+}
+
+
+/* Flip the front & back buffers
+ */
+static GLboolean
+intelPageFlip(const __DRIdrawablePrivate * dPriv)
+{
+   struct intel_context *intel;
+   int ret;
+   struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
+
+   if (INTEL_DEBUG & DEBUG_IOCTL)
+      fprintf(stderr, "%s\n", __FUNCTION__);
+
+   assert(dPriv);
+   assert(dPriv->driContextPriv);
+   assert(dPriv->driContextPriv->driverPrivate);
+
+   intel = (struct intel_context *) dPriv->driContextPriv->driverPrivate;
+
+   if (intel->intelScreen->drmMinor < 9)
+      return GL_FALSE;
+
+   intelFlush(&intel->ctx);
+
+   ret = 0;
+
+   LOCK_HARDWARE(intel);
+
+   if (dPriv->numClipRects && intel_fb->pf_active) {
+      drm_i915_flip_t flip;
+
+      flip.pipes = intel_fb->pf_planes;
+
+      ret = drmCommandWrite(intel->driFd, DRM_I915_FLIP, &flip, sizeof(flip));
+   }
+
+   UNLOCK_HARDWARE(intel);
+
+   if (ret || !intel_fb->pf_active)
+      return GL_FALSE;
+
+   if (!dPriv->numClipRects) {
+      usleep(10000);   /* throttle invisible client 10ms */
+   }
+
+   intel_fb->pf_current_page = (intel->sarea->pf_current_page >>
+                               (intel_fb->pf_planes & 0x2)) & 0x3;
+
+   if (dPriv->numClipRects != 0) {
+      intel_get_renderbuffer(&intel_fb->Base, BUFFER_FRONT_LEFT)->pf_pending =
+      intel_get_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT)->pf_pending =
+        ++intel_fb->pf_seq;
+   }
+
+   intel_flip_renderbuffers(intel_fb);
+   intel_draw_buffer(&intel->ctx, &intel_fb->Base);
+
+   return GL_TRUE;
+}
+
+static GLboolean
+intelScheduleSwap(__DRIdrawablePrivate * dPriv, GLboolean *missed_target)
+{
+   struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
+   unsigned int interval;
+   struct intel_context *intel =
+      intelScreenContext(dPriv->driScreenPriv->private);
+   const intelScreenPrivate *intelScreen = intel->intelScreen;
+   unsigned int target;
+   drm_i915_vblank_swap_t swap;
+   GLboolean ret;
+
+   if (!dPriv->vblFlags ||
+       (dPriv->vblFlags & VBLANK_FLAG_NO_IRQ) ||
+       intelScreen->drmMinor < (intel_fb->pf_active ? 9 : 6))
+      return GL_FALSE;
+
+   interval = driGetVBlankInterval(dPriv);
+
+   swap.seqtype = DRM_VBLANK_ABSOLUTE;
+
+   if (dPriv->vblFlags & VBLANK_FLAG_SYNC) {
+      swap.seqtype |= DRM_VBLANK_NEXTONMISS;
+   } else if (interval == 0)
+      return GL_FALSE;
+
+   swap.drawable = dPriv->hHWDrawable;
+   target = swap.sequence = dPriv->vblSeq + interval;
+
+   if ( dPriv->vblFlags & VBLANK_FLAG_SECONDARY ) {
+      swap.seqtype |= DRM_VBLANK_SECONDARY;
+   }
+
+   LOCK_HARDWARE(intel);
+
+   intel_batchbuffer_flush(intel->batch);
+
+   if ( intel_fb->pf_active ) {
+      swap.seqtype |= DRM_VBLANK_FLIP;
+
+      intel_fb->pf_current_page = (((intel->sarea->pf_current_page >>
+                                    (intel_fb->pf_planes & 0x2)) & 0x3) + 1) %
+                                 intel_fb->pf_num_pages;
+   }
+
+   if (!drmCommandWriteRead(intel->driFd, DRM_I915_VBLANK_SWAP, &swap,
+                           sizeof(swap))) {
+      dPriv->vblSeq = swap.sequence;
+      swap.sequence -= target;
+      *missed_target = swap.sequence > 0 && swap.sequence <= (1 << 23);
+
+      intel_get_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT)->vbl_pending =
+        intel_get_renderbuffer(&intel_fb->Base,
+                               BUFFER_FRONT_LEFT)->vbl_pending =
+        dPriv->vblSeq;
+
+      if (swap.seqtype & DRM_VBLANK_FLIP) {
+        intel_flip_renderbuffers(intel_fb);
+        intel_draw_buffer(&intel->ctx, intel->ctx.DrawBuffer);
+      }
+
+      ret = GL_TRUE;
+   } else {
+      if (swap.seqtype & DRM_VBLANK_FLIP) {
+        intel_fb->pf_current_page = ((intel->sarea->pf_current_page >>
+                                       (intel_fb->pf_planes & 0x2)) & 0x3) %
+                                    intel_fb->pf_num_pages;
+      }
+
+      ret = GL_FALSE;
+   }
+
+   UNLOCK_HARDWARE(intel);
+
+   return ret;
+}
+  
+void
+intelSwapBuffers(__DRIdrawablePrivate * dPriv)
+{
+   __DRIscreenPrivate *psp = dPriv->driScreenPriv;
+
+   if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+      GET_CURRENT_CONTEXT(ctx);
+      struct intel_context *intel;
+
+      if (ctx == NULL)
+        return;
+
+      intel = intel_context(ctx);
+
+      if (ctx->Visual.doubleBufferMode) {
+        GLboolean missed_target;
+        struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
+        int64_t ust;
+         
+        _mesa_notifySwapBuffers(ctx);  /* flush pending rendering comands */
+
+         if (!intelScheduleSwap(dPriv, &missed_target)) {
+           driWaitForVBlank(dPriv, &missed_target);
+
+           /*
+            * Update each buffer's vbl_pending so we don't get too out of
+            * sync
+            */
+           intel_get_renderbuffer(&intel_fb->Base,
+                                  BUFFER_BACK_LEFT)->vbl_pending = 
+                   intel_get_renderbuffer(&intel_fb->Base,
+                                          BUFFER_FRONT_LEFT)->vbl_pending =
+                   dPriv->vblSeq;
+           if (!intelPageFlip(dPriv)) {
+              intelCopyBuffer(dPriv, NULL);
+           }
+        }
+
+        intel_fb->swap_count++;
+        (*psp->systemTime->getUST) (&ust);
+        if (missed_target) {
+           intel_fb->swap_missed_count++;
+           intel_fb->swap_missed_ust = ust - intel_fb->swap_ust;
+        }
+
+        intel_fb->swap_ust = ust;
+      }
+      drmCommandNone(intel->driFd, DRM_I915_GEM_THROTTLE);
+
+   }
+   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
+intelCopySubBuffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h)
+{
+   if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+      struct intel_context *intel =
+         (struct intel_context *) dPriv->driContextPriv->driverPrivate;
+      GLcontext *ctx = &intel->ctx;
+
+      if (ctx->Visual.doubleBufferMode) {
+         drm_clip_rect_t rect;
+         rect.x1 = x + dPriv->x;
+         rect.y1 = (dPriv->h - y - h) + dPriv->y;
+         rect.x2 = rect.x1 + w;
+         rect.y2 = rect.y1 + h;
+         _mesa_notifySwapBuffers(ctx);  /* flush pending rendering comands */
+         intelCopyBuffer(dPriv, &rect);
+      }
+   }
+   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__);
+   }
+}
+
+
+/**
+ * Update the hardware state for drawing into a window or framebuffer object.
+ *
+ * Called by glDrawBuffer, glBindFramebufferEXT, MakeCurrent, and other
+ * places within the driver.
+ *
+ * Basically, this needs to be called any time the current framebuffer
+ * changes, the renderbuffers change, or we need to draw into different
+ * color buffers.
+ */
+void
+intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)
+{
+   struct intel_context *intel = intel_context(ctx);
+   struct intel_region *colorRegions[MAX_DRAW_BUFFERS], *depthRegion = NULL;
+   struct intel_renderbuffer *irbDepth = NULL, *irbStencil = NULL;
+   int front = 0;               /* drawing to front color buffer? */
+
+   if (!fb) {
+      /* this can happen during the initial context initialization */
+      return;
+   }
+
+   /* Do this here, note core Mesa, since this function is called from
+    * many places within the driver.
+    */
+   if (ctx->NewState & (_NEW_BUFFERS | _NEW_COLOR | _NEW_PIXEL)) {
+      /* this updates the DrawBuffer->_NumColorDrawBuffers fields, etc */
+      _mesa_update_framebuffer(ctx);
+      /* this updates the DrawBuffer's Width/Height if it's a FBO */
+      _mesa_update_draw_buffer_bounds(ctx);
+   }
+
+   if (fb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+      /* this may occur when we're called by glBindFrameBuffer() during
+       * the process of someone setting up renderbuffers, etc.
+       */
+      /*_mesa_debug(ctx, "DrawBuffer: incomplete user FBO\n");*/
+      return;
+   }
+
+   if (fb->Name)
+      intel_validate_paired_depth_stencil(ctx, fb);
+
+   /* If the batch contents require looping over cliprects, flush them before
+    * we go changing which cliprects get referenced when that happens.
+    */
+   if (intel->batch->cliprect_mode == LOOP_CLIPRECTS)
+      intel_batchbuffer_flush(intel->batch);
+
+   /*
+    * How many color buffers are we drawing into?
+    */
+   if (fb->_NumColorDrawBuffers == 0) {
+      /* writing to 0  */
+      FALLBACK(intel, INTEL_FALLBACK_DRAW_BUFFER, GL_TRUE);
+      colorRegions[0] = NULL;
+
+      if (fb->Name != 0)
+        intelSetRenderbufferClipRects(intel);
+   } else if (fb->_NumColorDrawBuffers > 1) {
+       int i;
+       struct intel_renderbuffer *irb;
+       FALLBACK(intel, INTEL_FALLBACK_DRAW_BUFFER, GL_FALSE);
+
+       if (fb->Name != 0)
+           intelSetRenderbufferClipRects(intel);
+       for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
+           irb = intel_renderbuffer(fb->_ColorDrawBuffers[i]);
+           colorRegions[i] = (irb && irb->region) ? irb->region : NULL;
+       }
+   }
+   else {
+      /* draw to exactly one color buffer */
+      /*_mesa_debug(ctx, "Hardware rendering\n");*/
+      FALLBACK(intel, INTEL_FALLBACK_DRAW_BUFFER, GL_FALSE);
+      if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) {
+         front = 1;
+      }
+
+      /*
+       * Get the intel_renderbuffer for the colorbuffer we're drawing into.
+       * And set up cliprects.
+       */
+      if (fb->Name == 0) {
+        /* drawing to window system buffer */
+        if (front) {
+           intelSetFrontClipRects(intel);
+           colorRegions[0] = intel_get_rb_region(fb, BUFFER_FRONT_LEFT);
+        }
+        else {
+           intelSetBackClipRects(intel);
+           colorRegions[0]= intel_get_rb_region(fb, BUFFER_BACK_LEFT);
+        }
+      }
+      else {
+        /* drawing to user-created FBO */
+        struct intel_renderbuffer *irb;
+        intelSetRenderbufferClipRects(intel);
+        irb = intel_renderbuffer(fb->_ColorDrawBuffers[0]);
+        colorRegions[0] = (irb && irb->region) ? irb->region : NULL;
+      }
+   }
+
+   /* Update culling direction which changes depending on the
+    * orientation of the buffer:
+    */
+   if (ctx->Driver.FrontFace)
+      ctx->Driver.FrontFace(ctx, ctx->Polygon.FrontFace);
+   else
+      ctx->NewState |= _NEW_POLYGON;
+
+   if (!colorRegions[0]) {
+      FALLBACK(intel, INTEL_FALLBACK_DRAW_BUFFER, GL_TRUE);
+   }
+   else {
+      FALLBACK(intel, INTEL_FALLBACK_DRAW_BUFFER, GL_FALSE);
+   }
+
+   /***
+    *** Get depth buffer region and check if we need a software fallback.
+    *** Note that the depth buffer is usually a DEPTH_STENCIL buffer.
+    ***/
+   if (fb->_DepthBuffer && fb->_DepthBuffer->Wrapped) {
+      irbDepth = intel_renderbuffer(fb->_DepthBuffer->Wrapped);
+      if (irbDepth && irbDepth->region) {
+         FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, GL_FALSE);
+         depthRegion = irbDepth->region;
+      }
+      else {
+         FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, GL_TRUE);
+         depthRegion = NULL;
+      }
+   }
+   else {
+      /* not using depth buffer */
+      FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, GL_FALSE);
+      depthRegion = NULL;
+   }
+
+   /***
+    *** Stencil buffer
+    *** This can only be hardware accelerated if we're using a
+    *** combined DEPTH_STENCIL buffer (for now anyway).
+    ***/
+   if (fb->_StencilBuffer && fb->_StencilBuffer->Wrapped) {
+      irbStencil = intel_renderbuffer(fb->_StencilBuffer->Wrapped);
+      if (irbStencil && irbStencil->region) {
+         ASSERT(irbStencil->Base._ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+         FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_FALSE);
+         /* need to re-compute stencil hw state */
+        if (ctx->Driver.Enable != NULL)
+           ctx->Driver.Enable(ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled);
+        else
+           ctx->NewState |= _NEW_STENCIL;
+         if (!depthRegion)
+            depthRegion = irbStencil->region;
+      }
+      else {
+         FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_TRUE);
+      }
+   }
+   else {
+      /* XXX FBO: instead of FALSE, pass ctx->Stencil.Enabled ??? */
+      FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_FALSE);
+      /* need to re-compute stencil hw state */
+      if (ctx->Driver.Enable != NULL)
+        ctx->Driver.Enable(ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled);
+      else
+        ctx->NewState |= _NEW_STENCIL;
+   }
+
+   /*
+    * Update depth test state
+    */
+   if (ctx->Driver.Enable) {
+      if (ctx->Depth.Test && fb->Visual.depthBits > 0) {
+        ctx->Driver.Enable(ctx, GL_DEPTH_TEST, GL_TRUE);
+      } else {
+        ctx->Driver.Enable(ctx, GL_DEPTH_TEST, GL_FALSE);
+      }
+   } else {
+      ctx->NewState |= _NEW_DEPTH;
+   }
+
+   intel->vtbl.set_draw_region(intel, colorRegions, depthRegion, 
+       fb->_NumColorDrawBuffers);
+
+   /* update viewport since it depends on window size */
+   if (ctx->Driver.Viewport) {
+      ctx->Driver.Viewport(ctx, ctx->Viewport.X, ctx->Viewport.Y,
+                          ctx->Viewport.Width, ctx->Viewport.Height);
+   } else {
+      ctx->NewState |= _NEW_VIEWPORT;
+   }
+
+   /* Set state we know depends on drawable parameters:
+    */
+   if (ctx->Driver.Scissor)
+      ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
+                         ctx->Scissor.Width, ctx->Scissor.Height);
+   intel->NewGLState |= _NEW_SCISSOR;
+
+   if (ctx->Driver.DepthRange)
+      ctx->Driver.DepthRange(ctx,
+                            ctx->Viewport.Near,
+                            ctx->Viewport.Far);
+}
+
+
+static void
+intelDrawBuffer(GLcontext * ctx, GLenum mode)
+{
+   intel_draw_buffer(ctx, ctx->DrawBuffer);
+}
+
+
+static void
+intelReadBuffer(GLcontext * ctx, GLenum mode)
+{
+   if (ctx->ReadBuffer == ctx->DrawBuffer) {
+      /* This will update FBO completeness status.
+       * A framebuffer will be incomplete if the GL_READ_BUFFER setting
+       * refers to a missing renderbuffer.  Calling glReadBuffer can set
+       * that straight and can make the drawing buffer complete.
+       */
+      intel_draw_buffer(ctx, ctx->DrawBuffer);
+   }
+   /* Generally, functions which read pixels (glReadPixels, glCopyPixels, etc)
+    * reference ctx->ReadBuffer and do appropriate state checks.
+    */
+}
+
+
+void
+intelInitBufferFuncs(struct dd_function_table *functions)
+{
+   functions->Clear = intelClear;
+   functions->DrawBuffer = intelDrawBuffer;
+   functions->ReadBuffer = intelReadBuffer;
+}
diff --git a/src/mesa/drivers/dri/intel/intel_buffers.h b/src/mesa/drivers/dri/intel/intel_buffers.h
new file mode 100644 (file)
index 0000000..a669a85
--- /dev/null
@@ -0,0 +1,56 @@
+
+/**************************************************************************
+ * 
+ * Copyright 2006 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_BUFFERS_H
+#define INTEL_BUFFERS_H
+
+
+struct intel_context;
+struct intel_framebuffer;
+
+
+extern GLboolean
+intel_intersect_cliprects(drm_clip_rect_t * dest,
+                          const drm_clip_rect_t * a,
+                          const drm_clip_rect_t * b);
+
+extern struct intel_region *intel_readbuf_region(struct intel_context *intel);
+
+extern struct intel_region *intel_drawbuf_region(struct intel_context *intel);
+
+extern void intel_wait_flips(struct intel_context *intel);
+
+extern void intelSwapBuffers(__DRIdrawablePrivate * dPriv);
+
+extern void intelWindowMoved(struct intel_context *intel);
+
+extern void intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb);
+
+extern void intelInitBufferFuncs(struct dd_function_table *functions);
+
+#endif /* INTEL_BUFFERS_H */
diff --git a/src/mesa/drivers/dri/intel/intel_chipset.h b/src/mesa/drivers/dri/intel/intel_chipset.h
new file mode 100644 (file)
index 0000000..170efd0
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Copyright Â© 2007 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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:
+ *    Eric Anholt <eric@anholt.net>
+ *
+ */
+
+#define PCI_CHIP_I810                  0x7121
+#define PCI_CHIP_I810_DC100            0x7123
+#define PCI_CHIP_I810_E                        0x7125
+#define PCI_CHIP_I815                  0x1132
+
+#define PCI_CHIP_I830_M                        0x3577
+#define PCI_CHIP_845_G                 0x2562
+#define PCI_CHIP_I855_GM               0x3582
+#define PCI_CHIP_I865_G                        0x2572
+
+#define PCI_CHIP_I915_G                        0x2582
+#define PCI_CHIP_E7221_G               0x258A
+#define PCI_CHIP_I915_GM               0x2592
+#define PCI_CHIP_I945_G                        0x2772
+#define PCI_CHIP_I945_GM               0x27A2
+#define PCI_CHIP_I945_GME              0x27AE
+
+#define PCI_CHIP_Q35_G                 0x29B2
+#define PCI_CHIP_G33_G                 0x29C2
+#define PCI_CHIP_Q33_G                 0x29D2
+
+#define PCI_CHIP_I965_G                        0x29A2
+#define PCI_CHIP_I965_Q                        0x2992
+#define PCI_CHIP_I965_G_1              0x2982
+#define PCI_CHIP_I946_GZ               0x2972
+#define PCI_CHIP_I965_GM                0x2A02
+#define PCI_CHIP_I965_GME               0x2A12
+
+#define PCI_CHIP_GM45_GM                0x2A42
+
+#define PCI_CHIP_IGD_E_G                0x2E02
+#define PCI_CHIP_Q45_G                  0x2E12
+#define PCI_CHIP_G45_G                  0x2E22
+#define PCI_CHIP_G41_G                  0x2E32
+
+#define IS_MOBILE(devid)       (devid == PCI_CHIP_I855_GM || \
+                                devid == PCI_CHIP_I915_GM || \
+                                devid == PCI_CHIP_I945_GM || \
+                                devid == PCI_CHIP_I945_GME || \
+                                devid == PCI_CHIP_I965_GM || \
+                                devid == PCI_CHIP_I965_GME || \
+                                devid == PCI_CHIP_GM45_GM)
+
+#define IS_GM45_GM(devid)       (devid == PCI_CHIP_GM45_GM)
+#define IS_G4X(devid)           (devid == PCI_CHIP_IGD_E_G || \
+                                 devid == PCI_CHIP_Q45_G || \
+                                 devid == PCI_CHIP_G45_G || \
+                                 devid == PCI_CHIP_G41_G)
+
+#define IS_915(devid)          (devid == PCI_CHIP_I915_G || \
+                                devid == PCI_CHIP_E7221_G || \
+                                devid == PCI_CHIP_I915_GM)
+
+#define IS_945(devid)          (devid == PCI_CHIP_I945_G || \
+                                devid == PCI_CHIP_I945_GM || \
+                                devid == PCI_CHIP_I945_GME || \
+                                devid == PCI_CHIP_G33_G || \
+                                devid == PCI_CHIP_Q33_G || \
+                                devid == PCI_CHIP_Q35_G)
+
+#define IS_965(devid)          (devid == PCI_CHIP_I965_G || \
+                                devid == PCI_CHIP_I965_Q || \
+                                devid == PCI_CHIP_I965_G_1 || \
+                                devid == PCI_CHIP_I965_GM || \
+                                devid == PCI_CHIP_I965_GME || \
+                                devid == PCI_CHIP_I946_GZ || \
+                                IS_GM45_GM(devid) || \
+                                IS_G4X(devid))
+
+#define IS_9XX(devid)          (IS_915(devid) || \
+                                IS_945(devid) || \
+                                IS_965(devid))
diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c
new file mode 100644 (file)
index 0000000..2ca5732
--- /dev/null
@@ -0,0 +1,1094 @@
+/**************************************************************************
+ * 
+ * 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 "points.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.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 "intel_chipset.h"
+#include "intel_buffers.h"
+#include "intel_tex.h"
+#include "intel_batchbuffer.h"
+#include "intel_blit.h"
+#include "intel_pixel.h"
+#include "intel_regions.h"
+#include "intel_buffer_objects.h"
+#include "intel_fbo.h"
+#include "intel_decode.h"
+#include "intel_bufmgr.h"
+
+#include "drirenderbuffer.h"
+#include "vblank.h"
+#include "utils.h"
+#include "xmlpool.h"            /* for symbolic values of enum-type options */
+#ifndef INTEL_DEBUG
+int INTEL_DEBUG = (0);
+#endif
+
+#define need_GL_NV_point_sprite
+#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_ARB_occlusion_query
+#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_framebuffer_object
+#define need_GL_EXT_multi_draw_arrays
+#define need_GL_EXT_secondary_color
+#define need_GL_NV_vertex_program
+#define need_GL_ATI_separate_stencil
+#define need_GL_EXT_point_parameters
+#define need_GL_VERSION_2_0
+#define need_GL_VERSION_2_1
+#define need_GL_ARB_shader_objects
+#define need_GL_ARB_vertex_shader
+
+#include "extension_helper.h"
+
+#define DRIVER_DATE                     "20080716"
+#define DRIVER_DATE_GEM                 "GEM " DRIVER_DATE
+
+static const GLubyte *
+intelGetString(GLcontext * ctx, GLenum name)
+{
+   const struct intel_context *const intel = intel_context(ctx);
+   const char *chipset;
+   static char buffer[128];
+
+   switch (name) {
+   case GL_VENDOR:
+      return (GLubyte *) "Tungsten Graphics, Inc";
+      break;
+
+   case GL_RENDERER:
+      switch (intel->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_E7221_G:
+        chipset = "Intel (R) E7221G (i915)";
+        break;
+      case PCI_CHIP_I915_GM:
+         chipset = "Intel(R) 915GM";
+         break;
+      case PCI_CHIP_I945_G:
+         chipset = "Intel(R) 945G";
+         break;
+      case PCI_CHIP_I945_GM:
+         chipset = "Intel(R) 945GM";
+         break;
+      case PCI_CHIP_I945_GME:
+         chipset = "Intel(R) 945GME";
+         break;
+      case PCI_CHIP_G33_G:
+        chipset = "Intel(R) G33";
+        break;
+      case PCI_CHIP_Q35_G:
+        chipset = "Intel(R) Q35";
+        break;
+      case PCI_CHIP_Q33_G:
+        chipset = "Intel(R) Q33";
+        break;
+      case PCI_CHIP_I965_Q:
+        chipset = "Intel(R) 965Q";
+        break;
+      case PCI_CHIP_I965_G:
+      case PCI_CHIP_I965_G_1:
+        chipset = "Intel(R) 965G";
+        break;
+      case PCI_CHIP_I946_GZ:
+        chipset = "Intel(R) 946GZ";
+        break;
+      case PCI_CHIP_I965_GM:
+        chipset = "Intel(R) 965GM";
+        break;
+      case PCI_CHIP_I965_GME:
+        chipset = "Intel(R) 965GME/GLE";
+        break;
+      case PCI_CHIP_GM45_GM:
+        chipset = "Mobile Intel® GM45 Express Chipset";
+        break; 
+      case PCI_CHIP_IGD_E_G:
+        chipset = "Intel(R) Integrated Graphics Device";
+        break;
+      case PCI_CHIP_G45_G:
+         chipset = "Intel(R) G45/G43";
+         break;
+      case PCI_CHIP_Q45_G:
+         chipset = "Intel(R) Q45/Q43";
+         break;
+      case PCI_CHIP_G41_G:
+         chipset = "Intel(R) G41";
+         break;
+      default:
+         chipset = "Unknown Intel Chipset";
+         break;
+      }
+
+      (void) driGetRendererString(buffer, chipset, 
+                                 (intel->ttm) ? DRIVER_DATE_GEM : DRIVER_DATE,
+                                 0);
+      return (GLubyte *) buffer;
+
+   default:
+      return NULL;
+   }
+}
+
+void
+intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
+{
+   struct intel_framebuffer *intel_fb = drawable->driverPrivate;
+   struct intel_renderbuffer *rb;
+   struct intel_region *region, *depth_region;
+   struct intel_context *intel = context->driverPrivate;
+   __DRIbuffer *buffers;
+   __DRIscreen *screen;
+   int i, count;
+   unsigned int attachments[10];
+   uint32_t name;
+   const char *region_name;
+
+   if (INTEL_DEBUG & DEBUG_DRI)
+      fprintf(stderr, "enter %s, drawable %p\n", __func__, drawable);
+
+   screen = intel->intelScreen->driScrnPriv;
+
+   i = 0;
+   if (intel_fb->color_rb[0])
+      attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
+   if (intel_fb->color_rb[1])
+      attachments[i++] = __DRI_BUFFER_BACK_LEFT;
+   if (intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH))
+      attachments[i++] = __DRI_BUFFER_DEPTH;
+   if (intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL))
+      attachments[i++] = __DRI_BUFFER_STENCIL;
+
+   buffers = (*screen->dri2.loader->getBuffers)(drawable,
+                                               &drawable->w,
+                                               &drawable->h,
+                                               attachments, i,
+                                               &count,
+                                               drawable->loaderPrivate);
+
+   if (buffers == NULL)
+      return;
+
+   drawable->x = 0;
+   drawable->y = 0;
+   drawable->backX = 0;
+   drawable->backY = 0;
+   drawable->numClipRects = 1;
+   drawable->pClipRects[0].x1 = 0;
+   drawable->pClipRects[0].y1 = 0;
+   drawable->pClipRects[0].x2 = drawable->w;
+   drawable->pClipRects[0].y2 = drawable->h;
+   drawable->numBackClipRects = 1;
+   drawable->pBackClipRects[0].x1 = 0;
+   drawable->pBackClipRects[0].y1 = 0;
+   drawable->pBackClipRects[0].x2 = drawable->w;
+   drawable->pBackClipRects[0].y2 = drawable->h;
+
+   depth_region = NULL;
+   for (i = 0; i < count; i++) {
+       switch (buffers[i].attachment) {
+       case __DRI_BUFFER_FRONT_LEFT:
+          rb = intel_fb->color_rb[0];
+          region_name = "dri2 front buffer";
+          break;
+
+       case __DRI_BUFFER_BACK_LEFT:
+          rb = intel_fb->color_rb[1];
+          region_name = "dri2 back buffer";
+          break;
+
+       case __DRI_BUFFER_DEPTH:
+          rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
+          region_name = "dri2 depth buffer";
+          break;
+
+       case __DRI_BUFFER_STENCIL:
+          rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
+          region_name = "dri2 stencil buffer";
+          break;
+
+       case __DRI_BUFFER_ACCUM:
+       default:
+          fprintf(stderr,
+                  "unhandled buffer attach event, attacment type %d\n",
+                  buffers[i].attachment);
+          return;
+       }
+
+       if (rb->region) {
+         dri_bo_flink(rb->region->buffer, &name);
+         if (name == buffers[i].name)
+            continue;
+       }
+
+       if (INTEL_DEBUG & DEBUG_DRI)
+         fprintf(stderr,
+                 "attaching buffer %d, at %d, cpp %d, pitch %d\n",
+                 buffers[i].name, buffers[i].attachment,
+                 buffers[i].cpp, buffers[i].pitch);
+       
+       if (buffers[i].attachment == __DRI_BUFFER_STENCIL && depth_region) {
+         if (INTEL_DEBUG & DEBUG_DRI)
+            fprintf(stderr, "(reusing depth buffer as stencil)\n");
+         intel_region_reference(&region, depth_region);
+       }
+       else
+          region = intel_region_alloc_for_handle(intel, buffers[i].cpp,
+                                                drawable->w,
+                                                drawable->h,
+                                                buffers[i].pitch / buffers[i].cpp,
+                                                buffers[i].name,
+                                                region_name);
+
+       if (buffers[i].attachment == __DRI_BUFFER_DEPTH)
+         depth_region = region;
+
+       intel_renderbuffer_set_region(rb, region);
+       intel_region_release(&region);
+   }
+
+   driUpdateFramebufferSize(&intel->ctx, drawable);
+}
+
+static void
+intel_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+    struct intel_context *intel = intel_context(ctx);
+    __DRIcontext *driContext = intel->driContext;
+
+    if (!driContext->driScreenPriv->dri2.enabled)
+       return;
+
+    intel_update_renderbuffers(driContext, driContext->driDrawablePriv);
+    if (driContext->driDrawablePriv != driContext->driReadablePriv)
+       intel_update_renderbuffers(driContext, driContext->driReadablePriv);
+
+    ctx->Driver.Viewport = NULL;
+    intel->driDrawable = driContext->driDrawablePriv;
+    intelWindowMoved(intel);
+    intel_draw_buffer(ctx, intel->ctx.DrawBuffer);
+    ctx->Driver.Viewport = intel_viewport;
+}
+
+/**
+ * Extension strings exported by the intel driver.
+ *
+ * Extensions supported by all chips supported by i830_dri, i915_dri, or
+ * i965_dri.
+ */
+static 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_NV_point_sprite", GL_NV_point_sprite_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_crossbar", NULL},
+   {"GL_ARB_texture_env_dot3", NULL},
+   {"GL_ARB_texture_mirrored_repeat", NULL},
+   {"GL_ARB_texture_non_power_of_two",   NULL },
+   {"GL_ARB_texture_rectangle", NULL},
+   {"GL_NV_texture_rectangle", NULL},
+   {"GL_EXT_texture_rectangle", NULL},
+   {"GL_ARB_point_parameters", 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_logic_op", NULL},
+   {"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_ATI_separate_stencil", GL_ATI_separate_stencil_functions},
+#if 1                           /* XXX FBO temporary? */
+   {"GL_EXT_packed_depth_stencil", NULL},
+#endif
+   {"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}
+};
+
+static const struct dri_extension brw_extensions[] = {
+   { "GL_ARB_shading_language_100",       GL_VERSION_2_0_functions},
+   { "GL_ARB_shading_language_120",       GL_VERSION_2_1_functions},
+   { "GL_ARB_shader_objects",             GL_ARB_shader_objects_functions},
+   { "GL_ARB_vertex_shader",              GL_ARB_vertex_shader_functions},
+   { "GL_ARB_point_sprite",              NULL},
+   { "GL_ARB_fragment_shader",            NULL },
+   { "GL_ARB_draw_buffers",               NULL },
+   { "GL_ARB_depth_texture",              NULL },
+   { "GL_ARB_fragment_program",           NULL },
+   { "GL_ARB_shadow",                     NULL },
+   { "GL_EXT_shadow_funcs",               NULL },
+   { "GL_ARB_fragment_program_shadow",    NULL },
+   /* ARB extn won't work if not enabled */
+   { "GL_SGIX_depth_texture",             NULL },
+   { "GL_EXT_texture_sRGB",              NULL},
+   { NULL,                                NULL }
+};
+
+#ifdef I915_MMIO_READ
+static const struct dri_extension arb_oc_extensions[] = {
+   {"GL_ARB_occlusion_query",            GL_ARB_occlusion_query_functions},
+   {NULL, NULL}
+};
+#endif
+
+static const struct dri_extension ttm_extensions[] = {
+   {"GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions},
+   {"GL_ARB_pixel_buffer_object", NULL},
+   {NULL, NULL}
+};
+
+/**
+ * Initializes potential list of extensions if ctx == NULL, or actually enables
+ * extensions for a context.
+ */
+void intelInitExtensions(GLcontext *ctx, GLboolean enable_imaging)
+{
+   struct intel_context *intel = ctx?intel_context(ctx):NULL;
+
+   /* Disable imaging extension until convolution is working in teximage paths.
+    */
+   enable_imaging = GL_FALSE;
+
+   driInitExtensions(ctx, card_extensions, enable_imaging);
+
+   if (intel == NULL || intel->ttm)
+      driInitExtensions(ctx, ttm_extensions, GL_FALSE);
+
+#ifdef I915_MMIO_READ
+   if (intel == NULL || 
+       (IS_965(intel->intelScreen->deviceID) && 
+       intel->intelScreen->drmMinor >= 8))
+      driInitExtensions(ctx, arb_oc_extensions, GL_FALSE);
+#endif
+
+   if (intel == NULL || IS_965(intel->intelScreen->deviceID))
+      driInitExtensions(ctx, brw_extensions, GL_FALSE);
+}
+
+static const struct dri_debug_control debug_control[] = {
+   { "tex",   DEBUG_TEXTURE},
+   { "state", DEBUG_STATE},
+   { "ioctl", DEBUG_IOCTL},
+   { "blit",  DEBUG_BLIT},
+   { "mip",   DEBUG_MIPTREE},
+   { "fall",  DEBUG_FALLBACKS},
+   { "verb",  DEBUG_VERBOSE},
+   { "bat",   DEBUG_BATCH},
+   { "pix",   DEBUG_PIXEL},
+   { "buf",   DEBUG_BUFMGR},
+   { "reg",   DEBUG_REGION},
+   { "fbo",   DEBUG_FBO},
+   { "lock",  DEBUG_LOCK},
+   { "sync",  DEBUG_SYNC},
+   { "prim",  DEBUG_PRIMS },
+   { "vert",  DEBUG_VERTS },
+   { "dri",   DEBUG_DRI },
+   { "dma",   DEBUG_DMA },
+   { "san",   DEBUG_SANITY },
+   { "sleep", DEBUG_SLEEP },
+   { "stats", DEBUG_STATS },
+   { "tile",  DEBUG_TILE },
+   { "sing",  DEBUG_SINGLE_THREAD },
+   { "thre",  DEBUG_SINGLE_THREAD },
+   { "wm",    DEBUG_WM },
+   { "urb",   DEBUG_URB },
+   { "vs",    DEBUG_VS },
+   { NULL,    0 }
+};
+
+
+static void
+intelInvalidateState(GLcontext * ctx, GLuint new_state)
+{
+    struct intel_context *intel = intel_context(ctx);
+
+   _swrast_InvalidateState(ctx, new_state);
+   _swsetup_InvalidateState(ctx, new_state);
+   _vbo_InvalidateState(ctx, new_state);
+   _tnl_InvalidateState(ctx, new_state);
+   _tnl_invalidate_vertex_state(ctx, new_state);
+
+   intel->NewGLState |= new_state;
+
+   if (intel->vtbl.invalidate_state)
+      intel->vtbl.invalidate_state( intel, new_state );
+}
+
+
+void
+intelFlush(GLcontext * ctx)
+{
+   struct intel_context *intel = intel_context(ctx);
+
+   if (intel->Fallback)
+      _swrast_flush(ctx);
+
+   if (!IS_965(intel->intelScreen->deviceID))
+      INTEL_FIREVERTICES(intel);
+
+   /* Emit a flush so that any frontbuffer rendering that might have occurred
+    * lands onscreen in a timely manner, even if the X Server doesn't trigger
+    * a flush for us.
+    */
+   intel_batchbuffer_emit_mi_flush(intel->batch);
+
+   if (intel->batch->map != intel->batch->ptr)
+      intel_batchbuffer_flush(intel->batch);
+}
+
+void
+intelFinish(GLcontext * ctx)
+{
+   struct gl_framebuffer *fb = ctx->DrawBuffer;
+   int i;
+
+   intelFlush(ctx);
+
+   for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
+       struct intel_renderbuffer *irb;
+
+       irb = intel_renderbuffer(fb->_ColorDrawBuffers[i]);
+
+       if (irb->region)
+         dri_bo_wait_rendering(irb->region->buffer);
+   }
+   if (fb->_DepthBuffer) {
+      /* XXX: Wait on buffer idle */
+   }
+}
+
+#ifdef I915_MMIO_READ
+static void
+intelBeginQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q)
+{
+       struct intel_context *intel = intel_context( ctx );
+       struct drm_i915_mmio io = {
+               .read_write = I915_MMIO_READ,
+               .reg = MMIO_REGS_PS_DEPTH_COUNT,
+               .data = &q->Result 
+       };
+       intel->stats_wm++;
+       intelFinish(&intel->ctx);
+       drmCommandWrite(intel->driFd, DRM_I915_MMIO, &io, sizeof(io));
+}
+
+static void
+intelEndQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q)
+{
+       struct intel_context *intel = intel_context( ctx );
+       GLuint64EXT tmp;        
+       struct drm_i915_mmio io = {
+               .read_write = I915_MMIO_READ,
+               .reg = MMIO_REGS_PS_DEPTH_COUNT,
+               .data = &tmp
+       };
+       intelFinish(&intel->ctx);
+       drmCommandWrite(intel->driFd, DRM_I915_MMIO, &io, sizeof(io));
+       q->Result = tmp - q->Result;
+       q->Ready = GL_TRUE;
+       intel->stats_wm--;
+}
+#endif
+
+void
+intelInitDriverFunctions(struct dd_function_table *functions)
+{
+   _mesa_init_driver_functions(functions);
+
+   functions->Flush = intelFlush;
+   functions->Finish = intelFinish;
+   functions->GetString = intelGetString;
+   functions->UpdateState = intelInvalidateState;
+   functions->Viewport = intel_viewport;
+
+   functions->CopyColorTable = _swrast_CopyColorTable;
+   functions->CopyColorSubTable = _swrast_CopyColorSubTable;
+   functions->CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+   functions->CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+
+#ifdef I915_MMIO_READ
+   functions->BeginQuery = intelBeginQuery;
+   functions->EndQuery = intelEndQuery;
+#endif
+
+   intelInitTextureFuncs(functions);
+   intelInitStateFuncs(functions);
+   intelInitBufferFuncs(functions);
+   intelInitPixelFuncs(functions);
+}
+
+
+GLboolean
+intelInitContext(struct intel_context *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;
+   int fthrottle_mode;
+
+   if (!_mesa_initialize_context(&intel->ctx, mesaVis, shareCtx,
+                                 functions, (void *) intel)) {
+      _mesa_printf("%s: failed to init mesa context\n", __FUNCTION__);
+      return GL_FALSE;
+   }
+
+   driContextPriv->driverPrivate = intel;
+   intel->intelScreen = intelScreen;
+   intel->driScreen = sPriv;
+   intel->sarea = intelScreen->sarea;
+   intel->driContext = driContextPriv;
+
+   /* Dri stuff */
+   intel->hHWContext = driContextPriv->hHWContext;
+   intel->driFd = sPriv->fd;
+   intel->driHwLock = sPriv->lock;
+
+   intel->width = intelScreen->width;
+   intel->height = intelScreen->height;
+
+   driParseConfigFiles(&intel->optionCache, &intelScreen->optionCache,
+                       intel->driScreen->myNum,
+                      IS_965(intelScreen->deviceID) ? "i965" : "i915");
+   if (intelScreen->deviceID == PCI_CHIP_I865_G)
+      intel->maxBatchSize = 4096;
+   else
+      intel->maxBatchSize = BATCH_SZ;
+
+   intel->bufmgr = intelScreen->bufmgr;
+   intel->ttm = intelScreen->ttm;
+   if (intel->ttm) {
+      int bo_reuse_mode;
+
+      bo_reuse_mode = driQueryOptioni(&intel->optionCache, "bo_reuse");
+      switch (bo_reuse_mode) {
+      case DRI_CONF_BO_REUSE_DISABLED:
+        break;
+      case DRI_CONF_BO_REUSE_ALL:
+        intel_bufmgr_gem_enable_reuse(intel->bufmgr);
+        break;
+      }
+   }
+
+   ctx->Const.MaxTextureMaxAnisotropy = 2.0;
+
+   /* This doesn't yet catch all non-conformant rendering, but it's a
+    * start.
+    */
+   if (getenv("INTEL_STRICT_CONFORMANCE")) {
+      intel->strict_conformance = 1;
+   }
+
+   if (intel->strict_conformance) {
+      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;
+   }
+   else {
+      ctx->Const.MinLineWidth = 1.0;
+      ctx->Const.MinLineWidthAA = 1.0;
+      ctx->Const.MaxLineWidth = 5.0;
+      ctx->Const.MaxLineWidthAA = 5.0;
+      ctx->Const.LineWidthGranularity = 0.5;
+   }
+
+   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;
+
+   /* reinitialize the context point state.
+    * It depend on constants in __GLcontextRec::Const
+    */
+   _mesa_init_point(ctx);
+
+   ctx->Const.MaxColorAttachments = 4;  /* XXX FBO: review this */
+
+   /* Initialize the software rasterizer and helper modules. */
+   _swrast_CreateContext(ctx);
+   _vbo_CreateContext(ctx);
+   _tnl_CreateContext(ctx);
+   _swsetup_CreateContext(ctx);
+   /* Configure swrast to match hardware characteristics: */
+   _swrast_allow_pixel_fog(ctx, GL_FALSE);
+   _swrast_allow_vertex_fog(ctx, GL_TRUE);
+
+   intel->hw_stencil = mesaVis->stencilBits && mesaVis->depthBits == 24;
+   intel->hw_stipple = 1;
+
+   /* XXX FBO: this doesn't seem to be used anywhere */
+   switch (mesaVis->depthBits) {
+   case 0:                     /* what to do in this case? */
+   case 16:
+      intel->polygon_offset_scale = 1.0;
+      break;
+   case 24:
+      intel->polygon_offset_scale = 2.0;     /* req'd to pass glean */
+      break;
+   default:
+      assert(0);
+      break;
+   }
+
+   if (IS_965(intelScreen->deviceID))
+      intel->polygon_offset_scale /= 0xffff;
+
+   intel->RenderIndex = ~0;
+
+   fthrottle_mode = driQueryOptioni(&intel->optionCache, "fthrottle_mode");
+   intel->irqsEmitted = 0;
+
+   intel->do_irqs = (intel->intelScreen->irq_active &&
+                     fthrottle_mode == DRI_CONF_FTHROTTLE_IRQS);
+
+   intel->do_usleeps = (fthrottle_mode == DRI_CONF_FTHROTTLE_USLEEPS);
+
+   _math_matrix_ctr(&intel->ViewportMatrix);
+
+   if (IS_965(intelScreen->deviceID) && !intel->intelScreen->irq_active) {
+      _mesa_printf("IRQs not active.  Exiting\n");
+      exit(1);
+   }
+
+   intelInitExtensions(ctx, GL_FALSE);
+
+   INTEL_DEBUG = driParseDebugString(getenv("INTEL_DEBUG"), debug_control);
+   if (INTEL_DEBUG & DEBUG_BUFMGR)
+      dri_bufmgr_set_debug(intel->bufmgr, GL_TRUE);
+
+   if (!sPriv->dri2.enabled)
+      intel_recreate_static_regions(intel);
+
+   intel->batch = intel_batchbuffer_alloc(intel);
+
+   intel_bufferobj_init(intel);
+   intel_fbo_init(intel);
+
+   if (intel->ctx.Mesa_DXTn) {
+      _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
+      _mesa_enable_extension(ctx, "GL_S3_s3tc");
+   }
+   else if (driQueryOptionb(&intel->optionCache, "force_s3tc_enable")) {
+      _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
+   }
+
+   intel->prim.primitive = ~0;
+
+   /* Force all software fallbacks */
+   if (driQueryOptionb(&intel->optionCache, "no_rast")) {
+      fprintf(stderr, "disabling 3D rasterization\n");
+      intel->no_rast = 1;
+   }
+
+   /* Disable all hardware rendering (skip emitting batches and fences/waits
+    * to the kernel)
+    */
+   intel->no_hw = getenv("INTEL_NO_HW") != NULL;
+
+   return GL_TRUE;
+}
+
+void
+intelDestroyContext(__DRIcontextPrivate * driContextPriv)
+{
+   struct intel_context *intel =
+      (struct intel_context *) driContextPriv->driverPrivate;
+
+   assert(intel);               /* should never be null */
+   if (intel) {
+      GLboolean release_texture_heaps;
+
+      INTEL_FIREVERTICES(intel);
+
+      intel->vtbl.destroy(intel);
+
+      release_texture_heaps = (intel->ctx.Shared->RefCount == 1);
+      _swsetup_DestroyContext(&intel->ctx);
+      _tnl_DestroyContext(&intel->ctx);
+      _vbo_DestroyContext(&intel->ctx);
+
+      _swrast_DestroyContext(&intel->ctx);
+      intel->Fallback = 0;      /* don't call _swrast_Flush later */
+
+      intel_batchbuffer_free(intel->batch);
+      free(intel->prim.vb);
+
+      if (release_texture_heaps) {
+         /* This share group is about to go away, free our private
+          * texture object data.
+          */
+         if (INTEL_DEBUG & DEBUG_TEXTURE)
+            fprintf(stderr, "do something to free texture heaps\n");
+      }
+
+      /* free the Mesa context */
+      _mesa_free_context_data(&intel->ctx);
+   }
+}
+
+GLboolean
+intelUnbindContext(__DRIcontextPrivate * driContextPriv)
+{
+   return GL_TRUE;
+}
+
+GLboolean
+intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
+                 __DRIdrawablePrivate * driDrawPriv,
+                 __DRIdrawablePrivate * driReadPriv)
+{
+   __DRIscreenPrivate *psp = driDrawPriv->driScreenPriv;
+
+   if (driContextPriv) {
+      struct intel_context *intel =
+         (struct intel_context *) driContextPriv->driverPrivate;
+      struct intel_framebuffer *intel_fb =
+        (struct intel_framebuffer *) driDrawPriv->driverPrivate;
+      GLframebuffer *readFb = (GLframebuffer *) driReadPriv->driverPrivate;
+      if (driContextPriv->driScreenPriv->dri2.enabled) {     
+          intel_update_renderbuffers(driContextPriv, driDrawPriv);
+          if (driDrawPriv != driReadPriv)
+              intel_update_renderbuffers(driContextPriv, driReadPriv);
+      } else {
+          /* XXX FBO temporary fix-ups! */
+          /* if the renderbuffers don't have regions, init them from the context */
+         struct intel_renderbuffer *irbDepth
+            = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
+         struct intel_renderbuffer *irbStencil
+            = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
+
+         if (intel_fb->color_rb[0]) {
+           intel_renderbuffer_set_region(intel_fb->color_rb[0],
+                                         intel->front_region);
+         }
+         if (intel_fb->color_rb[1]) {
+           intel_renderbuffer_set_region(intel_fb->color_rb[1],
+                                         intel->back_region);
+         }
+#if 0
+         if (intel_fb->color_rb[2]) {
+           intel_renderbuffer_set_region(intel_fb->color_rb[2],
+                                         intel->third_region);
+         }
+#endif
+         if (irbDepth) {
+           intel_renderbuffer_set_region(irbDepth, intel->depth_region);
+         }
+         if (irbStencil) {
+           intel_renderbuffer_set_region(irbStencil, intel->depth_region);
+         }
+      }
+
+      /* set GLframebuffer size to match window, if needed */
+      driUpdateFramebufferSize(&intel->ctx, driDrawPriv);
+
+      if (driReadPriv != driDrawPriv) {
+        driUpdateFramebufferSize(&intel->ctx, driReadPriv);
+      }
+
+      _mesa_make_current(&intel->ctx, &intel_fb->Base, readFb);
+
+      /* The drawbuffer won't always be updated by _mesa_make_current: 
+       */
+      if (intel->ctx.DrawBuffer == &intel_fb->Base) {
+
+        if (intel->driReadDrawable != driReadPriv)
+           intel->driReadDrawable = driReadPriv;
+
+        if (intel->driDrawable != driDrawPriv) {
+           if (driDrawPriv->swap_interval == (unsigned)-1) {
+              int i;
+
+              driDrawPriv->vblFlags = (intel->intelScreen->irq_active != 0)
+                 ? driGetDefaultVBlankFlags(&intel->optionCache)
+                : VBLANK_FLAG_NO_IRQ;
+
+              (*psp->systemTime->getUST) (&intel_fb->swap_ust);
+              driDrawableInitVBlank(driDrawPriv);
+              intel_fb->vbl_waited = driDrawPriv->vblSeq;
+
+              for (i = 0; i < (intel->intelScreen->third.handle ? 3 : 2); i++) {
+                 if (intel_fb->color_rb[i])
+                    intel_fb->color_rb[i]->vbl_pending = driDrawPriv->vblSeq;
+              }
+           }
+           intel->driDrawable = driDrawPriv;
+           intelWindowMoved(intel);
+        }
+
+        intel_draw_buffer(&intel->ctx, &intel_fb->Base);
+      }
+   }
+   else {
+      _mesa_make_current(NULL, NULL, NULL);
+   }
+
+   return GL_TRUE;
+}
+
+static void
+intelContendedLock(struct intel_context *intel, GLuint flags)
+{
+   __DRIdrawablePrivate *dPriv = intel->driDrawable;
+   __DRIscreenPrivate *sPriv = intel->driScreen;
+   volatile struct drm_i915_sarea *sarea = intel->sarea;
+   int me = intel->hHWContext;
+
+   drmGetLock(intel->driFd, intel->hHWContext, flags);
+   intel->locked = 1;
+
+   if (INTEL_DEBUG & DEBUG_LOCK)
+      _mesa_printf("%s - got contended lock\n", __progname);
+
+   /* 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 (sarea && sarea->ctxOwner != me) {
+      if (INTEL_DEBUG & DEBUG_BUFMGR) {
+        fprintf(stderr, "Lost Context: sarea->ctxOwner %x me %x\n",
+                sarea->ctxOwner, me);
+      }
+      sarea->ctxOwner = me;
+   }
+
+   /* If the last consumer of the texture memory wasn't us, notify the fake
+    * bufmgr and record the new owner.  We should have the memory shared
+    * between contexts of a single fake bufmgr, but this will at least make
+    * things correct for now.
+    */
+   if (!intel->ttm && sarea->texAge != intel->hHWContext) {
+      sarea->texAge = intel->hHWContext;
+      intel_bufmgr_fake_contended_lock_take(intel->bufmgr);
+      if (INTEL_DEBUG & DEBUG_BATCH)
+        intel_decode_context_reset();
+      if (INTEL_DEBUG & DEBUG_BUFMGR)
+        fprintf(stderr, "Lost Textures: sarea->texAge %x hw context %x\n",
+                sarea->ctxOwner, intel->hHWContext);
+   }
+
+   if (sarea->width != intel->width || sarea->height != intel->height) {
+       int numClipRects = intel->numClipRects;
+
+       /*
+       * FIXME: Really only need to do this when drawing to a
+       * common back- or front buffer.
+       */
+
+       /*
+       * This will essentially drop the outstanding batchbuffer on
+       * the floor.
+       */
+       intel->numClipRects = 0;
+
+       if (intel->Fallback)
+          _swrast_flush(&intel->ctx);
+
+       if (!IS_965(intel->intelScreen->deviceID))
+          INTEL_FIREVERTICES(intel);
+
+       if (intel->batch->map != intel->batch->ptr)
+          intel_batchbuffer_flush(intel->batch);
+
+       intel->numClipRects = numClipRects;
+
+       /* force window update */
+       intel->lastStamp = 0;
+
+       intel->width = sarea->width;
+       intel->height = sarea->height;
+   }
+
+   /* Drawable changed?
+    */
+   if (dPriv && intel->lastStamp != dPriv->lastStamp) {
+       intelWindowMoved(intel);
+       intel->lastStamp = dPriv->lastStamp;
+   }
+}
+
+
+_glthread_DECLARE_STATIC_MUTEX(lockMutex);
+
+/* Lock the hardware and validate our state.  
+ */
+void LOCK_HARDWARE( struct intel_context *intel )
+{
+    __DRIdrawable *dPriv = intel->driDrawable;
+    __DRIscreen *sPriv = intel->driScreen;
+    char __ret = 0;
+    struct intel_framebuffer *intel_fb = NULL;
+    struct intel_renderbuffer *intel_rb = NULL;
+
+    _glthread_LOCK_MUTEX(lockMutex);
+    assert(!intel->locked);
+    intel->locked = 1;
+
+    if (intel->driDrawable) {
+       intel_fb = intel->driDrawable->driverPrivate;
+
+       if (intel_fb)
+         intel_rb =
+            intel_get_renderbuffer(&intel_fb->Base,
+                                   intel_fb->Base._ColorDrawBufferIndexes[0]);
+    }
+
+    if (intel_rb && dPriv->vblFlags &&
+       !(dPriv->vblFlags & VBLANK_FLAG_NO_IRQ) &&
+       (intel_fb->vbl_waited - intel_rb->vbl_pending) > (1<<23)) {
+       drmVBlank vbl;
+
+       vbl.request.type = DRM_VBLANK_ABSOLUTE;
+
+       if ( dPriv->vblFlags & VBLANK_FLAG_SECONDARY ) {
+           vbl.request.type |= DRM_VBLANK_SECONDARY;
+       }
+
+       vbl.request.sequence = intel_rb->vbl_pending;
+       drmWaitVBlank(intel->driFd, &vbl);
+       intel_fb->vbl_waited = vbl.reply.sequence;
+    }
+
+    if (!sPriv->dri2.enabled) {
+       DRM_CAS(intel->driHwLock, intel->hHWContext,
+               (DRM_LOCK_HELD|intel->hHWContext), __ret);
+
+       if (__ret)
+           intelContendedLock( intel, 0 );
+    }
+
+
+    if (INTEL_DEBUG & DEBUG_LOCK)
+      _mesa_printf("%s - locked\n", __progname);
+}
+
+
+/* Unlock the hardware using the global current context 
+ */
+void UNLOCK_HARDWARE( struct intel_context *intel )
+{
+    __DRIscreen *sPriv = intel->driScreen;
+
+   intel->vtbl.note_unlock( intel );
+   intel->locked = 0;
+
+   if (!sPriv->dri2.enabled)
+      DRM_UNLOCK(intel->driFd, intel->driHwLock, intel->hHWContext);
+
+   _glthread_UNLOCK_MUTEX(lockMutex);
+
+   if (INTEL_DEBUG & DEBUG_LOCK)
+      _mesa_printf("%s - unlocked\n", __progname);
+
+   /**
+    * Nothing should be left in batch outside of LOCK/UNLOCK which references
+    * cliprects.
+    */
+   if (intel->batch->cliprect_mode == REFERENCES_CLIPRECTS)
+      intel_batchbuffer_flush(intel->batch);
+}
+
diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h
new file mode 100644 (file)
index 0000000..8bd7575
--- /dev/null
@@ -0,0 +1,508 @@
+/**************************************************************************
+ * 
+ * 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_bufmgr.h"
+
+#include "intel_screen.h"
+#include "intel_tex_obj.h"
+#include "i915_drm.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)
+
+struct intel_region;
+struct intel_context;
+
+typedef void (*intel_tri_func) (struct intel_context *, intelVertex *,
+                                intelVertex *, intelVertex *);
+typedef void (*intel_line_func) (struct intel_context *, intelVertex *,
+                                 intelVertex *);
+typedef void (*intel_point_func) (struct intel_context *, intelVertex *);
+
+#define INTEL_FALLBACK_DRAW_BUFFER      0x1
+#define INTEL_FALLBACK_READ_BUFFER      0x2
+#define INTEL_FALLBACK_DEPTH_BUFFER      0x4
+#define INTEL_FALLBACK_STENCIL_BUFFER    0x8
+#define INTEL_FALLBACK_USER             0x10
+#define INTEL_FALLBACK_RENDERMODE       0x20
+#define INTEL_FALLBACK_TEXTURE          0x40
+
+extern void intelFallback(struct intel_context *intel, GLuint bit,
+                          GLboolean mode);
+#define FALLBACK( intel, bit, mode ) intelFallback( intel, bit, mode )
+
+
+#define INTEL_WRITE_PART  0x1
+#define INTEL_WRITE_FULL  0x2
+#define INTEL_READ        0x4
+
+#define INTEL_MAX_FIXUP 64
+
+struct intel_context
+{
+   GLcontext ctx;               /* the parent class */
+
+   struct
+   {
+      void (*destroy) (struct intel_context * intel);
+      void (*emit_state) (struct intel_context * intel);
+      void (*finish_batch) (struct intel_context * intel);
+      void (*new_batch) (struct intel_context * intel);
+      void (*emit_invarient_state) (struct intel_context * intel);
+      void (*note_fence) (struct intel_context *intel, GLuint fence);
+      void (*note_unlock) (struct intel_context *intel);
+      void (*update_texture_state) (struct intel_context * intel);
+
+      void (*render_start) (struct intel_context * intel);
+      void (*render_prevalidate) (struct intel_context * intel);
+      void (*set_draw_region) (struct intel_context * intel,
+                               struct intel_region * draw_regions[],
+                               struct intel_region * depth_region,
+                              GLuint num_regions);
+
+      GLuint (*flush_cmd) (void);
+      void (*emit_flush) (struct intel_context *intel, GLuint unused);
+
+      void (*reduced_primitive_state) (struct intel_context * intel,
+                                       GLenum rprim);
+
+      GLboolean (*check_vertex_size) (struct intel_context * intel,
+                                     GLuint expected);
+      void (*invalidate_state) (struct intel_context *intel,
+                               GLuint new_state);
+
+
+      /* Metaops: 
+       */
+      void (*install_meta_state) (struct intel_context * intel);
+      void (*leave_meta_state) (struct intel_context * intel);
+
+      void (*meta_draw_region) (struct intel_context * intel,
+                                struct intel_region * draw_region,
+                                struct intel_region * depth_region);
+
+      void (*meta_draw_quad)(struct intel_context *intel,
+                            GLfloat x0, GLfloat x1,
+                            GLfloat y0, GLfloat y1,
+                            GLfloat z,
+                            GLuint color, /* ARGB32 */
+                            GLfloat s0, GLfloat s1,
+                            GLfloat t0, GLfloat t1);
+
+      void (*meta_color_mask) (struct intel_context * intel, GLboolean);
+
+      void (*meta_stencil_replace) (struct intel_context * intel,
+                                    GLuint mask, GLuint clear);
+
+      void (*meta_depth_replace) (struct intel_context * intel);
+
+      void (*meta_texture_blend_replace) (struct intel_context * intel);
+
+      void (*meta_no_stencil_write) (struct intel_context * intel);
+      void (*meta_no_depth_write) (struct intel_context * intel);
+      void (*meta_no_texture) (struct intel_context * intel);
+
+      void (*meta_import_pixel_state) (struct intel_context * intel);
+      void (*meta_frame_buffer_texture) (struct intel_context *intel,
+                                        GLint xoff, GLint yoff);
+
+      GLboolean(*meta_tex_rect_source) (struct intel_context * intel,
+                                       dri_bo * buffer,
+                                       GLuint offset,
+                                       GLuint pitch,
+                                       GLuint height,
+                                       GLenum format, GLenum type);
+
+      void (*assert_not_dirty) (struct intel_context *intel);
+
+      void (*debug_batch)(struct intel_context *intel);
+   } vtbl;
+
+   GLint refcount;
+   GLuint Fallback;
+   GLuint NewGLState;
+
+   dri_bufmgr *bufmgr;
+   unsigned int maxBatchSize;
+
+   struct intel_region *front_region;
+   struct intel_region *back_region;
+   struct intel_region *third_region;
+   struct intel_region *depth_region;
+
+   /**
+    * This value indicates that the kernel memory manager is being used
+    * instead of the fake client-side memory manager.
+    */
+   GLboolean ttm;
+
+   struct intel_batchbuffer *batch;
+   GLboolean no_batch_wrap;
+   unsigned batch_id;
+
+   struct
+   {
+      GLuint id;
+      uint32_t primitive;      /**< Current hardware primitive type */
+      void (*flush) (struct intel_context *);
+      dri_bo *vb_bo;
+      uint8_t *vb;
+      unsigned int start_offset; /**< Byte offset of primitive sequence */
+      unsigned int current_offset; /**< Byte offset of next vertex */
+      unsigned int count;      /**< Number of vertices in current primitive */
+   } prim;
+
+   GLuint stats_wm;
+   GLboolean locked;
+   char *prevLockFile;
+   int prevLockLine;
+
+   GLubyte clear_chan[4];
+   GLuint ClearColor565;
+   GLuint ClearColor8888;
+
+   /* Offsets of fields within the current vertex:
+    */
+   GLuint coloroffset;
+   GLuint specoffset;
+   GLuint wpos_offset;
+   GLuint wpos_size;
+
+   struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
+   GLuint vertex_attr_count;
+
+   GLfloat polygon_offset_scale;        /* dependent on depth_scale, bpp */
+
+   GLboolean hw_stencil;
+   GLboolean hw_stipple;
+   GLboolean depth_buffer_is_float;
+   GLboolean no_rast;
+   GLboolean strict_conformance;
+
+   /* State for intelvb.c and inteltris.c.
+    */
+   GLuint RenderIndex;
+   GLmatrix ViewportMatrix;
+   GLenum render_primitive;
+   GLenum reduced_primitive;
+   GLuint vertex_size;
+   GLubyte *verts;              /* points to tnl->clipspace.vertex_buf */
+   struct intel_region *draw_region;
+
+   /* Fallback rasterization functions 
+    */
+   intel_point_func draw_point;
+   intel_line_func draw_line;
+   intel_tri_func draw_tri;
+
+   /* These refer to the current drawing buffer:
+    */
+   int drawX, drawY;            /**< origin of drawing area within region */
+   GLuint numClipRects;         /**< cliprects for drawing */
+   drm_clip_rect_t *pClipRects;
+   struct gl_texture_object *frame_buffer_texobj;
+   drm_clip_rect_t fboRect;     /**< cliprect for FBO rendering */
+
+   int perf_boxes;
+
+   GLuint do_usleeps;
+   int do_irqs;
+   GLuint irqsEmitted;
+
+   GLboolean scissor;
+   drm_clip_rect_t draw_rect;
+   drm_clip_rect_t scissor_rect;
+
+   drm_context_t hHWContext;
+   drmLock *driHwLock;
+   int driFd;
+
+   __DRIcontextPrivate *driContext;
+   __DRIdrawablePrivate *driDrawable;
+   __DRIdrawablePrivate *driReadDrawable;
+   __DRIscreenPrivate *driScreen;
+   intelScreenPrivate *intelScreen;
+   volatile struct drm_i915_sarea *sarea;
+
+   GLuint lastStamp;
+
+   GLboolean no_hw;
+
+   /**
+    * Configuration cache
+    */
+   driOptionCache optionCache;
+
+   /* Last seen width/height of the screen */
+   int width;
+   int height;
+
+   int64_t swap_ust;
+   int64_t swap_missed_ust;
+
+   GLuint swap_count;
+   GLuint swap_missed_count;
+};
+
+/* These are functions now:
+ */
+void LOCK_HARDWARE( struct intel_context *intel );
+void UNLOCK_HARDWARE( struct intel_context *intel );
+
+extern char *__progname;
+
+
+#define SUBPIXEL_X 0.125
+#define SUBPIXEL_Y 0.125
+
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+#define ALIGN(value, alignment)  ((value + alignment - 1) & ~(alignment - 1))
+
+#define INTEL_FIREVERTICES(intel)              \
+do {                                           \
+   if ((intel)->prim.flush)                    \
+      (intel)->prim.flush(intel);              \
+} 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:
+ * XXX Put this in src/mesa/main/imports.h ???
+ */
+#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:
+ */
+extern int INTEL_DEBUG;
+
+#define DEBUG_TEXTURE  0x1
+#define DEBUG_STATE    0x2
+#define DEBUG_IOCTL    0x4
+#define DEBUG_BLIT     0x8
+#define DEBUG_MIPTREE   0x10
+#define DEBUG_FALLBACKS        0x20
+#define DEBUG_VERBOSE  0x40
+#define DEBUG_BATCH     0x80
+#define DEBUG_PIXEL     0x100
+#define DEBUG_BUFMGR    0x200
+#define DEBUG_REGION    0x400
+#define DEBUG_FBO       0x800
+#define DEBUG_LOCK      0x1000
+#define DEBUG_SYNC     0x2000
+#define DEBUG_PRIMS    0x4000
+#define DEBUG_VERTS    0x8000
+#define DEBUG_DRI       0x10000
+#define DEBUG_DMA       0x20000
+#define DEBUG_SANITY    0x40000
+#define DEBUG_SLEEP     0x80000
+#define DEBUG_STATS     0x100000
+#define DEBUG_TILE      0x200000
+#define DEBUG_SINGLE_THREAD   0x400000
+#define DEBUG_WM        0x800000
+#define DEBUG_URB       0x1000000
+#define DEBUG_VS        0x2000000
+
+#define DBG(...) do {                                          \
+       if (INTEL_DEBUG & FILE_DEBUG_FLAG)                      \
+               _mesa_printf(__VA_ARGS__);                      \
+} while(0)
+
+#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
+#define PCI_CHIP_I945_GM               0x27A2
+#define PCI_CHIP_I945_GME              0x27AE
+#define PCI_CHIP_G33_G                 0x29C2
+#define PCI_CHIP_Q35_G                 0x29B2
+#define PCI_CHIP_Q33_G                 0x29D2
+
+
+/* ================================================================
+ * intel_context.c:
+ */
+
+extern GLboolean intelInitContext(struct intel_context *intel,
+                                  const __GLcontextModes * mesaVis,
+                                  __DRIcontextPrivate * driContextPriv,
+                                  void *sharedContextPrivate,
+                                  struct dd_function_table *functions);
+
+extern void intelGetLock(struct intel_context *intel, GLuint flags);
+
+extern void intelFinish(GLcontext * ctx);
+extern void intelFlush(GLcontext * ctx);
+
+extern void intelInitDriverFunctions(struct dd_function_table *functions);
+extern void intelInitExtensions(GLcontext *ctx, GLboolean enable_imaging);
+
+
+/* ================================================================
+ * 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
+
+enum {
+   DRI_CONF_BO_REUSE_DISABLED,
+   DRI_CONF_BO_REUSE_ALL
+};
+
+extern int intel_translate_shadow_compare_func(GLenum func);
+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);
+
+void intel_update_renderbuffers(__DRIcontext *context,
+                               __DRIdrawable *drawable);
+
+/*======================================================================
+ * Inline conversion functions.  
+ * These are better-typed than the macros used previously:
+ */
+static INLINE struct intel_context *
+intel_context(GLcontext * ctx)
+{
+   return (struct intel_context *) ctx;
+}
+
+#endif
diff --git a/src/mesa/drivers/dri/intel/intel_decode.c b/src/mesa/drivers/dri/intel/intel_decode.c
new file mode 100644 (file)
index 0000000..9c10501
--- /dev/null
@@ -0,0 +1,1053 @@
+/* -*- c-basic-offset: 4 -*- */
+/*
+ * Copyright Â© 2007 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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:
+ *    Eric Anholt <eric@anholt.net>
+ *
+ */
+
+/** @file intel_decode.c
+ * This file contains code to print out batchbuffer contents in a
+ * human-readable format.
+ *
+ * The current version only supports i915 packets, and only pretty-prints a
+ * subset of them.  The intention is for it to make just a best attempt to
+ * decode, but never crash in the process.
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <inttypes.h>
+
+#include "intel_decode.h"
+#include "intel_chipset.h"
+
+#define BUFFER_FAIL(_count, _len, _name) do {                  \
+    fprintf(out, "Buffer size too small in %s (%d < %d)\n",    \
+           (_name), (_count), (_len));                         \
+    (*failures)++;                                             \
+    return count;                                              \
+} while (0)
+
+static FILE *out;
+static uint32_t saved_s2 = 0, saved_s4 = 0;
+static char saved_s2_set = 0, saved_s4_set = 0;
+
+static float
+int_as_float(uint32_t intval)
+{
+    union intfloat {
+       uint32_t i;
+       float f;
+    } uval;
+
+    uval.i = intval;
+    return uval.f;
+}
+
+static void
+instr_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
+         char *fmt, ...)
+{
+    va_list va;
+
+    fprintf(out, "0x%08x: 0x%08x:%s ", hw_offset + index * 4, data[index],
+           index == 0 ? "" : "  ");
+    va_start(va, fmt);
+    vfprintf(out, fmt, va);
+    va_end(va);
+}
+
+
+static int
+decode_mi(uint32_t *data, int count, uint32_t hw_offset, int *failures)
+{
+    unsigned int opcode;
+
+    struct {
+       uint32_t opcode;
+       int min_len;
+       int max_len;
+       char *name;
+    } opcodes_mi[] = {
+       { 0x08, 1, 1, "MI_ARB_ON_OFF" },
+       { 0x0a, 1, 1, "MI_BATCH_BUFFER_END" },
+       { 0x31, 2, 2, "MI_BATCH_BUFFER_START" },
+       { 0x14, 3, 3, "MI_DISPLAY_BUFFER_INFO" },
+       { 0x04, 1, 1, "MI_FLUSH" },
+       { 0x22, 3, 3, "MI_LOAD_REGISTER_IMM" },
+       { 0x13, 2, 2, "MI_LOAD_SCAN_LINES_EXCL" },
+       { 0x12, 2, 2, "MI_LOAD_SCAN_LINES_INCL" },
+       { 0x00, 1, 1, "MI_NOOP" },
+       { 0x11, 2, 2, "MI_OVERLAY_FLIP" },
+       { 0x07, 1, 1, "MI_REPORT_HEAD" },
+       { 0x18, 2, 2, "MI_SET_CONTEXT" },
+       { 0x20, 3, 4, "MI_STORE_DATA_IMM" },
+       { 0x21, 3, 4, "MI_STORE_DATA_INDEX" },
+       { 0x24, 3, 3, "MI_STORE_REGISTER_MEM" },
+       { 0x02, 1, 1, "MI_USER_INTERRUPT" },
+       { 0x03, 1, 1, "MI_WAIT_FOR_EVENT" },
+    };
+
+
+    for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]);
+        opcode++) {
+       if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) {
+           unsigned int len = 1, i;
+
+           instr_out(data, hw_offset, 0, "%s\n", opcodes_mi[opcode].name);
+           if (opcodes_mi[opcode].max_len > 1) {
+               len = (data[0] & 0x000000ff) + 2;
+               if (len < opcodes_mi[opcode].min_len ||
+                   len > opcodes_mi[opcode].max_len)
+               {
+                   fprintf(out, "Bad length in %s\n",
+                           opcodes_mi[opcode].name);
+               }
+           }
+
+           for (i = 1; i < len; i++) {
+               if (i >= count)
+                   BUFFER_FAIL(count, len, opcodes_mi[opcode].name);
+               instr_out(data, hw_offset, i, "dword %d\n", i);
+           }
+
+           return len;
+       }
+    }
+
+    instr_out(data, hw_offset, 0, "MI UNKNOWN\n");
+    (*failures)++;
+    return 1;
+}
+
+static int
+decode_2d(uint32_t *data, int count, uint32_t hw_offset, int *failures)
+{
+    unsigned int opcode, len;
+    char *format = NULL;
+
+    struct {
+       uint32_t opcode;
+       int min_len;
+       int max_len;
+       char *name;
+    } opcodes_2d[] = {
+       { 0x40, 5, 5, "COLOR_BLT" },
+       { 0x43, 6, 6, "SRC_COPY_BLT" },
+       { 0x01, 8, 8, "XY_SETUP_BLT" },
+       { 0x11, 9, 9, "XY_SETUP_MONO_PATTERN_SL_BLT" },
+       { 0x03, 3, 3, "XY_SETUP_CLIP_BLT" },
+       { 0x24, 2, 2, "XY_PIXEL_BLT" },
+       { 0x25, 3, 3, "XY_SCANLINES_BLT" },
+       { 0x26, 4, 4, "Y_TEXT_BLT" },
+       { 0x31, 5, 134, "XY_TEXT_IMMEDIATE_BLT" },
+       { 0x50, 6, 6, "XY_COLOR_BLT" },
+       { 0x51, 6, 6, "XY_PAT_BLT" },
+       { 0x76, 8, 8, "XY_PAT_CHROMA_BLT" },
+       { 0x72, 7, 135, "XY_PAT_BLT_IMMEDIATE" },
+       { 0x77, 9, 137, "XY_PAT_CHROMA_BLT_IMMEDIATE" },
+       { 0x52, 9, 9, "XY_MONO_PAT_BLT" },
+       { 0x59, 7, 7, "XY_MONO_PAT_FIXED_BLT" },
+       { 0x53, 8, 8, "XY_SRC_COPY_BLT" },
+       { 0x54, 8, 8, "XY_MONO_SRC_COPY_BLT" },
+       { 0x71, 9, 137, "XY_MONO_SRC_COPY_IMMEDIATE_BLT" },
+       { 0x55, 9, 9, "XY_FULL_BLT" },
+       { 0x55, 9, 137, "XY_FULL_IMMEDIATE_PATTERN_BLT" },
+       { 0x56, 9, 9, "XY_FULL_MONO_SRC_BLT" },
+       { 0x75, 10, 138, "XY_FULL_MONO_SRC_IMMEDIATE_PATTERN_BLT" },
+       { 0x57, 12, 12, "XY_FULL_MONO_PATTERN_BLT" },
+       { 0x58, 12, 12, "XY_FULL_MONO_PATTERN_MONO_SRC_BLT" },
+    };
+
+    switch ((data[0] & 0x1fc00000) >> 22) {
+    case 0x50:
+       instr_out(data, hw_offset, 0,
+                 "XY_COLOR_BLT (rgb %sabled, alpha %sabled, dst tile %d)\n",
+                 (data[0] & (1 << 20)) ? "en" : "dis",
+                 (data[0] & (1 << 21)) ? "en" : "dis",
+                 (data[0] >> 11) & 1);
+
+       len = (data[0] & 0x000000ff) + 2;
+       if (len != 6)
+           fprintf(out, "Bad count in XY_COLOR_BLT\n");
+       if (count < 6)
+           BUFFER_FAIL(count, len, "XY_COLOR_BLT");
+
+       switch ((data[1] >> 24) & 0x3) {
+       case 0:
+           format="8";
+           break;
+       case 1:
+           format="565";
+           break;
+       case 2:
+           format="1555";
+           break;
+       case 3:
+           format="8888";
+           break;
+       }
+
+       instr_out(data, hw_offset, 1, "format %s, pitch %d, "
+                 "clipping %sabled\n", format,
+                 (short)(data[1] & 0xffff),
+                 data[1] & (1 << 30) ? "en" : "dis");
+       instr_out(data, hw_offset, 2, "(%d,%d)\n",
+                 data[2] & 0xffff, data[2] >> 16);
+       instr_out(data, hw_offset, 3, "(%d,%d)\n",
+                 data[3] & 0xffff, data[3] >> 16);
+       instr_out(data, hw_offset, 4, "offset 0x%08x\n", data[4]);
+       instr_out(data, hw_offset, 5, "color\n");
+       return len;
+    case 0x53:
+       instr_out(data, hw_offset, 0,
+                 "XY_SRC_COPY_BLT (rgb %sabled, alpha %sabled, "
+                 "src tile %d, dst tile %d)\n",
+                 (data[0] & (1 << 20)) ? "en" : "dis",
+                 (data[0] & (1 << 21)) ? "en" : "dis",
+                 (data[0] >> 15) & 1,
+                 (data[0] >> 11) & 1);
+
+       len = (data[0] & 0x000000ff) + 2;
+       if (len != 8)
+           fprintf(out, "Bad count in XY_SRC_COPY_BLT\n");
+       if (count < 8)
+           BUFFER_FAIL(count, len, "XY_SRC_COPY_BLT");
+
+       switch ((data[1] >> 24) & 0x3) {
+       case 0:
+           format="8";
+           break;
+       case 1:
+           format="565";
+           break;
+       case 2:
+           format="1555";
+           break;
+       case 3:
+           format="8888";
+           break;
+       }
+
+       instr_out(data, hw_offset, 1, "format %s, dst pitch %d, "
+                 "clipping %sabled\n", format,
+                 (short)(data[1] & 0xffff),
+                 data[1] & (1 << 30) ? "en" : "dis");
+       instr_out(data, hw_offset, 2, "dst (%d,%d)\n",
+                 data[2] & 0xffff, data[2] >> 16);
+       instr_out(data, hw_offset, 3, "dst (%d,%d)\n",
+                 data[3] & 0xffff, data[3] >> 16);
+       instr_out(data, hw_offset, 4, "dst offset 0x%08x\n", data[4]);
+       instr_out(data, hw_offset, 5, "src (%d,%d)\n",
+                 data[5] & 0xffff, data[5] >> 16);
+       instr_out(data, hw_offset, 6, "src pitch %d\n",
+                 (short)(data[6] & 0xffff));
+       instr_out(data, hw_offset, 7, "src offset 0x%08x\n", data[7]);
+       return len;
+    }
+
+    for (opcode = 0; opcode < sizeof(opcodes_2d) / sizeof(opcodes_2d[0]);
+        opcode++) {
+       if ((data[0] & 0x1fc00000) >> 22 == opcodes_2d[opcode].opcode) {
+           unsigned int i;
+
+           len = 1;
+           instr_out(data, hw_offset, 0, "%s\n", opcodes_2d[opcode].name);
+           if (opcodes_2d[opcode].max_len > 1) {
+               len = (data[0] & 0x000000ff) + 2;
+               if (len < opcodes_2d[opcode].min_len ||
+                   len > opcodes_2d[opcode].max_len)
+               {
+                   fprintf(out, "Bad count in %s\n", opcodes_2d[opcode].name);
+               }
+           }
+
+           for (i = 1; i < len; i++) {
+               if (i >= count)
+                   BUFFER_FAIL(count, len, opcodes_2d[opcode].name);
+               instr_out(data, hw_offset, i, "dword %d\n", i);
+           }
+
+           return len;
+       }
+    }
+
+    instr_out(data, hw_offset, 0, "2D UNKNOWN\n");
+    (*failures)++;
+    return 1;
+}
+
+static int
+decode_3d_1c(uint32_t *data, int count, uint32_t hw_offset, int *failures)
+{
+    switch ((data[0] & 0x00f80000) >> 19) {
+    case 0x11:
+       instr_out(data, hw_offset, 0, "3DSTATE_DEPTH_SUBRECTANGLE_DISALBE\n");
+       return 1;
+    case 0x10:
+       instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_ENABLE\n");
+       return 1;
+    }
+
+    instr_out(data, hw_offset, 0, "3D UNKNOWN\n");
+    (*failures)++;
+    return 1;
+}
+
+static int
+decode_3d_1d(uint32_t *data, int count, uint32_t hw_offset, int *failures)
+{
+    unsigned int len, i, c, opcode, word, map, sampler, instr;
+
+    struct {
+       uint32_t opcode;
+       int min_len;
+       int max_len;
+       char *name;
+    } opcodes_3d_1d[] = {
+       { 0x8e, 3, 3, "3DSTATE_BUFFER_INFO" },
+       { 0x86, 4, 4, "3DSTATE_CHROMA_KEY" },
+       { 0x9c, 1, 1, "3DSTATE_CLEAR_PARAMETERS" },
+       { 0x88, 2, 2, "3DSTATE_CONSTANT_BLEND_COLOR" },
+       { 0x99, 2, 2, "3DSTATE_DEFAULT_DIFFUSE" },
+       { 0x9a, 2, 2, "3DSTATE_DEFAULT_SPECULAR" },
+       { 0x98, 2, 2, "3DSTATE_DEFAULT_Z" },
+       { 0x97, 2, 2, "3DSTATE_DEPTH_OFFSET_SCALE" },
+       { 0x85, 2, 2, "3DSTATE_DEST_BUFFER_VARIABLES" },
+       { 0x80, 5, 5, "3DSTATE_DRAWING_RECTANGLE" },
+       { 0x8e, 3, 3, "3DSTATE_BUFFER_INFO" },
+       { 0x9d, 65, 65, "3DSTATE_FILTER_COEFFICIENTS_4X4" },
+       { 0x9e, 4, 4, "3DSTATE_MONO_FILTER" },
+       { 0x89, 4, 4, "3DSTATE_FOG_MODE" },
+       { 0x8f, 2, 16, "3DSTATE_MAP_PALLETE_LOAD_32" },
+       { 0x81, 3, 3, "3DSTATE_SCISSOR_RECTANGLE" },
+       { 0x83, 2, 2, "3DSTATE_SPAN_STIPPLE" },
+    };
+
+    switch ((data[0] & 0x00ff0000) >> 16) {
+    case 0x07:
+       /* This instruction is unusual.  A 0 length means just 1 DWORD instead of
+        * 2.  The 0 length is specified in one place to be unsupported, but
+        * stated to be required in another, and 0 length LOAD_INDIRECTs appear
+        * to cause no harm at least.
+        */
+       instr_out(data, hw_offset, 0, "3DSTATE_LOAD_INDIRECT\n");
+       len = (data[0] & 0x000000ff) + 1;
+       i = 1;
+       if (data[0] & (0x01 << 8)) {
+           if (i + 2 >= count)
+               BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
+           instr_out(data, hw_offset, i++, "SIS.0\n");
+           instr_out(data, hw_offset, i++, "SIS.1\n");
+       }
+       if (data[0] & (0x02 << 8)) {
+           if (i + 1 >= count)
+               BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
+           instr_out(data, hw_offset, i++, "DIS.0\n");
+       }
+       if (data[0] & (0x04 << 8)) {
+           if (i + 2 >= count)
+               BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
+           instr_out(data, hw_offset, i++, "SSB.0\n");
+           instr_out(data, hw_offset, i++, "SSB.1\n");
+       }
+       if (data[0] & (0x08 << 8)) {
+           if (i + 2 >= count)
+               BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
+           instr_out(data, hw_offset, i++, "MSB.0\n");
+           instr_out(data, hw_offset, i++, "MSB.1\n");
+       }
+       if (data[0] & (0x10 << 8)) {
+           if (i + 2 >= count)
+               BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
+           instr_out(data, hw_offset, i++, "PSP.0\n");
+           instr_out(data, hw_offset, i++, "PSP.1\n");
+       }
+       if (data[0] & (0x20 << 8)) {
+           if (i + 2 >= count)
+               BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
+           instr_out(data, hw_offset, i++, "PSC.0\n");
+           instr_out(data, hw_offset, i++, "PSC.1\n");
+       }
+       if (len != i) {
+           fprintf(out, "Bad count in 3DSTATE_LOAD_INDIRECT\n");
+           (*failures)++;
+           return len;
+       }
+       return len;
+    case 0x04:
+       instr_out(data, hw_offset, 0, "3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
+       len = (data[0] & 0x0000000f) + 2;
+       i = 1;
+       for (word = 0; word <= 7; word++) {
+           if (data[0] & (1 << (4 + word))) {
+               if (i >= count)
+                   BUFFER_FAIL(count, len, "3DSTATE_LOAD_STATE_IMMEDIATE_1");
+
+               /* save vertex state for decode */
+               if (word == 2) {
+                   saved_s2_set = 1;
+                   saved_s2 = data[i];
+               }
+               if (word == 4) {
+                   saved_s4_set = 1;
+                   saved_s4 = data[i];
+               }
+
+               instr_out(data, hw_offset, i++, "S%d\n", word);
+           }
+       }
+       if (len != i) {
+           fprintf(out, "Bad count in 3DSTATE_LOAD_INDIRECT\n");
+           (*failures)++;
+       }
+       return len;
+    case 0x00:
+       instr_out(data, hw_offset, 0, "3DSTATE_MAP_STATE\n");
+       len = (data[0] & 0x0000003f) + 2;
+
+       i = 1;
+       for (map = 0; map <= 15; map++) {
+           if (data[1] & (1 << map)) {
+               if (i + 3 >= count)
+                   BUFFER_FAIL(count, len, "3DSTATE_MAP_STATE");
+               instr_out(data, hw_offset, i++, "map %d MS2\n", map);
+               instr_out(data, hw_offset, i++, "map %d MS3\n", map);
+               instr_out(data, hw_offset, i++, "map %d MS4\n", map);
+           }
+       }
+       if (len != i) {
+           fprintf(out, "Bad count in 3DSTATE_MAP_STATE\n");
+           (*failures)++;
+           return len;
+       }
+       return len;
+    case 0x06:
+       instr_out(data, hw_offset, 0, "3DSTATE_PIXEL_SHADER_CONSTANTS\n");
+       len = (data[0] & 0x000000ff) + 2;
+
+       i = 1;
+       for (c = 0; c <= 31; c++) {
+           if (data[1] & (1 << c)) {
+               if (i + 4 >= count)
+                   BUFFER_FAIL(count, len, "3DSTATE_PIXEL_SHADER_CONSTANTS");
+               instr_out(data, hw_offset, i, "C%d.X = %f\n",
+                         c, int_as_float(data[i]));
+               i++;
+               instr_out(data, hw_offset, i, "C%d.Y = %f\n",
+                         c, int_as_float(data[i]));
+               i++;
+               instr_out(data, hw_offset, i, "C%d.Z = %f\n",
+                         c, int_as_float(data[i]));
+               i++;
+               instr_out(data, hw_offset, i, "C%d.W = %f\n",
+                         c, int_as_float(data[i]));
+               i++;
+           }
+       }
+       if (len != i) {
+           fprintf(out, "Bad count in 3DSTATE_MAP_STATE\n");
+           (*failures)++;
+       }
+       return len;
+    case 0x05:
+       instr_out(data, hw_offset, 0, "3DSTATE_PIXEL_SHADER_PROGRAM\n");
+       len = (data[0] & 0x000000ff) + 2;
+       if ((len - 1) % 3 != 0 || len > 370) {
+           fprintf(out, "Bad count in 3DSTATE_PIXEL_SHADER_PROGRAM\n");
+           (*failures)++;
+       }
+       i = 1;
+       for (instr = 0; instr < (len - 1) / 3; instr++) {
+           if (i + 3 >= count)
+               BUFFER_FAIL(count, len, "3DSTATE_MAP_STATE");
+           instr_out(data, hw_offset, i++, "PS%03x\n", instr);
+           instr_out(data, hw_offset, i++, "PS%03x\n", instr);
+           instr_out(data, hw_offset, i++, "PS%03x\n", instr);
+       }
+       return len;
+    case 0x01:
+       instr_out(data, hw_offset, 0, "3DSTATE_SAMPLER_STATE\n");
+       len = (data[0] & 0x0000003f) + 2;
+       i = 1;
+       for (sampler = 0; sampler <= 15; sampler++) {
+           if (data[1] & (1 << sampler)) {
+               if (i + 3 >= count)
+                   BUFFER_FAIL(count, len, "3DSTATE_SAMPLER_STATE");
+               instr_out(data, hw_offset, i++, "sampler %d SS2\n",
+                         sampler);
+               instr_out(data, hw_offset, i++, "sampler %d SS3\n",
+                         sampler);
+               instr_out(data, hw_offset, i++, "sampler %d SS4\n",
+                         sampler);
+           }
+       }
+       if (len != i) {
+           fprintf(out, "Bad count in 3DSTATE_SAMPLER_STATE\n");
+           (*failures)++;
+       }
+       return len;
+    }
+
+    for (opcode = 0; opcode < sizeof(opcodes_3d_1d) / sizeof(opcodes_3d_1d[0]);
+        opcode++)
+    {
+       if (((data[0] & 0x00ff0000) >> 16) == opcodes_3d_1d[opcode].opcode) {
+           len = 1;
+
+           instr_out(data, hw_offset, 0, "%s\n", opcodes_3d_1d[opcode].name);
+           if (opcodes_3d_1d[opcode].max_len > 1) {
+               len = (data[0] & 0x0000ffff) + 2;
+               if (len < opcodes_3d_1d[opcode].min_len ||
+                   len > opcodes_3d_1d[opcode].max_len)
+               {
+                   fprintf(out, "Bad count in %s\n",
+                           opcodes_3d_1d[opcode].name);
+                   (*failures)++;
+               }
+           }
+
+           for (i = 1; i < len; i++) {
+               if (i >= count)
+                   BUFFER_FAIL(count, len,  opcodes_3d_1d[opcode].name);
+               instr_out(data, hw_offset, i, "dword %d\n", i);
+           }
+
+           return len;
+       }
+    }
+
+    instr_out(data, hw_offset, 0, "3D UNKNOWN\n");
+    (*failures)++;
+    return 1;
+}
+
+static int
+decode_3d_primitive(uint32_t *data, int count, uint32_t hw_offset,
+                   int *failures)
+{
+    char immediate = (data[0] & (1 << 23)) == 0;
+    unsigned int len, i;
+    char *primtype;
+
+    switch ((data[0] >> 18) & 0xf) {
+    case 0x0: primtype = "TRILIST"; break;
+    case 0x1: primtype = "TRISTRIP"; break;
+    case 0x2: primtype = "TRISTRIP_REVERSE"; break;
+    case 0x3: primtype = "TRIFAN"; break;
+    case 0x4: primtype = "POLYGON"; break;
+    case 0x5: primtype = "LINELIST"; break;
+    case 0x6: primtype = "LINESTRIP"; break;
+    case 0x7: primtype = "RECTLIST"; break;
+    case 0x8: primtype = "POINTLIST"; break;
+    case 0x9: primtype = "DIB"; break;
+    case 0xa: primtype = "CLEAR_RECT"; break;
+    default: primtype = "unknown"; break;
+    }
+
+    /* XXX: 3DPRIM_DIB not supported */
+    if (immediate) {
+       len = (data[0] & 0x0003ffff) + 2;
+       instr_out(data, hw_offset, 0, "3DPRIMITIVE inline %s\n", primtype);
+       if (count < len)
+           BUFFER_FAIL(count, len,  "3DPRIMITIVE inline");
+       if (!saved_s2_set || !saved_s4_set) {
+           fprintf(out, "unknown vertex format\n");
+           for (i = 1; i < len; i++) {
+               instr_out(data, hw_offset, i,
+                         "           vertex data (%f float)\n",
+                         int_as_float(data[i]));
+           }
+       } else {
+           unsigned int vertex = 0;
+           for (i = 1; i < len;) {
+               unsigned int tc;
+
+#define VERTEX_OUT(fmt, ...) do {                                      \
+    if (i < len)                                                       \
+       instr_out(data, hw_offset, i, " V%d."fmt"\n", vertex, __VA_ARGS__); \
+    else                                                               \
+       fprintf(out, " missing data in V%d\n", vertex);                 \
+    i++;                                                               \
+} while (0)
+
+               VERTEX_OUT("X = %f", int_as_float(data[i]));
+               VERTEX_OUT("Y = %f", int_as_float(data[i]));
+               switch (saved_s4 >> 6 & 0x7) {
+               case 0x1:
+                   VERTEX_OUT("Z = %f", int_as_float(data[i]));
+                   break;
+               case 0x2:
+                   VERTEX_OUT("Z = %f", int_as_float(data[i]));
+                   VERTEX_OUT("W = %f", int_as_float(data[i]));
+                   break;
+               case 0x3:
+                   break;
+               case 0x4:
+                   VERTEX_OUT("W = %f", int_as_float(data[i]));
+                   break;
+               default:
+                   fprintf(out, "bad S4 position mask\n");
+               }
+
+               if (saved_s4 & (1 << 10)) {
+                   VERTEX_OUT("color = (A=0x%02x, R=0x%02x, G=0x%02x, "
+                              "B=0x%02x)",
+                              data[i] >> 24,
+                              (data[i] >> 16) & 0xff,
+                              (data[i] >> 8) & 0xff,
+                              data[i] & 0xff);
+               }
+               if (saved_s4 & (1 << 11)) {
+                   VERTEX_OUT("spec = (A=0x%02x, R=0x%02x, G=0x%02x, "
+                              "B=0x%02x)",
+                              data[i] >> 24,
+                              (data[i] >> 16) & 0xff,
+                              (data[i] >> 8) & 0xff,
+                              data[i] & 0xff);
+               }
+               if (saved_s4 & (1 << 12))
+                   VERTEX_OUT("width = 0x%08x)", data[i]);
+
+               for (tc = 0; tc <= 7; tc++) {
+                   switch ((saved_s2 >> (tc * 4)) & 0xf) {
+                   case 0x0:
+                       VERTEX_OUT("T%d.X = %f", tc, int_as_float(data[i]));
+                       VERTEX_OUT("T%d.Y = %f", tc, int_as_float(data[i]));
+                       break;
+                   case 0x1:
+                       VERTEX_OUT("T%d.X = %f", tc, int_as_float(data[i]));
+                       VERTEX_OUT("T%d.Y = %f", tc, int_as_float(data[i]));
+                       VERTEX_OUT("T%d.Z = %f", tc, int_as_float(data[i]));
+                       break;
+                   case 0x2:
+                       VERTEX_OUT("T%d.X = %f", tc, int_as_float(data[i]));
+                       VERTEX_OUT("T%d.Y = %f", tc, int_as_float(data[i]));
+                       VERTEX_OUT("T%d.Z = %f", tc, int_as_float(data[i]));
+                       VERTEX_OUT("T%d.W = %f", tc, int_as_float(data[i]));
+                       break;
+                   case 0x3:
+                       VERTEX_OUT("T%d.X = %f", tc, int_as_float(data[i]));
+                       break;
+                   case 0x4:
+                       VERTEX_OUT("T%d.XY = 0x%08x half-float", tc, data[i]);
+                       break;
+                   case 0x5:
+                       VERTEX_OUT("T%d.XY = 0x%08x half-float", tc, data[i]);
+                       VERTEX_OUT("T%d.ZW = 0x%08x half-float", tc, data[i]);
+                       break;
+                   case 0xf:
+                       break;
+                   default:
+                       fprintf(out, "bad S2.T%d format\n", tc);
+                   }
+               }
+               vertex++;
+           }
+       }
+    } else {
+       /* indirect vertices */
+       len = data[0] & 0x0000ffff; /* index count */
+       if (data[0] & (1 << 17)) {
+           /* random vertex access */
+           if (count < (len + 1) / 2 + 1) {
+               BUFFER_FAIL(count, (len + 1) / 2 + 1,
+                           "3DPRIMITIVE random indirect");
+           }
+           instr_out(data, hw_offset, 0,
+                     "3DPRIMITIVE random indirect %s (%d)\n", primtype, len);
+           if (len == 0) {
+               /* vertex indices continue until 0xffff is found */
+               for (i = 1; i < count; i++) {
+                   if ((data[i] & 0xffff) == 0xffff) {
+                       instr_out(data, hw_offset, i,
+                                 "            indices: (terminator)\n");
+                       return i;
+                   } else if ((data[i] >> 16) == 0xffff) {
+                       instr_out(data, hw_offset, i,
+                                 "            indices: 0x%04x, "
+                                 "(terminator)\n",
+                                 data[i] & 0xffff);
+                       return i;
+                   } else {
+                       instr_out(data, hw_offset, i,
+                                 "            indices: 0x%04x, 0x%04x\n",
+                                 data[i] & 0xffff, data[i] >> 16);
+                   }
+               }
+               fprintf(out,
+                       "3DPRIMITIVE: no terminator found in index buffer\n");
+               (*failures)++;
+               return count;
+           } else {
+               /* fixed size vertex index buffer */
+               for (i = 0; i < len; i += 2) {
+                   if (i * 2 == len - 1) {
+                       instr_out(data, hw_offset, i,
+                                 "            indices: 0x%04x\n",
+                                 data[i] & 0xffff);
+                   } else {
+                       instr_out(data, hw_offset, i,
+                                 "            indices: 0x%04x, 0x%04x\n",
+                                 data[i] & 0xffff, data[i] >> 16);
+                   }
+               }
+           }
+           return (len + 1) / 2 + 1;
+       } else {
+           /* sequential vertex access */
+           if (count < 2)
+               BUFFER_FAIL(count, 2, "3DPRIMITIVE seq indirect");
+           instr_out(data, hw_offset, 0,
+                     "3DPRIMITIVE sequential indirect %s, %d starting from "
+                     "%d\n", primtype, len, data[1] & 0xffff);
+           instr_out(data, hw_offset, 1, "           start\n");
+           return 2;
+       }
+    }
+
+    return len;
+}
+
+static int
+decode_3d(uint32_t *data, int count, uint32_t hw_offset, int *failures)
+{
+    unsigned int opcode;
+
+    struct {
+       uint32_t opcode;
+       int min_len;
+       int max_len;
+       char *name;
+    } opcodes_3d[] = {
+       { 0x06, 1, 1, "3DSTATE_ANTI_ALIASING" },
+       { 0x08, 1, 1, "3DSTATE_BACKFACE_STENCIL_OPS" },
+       { 0x09, 1, 1, "3DSTATE_BACKFACE_STENCIL_MASKS" },
+       { 0x16, 1, 1, "3DSTATE_COORD_SET_BINDINGS" },
+       { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
+       { 0x0b, 1, 1, "3DSTATE_INDEPENDENT_ALPHA_BLEND" },
+       { 0x0d, 1, 1, "3DSTATE_MODES_4" },
+       { 0x0c, 1, 1, "3DSTATE_MODES_5" },
+       { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES" },
+    };
+
+    switch ((data[0] & 0x1f000000) >> 24) {
+    case 0x1f:
+       return decode_3d_primitive(data, count, hw_offset, failures);
+    case 0x1d:
+       return decode_3d_1d(data, count, hw_offset, failures);
+    case 0x1c:
+       return decode_3d_1c(data, count, hw_offset, failures);
+    }
+
+    for (opcode = 0; opcode < sizeof(opcodes_3d) / sizeof(opcodes_3d[0]);
+        opcode++) {
+       if ((data[0] & 0x1f000000) >> 24 == opcodes_3d[opcode].opcode) {
+           unsigned int len = 1, i;
+
+           instr_out(data, hw_offset, 0, "%s\n", opcodes_3d[opcode].name);
+           if (opcodes_3d[opcode].max_len > 1) {
+               len = (data[0] & 0xff) + 2;
+               if (len < opcodes_3d[opcode].min_len ||
+                   len > opcodes_3d[opcode].max_len)
+               {
+                   fprintf(out, "Bad count in %s\n", opcodes_3d[opcode].name);
+               }
+           }
+
+           for (i = 1; i < len; i++) {
+               if (i >= count)
+                   BUFFER_FAIL(count, len, opcodes_3d[opcode].name);
+               instr_out(data, hw_offset, i, "dword %d\n", i);
+           }
+           return len;
+       }
+    }
+
+    instr_out(data, hw_offset, 0, "3D UNKNOWN\n");
+    (*failures)++;
+    return 1;
+}
+
+static const char *
+get_965_surfacetype(unsigned int surfacetype)
+{
+    switch (surfacetype) {
+    case 0: return "1D";
+    case 1: return "2D";
+    case 2: return "3D";
+    case 3: return "CUBE";
+    case 4: return "BUFFER";
+    case 7: return "NULL";
+    default: return "unknown";
+    }
+}
+
+static const char *
+get_965_depthformat(unsigned int depthformat)
+{
+    switch (depthformat) {
+    case 0: return "s8_z24float";
+    case 1: return "z32float";
+    case 2: return "z24s8";
+    case 5: return "z16";
+    default: return "unknown";
+    }
+}
+
+static int
+decode_3d_965(uint32_t *data, int count, uint32_t hw_offset, int *failures)
+{
+    unsigned int opcode, len;
+
+    struct {
+       uint32_t opcode;
+       int min_len;
+       int max_len;
+       char *name;
+    } opcodes_3d[] = {
+       { 0x6000, 3, 3, "URB_FENCE" },
+       { 0x6001, 2, 2, "CS_URB_STATE" },
+       { 0x6002, 2, 2, "CONSTANT_BUFFER" },
+       { 0x6101, 6, 6, "STATE_BASE_ADDRESS" },
+       { 0x6102, 2, 2 , "STATE_SIP" },
+       { 0x6104, 1, 1, "3DSTATE_PIPELINE_SELECT" },
+       { 0x680b, 1, 1, "3DSTATE_VF_STATISTICS" },
+       { 0x6904, 1, 1, "3DSTATE_PIPELINE_SELECT" },
+       { 0x7800, 7, 7, "3DSTATE_PIPELINED_POINTERS" },
+       { 0x7801, 6, 6, "3DSTATE_BINDING_TABLE_POINTERS" },
+       { 0x780b, 1, 1, "3DSTATE_VF_STATISTICS" },
+       { 0x7808, 5, 257, "3DSTATE_VERTEX_BUFFERS" },
+       { 0x7809, 3, 256, "3DSTATE_VERTEX_ELEMENTS" },
+       /* 0x7808: 3DSTATE_VERTEX_BUFFERS */
+       /* 0x7809: 3DSTATE_VERTEX_ELEMENTS */
+       { 0x7900, 4, 4, "3DSTATE_DRAWING_RECTANGLE" },
+       { 0x7901, 5, 5, "3DSTATE_CONSTANT_COLOR" },
+       { 0x7905, 5, 7, "3DSTATE_DEPTH_BUFFER" },
+       { 0x7906, 2, 2, "3DSTATE_POLY_STIPPLE_OFFSET" },
+       { 0x7907, 33, 33, "3DSTATE_POLY_STIPPLE_PATTERN" },
+       { 0x7908, 3, 3, "3DSTATE_LINE_STIPPLE" },
+       { 0x7909, 2, 2, "3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP" },
+       { 0x790a, 3, 3, "3DSTATE_AA_LINE_PARAMETERS" },
+       { 0x7b00, 6, 6, "3DPRIMITIVE" },
+    };
+
+    len = (data[0] & 0x0000ffff) + 2;
+
+    switch ((data[0] & 0xffff0000) >> 16) {
+    case 0x6101:
+       if (len != 6)
+           fprintf(out, "Bad count in STATE_BASE_ADDRESS\n");
+       if (count < 6)
+           BUFFER_FAIL(count, len, "STATE_BASE_ADDRESS");
+
+       instr_out(data, hw_offset, 0,
+                 "STATE_BASE_ADDRESS\n");
+
+       if (data[1] & 1) {
+           instr_out(data, hw_offset, 1, "General state at 0x%08x\n",
+                     data[1] & ~1);
+       } else
+           instr_out(data, hw_offset, 1, "General state not updated\n");
+
+       if (data[2] & 1) {
+           instr_out(data, hw_offset, 2, "Surface state at 0x%08x\n",
+                     data[2] & ~1);
+       } else
+           instr_out(data, hw_offset, 2, "Surface state not updated\n");
+
+       if (data[3] & 1) {
+           instr_out(data, hw_offset, 3, "Indirect state at 0x%08x\n",
+                     data[3] & ~1);
+       } else
+           instr_out(data, hw_offset, 3, "Indirect state not updated\n");
+
+       if (data[4] & 1) {
+           instr_out(data, hw_offset, 4, "General state upper bound 0x%08x\n",
+                     data[4] & ~1);
+       } else
+           instr_out(data, hw_offset, 4, "General state not updated\n");
+
+       if (data[5] & 1) {
+           instr_out(data, hw_offset, 5, "Indirect state upper bound 0x%08x\n",
+                     data[5] & ~1);
+       } else
+           instr_out(data, hw_offset, 5, "Indirect state not updated\n");
+
+       return len;
+    case 0x7800:
+       if (len != 7)
+           fprintf(out, "Bad count in 3DSTATE_PIPELINED_POINTERS\n");
+       if (count < 7)
+           BUFFER_FAIL(count, len, "3DSTATE_PIPELINED_POINTERS");
+
+       instr_out(data, hw_offset, 0,
+                 "3DSTATE_PIPELINED_POINTERS\n");
+       instr_out(data, hw_offset, 1, "VS state\n");
+       instr_out(data, hw_offset, 2, "GS state\n");
+       instr_out(data, hw_offset, 3, "Clip state\n");
+       instr_out(data, hw_offset, 4, "SF state\n");
+       instr_out(data, hw_offset, 5, "WM state\n");
+       instr_out(data, hw_offset, 6, "CC state\n");
+       return len;
+    case 0x7801:
+       if (len != 6)
+           fprintf(out, "Bad count in 3DSTATE_BINDING_TABLE_POINTERS\n");
+       if (count < 6)
+           BUFFER_FAIL(count, len, "3DSTATE_BINDING_TABLE_POINTERS");
+
+       instr_out(data, hw_offset, 0,
+                 "3DSTATE_BINDING_TABLE_POINTERS\n");
+       instr_out(data, hw_offset, 1, "VS binding table\n");
+       instr_out(data, hw_offset, 2, "GS binding table\n");
+       instr_out(data, hw_offset, 3, "Clip binding table\n");
+       instr_out(data, hw_offset, 4, "SF binding table\n");
+       instr_out(data, hw_offset, 5, "WM binding table\n");
+
+       return len;
+
+    case 0x7900:
+       if (len != 4)
+           fprintf(out, "Bad count in 3DSTATE_DRAWING_RECTANGLE\n");
+       if (count < 4)
+           BUFFER_FAIL(count, len, "3DSTATE_DRAWING_RECTANGLE");
+
+       instr_out(data, hw_offset, 0,
+                 "3DSTATE_DRAWING_RECTANGLE\n");
+       instr_out(data, hw_offset, 1, "top left: %d,%d\n",
+                 data[1] & 0xffff,
+                 (data[1] >> 16) & 0xffff);
+       instr_out(data, hw_offset, 2, "bottom right: %d,%d\n",
+                 data[2] & 0xffff,
+                 (data[2] >> 16) & 0xffff);
+       instr_out(data, hw_offset, 3, "origin: %d,%d\n",
+                 (int)data[3] & 0xffff,
+                 ((int)data[3] >> 16) & 0xffff);
+
+       return len;
+
+    case 0x7905:
+       if (len != 5)
+           fprintf(out, "Bad count in 3DSTATE_DEPTH_BUFFER\n");
+       if (count < 5)
+           BUFFER_FAIL(count, len, "3DSTATE_DEPTH_BUFFER");
+
+       instr_out(data, hw_offset, 0,
+                 "3DSTATE_DEPTH_BUFFER\n");
+       instr_out(data, hw_offset, 1, "%s, %s, pitch = %d bytes, %stiled\n",
+                 get_965_surfacetype(data[1] >> 29),
+                 get_965_depthformat((data[1] >> 18) & 0x7),
+                 (data[1] & 0x0001ffff) + 1,
+                 data[1] & (1 << 27) ? "" : "not ");
+       instr_out(data, hw_offset, 2, "depth offset\n");
+       instr_out(data, hw_offset, 3, "%dx%d\n",
+                 ((data[3] & 0x0007ffc0) >> 6) + 1,
+                 ((data[3] & 0xfff80000) >> 19) + 1);
+       instr_out(data, hw_offset, 4, "volume depth\n");
+
+       return len;
+    }
+
+    for (opcode = 0; opcode < sizeof(opcodes_3d) / sizeof(opcodes_3d[0]);
+        opcode++) {
+       if ((data[0] & 0xffff0000) >> 16 == opcodes_3d[opcode].opcode) {
+           unsigned int i;
+           len = 1;
+
+           instr_out(data, hw_offset, 0, "%s\n", opcodes_3d[opcode].name);
+           if (opcodes_3d[opcode].max_len > 1) {
+               len = (data[0] & 0xff) + 2;
+               if (len < opcodes_3d[opcode].min_len ||
+                   len > opcodes_3d[opcode].max_len)
+               {
+                   fprintf(out, "Bad count in %s\n", opcodes_3d[opcode].name);
+               }
+           }
+
+           for (i = 1; i < len; i++) {
+               if (i >= count)
+                   BUFFER_FAIL(count, len, opcodes_3d[opcode].name);
+               instr_out(data, hw_offset, i, "dword %d\n", i);
+           }
+           return len;
+       }
+    }
+
+    instr_out(data, hw_offset, 0, "3D UNKNOWN\n");
+    (*failures)++;
+    return 1;
+}
+
+/**
+ * Decodes an i830-i915 batch buffer, writing the output to stdout.
+ *
+ * \param data batch buffer contents
+ * \param count number of DWORDs to decode in the batch buffer
+ * \param hw_offset hardware address for the buffer
+ */
+int
+intel_decode(uint32_t *data, int count, uint32_t hw_offset, uint32_t devid)
+{
+    int index = 0;
+    int failures = 0;
+
+    out = stderr;
+
+    while (index < count) {
+       switch ((data[index] & 0xe0000000) >> 29) {
+       case 0x0:
+           index += decode_mi(data + index, count - index,
+                              hw_offset + index * 4, &failures);
+           break;
+       case 0x2:
+           index += decode_2d(data + index, count - index,
+                              hw_offset + index * 4, &failures);
+           break;
+       case 0x3:
+           if (IS_965(devid)) {
+               index += decode_3d_965(data + index, count - index,
+                                      hw_offset + index * 4, &failures);
+           } else {
+               index += decode_3d(data + index, count - index,
+                                  hw_offset + index * 4, &failures);
+           }
+           break;
+       default:
+           instr_out(data, hw_offset, index, "UNKNOWN\n");
+           failures++;
+           index++;
+           break;
+       }
+       fflush(out);
+    }
+
+    return failures;
+}
+
+void intel_decode_context_reset(void)
+{
+    saved_s2_set = 0;
+    saved_s4_set = 1;
+}
+
diff --git a/src/mesa/drivers/dri/intel/intel_decode.h b/src/mesa/drivers/dri/intel/intel_decode.h
new file mode 100644 (file)
index 0000000..c50644a
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright Â© 2007 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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:
+ *    Eric Anholt <eric@anholt.net>
+ *
+ */
+
+int intel_decode(uint32_t *data, int count, uint32_t hw_offset, uint32_t devid);
+void intel_decode_context_reset(void);
diff --git a/src/mesa/drivers/dri/intel/intel_depthstencil.c b/src/mesa/drivers/dri/intel/intel_depthstencil.c
new file mode 100644 (file)
index 0000000..70ba68e
--- /dev/null
@@ -0,0 +1,252 @@
+/**************************************************************************
+ * 
+ * Copyright 2006 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 "imports.h"
+#include "context.h"
+#include "depthstencil.h"
+#include "fbobject.h"
+#include "framebuffer.h"
+#include "hash.h"
+#include "mtypes.h"
+#include "renderbuffer.h"
+
+#include "intel_context.h"
+#include "intel_fbo.h"
+#include "intel_depthstencil.h"
+#include "intel_regions.h"
+#include "intel_span.h"
+
+/**
+ * The GL_EXT_framebuffer_object allows the user to create their own
+ * framebuffer objects consisting of color renderbuffers (0 or more),
+ * depth renderbuffers (0 or 1) and stencil renderbuffers (0 or 1).
+ *
+ * The spec considers depth and stencil renderbuffers to be totally independent
+ * buffers.  In reality, most graphics hardware today uses a combined
+ * depth+stencil buffer (one 32-bit pixel = 24 bits of Z + 8 bits of stencil).
+ *
+ * This causes difficulty because the user may create some number of depth
+ * renderbuffers and some number of stencil renderbuffers and bind them
+ * together in framebuffers in any combination.
+ *
+ * This code manages all that.
+ *
+ * 1. Depth renderbuffers are always allocated in hardware as 32bpp
+ *    GL_DEPTH24_STENCIL8 buffers.
+ *
+ * 2. Stencil renderbuffers are initially allocated in software as 8bpp
+ *    GL_STENCIL_INDEX8 buffers.
+ *
+ * 3. Depth and Stencil renderbuffers use the PairedStencil and PairedDepth
+ *    fields (respectively) to indicate if the buffer's currently paired
+ *    with another stencil or depth buffer (respectively).
+ *
+ * 4. When a depth and stencil buffer are initially both attached to the
+ *    current framebuffer, we merge the stencil buffer values into the
+ *    depth buffer (really a depth+stencil buffer).  The then hardware uses
+ *    the combined buffer.
+ *
+ * 5. Whenever a depth or stencil buffer is reallocated (with
+ *    glRenderbufferStorage) we undo the pairing and copy the stencil values
+ *    from the combined depth/stencil buffer back to the stencil-only buffer.
+ *
+ * 6. We also undo the pairing when we find a change in buffer bindings.
+ *
+ * 7. If a framebuffer is only using a depth renderbuffer (no stencil), we
+ *    just use the combined depth/stencil buffer and ignore the stencil values.
+ *
+ * 8. If a framebuffer is only using a stencil renderbuffer (no depth) we have
+ *    to promote the 8bpp software stencil buffer to a 32bpp hardware
+ *    depth+stencil buffer.
+ *
+ */
+
+/**
+ * Undo the pairing/interleaving between depth and stencil buffers.
+ * irb should be a depth/stencil or stencil renderbuffer.
+ */
+void
+intel_unpair_depth_stencil(GLcontext *ctx, struct intel_renderbuffer *irb)
+{
+   struct intel_context *intel = intel_context(ctx);
+   struct gl_renderbuffer *rb = &irb->Base;
+
+   if (irb->PairedStencil) {
+      /* irb is a depth/stencil buffer */
+      struct gl_renderbuffer *stencilRb;
+      struct intel_renderbuffer *stencilIrb;
+
+      ASSERT(rb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+
+      stencilRb = _mesa_lookup_renderbuffer(ctx, irb->PairedStencil);
+      stencilIrb = intel_renderbuffer(stencilRb);
+      if (stencilIrb) {
+         /* need to extract stencil values from the depth buffer */
+        ASSERT(stencilIrb->PairedDepth == rb->Name);
+        intel_renderbuffer_map(intel, rb);
+        intel_renderbuffer_map(intel, stencilRb);
+        _mesa_extract_stencil(ctx, rb, stencilRb);
+        intel_renderbuffer_unmap(intel, stencilRb);
+        intel_renderbuffer_unmap(intel, rb);
+         stencilIrb->PairedDepth = 0;
+      }
+      irb->PairedStencil = 0;
+   }
+   else if (irb->PairedDepth) {
+      /* irb is a stencil buffer */
+      struct gl_renderbuffer *depthRb;
+      struct intel_renderbuffer *depthIrb;
+
+      ASSERT(rb->_ActualFormat == GL_STENCIL_INDEX8_EXT ||
+             rb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+
+      depthRb = _mesa_lookup_renderbuffer(ctx, irb->PairedDepth);
+      depthIrb = intel_renderbuffer(depthRb);
+      if (depthIrb) {
+         /* need to extract stencil values from the depth buffer */
+        ASSERT(depthIrb->PairedStencil == rb->Name);
+        intel_renderbuffer_map(intel, rb);
+        intel_renderbuffer_map(intel, depthRb);
+        _mesa_extract_stencil(ctx, depthRb, rb);
+        intel_renderbuffer_unmap(intel, depthRb);
+        intel_renderbuffer_unmap(intel, rb);
+         depthIrb->PairedStencil = 0;
+      }
+      irb->PairedDepth = 0;
+   }
+   else {
+      _mesa_problem(ctx, "Problem in undo_depth_stencil_pairing");
+   }
+
+   ASSERT(irb->PairedStencil == 0);
+   ASSERT(irb->PairedDepth == 0);
+}
+
+
+/**
+ * Examine the depth and stencil renderbuffers which are attached to the
+ * framebuffer.  If both depth and stencil are attached, make sure that the
+ * renderbuffers are 'paired' (combined).  If only depth or only stencil is
+ * attached, undo any previous pairing.
+ *
+ * Must be called if NewState & _NEW_BUFFER (when renderbuffer attachments
+ * change, for example).
+ */
+void
+intel_validate_paired_depth_stencil(GLcontext * ctx,
+                                    struct gl_framebuffer *fb)
+{
+   struct intel_context *intel = intel_context(ctx);
+   struct intel_renderbuffer *depthRb, *stencilRb;
+
+   depthRb = intel_get_renderbuffer(fb, BUFFER_DEPTH);
+   stencilRb = intel_get_renderbuffer(fb, BUFFER_STENCIL);
+
+   if (depthRb && stencilRb) {
+      if (depthRb == stencilRb) {
+         /* Using a user-created combined depth/stencil buffer.
+          * Nothing to do.
+          */
+         ASSERT(depthRb->Base._BaseFormat == GL_DEPTH_STENCIL_EXT);
+         ASSERT(depthRb->Base._ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+      }
+      else {
+         /* Separate depth/stencil buffers, need to interleave now */
+         ASSERT(depthRb->Base._BaseFormat == GL_DEPTH_COMPONENT);
+         ASSERT(stencilRb->Base._BaseFormat == GL_STENCIL_INDEX);
+         /* may need to interleave depth/stencil now */
+         if (depthRb->PairedStencil == stencilRb->Base.Name) {
+            /* OK, the depth and stencil buffers are already interleaved */
+            ASSERT(stencilRb->PairedDepth == depthRb->Base.Name);
+         }
+         else {
+            /* need to setup new pairing/interleaving */
+            if (depthRb->PairedStencil) {
+               intel_unpair_depth_stencil(ctx, depthRb);
+            }
+            if (stencilRb->PairedDepth) {
+               intel_unpair_depth_stencil(ctx, stencilRb);
+            }
+
+            ASSERT(depthRb->Base._ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+            ASSERT(stencilRb->Base._ActualFormat == GL_STENCIL_INDEX8_EXT ||
+                   stencilRb->Base._ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+
+            /* establish new pairing: interleave stencil into depth buffer */
+           intel_renderbuffer_map(intel, &depthRb->Base);
+           intel_renderbuffer_map(intel, &stencilRb->Base);
+            _mesa_insert_stencil(ctx, &depthRb->Base, &stencilRb->Base);
+           intel_renderbuffer_unmap(intel, &stencilRb->Base);
+           intel_renderbuffer_unmap(intel, &depthRb->Base);
+            depthRb->PairedStencil = stencilRb->Base.Name;
+            stencilRb->PairedDepth = depthRb->Base.Name;
+         }
+
+      }
+   }
+   else if (depthRb) {
+      /* Depth buffer but no stencil buffer.
+       * We'll use a GL_DEPTH24_STENCIL8 buffer and ignore the stencil bits.
+       */
+      /* can't assert this until storage is allocated:
+         ASSERT(depthRb->Base._ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+       */
+      /* intel_undo any previous pairing */
+      if (depthRb->PairedStencil) {
+         intel_unpair_depth_stencil(ctx, depthRb);
+      }
+   }
+   else if (stencilRb) {
+      /* Stencil buffer but no depth buffer.
+       * Since h/w doesn't typically support just 8bpp stencil w/out Z,
+       * we'll use a GL_DEPTH24_STENCIL8 buffer and ignore the depth bits.
+       */
+      /* undo any previous pairing */
+      if (stencilRb->PairedDepth) {
+         intel_unpair_depth_stencil(ctx, stencilRb);
+      }
+      if (stencilRb->Base._ActualFormat == GL_STENCIL_INDEX8_EXT) {
+         /* promote buffer to GL_DEPTH24_STENCIL8 for hw rendering */
+         _mesa_promote_stencil(ctx, &stencilRb->Base);
+         ASSERT(stencilRb->Base._ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+      }
+   }
+
+   /* Finally, update the fb->_DepthBuffer and fb->_StencilBuffer fields */
+   _mesa_update_depth_buffer(ctx, fb, BUFFER_DEPTH);
+   if (depthRb && depthRb->PairedStencil)
+      _mesa_update_stencil_buffer(ctx, fb, BUFFER_DEPTH);
+   else
+      _mesa_update_stencil_buffer(ctx, fb, BUFFER_STENCIL);
+
+
+   /* The hardware should use fb->Attachment[BUFFER_DEPTH].Renderbuffer
+    * first, if present, then fb->Attachment[BUFFER_STENCIL].Renderbuffer
+    * if present.
+    */
+}
diff --git a/src/mesa/drivers/dri/intel/intel_depthstencil.h b/src/mesa/drivers/dri/intel/intel_depthstencil.h
new file mode 100644 (file)
index 0000000..740eb0d
--- /dev/null
@@ -0,0 +1,15 @@
+
+#ifndef INTEL_DEPTH_STENCIL_H
+#define INTEL_DEPTH_STENCIL_H
+
+#include "intel_fbo.h"
+
+extern void
+intel_unpair_depth_stencil(GLcontext * ctx, struct intel_renderbuffer *irb);
+
+extern void
+intel_validate_paired_depth_stencil(GLcontext * ctx,
+                                    struct gl_framebuffer *fb);
+
+
+#endif /* INTEL_DEPTH_STENCIL_H */
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
new file mode 100644 (file)
index 0000000..6570f6e
--- /dev/null
@@ -0,0 +1,709 @@
+/**************************************************************************
+ * 
+ * Copyright 2006 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 "imports.h"
+#include "mtypes.h"
+#include "fbobject.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
+#include "context.h"
+#include "texformat.h"
+#include "texrender.h"
+
+#include "intel_context.h"
+#include "intel_buffers.h"
+#include "intel_depthstencil.h"
+#include "intel_fbo.h"
+#include "intel_mipmap_tree.h"
+#include "intel_regions.h"
+#include "intel_span.h"
+
+
+#define FILE_DEBUG_FLAG DEBUG_FBO
+
+#define INTEL_RB_CLASS 0x12345678
+
+
+/* XXX FBO: move this to intel_context.h (inlined) */
+/**
+ * Return a gl_renderbuffer ptr casted to intel_renderbuffer.
+ * NULL will be returned if the rb isn't really an intel_renderbuffer.
+ * This is determiend by checking the ClassID.
+ */
+struct intel_renderbuffer *
+intel_renderbuffer(struct gl_renderbuffer *rb)
+{
+   struct intel_renderbuffer *irb = (struct intel_renderbuffer *) rb;
+   if (irb && irb->Base.ClassID == INTEL_RB_CLASS) {
+      /*_mesa_warning(NULL, "Returning non-intel Rb\n");*/
+      return irb;
+   }
+   else
+      return NULL;
+}
+
+
+struct intel_renderbuffer *
+intel_get_renderbuffer(struct gl_framebuffer *fb, int attIndex)
+{
+   if (attIndex >= 0)
+      return intel_renderbuffer(fb->Attachment[attIndex].Renderbuffer);
+   else
+      return NULL;
+}
+
+
+void
+intel_flip_renderbuffers(struct intel_framebuffer *intel_fb)
+{
+   int current_page = intel_fb->pf_current_page;
+   int next_page = (current_page + 1) % intel_fb->pf_num_pages;
+   struct gl_renderbuffer *tmp_rb;
+
+   /* Exchange renderbuffers if necessary but make sure their reference counts
+    * are preserved.
+    */
+   if (intel_fb->color_rb[current_page] &&
+       intel_fb->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer !=
+       &intel_fb->color_rb[current_page]->Base) {
+      tmp_rb = NULL;
+      _mesa_reference_renderbuffer(&tmp_rb,
+        intel_fb->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
+      tmp_rb = &intel_fb->color_rb[current_page]->Base;
+      _mesa_reference_renderbuffer(
+        &intel_fb->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer, tmp_rb);
+      _mesa_reference_renderbuffer(&tmp_rb, NULL);
+   }
+
+   if (intel_fb->color_rb[next_page] &&
+       intel_fb->Base.Attachment[BUFFER_BACK_LEFT].Renderbuffer !=
+       &intel_fb->color_rb[next_page]->Base) {
+      tmp_rb = NULL;
+      _mesa_reference_renderbuffer(&tmp_rb,
+        intel_fb->Base.Attachment[BUFFER_BACK_LEFT].Renderbuffer);
+      tmp_rb = &intel_fb->color_rb[next_page]->Base;
+      _mesa_reference_renderbuffer(
+        &intel_fb->Base.Attachment[BUFFER_BACK_LEFT].Renderbuffer, tmp_rb);
+      _mesa_reference_renderbuffer(&tmp_rb, NULL);
+   }
+}
+
+
+struct intel_region *
+intel_get_rb_region(struct gl_framebuffer *fb, GLuint attIndex)
+{
+   struct intel_renderbuffer *irb = intel_get_renderbuffer(fb, attIndex);
+
+   if (irb)
+      return irb->region;
+   else
+      return NULL;
+}
+
+
+
+/**
+ * Create a new framebuffer object.
+ */
+static struct gl_framebuffer *
+intel_new_framebuffer(GLcontext * ctx, GLuint name)
+{
+   /* Only drawable state in intel_framebuffer at this time, just use Mesa's
+    * class
+    */
+   return _mesa_new_framebuffer(ctx, name);
+}
+
+
+static void
+intel_delete_renderbuffer(struct gl_renderbuffer *rb)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct intel_context *intel = intel_context(ctx);
+   struct intel_renderbuffer *irb = intel_renderbuffer(rb);
+
+   ASSERT(irb);
+
+   if (irb->PairedStencil || irb->PairedDepth) {
+      intel_unpair_depth_stencil(ctx, irb);
+   }
+
+   if (irb->span_cache != NULL)
+      _mesa_free(irb->span_cache);
+
+   if (intel && irb->region) {
+      intel_region_release(&irb->region);
+   }
+
+   _mesa_free(irb);
+}
+
+
+
+/**
+ * Return a pointer to a specific pixel in a renderbuffer.
+ */
+static void *
+intel_get_pointer(GLcontext * ctx, struct gl_renderbuffer *rb,
+                  GLint x, GLint y)
+{
+   /* By returning NULL we force all software rendering to go through
+    * the span routines.
+    */
+   return NULL;
+}
+
+
+
+/**
+ * Called via glRenderbufferStorageEXT() to set the format and allocate
+ * storage for a user-created renderbuffer.
+ */
+static GLboolean
+intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
+                                 GLenum internalFormat,
+                                 GLuint width, GLuint height)
+{
+   struct intel_context *intel = intel_context(ctx);
+   struct intel_renderbuffer *irb = intel_renderbuffer(rb);
+   GLboolean softwareBuffer = GL_FALSE;
+   int cpp;
+
+   ASSERT(rb->Name != 0);
+
+   switch (internalFormat) {
+   case GL_R3_G3_B2:
+   case GL_RGB4:
+   case GL_RGB5:
+      rb->_ActualFormat = GL_RGB5;
+      rb->DataType = GL_UNSIGNED_BYTE;
+      rb->RedBits = 5;
+      rb->GreenBits = 6;
+      rb->BlueBits = 5;
+      cpp = 2;
+      break;
+   case GL_RGB:
+   case GL_RGB8:
+   case GL_RGB10:
+   case GL_RGB12:
+   case GL_RGB16:
+      rb->_ActualFormat = GL_RGB8;
+      rb->DataType = GL_UNSIGNED_BYTE;
+      rb->RedBits = 8;
+      rb->GreenBits = 8;
+      rb->BlueBits = 8;
+      rb->AlphaBits = 0;
+      cpp = 4;
+      break;
+   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:
+      rb->_ActualFormat = GL_RGBA8;
+      rb->DataType = GL_UNSIGNED_BYTE;
+      rb->RedBits = 8;
+      rb->GreenBits = 8;
+      rb->BlueBits = 8;
+      rb->AlphaBits = 8;
+      cpp = 4;
+      break;
+   case GL_STENCIL_INDEX:
+   case GL_STENCIL_INDEX1_EXT:
+   case GL_STENCIL_INDEX4_EXT:
+   case GL_STENCIL_INDEX8_EXT:
+   case GL_STENCIL_INDEX16_EXT:
+      /* alloc a depth+stencil buffer */
+      rb->_ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+      rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
+      rb->StencilBits = 8;
+      cpp = 4;
+      break;
+   case GL_DEPTH_COMPONENT16:
+      rb->_ActualFormat = GL_DEPTH_COMPONENT16;
+      rb->DataType = GL_UNSIGNED_SHORT;
+      rb->DepthBits = 16;
+      cpp = 2;
+      break;
+   case GL_DEPTH_COMPONENT:
+   case GL_DEPTH_COMPONENT24:
+   case GL_DEPTH_COMPONENT32:
+      rb->_ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+      rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
+      rb->DepthBits = 24;
+      cpp = 4;
+      break;
+   case GL_DEPTH_STENCIL_EXT:
+   case GL_DEPTH24_STENCIL8_EXT:
+      rb->_ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+      rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
+      rb->DepthBits = 24;
+      rb->StencilBits = 8;
+      cpp = 4;
+      break;
+   default:
+      _mesa_problem(ctx,
+                    "Unexpected format in intel_alloc_renderbuffer_storage");
+      return GL_FALSE;
+   }
+
+   intelFlush(ctx);
+
+   /* free old region */
+   if (irb->region) {
+      intel_region_release(&irb->region);
+   }
+
+   /* allocate new memory region/renderbuffer */
+   if (softwareBuffer) {
+      return _mesa_soft_renderbuffer_storage(ctx, rb, internalFormat,
+                                             width, height);
+   }
+   else {
+      /* Choose a pitch to match hardware requirements:
+       */
+      GLuint pitch = ((cpp * width + 63) & ~63) / cpp;
+
+      /* alloc hardware renderbuffer */
+      DBG("Allocating %d x %d Intel RBO (pitch %d)\n", width,
+         height, pitch);
+
+      irb->region = intel_region_alloc(intel, cpp, width, height, pitch);
+      if (!irb->region)
+         return GL_FALSE;       /* out of memory? */
+
+      ASSERT(irb->region->buffer);
+
+      rb->Width = width;
+      rb->Height = height;
+
+      return GL_TRUE;
+   }
+}
+
+
+
+/**
+ * Called for each hardware renderbuffer when a _window_ is resized.
+ * Just update fields.
+ * Not used for user-created renderbuffers!
+ */
+static GLboolean
+intel_alloc_window_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
+                           GLenum internalFormat, GLuint width, GLuint height)
+{
+   ASSERT(rb->Name == 0);
+   rb->Width = width;
+   rb->Height = height;
+   rb->_ActualFormat = internalFormat;
+
+   return GL_TRUE;
+}
+
+static void
+intel_resize_buffers(GLcontext *ctx, struct gl_framebuffer *fb,
+                    GLuint width, GLuint height)
+{
+   struct intel_framebuffer *intel_fb = (struct intel_framebuffer*)fb;
+   int i;
+
+   _mesa_resize_framebuffer(ctx, fb, width, height);
+
+   fb->Initialized = GL_TRUE; /* XXX remove someday */
+
+   if (fb->Name != 0) {
+      return;
+   }
+
+   /* Make sure all window system renderbuffers are up to date */
+   for (i = 0; i < 3; i++) {
+      struct gl_renderbuffer *rb = &intel_fb->color_rb[i]->Base;
+
+      /* only resize if size is changing */
+      if (rb && (rb->Width != width || rb->Height != height)) {
+        rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height);
+      }
+   }
+}
+
+static GLboolean
+intel_nop_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
+                        GLenum internalFormat, GLuint width, GLuint height)
+{
+   _mesa_problem(ctx, "intel_op_alloc_storage should never be called.");
+   return GL_FALSE;
+}
+
+
+void
+intel_renderbuffer_set_region(struct intel_renderbuffer *rb,
+                             struct intel_region *region)
+{
+   struct intel_region *old;
+
+   old = rb->region;
+   rb->region = NULL;
+   intel_region_reference(&rb->region, region);
+   intel_region_release(&old);
+
+   rb->pfPitch = region->pitch;
+}
+
+/**
+ * Create a new intel_renderbuffer which corresponds to an on-screen window,
+ * not a user-created renderbuffer.
+ */
+struct intel_renderbuffer *
+intel_create_renderbuffer(GLenum intFormat)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   struct intel_renderbuffer *irb;
+   const GLuint name = 0;
+
+   irb = CALLOC_STRUCT(intel_renderbuffer);
+   if (!irb) {
+      _mesa_error(ctx, GL_OUT_OF_MEMORY, "creating renderbuffer");
+      return NULL;
+   }
+
+   _mesa_init_renderbuffer(&irb->Base, name);
+   irb->Base.ClassID = INTEL_RB_CLASS;
+
+   switch (intFormat) {
+   case GL_RGB5:
+      irb->Base._ActualFormat = GL_RGB5;
+      irb->Base._BaseFormat = GL_RGBA;
+      irb->Base.RedBits = 5;
+      irb->Base.GreenBits = 6;
+      irb->Base.BlueBits = 5;
+      irb->Base.DataType = GL_UNSIGNED_BYTE;
+      break;
+   case GL_RGBA8:
+      irb->Base._ActualFormat = GL_RGBA8;
+      irb->Base._BaseFormat = GL_RGBA;
+      irb->Base.RedBits = 8;
+      irb->Base.GreenBits = 8;
+      irb->Base.BlueBits = 8;
+      irb->Base.AlphaBits = 8;
+      irb->Base.DataType = GL_UNSIGNED_BYTE;
+      break;
+   case GL_STENCIL_INDEX8_EXT:
+      irb->Base._ActualFormat = GL_STENCIL_INDEX8_EXT;
+      irb->Base._BaseFormat = GL_STENCIL_INDEX;
+      irb->Base.StencilBits = 8;
+      irb->Base.DataType = GL_UNSIGNED_BYTE;
+      break;
+   case GL_DEPTH_COMPONENT16:
+      irb->Base._ActualFormat = GL_DEPTH_COMPONENT16;
+      irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
+      irb->Base.DepthBits = 16;
+      irb->Base.DataType = GL_UNSIGNED_SHORT;
+      break;
+   case GL_DEPTH_COMPONENT24:
+      irb->Base._ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+      irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
+      irb->Base.DepthBits = 24;
+      irb->Base.DataType = GL_UNSIGNED_INT;
+      break;
+   case GL_DEPTH24_STENCIL8_EXT:
+      irb->Base._ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+      irb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT;
+      irb->Base.DepthBits = 24;
+      irb->Base.StencilBits = 8;
+      irb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
+      break;
+   default:
+      _mesa_problem(NULL,
+                    "Unexpected intFormat in intel_create_renderbuffer");
+      return NULL;
+   }
+
+   irb->Base.InternalFormat = intFormat;
+
+   /* intel-specific methods */
+   irb->Base.Delete = intel_delete_renderbuffer;
+   irb->Base.AllocStorage = intel_alloc_window_storage;
+   irb->Base.GetPointer = intel_get_pointer;
+
+   return irb;
+}
+
+
+/**
+ * Create a new renderbuffer object.
+ * Typically called via glBindRenderbufferEXT().
+ */
+static struct gl_renderbuffer *
+intel_new_renderbuffer(GLcontext * ctx, GLuint name)
+{
+   /*struct intel_context *intel = intel_context(ctx); */
+   struct intel_renderbuffer *irb;
+
+   irb = CALLOC_STRUCT(intel_renderbuffer);
+   if (!irb) {
+      _mesa_error(ctx, GL_OUT_OF_MEMORY, "creating renderbuffer");
+      return NULL;
+   }
+
+   _mesa_init_renderbuffer(&irb->Base, name);
+   irb->Base.ClassID = INTEL_RB_CLASS;
+
+   /* intel-specific methods */
+   irb->Base.Delete = intel_delete_renderbuffer;
+   irb->Base.AllocStorage = intel_alloc_renderbuffer_storage;
+   irb->Base.GetPointer = intel_get_pointer;
+   /* span routines set in alloc_storage function */
+
+   return &irb->Base;
+}
+
+
+/**
+ * Called via glBindFramebufferEXT().
+ */
+static void
+intel_bind_framebuffer(GLcontext * ctx, GLenum target,
+                       struct gl_framebuffer *fb, struct gl_framebuffer *fbread)
+{
+   if (target == GL_FRAMEBUFFER_EXT || target == GL_DRAW_FRAMEBUFFER_EXT) {
+      intel_draw_buffer(ctx, fb);
+      /* Integer depth range depends on depth buffer bits */
+      if (ctx->Driver.DepthRange != NULL)
+        ctx->Driver.DepthRange(ctx, ctx->Viewport.Near, ctx->Viewport.Far);
+   }
+   else {
+      /* don't need to do anything if target == GL_READ_FRAMEBUFFER_EXT */
+   }
+}
+
+
+/**
+ * Called via glFramebufferRenderbufferEXT().
+ */
+static void
+intel_framebuffer_renderbuffer(GLcontext * ctx,
+                               struct gl_framebuffer *fb,
+                               GLenum attachment, struct gl_renderbuffer *rb)
+{
+   DBG("Intel FramebufferRenderbuffer %u %u\n", fb->Name, rb ? rb->Name : 0);
+
+   intelFlush(ctx);
+
+   _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb);
+   intel_draw_buffer(ctx, fb);
+}
+
+static GLboolean
+intel_update_wrapper(GLcontext *ctx, struct intel_renderbuffer *irb, 
+                    struct gl_texture_image *texImage)
+{
+   if (texImage->TexFormat == &_mesa_texformat_argb8888) {
+      irb->Base._ActualFormat = GL_RGBA8;
+      irb->Base._BaseFormat = GL_RGBA;
+      DBG("Render to RGBA8 texture OK\n");
+   }
+   else if (texImage->TexFormat == &_mesa_texformat_rgb565) {
+      irb->Base._ActualFormat = GL_RGB5;
+      irb->Base._BaseFormat = GL_RGB;
+      DBG("Render to RGB5 texture OK\n");
+   }
+   else if (texImage->TexFormat == &_mesa_texformat_z16) {
+      irb->Base._ActualFormat = GL_DEPTH_COMPONENT16;
+      irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
+      DBG("Render to DEPTH16 texture OK\n");
+   } else if (texImage->TexFormat == &_mesa_texformat_z24_s8) {
+      irb->Base._ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+      irb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT;
+      DBG("Render to DEPTH_STENCIL texture OK\n");
+   }
+   else {
+      DBG("Render to texture BAD FORMAT %d\n",
+         texImage->TexFormat->MesaFormat);
+      return GL_FALSE;
+   }
+
+   irb->Base.InternalFormat = irb->Base._ActualFormat;
+   irb->Base.Width = texImage->Width;
+   irb->Base.Height = texImage->Height;
+   irb->Base.DataType = GL_UNSIGNED_BYTE;       /* FBO XXX fix */
+   irb->Base.RedBits = texImage->TexFormat->RedBits;
+   irb->Base.GreenBits = texImage->TexFormat->GreenBits;
+   irb->Base.BlueBits = texImage->TexFormat->BlueBits;
+   irb->Base.AlphaBits = texImage->TexFormat->AlphaBits;
+   irb->Base.DepthBits = texImage->TexFormat->DepthBits;
+
+   irb->Base.Delete = intel_delete_renderbuffer;
+   irb->Base.AllocStorage = intel_nop_alloc_storage;
+
+   irb->RenderToTexture = GL_TRUE;
+
+   return GL_TRUE;
+}
+
+/**
+ * When glFramebufferTexture[123]D is called this function sets up the
+ * gl_renderbuffer wrapper around the texture image.
+ * This will have the region info needed for hardware rendering.
+ */
+static struct intel_renderbuffer *
+intel_wrap_texture(GLcontext * ctx, struct gl_texture_image *texImage)
+{
+   const GLuint name = ~0;      /* not significant, but distinct for debugging */
+   struct intel_renderbuffer *irb;
+
+   /* make an intel_renderbuffer to wrap the texture image */
+   irb = CALLOC_STRUCT(intel_renderbuffer);
+   if (!irb) {
+      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glFramebufferTexture");
+      return NULL;
+   }
+
+   _mesa_init_renderbuffer(&irb->Base, name);
+   irb->Base.ClassID = INTEL_RB_CLASS;
+
+   if (!intel_update_wrapper(ctx, irb, texImage)) {
+      _mesa_free(irb);
+      return NULL;
+   }
+
+   return irb;
+}
+
+
+/**
+ * Called by glFramebufferTexture[123]DEXT() (and other places) to
+ * prepare for rendering into texture memory.  This might be called
+ * many times to choose different texture levels, cube faces, etc
+ * before intel_finish_render_texture() is ever called.
+ */
+static void
+intel_render_texture(GLcontext * ctx,
+                     struct gl_framebuffer *fb,
+                     struct gl_renderbuffer_attachment *att)
+{
+   struct gl_texture_image *newImage
+      = att->Texture->Image[att->CubeMapFace][att->TextureLevel];
+   struct intel_renderbuffer *irb = intel_renderbuffer(att->Renderbuffer);
+   struct intel_texture_image *intel_image;
+   GLuint imageOffset;
+
+   (void) fb;
+
+   ASSERT(newImage);
+
+   if (!irb) {
+      irb = intel_wrap_texture(ctx, newImage);
+      if (irb) {
+         /* bind the wrapper to the attachment point */
+         _mesa_reference_renderbuffer(&att->Renderbuffer, &irb->Base);
+      }
+      else {
+         /* fallback to software rendering */
+         _mesa_render_texture(ctx, fb, att);
+         return;
+      }
+   } if (!intel_update_wrapper(ctx, irb, newImage)) {
+       _mesa_reference_renderbuffer(&att->Renderbuffer, NULL);
+       _mesa_render_texture(ctx, fb, att);
+       return;
+   }
+
+   DBG("Begin render texture tid %x tex=%u w=%d h=%d refcount=%d\n",
+       _glthread_GetID(),
+       att->Texture->Name, newImage->Width, newImage->Height,
+       irb->Base.RefCount);
+
+   /* point the renderbufer's region to the texture image region */
+   intel_image = intel_texture_image(newImage);
+   if (irb->region != intel_image->mt->region) {
+      if (irb->region)
+        intel_region_release(&irb->region);
+      intel_region_reference(&irb->region, intel_image->mt->region);
+   }
+
+   /* compute offset of the particular 2D image within the texture region */
+   imageOffset = intel_miptree_image_offset(intel_image->mt,
+                                            att->CubeMapFace,
+                                            att->TextureLevel);
+
+   if (att->Texture->Target == GL_TEXTURE_3D) {
+      const GLuint *offsets = intel_miptree_depth_offsets(intel_image->mt,
+                                                          att->TextureLevel);
+      imageOffset += offsets[att->Zoffset];
+   }
+
+   /* store that offset in the region */
+   intel_image->mt->region->draw_offset = imageOffset;
+
+   /* update drawing region, etc */
+   intel_draw_buffer(ctx, fb);
+}
+
+
+/**
+ * Called by Mesa when rendering to a texture is done.
+ */
+static void
+intel_finish_render_texture(GLcontext * ctx,
+                            struct gl_renderbuffer_attachment *att)
+{
+   struct intel_renderbuffer *irb = intel_renderbuffer(att->Renderbuffer);
+
+   DBG("End render texture (tid %x) tex %u\n", _glthread_GetID(), att->Texture->Name);
+
+   if (irb) {
+      /* just release the region */
+      intel_region_release(&irb->region);
+   }
+   else if (att->Renderbuffer) {
+      /* software fallback */
+      _mesa_finish_render_texture(ctx, att);
+      /* XXX FBO: Need to unmap the buffer (or in intelSpanRenderStart???) */
+   }
+}
+
+
+/**
+ * Do one-time context initializations related to GL_EXT_framebuffer_object.
+ * Hook in device driver functions.
+ */
+void
+intel_fbo_init(struct intel_context *intel)
+{
+   intel->ctx.Driver.NewFramebuffer = intel_new_framebuffer;
+   intel->ctx.Driver.NewRenderbuffer = intel_new_renderbuffer;
+   intel->ctx.Driver.BindFramebuffer = intel_bind_framebuffer;
+   intel->ctx.Driver.FramebufferRenderbuffer = intel_framebuffer_renderbuffer;
+   intel->ctx.Driver.RenderTexture = intel_render_texture;
+   intel->ctx.Driver.FinishRenderTexture = intel_finish_render_texture;
+   intel->ctx.Driver.ResizeBuffers = intel_resize_buffers;
+}
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.h b/src/mesa/drivers/dri/intel/intel_fbo.h
new file mode 100644 (file)
index 0000000..9d15582
--- /dev/null
@@ -0,0 +1,115 @@
+/**************************************************************************
+ * 
+ * Copyright 2006 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_FBO_H
+#define INTEL_FBO_H
+
+#include "intel_screen.h"
+
+struct intel_context;
+
+/**
+ * Intel framebuffer, derived from gl_framebuffer.
+ */
+struct intel_framebuffer
+{
+   struct gl_framebuffer Base;
+
+   struct intel_renderbuffer *color_rb[3];
+
+   /* Drawable page flipping state */
+   GLboolean pf_active;
+   GLuint pf_seq;
+   GLint pf_planes;
+   GLint pf_current_page;
+   GLint pf_num_pages;
+
+   /* VBI
+    */
+   GLuint vbl_waited;
+
+   int64_t swap_ust;
+   int64_t swap_missed_ust;
+
+   GLuint swap_count;
+   GLuint swap_missed_count;
+};
+
+
+/**
+ * Intel renderbuffer, derived from gl_renderbuffer.
+ * Note: The PairedDepth and PairedStencil fields use renderbuffer IDs,
+ * not pointers because in some circumstances a deleted renderbuffer could
+ * result in a dangling pointer here.
+ */
+struct intel_renderbuffer
+{
+   struct gl_renderbuffer Base;
+   struct intel_region *region;
+   GLuint pfPitch;              /* possibly paged flipped pitch */
+   GLboolean RenderToTexture;   /* RTT? */
+
+   GLuint PairedDepth;   /**< only used if this is a depth renderbuffer */
+   GLuint PairedStencil; /**< only used if this is a stencil renderbuffer */
+
+   GLuint pf_pending;  /**< sequence number of pending flip */
+
+   GLuint vbl_pending;   /**< vblank sequence number of pending flip */
+
+   uint8_t *span_cache;
+   unsigned long span_cache_offset;
+};
+
+extern struct intel_renderbuffer *intel_renderbuffer(struct gl_renderbuffer
+                                                     *rb);
+
+extern void
+intel_renderbuffer_set_region(struct intel_renderbuffer *irb,
+                             struct intel_region *region);
+
+extern struct intel_renderbuffer *
+intel_create_renderbuffer(GLenum intFormat);
+
+extern void intel_fbo_init(struct intel_context *intel);
+
+
+/* XXX make inline or macro */
+extern struct intel_renderbuffer *intel_get_renderbuffer(struct gl_framebuffer
+                                                         *fb,
+                                                         int attIndex);
+
+extern void intel_flip_renderbuffers(struct intel_framebuffer *intel_fb);
+
+
+/* XXX make inline or macro */
+extern struct intel_region *intel_get_rb_region(struct gl_framebuffer *fb,
+                                                GLuint attIndex);
+
+
+
+
+#endif /* INTEL_FBO_H */
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
new file mode 100644 (file)
index 0000000..f28fac8
--- /dev/null
@@ -0,0 +1,492 @@
+/**************************************************************************
+ * 
+ * Copyright 2006 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 "intel_context.h"
+#include "intel_mipmap_tree.h"
+#include "intel_regions.h"
+#include "intel_chipset.h"
+#include "enums.h"
+
+#define FILE_DEBUG_FLAG DEBUG_MIPTREE
+
+static GLenum
+target_to_target(GLenum target)
+{
+   switch (target) {
+   case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
+   case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
+   case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
+   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
+   case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
+   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
+      return GL_TEXTURE_CUBE_MAP_ARB;
+   default:
+      return target;
+   }
+}
+
+static struct intel_mipmap_tree *
+intel_miptree_create_internal(struct intel_context *intel,
+                             GLenum target,
+                             GLenum internal_format,
+                             GLuint first_level,
+                             GLuint last_level,
+                             GLuint width0,
+                             GLuint height0,
+                             GLuint depth0, GLuint cpp, GLuint compress_byte)
+{
+   GLboolean ok;
+   struct intel_mipmap_tree *mt = calloc(sizeof(*mt), 1);
+
+   DBG("%s target %s format %s level %d..%d\n", __FUNCTION__,
+       _mesa_lookup_enum_by_nr(target),
+       _mesa_lookup_enum_by_nr(internal_format), first_level, last_level);
+
+   mt->target = target_to_target(target);
+   mt->internal_format = internal_format;
+   mt->first_level = first_level;
+   mt->last_level = last_level;
+   mt->width0 = width0;
+   mt->height0 = height0;
+   mt->depth0 = depth0;
+   mt->cpp = compress_byte ? compress_byte : cpp;
+   mt->compressed = compress_byte ? 1 : 0;
+   mt->refcount = 1; 
+   mt->pitch = 0;
+
+#ifdef I915
+   if (IS_945(intel->intelScreen->deviceID))
+      ok = i945_miptree_layout(intel, mt);
+   else
+      ok = i915_miptree_layout(intel, mt);
+#else
+   ok = brw_miptree_layout(intel, mt);
+#endif
+
+   if (!ok) {
+      free(mt);
+      return NULL;
+   }
+
+   return mt;
+}
+
+struct intel_mipmap_tree *
+intel_miptree_create(struct intel_context *intel,
+                    GLenum target,
+                    GLenum internal_format,
+                    GLuint first_level,
+                    GLuint last_level,
+                    GLuint width0,
+                    GLuint height0,
+                    GLuint depth0, GLuint cpp, GLuint compress_byte)
+{
+   struct intel_mipmap_tree *mt;
+
+   mt = intel_miptree_create_internal(intel, target, internal_format,
+                                     first_level, last_level, width0,
+                                     height0, depth0, cpp, compress_byte);
+   /*
+    * pitch == 0 indicates the null texture
+    */
+   if (!mt || !mt->pitch)
+      return NULL;
+
+   mt->region = intel_region_alloc(intel,
+                                  mt->cpp,
+                                  mt->pitch,
+                                  mt->total_height,
+                                  mt->pitch);
+
+   if (!mt->region) {
+       free(mt);
+       return NULL;
+   }
+
+   return mt;
+}
+
+struct intel_mipmap_tree *
+intel_miptree_create_for_region(struct intel_context *intel,
+                               GLenum target,
+                               GLenum internal_format,
+                               GLuint first_level,
+                               GLuint last_level,
+                               struct intel_region *region,
+                               GLuint depth0,
+                               GLuint compress_byte)
+{
+   struct intel_mipmap_tree *mt;
+
+   mt = intel_miptree_create_internal(intel, target, internal_format,
+                                     first_level, last_level,
+                                     region->width, region->height, 1,
+                                     region->cpp, compress_byte);
+   if (!mt)
+      return mt;
+#if 0
+   if (mt->pitch != region->pitch) {
+      fprintf(stderr,
+             "region pitch (%d) doesn't match mipmap tree pitch (%d)\n",
+             region->pitch, mt->pitch);
+      free(mt);
+      return NULL;
+   }
+#else
+   /* The mipmap tree pitch is aligned to 64 bytes to make sure render
+    * to texture works, but we don't need that for texturing from a
+    * pixmap.  Just override it here. */
+   mt->pitch = region->pitch;
+#endif
+
+   mt->region = region;
+
+   return mt;
+ }
+
+/**
+ * intel_miptree_pitch_align:
+ *
+ * @intel: intel context pointer
+ *
+ * @mt: the miptree to compute pitch alignment for
+ *
+ * @pitch: the natural pitch value
+ *
+ * Given @pitch, compute a larger value which accounts for
+ * any necessary alignment required by the device
+ */
+
+int intel_miptree_pitch_align (struct intel_context *intel,
+                              struct intel_mipmap_tree *mt,
+                              int pitch)
+{
+#ifdef I915
+   GLcontext *ctx = &intel->ctx;
+#endif
+
+   if (!mt->compressed) {
+      int pitch_align;
+
+      if (intel->ttm) {
+        /* XXX: Align pitch to multiple of 64 bytes for now to allow
+         * render-to-texture to work in all cases. This should probably be
+         * replaced at some point by some scheme to only do this when really
+         * necessary.
+         */
+        pitch_align = 64;
+      } else {
+        pitch_align = 4;
+      }
+
+      pitch = ALIGN(pitch * mt->cpp, pitch_align);
+
+#ifdef I915
+      /* XXX: At least the i915 seems very upset when the pitch is a multiple
+       * of 1024 and sometimes 512 bytes - performance can drop by several
+       * times. Go to the next multiple of the required alignment for now.
+       */
+      if (!(pitch & 511) && 
+        (pitch + pitch_align) < (1 << ctx->Const.MaxTextureLevels))
+        pitch += pitch_align;
+#endif
+
+      pitch /= mt->cpp;
+   }
+   return pitch;
+}
+
+void
+intel_miptree_reference(struct intel_mipmap_tree **dst,
+                        struct intel_mipmap_tree *src)
+{
+   src->refcount++;
+   *dst = src;
+   DBG("%s %p refcount now %d\n", __FUNCTION__, src, src->refcount);
+}
+
+void
+intel_miptree_release(struct intel_context *intel,
+                      struct intel_mipmap_tree **mt)
+{
+   if (!*mt)
+      return;
+
+   DBG("%s %p refcount will be %d\n", __FUNCTION__, *mt, (*mt)->refcount - 1);
+   if (--(*mt)->refcount <= 0) {
+      GLuint i;
+
+      DBG("%s deleting %p\n", __FUNCTION__, *mt);
+
+      intel_region_release(&((*mt)->region));
+
+      for (i = 0; i < MAX_TEXTURE_LEVELS; i++)
+         if ((*mt)->level[i].image_offset)
+            free((*mt)->level[i].image_offset);
+
+      free(*mt);
+   }
+   *mt = NULL;
+}
+
+
+
+
+/* Can the image be pulled into a unified mipmap tree.  This mirrors
+ * the completeness test in a lot of ways.
+ *
+ * Not sure whether I want to pass gl_texture_image here.
+ */
+GLboolean
+intel_miptree_match_image(struct intel_mipmap_tree *mt,
+                          struct gl_texture_image *image,
+                          GLuint face, GLuint level)
+{
+   /* Images with borders are never pulled into mipmap trees. 
+    */
+   if (image->Border ||
+       ((image->_BaseFormat == GL_DEPTH_COMPONENT) &&
+        ((image->TexObject->WrapS == GL_CLAMP_TO_BORDER) ||
+         (image->TexObject->WrapT == GL_CLAMP_TO_BORDER)))) 
+      return GL_FALSE;
+
+   if (image->InternalFormat != mt->internal_format ||
+       image->IsCompressed != mt->compressed)
+      return GL_FALSE;
+
+   if (!image->IsCompressed &&
+       !mt->compressed &&
+       image->TexFormat->TexelBytes != mt->cpp)
+      return GL_FALSE;
+
+   /* Test image dimensions against the base level image adjusted for
+    * minification.  This will also catch images not present in the
+    * tree, changed targets, etc.
+    */
+   if (image->Width != mt->level[level].width ||
+       image->Height != mt->level[level].height ||
+       image->Depth != mt->level[level].depth)
+      return GL_FALSE;
+
+   return GL_TRUE;
+}
+
+
+void
+intel_miptree_set_level_info(struct intel_mipmap_tree *mt,
+                            GLuint level,
+                            GLuint nr_images,
+                            GLuint x, GLuint y,
+                            GLuint w, GLuint h, GLuint d)
+{
+   mt->level[level].width = w;
+   mt->level[level].height = h;
+   mt->level[level].depth = d;
+   mt->level[level].level_offset = (x + y * mt->pitch) * mt->cpp;
+   mt->level[level].nr_images = nr_images;
+
+   DBG("%s level %d size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__,
+       level, w, h, d, x, y, mt->level[level].level_offset);
+
+   /* Not sure when this would happen, but anyway: 
+    */
+   if (mt->level[level].image_offset) {
+      free(mt->level[level].image_offset);
+      mt->level[level].image_offset = NULL;
+   }
+
+   assert(nr_images);
+
+   mt->level[level].image_offset = malloc(nr_images * sizeof(GLuint));
+   mt->level[level].image_offset[0] = 0;
+}
+
+
+
+void
+intel_miptree_set_image_offset(struct intel_mipmap_tree *mt,
+                              GLuint level, GLuint img,
+                              GLuint x, GLuint y)
+{
+   if (img == 0 && level == 0)
+      assert(x == 0 && y == 0);
+
+   assert(img < mt->level[level].nr_images);
+
+   mt->level[level].image_offset[img] = (x + y * mt->pitch) * mt->cpp;
+
+   DBG("%s level %d img %d pos %d,%d image_offset %x\n",
+       __FUNCTION__, level, img, x, y, mt->level[level].image_offset[img]);
+}
+
+
+/* Although we use the image_offset[] array to store relative offsets
+ * to cube faces, Mesa doesn't know anything about this and expects
+ * each cube face to be treated as a separate image.
+ *
+ * These functions present that view to mesa:
+ */
+const GLuint *
+intel_miptree_depth_offsets(struct intel_mipmap_tree *mt, GLuint level)
+{
+   static const GLuint zero = 0;
+
+   if (mt->target != GL_TEXTURE_3D || mt->level[level].nr_images == 1)
+      return &zero;
+   else
+      return mt->level[level].image_offset;
+}
+
+
+GLuint
+intel_miptree_image_offset(struct intel_mipmap_tree *mt,
+                          GLuint face, GLuint level)
+{
+   if (mt->target == GL_TEXTURE_CUBE_MAP_ARB)
+      return (mt->level[level].level_offset +
+             mt->level[level].image_offset[face]);
+   else
+      return mt->level[level].level_offset;
+}
+
+
+
+/**
+ * Map a teximage in a mipmap tree.
+ * \param row_stride  returns row stride in bytes
+ * \param image_stride  returns image stride in bytes (for 3D textures).
+ * \param image_offsets pointer to array of pixel offsets from the returned
+ *       pointer to each depth image
+ * \return address of mapping
+ */
+GLubyte *
+intel_miptree_image_map(struct intel_context * intel,
+                        struct intel_mipmap_tree * mt,
+                        GLuint face,
+                        GLuint level,
+                        GLuint * row_stride, GLuint * image_offsets)
+{
+   DBG("%s \n", __FUNCTION__);
+
+   if (row_stride)
+      *row_stride = mt->pitch * mt->cpp;
+
+   if (mt->target == GL_TEXTURE_3D) {
+      int i;
+
+      for (i = 0; i < mt->level[level].depth; i++)
+        image_offsets[i] = mt->level[level].image_offset[i] / mt->cpp;
+   } else {
+      assert(mt->level[level].depth == 1);
+      assert(mt->target == GL_TEXTURE_CUBE_MAP ||
+            mt->level[level].image_offset[0] == 0);
+      image_offsets[0] = 0;
+   }
+
+   return (intel_region_map(intel, mt->region) +
+           intel_miptree_image_offset(mt, face, level));
+}
+
+void
+intel_miptree_image_unmap(struct intel_context *intel,
+                          struct intel_mipmap_tree *mt)
+{
+   DBG("%s\n", __FUNCTION__);
+   intel_region_unmap(intel, mt->region);
+}
+
+
+
+/* Upload data for a particular image.
+ */
+void
+intel_miptree_image_data(struct intel_context *intel,
+                        struct intel_mipmap_tree *dst,
+                        GLuint face,
+                        GLuint level,
+                        void *src,
+                        GLuint src_row_pitch,
+                        GLuint src_image_pitch)
+{
+   GLuint depth = dst->level[level].depth;
+   GLuint dst_offset = intel_miptree_image_offset(dst, face, level);
+   const GLuint *dst_depth_offset = intel_miptree_depth_offsets(dst, level);
+   GLuint i;
+   GLuint height = 0;
+
+   DBG("%s: %d/%d\n", __FUNCTION__, face, level);
+   for (i = 0; i < depth; i++) {
+      height = dst->level[level].height;
+      if(dst->compressed)
+        height = (height + 3) / 4;
+      intel_region_data(intel,
+                       dst->region,
+                       dst_offset + dst_depth_offset[i], /* dst_offset */
+                       0, 0,                             /* dstx, dsty */
+                       src,
+                       src_row_pitch,
+                       0, 0,                             /* source x, y */
+                       dst->level[level].width, height); /* width, height */
+
+      src += src_image_pitch * dst->cpp;
+   }
+}
+
+extern GLuint intel_compressed_alignment(GLenum);
+/* Copy mipmap image between trees
+ */
+void
+intel_miptree_image_copy(struct intel_context *intel,
+                         struct intel_mipmap_tree *dst,
+                         GLuint face, GLuint level,
+                         struct intel_mipmap_tree *src)
+{
+   GLuint width = src->level[level].width;
+   GLuint height = src->level[level].height;
+   GLuint depth = src->level[level].depth;
+   GLuint dst_offset = intel_miptree_image_offset(dst, face, level);
+   GLuint src_offset = intel_miptree_image_offset(src, face, level);
+   const GLuint *dst_depth_offset = intel_miptree_depth_offsets(dst, level);
+   const GLuint *src_depth_offset = intel_miptree_depth_offsets(src, level);
+   GLuint i;
+
+   if (dst->compressed) {
+       GLuint alignment = intel_compressed_alignment(dst->internal_format);
+       height = (height + 3) / 4;
+       width = ((width + alignment - 1) & ~(alignment - 1));
+   }
+
+   for (i = 0; i < depth; i++) {
+      intel_region_copy(intel,
+                        dst->region, dst_offset + dst_depth_offset[i],
+                        0,
+                        0,
+                        src->region, src_offset + src_depth_offset[i],
+                        0, 0, width, height);
+   }
+
+}
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
new file mode 100644 (file)
index 0000000..c9537db
--- /dev/null
@@ -0,0 +1,226 @@
+/**************************************************************************
+ * 
+ * Copyright 2006 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_MIPMAP_TREE_H
+#define INTEL_MIPMAP_TREE_H
+
+#include "intel_regions.h"
+
+/* A layer on top of the intel_regions code which adds:
+ *
+ * - Code to size and layout a region to hold a set of mipmaps.
+ * - Query to determine if a new image fits in an existing tree.
+ * - More refcounting 
+ *     - maybe able to remove refcounting from intel_region?
+ * - ?
+ *
+ * The fixed mipmap layout of intel hardware where one offset
+ * specifies the position of all images in a mipmap hierachy
+ * complicates the implementation of GL texture image commands,
+ * compared to hardware where each image is specified with an
+ * independent offset.
+ *
+ * In an ideal world, each texture object would be associated with a
+ * single bufmgr buffer or 2d intel_region, and all the images within
+ * the texture object would slot into the tree as they arrive.  The
+ * reality can be a little messier, as images can arrive from the user
+ * with sizes that don't fit in the existing tree, or in an order
+ * where the tree layout cannot be guessed immediately.  
+ * 
+ * This structure encodes an idealized mipmap tree.  The GL image
+ * commands build these where possible, otherwise store the images in
+ * temporary system buffers.
+ */
+
+
+/**
+ * Describes the location of each texture image within a texture region.
+ */
+struct intel_mipmap_level
+{
+   /**
+    * Byte offset to the base of this level.
+    *
+    * This is used for mipmap levels of 1D/2D/3D textures.  However, CUBE
+    * layouts spread images around the whole tree, so the level offset is
+    * always zero in that case.
+    */
+   GLuint level_offset;
+   GLuint width;
+   GLuint height;
+   /** Depth of the mipmap at this level: 1 for 1D/2D/CUBE, n for 3D. */
+   GLuint depth;
+   /** Number of images at this level: 1 for 1D/2D, 6 for CUBE, depth for 3D */
+   GLuint nr_images;
+
+   /**
+    * Byte offset from level_offset to the image for each cube face or depth
+    * level.
+    *
+    * Pretty much have to accept that hardware formats
+    * are going to be so diverse that there is no unified way to
+    * compute the offsets of depth/cube images within a mipmap level,
+    * so have to store them as a lookup table.
+    */
+   GLuint *image_offset;
+};
+
+struct intel_mipmap_tree
+{
+   /* Effectively the key:
+    */
+   GLenum target;
+   GLenum internal_format;
+
+   GLuint first_level;
+   GLuint last_level;
+
+   GLuint width0, height0, depth0; /**< Level zero image dimensions */
+   GLuint cpp;
+   GLboolean compressed;
+
+   /* Derived from the above:
+    */
+   GLuint pitch;
+   GLuint depth_pitch;          /* per-image on i945? */
+   GLuint total_height;
+
+   /* Includes image offset tables:
+    */
+   struct intel_mipmap_level level[MAX_TEXTURE_LEVELS];
+
+   /* The data is held here:
+    */
+   struct intel_region *region;
+
+   /* These are also refcounted:
+    */
+   GLuint refcount;
+};
+
+
+
+struct intel_mipmap_tree *intel_miptree_create(struct intel_context *intel,
+                                               GLenum target,
+                                               GLenum internal_format,
+                                               GLuint first_level,
+                                               GLuint last_level,
+                                               GLuint width0,
+                                               GLuint height0,
+                                               GLuint depth0,
+                                               GLuint cpp,
+                                               GLuint compress_byte);
+
+struct intel_mipmap_tree *
+intel_miptree_create_for_region(struct intel_context *intel,
+                               GLenum target,
+                               GLenum internal_format,
+                               GLuint first_level,
+                               GLuint last_level,
+                               struct intel_region *region,
+                               GLuint depth0,
+                               GLuint compress_byte);
+
+int intel_miptree_pitch_align (struct intel_context *intel,
+                              struct intel_mipmap_tree *mt,
+                              int pitch);
+
+void intel_miptree_reference(struct intel_mipmap_tree **dst,
+                             struct intel_mipmap_tree *src);
+
+void intel_miptree_release(struct intel_context *intel,
+                           struct intel_mipmap_tree **mt);
+
+/* Check if an image fits an existing mipmap tree layout
+ */
+GLboolean intel_miptree_match_image(struct intel_mipmap_tree *mt,
+                                    struct gl_texture_image *image,
+                                    GLuint face, GLuint level);
+
+/* Return a pointer to an image within a tree.  Return image stride as
+ * well.
+ */
+GLubyte *intel_miptree_image_map(struct intel_context *intel,
+                                 struct intel_mipmap_tree *mt,
+                                 GLuint face,
+                                 GLuint level,
+                                 GLuint * row_stride, GLuint * image_stride);
+
+void intel_miptree_image_unmap(struct intel_context *intel,
+                               struct intel_mipmap_tree *mt);
+
+
+/* Return the linear offset of an image relative to the start of the
+ * tree:
+ */
+GLuint intel_miptree_image_offset(struct intel_mipmap_tree *mt,
+                                  GLuint face, GLuint level);
+
+/* Return pointers to each 2d slice within an image.  Indexed by depth
+ * value.
+ */
+const GLuint *intel_miptree_depth_offsets(struct intel_mipmap_tree *mt,
+                                          GLuint level);
+
+
+void intel_miptree_set_level_info(struct intel_mipmap_tree *mt,
+                                  GLuint level,
+                                  GLuint nr_images,
+                                  GLuint x, GLuint y,
+                                  GLuint w, GLuint h, GLuint d);
+
+void intel_miptree_set_image_offset(struct intel_mipmap_tree *mt,
+                                    GLuint level,
+                                    GLuint img, GLuint x, GLuint y);
+
+
+/* Upload an image into a tree
+ */
+void intel_miptree_image_data(struct intel_context *intel,
+                              struct intel_mipmap_tree *dst,
+                              GLuint face,
+                              GLuint level,
+                              void *src,
+                              GLuint src_row_pitch, GLuint src_image_pitch);
+
+/* Copy an image between two trees
+ */
+void intel_miptree_image_copy(struct intel_context *intel,
+                              struct intel_mipmap_tree *dst,
+                              GLuint face, GLuint level,
+                              struct intel_mipmap_tree *src);
+
+/* i915_mipmap_tree.c:
+ */
+GLboolean i915_miptree_layout(struct intel_context *intel,
+                             struct intel_mipmap_tree *mt);
+GLboolean i945_miptree_layout(struct intel_context *intel,
+                             struct intel_mipmap_tree *mt);
+GLboolean brw_miptree_layout(struct intel_context *intel,
+                            struct intel_mipmap_tree *mt);
+
+#endif
diff --git a/src/mesa/drivers/dri/intel/intel_pixel.c b/src/mesa/drivers/dri/intel/intel_pixel.c
new file mode 100644 (file)
index 0000000..6417866
--- /dev/null
@@ -0,0 +1,189 @@
+/**************************************************************************
+ * 
+ * Copyright 2006 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 portionsalloc
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 "enums.h"
+#include "state.h"
+#include "swrast/swrast.h"
+
+#include "intel_context.h"
+#include "intel_pixel.h"
+#include "intel_regions.h"
+
+#define FILE_DEBUG_FLAG DEBUG_PIXEL
+
+static GLenum
+effective_func(GLenum func, GLboolean src_alpha_is_one)
+{
+   if (src_alpha_is_one) {
+      if (func == GL_SRC_ALPHA)
+        return GL_ONE;
+      if (func == GL_ONE_MINUS_SRC_ALPHA)
+        return GL_ZERO;
+   }
+
+   return func;
+}
+
+/**
+ * Check if any fragment operations are in effect which might effect
+ * glDraw/CopyPixels.
+ */
+GLboolean
+intel_check_blit_fragment_ops(GLcontext * ctx, GLboolean src_alpha_is_one)
+{
+   if (ctx->NewState)
+      _mesa_update_state(ctx);
+
+   if (ctx->FragmentProgram._Enabled) {
+      DBG("fallback due to fragment program\n");
+      return GL_FALSE;
+   }
+
+   if (ctx->Color.BlendEnabled &&
+       (effective_func(ctx->Color.BlendSrcRGB, src_alpha_is_one) != GL_ONE ||
+       effective_func(ctx->Color.BlendDstRGB, src_alpha_is_one) != GL_ZERO ||
+       ctx->Color.BlendEquationRGB != GL_FUNC_ADD ||
+       effective_func(ctx->Color.BlendSrcA, src_alpha_is_one) != GL_ONE ||
+       effective_func(ctx->Color.BlendDstA, src_alpha_is_one) != GL_ZERO ||
+       ctx->Color.BlendEquationA != GL_FUNC_ADD)) {
+      DBG("fallback due to blend\n");
+      return GL_FALSE;
+   }
+
+   if (ctx->Texture._EnabledUnits) {
+      DBG("fallback due to texturing\n");
+      return GL_FALSE;
+   }
+
+   if (!(ctx->Color.ColorMask[0] &&
+        ctx->Color.ColorMask[1] &&
+        ctx->Color.ColorMask[2] &&
+        ctx->Color.ColorMask[3])) {
+      DBG("fallback due to color masking\n");
+      return GL_FALSE;
+   }
+
+   if (ctx->Color.AlphaEnabled) {
+      DBG("fallback due to alpha\n");
+      return GL_FALSE;
+   }
+
+   if (ctx->Depth.Test) {
+      DBG("fallback due to depth test\n");
+      return GL_FALSE;
+   }
+
+   if (ctx->Fog.Enabled) {
+      DBG("fallback due to fog\n");
+      return GL_FALSE;
+   }
+
+   if (ctx->_ImageTransferState) {
+      DBG("fallback due to image transfer\n");
+      return GL_FALSE;
+   }
+
+   if (ctx->Stencil.Enabled) {
+      DBG("fallback due to image stencil\n");
+      return GL_FALSE;
+   }
+
+   if (ctx->Scissor.Enabled) {
+      /* XXX Note: Scissor could be done with the blitter */
+      DBG("fallback due to image scissor\n");
+      return GL_FALSE;
+   }
+
+   if (ctx->RenderMode != GL_RENDER) {
+      DBG("fallback due to render mode\n");
+      return GL_FALSE;
+   }
+
+   return GL_TRUE;
+}
+
+
+GLboolean
+intel_check_meta_tex_fragment_ops(GLcontext * ctx)
+{
+   if (ctx->NewState)
+      _mesa_update_state(ctx);
+
+   /* Some of _ImageTransferState (scale, bias) could be done with
+    * fragment programs on i915.
+    */
+   return !(ctx->_ImageTransferState || ctx->Fog.Enabled ||     /* not done yet */
+            ctx->Texture._EnabledUnits || ctx->FragmentProgram._Enabled);
+}
+
+/* The intel_region struct doesn't really do enough to capture the
+ * format of the pixels in the region.  For now this code assumes that
+ * the region is a display surface and hence is either ARGB8888 or
+ * RGB565.
+ * XXX FBO: If we'd pass in the intel_renderbuffer instead of region, we'd
+ * know the buffer's pixel format.
+ *
+ * \param format  as given to glDraw/ReadPixels
+ * \param type  as given to glDraw/ReadPixels
+ */
+GLboolean
+intel_check_blit_format(struct intel_region * region,
+                        GLenum format, GLenum type)
+{
+   if (region->cpp == 4 &&
+       (type == GL_UNSIGNED_INT_8_8_8_8_REV ||
+        type == GL_UNSIGNED_BYTE) && format == GL_BGRA) {
+      return GL_TRUE;
+   }
+
+   if (region->cpp == 2 &&
+       type == GL_UNSIGNED_SHORT_5_6_5_REV && format == GL_BGR) {
+      return GL_TRUE;
+   }
+
+   if (INTEL_DEBUG & DEBUG_PIXEL)
+      fprintf(stderr, "%s: bad format for blit (cpp %d, type %s format %s)\n",
+              __FUNCTION__, region->cpp,
+              _mesa_lookup_enum_by_nr(type), _mesa_lookup_enum_by_nr(format));
+
+   return GL_FALSE;
+}
+
+
+void
+intelInitPixelFuncs(struct dd_function_table *functions)
+{
+   functions->Accum = _swrast_Accum;
+   if (!getenv("INTEL_NO_BLIT")) {
+      functions->Bitmap = intelBitmap;
+      functions->CopyPixels = intelCopyPixels;
+#ifdef I915
+      functions->ReadPixels = intelReadPixels;
+      functions->DrawPixels = intelDrawPixels;
+#endif
+   }
+}
diff --git a/src/mesa/drivers/dri/intel/intel_pixel.h b/src/mesa/drivers/dri/intel/intel_pixel.h
new file mode 100644 (file)
index 0000000..9c899b9
--- /dev/null
@@ -0,0 +1,70 @@
+/**************************************************************************
+ * 
+ * Copyright 2006 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_PIXEL_H
+#define INTEL_PIXEL_H
+
+#include "mtypes.h"
+
+void intelInitPixelFuncs(struct dd_function_table *functions);
+
+GLboolean intel_check_blit_fragment_ops(GLcontext * ctx,
+                                       GLboolean src_alpha_is_one);
+
+GLboolean intel_check_meta_tex_fragment_ops(GLcontext * ctx);
+
+GLboolean intel_check_blit_format(struct intel_region *region,
+                                  GLenum format, GLenum type);
+
+
+void intelReadPixels(GLcontext * ctx,
+                     GLint x, GLint y,
+                     GLsizei width, GLsizei height,
+                     GLenum format, GLenum type,
+                     const struct gl_pixelstore_attrib *pack,
+                     GLvoid * pixels);
+
+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);
+
+void intelCopyPixels(GLcontext * ctx,
+                     GLint srcx, GLint srcy,
+                     GLsizei width, GLsizei height,
+                     GLint destx, GLint desty, GLenum type);
+
+void intelBitmap(GLcontext * ctx,
+                GLint x, GLint y,
+                GLsizei width, GLsizei height,
+                const struct gl_pixelstore_attrib *unpack,
+                const GLubyte * pixels);
+
+#endif
diff --git a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
new file mode 100644 (file)
index 0000000..daa6d4b
--- /dev/null
@@ -0,0 +1,356 @@
+/**************************************************************************
+ * 
+ * Copyright 2006 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 portionsalloc
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 "image.h"
+#include "colormac.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "bufferobj.h"
+#include "swrast/swrast.h"
+
+#include "intel_screen.h"
+#include "intel_context.h"
+#include "intel_batchbuffer.h"
+#include "intel_blit.h"
+#include "intel_regions.h"
+#include "intel_buffer_objects.h"
+#include "intel_buffers.h"
+#include "intel_pixel.h"
+#include "intel_reg.h"
+
+
+#define FILE_DEBUG_FLAG DEBUG_PIXEL
+
+
+/* Unlike the other intel_pixel_* functions, the expectation here is
+ * that the incoming data is not in a PBO.  With the XY_TEXT blit
+ * method, there's no benefit haveing it in a PBO, but we could
+ * implement a path based on XY_MONO_SRC_COPY_BLIT which might benefit
+ * PBO bitmaps.  I think they are probably pretty rare though - I
+ * wonder if Xgl uses them?
+ */
+static const GLubyte *map_pbo( GLcontext *ctx,
+                              GLsizei width, GLsizei height,
+                              const struct gl_pixelstore_attrib *unpack,
+                              const GLubyte *bitmap )
+{
+   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 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, "glBitmap(PBO is mapped)");
+      return NULL;
+   }
+
+   return ADD_POINTERS(buf, bitmap);
+}
+
+static GLboolean test_bit( const GLubyte *src,
+                           GLuint bit )
+{
+   return (src[bit/8] & (1<<(bit % 8))) ? 1 : 0;
+}
+
+static void set_bit( GLubyte *dest,
+                         GLuint bit )
+{
+   dest[bit/8] |= 1 << (bit % 8);
+}
+
+/* Extract a rectangle's worth of data from the bitmap.  Called
+ * per-cliprect.
+ */
+static GLuint get_bitmap_rect(GLsizei width, GLsizei height,
+                             const struct gl_pixelstore_attrib *unpack,
+                             const GLubyte *bitmap,
+                             GLuint x, GLuint y, 
+                             GLuint w, GLuint h,
+                             GLubyte *dest,
+                             GLuint row_align,
+                             GLboolean invert)
+{
+   GLuint src_offset = (x + unpack->SkipPixels) & 0x7;
+   GLuint mask = unpack->LsbFirst ? 0 : 7;
+   GLuint bit = 0;
+   GLint row, col;
+   GLint first, last;
+   GLint incr;
+   GLuint count = 0;
+
+   if (INTEL_DEBUG & DEBUG_PIXEL)
+      _mesa_printf("%s %d,%d %dx%d bitmap %dx%d skip %d src_offset %d mask %d\n",
+                  __FUNCTION__, x,y,w,h,width,height,unpack->SkipPixels, src_offset, mask);
+
+   if (invert) {
+      first = h-1;
+      last = 0;
+      incr = -1;
+   }
+   else {
+      first = 0;
+      last = h-1;
+      incr = 1;
+   }
+
+   /* Require that dest be pre-zero'd.
+    */
+   for (row = first; row != (last+incr); row += incr) {
+      const GLubyte *rowsrc = _mesa_image_address2d(unpack, bitmap, 
+                                                   width, height, 
+                                                   GL_COLOR_INDEX, GL_BITMAP, 
+                                                   y + row, x);
+
+      for (col = 0; col < w; col++, bit++) {
+        if (test_bit(rowsrc, (col + src_offset) ^ mask)) {
+           set_bit(dest, bit ^ 7);
+           count++;
+        }
+      }
+
+      if (row_align)
+        bit = ALIGN(bit, row_align);
+   }
+
+   return count;
+}
+
+
+
+
+/*
+ * Render a bitmap.
+ */
+static GLboolean
+do_blit_bitmap( GLcontext *ctx, 
+               GLint dstx, GLint dsty,
+               GLsizei width, GLsizei height,
+               const struct gl_pixelstore_attrib *unpack,
+               const GLubyte *bitmap )
+{
+   struct intel_context *intel = intel_context(ctx);
+   struct intel_region *dst = intel_drawbuf_region(intel);
+   GLfloat tmpColor[4];
+   GLubyte ubcolor[4];
+   GLuint color8888, color565;
+
+   if (!dst)
+       return GL_FALSE;
+
+   if (unpack->BufferObj->Name) {
+      bitmap = map_pbo(ctx, width, height, unpack, bitmap);
+      if (bitmap == NULL)
+        return GL_TRUE;        /* even though this is an error, we're done */
+   }
+
+   COPY_4V(tmpColor, ctx->Current.RasterColor);
+
+   if (NEED_SECONDARY_COLOR(ctx)) {
+       ADD_3V(tmpColor, tmpColor, ctx->Current.RasterSecondaryColor);
+   }
+
+   UNCLAMPED_FLOAT_TO_UBYTE(ubcolor[0], tmpColor[0]);
+   UNCLAMPED_FLOAT_TO_UBYTE(ubcolor[1], tmpColor[1]);
+   UNCLAMPED_FLOAT_TO_UBYTE(ubcolor[2], tmpColor[2]);
+   UNCLAMPED_FLOAT_TO_UBYTE(ubcolor[3], tmpColor[3]);
+
+   color8888 = INTEL_PACKCOLOR8888(ubcolor[0], ubcolor[1], ubcolor[2], ubcolor[3]);
+   color565 = INTEL_PACKCOLOR565(ubcolor[0], ubcolor[1], ubcolor[2]);
+
+   /* Does zoom apply to bitmaps?
+    */
+   if (!intel_check_blit_fragment_ops(ctx, tmpColor[3] == 1.0F) ||
+       ctx->Pixel.ZoomX != 1.0F || 
+       ctx->Pixel.ZoomY != 1.0F)
+      return GL_FALSE;
+
+   LOCK_HARDWARE(intel);
+
+   if (intel->driDrawable->numClipRects) {
+      __DRIdrawablePrivate *dPriv = intel->driDrawable;
+      drm_clip_rect_t *box = dPriv->pClipRects;
+      drm_clip_rect_t dest_rect;
+      GLint nbox = dPriv->numClipRects;
+      GLint srcx = 0, srcy = 0;
+      GLint orig_screen_x1, orig_screen_y2;
+      GLuint i;
+
+
+      orig_screen_x1 = dPriv->x + dstx;
+      orig_screen_y2 = dPriv->y + (dPriv->h - dsty);
+
+      /* Do scissoring in GL coordinates:
+       */
+      if (ctx->Scissor.Enabled)
+      {
+        GLint x = ctx->Scissor.X;
+        GLint y = ctx->Scissor.Y;
+        GLuint w = ctx->Scissor.Width;
+        GLuint h = ctx->Scissor.Height;
+
+         if (!_mesa_clip_to_region(x, y, x+w-1, y+h-1, &dstx, &dsty, &width, &height))
+            goto out;
+      }
+
+      /* Convert from GL to hardware coordinates:
+       */
+      dsty = dPriv->y + (dPriv->h - dsty - height);  
+      dstx = dPriv->x + dstx;
+
+      dest_rect.x1 = dstx < 0 ? 0 : dstx;
+      dest_rect.y1 = dsty < 0 ? 0 : dsty;
+      dest_rect.x2 = dstx + width < 0 ? 0 : dstx + width;
+      dest_rect.y2 = dsty + height < 0 ? 0 : dsty + height;
+
+      for (i = 0; i < nbox; i++) {
+         drm_clip_rect_t rect;
+        int box_w, box_h;
+        GLint px, py;
+        GLuint stipple[32];  
+
+         if (!intel_intersect_cliprects(&rect, &dest_rect, &box[i]))
+            continue;
+
+        /* Now go back to GL coordinates to figure out what subset of
+         * the bitmap we are uploading for this cliprect:
+         */
+        box_w = rect.x2 - rect.x1;
+        box_h = rect.y2 - rect.y1;
+        srcx = rect.x1 - orig_screen_x1;
+        srcy = orig_screen_y2 - rect.y2;
+
+
+#define DY 32
+#define DX 32
+
+        /* Then, finally, chop it all into chunks that can be
+         * digested by hardware:
+         */
+        for (py = 0; py < box_h; py += DY) { 
+           for (px = 0; px < box_w; px += DX) { 
+              int h = MIN2(DY, box_h - py);
+              int w = MIN2(DX, box_w - px); 
+              GLuint sz = ALIGN(ALIGN(w,8) * h, 64)/8;
+              GLenum logic_op = ctx->Color.ColorLogicOpEnabled ?
+                 ctx->Color.LogicOp : GL_COPY;
+
+              assert(sz <= sizeof(stipple));
+              memset(stipple, 0, sz);
+
+              /* May need to adjust this when padding has been introduced in
+               * sz above:
+               */
+              if (get_bitmap_rect(width, height, unpack, 
+                                  bitmap,
+                                  srcx + px, srcy + py, w, h,
+                                  (GLubyte *)stipple,
+                                  8,
+                                  GL_TRUE) == 0)
+                 continue;
+
+              /* 
+               */
+              intelEmitImmediateColorExpandBlit( intel,
+                                                 dst->cpp,
+                                                 (GLubyte *)stipple, 
+                                                 sz,
+                                                 (dst->cpp == 2) ? color565 : color8888,
+                                                 dst->pitch,
+                                                 dst->buffer,
+                                                 0,
+                                                 dst->tiling,
+                                                 rect.x1 + px,
+                                                 rect.y2 - (py + h),
+                                                 w, h,
+                                                 logic_op);
+           } 
+        } 
+      }
+   }
+out:
+   UNLOCK_HARDWARE(intel);
+
+
+   if (unpack->BufferObj->Name) {
+      /* done with PBO so unmap it now */
+      ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+                              unpack->BufferObj);
+   }
+
+   return GL_TRUE;
+}
+
+
+
+
+
+/* There are a large number of possible ways to implement bitmap on
+ * this hardware, most of them have some sort of drawback.  Here are a
+ * few that spring to mind:
+ * 
+ * Blit:
+ *    - XY_MONO_SRC_BLT_CMD
+ *         - use XY_SETUP_CLIP_BLT for cliprect clipping.
+ *    - XY_TEXT_BLT
+ *    - XY_TEXT_IMMEDIATE_BLT
+ *         - blit per cliprect, subject to maximum immediate data size.
+ *    - XY_COLOR_BLT 
+ *         - per pixel or run of pixels
+ *    - XY_PIXEL_BLT
+ *         - good for sparse bitmaps
+ *
+ * 3D engine:
+ *    - Point per pixel
+ *    - Translate bitmap to an alpha texture and render as a quad
+ *    - Chop bitmap up into 32x32 squares and render w/polygon stipple.
+ */
+void
+intelBitmap(GLcontext * ctx,
+           GLint x, GLint y,
+           GLsizei width, GLsizei height,
+           const struct gl_pixelstore_attrib *unpack,
+           const GLubyte * pixels)
+{
+   if (do_blit_bitmap(ctx, x, y, width, height,
+                          unpack, pixels))
+      return;
+
+   if (INTEL_DEBUG & DEBUG_PIXEL)
+      _mesa_printf("%s: fallback to swrast\n", __FUNCTION__);
+
+   _swrast_Bitmap(ctx, x, y, width, height, unpack, pixels);
+}
diff --git a/src/mesa/drivers/dri/intel/intel_pixel_copy.c b/src/mesa/drivers/dri/intel/intel_pixel_copy.c
new file mode 100644 (file)
index 0000000..1c72d61
--- /dev/null
@@ -0,0 +1,376 @@
+/**************************************************************************
+ * 
+ * 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 "image.h"
+#include "state.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "swrast/swrast.h"
+
+#include "intel_screen.h"
+#include "intel_context.h"
+#include "intel_batchbuffer.h"
+#include "intel_buffers.h"
+#include "intel_blit.h"
+#include "intel_regions.h"
+#include "intel_pixel.h"
+
+#define FILE_DEBUG_FLAG DEBUG_PIXEL
+
+static struct intel_region *
+copypix_src_region(struct intel_context *intel, GLenum type)
+{
+   switch (type) {
+   case GL_COLOR:
+      return intel_readbuf_region(intel);
+   case GL_DEPTH:
+      /* Don't think this is really possible execpt at 16bpp, when we have no stencil.
+       */
+      if (intel->depth_region && intel->depth_region->cpp == 2)
+         return intel->depth_region;
+   case GL_STENCIL:
+      /* Don't think this is really possible. 
+       */
+      break;
+   case GL_DEPTH_STENCIL_EXT:
+      /* Does it matter whether it is stencil/depth or depth/stencil?
+       */
+      return intel->depth_region;
+   default:
+      break;
+   }
+
+   return NULL;
+}
+
+
+/**
+ * Check if any fragment operations are in effect which might effect
+ * glCopyPixels.  Differs from intel_check_blit_fragment_ops in that
+ * we allow Scissor.
+ */
+static GLboolean
+intel_check_copypixel_blit_fragment_ops(GLcontext * ctx)
+{
+   if (ctx->NewState)
+      _mesa_update_state(ctx);
+
+   /* Could do logicop with the blitter: 
+    */
+   return !(ctx->_ImageTransferState ||
+            ctx->Color.AlphaEnabled ||
+            ctx->Depth.Test ||
+            ctx->Fog.Enabled ||
+            ctx->Stencil.Enabled ||
+            !ctx->Color.ColorMask[0] ||
+            !ctx->Color.ColorMask[1] ||
+            !ctx->Color.ColorMask[2] ||
+            !ctx->Color.ColorMask[3] ||
+            ctx->Texture._EnabledUnits ||
+           ctx->FragmentProgram._Enabled ||
+           ctx->Color.BlendEnabled);
+}
+
+#ifdef I915
+/* Doesn't work for overlapping regions.  Could do a double copy or
+ * just fallback.
+ */
+static GLboolean
+do_texture_copypixels(GLcontext * ctx,
+                      GLint srcx, GLint srcy,
+                      GLsizei width, GLsizei height,
+                      GLint dstx, GLint dsty, GLenum type)
+{
+   struct intel_context *intel = intel_context(ctx);
+   struct intel_region *dst = intel_drawbuf_region(intel);
+   struct intel_region *src = copypix_src_region(intel, type);
+   GLenum src_format;
+   GLenum src_type;
+
+   DBG("%s %d,%d %dx%d --> %d,%d\n", __FUNCTION__, 
+       srcx, srcy, width, height, dstx, dsty);
+
+   if (!src || !dst || type != GL_COLOR)
+      return GL_FALSE;
+
+   /* Can't handle overlapping regions.  Don't have sufficient control
+    * over rasterization to pull it off in-place.  Punt on these for
+    * now.
+    * 
+    * XXX: do a copy to a temporary. 
+    */
+   if (src->buffer == dst->buffer) {
+      drm_clip_rect_t srcbox;
+      drm_clip_rect_t dstbox;
+      drm_clip_rect_t tmp;
+
+      srcbox.x1 = srcx;
+      srcbox.y1 = srcy;
+      srcbox.x2 = srcx + width;
+      srcbox.y2 = srcy + height;
+
+      dstbox.x1 = dstx;
+      dstbox.y1 = dsty;
+      dstbox.x2 = dstx + width * ctx->Pixel.ZoomX;
+      dstbox.y2 = dsty + height * ctx->Pixel.ZoomY;
+
+      DBG("src %d,%d %d,%d\n", srcbox.x1, srcbox.y1, srcbox.x2, srcbox.y2);
+      DBG("dst %d,%d %d,%d (%dx%d) (%f,%f)\n", dstbox.x1, dstbox.y1, dstbox.x2, dstbox.y2,
+         width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY);
+
+      if (intel_intersect_cliprects(&tmp, &srcbox, &dstbox)) {
+         DBG("%s: regions overlap\n", __FUNCTION__);
+         return GL_FALSE;
+      }
+   }
+
+   intelFlush(&intel->ctx);
+
+   intel->vtbl.install_meta_state(intel);
+
+   /* Is this true?  Also will need to turn depth testing on according
+    * to state:
+    */
+   intel->vtbl.meta_no_stencil_write(intel);
+   intel->vtbl.meta_no_depth_write(intel);
+
+   /* Set the 3d engine to draw into the destination region:
+    */
+   intel->vtbl.meta_draw_region(intel, dst, intel->depth_region);
+
+   intel->vtbl.meta_import_pixel_state(intel);
+
+   if (src->cpp == 2) {
+      src_format = GL_RGB;
+      src_type = GL_UNSIGNED_SHORT_5_6_5;
+   }
+   else {
+      src_format = GL_BGRA;
+      src_type = GL_UNSIGNED_BYTE;
+   }
+
+   /* Set the frontbuffer up as a large rectangular texture.
+    */
+   if (!intel->vtbl.meta_tex_rect_source(intel, src->buffer, 0,
+                                         src->pitch,
+                                         src->height, src_format, src_type)) {
+      intel->vtbl.leave_meta_state(intel);
+      return GL_FALSE;
+   }
+
+
+   intel->vtbl.meta_texture_blend_replace(intel);
+
+   LOCK_HARDWARE(intel);
+
+   if (intel->driDrawable->numClipRects) {
+      __DRIdrawablePrivate *dPriv = intel->driDrawable;
+
+
+      srcy = dPriv->h - srcy - height;  /* convert from gl to hardware coords */
+
+      srcx += dPriv->x;
+      srcy += dPriv->y;
+
+      /* Clip against the source region.  This is the only source
+       * clipping we do.  XXX: Just set the texcord wrap mode to clamp
+       * or similar.
+       *
+       */
+      if (0) {
+         GLint orig_x = srcx;
+         GLint orig_y = srcy;
+
+         if (!_mesa_clip_to_region(0, 0, src->pitch, src->height,
+                                   &srcx, &srcy, &width, &height))
+            goto out;
+
+         dstx += srcx - orig_x;
+         dsty += (srcy - orig_y) * ctx->Pixel.ZoomY;
+      }
+
+      /* Just use the regular cliprect mechanism...  Does this need to
+       * even hold the lock???
+       */
+      intel->vtbl.meta_draw_quad(intel,
+                                dstx,
+                                dstx + width * ctx->Pixel.ZoomX,
+                                dPriv->h - (dsty + height * ctx->Pixel.ZoomY),
+                                dPriv->h - (dsty), 0, /* XXX: what z value? */
+                                0x00ff00ff,
+                                srcx, srcx + width, srcy, srcy + height);
+
+    out:
+      intel->vtbl.leave_meta_state(intel);
+      intel_batchbuffer_emit_mi_flush(intel->batch);
+   }
+   UNLOCK_HARDWARE(intel);
+
+   DBG("%s: success\n", __FUNCTION__);
+   return GL_TRUE;
+}
+#endif /* I915 */
+
+
+/**
+ * CopyPixels with the blitter.  Don't support zooming, pixel transfer, etc.
+ */
+static GLboolean
+do_blit_copypixels(GLcontext * ctx,
+                   GLint srcx, GLint srcy,
+                   GLsizei width, GLsizei height,
+                   GLint dstx, GLint dsty, GLenum type)
+{
+   struct intel_context *intel = intel_context(ctx);
+   struct intel_region *dst = intel_drawbuf_region(intel);
+   struct intel_region *src = copypix_src_region(intel, type);
+
+   /* Copypixels can be more than a straight copy.  Ensure all the
+    * extra operations are disabled:
+    */
+   if (!intel_check_copypixel_blit_fragment_ops(ctx) ||
+       ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F)
+      return GL_FALSE;
+
+   if (!src || !dst)
+      return GL_FALSE;
+
+
+
+   intelFlush(&intel->ctx);
+
+   LOCK_HARDWARE(intel);
+
+   if (intel->driDrawable->numClipRects) {
+      __DRIdrawablePrivate *dPriv = intel->driDrawable;
+      __DRIdrawablePrivate *dReadPriv = intel->driReadDrawable;
+      drm_clip_rect_t *box = dPriv->pClipRects;
+      GLint nbox = dPriv->numClipRects;
+      GLint delta_x = 0;
+      GLint delta_y = 0;
+      GLuint i;
+
+      /* Do scissoring in GL coordinates:
+       */
+      if (ctx->Scissor.Enabled)
+      {
+        GLint x = ctx->Scissor.X;
+        GLint y = ctx->Scissor.Y;
+        GLuint w = ctx->Scissor.Width;
+        GLuint h = ctx->Scissor.Height;
+        GLint dx = dstx - srcx;
+         GLint dy = dsty - srcy;
+
+         if (!_mesa_clip_to_region(x, y, x+w-1, y+h-1, &dstx, &dsty, &width, &height))
+            goto out;
+        
+         srcx = dstx - dx;
+         srcy = dsty - dy;
+      }
+
+      /* Convert from GL to hardware coordinates:
+       */
+      dsty = dPriv->h - dsty - height;  
+      srcy = dPriv->h - srcy - height;  
+      dstx += dPriv->x;
+      dsty += dPriv->y;
+      srcx += dReadPriv->x;
+      srcy += dReadPriv->y;
+
+      /* Clip against the source region.  This is the only source
+       * clipping we do.  Dst is clipped with cliprects below.
+       */
+      {
+         delta_x = srcx - dstx;
+         delta_y = srcy - dsty;
+
+         if (!_mesa_clip_to_region(0, 0, src->pitch, src->height,
+                                   &srcx, &srcy, &width, &height))
+            goto out;
+
+         dstx = srcx - delta_x;
+         dsty = srcy - delta_y;
+      }
+
+      /* Could do slightly more clipping: Eg, take the intersection of
+       * the existing set of cliprects and those cliprects translated
+       * by delta_x, delta_y:
+       * 
+       * This code will not overwrite other windows, but will
+       * introduce garbage when copying from obscured window regions.
+       */
+      for (i = 0; i < nbox; i++) {
+        GLint clip_x = dstx;
+        GLint clip_y = dsty;
+        GLint clip_w = width;
+        GLint clip_h = height;
+
+         if (!_mesa_clip_to_region(box[i].x1, box[i].y1, box[i].x2, box[i].y2,
+                                  &clip_x, &clip_y, &clip_w, &clip_h))
+            continue;
+
+         intelEmitCopyBlit(intel, dst->cpp,
+                          src->pitch, src->buffer, 0, src->tiling,
+                          dst->pitch, dst->buffer, 0, dst->tiling,
+                          clip_x + delta_x, clip_y + delta_y, /* srcx, srcy */
+                          clip_x, clip_y, /* dstx, dsty */
+                          clip_w, clip_h,
+                          ctx->Color.ColorLogicOpEnabled ?
+                          ctx->Color.LogicOp : GL_COPY);
+      }
+   }
+out:
+   UNLOCK_HARDWARE(intel);
+
+   DBG("%s: success\n", __FUNCTION__);
+   return GL_TRUE;
+}
+
+
+void
+intelCopyPixels(GLcontext * ctx,
+                GLint srcx, GLint srcy,
+                GLsizei width, GLsizei height,
+                GLint destx, GLint desty, GLenum type)
+{
+   if (INTEL_DEBUG & DEBUG_PIXEL)
+      fprintf(stderr, "%s\n", __FUNCTION__);
+
+   if (do_blit_copypixels(ctx, srcx, srcy, width, height, destx, desty, type))
+      return;
+
+#ifdef I915
+   if (do_texture_copypixels(ctx, srcx, srcy, width, height, destx, desty, type))
+      return;
+#endif
+
+   DBG("fallback to _swrast_CopyPixels\n");
+
+   _swrast_CopyPixels(ctx, srcx, srcy, width, height, destx, desty, type);
+}
diff --git a/src/mesa/drivers/dri/intel/intel_pixel_draw.c b/src/mesa/drivers/dri/intel/intel_pixel_draw.c
new file mode 100644 (file)
index 0000000..47460da
--- /dev/null
@@ -0,0 +1,379 @@
+/**************************************************************************
+ * 
+ * Copyright 2006 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 portionsalloc
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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 "image.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "bufferobj.h"
+#include "swrast/swrast.h"
+
+#include "intel_screen.h"
+#include "intel_context.h"
+#include "intel_batchbuffer.h"
+#include "intel_blit.h"
+#include "intel_buffers.h"
+#include "intel_regions.h"
+#include "intel_pixel.h"
+#include "intel_buffer_objects.h"
+#include "intel_tris.h"
+
+
+
+static GLboolean
+do_texture_drawpixels(GLcontext * ctx,
+                      GLint x, GLint y,
+                      GLsizei width, GLsizei height,
+                      GLenum format, GLenum type,
+                      const struct gl_pixelstore_attrib *unpack,
+                      const GLvoid * pixels)
+{
+   struct intel_context *intel = intel_context(ctx);
+   struct intel_region *dst = intel_drawbuf_region(intel);
+   struct intel_buffer_object *src = intel_buffer_object(unpack->BufferObj);
+   GLuint rowLength = unpack->RowLength ? unpack->RowLength : width;
+   GLuint src_offset;
+
+   if (INTEL_DEBUG & DEBUG_PIXEL)
+      fprintf(stderr, "%s\n", __FUNCTION__);
+
+   intelFlush(&intel->ctx);
+
+   if (!dst)
+      return GL_FALSE;
+
+   intel->vtbl.render_start(intel);
+   intel->vtbl.emit_state(intel);
+
+   if (src) {
+      if (!_mesa_validate_pbo_access(2, unpack, width, height, 1,
+                                     format, type, pixels)) {
+         _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels");
+         return GL_TRUE;
+      }
+   }
+   else {
+      /* PBO only for now:
+       */
+      if (INTEL_DEBUG & DEBUG_PIXEL)
+        _mesa_printf("%s - not PBO\n", __FUNCTION__);
+      return GL_FALSE;
+   }
+
+   /* There are a couple of things we can't do yet, one of which is
+    * set the correct state for pixel operations when GL texturing is
+    * enabled.  That's a pretty rare state and probably not worth the
+    * effort.  A completely device-independent version of this may do
+    * more.
+    *
+    * Similarly, we make no attempt to merge metaops processing with
+    * an enabled fragment program, though it would certainly be
+    * possible.
+    */
+   if (!intel_check_meta_tex_fragment_ops(ctx)) {
+      if (INTEL_DEBUG & DEBUG_PIXEL)
+         _mesa_printf("%s - bad GL fragment state for metaops texture\n",
+                      __FUNCTION__);
+      return GL_FALSE;
+   }
+
+   intel->vtbl.install_meta_state(intel);
+
+
+   /* Is this true?  Also will need to turn depth testing on according
+    * to state:
+    */
+   intel->vtbl.meta_no_stencil_write(intel);
+   intel->vtbl.meta_no_depth_write(intel);
+
+   /* Set the 3d engine to draw into the destination region:
+    */
+   intel->vtbl.meta_draw_region(intel, dst, intel->depth_region);
+
+   intel->vtbl.meta_import_pixel_state(intel);
+
+   src_offset = (GLuint) _mesa_image_address(2, unpack, pixels, width, height,
+                                             format, type, 0, 0, 0);
+
+
+   /* Setup the pbo up as a rectangular texture, if possible.
+    *
+    * TODO: This is almost always possible if the i915 fragment
+    * program is adjusted to correctly swizzle the sampled colors.
+    * The major exception is any 24bit texture, like RGB888, for which
+    * there is no hardware support.  
+    */
+   if (!intel->vtbl.meta_tex_rect_source(intel, src->buffer, src_offset,
+                                         rowLength, height, format, type)) {
+      intel->vtbl.leave_meta_state(intel);
+      return GL_FALSE;
+   }
+
+   intel->vtbl.meta_texture_blend_replace(intel);
+
+
+   LOCK_HARDWARE(intel);
+
+   if (intel->driDrawable->numClipRects) {
+      __DRIdrawablePrivate *dPriv = intel->driDrawable;
+      GLint srcx, srcy;
+      GLint dstx, dsty;
+
+      dstx = x;
+      dsty = dPriv->h - (y + height);
+
+      srcx = 0;                 /* skiprows/pixels already done */
+      srcy = 0;
+
+      if (0) {
+         const GLint orig_x = dstx;
+         const GLint orig_y = dsty;
+
+         if (!_mesa_clip_to_region(0, 0, dst->pitch, dst->height,
+                                   &dstx, &dsty, &width, &height))
+            goto out;
+
+         srcx += dstx - orig_x;
+         srcy += dsty - orig_y;
+      }
+
+
+      if (INTEL_DEBUG & DEBUG_PIXEL)
+         _mesa_printf("draw %d,%d %dx%d\n", dstx, dsty, width, height);
+
+      /* Must use the regular cliprect mechanism in order to get the
+       * drawing origin set correctly.  Otherwise scissor state is in
+       * incorrect coordinate space.  Does this even need to hold the
+       * lock???
+       */
+      intel->vtbl.meta_draw_quad(intel,
+                                dstx, dstx + width * ctx->Pixel.ZoomX,
+                                dPriv->h - (y + height * ctx->Pixel.ZoomY),
+                                dPriv->h - (y),
+                                -ctx->Current.RasterPos[2] * .5,
+                                0x00ff00ff,
+                                srcx, srcx + width, srcy + height, srcy);
+    out:
+      intel->vtbl.leave_meta_state(intel);
+      intel_batchbuffer_emit_mi_flush(intel->batch);
+   }
+   UNLOCK_HARDWARE(intel);
+   return GL_TRUE;
+}
+
+
+
+
+
+/* Pros:  
+ *   - no waiting for idle before updating framebuffer.
+ *   
+ * Cons:
+ *   - if upload is by memcpy, this may actually be slower than fallback path.
+ *   - uploads the whole image even if destination is clipped
+ *   
+ * Need to benchmark.
+ *
+ * Given the questions about performance, implement for pbo's only.
+ * This path is definitely a win if the pbo is already in agp.  If it
+ * turns out otherwise, we can add the code necessary to upload client
+ * data to agp space before performing the blit.  (Though it may turn
+ * out to be better/simpler just to use the texture engine).
+ */
+static GLboolean
+do_blit_drawpixels(GLcontext * ctx,
+                   GLint x, GLint y,
+                   GLsizei width, GLsizei height,
+                   GLenum format, GLenum type,
+                   const struct gl_pixelstore_attrib *unpack,
+                   const GLvoid * pixels)
+{
+   struct intel_context *intel = intel_context(ctx);
+   struct intel_region *dest = intel_drawbuf_region(intel);
+   struct intel_buffer_object *src = intel_buffer_object(unpack->BufferObj);
+   GLuint src_offset;
+   GLuint rowLength;
+
+   if (INTEL_DEBUG & DEBUG_PIXEL)
+      _mesa_printf("%s\n", __FUNCTION__);
+
+
+   if (!dest) {
+      if (INTEL_DEBUG & DEBUG_PIXEL)
+         _mesa_printf("%s - no dest\n", __FUNCTION__);
+      return GL_FALSE;
+   }
+
+   if (src) {
+      /* This validation should be done by core mesa:
+       */
+      if (!_mesa_validate_pbo_access(2, unpack, width, height, 1,
+                                     format, type, pixels)) {
+         _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels");
+         return GL_TRUE;
+      }
+   }
+   else {
+      /* PBO only for now:
+       */
+      if (INTEL_DEBUG & DEBUG_PIXEL)
+         _mesa_printf("%s - not PBO\n", __FUNCTION__);
+      return GL_FALSE;
+   }
+
+   if (!intel_check_blit_format(dest, format, type)) {
+      if (INTEL_DEBUG & DEBUG_PIXEL)
+         _mesa_printf("%s - bad format for blit\n", __FUNCTION__);
+      return GL_FALSE;
+   }
+
+   if (!intel_check_blit_fragment_ops(ctx, GL_FALSE)) {
+      if (INTEL_DEBUG & DEBUG_PIXEL)
+         _mesa_printf("%s - bad GL fragment state for blitter\n",
+                      __FUNCTION__);
+      return GL_FALSE;
+   }
+
+   if (ctx->Pixel.ZoomX != 1.0F) {
+      if (INTEL_DEBUG & DEBUG_PIXEL)
+         _mesa_printf("%s - bad PixelZoomX for blit\n", __FUNCTION__);
+      return GL_FALSE;
+   }
+
+
+   if (unpack->RowLength > 0)
+      rowLength = unpack->RowLength;
+   else
+      rowLength = width;
+
+   if (ctx->Pixel.ZoomY == -1.0F) {
+      if (INTEL_DEBUG & DEBUG_PIXEL)
+         _mesa_printf("%s - bad PixelZoomY for blit\n", __FUNCTION__);
+      return GL_FALSE;          /* later */
+      y -= height;
+   }
+   else if (ctx->Pixel.ZoomY == 1.0F) {
+      rowLength = -rowLength;
+   }
+   else {
+      if (INTEL_DEBUG & DEBUG_PIXEL)
+         _mesa_printf("%s - bad PixelZoomY for blit\n", __FUNCTION__);
+      return GL_FALSE;
+   }
+
+   src_offset = (GLuint) _mesa_image_address(2, unpack, pixels, width, height,
+                                             format, type, 0, 0, 0);
+
+   intelFlush(&intel->ctx);
+   LOCK_HARDWARE(intel);
+
+   if (intel->driDrawable->numClipRects) {
+      __DRIdrawablePrivate *dPriv = intel->driDrawable;
+      int nbox = dPriv->numClipRects;
+      drm_clip_rect_t *box = dPriv->pClipRects;
+      drm_clip_rect_t rect;
+      drm_clip_rect_t dest_rect;
+      dri_bo *src_buffer = intel_bufferobj_buffer(intel, src, INTEL_READ);
+      int i;
+
+      dest_rect.x1 = dPriv->x + x;
+      dest_rect.y1 = dPriv->y + dPriv->h - (y + height);
+      dest_rect.x2 = dest_rect.x1 + width;
+      dest_rect.y2 = dest_rect.y1 + height;
+
+      for (i = 0; i < nbox; i++) {
+         if (!intel_intersect_cliprects(&rect, &dest_rect, &box[i]))
+            continue;
+
+         intelEmitCopyBlit(intel,
+                           dest->cpp,
+                           rowLength, src_buffer, src_offset, GL_FALSE,
+                           dest->pitch, dest->buffer, 0, dest->tiling,
+                           rect.x1 - dest_rect.x1,
+                           rect.y2 - dest_rect.y2,
+                           rect.x1,
+                           rect.y1, rect.x2 - rect.x1, rect.y2 - rect.y1,
+                          ctx->Color.ColorLogicOpEnabled ?
+                          ctx->Color.LogicOp : GL_COPY);
+      }
+   }
+   UNLOCK_HARDWARE(intel);
+
+   if (INTEL_DEBUG & DEBUG_PIXEL)
+      _mesa_printf("%s - DONE\n", __FUNCTION__);
+
+   return GL_TRUE;
+}
+
+
+
+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 (do_blit_drawpixels(ctx, x, y, width, height, format, type,
+                          unpack, pixels))
+      return;
+
+   if (do_texture_drawpixels(ctx, x, y, width, height, format, type,
+                             unpack, pixels))
+      return;
+
+
+   if (INTEL_DEBUG & DEBUG_PIXEL)
+      _mesa_printf("%s: fallback to swrast\n", __FUNCTION__);
+
+   if (ctx->FragmentProgram._Current == ctx->FragmentProgram._TexEnvProgram) {
+      /*
+       * We don't want the i915 texenv program to be applied to DrawPixels.
+       * This is really just a performance optimization (mesa will other-
+       * wise happily run the fragment program on each pixel in the image).
+       */
+      struct gl_fragment_program *fpSave = ctx->FragmentProgram._Current;
+   /* can't just set current frag prog to 0 here as on buffer resize
+      we'll get new state checks which will segfault. Remains a hack. */
+      ctx->FragmentProgram._Current = NULL;
+      ctx->FragmentProgram._UseTexEnvProgram = GL_FALSE;
+      ctx->FragmentProgram._Active = GL_FALSE;
+      _swrast_DrawPixels( ctx, x, y, width, height, format, type,
+                          unpack, pixels );
+      ctx->FragmentProgram._Current = fpSave;
+      ctx->FragmentProgram._UseTexEnvProgram = GL_TRUE;
+      ctx->FragmentProgram._Active = GL_TRUE;
+      _swrast_InvalidateState(ctx, _NEW_PROGRAM);
+   }
+   else {
+      _swrast_DrawPixels( ctx, x, y, width, height, format, type,
+                          unpack, pixels );
+   }
+}
diff --git a/src/mesa/drivers/dri/intel/intel_reg.h b/src/mesa/drivers/dri/intel/intel_reg.h
new file mode 100644 (file)
index 0000000..96af7e1
--- /dev/null
@@ -0,0 +1,208 @@
+/**************************************************************************
+ * 
+ * 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.
+ * 
+ **************************************************************************/
+
+#define CMD_MI                         (0x0 << 29)
+#define CMD_2D                         (0x2 << 29)
+#define CMD_3D                         (0x3 << 29)
+
+#define MI_BATCH_BUFFER_END            (CMD_MI | 0xA << 23)
+
+#define MI_FLUSH                       (CMD_MI | (4 << 23))
+#define FLUSH_MAP_CACHE                                (1 << 0)
+#define INHIBIT_FLUSH_RENDER_CACHE             (1 << 2)
+
+/* Stalls command execution waiting for the given events to have occurred. */
+#define MI_WAIT_FOR_EVENT               (CMD_MI | (0x3 << 23))
+#define MI_WAIT_FOR_PLANE_B_FLIP        (1<<6)
+#define MI_WAIT_FOR_PLANE_A_FLIP        (1<<2)
+
+/* p189 */
+#define _3DSTATE_LOAD_STATE_IMMEDIATE_1   (CMD_3D | (0x1d<<24) | (0x04<<16))
+#define I1_LOAD_S(n)                      (1<<(4+n))
+
+/** @{
+ * 915 definitions
+ */
+#define S0_VB_OFFSET_MASK              0xffffffc
+#define S0_AUTO_CACHE_INV_DISABLE      (1<<0)
+/** @} */
+
+/** @{
+ * 830 definitions
+ */
+#define S0_VB_OFFSET_MASK_830          0xffffff8
+#define S0_VB_PITCH_SHIFT_830          1
+#define S0_VB_ENABLE_830               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)
+#define S2_TEX_COUNT_SHIFT_830         12
+#define S2_VERTEX_0_WIDTH_SHIFT_830    0
+#define S2_VERTEX_1_WIDTH_SHIFT_830    6
+/* 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
+
+/* Primitive dispatch on 830-945 */
+#define _3DPRIMITIVE                   (CMD_3D | (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 XY_SETUP_BLT_CMD               (CMD_2D | (0x01 << 22) | 6)
+
+#define XY_COLOR_BLT_CMD               (CMD_2D | (0x50 << 22) | 4)
+
+#define XY_SRC_COPY_BLT_CMD             (CMD_2D | (0x53 << 22) | 6)
+
+#define XY_TEXT_IMMEDIATE_BLIT_CMD     (CMD_2D | (0x31 << 22))
+# define XY_TEXT_BYTE_PACKED           (1 << 16)
+
+/* BR00 */
+#define XY_BLT_WRITE_ALPHA     (1 << 21)
+#define XY_BLT_WRITE_RGB       (1 << 20)
+#define XY_SRC_TILED           (1 << 15)
+#define XY_DST_TILED           (1 << 11)
+
+/* BR13 */
+#define BR13_565               (0x1 << 24)
+#define BR13_8888              (0x3 << 24)
+
+#define FENCE_LINEAR 0
+#define FENCE_XMAJOR 1
+#define FENCE_YMAJOR 2
diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c
new file mode 100644 (file)
index 0000000..cb0f4ba
--- /dev/null
@@ -0,0 +1,568 @@
+/**************************************************************************
+ * 
+ * Copyright 2006 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.
+ * 
+ **************************************************************************/
+
+/* Provide additional functionality on top of bufmgr buffers:
+ *   - 2d semantics and blit operations
+ *   - refcounting of buffers for multiple images in a buffer.
+ *   - refcounting of buffer mappings.
+ *   - some logic for moving the buffers to the best memory pools for
+ *     given operations.
+ *
+ * Most of this is to make it easier to implement the fixed-layout
+ * mipmap tree required by intel hardware in the face of GL's
+ * programming interface where each image can be specifed in random
+ * order and it isn't clear what layout the tree should have until the
+ * last moment.
+ */
+
+#include <sys/ioctl.h>
+#include <errno.h>
+
+#include "intel_context.h"
+#include "intel_regions.h"
+#include "intel_blit.h"
+#include "intel_buffer_objects.h"
+#include "intel_bufmgr.h"
+#include "intel_batchbuffer.h"
+#include "intel_chipset.h"
+
+#define FILE_DEBUG_FLAG DEBUG_REGION
+
+/* XXX: Thread safety?
+ */
+GLubyte *
+intel_region_map(struct intel_context *intel, struct intel_region *region)
+{
+   DBG("%s\n", __FUNCTION__);
+   if (!region->map_refcount++) {
+      if (region->pbo)
+         intel_region_cow(intel, region);
+
+      dri_bo_map(region->buffer, GL_TRUE);
+      region->map = region->buffer->virtual;
+   }
+
+   return region->map;
+}
+
+void
+intel_region_unmap(struct intel_context *intel, struct intel_region *region)
+{
+   DBG("%s\n", __FUNCTION__);
+   if (!--region->map_refcount) {
+      dri_bo_unmap(region->buffer);
+      region->map = NULL;
+   }
+}
+
+static int
+intel_set_region_tiling_gem(struct intel_context *intel,
+                           struct intel_region *region,
+                           uint32_t bo_handle)
+{
+   struct drm_i915_gem_get_tiling get_tiling;
+   int ret;
+
+   memset(&get_tiling, 0, sizeof(get_tiling));
+
+   get_tiling.handle = bo_handle;
+   ret = ioctl(intel->driFd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling);
+   if (ret != 0) {
+      fprintf(stderr, "Failed to get tiling state for region: %s\n",
+             strerror(errno));
+      return ret;
+   }
+
+   region->tiling = get_tiling.tiling_mode;
+   region->bit_6_swizzle = get_tiling.swizzle_mode;
+
+   return 0;
+}
+
+static struct intel_region *
+intel_region_alloc_internal(struct intel_context *intel,
+                           GLuint cpp,
+                           GLuint width, GLuint height, GLuint pitch,
+                           dri_bo *buffer)
+{
+   struct intel_region *region;
+
+   DBG("%s\n", __FUNCTION__);
+
+   if (buffer == NULL)
+      return NULL;
+
+   region = calloc(sizeof(*region), 1);
+   region->cpp = cpp;
+   region->width = width;
+   region->height = height;
+   region->pitch = pitch;
+   region->refcount = 1;
+   region->buffer = buffer;
+
+   /* Default to no tiling */
+   region->tiling = I915_TILING_NONE;
+   region->bit_6_swizzle = I915_BIT_6_SWIZZLE_NONE;
+
+   return region;
+}
+
+struct intel_region *
+intel_region_alloc(struct intel_context *intel,
+                   GLuint cpp, GLuint width, GLuint height, GLuint pitch)
+{
+   dri_bo *buffer;
+
+   buffer = dri_bo_alloc(intel->bufmgr, "region",
+                        pitch * cpp * height, 64);
+
+   return intel_region_alloc_internal(intel, cpp, width, height, pitch, buffer);
+}
+
+struct intel_region *
+intel_region_alloc_for_handle(struct intel_context *intel,
+                             GLuint cpp,
+                             GLuint width, GLuint height, GLuint pitch,
+                             GLuint handle, const char *name)
+{
+   struct intel_region *region;
+   dri_bo *buffer;
+
+   buffer = intel_bo_gem_create_from_name(intel->bufmgr, name, handle);
+
+   region = intel_region_alloc_internal(intel, cpp,
+                                       width, height, pitch, buffer);
+   if (region == NULL)
+      return region;
+
+   intel_set_region_tiling_gem(intel, region, handle);
+
+   return region;
+}
+
+void
+intel_region_reference(struct intel_region **dst, struct intel_region *src)
+{
+   if (src)
+      DBG("%s %d\n", __FUNCTION__, src->refcount);
+
+   assert(*dst == NULL);
+   if (src) {
+      src->refcount++;
+      *dst = src;
+   }
+}
+
+void
+intel_region_release(struct intel_region **region_handle)
+{
+   struct intel_region *region = *region_handle;
+
+   if (region == NULL)
+      return;
+
+   DBG("%s %d\n", __FUNCTION__, region->refcount - 1);
+
+   ASSERT(region->refcount > 0);
+   region->refcount--;
+
+   if (region->refcount == 0) {
+      assert(region->map_refcount == 0);
+
+      if (region->pbo)
+        region->pbo->region = NULL;
+      region->pbo = NULL;
+      dri_bo_unreference(region->buffer);
+
+      if (region->classic_map != NULL) {
+        drmUnmap(region->classic_map,
+                       region->pitch * region->cpp * region->height);
+      }
+
+      free(region);
+   }
+   *region_handle = NULL;
+}
+
+/*
+ * XXX Move this into core Mesa?
+ */
+void
+_mesa_copy_rect(GLubyte * dst,
+                GLuint cpp,
+                GLuint dst_pitch,
+                GLuint dst_x,
+                GLuint dst_y,
+                GLuint width,
+                GLuint height,
+                const GLubyte * src,
+                GLuint src_pitch, GLuint src_x, GLuint src_y)
+{
+   GLuint i;
+
+   dst_pitch *= cpp;
+   src_pitch *= cpp;
+   dst += dst_x * cpp;
+   src += src_x * cpp;
+   dst += dst_y * dst_pitch;
+   src += src_y * dst_pitch;
+   width *= cpp;
+
+   if (width == dst_pitch && width == src_pitch)
+      memcpy(dst, src, height * width);
+   else {
+      for (i = 0; i < height; i++) {
+         memcpy(dst, src, width);
+         dst += dst_pitch;
+         src += src_pitch;
+      }
+   }
+}
+
+
+/* Upload data to a rectangular sub-region.  Lots of choices how to do this:
+ *
+ * - memcpy by span to current destination
+ * - upload data as new buffer and blit
+ *
+ * Currently always memcpy.
+ */
+void
+intel_region_data(struct intel_context *intel,
+                  struct intel_region *dst,
+                  GLuint dst_offset,
+                  GLuint dstx, GLuint dsty,
+                  const void *src, GLuint src_pitch,
+                  GLuint srcx, GLuint srcy, GLuint width, GLuint height)
+{
+   GLboolean locked = GL_FALSE;
+
+   DBG("%s\n", __FUNCTION__);
+
+   if (intel == NULL)
+      return;
+
+   if (dst->pbo) {
+      if (dstx == 0 &&
+          dsty == 0 && width == dst->pitch && height == dst->height)
+         intel_region_release_pbo(intel, dst);
+      else
+         intel_region_cow(intel, dst);
+   }
+
+   if (!intel->locked) {
+      LOCK_HARDWARE(intel);
+      locked = GL_TRUE;
+   }
+
+   _mesa_copy_rect(intel_region_map(intel, dst) + dst_offset,
+                   dst->cpp,
+                   dst->pitch,
+                   dstx, dsty, width, height, src, src_pitch, srcx, srcy);
+
+   intel_region_unmap(intel, dst);
+
+   if (locked)
+      UNLOCK_HARDWARE(intel);
+
+}
+
+/* Copy rectangular sub-regions. Need better logic about when to
+ * push buffers into AGP - will currently do so whenever possible.
+ */
+void
+intel_region_copy(struct intel_context *intel,
+                  struct intel_region *dst,
+                  GLuint dst_offset,
+                  GLuint dstx, GLuint dsty,
+                  struct intel_region *src,
+                  GLuint src_offset,
+                  GLuint srcx, GLuint srcy, GLuint width, GLuint height)
+{
+   DBG("%s\n", __FUNCTION__);
+
+   if (intel == NULL)
+      return;
+
+   if (dst->pbo) {
+      if (dstx == 0 &&
+          dsty == 0 && width == dst->pitch && height == dst->height)
+         intel_region_release_pbo(intel, dst);
+      else
+         intel_region_cow(intel, dst);
+   }
+
+   assert(src->cpp == dst->cpp);
+
+   intelEmitCopyBlit(intel,
+                     dst->cpp,
+                     src->pitch, src->buffer, src_offset, src->tiling,
+                     dst->pitch, dst->buffer, dst_offset, dst->tiling,
+                     srcx, srcy, dstx, dsty, width, height,
+                    GL_COPY);
+}
+
+/* Fill a rectangular sub-region.  Need better logic about when to
+ * push buffers into AGP - will currently do so whenever possible.
+ */
+void
+intel_region_fill(struct intel_context *intel,
+                  struct intel_region *dst,
+                  GLuint dst_offset,
+                  GLuint dstx, GLuint dsty,
+                  GLuint width, GLuint height, GLuint color)
+{
+   DBG("%s\n", __FUNCTION__);
+
+   if (intel == NULL)
+      return;   
+
+   if (dst->pbo) {
+      if (dstx == 0 &&
+          dsty == 0 && width == dst->pitch && height == dst->height)
+         intel_region_release_pbo(intel, dst);
+      else
+         intel_region_cow(intel, dst);
+   }
+
+   intelEmitFillBlit(intel,
+                     dst->cpp,
+                     dst->pitch, dst->buffer, dst_offset, dst->tiling,
+                     dstx, dsty, width, height, color);
+}
+
+/* Attach to a pbo, discarding our data.  Effectively zero-copy upload
+ * the pbo's data.
+ */
+void
+intel_region_attach_pbo(struct intel_context *intel,
+                        struct intel_region *region,
+                        struct intel_buffer_object *pbo)
+{
+   if (region->pbo == pbo)
+      return;
+
+   /* If there is already a pbo attached, break the cow tie now.
+    * Don't call intel_region_release_pbo() as that would
+    * unnecessarily allocate a new buffer we would have to immediately
+    * discard.
+    */
+   if (region->pbo) {
+      region->pbo->region = NULL;
+      region->pbo = NULL;
+   }
+
+   if (region->buffer) {
+      dri_bo_unreference(region->buffer);
+      region->buffer = NULL;
+   }
+
+   region->pbo = pbo;
+   region->pbo->region = region;
+   dri_bo_reference(pbo->buffer);
+   region->buffer = pbo->buffer;
+}
+
+
+/* Break the COW tie to the pbo and allocate a new buffer.
+ * The pbo gets to keep the data.
+ */
+void
+intel_region_release_pbo(struct intel_context *intel,
+                         struct intel_region *region)
+{
+   assert(region->buffer == region->pbo->buffer);
+   region->pbo->region = NULL;
+   region->pbo = NULL;
+   dri_bo_unreference(region->buffer);
+   region->buffer = NULL;
+
+   region->buffer = dri_bo_alloc(intel->bufmgr, "region",
+                                region->pitch * region->cpp * region->height,
+                                64);
+}
+
+/* Break the COW tie to the pbo.  Both the pbo and the region end up
+ * with a copy of the data.
+ */
+void
+intel_region_cow(struct intel_context *intel, struct intel_region *region)
+{
+   struct intel_buffer_object *pbo = region->pbo;
+   GLboolean was_locked = intel->locked;
+
+   if (intel == NULL)
+      return;
+
+   intel_region_release_pbo(intel, region);
+
+   assert(region->cpp * region->pitch * region->height == pbo->Base.Size);
+
+   DBG("%s (%d bytes)\n", __FUNCTION__, pbo->Base.Size);
+
+   /* Now blit from the texture buffer to the new buffer: 
+    */
+
+   was_locked = intel->locked;
+   if (!was_locked)
+      LOCK_HARDWARE(intel);
+
+   intelEmitCopyBlit(intel,
+                    region->cpp,
+                    region->pitch, region->buffer, 0, region->tiling,
+                    region->pitch, pbo->buffer, 0, region->tiling,
+                    0, 0, 0, 0,
+                    region->pitch, region->height,
+                    GL_COPY);
+
+   if (!was_locked)
+      UNLOCK_HARDWARE(intel);
+}
+
+dri_bo *
+intel_region_buffer(struct intel_context *intel,
+                    struct intel_region *region, GLuint flag)
+{
+   if (region->pbo) {
+      if (flag == INTEL_WRITE_PART)
+         intel_region_cow(intel, region);
+      else if (flag == INTEL_WRITE_FULL)
+         intel_region_release_pbo(intel, region);
+   }
+
+   return region->buffer;
+}
+
+static struct intel_region *
+intel_recreate_static(struct intel_context *intel,
+                     const char *name,
+                     struct intel_region *region,
+                     intelRegion *region_desc)
+{
+   intelScreenPrivate *intelScreen = intel->intelScreen;
+   int ret;
+
+   if (region == NULL) {
+      region = calloc(sizeof(*region), 1);
+      region->refcount = 1;
+   }
+
+   if (intel->ctx.Visual.rgbBits == 24)
+      region->cpp = 4;
+   else
+      region->cpp = intel->ctx.Visual.rgbBits / 8;
+   region->pitch = intelScreen->pitch;
+   region->height = intelScreen->height;     /* needed? */
+
+   if (intel->ttm) {
+      assert(region_desc->bo_handle != -1);
+      region->buffer = intel_bo_gem_create_from_name(intel->bufmgr,
+                                                    name,
+                                                    region_desc->bo_handle);
+
+      intel_set_region_tiling_gem(intel, region, region_desc->bo_handle);
+   } else {
+      ret = drmMap(intel->driFd, region_desc->handle,
+                  region->pitch * region->cpp * region->height,
+                  &region->classic_map);
+      if (ret != 0) {
+        fprintf(stderr, "Failed to drmMap %s buffer\n", name);
+        free(region);
+        return NULL;
+      }
+
+      region->buffer = intel_bo_fake_alloc_static(intel->bufmgr,
+                                                 name,
+                                                 region_desc->offset,
+                                                 region->pitch * region->cpp *
+                                                 region->height,
+                                                 region->classic_map);
+
+      /* The sarea just gives us a boolean for whether it's tiled or not,
+       * instead of which tiling mode it is.  Guess.
+       */
+      if (region_desc->tiled) {
+        if (IS_965(intel->intelScreen->deviceID) &&
+            region_desc == &intelScreen->depth)
+           region->tiling = I915_TILING_Y;
+        else
+           region->tiling = I915_TILING_X;
+      } else {
+        region->tiling = I915_TILING_NONE;
+      }
+
+      region->bit_6_swizzle = I915_BIT_6_SWIZZLE_NONE;
+   }
+
+   assert(region->buffer != NULL);
+
+   return region;
+}
+
+/**
+ * Create intel_region structs to describe the static front, back, and depth
+ * buffers created by the xserver.
+ *
+ * Although FBO's mean we now no longer use these as render targets in
+ * all circumstances, they won't go away until the back and depth
+ * buffers become private, and the front buffer will remain even then.
+ *
+ * Note that these don't allocate video memory, just describe
+ * allocations alread made by the X server.
+ */
+void
+intel_recreate_static_regions(struct intel_context *intel)
+{
+   intelScreenPrivate *intelScreen = intel->intelScreen;
+
+   intel->front_region =
+      intel_recreate_static(intel, "front",
+                           intel->front_region,
+                           &intelScreen->front);
+
+   intel->back_region =
+      intel_recreate_static(intel, "back",
+                           intel->back_region,
+                           &intelScreen->back);
+
+#ifdef I915
+   if (intelScreen->third.handle) {
+      intel->third_region =
+        intel_recreate_static(intel, "third",
+                              intel->third_region,
+                              &intelScreen->third);
+   }
+#endif /* I915 */
+
+   /* Still assumes front.cpp == depth.cpp.  We can kill this when we move to
+    * private buffers.
+    */
+   intel->depth_region =
+      intel_recreate_static(intel, "depth",
+                           intel->depth_region,
+                           &intelScreen->depth);
+}
diff --git a/src/mesa/drivers/dri/intel/intel_regions.h b/src/mesa/drivers/dri/intel/intel_regions.h
new file mode 100644 (file)
index 0000000..62eb049
--- /dev/null
@@ -0,0 +1,151 @@
+/**************************************************************************
+ * 
+ * Copyright 2006 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_REGIONS_H
+#define INTEL_REGIONS_H
+
+/** @file intel_regions.h
+ *
+ * Structure definitions and prototypes for intel_region handling, which is
+ * the basic structure for rectangular collections of pixels stored in a dri_bo.
+ */
+
+#include <xf86drm.h>
+
+#include "mtypes.h"
+#include "intel_bufmgr.h"
+
+struct intel_context;
+struct intel_buffer_object;
+
+/**
+ * A layer on top of the bufmgr buffers that adds a few useful things:
+ *
+ * - Refcounting for local buffer references.
+ * - Refcounting for buffer maps
+ * - Buffer dimensions - pitch and height.
+ * - Blitter commands for copying 2D regions between buffers. (really???)
+ */
+struct intel_region
+{
+   dri_bo *buffer;  /**< buffer manager's buffer */
+   GLuint refcount; /**< Reference count for region */
+   GLuint cpp;      /**< bytes per pixel */
+   GLuint width;    /**< in pixels */
+   GLuint height;   /**< in pixels */
+   GLuint pitch;    /**< in pixels */
+   GLubyte *map;    /**< only non-NULL when region is actually mapped */
+   GLuint map_refcount;  /**< Reference count for mapping */
+
+   GLuint draw_offset; /**< Offset of drawing address within the region */
+   uint32_t tiling; /**< Which tiling mode the region is in */
+   uint32_t bit_6_swizzle; /**< GEM flag for address swizzling requirement */
+   drmAddress classic_map; /**< drmMap of the region when not in GEM mode */
+   struct intel_buffer_object *pbo;     /* zero-copy uploads */
+};
+
+
+/* Allocate a refcounted region.  Pointers to regions should only be
+ * copied by calling intel_reference_region().
+ */
+struct intel_region *intel_region_alloc(struct intel_context *intel,
+                                        GLuint cpp, GLuint width,
+                                        GLuint height, GLuint pitch);
+
+struct intel_region *
+intel_region_alloc_for_handle(struct intel_context *intel,
+                             GLuint cpp,
+                             GLuint width, GLuint height, GLuint pitch,
+                             unsigned int handle, const char *name);
+
+void intel_region_reference(struct intel_region **dst,
+                            struct intel_region *src);
+
+void intel_region_release(struct intel_region **ib);
+
+void intel_recreate_static_regions(struct intel_context *intel);
+
+/* Map/unmap regions.  This is refcounted also: 
+ */
+GLubyte *intel_region_map(struct intel_context *intel,
+                          struct intel_region *ib);
+
+void intel_region_unmap(struct intel_context *intel, struct intel_region *ib);
+
+
+/* Upload data to a rectangular sub-region
+ */
+void intel_region_data(struct intel_context *intel,
+                       struct intel_region *dest,
+                       GLuint dest_offset,
+                       GLuint destx, GLuint desty,
+                       const void *src, GLuint src_stride,
+                       GLuint srcx, GLuint srcy, GLuint width, GLuint height);
+
+/* Copy rectangular sub-regions
+ */
+void intel_region_copy(struct intel_context *intel,
+                       struct intel_region *dest,
+                       GLuint dest_offset,
+                       GLuint destx, GLuint desty,
+                       struct intel_region *src,
+                       GLuint src_offset,
+                       GLuint srcx, GLuint srcy, GLuint width, GLuint height);
+
+/* Fill a rectangular sub-region
+ */
+void intel_region_fill(struct intel_context *intel,
+                       struct intel_region *dest,
+                       GLuint dest_offset,
+                       GLuint destx, GLuint desty,
+                       GLuint width, GLuint height, GLuint color);
+
+/* Helpers for zerocopy uploads, particularly texture image uploads:
+ */
+void intel_region_attach_pbo(struct intel_context *intel,
+                             struct intel_region *region,
+                             struct intel_buffer_object *pbo);
+void intel_region_release_pbo(struct intel_context *intel,
+                              struct intel_region *region);
+void intel_region_cow(struct intel_context *intel,
+                      struct intel_region *region);
+
+dri_bo *intel_region_buffer(struct intel_context *intel,
+                           struct intel_region *region,
+                           GLuint flag);
+
+void _mesa_copy_rect(GLubyte * dst,
+                GLuint cpp,
+                GLuint dst_pitch,
+                GLuint dst_x,
+                GLuint dst_y,
+                GLuint width,
+                GLuint height,
+                const GLubyte * src,
+                GLuint src_pitch, GLuint src_x, GLuint src_y);
+
+#endif
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
new file mode 100644 (file)
index 0000000..373e0e1
--- /dev/null
@@ -0,0 +1,749 @@
+/**************************************************************************
+ * 
+ * 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 "vblank.h"
+#include "xmlpool.h"
+
+
+#include "intel_screen.h"
+
+#include "intel_buffers.h"
+#include "intel_tex.h"
+#include "intel_span.h"
+#include "intel_fbo.h"
+#include "intel_chipset.h"
+
+#include "i915_drm.h"
+#include "i830_dri.h"
+#include "intel_regions.h"
+#include "intel_batchbuffer.h"
+#include "intel_bufmgr.h"
+
+PUBLIC 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_ALWAYS_SYNC)
+      /* Options correspond to DRI_CONF_BO_REUSE_DISABLED,
+       * DRI_CONF_BO_REUSE_ALL
+       */
+      DRI_CONF_OPT_BEGIN_V(bo_reuse, enum, 1, "0:1")
+        DRI_CONF_DESC_BEGIN(en, "Buffer object reuse")
+           DRI_CONF_ENUM(0, "Disable buffer object reuse")
+           DRI_CONF_ENUM(1, "Enable reuse of all sizes of buffer objects")
+        DRI_CONF_DESC_END
+      DRI_CONF_OPT_END
+   DRI_CONF_SECTION_END
+   DRI_CONF_SECTION_QUALITY
+      DRI_CONF_FORCE_S3TC_ENABLE(false)
+      DRI_CONF_ALLOW_LARGE_TEXTURES(2)
+   DRI_CONF_SECTION_END
+   DRI_CONF_SECTION_DEBUG
+     DRI_CONF_NO_RAST(false)
+   DRI_CONF_SECTION_END
+DRI_CONF_END;
+
+const GLuint __driNConfigOptions = 6;
+
+#ifdef USE_NEW_INTERFACE
+static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
+#endif /*USE_NEW_INTERFACE */
+
+/**
+ * Map all the memory regions described by the screen.
+ * \return GL_TRUE if success, GL_FALSE if error.
+ */
+GLboolean
+intelMapScreenRegions(__DRIscreenPrivate * sPriv)
+{
+   intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private;
+
+   if (0)
+      _mesa_printf("TEX 0x%08x ", intelScreen->tex.handle);
+   if (intelScreen->tex.size != 0) {
+      if (drmMap(sPriv->fd,
+                intelScreen->tex.handle,
+                intelScreen->tex.size,
+                (drmAddress *) & intelScreen->tex.map) != 0) {
+        intelUnmapScreenRegions(intelScreen);
+        return GL_FALSE;
+      }
+   }
+
+   return GL_TRUE;
+}
+
+void
+intelUnmapScreenRegions(intelScreenPrivate * intelScreen)
+{
+   if (intelScreen->tex.map) {
+      drmUnmap(intelScreen->tex.map, intelScreen->tex.size);
+      intelScreen->tex.map = NULL;
+   }
+}
+
+
+static void
+intelPrintDRIInfo(intelScreenPrivate * intelScreen,
+                  __DRIscreenPrivate * sPriv, I830DRIPtr gDRIPriv)
+{
+   fprintf(stderr, "*** Front size:   0x%x  offset: 0x%x  pitch: %d\n",
+           intelScreen->front.size, intelScreen->front.offset,
+           intelScreen->pitch);
+   fprintf(stderr, "*** Back size:    0x%x  offset: 0x%x  pitch: %d\n",
+           intelScreen->back.size, intelScreen->back.offset,
+           intelScreen->pitch);
+   fprintf(stderr, "*** Depth size:   0x%x  offset: 0x%x  pitch: %d\n",
+           intelScreen->depth.size, intelScreen->depth.offset,
+           intelScreen->pitch);
+   fprintf(stderr, "*** Texture size: 0x%x  offset: 0x%x\n",
+           intelScreen->tex.size, intelScreen->tex.offset);
+   fprintf(stderr, "*** Memory : 0x%x\n", gDRIPriv->mem);
+}
+
+
+static void
+intelPrintSAREA(const struct drm_i915_sarea * sarea)
+{
+   fprintf(stderr, "SAREA: sarea width %d  height %d\n", sarea->width,
+           sarea->height);
+   fprintf(stderr, "SAREA: pitch: %d\n", sarea->pitch);
+   fprintf(stderr,
+           "SAREA: front offset: 0x%08x  size: 0x%x  handle: 0x%x tiled: %d\n",
+           sarea->front_offset, sarea->front_size,
+           (unsigned) sarea->front_handle, sarea->front_tiled);
+   fprintf(stderr,
+           "SAREA: back  offset: 0x%08x  size: 0x%x  handle: 0x%x tiled: %d\n",
+           sarea->back_offset, sarea->back_size,
+           (unsigned) sarea->back_handle, sarea->back_tiled);
+   fprintf(stderr, "SAREA: depth offset: 0x%08x  size: 0x%x  handle: 0x%x tiled: %d\n",
+           sarea->depth_offset, sarea->depth_size,
+           (unsigned) sarea->depth_handle, sarea->depth_tiled);
+   fprintf(stderr, "SAREA: tex   offset: 0x%08x  size: 0x%x  handle: 0x%x\n",
+           sarea->tex_offset, sarea->tex_size, (unsigned) sarea->tex_handle);
+}
+
+
+/**
+ * A number of the screen parameters are obtained/computed from
+ * information in the SAREA.  This function updates those parameters.
+ */
+void
+intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen,
+                           struct drm_i915_sarea * sarea)
+{
+   intelScreen->width = sarea->width;
+   intelScreen->height = sarea->height;
+   intelScreen->pitch = sarea->pitch;
+
+   intelScreen->front.offset = sarea->front_offset;
+   intelScreen->front.handle = sarea->front_handle;
+   intelScreen->front.size = sarea->front_size;
+   intelScreen->front.tiled = sarea->front_tiled;
+
+   intelScreen->back.offset = sarea->back_offset;
+   intelScreen->back.handle = sarea->back_handle;
+   intelScreen->back.size = sarea->back_size;
+   intelScreen->back.tiled = sarea->back_tiled;
+
+   if (intelScreen->driScrnPriv->ddx_version.minor >= 8) {
+      intelScreen->third.offset = sarea->third_offset;
+      intelScreen->third.handle = sarea->third_handle;
+      intelScreen->third.size = sarea->third_size;
+      intelScreen->third.tiled = sarea->third_tiled;
+   }
+
+   intelScreen->depth.offset = sarea->depth_offset;
+   intelScreen->depth.handle = sarea->depth_handle;
+   intelScreen->depth.size = sarea->depth_size;
+   intelScreen->depth.tiled = sarea->depth_tiled;
+
+   if (intelScreen->driScrnPriv->ddx_version.minor >= 9) {
+      intelScreen->front.bo_handle = sarea->front_bo_handle;
+      intelScreen->back.bo_handle = sarea->back_bo_handle;
+      intelScreen->third.bo_handle = sarea->third_bo_handle;
+      intelScreen->depth.bo_handle = sarea->depth_bo_handle;
+   } else {
+      intelScreen->front.bo_handle = -1;
+      intelScreen->back.bo_handle = -1;
+      intelScreen->third.bo_handle = -1;
+      intelScreen->depth.bo_handle = -1;
+   }
+
+   intelScreen->tex.offset = sarea->tex_offset;
+   intelScreen->logTextureGranularity = sarea->log_tex_granularity;
+   intelScreen->tex.handle = sarea->tex_handle;
+   intelScreen->tex.size = sarea->tex_size;
+
+   if (0)
+      intelPrintSAREA(sarea);
+}
+
+static const __DRItexOffsetExtension intelTexOffsetExtension = {
+   { __DRI_TEX_OFFSET },
+   intelSetTexOffset,
+};
+
+static const __DRItexBufferExtension intelTexBufferExtension = {
+    { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION },
+   intelSetTexBuffer,
+};
+
+static const __DRIextension *intelScreenExtensions[] = {
+    &driReadDrawableExtension,
+    &driCopySubBufferExtension.base,
+    &driSwapControlExtension.base,
+    &driFrameTrackingExtension.base,
+    &driMediaStreamCounterExtension.base,
+    &intelTexOffsetExtension.base,
+    &intelTexBufferExtension.base,
+    NULL
+};
+
+static GLboolean
+intel_get_param(__DRIscreenPrivate *psp, int param, int *value)
+{
+   int ret;
+   struct drm_i915_getparam gp;
+
+   gp.param = param;
+   gp.value = value;
+
+   ret = drmCommandWriteRead(psp->fd, DRM_I915_GETPARAM, &gp, sizeof(gp));
+   if (ret) {
+      fprintf(stderr, "drm_i915_getparam: %d\n", ret);
+      return GL_FALSE;
+   }
+
+   return GL_TRUE;
+}
+
+static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv)
+{
+   intelScreenPrivate *intelScreen;
+   I830DRIPtr gDRIPriv = (I830DRIPtr) sPriv->pDevPriv;
+   struct drm_i915_sarea *sarea;
+
+   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;
+   sarea = (struct drm_i915_sarea *)
+      (((GLubyte *) sPriv->pSAREA) + gDRIPriv->sarea_priv_offset);
+   intelScreen->sarea = sarea;
+
+   intelScreen->deviceID = gDRIPriv->deviceID;
+
+   intelUpdateScreenFromSAREA(intelScreen, sarea);
+
+   if (!intelMapScreenRegions(sPriv)) {
+      fprintf(stderr, "\nERROR!  mapping regions\n");
+      _mesa_free(intelScreen);
+      sPriv->private = NULL;
+      return GL_FALSE;
+   }
+
+   if (0)
+      intelPrintDRIInfo(intelScreen, sPriv, gDRIPriv);
+
+   intelScreen->drmMinor = sPriv->drm_version.minor;
+
+   /* Determine if IRQs are active? */
+   if (!intel_get_param(sPriv, I915_PARAM_IRQ_ACTIVE,
+                       &intelScreen->irq_active))
+      return GL_FALSE;
+
+   sPriv->extensions = intelScreenExtensions;
+
+   return GL_TRUE;
+}
+
+
+static void
+intelDestroyScreen(__DRIscreenPrivate * sPriv)
+{
+   intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private;
+
+   dri_bufmgr_destroy(intelScreen->bufmgr);
+   intelUnmapScreenRegions(intelScreen);
+
+   FREE(intelScreen);
+   sPriv->private = NULL;
+}
+
+
+/**
+ * This is called when we need to set up GL rendering to a new X window.
+ */
+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);
+      GLenum rgbFormat = (mesaVis->redBits == 5 ? GL_RGB5 : GL_RGBA8);
+
+      struct intel_framebuffer *intel_fb = CALLOC_STRUCT(intel_framebuffer);
+
+      if (!intel_fb)
+        return GL_FALSE;
+
+      _mesa_initialize_framebuffer(&intel_fb->Base, mesaVis);
+
+      /* setup the hardware-based renderbuffers */
+      intel_fb->color_rb[0] = intel_create_renderbuffer(rgbFormat);
+      _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_FRONT_LEFT,
+                            &intel_fb->color_rb[0]->Base);
+
+      if (mesaVis->doubleBufferMode) {
+        intel_fb->color_rb[1] = intel_create_renderbuffer(rgbFormat);
+
+         _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT,
+                               &intel_fb->color_rb[1]->Base);
+
+        if (screen->third.handle) {
+           struct gl_renderbuffer *tmp_rb = NULL;
+
+           intel_fb->color_rb[2] = intel_create_renderbuffer(rgbFormat);
+           _mesa_reference_renderbuffer(&tmp_rb, &intel_fb->color_rb[2]->Base);
+        }
+      }
+
+      if (mesaVis->depthBits == 24) {
+        if (mesaVis->stencilBits == 8) {
+           /* combined depth/stencil buffer */
+           struct intel_renderbuffer *depthStencilRb
+              = intel_create_renderbuffer(GL_DEPTH24_STENCIL8_EXT);
+           /* note: bind RB to two attachment points */
+           _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH,
+                                  &depthStencilRb->Base);
+           _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_STENCIL,
+                                  &depthStencilRb->Base);
+        } else {
+           struct intel_renderbuffer *depthRb
+              = intel_create_renderbuffer(GL_DEPTH_COMPONENT24);
+           _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH,
+                                  &depthRb->Base);
+        }
+      }
+      else if (mesaVis->depthBits == 16) {
+         /* just 16-bit depth buffer, no hw stencil */
+         struct intel_renderbuffer *depthRb
+           = intel_create_renderbuffer(GL_DEPTH_COMPONENT16);
+         _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, &depthRb->Base);
+      }
+
+      /* now add any/all software-based renderbuffers we may need */
+      _mesa_add_soft_renderbuffers(&intel_fb->Base,
+                                   GL_FALSE, /* never sw color */
+                                   GL_FALSE, /* never sw depth */
+                                   swStencil, mesaVis->accumRedBits > 0,
+                                   GL_FALSE, /* never sw alpha */
+                                   GL_FALSE  /* never sw aux */ );
+      driDrawPriv->driverPrivate = (void *) intel_fb;
+
+      return GL_TRUE;
+   }
+}
+
+static void
+intelDestroyBuffer(__DRIdrawablePrivate * driDrawPriv)
+{
+   _mesa_unreference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)));
+}
+
+
+/**
+ * Get information about previous buffer swaps.
+ */
+static int
+intelGetSwapInfo(__DRIdrawablePrivate * dPriv, __DRIswapInfo * sInfo)
+{
+   struct intel_framebuffer *intel_fb;
+
+   if ((dPriv == NULL) || (dPriv->driverPrivate == NULL)
+       || (sInfo == NULL)) {
+      return -1;
+   }
+
+   intel_fb = dPriv->driverPrivate;
+   sInfo->swap_count = intel_fb->swap_count;
+   sInfo->swap_ust = intel_fb->swap_ust;
+   sInfo->swap_missed_count = intel_fb->swap_missed_count;
+
+   sInfo->swap_missed_usage = (sInfo->swap_missed_count != 0)
+      ? driCalculateSwapUsage(dPriv, 0, intel_fb->swap_missed_ust)
+      : 0.0;
+
+   return 0;
+}
+
+
+/* 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);
+extern GLboolean brwCreateContext(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;
+
+#ifdef I915
+   if (IS_9XX(intelScreen->deviceID)) {
+      if (!IS_965(intelScreen->deviceID)) {
+        return i915CreateContext(mesaVis, driContextPriv,
+                                 sharedContextPrivate);
+      }
+   } else {
+      return i830CreateContext(mesaVis, driContextPriv, sharedContextPrivate);
+   }
+#else
+   if (IS_965(intelScreen->deviceID))
+      return brwCreateContext(mesaVis, driContextPriv, sharedContextPrivate);
+#endif
+   fprintf(stderr, "Unrecognized deviceID %x\n", intelScreen->deviceID);
+   return GL_FALSE;
+}
+
+
+static __DRIconfig **
+intelFillInModes(__DRIscreenPrivate *psp,
+                unsigned pixel_bits, unsigned depth_bits,
+                 unsigned stencil_bits, GLboolean have_back_buffer)
+{
+   __DRIconfig **configs;
+   __GLcontextModes *m;
+   unsigned depth_buffer_factor;
+   unsigned back_buffer_factor;
+   GLenum fb_format;
+   GLenum fb_type;
+   int i;
+
+   /* 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;
+   if (depth_bits == 24)
+      stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits;
+
+   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;
+
+   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;
+   }
+
+   configs = driCreateConfigs(fb_format, fb_type,
+                             depth_bits_array, stencil_bits_array,
+                             depth_buffer_factor, back_buffer_modes,
+                             back_buffer_factor);
+   if (configs == NULL) {
+    fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
+              __LINE__);
+      return NULL;
+   }
+
+   /* Mark the visual as slow if there are "fake" stencil bits.
+    */
+   for (i = 0; configs[i]; i++) {
+      m = &configs[i]->modes;
+      if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
+         m->visualRating = GLX_SLOW_CONFIG;
+      }
+   }
+
+   return configs;
+}
+
+static GLboolean
+intel_init_bufmgr(intelScreenPrivate *intelScreen)
+{
+   GLboolean gem_disable = getenv("INTEL_NO_GEM") != NULL;
+   int gem_kernel = 0;
+   GLboolean gem_supported;
+   struct drm_i915_getparam gp;
+   __DRIscreenPrivate *spriv = intelScreen->driScrnPriv;
+
+   intelScreen->no_hw = getenv("INTEL_NO_HW") != NULL;
+
+   gp.param = I915_PARAM_HAS_GEM;
+   gp.value = &gem_kernel;
+
+   (void) drmCommandWriteRead(spriv->fd, DRM_I915_GETPARAM, &gp, sizeof(gp));
+
+   /* If we've got a new enough DDX that's initializing GEM and giving us
+    * object handles for the shared buffers, use that.
+    */
+   intelScreen->ttm = GL_FALSE;
+   if (intelScreen->driScrnPriv->dri2.enabled)
+       gem_supported = GL_TRUE;
+   else if (intelScreen->driScrnPriv->ddx_version.minor >= 9 &&
+           gem_kernel &&
+           intelScreen->front.bo_handle != -1)
+       gem_supported = GL_TRUE;
+   else
+       gem_supported = GL_FALSE;
+
+   if (!gem_disable && gem_supported) {
+      intelScreen->bufmgr = intel_bufmgr_gem_init(spriv->fd, BATCH_SZ);
+      if (intelScreen->bufmgr != NULL)
+        intelScreen->ttm = GL_TRUE;
+   }
+   /* Otherwise, use the classic buffer manager. */
+   if (intelScreen->bufmgr == NULL) {
+      if (gem_disable) {
+        fprintf(stderr, "GEM disabled.  Using classic.\n");
+      } else {
+        fprintf(stderr, "Failed to initialize GEM.  "
+                "Falling back to classic.\n");
+      }
+
+      if (intelScreen->tex.size == 0) {
+        fprintf(stderr, "[%s:%u] Error initializing buffer manager.\n",
+                __func__, __LINE__);
+        return GL_FALSE;
+      }
+
+      intelScreen->bufmgr =
+        intel_bufmgr_fake_init(spriv->fd,
+                               intelScreen->tex.offset,
+                               intelScreen->tex.map,
+                               intelScreen->tex.size,
+                               (unsigned int * volatile)
+                               &intelScreen->sarea->last_dispatch);
+   }
+
+   /* XXX bufmgr should be per-screen, not per-context */
+   intelScreen->ttm = intelScreen->ttm;
+
+   return GL_TRUE;
+}
+
+/**
+ * This is the driver specific part of the createNewScreen entry point.
+ * Called when using legacy DRI.
+ * 
+ * \todo maybe fold this into intelInitDriver
+ *
+ * \return the __GLcontextModes supported by this driver
+ */
+static const __DRIconfig **intelInitScreen(__DRIscreenPrivate *psp)
+{
+   intelScreenPrivate *intelScreen;
+#ifdef I915
+   static const __DRIversion ddx_expected = { 1, 5, 0 };
+#else
+   static const __DRIversion ddx_expected = { 1, 6, 0 };
+#endif
+   static const __DRIversion dri_expected = { 4, 0, 0 };
+   static const __DRIversion drm_expected = { 1, 5, 0 };
+   I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv;
+
+   if (!driCheckDriDdxDrmVersions2("i915",
+                                   &psp->dri_version, &dri_expected,
+                                   &psp->ddx_version, &ddx_expected,
+                                   &psp->drm_version, &drm_expected)) {
+      return NULL;
+   }
+
+   /* 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?
+    */
+   intelInitExtensions(NULL, GL_TRUE);
+          
+   if (!intelInitDriver(psp))
+       return NULL;
+
+   psp->extensions = intelScreenExtensions;
+
+   intelScreen = psp->private;
+   if (!intel_init_bufmgr(intelScreen))
+       return GL_FALSE;
+
+   return (const __DRIconfig **)
+       intelFillInModes(psp, dri_priv->cpp * 8,
+                       (dri_priv->cpp == 2) ? 16 : 24,
+                       (dri_priv->cpp == 2) ? 0  : 8, 1);
+}
+
+struct intel_context *intelScreenContext(intelScreenPrivate *intelScreen)
+{
+  /*
+   * This should probably change to have the screen allocate a dummy
+   * context at screen creation. For now just use the current context.
+   */
+
+  GET_CURRENT_CONTEXT(ctx);
+  if (ctx == NULL) {
+     _mesa_problem(NULL, "No current context in intelScreenContext\n");
+     return NULL;
+  }
+  return intel_context(ctx);
+}
+
+/**
+ * This is the driver specific part of the createNewScreen entry point.
+ * Called when using DRI2.
+ *
+ * \return the __GLcontextModes supported by this driver
+ */
+static const
+__DRIconfig **intelInitScreen2(__DRIscreenPrivate *psp)
+{
+   intelScreenPrivate *intelScreen;
+
+   /* 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?
+    */
+   intelInitExtensions(NULL, GL_TRUE);
+
+   /* 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 = psp;
+   psp->private = (void *) intelScreen;
+
+   intelScreen->drmMinor = psp->drm_version.minor;
+
+   /* Determine chipset ID */
+   if (!intel_get_param(psp, I915_PARAM_CHIPSET_ID,
+                       &intelScreen->deviceID))
+      return GL_FALSE;
+
+   if (!intel_init_bufmgr(intelScreen))
+       return GL_FALSE;
+
+   intelScreen->irq_active = 1;
+   psp->extensions = intelScreenExtensions;
+
+   return driConcatConfigs(intelFillInModes(psp, 16, 16, 0, 1),
+                          intelFillInModes(psp, 32, 24, 8, 1));
+}
+
+const struct __DriverAPIRec driDriverAPI = {
+   .InitScreen          = intelInitScreen,
+   .DestroyScreen       = intelDestroyScreen,
+   .CreateContext       = intelCreateContext,
+   .DestroyContext      = intelDestroyContext,
+   .CreateBuffer        = intelCreateBuffer,
+   .DestroyBuffer       = intelDestroyBuffer,
+   .SwapBuffers                 = intelSwapBuffers,
+   .MakeCurrent                 = intelMakeCurrent,
+   .UnbindContext       = intelUnbindContext,
+   .GetSwapInfo                 = intelGetSwapInfo,
+   .GetDrawableMSC      = driDrawableGetMSC32,
+   .WaitForMSC          = driWaitForMSC32,
+   .CopySubBuffer       = intelCopySubBuffer,
+
+   .InitScreen2                 = intelInitScreen2,
+};
diff --git a/src/mesa/drivers/dri/intel/intel_screen.h b/src/mesa/drivers/dri/intel/intel_screen.h
new file mode 100644 (file)
index 0000000..fc913da
--- /dev/null
@@ -0,0 +1,115 @@
+/**************************************************************************
+ * 
+ * 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 "intel_bufmgr.h"
+#include "i915_drm.h"
+#include "xmlconfig.h"
+
+/* XXX: change name or eliminate to avoid conflict with "struct
+ * intel_region"!!!
+ */
+typedef struct
+{
+   drm_handle_t handle;
+   drmSize size;                /* region size in bytes */
+   char *map;                   /* memory map */
+   int offset;                  /* from start of video mem, in bytes */
+   unsigned int bo_handle;     /* buffer object id if available, or -1 */
+   /**
+    * Flags if the region is tiled.
+    *
+    * Not included is Y versus X tiling.
+    */
+   GLboolean tiled;
+} intelRegion;
+
+typedef struct
+{
+   intelRegion front;
+   intelRegion back;
+   intelRegion third;
+   intelRegion depth;
+   intelRegion tex;
+
+   int deviceID;
+   int width;
+   int height;
+   int pitch;                   /* common row stride, in pixels */
+
+   int logTextureGranularity;
+
+   __DRIscreenPrivate *driScrnPriv;
+
+   volatile struct drm_i915_sarea *sarea;
+
+   int drmMinor;
+
+   int irq_active;
+
+   GLboolean no_hw;
+
+   int ttm;
+   dri_bufmgr *bufmgr;
+
+   /**
+   * Configuration cache with default values for all contexts
+   */
+   driOptionCache optionCache;
+} intelScreenPrivate;
+
+
+
+extern GLboolean intelMapScreenRegions(__DRIscreenPrivate * sPriv);
+
+extern void intelUnmapScreenRegions(intelScreenPrivate * intelScreen);
+
+extern void
+intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen,
+                           struct drm_i915_sarea * sarea);
+
+extern void intelDestroyContext(__DRIcontextPrivate * driContextPriv);
+
+extern GLboolean intelUnbindContext(__DRIcontextPrivate * driContextPriv);
+
+extern GLboolean
+intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
+                 __DRIdrawablePrivate * driDrawPriv,
+                 __DRIdrawablePrivate * driReadPriv);
+
+extern void intelSwapBuffers(__DRIdrawablePrivate * dPriv);
+
+extern void
+intelCopySubBuffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h);
+
+extern struct intel_context *intelScreenContext(intelScreenPrivate *intelScreen);
+
+#endif
diff --git a/src/mesa/drivers/dri/intel/intel_span.c b/src/mesa/drivers/dri/intel/intel_span.c
new file mode 100644 (file)
index 0000000..0ea8576
--- /dev/null
@@ -0,0 +1,814 @@
+/**************************************************************************
+ * 
+ * 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_fbo.h"
+#include "intel_screen.h"
+#include "intel_span.h"
+#include "intel_regions.h"
+#include "intel_tex.h"
+
+#include "swrast/swrast.h"
+
+static void
+intel_set_span_functions(struct intel_context *intel,
+                        struct gl_renderbuffer *rb);
+
+#define SPAN_CACHE_SIZE                4096
+
+static void
+get_span_cache(struct intel_renderbuffer *irb, uint32_t offset)
+{
+   if (irb->span_cache == NULL) {
+      irb->span_cache = _mesa_malloc(SPAN_CACHE_SIZE);
+      irb->span_cache_offset = -1;
+   }
+
+   if ((offset & ~(SPAN_CACHE_SIZE - 1)) != irb->span_cache_offset) {
+      irb->span_cache_offset = offset & ~(SPAN_CACHE_SIZE - 1);
+      dri_bo_get_subdata(irb->region->buffer, irb->span_cache_offset,
+                        SPAN_CACHE_SIZE, irb->span_cache);
+   }
+}
+
+static void
+clear_span_cache(struct intel_renderbuffer *irb)
+{
+   irb->span_cache_offset = -1;
+}
+
+static uint32_t
+pread_32(struct intel_renderbuffer *irb, uint32_t offset)
+{
+   get_span_cache(irb, offset);
+
+   return *(uint32_t *)(irb->span_cache + (offset & (SPAN_CACHE_SIZE - 1)));
+}
+
+static uint32_t
+pread_xrgb8888(struct intel_renderbuffer *irb, uint32_t offset)
+{
+   get_span_cache(irb, offset);
+
+   return *(uint32_t *)(irb->span_cache + (offset & (SPAN_CACHE_SIZE - 1))) |
+      0xff000000;
+}
+
+static uint16_t
+pread_16(struct intel_renderbuffer *irb, uint32_t offset)
+{
+   get_span_cache(irb, offset);
+
+   return *(uint16_t *)(irb->span_cache + (offset & (SPAN_CACHE_SIZE - 1)));
+}
+
+static uint8_t
+pread_8(struct intel_renderbuffer *irb, uint32_t offset)
+{
+   get_span_cache(irb, offset);
+
+   return *(uint8_t *)(irb->span_cache + (offset & (SPAN_CACHE_SIZE - 1)));
+}
+
+static void
+pwrite_32(struct intel_renderbuffer *irb, uint32_t offset, uint32_t val)
+{
+   clear_span_cache(irb);
+
+   dri_bo_subdata(irb->region->buffer, offset, 4, &val);
+}
+
+static void
+pwrite_xrgb8888(struct intel_renderbuffer *irb, uint32_t offset, uint32_t val)
+{
+   clear_span_cache(irb);
+
+   dri_bo_subdata(irb->region->buffer, offset, 3, &val);
+}
+
+static void
+pwrite_16(struct intel_renderbuffer *irb, uint32_t offset, uint16_t val)
+{
+   clear_span_cache(irb);
+
+   dri_bo_subdata(irb->region->buffer, offset, 2, &val);
+}
+
+static void
+pwrite_8(struct intel_renderbuffer *irb, uint32_t offset, uint8_t val)
+{
+   clear_span_cache(irb);
+
+   dri_bo_subdata(irb->region->buffer, offset, 1, &val);
+}
+
+static uint32_t no_tile_swizzle(struct intel_renderbuffer *irb,
+                               struct intel_context *intel,
+                               int x, int y)
+{
+       x += intel->drawX;
+       y += intel->drawY;
+
+       return (y * irb->region->pitch + x) * irb->region->cpp;
+}
+
+/*
+ * Deal with tiled surfaces
+ */
+
+static uint32_t x_tile_swizzle(struct intel_renderbuffer *irb,
+                              struct intel_context *intel,
+                              int x, int y)
+{
+       int     tile_stride;
+       int     xbyte;
+       int     x_tile_off, y_tile_off;
+       int     x_tile_number, y_tile_number;
+       int     tile_off, tile_base;
+       
+       tile_stride = (irb->pfPitch * irb->region->cpp) << 3;
+       
+       x += intel->drawX;
+       y += intel->drawY;
+
+       xbyte = x * irb->region->cpp;
+
+       x_tile_off = xbyte & 0x1ff;
+       y_tile_off = y & 7;
+
+       x_tile_number = xbyte >> 9;
+       y_tile_number = y >> 3;
+
+       tile_off = (y_tile_off << 9) + x_tile_off;
+
+       switch (irb->region->bit_6_swizzle) {
+       case I915_BIT_6_SWIZZLE_NONE:
+          break;
+       case I915_BIT_6_SWIZZLE_9:
+          tile_off ^= ((tile_off >> 3) & 64);
+          break;
+       case I915_BIT_6_SWIZZLE_9_10:
+          tile_off ^= ((tile_off >> 3) & 64) ^ ((tile_off >> 4) & 64);
+          break;
+       case I915_BIT_6_SWIZZLE_9_11:
+          tile_off ^= ((tile_off >> 3) & 64) ^ ((tile_off >> 5) & 64);
+          break;
+       case I915_BIT_6_SWIZZLE_9_10_11:
+          tile_off ^= ((tile_off >> 3) & 64) ^ ((tile_off >> 4) & 64) ^
+             ((tile_off >> 5) & 64);
+          break;
+       default:
+          fprintf(stderr, "Unknown tile swizzling mode %d\n",
+                  irb->region->bit_6_swizzle);
+          exit(1);
+       }
+
+       tile_base = (x_tile_number << 12) + y_tile_number * tile_stride;
+
+#if 0
+       printf("(%d,%d) -> %d + %d = %d (pitch = %d, tstride = %d)\n",
+              x, y, tile_off, tile_base,
+              tile_off + tile_base,
+              irb->pfPitch, tile_stride);
+#endif
+
+       return tile_base + tile_off;
+}
+
+static uint32_t y_tile_swizzle(struct intel_renderbuffer *irb,
+                              struct intel_context *intel,
+                              int x, int y)
+{
+       int     tile_stride;
+       int     xbyte;
+       int     x_tile_off, y_tile_off;
+       int     x_tile_number, y_tile_number;
+       int     tile_off, tile_base;
+       
+       tile_stride = (irb->pfPitch * irb->region->cpp) << 5;
+       
+       x += intel->drawX;
+       y += intel->drawY;
+
+       xbyte = x * irb->region->cpp;
+
+       x_tile_off = xbyte & 0x7f;
+       y_tile_off = y & 0x1f;
+
+       x_tile_number = xbyte >> 7;
+       y_tile_number = y >> 5;
+
+       tile_off = ((x_tile_off & ~0xf) << 5) + (y_tile_off << 4) +
+          (x_tile_off & 0xf);
+
+       switch (irb->region->bit_6_swizzle) {
+       case I915_BIT_6_SWIZZLE_NONE:
+          break;
+       case I915_BIT_6_SWIZZLE_9:
+          tile_off ^= ((tile_off >> 3) & 64);
+          break;
+       case I915_BIT_6_SWIZZLE_9_10:
+          tile_off ^= ((tile_off >> 3) & 64) ^ ((tile_off >> 4) & 64);
+          break;
+       case I915_BIT_6_SWIZZLE_9_11:
+          tile_off ^= ((tile_off >> 3) & 64) ^ ((tile_off >> 5) & 64);
+          break;
+       case I915_BIT_6_SWIZZLE_9_10_11:
+          tile_off ^= ((tile_off >> 3) & 64) ^ ((tile_off >> 4) & 64) ^
+             ((tile_off >> 5) & 64);
+          break;
+       default:
+          fprintf(stderr, "Unknown tile swizzling mode %d\n",
+                  irb->region->bit_6_swizzle);
+          exit(1);
+       }
+
+       tile_base = (x_tile_number << 12) + y_tile_number * tile_stride;
+
+       return tile_base + tile_off;
+}
+
+/*
+  break intelWriteRGBASpan_ARGB8888
+*/
+
+#undef DBG
+#define DBG 0
+
+#define LOCAL_VARS                                                     \
+   struct intel_context *intel = intel_context(ctx);                   \
+   struct intel_renderbuffer *irb = intel_renderbuffer(rb);            \
+   const GLint yScale = irb->RenderToTexture ? 1 : -1;                 \
+   const GLint yBias = irb->RenderToTexture ? 0 : irb->Base.Height - 1;        \
+   GLuint p;                                                           \
+   (void) p;
+
+/* XXX FBO: this is identical to the macro in spantmp2.h except we get
+ * the cliprect info from the context, not the driDrawable.
+ * Move this into spantmp2.h someday.
+ */
+#define HW_CLIPLOOP()                                                  \
+   do {                                                                        \
+      int _nc = intel->numClipRects;                                   \
+      while ( _nc-- ) {                                                        \
+        int minx = intel->pClipRects[_nc].x1 - intel->drawX;           \
+        int miny = intel->pClipRects[_nc].y1 - intel->drawY;           \
+        int maxx = intel->pClipRects[_nc].x2 - intel->drawX;           \
+        int maxy = intel->pClipRects[_nc].y2 - intel->drawY;
+       
+#if 0
+      }}
+#endif
+
+#define Y_FLIP(_y) ((_y) * yScale + yBias)
+
+/* XXX with GEM, these need to tell the kernel */
+#define HW_LOCK()
+
+#define HW_UNLOCK()
+
+/* 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)    intel##x##_RGB565
+#define TAG2(x,y) intel##x##_RGB565##y
+#define GET_VALUE(X, Y) pread_16(irb, no_tile_swizzle(irb, intel, X, Y))
+#define PUT_VALUE(X, Y, V) pwrite_16(irb, no_tile_swizzle(irb, intel, X, Y), V)
+#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)    intel##x##_ARGB8888
+#define TAG2(x,y) intel##x##_ARGB8888##y
+#define GET_VALUE(X, Y) pread_32(irb, no_tile_swizzle(irb, intel, X, Y))
+#define PUT_VALUE(X, Y, V) pwrite_32(irb, no_tile_swizzle(irb, intel, X, Y), V)
+#include "spantmp2.h"
+
+/* 32 bit, xRGB8888 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)    intel##x##_xRGB8888
+#define TAG2(x,y) intel##x##_xRGB8888##y
+#define GET_VALUE(X, Y) pread_xrgb8888(irb, no_tile_swizzle(irb, intel, X, Y))
+#define PUT_VALUE(X, Y, V) pwrite_xrgb8888(irb, no_tile_swizzle(irb, intel, X, Y), V)
+#include "spantmp2.h"
+
+/* 16 bit RGB565 color tile spanline and pixel functions
+ */
+
+#define SPANTMP_PIXEL_FMT GL_RGB
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
+
+#define TAG(x)    intel_XTile_##x##_RGB565
+#define TAG2(x,y) intel_XTile_##x##_RGB565##y
+#define GET_VALUE(X, Y) pread_16(irb, x_tile_swizzle(irb, intel, X, Y))
+#define PUT_VALUE(X, Y, V) pwrite_16(irb, x_tile_swizzle(irb, intel, X, Y), V)
+#include "spantmp2.h"
+
+#define SPANTMP_PIXEL_FMT GL_RGB
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
+
+#define TAG(x)    intel_YTile_##x##_RGB565
+#define TAG2(x,y) intel_YTile_##x##_RGB565##y
+#define GET_VALUE(X, Y) pread_16(irb, y_tile_swizzle(irb, intel, X, Y))
+#define PUT_VALUE(X, Y, V) pwrite_16(irb, y_tile_swizzle(irb, intel, X, Y), V)
+#include "spantmp2.h"
+
+/* 32 bit ARGB888 color tile 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)    intel_XTile_##x##_ARGB8888
+#define TAG2(x,y) intel_XTile_##x##_ARGB8888##y
+#define GET_VALUE(X, Y) pread_32(irb, x_tile_swizzle(irb, intel, X, Y))
+#define PUT_VALUE(X, Y, V) pwrite_32(irb, x_tile_swizzle(irb, intel, X, Y), V)
+#include "spantmp2.h"
+
+#define SPANTMP_PIXEL_FMT GL_BGRA
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
+
+#define TAG(x)    intel_YTile_##x##_ARGB8888
+#define TAG2(x,y) intel_YTile_##x##_ARGB8888##y
+#define GET_VALUE(X, Y) pread_32(irb, y_tile_swizzle(irb, intel, X, Y))
+#define PUT_VALUE(X, Y, V) pwrite_32(irb, y_tile_swizzle(irb, intel, X, Y), V)
+#include "spantmp2.h"
+
+/* 32 bit xRGB888 color tile 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)    intel_XTile_##x##_xRGB8888
+#define TAG2(x,y) intel_XTile_##x##_xRGB8888##y
+#define GET_VALUE(X, Y) pread_xrgb8888(irb, x_tile_swizzle(irb, intel, X, Y))
+#define PUT_VALUE(X, Y, V) pwrite_xrgb8888(irb, x_tile_swizzle(irb, intel, X, Y), V)
+#include "spantmp2.h"
+
+#define SPANTMP_PIXEL_FMT GL_BGRA
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
+
+#define TAG(x)    intel_YTile_##x##_xRGB8888
+#define TAG2(x,y) intel_YTile_##x##_xRGB8888##y
+#define GET_VALUE(X, Y) pread_xrgb8888(irb, y_tile_swizzle(irb, intel, X, Y))
+#define PUT_VALUE(X, Y, V) pwrite_xrgb8888(irb, y_tile_swizzle(irb, intel, X, Y), V)
+#include "spantmp2.h"
+
+#define LOCAL_DEPTH_VARS                                               \
+   struct intel_context *intel = intel_context(ctx);                   \
+   struct intel_renderbuffer *irb = intel_renderbuffer(rb);            \
+   const GLint yScale = irb->RenderToTexture ? 1 : -1;                 \
+   const GLint yBias = irb->RenderToTexture ? 0 : irb->Base.Height - 1;
+
+
+#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
+
+/**
+ ** 16-bit depthbuffer functions.
+ **/
+#define VALUE_TYPE GLushort
+#define WRITE_DEPTH(_x, _y, d) \
+   pwrite_16(irb, no_tile_swizzle(irb, intel, _x, _y), d)
+#define READ_DEPTH(d, _x, _y) \
+   d = pread_16(irb, no_tile_swizzle(irb, intel, _x, _y))
+#define TAG(x) intel##x##_z16
+#include "depthtmp.h"
+
+
+/**
+ ** 16-bit x tile depthbuffer functions.
+ **/
+#define VALUE_TYPE GLushort
+#define WRITE_DEPTH(_x, _y, d) \
+   pwrite_16(irb, x_tile_swizzle(irb, intel, _x, _y), d)
+#define READ_DEPTH(d, _x, _y) \
+   d = pread_16(irb, x_tile_swizzle(irb, intel, _x, _y))
+#define TAG(x) intel_XTile_##x##_z16
+#include "depthtmp.h"
+
+/**
+ ** 16-bit y tile depthbuffer functions.
+ **/
+#define VALUE_TYPE GLushort
+#define WRITE_DEPTH(_x, _y, d) \
+   pwrite_16(irb, y_tile_swizzle(irb, intel, _x, _y), d)
+#define READ_DEPTH(d, _x, _y) \
+   d = pread_16(irb, y_tile_swizzle(irb, intel, _x, _y))
+#define TAG(x) intel_YTile_##x##_z16
+#include "depthtmp.h"
+
+
+/**
+ ** 24/8-bit interleaved depth/stencil functions
+ ** Note: we're actually reading back combined depth+stencil values.
+ ** The wrappers in main/depthstencil.c are used to extract the depth
+ ** and stencil values.
+ **/
+#define VALUE_TYPE GLuint
+
+/* Change ZZZS -> SZZZ */
+#define WRITE_DEPTH(_x, _y, d)                                 \
+   pwrite_32(irb, no_tile_swizzle(irb, intel, _x, _y),         \
+            ((d) >> 8) | ((d) << 24))
+
+/* Change SZZZ -> ZZZS */
+#define READ_DEPTH( d, _x, _y ) {                              \
+   GLuint tmp = pread_32(irb, no_tile_swizzle(irb, intel, _x, _y));    \
+   d = (tmp << 8) | (tmp >> 24);                               \
+}
+
+#define TAG(x) intel##x##_z24_s8
+#include "depthtmp.h"
+
+
+/**
+ ** 24/8-bit x-tile interleaved depth/stencil functions
+ ** Note: we're actually reading back combined depth+stencil values.
+ ** The wrappers in main/depthstencil.c are used to extract the depth
+ ** and stencil values.
+ **/
+#define VALUE_TYPE GLuint
+
+/* Change ZZZS -> SZZZ */
+#define WRITE_DEPTH(_x, _y, d)                                 \
+   pwrite_32(irb, x_tile_swizzle(irb, intel, _x, _y),          \
+            ((d) >> 8) | ((d) << 24))                          \
+
+/* Change SZZZ -> ZZZS */
+#define READ_DEPTH( d, _x, _y ) {                              \
+   GLuint tmp = pread_32(irb, x_tile_swizzle(irb, intel, _x, _y));     \
+   d = (tmp << 8) | (tmp >> 24);                               \
+}
+
+#define TAG(x) intel_XTile_##x##_z24_s8
+#include "depthtmp.h"
+
+/**
+ ** 24/8-bit y-tile interleaved depth/stencil functions
+ ** Note: we're actually reading back combined depth+stencil values.
+ ** The wrappers in main/depthstencil.c are used to extract the depth
+ ** and stencil values.
+ **/
+#define VALUE_TYPE GLuint
+
+/* Change ZZZS -> SZZZ */
+#define WRITE_DEPTH(_x, _y, d)                                 \
+   pwrite_32(irb, y_tile_swizzle(irb, intel, _x, _y),          \
+            ((d) >> 8) | ((d) << 24))
+
+/* Change SZZZ -> ZZZS */
+#define READ_DEPTH( d, _x, _y ) {                              \
+   GLuint tmp = pread_32(irb, y_tile_swizzle(irb, intel, _x, _y));     \
+   d = (tmp << 8) | (tmp >> 24);                               \
+}
+
+#define TAG(x) intel_YTile_##x##_z24_s8
+#include "depthtmp.h"
+
+
+/**
+ ** 8-bit stencil function (XXX FBO: This is obsolete)
+ **/
+#define WRITE_STENCIL(_x, _y, d)                               \
+   pwrite_8(irb, no_tile_swizzle(irb, intel, _x, _y) + 3, d)
+
+#define READ_STENCIL(d, _x, _y)                                        \
+   d = pread_8(irb, no_tile_swizzle(irb, intel, _x, _y) + 3);
+
+#define TAG(x) intel##x##_z24_s8
+#include "stenciltmp.h"
+
+/**
+ ** 8-bit x-tile stencil function (XXX FBO: This is obsolete)
+ **/
+#define WRITE_STENCIL(_x, _y, d)                               \
+   pwrite_8(irb, x_tile_swizzle(irb, intel, _x, _y) + 3, d)
+
+#define READ_STENCIL(d, _x, _y)                                        \
+   d = pread_8(irb, x_tile_swizzle(irb, intel, _x, _y) + 3);
+
+#define TAG(x) intel_XTile_##x##_z24_s8
+#include "stenciltmp.h"
+
+/**
+ ** 8-bit y-tile stencil function (XXX FBO: This is obsolete)
+ **/
+#define WRITE_STENCIL(_x, _y, d)                               \
+   pwrite_8(irb, y_tile_swizzle(irb, intel, _x, _y) + 3, d)
+
+#define READ_STENCIL(d, _x, _y)                                        \
+   d = pread_8(irb, y_tile_swizzle(irb, intel, _x, _y) + 3)
+
+#define TAG(x) intel_YTile_##x##_z24_s8
+#include "stenciltmp.h"
+
+void
+intel_renderbuffer_map(struct intel_context *intel, struct gl_renderbuffer *rb)
+{
+   struct intel_renderbuffer *irb = intel_renderbuffer(rb);
+
+   if (irb == NULL || irb->region == NULL)
+      return;
+
+   irb->pfPitch = irb->region->pitch;
+
+   intel_set_span_functions(intel, rb);
+}
+
+void
+intel_renderbuffer_unmap(struct intel_context *intel,
+                        struct gl_renderbuffer *rb)
+{
+   struct intel_renderbuffer *irb = intel_renderbuffer(rb);
+
+   if (irb == NULL || irb->region == NULL)
+      return;
+
+   clear_span_cache(irb);
+   irb->pfPitch = 0;
+
+   rb->GetRow = NULL;
+   rb->PutRow = NULL;
+}
+
+/**
+ * Map or unmap all the renderbuffers which we may need during
+ * software rendering.
+ * XXX in the future, we could probably convey extra information to
+ * reduce the number of mappings needed.  I.e. if doing a glReadPixels
+ * from the depth buffer, we really only need one mapping.
+ *
+ * XXX Rewrite this function someday.
+ * We can probably just loop over all the renderbuffer attachments,
+ * map/unmap all of them, and not worry about the _ColorDrawBuffers
+ * _ColorReadBuffer, _DepthBuffer or _StencilBuffer fields.
+ */
+static void
+intel_map_unmap_buffers(struct intel_context *intel, GLboolean map)
+{
+   GLcontext *ctx = &intel->ctx;
+   GLuint i, j;
+
+   /* color draw buffers */
+   for (j = 0; j < ctx->DrawBuffer->_NumColorDrawBuffers; j++) {
+      if (map)
+        intel_renderbuffer_map(intel, ctx->DrawBuffer->_ColorDrawBuffers[j]);
+      else
+        intel_renderbuffer_unmap(intel, ctx->DrawBuffer->_ColorDrawBuffers[j]);
+   }
+
+   /* check for render to textures */
+   for (i = 0; i < BUFFER_COUNT; i++) {
+      struct gl_renderbuffer_attachment *att =
+         ctx->DrawBuffer->Attachment + i;
+      struct gl_texture_object *tex = att->Texture;
+      if (tex) {
+         /* render to texture */
+         ASSERT(att->Renderbuffer);
+         if (map) {
+            struct gl_texture_image *texImg;
+            texImg = tex->Image[att->CubeMapFace][att->TextureLevel];
+            intel_tex_map_images(intel, intel_texture_object(tex));
+         }
+         else {
+            intel_tex_unmap_images(intel, intel_texture_object(tex));
+         }
+      }
+   }
+
+   /* color read buffers */
+   if (map)
+      intel_renderbuffer_map(intel, ctx->ReadBuffer->_ColorReadBuffer);
+   else
+      intel_renderbuffer_unmap(intel, ctx->ReadBuffer->_ColorReadBuffer);
+
+   /* depth buffer (Note wrapper!) */
+   if (ctx->DrawBuffer->_DepthBuffer) {
+      if (map)
+        intel_renderbuffer_map(intel, ctx->DrawBuffer->_DepthBuffer->Wrapped);
+      else
+        intel_renderbuffer_unmap(intel,
+                                 ctx->DrawBuffer->_DepthBuffer->Wrapped);
+   }
+
+   /* stencil buffer (Note wrapper!) */
+   if (ctx->DrawBuffer->_StencilBuffer) {
+      if (map)
+        intel_renderbuffer_map(intel,
+                               ctx->DrawBuffer->_StencilBuffer->Wrapped);
+      else
+        intel_renderbuffer_unmap(intel,
+                                 ctx->DrawBuffer->_StencilBuffer->Wrapped);
+   }
+}
+
+
+
+/**
+ * Prepare for softare rendering.  Map current read/draw framebuffers'
+ * renderbuffes and all currently bound texture objects.
+ *
+ * Old note: Moved locking out to get reasonable span performance.
+ */
+void
+intelSpanRenderStart(GLcontext * ctx)
+{
+   struct intel_context *intel = intel_context(ctx);
+   GLuint i;
+
+   intelFlush(&intel->ctx);
+   LOCK_HARDWARE(intel);
+
+   for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
+      if (ctx->Texture.Unit[i]._ReallyEnabled) {
+         struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current;
+         intel_tex_map_images(intel, intel_texture_object(texObj));
+      }
+   }
+
+   intel_map_unmap_buffers(intel, GL_TRUE);
+}
+
+/**
+ * Called when done softare rendering.  Unmap the buffers we mapped in
+ * the above function.
+ */
+void
+intelSpanRenderFinish(GLcontext * ctx)
+{
+   struct intel_context *intel = intel_context(ctx);
+   GLuint i;
+
+   _swrast_flush(ctx);
+
+   for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
+      if (ctx->Texture.Unit[i]._ReallyEnabled) {
+         struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current;
+         intel_tex_unmap_images(intel, intel_texture_object(texObj));
+      }
+   }
+
+   intel_map_unmap_buffers(intel, GL_FALSE);
+
+   UNLOCK_HARDWARE(intel);
+}
+
+
+void
+intelInitSpanFuncs(GLcontext * ctx)
+{
+   struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
+   swdd->SpanRenderStart = intelSpanRenderStart;
+   swdd->SpanRenderFinish = intelSpanRenderFinish;
+}
+
+
+/**
+ * Plug in appropriate span read/write functions for the given renderbuffer.
+ * These are used for the software fallbacks.
+ */
+static void
+intel_set_span_functions(struct intel_context *intel,
+                        struct gl_renderbuffer *rb)
+{
+   struct intel_renderbuffer *irb = (struct intel_renderbuffer *) rb;
+   uint32_t tiling;
+
+   /* If in GEM mode, we need to do the tile address swizzling ourselves,
+    * instead of the fence registers handling it.
+    */
+   if (intel->ttm)
+      tiling = irb->region->tiling;
+   else
+      tiling = I915_TILING_NONE;
+
+   if (rb->_ActualFormat == GL_RGB5) {
+      /* 565 RGB */
+      switch (tiling) {
+      case I915_TILING_NONE:
+      default:
+        intelInitPointers_RGB565(rb);
+        break;
+      case I915_TILING_X:
+        intel_XTile_InitPointers_RGB565(rb);
+        break;
+      case I915_TILING_Y:
+        intel_YTile_InitPointers_RGB565(rb);
+        break;
+      }
+   }
+   else if (rb->_ActualFormat == GL_RGB8) {
+      /* 8888 RGBx */
+      switch (tiling) {
+      case I915_TILING_NONE:
+      default:
+        intelInitPointers_xRGB8888(rb);
+        break;
+      case I915_TILING_X:
+        intel_XTile_InitPointers_xRGB8888(rb);
+        break;
+      case I915_TILING_Y:
+        intel_YTile_InitPointers_xRGB8888(rb);
+        break;
+      }
+   }
+   else if (rb->_ActualFormat == GL_RGBA8) {
+      /* 8888 RGBA */
+      switch (tiling) {
+      case I915_TILING_NONE:
+      default:
+        intelInitPointers_ARGB8888(rb);
+        break;
+      case I915_TILING_X:
+        intel_XTile_InitPointers_ARGB8888(rb);
+        break;
+      case I915_TILING_Y:
+        intel_YTile_InitPointers_ARGB8888(rb);
+        break;
+      }
+   }
+   else if (rb->_ActualFormat == GL_DEPTH_COMPONENT16) {
+      switch (tiling) {
+      case I915_TILING_NONE:
+      default:
+        intelInitDepthPointers_z16(rb);
+        break;
+      case I915_TILING_X:
+        intel_XTile_InitDepthPointers_z16(rb);
+        break;
+      case I915_TILING_Y:
+        intel_YTile_InitDepthPointers_z16(rb);
+        break;
+      }
+   }
+   else if (rb->_ActualFormat == GL_DEPTH_COMPONENT24 ||        /* XXX FBO remove */
+            rb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT) {
+      switch (tiling) {
+      case I915_TILING_NONE:
+      default:
+        intelInitDepthPointers_z24_s8(rb);
+        break;
+      case I915_TILING_X:
+        intel_XTile_InitDepthPointers_z24_s8(rb);
+        break;
+      case I915_TILING_Y:
+        intel_YTile_InitDepthPointers_z24_s8(rb);
+        break;
+      }
+   }
+   else if (rb->_ActualFormat == GL_STENCIL_INDEX8_EXT) {
+      switch (tiling) {
+      case I915_TILING_NONE:
+      default:
+        intelInitStencilPointers_z24_s8(rb);
+        break;
+      case I915_TILING_X:
+        intel_XTile_InitStencilPointers_z24_s8(rb);
+        break;
+      case I915_TILING_Y:
+        intel_YTile_InitStencilPointers_z24_s8(rb);
+        break;
+      }
+   }
+   else {
+      _mesa_problem(NULL,
+                    "Unexpected _ActualFormat in intelSetSpanFunctions");
+   }
+}
diff --git a/src/mesa/drivers/dri/intel/intel_span.h b/src/mesa/drivers/dri/intel/intel_span.h
new file mode 100644 (file)
index 0000000..acbeb4a
--- /dev/null
@@ -0,0 +1,40 @@
+/**************************************************************************
+ * 
+ * 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
+
+extern void intelInitSpanFuncs(GLcontext * ctx);
+
+extern void intelSpanRenderFinish(GLcontext * ctx);
+extern void intelSpanRenderStart(GLcontext * ctx);
+void intel_renderbuffer_map(struct intel_context *intel,
+                           struct gl_renderbuffer *rb);
+void intel_renderbuffer_unmap(struct intel_context *intel,
+                             struct gl_renderbuffer *rb);
+
+#endif
diff --git a/src/mesa/drivers/dri/intel/intel_tex.c b/src/mesa/drivers/dri/intel/intel_tex.c
new file mode 100644 (file)
index 0000000..4fa18e2
--- /dev/null
@@ -0,0 +1,256 @@
+#include "swrast/swrast.h"
+#include "texobj.h"
+#include "teximage.h"
+#include "mipmap.h"
+#include "intel_context.h"
+#include "intel_mipmap_tree.h"
+#include "intel_tex.h"
+
+#define FILE_DEBUG_FLAG DEBUG_TEXTURE
+
+static GLboolean
+intelIsTextureResident(GLcontext * ctx, struct gl_texture_object *texObj)
+{
+#if 0
+   struct intel_context *intel = intel_context(ctx);
+   struct intel_texture_object *intelObj = intel_texture_object(texObj);
+
+   return
+      intelObj->mt &&
+      intelObj->mt->region &&
+      intel_is_region_resident(intel, intelObj->mt->region);
+#endif
+   return 1;
+}
+
+
+
+static struct gl_texture_image *
+intelNewTextureImage(GLcontext * ctx)
+{
+   DBG("%s\n", __FUNCTION__);
+   (void) ctx;
+   return (struct gl_texture_image *) CALLOC_STRUCT(intel_texture_image);
+}
+
+
+static struct gl_texture_object *
+intelNewTextureObject(GLcontext * ctx, GLuint name, GLenum target)
+{
+   struct intel_texture_object *obj = CALLOC_STRUCT(intel_texture_object);
+
+   DBG("%s\n", __FUNCTION__);
+   _mesa_initialize_texture_object(&obj->base, name, target);
+
+   return &obj->base;
+}
+
+static void 
+intelDeleteTextureObject(GLcontext *ctx,
+                        struct gl_texture_object *texObj)
+{
+   struct intel_context *intel = intel_context(ctx);
+   struct intel_texture_object *intelObj = intel_texture_object(texObj);
+
+   if (intelObj->mt)
+      intel_miptree_release(intel, &intelObj->mt);
+
+   _mesa_delete_texture_object(ctx, texObj);
+}
+
+
+static void
+intelFreeTextureImageData(GLcontext * ctx, struct gl_texture_image *texImage)
+{
+   struct intel_context *intel = intel_context(ctx);
+   struct intel_texture_image *intelImage = intel_texture_image(texImage);
+
+   DBG("%s\n", __FUNCTION__);
+
+   if (intelImage->mt) {
+      intel_miptree_release(intel, &intelImage->mt);
+   }
+
+   if (texImage->Data) {
+      _mesa_free_texmemory(texImage->Data);
+      texImage->Data = NULL;
+   }
+}
+
+
+/* The system memcpy (at least on ubuntu 5.10) has problems copying
+ * to agp (writecombined) memory from a source which isn't 64-byte
+ * aligned - there is a 4x performance falloff.
+ *
+ * The x86 __memcpy is immune to this but is slightly slower
+ * (10%-ish) than the system memcpy.
+ *
+ * The sse_memcpy seems to have a slight cliff at 64/32 bytes, but
+ * isn't much faster than x86_memcpy for agp copies.
+ * 
+ * TODO: switch dynamically.
+ */
+static void *
+do_memcpy(void *dest, const void *src, size_t n)
+{
+   if ((((unsigned) src) & 63) || (((unsigned) dest) & 63)) {
+      return __memcpy(dest, src, n);
+   }
+   else
+      return memcpy(dest, src, n);
+}
+
+
+#if DO_DEBUG && !defined(__ia64__)
+
+#ifndef __x86_64__
+static unsigned
+fastrdtsc(void)
+{
+   unsigned eax;
+   __asm__ volatile ("\t"
+                     "pushl  %%ebx\n\t"
+                     "cpuid\n\t" ".byte 0x0f, 0x31\n\t"
+                     "popl %%ebx\n":"=a" (eax)
+                     :"0"(0)
+                     :"ecx", "edx", "cc");
+
+   return eax;
+}
+#else
+static unsigned
+fastrdtsc(void)
+{
+   unsigned eax;
+   __asm__ volatile ("\t" "cpuid\n\t" ".byte 0x0f, 0x31\n\t":"=a" (eax)
+                     :"0"(0)
+                     :"ecx", "edx", "ebx", "cc");
+
+   return eax;
+}
+#endif
+
+static unsigned
+time_diff(unsigned t, unsigned t2)
+{
+   return ((t < t2) ? t2 - t : 0xFFFFFFFFU - (t - t2 - 1));
+}
+
+
+static void *
+timed_memcpy(void *dest, const void *src, size_t n)
+{
+   void *ret;
+   unsigned t1, t2;
+   double rate;
+
+   if ((((unsigned) src) & 63) || (((unsigned) dest) & 63))
+      _mesa_printf("Warning - non-aligned texture copy!\n");
+
+   t1 = fastrdtsc();
+   ret = do_memcpy(dest, src, n);
+   t2 = fastrdtsc();
+
+   rate = time_diff(t1, t2);
+   rate /= (double) n;
+   _mesa_printf("timed_memcpy: %u %u --> %f clocks/byte\n", t1, t2, rate);
+   return ret;
+}
+#endif /* DO_DEBUG */
+
+/**
+ * Generate new mipmap data from BASE+1 to BASE+p (the minimally-sized mipmap
+ * level).
+ *
+ * The texture object's miptree must be mapped.
+ *
+ * It would be really nice if this was just called by Mesa whenever mipmaps
+ * needed to be regenerated, rather than us having to remember to do so in
+ * each texture image modification path.
+ *
+ * This function should also include an accelerated path.
+ */
+void
+intel_generate_mipmap(GLcontext *ctx, GLenum target,
+                      struct gl_texture_object *texObj)
+{
+   struct intel_context *intel = intel_context(ctx);
+   struct intel_texture_object *intelObj = intel_texture_object(texObj);
+   GLuint nr_faces = (intelObj->base.Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
+   int face, i;
+
+   _mesa_generate_mipmap(ctx, target, texObj);
+
+   /* Update the level information in our private data in the new images, since
+    * it didn't get set as part of a normal TexImage path.
+    */
+   for (face = 0; face < nr_faces; face++) {
+      for (i = texObj->BaseLevel + 1; i < texObj->MaxLevel; i++) {
+         struct intel_texture_image *intelImage;
+
+        intelImage = intel_texture_image(texObj->Image[face][i]);
+        if (intelImage == NULL)
+           break;
+
+        intelImage->level = i;
+        intelImage->face = face;
+        /* Unreference the miptree to signal that the new Data is a bare
+         * pointer from mesa.
+         */
+        intel_miptree_release(intel, &intelImage->mt);
+      }
+   }
+}
+
+static void intelGenerateMipmap(GLcontext *ctx, GLenum target, struct gl_texture_object *texObj)
+{
+   struct intel_context *intel = intel_context(ctx);
+   struct intel_texture_object *intelObj = intel_texture_object(texObj);
+
+   intel_tex_map_level_images(intel, intelObj, texObj->BaseLevel);
+   intel_generate_mipmap(ctx, target, texObj);
+   intel_tex_unmap_level_images(intel, intelObj, texObj->BaseLevel);
+}
+
+void
+intelInitTextureFuncs(struct dd_function_table *functions)
+{
+   functions->ChooseTextureFormat = intelChooseTextureFormat;
+   functions->TexImage1D = intelTexImage1D;
+   functions->TexImage2D = intelTexImage2D;
+   functions->TexImage3D = intelTexImage3D;
+   functions->TexSubImage1D = intelTexSubImage1D;
+   functions->TexSubImage2D = intelTexSubImage2D;
+   functions->TexSubImage3D = intelTexSubImage3D;
+#ifdef I915
+   functions->CopyTexImage1D = intelCopyTexImage1D;
+   functions->CopyTexImage2D = intelCopyTexImage2D;
+   functions->CopyTexSubImage1D = intelCopyTexSubImage1D;
+   functions->CopyTexSubImage2D = intelCopyTexSubImage2D;
+#else
+   functions->CopyTexImage1D = _swrast_copy_teximage1d;
+   functions->CopyTexImage2D = _swrast_copy_teximage2d;
+   functions->CopyTexSubImage1D = _swrast_copy_texsubimage1d;
+   functions->CopyTexSubImage2D = _swrast_copy_texsubimage2d;
+#endif
+   functions->GetTexImage = intelGetTexImage;
+   functions->GenerateMipmap = intelGenerateMipmap;
+
+   /* compressed texture functions */
+   functions->CompressedTexImage2D = intelCompressedTexImage2D;
+   functions->GetCompressedTexImage = intelGetCompressedTexImage;
+
+   functions->NewTextureObject = intelNewTextureObject;
+   functions->NewTextureImage = intelNewTextureImage;
+   functions->DeleteTexture = intelDeleteTextureObject;
+   functions->FreeTexImageData = intelFreeTextureImageData;
+   functions->UpdateTexturePalette = 0;
+   functions->IsTextureResident = intelIsTextureResident;
+
+#if DO_DEBUG && !defined(__ia64__)
+   if (INTEL_DEBUG & DEBUG_BUFMGR)
+      functions->TextureMemCpy = timed_memcpy;
+   else
+#endif
+      functions->TextureMemCpy = do_memcpy;
+}
diff --git a/src/mesa/drivers/dri/intel/intel_tex.h b/src/mesa/drivers/dri/intel/intel_tex.h
new file mode 100644 (file)
index 0000000..fe7a8ba
--- /dev/null
@@ -0,0 +1,164 @@
+/**************************************************************************
+ * 
+ * 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);
+
+const struct gl_texture_format *intelChooseTextureFormat(GLcontext * ctx,
+                                                         GLint internalFormat,
+                                                         GLenum format,
+                                                         GLenum type);
+
+
+void intelTexImage3D(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);
+
+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);
+
+void intelTexImage2D(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);
+
+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);
+
+void intelTexImage1D(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);
+
+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);
+
+void intelCopyTexImage1D(GLcontext * ctx, GLenum target, GLint level,
+                         GLenum internalFormat,
+                         GLint x, GLint y, GLsizei width, GLint border);
+
+void intelCopyTexImage2D(GLcontext * ctx, GLenum target, GLint level,
+                         GLenum internalFormat,
+                         GLint x, GLint y, GLsizei width, GLsizei height,
+                         GLint border);
+
+void intelCopyTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
+                            GLint xoffset, GLint x, GLint y, GLsizei width);
+
+void intelCopyTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
+                            GLint xoffset, GLint yoffset,
+                            GLint x, GLint y, GLsizei width, GLsizei height);
+
+void intelGetTexImage(GLcontext * ctx, GLenum target, GLint level,
+                      GLenum format, GLenum type, GLvoid * pixels,
+                      struct gl_texture_object *texObj,
+                      struct gl_texture_image *texImage);
+
+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 );
+
+void intelGetCompressedTexImage(GLcontext *ctx, GLenum target, GLint level,
+                               GLvoid *pixels,
+                               struct gl_texture_object *texObj,
+                               struct gl_texture_image *texImage);
+
+void intelSetTexOffset(__DRIcontext *pDRICtx, GLint texname,
+                      unsigned long long offset, GLint depth, GLuint pitch);
+void intelSetTexBuffer(__DRIcontext *pDRICtx,
+                      GLint target, __DRIdrawable *pDraw);
+
+GLuint intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit);
+
+void intel_tex_map_level_images(struct intel_context *intel,
+                               struct intel_texture_object *intelObj,
+                               int level);
+
+void intel_tex_unmap_level_images(struct intel_context *intel,
+                                 struct intel_texture_object *intelObj,
+                                 int level);
+
+void intel_tex_map_images(struct intel_context *intel,
+                          struct intel_texture_object *intelObj);
+
+void intel_tex_unmap_images(struct intel_context *intel,
+                            struct intel_texture_object *intelObj);
+
+int intel_compressed_num_bytes(GLuint mesaFormat);
+
+void intel_generate_mipmap(GLcontext *ctx, GLenum target,
+                          struct gl_texture_object *texObj);
+
+#endif
diff --git a/src/mesa/drivers/dri/intel/intel_tex_copy.c b/src/mesa/drivers/dri/intel/intel_tex_copy.c
new file mode 100644 (file)
index 0000000..d0ab464
--- /dev/null
@@ -0,0 +1,298 @@
+/**************************************************************************
+ * 
+ * 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 "mtypes.h"
+#include "enums.h"
+#include "image.h"
+#include "teximage.h"
+#include "mipmap.h"
+#include "swrast/swrast.h"
+
+#include "intel_screen.h"
+#include "intel_context.h"
+#include "intel_batchbuffer.h"
+#include "intel_buffers.h"
+#include "intel_mipmap_tree.h"
+#include "intel_regions.h"
+#include "intel_fbo.h"
+#include "intel_tex.h"
+#include "intel_blit.h"
+
+#define FILE_DEBUG_FLAG DEBUG_TEXTURE
+
+/**
+ * Get the intel_region which is the source for any glCopyTex[Sub]Image call.
+ *
+ * Do the best we can using the blitter.  A future project is to use
+ * the texture engine and fragment programs for these copies.
+ */
+static const struct intel_region *
+get_teximage_source(struct intel_context *intel, GLenum internalFormat)
+{
+   struct intel_renderbuffer *irb;
+
+   DBG("%s %s\n", __FUNCTION__,
+       _mesa_lookup_enum_by_nr(internalFormat));
+
+   switch (internalFormat) {
+   case GL_DEPTH_COMPONENT:
+   case GL_DEPTH_COMPONENT16_ARB:
+      irb = intel_get_renderbuffer(intel->ctx.ReadBuffer, BUFFER_DEPTH);
+      if (irb && irb->region && irb->region->cpp == 2)
+         return irb->region;
+      return NULL;
+   case GL_DEPTH24_STENCIL8_EXT:
+   case GL_DEPTH_STENCIL_EXT:
+      irb = intel_get_renderbuffer(intel->ctx.ReadBuffer, BUFFER_DEPTH);
+      if (irb && irb->region && irb->region->cpp == 4)
+         return irb->region;
+      return NULL;
+   case GL_RGBA:
+   case GL_RGBA8:
+      return intel_readbuf_region(intel);
+   case GL_RGB:
+      if (intel->ctx.Visual.rgbBits == 16)
+         return intel_readbuf_region(intel);
+      return NULL;
+   default:
+      return NULL;
+   }
+}
+
+
+static GLboolean
+do_copy_texsubimage(struct intel_context *intel,
+                   GLenum target,
+                    struct intel_texture_image *intelImage,
+                    GLenum internalFormat,
+                    GLint dstx, GLint dsty,
+                    GLint x, GLint y, GLsizei width, GLsizei height)
+{
+   GLcontext *ctx = &intel->ctx;
+   struct gl_texture_object *texObj = intelImage->base.TexObject;
+   const struct intel_region *src =
+      get_teximage_source(intel, internalFormat);
+
+   if (!intelImage->mt || !src) {
+      DBG("%s fail %p %p\n", __FUNCTION__, intelImage->mt, src);
+      return GL_FALSE;
+   }
+
+   intelFlush(ctx);
+   LOCK_HARDWARE(intel);
+   {
+      GLuint image_offset = intel_miptree_image_offset(intelImage->mt,
+                                                       intelImage->face,
+                                                       intelImage->level);
+      const GLint orig_x = x;
+      const GLint orig_y = y;
+      const struct gl_framebuffer *fb = ctx->DrawBuffer;
+
+      if (_mesa_clip_to_region(fb->_Xmin, fb->_Ymin, fb->_Xmax, fb->_Ymax,
+                               &x, &y, &width, &height)) {
+         /* Update dst for clipped src.  Need to also clip the source rect.
+          */
+         dstx += x - orig_x;
+         dsty += y - orig_y;
+
+         if (ctx->ReadBuffer->Name == 0) {
+            /* reading from a window, adjust x, y */
+            __DRIdrawablePrivate *dPriv = intel->driDrawable;
+            GLuint window_y;
+            /* window_y = position of window on screen if y=0=bottom */
+            window_y = intel->intelScreen->height - (dPriv->y + dPriv->h);
+            y = window_y + y;
+            x += dPriv->x;
+         }
+         else {
+            /* reading from a FBO */
+            /* invert Y */
+            y = ctx->ReadBuffer->Height - y - 1;
+         }
+
+
+         /* A bit of fiddling to get the blitter to work with -ve
+          * pitches.  But we get a nice inverted blit this way, so it's
+          * worth it:
+          */
+         intelEmitCopyBlit(intel,
+                           intelImage->mt->cpp,
+                           -src->pitch,
+                           src->buffer,
+                           src->height * src->pitch * src->cpp,
+                          src->tiling,
+                           intelImage->mt->pitch,
+                           intelImage->mt->region->buffer,
+                           image_offset,
+                          intelImage->mt->region->tiling,
+                           x, y + height, dstx, dsty, width, height,
+                          GL_COPY); /* ? */
+      }
+   }
+
+
+   UNLOCK_HARDWARE(intel);
+
+   /* GL_SGIS_generate_mipmap */
+   if (intelImage->level == texObj->BaseLevel && texObj->GenerateMipmap) {
+      intel_generate_mipmap(ctx, target, texObj);
+   }
+
+   return GL_TRUE;
+}
+
+
+
+
+
+void
+intelCopyTexImage1D(GLcontext * ctx, GLenum target, GLint level,
+                    GLenum internalFormat,
+                    GLint x, GLint y, GLsizei width, GLint border)
+{
+   struct gl_texture_unit *texUnit =
+      &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+   struct gl_texture_object *texObj =
+      _mesa_select_tex_object(ctx, texUnit, target);
+   struct gl_texture_image *texImage =
+      _mesa_select_tex_image(ctx, texObj, target, level);
+
+   if (border)
+      goto fail;
+
+   /* Setup or redefine the texture object, mipmap tree and texture
+    * image.  Don't populate yet.  
+    */
+   ctx->Driver.TexImage1D(ctx, target, level, internalFormat,
+                          width, border,
+                          GL_RGBA, CHAN_TYPE, NULL,
+                          &ctx->DefaultPacking, texObj, texImage);
+
+   if (!do_copy_texsubimage(intel_context(ctx), target,
+                            intel_texture_image(texImage),
+                            internalFormat, 0, 0, x, y, width, 1))
+      goto fail;
+
+   return;
+
+ fail:
+   _swrast_copy_teximage1d(ctx, target, level, internalFormat, x, y,
+                           width, border);
+}
+
+void
+intelCopyTexImage2D(GLcontext * ctx, GLenum target, GLint level,
+                    GLenum internalFormat,
+                    GLint x, GLint y, GLsizei width, GLsizei height,
+                    GLint border)
+{
+   struct gl_texture_unit *texUnit =
+      &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+   struct gl_texture_object *texObj =
+      _mesa_select_tex_object(ctx, texUnit, target);
+   struct gl_texture_image *texImage =
+      _mesa_select_tex_image(ctx, texObj, target, level);
+
+   if (border)
+      goto fail;
+
+   /* Setup or redefine the texture object, mipmap tree and texture
+    * image.  Don't populate yet.  
+    */
+   ctx->Driver.TexImage2D(ctx, target, level, internalFormat,
+                          width, height, border,
+                          GL_RGBA, CHAN_TYPE, NULL,
+                          &ctx->DefaultPacking, texObj, texImage);
+
+
+   if (!do_copy_texsubimage(intel_context(ctx), target,
+                            intel_texture_image(texImage),
+                            internalFormat, 0, 0, x, y, width, height))
+      goto fail;
+
+   return;
+
+ fail:
+   _swrast_copy_teximage2d(ctx, target, level, internalFormat, x, y,
+                           width, height, border);
+}
+
+
+void
+intelCopyTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
+                       GLint xoffset, GLint x, GLint y, GLsizei width)
+{
+   struct gl_texture_unit *texUnit =
+      &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+   struct gl_texture_object *texObj =
+      _mesa_select_tex_object(ctx, texUnit, target);
+   struct gl_texture_image *texImage =
+      _mesa_select_tex_image(ctx, texObj, target, level);
+   GLenum internalFormat = texImage->InternalFormat;
+
+   /* XXX need to check <border> as in above function? */
+
+   /* Need to check texture is compatible with source format. 
+    */
+
+   if (!do_copy_texsubimage(intel_context(ctx), target,
+                            intel_texture_image(texImage),
+                            internalFormat, xoffset, 0, x, y, width, 1)) {
+      _swrast_copy_texsubimage1d(ctx, target, level, xoffset, x, y, width);
+   }
+}
+
+
+
+void
+intelCopyTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
+                       GLint xoffset, GLint yoffset,
+                       GLint x, GLint y, GLsizei width, GLsizei height)
+{
+   struct gl_texture_unit *texUnit =
+      &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+   struct gl_texture_object *texObj =
+      _mesa_select_tex_object(ctx, texUnit, target);
+   struct gl_texture_image *texImage =
+      _mesa_select_tex_image(ctx, texObj, target, level);
+   GLenum internalFormat = texImage->InternalFormat;
+
+
+   /* Need to check texture is compatible with source format. 
+    */
+
+   if (!do_copy_texsubimage(intel_context(ctx), target,
+                            intel_texture_image(texImage),
+                            internalFormat,
+                            xoffset, yoffset, x, y, width, height)) {
+
+      DBG("%s - fallback to swrast\n", __FUNCTION__);
+
+      _swrast_copy_texsubimage2d(ctx, target, level,
+                                 xoffset, yoffset, x, y, width, height);
+   }
+}
diff --git a/src/mesa/drivers/dri/intel/intel_tex_format.c b/src/mesa/drivers/dri/intel/intel_tex_format.c
new file mode 100644 (file)
index 0000000..8ae80e1
--- /dev/null
@@ -0,0 +1,193 @@
+#include "intel_context.h"
+#include "intel_tex.h"
+#include "texformat.h"
+#include "enums.h"
+
+/* It works out that this function is fine for all the supported
+ * hardware.  However, there is still a need to map the formats onto
+ * hardware descriptors.
+ */
+/* Note that the i915 can actually support many more formats than
+ * these if we take the step of simply swizzling the colors
+ * immediately after sampling...
+ */
+const struct gl_texture_format *
+intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
+                         GLenum format, GLenum type)
+{
+   struct intel_context *intel = intel_context(ctx);
+   const GLboolean do32bpt = (intel->ctx.Visual.rgbBits == 32);
+
+   switch (internalFormat) {
+   case 4:
+   case GL_RGBA:
+   case GL_COMPRESSED_RGBA:
+      if (format == GL_BGRA) {
+         if (type == GL_UNSIGNED_BYTE || 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 &_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_DEPTH_COMPONENT:
+   case GL_DEPTH_COMPONENT16:
+   case GL_DEPTH_COMPONENT24:
+   case GL_DEPTH_COMPONENT32:
+      return &_mesa_texformat_z16;
+
+   case GL_DEPTH_STENCIL_EXT:
+   case GL_DEPTH24_STENCIL8_EXT:
+      return &_mesa_texformat_s8_z24;
+
+#ifndef I915
+   case GL_SRGB_EXT:
+   case GL_SRGB8_EXT:
+   case GL_SRGB_ALPHA_EXT:
+   case GL_SRGB8_ALPHA8_EXT:
+   case GL_SLUMINANCE_EXT:
+   case GL_SLUMINANCE8_EXT:
+   case GL_SLUMINANCE_ALPHA_EXT:
+   case GL_SLUMINANCE8_ALPHA8_EXT:
+   case GL_COMPRESSED_SRGB_EXT:
+   case GL_COMPRESSED_SRGB_ALPHA_EXT:
+   case GL_COMPRESSED_SLUMINANCE_EXT:
+   case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
+       return &_mesa_texformat_srgba8;
+   case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
+   case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
+   case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
+   case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
+     return &_mesa_texformat_srgb_dxt1;
+#endif
+
+   default:
+      fprintf(stderr, "unexpected texture format %s in %s\n",
+              _mesa_lookup_enum_by_nr(internalFormat), __FUNCTION__);
+      return NULL;
+   }
+
+   return NULL;                 /* never get here */
+}
+
+int intel_compressed_num_bytes(GLuint mesaFormat)
+{
+   int bytes = 0;
+   switch(mesaFormat) {
+     
+   case MESA_FORMAT_RGB_FXT1:
+   case MESA_FORMAT_RGBA_FXT1:
+   case MESA_FORMAT_RGB_DXT1:
+   case MESA_FORMAT_RGBA_DXT1:
+     bytes = 2;
+     break;
+     
+   case MESA_FORMAT_RGBA_DXT3:
+   case MESA_FORMAT_RGBA_DXT5:
+     bytes = 4;
+   default:
+     break;
+   }
+   
+   return bytes;
+}
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
new file mode 100644 (file)
index 0000000..1820d3d
--- /dev/null
@@ -0,0 +1,778 @@
+
+#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 "teximage.h"
+
+#include "intel_context.h"
+#include "intel_mipmap_tree.h"
+#include "intel_buffer_objects.h"
+#include "intel_batchbuffer.h"
+#include "intel_tex.h"
+#include "intel_blit.h"
+#include "intel_fbo.h"
+
+#define FILE_DEBUG_FLAG DEBUG_TEXTURE
+
+/* Functions to store texture images.  Where possible, mipmap_tree's
+ * will be created or further instantiated with image data, otherwise
+ * images will be stored in malloc'd memory.  A validation step is
+ * required to pull those images into a mipmap tree, or otherwise
+ * decide a fallback is required.
+ */
+
+
+static int
+logbase2(int n)
+{
+   GLint i = 1;
+   GLint log2 = 0;
+
+   while (n > i) {
+      i *= 2;
+      log2++;
+   }
+
+   return log2;
+}
+
+
+/* Otherwise, store it in memory if (Border != 0) or (any dimension ==
+ * 1).
+ *    
+ * Otherwise, if max_level >= level >= min_level, create tree with
+ * space for textures from min_level down to max_level.
+ *
+ * Otherwise, create tree with space for textures from (level
+ * 0)..(1x1).  Consider pruning this tree at a validation if the
+ * saving is worth it.
+ */
+static void
+guess_and_alloc_mipmap_tree(struct intel_context *intel,
+                            struct intel_texture_object *intelObj,
+                            struct intel_texture_image *intelImage)
+{
+   GLuint firstLevel;
+   GLuint lastLevel;
+   GLuint width = intelImage->base.Width;
+   GLuint height = intelImage->base.Height;
+   GLuint depth = intelImage->base.Depth;
+   GLuint l2width, l2height, l2depth;
+   GLuint i, comp_byte = 0;
+
+   DBG("%s\n", __FUNCTION__);
+
+   if (intelImage->base.Border ||
+       ((intelImage->base._BaseFormat == GL_DEPTH_COMPONENT) && 
+        ((intelObj->base.WrapS == GL_CLAMP_TO_BORDER) ||
+         (intelObj->base.WrapT == GL_CLAMP_TO_BORDER))))
+      return;
+
+   if (intelImage->level > intelObj->base.BaseLevel &&
+       (intelImage->base.Width == 1 ||
+        (intelObj->base.Target != GL_TEXTURE_1D &&
+         intelImage->base.Height == 1) ||
+        (intelObj->base.Target == GL_TEXTURE_3D &&
+         intelImage->base.Depth == 1)))
+      return;
+
+   /* If this image disrespects BaseLevel, allocate from level zero.
+    * Usually BaseLevel == 0, so it's unlikely to happen.
+    */
+   if (intelImage->level < intelObj->base.BaseLevel)
+      firstLevel = 0;
+   else
+      firstLevel = intelObj->base.BaseLevel;
+
+
+   /* Figure out image dimensions at start level. 
+    */
+   for (i = intelImage->level; i > firstLevel; i--) {
+      width <<= 1;
+      if (height != 1)
+         height <<= 1;
+      if (depth != 1)
+         depth <<= 1;
+   }
+
+   /* Guess a reasonable value for lastLevel.  This is probably going
+    * to be wrong fairly often and might mean that we have to look at
+    * resizable buffers, or require that buffers implement lazy
+    * pagetable arrangements.
+    */
+   if ((intelObj->base.MinFilter == GL_NEAREST ||
+        intelObj->base.MinFilter == GL_LINEAR) &&
+       intelImage->level == firstLevel) {
+      lastLevel = firstLevel;
+   }
+   else {
+      l2width = logbase2(width);
+      l2height = logbase2(height);
+      l2depth = logbase2(depth);
+      lastLevel = firstLevel + MAX2(MAX2(l2width, l2height), l2depth);
+   }
+
+   assert(!intelObj->mt);
+   if (intelImage->base.IsCompressed)
+      comp_byte = intel_compressed_num_bytes(intelImage->base.TexFormat->MesaFormat);
+   intelObj->mt = intel_miptree_create(intel,
+                                       intelObj->base.Target,
+                                       intelImage->base.InternalFormat,
+                                       firstLevel,
+                                       lastLevel,
+                                       width,
+                                       height,
+                                       depth,
+                                       intelImage->base.TexFormat->TexelBytes,
+                                       comp_byte);
+
+   DBG("%s - success\n", __FUNCTION__);
+}
+
+
+
+
+static GLuint
+target_to_face(GLenum target)
+{
+   switch (target) {
+   case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
+   case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
+   case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
+   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
+   case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
+   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
+      return ((GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X);
+   default:
+      return 0;
+   }
+}
+
+/* There are actually quite a few combinations this will work for,
+ * more than what I've listed here.
+ */
+static GLboolean
+check_pbo_format(GLint internalFormat,
+                 GLenum format, GLenum type,
+                 const struct gl_texture_format *mesa_format)
+{
+   switch (internalFormat) {
+   case 4:
+   case GL_RGBA:
+      return (format == GL_BGRA &&
+              (type == GL_UNSIGNED_BYTE ||
+               type == GL_UNSIGNED_INT_8_8_8_8_REV) &&
+              mesa_format == &_mesa_texformat_argb8888);
+   case 3:
+   case GL_RGB:
+      return (format == GL_RGB &&
+              type == GL_UNSIGNED_SHORT_5_6_5 &&
+              mesa_format == &_mesa_texformat_rgb565);
+   case GL_YCBCR_MESA:
+      return (type == GL_UNSIGNED_SHORT_8_8_MESA || type == GL_UNSIGNED_BYTE);
+   default:
+      return GL_FALSE;
+   }
+}
+
+
+/* XXX: Do this for TexSubImage also:
+ */
+static GLboolean
+try_pbo_upload(struct intel_context *intel,
+               struct intel_texture_image *intelImage,
+               const struct gl_pixelstore_attrib *unpack,
+               GLint internalFormat,
+               GLint width, GLint height,
+               GLenum format, GLenum type, const void *pixels)
+{
+   struct intel_buffer_object *pbo = intel_buffer_object(unpack->BufferObj);
+   GLuint src_offset, src_stride;
+   GLuint dst_offset, dst_stride;
+
+   if (!pbo ||
+       intel->ctx._ImageTransferState ||
+       unpack->SkipPixels || unpack->SkipRows) {
+      _mesa_printf("%s: failure 1\n", __FUNCTION__);
+      return GL_FALSE;
+   }
+
+   src_offset = (GLuint) pixels;
+
+   if (unpack->RowLength > 0)
+      src_stride = unpack->RowLength;
+   else
+      src_stride = width;
+
+   dst_offset = intel_miptree_image_offset(intelImage->mt,
+                                           intelImage->face,
+                                           intelImage->level);
+
+   dst_stride = intelImage->mt->pitch;
+
+   intelFlush(&intel->ctx);
+   LOCK_HARDWARE(intel);
+   {
+      dri_bo *src_buffer = intel_bufferobj_buffer(intel, pbo, INTEL_READ);
+      dri_bo *dst_buffer = intel_region_buffer(intel,
+                                              intelImage->mt->region,
+                                              INTEL_WRITE_FULL);
+
+
+      intelEmitCopyBlit(intel,
+                        intelImage->mt->cpp,
+                        src_stride, src_buffer, src_offset, GL_FALSE,
+                        dst_stride, dst_buffer, dst_offset, GL_FALSE,
+                        0, 0, 0, 0, width, height,
+                       GL_COPY);
+   }
+   UNLOCK_HARDWARE(intel);
+
+   return GL_TRUE;
+}
+
+
+
+static GLboolean
+try_pbo_zcopy(struct intel_context *intel,
+              struct intel_texture_image *intelImage,
+              const struct gl_pixelstore_attrib *unpack,
+              GLint internalFormat,
+              GLint width, GLint height,
+              GLenum format, GLenum type, const void *pixels)
+{
+   struct intel_buffer_object *pbo = intel_buffer_object(unpack->BufferObj);
+   GLuint src_offset, src_stride;
+   GLuint dst_offset, dst_stride;
+
+   if (!pbo ||
+       intel->ctx._ImageTransferState ||
+       unpack->SkipPixels || unpack->SkipRows) {
+      _mesa_printf("%s: failure 1\n", __FUNCTION__);
+      return GL_FALSE;
+   }
+
+   src_offset = (GLuint) pixels;
+
+   if (unpack->RowLength > 0)
+      src_stride = unpack->RowLength;
+   else
+      src_stride = width;
+
+   dst_offset = intel_miptree_image_offset(intelImage->mt,
+                                           intelImage->face,
+                                           intelImage->level);
+
+   dst_stride = intelImage->mt->pitch;
+
+   if (src_stride != dst_stride || dst_offset != 0 || src_offset != 0) {
+      _mesa_printf("%s: failure 2\n", __FUNCTION__);
+      return GL_FALSE;
+   }
+
+   intel_region_attach_pbo(intel, intelImage->mt->region, pbo);
+
+   return GL_TRUE;
+}
+
+
+
+
+
+
+static void
+intelTexImage(GLcontext * ctx,
+              GLint dims,
+              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 *unpack,
+              struct gl_texture_object *texObj,
+              struct gl_texture_image *texImage, GLsizei imageSize, int compressed)
+{
+   struct intel_context *intel = intel_context(ctx);
+   struct intel_texture_object *intelObj = intel_texture_object(texObj);
+   struct intel_texture_image *intelImage = intel_texture_image(texImage);
+   GLint postConvWidth = width;
+   GLint postConvHeight = height;
+   GLint texelBytes, sizeInBytes;
+   GLuint dstRowStride, srcRowStride = texImage->RowStride;
+
+
+   DBG("%s target %s level %d %dx%dx%d border %d\n", __FUNCTION__,
+       _mesa_lookup_enum_by_nr(target), level, width, height, depth, border);
+
+   intelFlush(ctx);
+
+   intelImage->face = target_to_face(target);
+   intelImage->level = level;
+
+   if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) {
+      _mesa_adjust_image_for_convolution(ctx, dims, &postConvWidth,
+                                         &postConvHeight);
+   }
+
+   /* choose the texture format */
+   texImage->TexFormat = intelChooseTextureFormat(ctx, internalFormat,
+                                                  format, type);
+
+   _mesa_set_fetch_functions(texImage, dims);
+
+   if (texImage->TexFormat->TexelBytes == 0) {
+      /* must be a compressed format */
+      texelBytes = 0;
+      texImage->IsCompressed = GL_TRUE;
+      texImage->CompressedSize =
+        ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
+                                          texImage->Height, texImage->Depth,
+                                          texImage->TexFormat->MesaFormat);
+   } else {
+      texelBytes = texImage->TexFormat->TexelBytes;
+      
+      /* Minimum pitch of 32 bytes */
+      if (postConvWidth * texelBytes < 32) {
+        postConvWidth = 32 / texelBytes;
+        texImage->RowStride = postConvWidth;
+      }
+
+      if (!intelImage->mt) {      
+         assert(texImage->RowStride == postConvWidth);
+      }
+   }
+
+   /* Release the reference to a potentially orphaned buffer.   
+    * Release any old malloced memory.
+    */
+   if (intelImage->mt) {
+      intel_miptree_release(intel, &intelImage->mt);
+      assert(!texImage->Data);
+   }
+   else if (texImage->Data) {
+      _mesa_free_texmemory(texImage->Data);
+      texImage->Data = NULL;
+   }
+
+   /* If this is the only texture image in the tree, could call
+    * bmBufferData with NULL data to free the old block and avoid
+    * waiting on any outstanding fences.
+    */
+   if (intelObj->mt &&
+       intelObj->mt->first_level == level &&
+       intelObj->mt->last_level == level &&
+       intelObj->mt->target != GL_TEXTURE_CUBE_MAP_ARB &&
+       !intel_miptree_match_image(intelObj->mt, &intelImage->base,
+                                  intelImage->face, intelImage->level)) {
+
+      DBG("release it\n");
+      intel_miptree_release(intel, &intelObj->mt);
+      assert(!intelObj->mt);
+   }
+
+   if (!intelObj->mt) {
+      guess_and_alloc_mipmap_tree(intel, intelObj, intelImage);
+      if (!intelObj->mt) {
+        DBG("guess_and_alloc_mipmap_tree: failed\n");
+      }
+   }
+
+   assert(!intelImage->mt);
+
+   if (intelObj->mt &&
+       intel_miptree_match_image(intelObj->mt, &intelImage->base,
+                                 intelImage->face, intelImage->level)) {
+
+      intel_miptree_reference(&intelImage->mt, intelObj->mt);
+      assert(intelImage->mt);
+   } else if (intelImage->base.Border == 0) {
+      int comp_byte = 0;
+
+      if (intelImage->base.IsCompressed) {
+        comp_byte =
+           intel_compressed_num_bytes(intelImage->base.TexFormat->MesaFormat);
+      }
+
+      /* Didn't fit in the object miptree, but it's suitable for inclusion in
+       * a miptree, so create one just for our level and store it in the image.
+       * It'll get moved into the object miptree at validate time.
+       */
+      intelImage->mt = intel_miptree_create(intel, target, internalFormat,
+                                           level, level,
+                                           width, height, depth,
+                                           intelImage->base.TexFormat->TexelBytes,
+                                           comp_byte);
+
+   }
+
+   /* PBO fastpaths:
+    */
+   if (dims <= 2 &&
+       intelImage->mt &&
+       intel_buffer_object(unpack->BufferObj) &&
+       check_pbo_format(internalFormat, format,
+                        type, intelImage->base.TexFormat)) {
+
+      DBG("trying pbo upload\n");
+
+      /* Attempt to texture directly from PBO data (zero copy upload).
+       *
+       * Currently disable as it can lead to worse as well as better
+       * performance (in particular when intel_region_cow() is
+       * required).
+       */
+      if (intelObj->mt == intelImage->mt &&
+          intelObj->mt->first_level == level &&
+          intelObj->mt->last_level == level) {
+
+         if (try_pbo_zcopy(intel, intelImage, unpack,
+                           internalFormat,
+                           width, height, format, type, pixels)) {
+
+            DBG("pbo zcopy upload succeeded\n");
+            return;
+         }
+      }
+
+
+      /* Otherwise, attempt to use the blitter for PBO image uploads.
+       */
+      if (try_pbo_upload(intel, intelImage, unpack,
+                         internalFormat,
+                         width, height, format, type, pixels)) {
+         DBG("pbo upload succeeded\n");
+         return;
+      }
+
+      DBG("pbo upload failed\n");
+   }
+
+
+
+   /* intelCopyTexImage calls this function with pixels == NULL, with
+    * the expectation that the mipmap tree will be set up but nothing
+    * more will be done.  This is where those calls return:
+    */
+   if (compressed) {
+      pixels = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, pixels,
+                                                     unpack,
+                                                     "glCompressedTexImage");
+   } else {
+      pixels = _mesa_validate_pbo_teximage(ctx, dims, width, height, 1,
+                                          format, type,
+                                          pixels, unpack, "glTexImage");
+   }
+
+   LOCK_HARDWARE(intel);
+
+   if (intelImage->mt) {
+      texImage->Data = intel_miptree_image_map(intel,
+                                               intelImage->mt,
+                                               intelImage->face,
+                                               intelImage->level,
+                                               &dstRowStride,
+                                               intelImage->base.ImageOffsets);
+      texImage->RowStride = dstRowStride / intelImage->mt->cpp;
+   }
+   else {
+      /* Allocate regular memory and store the image there temporarily.   */
+      if (texImage->IsCompressed) {
+         sizeInBytes = texImage->CompressedSize;
+         dstRowStride =
+            _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, width);
+         assert(dims != 3);
+      }
+      else {
+         dstRowStride = postConvWidth * texelBytes;
+         sizeInBytes = depth * dstRowStride * postConvHeight;
+      }
+
+      texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
+   }
+
+   DBG("Upload image %dx%dx%d row_len %d "
+       "pitch %d\n",
+       width, height, depth, width * texelBytes, dstRowStride);
+
+   /* Copy data.  Would like to know when it's ok for us to eg. use
+    * the blitter to copy.  Or, use the hardware to do the format
+    * conversion and copy:
+    */
+   if (pixels) {
+       if (compressed) {
+          if (intelImage->mt) {
+              struct intel_region *dst = intelImage->mt->region;
+              _mesa_copy_rect(texImage->Data, dst->cpp, dst->pitch,
+                              0, 0,
+                              intelImage->mt->level[level].width,
+                              intelImage->mt->level[level].height/4,
+                              pixels,
+                              srcRowStride,
+                              0, 0);
+          } else
+              memcpy(texImage->Data, pixels, imageSize);
+       } else if (!texImage->TexFormat->StoreImage(ctx, dims, 
+                                                  texImage->_BaseFormat, 
+                                                  texImage->TexFormat, 
+                                                  texImage->Data, 0, 0, 0, /* dstX/Y/Zoffset */
+                                                  dstRowStride,
+                                                  texImage->ImageOffsets,
+                                                  width, height, depth,
+                                                  format, type, pixels, unpack)) {
+          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
+       }
+   }
+
+   /* GL_SGIS_generate_mipmap */
+   if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+      intel_generate_mipmap(ctx, target, texObj);
+   }
+
+   _mesa_unmap_teximage_pbo(ctx, unpack);
+
+   if (intelImage->mt) {
+      intel_miptree_image_unmap(intel, intelImage->mt);
+      texImage->Data = NULL;
+   }
+
+   UNLOCK_HARDWARE(intel);
+}
+
+void
+intelTexImage3D(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 *unpack,
+                struct gl_texture_object *texObj,
+                struct gl_texture_image *texImage)
+{
+   intelTexImage(ctx, 3, target, level,
+                 internalFormat, width, height, depth, border,
+                 format, type, pixels, unpack, texObj, texImage, 0, 0);
+}
+
+
+void
+intelTexImage2D(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 *unpack,
+                struct gl_texture_object *texObj,
+                struct gl_texture_image *texImage)
+{
+   intelTexImage(ctx, 2, target, level,
+                 internalFormat, width, height, 1, border,
+                 format, type, pixels, unpack, texObj, texImage, 0, 0);
+}
+
+void
+intelTexImage1D(GLcontext * ctx,
+                GLenum target, GLint level,
+                GLint internalFormat,
+                GLint width, GLint border,
+                GLenum format, GLenum type, const void *pixels,
+                const struct gl_pixelstore_attrib *unpack,
+                struct gl_texture_object *texObj,
+                struct gl_texture_image *texImage)
+{
+   intelTexImage(ctx, 1, target, level,
+                 internalFormat, width, 1, 1, border,
+                 format, type, pixels, unpack, texObj, texImage, 0, 0);
+}
+
+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 )
+{
+   intelTexImage(ctx, 2, target, level,
+                internalFormat, width, height, 1, border,
+                0, 0, data, &ctx->Unpack, texObj, texImage, imageSize, 1);
+}
+
+/**
+ * Need to map texture image into memory before copying image data,
+ * then unmap it.
+ */
+static void
+intel_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
+                   GLenum format, GLenum type, GLvoid * pixels,
+                   struct gl_texture_object *texObj,
+                   struct gl_texture_image *texImage, int compressed)
+{
+   struct intel_context *intel = intel_context(ctx);
+   struct intel_texture_image *intelImage = intel_texture_image(texImage);
+
+   /* Map */
+   if (intelImage->mt) {
+      /* Image is stored in hardware format in a buffer managed by the
+       * kernel.  Need to explicitly map and unmap it.
+       */
+      intelImage->base.Data =
+         intel_miptree_image_map(intel,
+                                 intelImage->mt,
+                                 intelImage->face,
+                                 intelImage->level,
+                                 &intelImage->base.RowStride,
+                                 intelImage->base.ImageOffsets);
+      intelImage->base.RowStride /= intelImage->mt->cpp;
+   }
+   else {
+      /* Otherwise, the image should actually be stored in
+       * intelImage->base.Data.  This is pretty confusing for
+       * everybody, I'd much prefer to separate the two functions of
+       * texImage->Data - storage for texture images in main memory
+       * and access (ie mappings) of images.  In other words, we'd
+       * create a new texImage->Map field and leave Data simply for
+       * storage.
+       */
+      assert(intelImage->base.Data);
+   }
+
+
+   if (compressed) {
+      _mesa_get_compressed_teximage(ctx, target, level, pixels,
+                                   texObj, texImage);
+   } else {
+      _mesa_get_teximage(ctx, target, level, format, type, pixels,
+                        texObj, texImage);
+   }
+     
+
+   /* Unmap */
+   if (intelImage->mt) {
+      intel_miptree_image_unmap(intel, intelImage->mt);
+      intelImage->base.Data = NULL;
+   }
+}
+
+void
+intelGetTexImage(GLcontext * ctx, GLenum target, GLint level,
+                 GLenum format, GLenum type, GLvoid * pixels,
+                 struct gl_texture_object *texObj,
+                 struct gl_texture_image *texImage)
+{
+   intel_get_tex_image(ctx, target, level, format, type, pixels,
+                      texObj, texImage, 0);
+
+
+}
+
+void
+intelGetCompressedTexImage(GLcontext *ctx, GLenum target, GLint level,
+                          GLvoid *pixels,
+                          struct gl_texture_object *texObj,
+                          struct gl_texture_image *texImage)
+{
+   intel_get_tex_image(ctx, target, level, 0, 0, pixels,
+                      texObj, texImage, 1);
+}
+
+void
+intelSetTexOffset(__DRIcontext *pDRICtx, GLint texname,
+                 unsigned long long offset, GLint depth, GLuint pitch)
+{
+   struct intel_context *intel = pDRICtx->driverPrivate;
+   struct gl_texture_object *tObj = _mesa_lookup_texture(&intel->ctx, texname);
+   struct intel_texture_object *intelObj = intel_texture_object(tObj);
+
+   if (!intelObj)
+      return;
+
+   if (intelObj->mt)
+      intel_miptree_release(intel, &intelObj->mt);
+
+   intelObj->imageOverride = GL_TRUE;
+   intelObj->depthOverride = depth;
+   intelObj->pitchOverride = pitch;
+
+   if (offset)
+      intelObj->textureOffset = offset;
+}
+
+void
+intelSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv)
+{
+   struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
+   struct intel_context *intel = pDRICtx->driverPrivate;
+   struct intel_texture_object *intelObj;
+   struct intel_texture_image *intelImage;
+   struct intel_mipmap_tree *mt;
+   struct intel_renderbuffer *rb;
+   struct gl_texture_unit *texUnit;
+   struct gl_texture_object *texObj;
+   struct gl_texture_image *texImage;
+   int level = 0, type, format, internalFormat;
+
+   texUnit = &intel->ctx.Texture.Unit[intel->ctx.Texture.CurrentUnit];
+   texObj = _mesa_select_tex_object(&intel->ctx, texUnit, target);
+   intelObj = intel_texture_object(texObj);
+
+   if (!intelObj)
+      return;
+
+   intel_update_renderbuffers(pDRICtx, dPriv);
+
+   rb = intel_fb->color_rb[0];
+   /* If the region isn't set, then intel_update_renderbuffers was unable
+    * to get the buffers for the drawable.
+    */
+   if (rb->region == NULL)
+      return;
+
+   type = GL_BGRA;
+   format = GL_UNSIGNED_BYTE;
+   internalFormat = (rb->region->cpp == 3 ? 3 : 4);
+
+   mt = intel_miptree_create_for_region(intel, target,
+                                       internalFormat,
+                                       0, 0, rb->region, 1, 0);
+   if (mt == NULL)
+       return;
+
+   _mesa_lock_texture(&intel->ctx, texObj);
+
+   if (intelObj->mt)
+      intel_miptree_release(intel, &intelObj->mt);
+
+   intelObj->mt = mt;
+   texImage = _mesa_get_tex_image(&intel->ctx, texObj, target, level);
+   _mesa_init_teximage_fields(&intel->ctx, target, texImage,
+                             rb->region->width, rb->region->height, 1,
+                             0, internalFormat);
+
+   intelImage = intel_texture_image(texImage);
+   intelImage->face = target_to_face(target);
+   intelImage->level = level;
+   texImage->TexFormat = intelChooseTextureFormat(&intel->ctx, internalFormat,
+                                                  type, format);
+   _mesa_set_fetch_functions(texImage, 2);
+   texImage->RowStride = rb->region->pitch;
+   intel_miptree_reference(&intelImage->mt, intelObj->mt);
+
+   if (!intel_miptree_match_image(intelObj->mt, &intelImage->base,
+                                 intelImage->face, intelImage->level)) {
+          fprintf(stderr, "miptree doesn't match image\n");
+   }
+
+   _mesa_unlock_texture(&intel->ctx, texObj);
+}
index fcb5cc390682587c36db93ff630d339b71269e30..edc3a2eaa47a575b32ef65246ba94fbabd5846aa 100644 (file)
 
 #include "intel_mipmap_tree.h"
 #include "intel_tex_layout.h"
+#include "intel_context.h"
 #include "macros.h"
 
-
-static int align(int value, int alignment)
+GLuint intel_compressed_alignment(GLenum internalFormat)
 {
-   return (value + alignment - 1) & ~(alignment - 1);
+    GLuint alignment = 4;
+
+    switch (internalFormat) {
+    case GL_COMPRESSED_RGB_FXT1_3DFX:
+    case GL_COMPRESSED_RGBA_FXT1_3DFX:
+        alignment = 8;
+        break;
+
+    default:
+        break;
+    }
+
+    return alignment;
 }
 
-void i945_miptree_layout_2d( struct intel_mipmap_tree *mt )
+void i945_miptree_layout_2d( struct intel_context *intel, struct intel_mipmap_tree *mt )
 {
    GLint align_h = 2, align_w = 4;
    GLuint level;
@@ -51,23 +63,36 @@ void i945_miptree_layout_2d( struct intel_mipmap_tree *mt )
 
    mt->pitch = mt->width0;
 
+   if (mt->compressed) {
+       align_w = intel_compressed_alignment(mt->internal_format);
+       mt->pitch = ALIGN(mt->width0, align_w);
+   }
+
    /* May need to adjust pitch to accomodate the placement of
     * the 2nd mipmap.  This occurs when the alignment
     * constraints of mipmap placement push the right edge of the
     * 2nd mipmap out past the width of its parent.
     */
    if (mt->first_level != mt->last_level) {
-      GLuint mip1_width = align(minify(mt->width0), align_w)
-                       + minify(minify(mt->width0));
+       GLuint mip1_width;
+
+       if (mt->compressed) {
+           mip1_width = ALIGN(minify(mt->width0), align_w)
+               + ALIGN(minify(minify(mt->width0)), align_w);
+       } else {
+           mip1_width = ALIGN(minify(mt->width0), align_w)
+               + minify(minify(mt->width0));
+       }
 
-      if (mip1_width > mt->width0)
-        mt->pitch = mip1_width;
+       if (mip1_width > mt->pitch) {
+           mt->pitch = mip1_width;
+       }
    }
 
    /* Pitch must be a whole number of dwords, even though we
     * express it in texels.
     */
-   mt->pitch = align(mt->pitch * mt->cpp, 4) / mt->cpp;
+   mt->pitch = intel_miptree_pitch_align (intel, mt, mt->pitch);
    mt->total_height = 0;
 
    for ( level = mt->first_level ; level <= mt->last_level ; level++ ) {
@@ -79,7 +104,7 @@ void i945_miptree_layout_2d( struct intel_mipmap_tree *mt )
       if (mt->compressed)
         img_height = MAX2(1, height/4);
       else
-        img_height = align(height, align_h);
+        img_height = ALIGN(height, align_h);
 
 
       /* Because the images are packed better, the final offset
@@ -90,7 +115,7 @@ void i945_miptree_layout_2d( struct intel_mipmap_tree *mt )
       /* Layout_below: step right after second mipmap.
        */
       if (level == mt->first_level + 1) {
-        x += align(width, align_w);
+        x += ALIGN(width, align_w);
       }
       else {
         y += img_height;
index 1e37f8f525faa6da98e7dc138d1a4ca6ded5f6bd..193699d3f708f3a3da7f2773265915b29f17d1f4 100644 (file)
@@ -38,4 +38,5 @@ static GLuint minify( GLuint d )
    return MAX2(1, d>>1);
 }
 
-extern void i945_miptree_layout_2d( struct intel_mipmap_tree *mt );
+extern void i945_miptree_layout_2d( struct intel_context *intel, struct intel_mipmap_tree *mt );
+extern GLuint intel_compressed_alignment(GLenum);
diff --git a/src/mesa/drivers/dri/intel/intel_tex_obj.h b/src/mesa/drivers/dri/intel/intel_tex_obj.h
new file mode 100644 (file)
index 0000000..5a93461
--- /dev/null
@@ -0,0 +1,83 @@
+/**************************************************************************
+ * 
+ * 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_TEX_OBJ_H
+#define _INTEL_TEX_OBJ_H
+
+struct intel_texture_object
+{
+   struct gl_texture_object base;       /* The "parent" object */
+
+   /* The mipmap tree must include at least these levels once
+    * validated:
+    */
+   GLuint firstLevel;
+   GLuint lastLevel;
+
+   /* Offset for firstLevel image:
+    */
+   GLuint textureOffset;
+
+   /* On validation any active images held in main memory or in other
+    * regions will be copied to this region and the old storage freed.
+    */
+   struct intel_mipmap_tree *mt;
+
+   GLboolean imageOverride;
+   GLint depthOverride;
+   GLuint pitchOverride;
+};
+
+struct intel_texture_image
+{
+   struct gl_texture_image base;
+
+   /* These aren't stored in gl_texture_image 
+    */
+   GLuint level;
+   GLuint face;
+
+   /* If intelImage->mt != NULL, image data is stored here.
+    * Else if intelImage->base.Data != NULL, image is stored there.
+    * Else there is no image data.
+    */
+   struct intel_mipmap_tree *mt;
+};
+
+static INLINE struct intel_texture_object *
+intel_texture_object(struct gl_texture_object *obj)
+{
+   return (struct intel_texture_object *) obj;
+}
+
+static INLINE struct intel_texture_image *
+intel_texture_image(struct gl_texture_image *img)
+{
+   return (struct intel_texture_image *) img;
+}
+
+#endif /* _INTEL_TEX_OBJ_H */
diff --git a/src/mesa/drivers/dri/intel/intel_tex_subimage.c b/src/mesa/drivers/dri/intel/intel_tex_subimage.c
new file mode 100644 (file)
index 0000000..5428a1d
--- /dev/null
@@ -0,0 +1,186 @@
+
+/**************************************************************************
+ * 
+ * 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 "mtypes.h"
+#include "texobj.h"
+#include "texstore.h"
+#include "texcompress.h"
+#include "enums.h"
+
+#include "intel_context.h"
+#include "intel_tex.h"
+#include "intel_mipmap_tree.h"
+
+#define FILE_DEBUG_FLAG DEBUG_TEXTURE
+
+static void
+intelTexSubimage(GLcontext * ctx,
+                 GLint dims,
+                 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)
+{
+   struct intel_context *intel = intel_context(ctx);
+   struct intel_texture_image *intelImage = intel_texture_image(texImage);
+   GLuint dstRowStride = 0;
+   
+   DBG("%s target %s level %d offset %d,%d %dx%d\n", __FUNCTION__,
+       _mesa_lookup_enum_by_nr(target),
+       level, xoffset, yoffset, width, height);
+
+   intelFlush(ctx);
+
+   pixels =
+      _mesa_validate_pbo_teximage(ctx, dims, width, height, depth, format,
+                                  type, pixels, packing, "glTexSubImage2D");
+   if (!pixels)
+      return;
+
+   LOCK_HARDWARE(intel);
+
+   /* Map buffer if necessary.  Need to lock to prevent other contexts
+    * from uploading the buffer under us.
+    */
+   if (intelImage->mt) 
+      texImage->Data = intel_miptree_image_map(intel,
+                                               intelImage->mt,
+                                               intelImage->face,
+                                               intelImage->level,
+                                               &dstRowStride,
+                                               texImage->ImageOffsets);
+   else {
+      if (texImage->IsCompressed) {
+         dstRowStride =
+            _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, width);
+         assert(dims != 3);
+      }
+      else {
+         dstRowStride = texImage->RowStride * texImage->TexFormat->TexelBytes;
+      }
+   }
+
+   assert(dstRowStride);
+
+   if (!texImage->TexFormat->StoreImage(ctx, dims, texImage->_BaseFormat,
+                                        texImage->TexFormat,
+                                        texImage->Data,
+                                        xoffset, yoffset, zoffset,
+                                        dstRowStride,
+                                        texImage->ImageOffsets,
+                                        width, height, depth,
+                                        format, type, pixels, packing)) {
+      _mesa_error(ctx, GL_OUT_OF_MEMORY, "intelTexSubImage");
+   }
+
+   /* GL_SGIS_generate_mipmap */
+   if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+      intel_generate_mipmap(ctx, target, texObj);
+   }
+
+   _mesa_unmap_teximage_pbo(ctx, packing);
+
+   if (intelImage->mt) {
+      intel_miptree_image_unmap(intel, intelImage->mt);
+      texImage->Data = NULL;
+   }
+
+   UNLOCK_HARDWARE(intel);
+}
+
+
+
+
+
+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)
+{
+
+   intelTexSubimage(ctx, 3,
+                    target, level,
+                    xoffset, yoffset, zoffset,
+                    width, height, depth,
+                    format, type, pixels, packing, texObj, texImage);
+
+}
+
+
+
+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)
+{
+
+   intelTexSubimage(ctx, 2,
+                    target, level,
+                    xoffset, yoffset, 0,
+                    width, height, 1,
+                    format, type, pixels, packing, texObj, texImage);
+
+}
+
+
+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)
+{
+   intelTexSubimage(ctx, 1,
+                    target, level,
+                    xoffset, 0, 0,
+                    width, 1, 1,
+                    format, type, pixels, packing, texObj, texImage);
+
+}
diff --git a/src/mesa/drivers/dri/intel/intel_tex_validate.c b/src/mesa/drivers/dri/intel/intel_tex_validate.c
new file mode 100644 (file)
index 0000000..5763f4a
--- /dev/null
@@ -0,0 +1,300 @@
+#include "mtypes.h"
+#include "macros.h"
+
+#include "intel_context.h"
+#include "intel_batchbuffer.h"
+#include "intel_mipmap_tree.h"
+#include "intel_tex.h"
+
+#define FILE_DEBUG_FLAG DEBUG_TEXTURE
+
+/**
+ * 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.
+ */
+static void
+intel_calculate_first_last_level(struct intel_texture_object *intelObj)
+{
+   struct gl_texture_object *tObj = &intelObj->base;
+   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 {
+#ifdef I915
+         firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5);
+         firstLevel = MAX2(firstLevel, tObj->BaseLevel);
+         firstLevel = MIN2(firstLevel, tObj->BaseLevel + baseImage->MaxLog2);
+         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 */
+#else
+        /* Currently not taking min/max lod into account here, those
+         * values are programmed as sampler state elsewhere and we
+         * upload the same mipmap levels regardless.  Not sure if
+         * this makes sense as it means it isn't possible for the app
+         * to use min/max lod to reduce texture memory pressure:
+         */
+        firstLevel = tObj->BaseLevel;
+        lastLevel = MIN2(tObj->BaseLevel + baseImage->MaxLog2,
+                         tObj->MaxLevel);
+        lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
+#endif
+      }
+      break;
+   case GL_TEXTURE_RECTANGLE_NV:
+   case GL_TEXTURE_4D_SGIS:
+      firstLevel = lastLevel = 0;
+      break;
+   default:
+      return;
+   }
+
+   /* save these values */
+   intelObj->firstLevel = firstLevel;
+   intelObj->lastLevel = lastLevel;
+}
+
+/**
+ * Copies the image's contents at its level into the object's miptree,
+ * and updates the image to point at the object's miptree.
+ */
+static void
+copy_image_data_to_tree(struct intel_context *intel,
+                        struct intel_texture_object *intelObj,
+                        struct intel_texture_image *intelImage)
+{
+   if (intelImage->mt) {
+      /* Copy potentially with the blitter:
+       */
+      intel_miptree_image_copy(intel,
+                               intelObj->mt,
+                               intelImage->face,
+                               intelImage->level, intelImage->mt);
+
+      intel_miptree_release(intel, &intelImage->mt);
+   }
+   else {
+      assert(intelImage->base.Data != NULL);
+
+      /* More straightforward upload.  
+       */
+      intel_miptree_image_data(intel,
+                               intelObj->mt,
+                               intelImage->face,
+                               intelImage->level,
+                               intelImage->base.Data,
+                               intelImage->base.RowStride,
+                               intelImage->base.RowStride *
+                               intelImage->base.Height);
+      _mesa_align_free(intelImage->base.Data);
+      intelImage->base.Data = NULL;
+   }
+
+   intel_miptree_reference(&intelImage->mt, intelObj->mt);
+}
+
+
+/*  
+ */
+GLuint
+intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
+{
+   struct gl_texture_object *tObj = intel->ctx.Texture.Unit[unit]._Current;
+   struct intel_texture_object *intelObj = intel_texture_object(tObj);
+   int comp_byte = 0;
+   int cpp;
+   GLuint face, i;
+   GLuint nr_faces = 0;
+   struct intel_texture_image *firstImage;
+
+   /* We know/require this is true by now: 
+    */
+   assert(intelObj->base._Complete);
+
+   /* What levels must the tree include at a minimum?
+    */
+   intel_calculate_first_last_level(intelObj);
+   firstImage =
+      intel_texture_image(intelObj->base.Image[0][intelObj->firstLevel]);
+
+   /* Fallback case:
+    */
+   if (firstImage->base.Border ||
+       ((firstImage->base._BaseFormat == GL_DEPTH_COMPONENT) &&
+        ((tObj->WrapS == GL_CLAMP_TO_BORDER) ||
+         (tObj->WrapT == GL_CLAMP_TO_BORDER)))) {
+      if (intelObj->mt) {
+         intel_miptree_release(intel, &intelObj->mt);
+      }
+      return GL_FALSE;
+   }
+
+
+   /* If both firstImage and intelObj have a tree which can contain
+    * all active images, favour firstImage.  Note that because of the
+    * completeness requirement, we know that the image dimensions
+    * will match.
+    */
+   if (firstImage->mt &&
+       firstImage->mt != intelObj->mt &&
+       firstImage->mt->first_level <= intelObj->firstLevel &&
+       firstImage->mt->last_level >= intelObj->lastLevel) {
+
+      if (intelObj->mt)
+         intel_miptree_release(intel, &intelObj->mt);
+
+      intel_miptree_reference(&intelObj->mt, firstImage->mt);
+   }
+
+   if (firstImage->base.IsCompressed) {
+      comp_byte = intel_compressed_num_bytes(firstImage->base.TexFormat->MesaFormat);
+      cpp = comp_byte;
+   }
+   else cpp = firstImage->base.TexFormat->TexelBytes;
+
+   /* Check tree can hold all active levels.  Check tree matches
+    * target, imageFormat, etc.
+    * 
+    * XXX: For some layouts (eg i945?), the test might have to be
+    * first_level == firstLevel, as the tree isn't valid except at the
+    * original start level.  Hope to get around this by
+    * programming minLod, maxLod, baseLevel into the hardware and
+    * leaving the tree alone.
+    */
+   if (intelObj->mt &&
+       (intelObj->mt->target != intelObj->base.Target ||
+       intelObj->mt->internal_format != firstImage->base.InternalFormat ||
+       intelObj->mt->first_level != intelObj->firstLevel ||
+       intelObj->mt->last_level != intelObj->lastLevel ||
+       intelObj->mt->width0 != firstImage->base.Width ||
+       intelObj->mt->height0 != firstImage->base.Height ||
+       intelObj->mt->depth0 != firstImage->base.Depth ||
+       intelObj->mt->cpp != cpp ||
+       intelObj->mt->compressed != firstImage->base.IsCompressed)) {
+      intel_miptree_release(intel, &intelObj->mt);
+   }
+
+
+   /* May need to create a new tree:
+    */
+   if (!intelObj->mt) {
+      intelObj->mt = intel_miptree_create(intel,
+                                          intelObj->base.Target,
+                                          firstImage->base.InternalFormat,
+                                          intelObj->firstLevel,
+                                          intelObj->lastLevel,
+                                          firstImage->base.Width,
+                                          firstImage->base.Height,
+                                          firstImage->base.Depth,
+                                          cpp,
+                                          comp_byte);
+   }
+
+   /* Pull in any images not in the object's tree:
+    */
+   nr_faces = (intelObj->base.Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
+   for (face = 0; face < nr_faces; face++) {
+      for (i = intelObj->firstLevel; i <= intelObj->lastLevel; i++) {
+         struct intel_texture_image *intelImage =
+            intel_texture_image(intelObj->base.Image[face][i]);
+
+         /* Need to import images in main memory or held in other trees.
+          */
+         if (intelObj->mt != intelImage->mt) {
+            copy_image_data_to_tree(intel, intelObj, intelImage);
+         }
+      }
+   }
+
+   return GL_TRUE;
+}
+
+void
+intel_tex_map_level_images(struct intel_context *intel,
+                          struct intel_texture_object *intelObj,
+                          int level)
+{
+   GLuint nr_faces = (intelObj->base.Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
+   GLuint face;
+
+   for (face = 0; face < nr_faces; face++) {
+      struct intel_texture_image *intelImage =
+        intel_texture_image(intelObj->base.Image[face][level]);
+
+      if (intelImage->mt) {
+        intelImage->base.Data =
+           intel_miptree_image_map(intel,
+                                   intelImage->mt,
+                                   intelImage->face,
+                                   intelImage->level,
+                                   &intelImage->base.RowStride,
+                                   intelImage->base.ImageOffsets);
+        /* convert stride to texels, not bytes */
+        intelImage->base.RowStride /= intelImage->mt->cpp;
+        /* intelImage->base.ImageStride /= intelImage->mt->cpp; */
+      }
+   }
+}
+
+void
+intel_tex_unmap_level_images(struct intel_context *intel,
+                            struct intel_texture_object *intelObj,
+                            int level)
+{
+   GLuint nr_faces = (intelObj->base.Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
+   GLuint face;
+
+   for (face = 0; face < nr_faces; face++) {
+      struct intel_texture_image *intelImage =
+        intel_texture_image(intelObj->base.Image[face][level]);
+
+      if (intelImage->mt) {
+        intel_miptree_image_unmap(intel, intelImage->mt);
+        intelImage->base.Data = NULL;
+      }
+   }
+}
+
+void
+intel_tex_map_images(struct intel_context *intel,
+                     struct intel_texture_object *intelObj)
+{
+   int i;
+
+   DBG("%s\n", __FUNCTION__);
+
+   for (i = intelObj->firstLevel; i <= intelObj->lastLevel; i++)
+      intel_tex_map_level_images(intel, intelObj, i);
+}
+
+void
+intel_tex_unmap_images(struct intel_context *intel,
+                       struct intel_texture_object *intelObj)
+{
+   int i;
+
+   for (i = intelObj->firstLevel; i <= intelObj->lastLevel; i++)
+      intel_tex_unmap_level_images(intel, intelObj, i);
+}
diff --git a/src/mesa/drivers/dri/intel/server/i830_dri.h b/src/mesa/drivers/dri/intel/server/i830_dri.h
new file mode 100644 (file)
index 0000000..def049e
--- /dev/null
@@ -0,0 +1,62 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_dri.h,v 1.6 2003/09/28 20:15:59 alanh Exp $ */
+
+#ifndef _I830_DRI_H
+#define _I830_DRI_H
+
+#include "xf86drm.h"
+
+#define I830_MAX_DRAWABLES 256
+
+#define I830_MAJOR_VERSION 1
+#define I830_MINOR_VERSION 9
+#define I830_PATCHLEVEL 0
+
+#define I830_REG_SIZE 0x80000
+
+typedef struct _I830DRIRec {
+   drm_handle_t regs;
+   drmSize regsSize;
+
+   drmSize unused1; /* backbufferSize */
+   drm_handle_t unused2; /* backbuffer */
+
+   drmSize unused3; /* depthbufferSize */
+   drm_handle_t unused4; /* depthbuffer */
+
+   drmSize unused5; /* rotatedSize */
+   drm_handle_t unused6; /* rotatedbuffer */
+
+   drm_handle_t unused7; /* textures */
+   int unused8; /* textureSize */
+
+   drm_handle_t unused9; /* agp_buffers */
+   drmSize unused10; /* agp_buf_size */
+
+   int deviceID;
+   int width;
+   int height;
+   int mem;
+   int cpp;
+   int bitsPerPixel;
+
+   int unused11[8]; /* was front/back/depth/rotated offset/pitch */
+
+   int unused12; /* logTextureGranularity */
+   int unused13; /* 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/src/mesa/drivers/dri/intel/server/intel.h b/src/mesa/drivers/dri/intel/server/intel.h
new file mode 100644 (file)
index 0000000..6ea7249
--- /dev/null
@@ -0,0 +1,331 @@
+#ifndef _INTEL_H_
+#define _INTEL_H_
+
+#include "xf86drm.h"           /* drm_handle_t, etc */
+
+/* Intel */
+#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
+#define PCI_CHIP_I810_BRIDGE       0x7120
+#define PCI_CHIP_I810_DC100_BRIDGE 0x7122
+#define PCI_CHIP_I810_E_BRIDGE     0x7124
+#define PCI_CHIP_I815_BRIDGE       0x1130
+#endif
+
+#define PCI_CHIP_845_G                 0x2562
+#define PCI_CHIP_I830_M                        0x3577
+
+#ifndef PCI_CHIP_I855_GM
+#define PCI_CHIP_I855_GM          0x3582
+#define PCI_CHIP_I855_GM_BRIDGE           0x3580
+#endif
+
+#ifndef PCI_CHIP_I865_G
+#define PCI_CHIP_I865_G                   0x2572
+#define PCI_CHIP_I865_G_BRIDGE    0x2570
+#endif
+
+#ifndef PCI_CHIP_I915_G
+#define PCI_CHIP_I915_G                   0x2582
+#define PCI_CHIP_I915_G_BRIDGE    0x2580
+#endif
+
+#ifndef PCI_CHIP_I915_GM
+#define PCI_CHIP_I915_GM          0x2592
+#define PCI_CHIP_I915_GM_BRIDGE           0x2590
+#endif
+
+#ifndef PCI_CHIP_E7221_G
+#define PCI_CHIP_E7221_G          0x258A
+/* Same as I915_G_BRIDGE */
+#define PCI_CHIP_E7221_G_BRIDGE           0x2580
+#endif
+
+#ifndef PCI_CHIP_I945_G
+#define PCI_CHIP_I945_G        0x2772
+#define PCI_CHIP_I945_G_BRIDGE 0x2770
+#endif
+
+#ifndef PCI_CHIP_I945_GM
+#define PCI_CHIP_I945_GM        0x27A2
+#define PCI_CHIP_I945_GM_BRIDGE 0x27A0
+#endif
+
+#define IS_I810(pI810) (pI810->Chipset == PCI_CHIP_I810 ||     \
+                       pI810->Chipset == PCI_CHIP_I810_DC100 || \
+                       pI810->Chipset == PCI_CHIP_I810_E)
+#define IS_I815(pI810) (pI810->Chipset == PCI_CHIP_I815)
+#define IS_I830(pI810) (pI810->Chipset == PCI_CHIP_I830_M)
+#define IS_845G(pI810) (pI810->Chipset == PCI_CHIP_845_G)
+#define IS_I85X(pI810)  (pI810->Chipset == PCI_CHIP_I855_GM)
+#define IS_I852(pI810)  (pI810->Chipset == PCI_CHIP_I855_GM && (pI810->variant == I852_GM || pI810->variant == I852_GME))
+#define IS_I855(pI810)  (pI810->Chipset == PCI_CHIP_I855_GM && (pI810->variant == I855_GM || pI810->variant == I855_GME))
+#define IS_I865G(pI810) (pI810->Chipset == PCI_CHIP_I865_G)
+
+#define IS_I915G(pI810) (pI810->Chipset == PCI_CHIP_I915_G || pI810->Chipset == PCI_CHIP_E7221_G)
+#define IS_I915GM(pI810) (pI810->Chipset == PCI_CHIP_I915_GM)
+#define IS_I945G(pI810) (pI810->Chipset == PCI_CHIP_I945_G)
+#define IS_I945GM(pI810) (pI810->Chipset == PCI_CHIP_I945_GM)
+#define IS_I9XX(pI810) (IS_I915G(pI810) || IS_I915GM(pI810) || IS_I945G(pI810) || IS_I945GM(pI810))
+
+#define IS_MOBILE(pI810) (IS_I830(pI810) || IS_I85X(pI810) || IS_I915GM(pI810) || IS_I945GM(pI810))
+
+#define I830_GMCH_CTRL         0x52
+
+#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 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 I915G_GMCH_GMS_STOLEN_48M              (0x6 << 4)
+#define I915G_GMCH_GMS_STOLEN_64M              (0x7 << 4)
+
+typedef unsigned char Bool;
+#define TRUE 1
+#define FALSE 0
+
+#define PIPE_NONE      0<<0
+#define PIPE_CRT       1<<0
+#define PIPE_TV                1<<1
+#define PIPE_DFP       1<<2
+#define PIPE_LFP       1<<3
+#define PIPE_CRT2      1<<4
+#define PIPE_TV2       1<<5
+#define PIPE_DFP2      1<<6
+#define PIPE_LFP2      1<<7
+
+typedef struct _I830MemPool *I830MemPoolPtr;
+typedef struct _I830MemRange *I830MemRangePtr;
+typedef struct _I830MemRange {
+   long Start;
+   long End;
+   long Size;
+   unsigned long Physical;
+   unsigned long Offset;               /* Offset of AGP-allocated portion */
+   unsigned long Alignment;
+   drm_handle_t Key;
+   unsigned long Pitch; // add pitch
+   I830MemPoolPtr Pool;
+} I830MemRange;
+
+typedef struct _I830MemPool {
+   I830MemRange Total;
+   I830MemRange Free;
+   I830MemRange Fixed;
+   I830MemRange Allocated;
+} I830MemPool;
+
+typedef struct {
+   int tail_mask;
+   I830MemRange mem;
+   unsigned char *virtual_start;
+   int head;
+   int tail;
+   int space;
+} I830RingBuffer;
+
+typedef struct _I830Rec {
+   unsigned char *MMIOBase;
+   unsigned char *FbBase;
+   int cpp;
+   uint32_t aper_size;
+   unsigned int bios_version;
+
+   /* These are set in PreInit and never changed. */
+   long FbMapSize;
+   long TotalVideoRam;
+   I830MemRange StolenMemory;          /* pre-allocated memory */
+   long BIOSMemorySize;                        /* min stolen pool size */
+   int BIOSMemSizeLoc;
+
+   /* These change according to what has been allocated. */
+   long FreeMemory;
+   I830MemRange MemoryAperture;
+   I830MemPool StolenPool;
+   long allocatedMemory;
+
+   /* Regions allocated either from the above pools, or from agpgart. */
+   /* for single and dual head configurations */
+   I830MemRange FrontBuffer;
+   I830MemRange FrontBuffer2;
+   I830MemRange Scratch;
+   I830MemRange Scratch2;
+
+   I830RingBuffer *LpRing;
+
+   I830MemRange BackBuffer;
+   I830MemRange DepthBuffer;
+   I830MemRange TexMem;
+   int TexGranularity;
+   I830MemRange ContextMem;
+   int drmMinor;
+   Bool have3DWindows;
+
+   Bool NeedRingBufferLow;
+   Bool allowPageFlip;
+   Bool disableTiling;
+
+   int Chipset;
+   unsigned long LinearAddr;
+   unsigned long MMIOAddr;
+
+   drmSize           registerSize;     /**< \brief MMIO register map size */
+   drm_handle_t         registerHandle;   /**< \brief MMIO register map handle */
+  //   IOADDRESS ioBase;
+   int               irq;              /**< \brief IRQ number */
+   int GttBound;
+
+   drm_handle_t ring_map;
+   unsigned int Fence[8];
+
+} I830Rec;
+
+/*
+ * 12288 is set as the maximum, chosen because it is enough for
+ * 1920x1440@32bpp with a 2048 pixel line pitch with some to spare.
+ */
+#define I830_MAXIMUM_VBIOS_MEM         12288
+#define I830_DEFAULT_VIDEOMEM_2D       (MB(32) / 1024)
+#define I830_DEFAULT_VIDEOMEM_3D       (MB(64) / 1024)
+
+/* Flags for memory allocation function */
+#define FROM_ANYWHERE                  0x00000000
+#define FROM_POOL_ONLY                 0x00000001
+#define FROM_NEW_ONLY                  0x00000002
+#define FROM_MASK                      0x0000000f
+
+#define ALLOCATE_AT_TOP                        0x00000010
+#define ALLOCATE_AT_BOTTOM             0x00000020
+#define FORCE_GAPS                     0x00000040
+
+#define NEED_PHYSICAL_ADDR             0x00000100
+#define ALIGN_BOTH_ENDS                        0x00000200
+#define FORCE_LOW                      0x00000400
+
+#define ALLOC_NO_TILING                        0x00001000
+#define ALLOC_INITIAL                  0x00002000
+
+#define ALLOCATE_DRY_RUN               0x80000000
+
+/* Chipset registers for VIDEO BIOS memory RW access */
+#define _855_DRAM_RW_CONTROL 0x58
+#define _845_DRAM_RW_CONTROL 0x90
+#define DRAM_WRITE    0x33330000
+
+#define KB(x) ((x) * 1024)
+#define MB(x) ((x) * KB(1024))
+
+#define GTT_PAGE_SIZE                  KB(4)
+#define ROUND_TO(x, y)                 (((x) + (y) - 1) / (y) * (y))
+#define ROUND_DOWN_TO(x, y)            ((x) / (y) * (y))
+#define ROUND_TO_PAGE(x)               ROUND_TO((x), GTT_PAGE_SIZE)
+#define ROUND_TO_MB(x)                 ROUND_TO((x), MB(1))
+#define PRIMARY_RINGBUFFER_SIZE                KB(128)
+
+
+/* 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          0x03FFFFF8
+#define I830_RING_START_MASK   0xFFFFF000
+
+#define RING_LEN       0x0C
+#define RING_NR_PAGES       0x001FF000 
+#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
+
+
+/* Fence/Tiling ranges [0..7]
+ */
+#define FENCE            0x2000
+#define FENCE_NR         8
+
+#define I915G_FENCE_START_MASK 0x0ff00000
+
+#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 I915G_FENCE_SIZE_1M       0x00000000
+#define I915G_FENCE_SIZE_2M       0x00000100
+#define I915G_FENCE_SIZE_4M       0x00000200
+#define I915G_FENCE_SIZE_8M       0x00000300
+#define I915G_FENCE_SIZE_16M      0x00000400
+#define I915G_FENCE_SIZE_32M      0x00000500
+#define I915G_FENCE_SIZE_64M   0x00000600
+#define I915G_FENCE_SIZE_128M  0x00000700
+#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
+
+#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(MMIO, addr)
+#define INREG(addr)         MMIO_IN32(MMIO, addr)
+#define OUTREG8(addr, val)  MMIO_OUT8(MMIO, addr, val)
+#define OUTREG(addr, val)   MMIO_OUT32(MMIO, addr, val)
+
+#define DSPABASE               0x70184
+
+#endif
diff --git a/src/mesa/drivers/dri/intel/server/intel_dri.c b/src/mesa/drivers/dri/intel/server/intel_dri.c
new file mode 100644 (file)
index 0000000..e49c421
--- /dev/null
@@ -0,0 +1,1306 @@
+/**
+ * \file server/intel_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) 2006 Dave Airlie (airlied@linux.ie)
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and 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 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include "driver.h"
+#include "drm.h"
+
+#include "intel.h"
+#include "i830_dri.h"
+
+#include "memops.h"
+#include "pciaccess.h"
+
+static size_t drm_page_size;
+static int nextTile = 0;
+#define xf86DrvMsg(...) do {} while(0)
+
+static const int pitches[] = {
+  128 * 8,
+  128 * 16,
+  128 * 32,
+  128 * 64,
+  0
+};
+
+static Bool I830DRIDoMappings(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea);
+
+static unsigned long
+GetBestTileAlignment(unsigned long size)
+{
+   unsigned long i;
+
+   for (i = KB(512); i < size; i <<= 1)
+      ;
+
+   if (i > MB(64))
+      i = MB(64);
+
+   return i;
+}
+
+static void SetFenceRegs(const DRIDriverContext *ctx, I830Rec *pI830)
+{
+  int i;
+  unsigned char *MMIO = ctx->MMIOAddress;
+
+  for (i = 0; i < 8; i++) {
+    OUTREG(FENCE + i * 4, pI830->Fence[i]);
+    //    if (I810_DEBUG & DEBUG_VERBOSE_VGA)
+    fprintf(stderr,"Fence Register : %x\n", pI830->Fence[i]);
+  }
+}
+
+/* Tiled memory is good... really, really good...
+ *
+ * Need to make it less likely that we miss out on this - probably
+ * need to move the frontbuffer away from the 'guarenteed' alignment
+ * of the first memory segment, or perhaps allocate a discontigous
+ * framebuffer to get more alignment 'sweet spots'.
+ */
+static void
+SetFence(const DRIDriverContext *ctx, I830Rec *pI830,
+        int nr, unsigned int start, unsigned int pitch,
+         unsigned int size)
+{
+   unsigned int val;
+   unsigned int fence_mask = 0;
+   unsigned int fence_pitch;
+
+   if (nr < 0 || nr > 7) {
+      fprintf(stderr,
+                "SetFence: fence %d out of range\n",nr);
+      return;
+   }
+
+   pI830->Fence[nr] = 0;
+
+   if (IS_I9XX(pI830))
+       fence_mask = ~I915G_FENCE_START_MASK;
+   else
+       fence_mask = ~I830_FENCE_START_MASK;
+
+   if (start & fence_mask) {
+      fprintf(stderr,
+                "SetFence: %d: start (0x%08x) is not %s aligned\n",
+                nr, start, (IS_I9XX(pI830)) ? "1MB" : "512k");
+      return;
+   }
+
+   if (start % size) {
+      fprintf(stderr,
+                "SetFence: %d: start (0x%08x) is not size (%dk) aligned\n",
+                nr, start, size / 1024);
+      return;
+   }
+
+   if (pitch & 127) {
+      fprintf(stderr,
+                "SetFence: %d: pitch (%d) not a multiple of 128 bytes\n",
+                nr, pitch);
+      return;
+   }
+
+   val = (start | FENCE_X_MAJOR | FENCE_VALID);
+
+   if (IS_I9XX(pI830)) {
+       switch (size) {
+          case MB(1):
+               val |= I915G_FENCE_SIZE_1M;
+               break;
+          case MB(2):
+               val |= I915G_FENCE_SIZE_2M;
+               break;
+          case MB(4):
+               val |= I915G_FENCE_SIZE_4M;
+               break;
+          case MB(8):
+               val |= I915G_FENCE_SIZE_8M;
+               break;
+          case MB(16):
+               val |= I915G_FENCE_SIZE_16M;
+               break;
+          case MB(32):
+               val |= I915G_FENCE_SIZE_32M;
+               break;
+          case MB(64):
+               val |= I915G_FENCE_SIZE_64M;
+               break;
+          default:
+               fprintf(stderr,
+                "SetFence: %d: illegal size (%d kByte)\n", nr, size / 1024);
+               return;
+       }
+    } else {
+       switch (size) {
+          case KB(512):
+               val |= FENCE_SIZE_512K;
+               break;
+          case MB(1):
+               val |= FENCE_SIZE_1M;
+               break;
+          case MB(2):
+               val |= FENCE_SIZE_2M;
+               break;
+          case MB(4):
+               val |= FENCE_SIZE_4M;
+               break;
+          case MB(8):
+               val |= FENCE_SIZE_8M;
+               break;
+          case MB(16):
+               val |= FENCE_SIZE_16M;
+               break;
+          case MB(32):
+               val |= FENCE_SIZE_32M;
+               break;
+          case MB(64):
+               val |= FENCE_SIZE_64M;
+               break;
+          default:
+               fprintf(stderr,
+                "SetFence: %d: illegal size (%d kByte)\n", nr, size / 1024);
+               return;
+       }
+   }
+
+   if (IS_I9XX(pI830))
+       fence_pitch = pitch / 512;
+   else
+       fence_pitch = pitch / 128;
+
+   switch (fence_pitch) {
+   case 1:
+      val |= FENCE_PITCH_1;
+      break;
+   case 2:
+      val |= FENCE_PITCH_2;
+      break;
+   case 4:
+      val |= FENCE_PITCH_4;
+      break;
+   case 8:
+      val |= FENCE_PITCH_8;
+      break;
+   case 16:
+      val |= FENCE_PITCH_16;
+      break;
+   case 32:
+      val |= FENCE_PITCH_32;
+      break;
+   case 64:
+      val |= FENCE_PITCH_64;
+      break;
+   default:
+      fprintf(stderr,
+                "SetFence: %d: illegal pitch (%d)\n", nr, pitch);
+      return;
+   }
+
+   pI830->Fence[nr] = val;
+}
+
+static Bool
+MakeTiles(const DRIDriverContext *ctx, I830Rec *pI830, I830MemRange *pMem)
+{
+   int pitch, ntiles, i;
+
+   pitch = pMem->Pitch * ctx->cpp;
+   /*
+    * Simply try to break the region up into at most four pieces of size
+    * equal to the alignment.
+    */
+   ntiles = ROUND_TO(pMem->Size, pMem->Alignment) / pMem->Alignment;
+   if (ntiles >= 4) {
+      return FALSE;
+   }
+
+   for (i = 0; i < ntiles; i++, nextTile++) {
+     SetFence(ctx, pI830, nextTile, pMem->Start + i * pMem->Alignment,
+              pitch, pMem->Alignment);
+   }
+   return TRUE;
+}
+
+static void I830SetupMemoryTiling(const DRIDriverContext *ctx, I830Rec *pI830)
+{
+  int i;
+
+  /* Clear out */
+  for (i = 0; i < 8; i++)
+    pI830->Fence[i] = 0;
+  
+  nextTile = 0;
+
+  if (pI830->BackBuffer.Alignment >= KB(512)) {
+    if (MakeTiles(ctx, pI830, &(pI830->BackBuffer))) {
+      fprintf(stderr,
+                "Activating tiled memory for the back buffer.\n");
+    } else {
+      fprintf(stderr,
+                "MakeTiles failed for the back buffer.\n");
+      pI830->allowPageFlip = FALSE;
+    }
+  }
+  
+  if (pI830->DepthBuffer.Alignment >= KB(512)) {
+    if (MakeTiles(ctx, pI830, &(pI830->DepthBuffer))) {
+      fprintf(stderr,
+                "Activating tiled memory for the depth buffer.\n");
+    } else {
+      fprintf(stderr,
+                "MakeTiles failed for the depth buffer.\n");
+    }
+  }
+
+  return;
+}
+
+static int I830DetectMemory(const DRIDriverContext *ctx, I830Rec *pI830)
+{
+  struct pci_device host_bridge, ig_dev;
+  uint32_t gmch_ctrl;
+  int memsize = 0;
+  int range;
+  uint32_t aper_size;
+  uint32_t membase2 = 0;
+      
+  memset(&host_bridge, 0, sizeof(host_bridge));
+  memset(&ig_dev, 0, sizeof(ig_dev));
+
+  ig_dev.dev = 2;
+
+  pci_device_cfg_read_u32(&host_bridge, &gmch_ctrl, I830_GMCH_CTRL);
+
+  if (IS_I830(pI830) || IS_845G(pI830)) {
+    if ((gmch_ctrl & I830_GMCH_MEM_MASK) == I830_GMCH_MEM_128M) {
+      aper_size = 0x80000000;
+    } else {
+      aper_size = 0x40000000;
+    }
+  } else {
+    if (IS_I9XX(pI830)) {
+      int ret;
+      ret = pci_device_cfg_read_u32(&ig_dev, &membase2, 0x18);
+      if (membase2 & 0x08000000)
+       aper_size = 0x8000000;
+      else
+       aper_size = 0x10000000;
+
+      fprintf(stderr,"aper size is %08X %08x %d\n", aper_size, membase2, ret);
+    } else
+      aper_size = 0x8000000;
+  }
+
+  pI830->aper_size = aper_size;
+
+
+  /* We need to reduce the stolen size, by the GTT and the popup.
+   * The GTT varying according the the FbMapSize and the popup is 4KB */
+  range = (ctx->shared.fbSize / (1024*1024)) + 4;
+
+   if (IS_I85X(pI830) || IS_I865G(pI830) || IS_I9XX(pI830)) {
+      switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
+      case I855_GMCH_GMS_STOLEN_1M:
+        memsize = MB(1) - KB(range);
+        break;
+      case I855_GMCH_GMS_STOLEN_4M:
+        memsize = MB(4) - KB(range);
+        break;
+      case I855_GMCH_GMS_STOLEN_8M:
+        memsize = MB(8) - KB(range);
+        break;
+      case I855_GMCH_GMS_STOLEN_16M:
+        memsize = MB(16) - KB(range);
+        break;
+      case I855_GMCH_GMS_STOLEN_32M:
+        memsize = MB(32) - KB(range);
+        break;
+      case I915G_GMCH_GMS_STOLEN_48M:
+        if (IS_I9XX(pI830))
+           memsize = MB(48) - KB(range);
+        break;
+      case I915G_GMCH_GMS_STOLEN_64M:
+        if (IS_I9XX(pI830))
+           memsize = MB(64) - KB(range);
+        break;
+      }
+   } else {
+      switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
+      case I830_GMCH_GMS_STOLEN_512:
+        memsize = KB(512) - KB(range);
+        break;
+      case I830_GMCH_GMS_STOLEN_1024:
+        memsize = MB(1) - KB(range);
+        break;
+      case I830_GMCH_GMS_STOLEN_8192:
+        memsize = MB(8) - KB(range);
+        break;
+      case I830_GMCH_GMS_LOCAL:
+        memsize = 0;
+        xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+                   "Local memory found, but won't be used.\n");
+        break;
+      }
+   }
+   if (memsize > 0) {
+     fprintf(stderr,
+                "detected %d kB stolen memory.\n", memsize / 1024);
+   } else {
+     fprintf(stderr,
+                "no video memory detected.\n");
+   }
+   return memsize;
+}
+
+static int AgpInit(const DRIDriverContext *ctx, I830Rec *info)
+{
+  unsigned long mode = 0x4;
+
+  if (drmAgpAcquire(ctx->drmFD) < 0) {
+    fprintf(stderr, "[gart] AGP not available\n");
+    return 0;
+  }
+  
+  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);
+
+  return 1;
+}
+
+/*
+ * Allocate memory from the given pool.  Grow the pool if needed and if
+ * possible.
+ */
+static unsigned long
+AllocFromPool(const DRIDriverContext *ctx, I830Rec *pI830, 
+             I830MemRange *result, I830MemPool *pool,
+             long size, unsigned long alignment, int flags)
+{
+   long needed, start, end;
+
+   if (!result || !pool || !size)
+      return 0;
+
+   /* Calculate how much space is needed. */
+   if (alignment <= GTT_PAGE_SIZE)
+      needed = size;
+   else {
+        start = ROUND_TO(pool->Free.Start, alignment);
+        end = ROUND_TO(start + size, alignment);
+        needed = end - pool->Free.Start;
+   }
+   if (needed > pool->Free.Size) {
+     return 0;
+   }
+
+   result->Start = ROUND_TO(pool->Free.Start, alignment);
+   pool->Free.Start += needed;
+   result->End = pool->Free.Start;
+
+   pool->Free.Size = pool->Free.End - pool->Free.Start;
+   result->Size = result->End - result->Start;
+   result->Pool = pool;
+   result->Alignment = alignment;
+   return needed;
+}
+
+static unsigned long AllocFromAGP(const DRIDriverContext *ctx, I830Rec *pI830, long size, unsigned long alignment, I830MemRange  *result)
+{
+   unsigned long start, end;
+   unsigned long newApStart, newApEnd;
+   int ret;
+   if (!result || !size)
+      return 0;
+   
+   if (!alignment)
+     alignment = 4;
+
+   start = ROUND_TO(pI830->MemoryAperture.Start, alignment);
+   end = ROUND_TO(start + size, alignment);
+   newApStart = end;
+   newApEnd = pI830->MemoryAperture.End;
+
+   ret=drmAgpAlloc(ctx->drmFD, size, 0, &(result->Physical), (drm_handle_t *)&(result->Key));
+   
+   if (ret)
+   {
+     fprintf(stderr,"drmAgpAlloc failed %d\n", ret);
+     return 0;
+   }
+   pI830->allocatedMemory += size;
+   pI830->MemoryAperture.Start = newApStart;
+   pI830->MemoryAperture.End = newApEnd;
+   pI830->MemoryAperture.Size = newApEnd - newApStart;
+   //   pI830->FreeMemory -= size;
+   result->Start = start;
+   result->End = start + size;
+   result->Size = size;
+   result->Offset = start;
+   result->Alignment = alignment;
+   result->Pool = NULL;
+  
+   return size;
+}
+
+unsigned long
+I830AllocVidMem(const DRIDriverContext *ctx, I830Rec *pI830,
+                I830MemRange *result, I830MemPool *pool, long size,
+                unsigned long alignment, int flags)
+{
+   unsigned long ret;
+
+   if (!result)
+      return 0;
+
+   /* Make sure these are initialised. */
+   result->Size = 0;
+   result->Key = -1;
+
+   if (!size) {
+      return 0;
+   }
+
+   if (pool->Free.Size < size) {
+      ret = AllocFromAGP(ctx, pI830, size, alignment, result);
+   }
+   else {
+      ret = AllocFromPool(ctx, pI830, result, pool, size, alignment, flags);
+      if (ret == 0)
+         ret = AllocFromAGP(ctx, pI830, size, alignment, result);
+   }
+   return ret;
+}
+
+static Bool BindAgpRange(const DRIDriverContext *ctx, I830MemRange *mem)
+{
+  if (!mem)
+    return FALSE;
+  
+  if (mem->Key == -1)
+    return TRUE;
+
+  return !drmAgpBind(ctx->drmFD, mem->Key, mem->Offset);
+}
+
+/* simple memory allocation routines needed */
+/* put ring buffer in low memory */
+/* need to allocate front, back, depth buffers aligned correctly,
+   allocate ring buffer, 
+*/
+
+/* */
+static Bool
+I830AllocateMemory(const DRIDriverContext *ctx, I830Rec *pI830)
+{
+  unsigned long size, ret;
+  unsigned long lines, lineSize, align;
+
+  /* allocate ring buffer */
+  memset(pI830->LpRing, 0, sizeof(I830RingBuffer));
+  pI830->LpRing->mem.Key = -1;
+
+  size = PRIMARY_RINGBUFFER_SIZE;
+  
+  ret = I830AllocVidMem(ctx, pI830, &pI830->LpRing->mem, &pI830->StolenPool, size, 0x1000, 0);
+  
+  if (ret != size)
+  {
+    fprintf(stderr,"unable to allocate ring buffer %ld\n", ret);
+    return FALSE;
+  }
+
+  pI830->LpRing->tail_mask = pI830->LpRing->mem.Size - 1;
+
+  
+  /* allocate front buffer */
+  memset(&(pI830->FrontBuffer), 0, sizeof(pI830->FrontBuffer));
+  pI830->FrontBuffer.Key = -1;
+  pI830->FrontBuffer.Pitch = ctx->shared.virtualWidth;
+
+  align = KB(512);  
+
+  lineSize = ctx->shared.virtualWidth * ctx->cpp;
+  lines = (ctx->shared.virtualHeight + 15) / 16 * 16;
+  size = lineSize * lines;
+  size = ROUND_TO_PAGE(size);
+
+  align = GetBestTileAlignment(size);
+
+  ret = I830AllocVidMem(ctx, pI830, &pI830->FrontBuffer, &pI830->StolenPool, size, align, 0);
+  if (ret < size)
+  {
+    fprintf(stderr,"unable to allocate front buffer %ld\n", ret);
+    return FALSE;
+  }
+
+  memset(&(pI830->BackBuffer), 0, sizeof(pI830->BackBuffer));
+  pI830->BackBuffer.Key = -1;
+  pI830->BackBuffer.Pitch = ctx->shared.virtualWidth;
+
+  ret = I830AllocVidMem(ctx, pI830, &pI830->BackBuffer, &pI830->StolenPool, size, align, 0);
+  if (ret < size)
+  {
+    fprintf(stderr,"unable to allocate back buffer %ld\n", ret);
+    return FALSE;
+  }
+  
+  memset(&(pI830->DepthBuffer), 0, sizeof(pI830->DepthBuffer));
+  pI830->DepthBuffer.Key = -1;
+  pI830->DepthBuffer.Pitch = ctx->shared.virtualWidth;
+
+  ret = I830AllocVidMem(ctx, pI830, &pI830->DepthBuffer, &pI830->StolenPool, size, align, 0);
+  if (ret < size)
+  {
+    fprintf(stderr,"unable to allocate depth buffer %ld\n", ret);
+    return FALSE;
+  }
+
+  memset(&(pI830->ContextMem), 0, sizeof(pI830->ContextMem));
+  pI830->ContextMem.Key = -1;
+  size = KB(32);
+
+  ret = I830AllocVidMem(ctx, pI830, &pI830->ContextMem, &pI830->StolenPool, size, align, 0);
+  if (ret < size)
+  {
+    fprintf(stderr,"unable to allocate context buffer %ld\n", ret);
+    return FALSE;
+  }
+
+#if 0  
+  memset(&(pI830->TexMem), 0, sizeof(pI830->TexMem));
+  pI830->TexMem.Key = -1;
+
+  size = 32768 * 1024;
+  ret = AllocFromAGP(ctx, pI830, size, align, &pI830->TexMem);
+  if (ret < size)
+  {
+    fprintf(stderr,"unable to allocate texture memory %ld\n", ret);
+    return FALSE;
+  }
+#endif
+
+  return TRUE;
+}
+
+static Bool
+I830BindMemory(const DRIDriverContext *ctx, I830Rec *pI830)
+{
+  if (!BindAgpRange(ctx, &pI830->LpRing->mem))
+    return FALSE;
+  if (!BindAgpRange(ctx, &pI830->FrontBuffer))
+    return FALSE;
+  if (!BindAgpRange(ctx, &pI830->BackBuffer))
+    return FALSE;
+  if (!BindAgpRange(ctx, &pI830->DepthBuffer))
+    return FALSE;
+  if (!BindAgpRange(ctx, &pI830->ContextMem))
+    return FALSE;
+#if 0
+  if (!BindAgpRange(ctx, &pI830->TexMem))
+    return FALSE;
+#endif
+  return TRUE;
+}
+
+static void SetupDRIMM(const DRIDriverContext *ctx, I830Rec *pI830)
+{
+  unsigned long aperEnd = ROUND_DOWN_TO(pI830->aper_size, GTT_PAGE_SIZE) / GTT_PAGE_SIZE;
+  unsigned long aperStart = ROUND_TO(pI830->aper_size - KB(32768), GTT_PAGE_SIZE) / GTT_PAGE_SIZE;
+
+  fprintf(stderr, "aper size is %08X\n", ctx->shared.fbSize);
+  if (drmMMInit(ctx->drmFD, aperStart, aperEnd - aperStart, DRM_BO_MEM_TT)) {
+      fprintf(stderr,
+             "DRM MM Initialization Failed\n");
+  } else {
+    fprintf(stderr,
+           "DRM MM Initialized at offset 0x%lx length %d page\n", aperStart, aperEnd-aperStart);
+  }
+
+}
+
+static Bool
+I830CleanupDma(const DRIDriverContext *ctx)
+{
+   drmI830Init info;
+
+   memset(&info, 0, sizeof(drmI830Init));
+   info.func = I830_CLEANUP_DMA;
+
+   if (drmCommandWrite(ctx->drmFD, DRM_I830_INIT,
+                      &info, sizeof(drmI830Init))) {
+     fprintf(stderr, "I830 Dma Cleanup Failed\n");
+      return FALSE;
+   }
+
+   return TRUE;
+}
+
+static Bool
+I830InitDma(const DRIDriverContext *ctx, I830Rec *pI830)
+{
+   I830RingBuffer *ring = pI830->LpRing;
+   drmI830Init info;
+
+   memset(&info, 0, sizeof(drmI830Init));
+   info.func = I830_INIT_DMA;
+
+   info.ring_start = ring->mem.Start + pI830->LinearAddr;
+   info.ring_end = ring->mem.End + pI830->LinearAddr;
+   info.ring_size = ring->mem.Size;
+
+   info.mmio_offset = (unsigned int)ctx->MMIOStart;
+
+   info.sarea_priv_offset = sizeof(drm_sarea_t);
+
+   info.front_offset = pI830->FrontBuffer.Start;
+   info.back_offset = pI830->BackBuffer.Start;
+   info.depth_offset = pI830->DepthBuffer.Start;
+   info.w = ctx->shared.virtualWidth;
+   info.h = ctx->shared.virtualHeight;
+   info.pitch = ctx->shared.virtualWidth;
+   info.back_pitch = pI830->BackBuffer.Pitch;
+   info.depth_pitch = pI830->DepthBuffer.Pitch;
+   info.cpp = ctx->cpp;
+
+   if (drmCommandWrite(ctx->drmFD, DRM_I830_INIT,
+                      &info, sizeof(drmI830Init))) {
+      fprintf(stderr,
+                "I830 Dma Initialization Failed\n");
+      return FALSE;
+   }
+
+   return TRUE;
+}
+
+static int I830CheckDRMVersion( const DRIDriverContext *ctx,
+                                 I830Rec *pI830 )
+{
+   drmVersionPtr  version;
+
+   version = drmGetVersion(ctx->drmFD);
+
+   if (version) {
+     int req_minor, req_patch;
+
+     req_minor = 4;
+     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] I830DRIScreenInit failed because of a version "
+              "mismatch.\n"
+              "[dri] i915.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;
+     }
+     
+     pI830->drmMinor = version->version_minor;
+     drmFreeVersion(version);
+   }
+   return 1;
+}
+
+static void
+I830SetRingRegs(const DRIDriverContext *ctx, I830Rec *pI830)
+{
+  unsigned int itemp;
+  unsigned char *MMIO = ctx->MMIOAddress;
+
+   OUTREG(LP_RING + RING_LEN, 0);
+   OUTREG(LP_RING + RING_TAIL, 0);
+   OUTREG(LP_RING + RING_HEAD, 0);
+
+   if ((long)(pI830->LpRing->mem.Start & I830_RING_START_MASK) !=
+       pI830->LpRing->mem.Start) {
+      fprintf(stderr,
+                "I830SetRingRegs: Ring buffer start (%lx) violates its "
+                "mask (%x)\n", pI830->LpRing->mem.Start, I830_RING_START_MASK);
+   }
+   /* Don't care about the old value.  Reserved bits must be zero anyway. */
+   itemp = pI830->LpRing->mem.Start & I830_RING_START_MASK;
+   OUTREG(LP_RING + RING_START, itemp);
+
+   if (((pI830->LpRing->mem.Size - 4096) & I830_RING_NR_PAGES) !=
+       pI830->LpRing->mem.Size - 4096) {
+      fprintf(stderr,
+                "I830SetRingRegs: Ring buffer size - 4096 (%lx) violates its "
+                "mask (%x)\n", pI830->LpRing->mem.Size - 4096,
+                I830_RING_NR_PAGES);
+   }
+   /* Don't care about the old value.  Reserved bits must be zero anyway. */
+   itemp = (pI830->LpRing->mem.Size - 4096) & I830_RING_NR_PAGES;
+   itemp |= (RING_NO_REPORT | RING_VALID);
+   OUTREG(LP_RING + RING_LEN, itemp);
+
+   pI830->LpRing->head = INREG(LP_RING + RING_HEAD) & I830_HEAD_MASK;
+   pI830->LpRing->tail = INREG(LP_RING + RING_TAIL);
+   pI830->LpRing->space = pI830->LpRing->head - (pI830->LpRing->tail + 8);
+   if (pI830->LpRing->space < 0)
+      pI830->LpRing->space += pI830->LpRing->mem.Size;
+
+   SetFenceRegs(ctx, pI830);
+   
+   /* RESET THE DISPLAY PIPE TO POINT TO THE FRONTBUFFER - hacky
+      hacky hacky */
+   OUTREG(DSPABASE, pI830->FrontBuffer.Start + pI830->LinearAddr);
+
+}
+
+static Bool
+I830SetParam(const DRIDriverContext *ctx, int param, int value)
+{
+   drmI830SetParam sp;
+
+   memset(&sp, 0, sizeof(sp));
+   sp.param = param;
+   sp.value = value;
+
+   if (drmCommandWrite(ctx->drmFD, DRM_I830_SETPARAM, &sp, sizeof(sp))) {
+      fprintf(stderr, "I830 SetParam Failed\n");
+      return FALSE;
+   }
+
+   return TRUE;
+}
+
+static Bool
+I830DRIMapScreenRegions(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea)
+{
+   fprintf(stderr,
+              "[drm] Mapping front buffer\n");
+
+   if (drmAddMap(ctx->drmFD,
+                 (drm_handle_t)(sarea->front_offset + pI830->LinearAddr),
+                 sarea->front_size,
+                 DRM_FRAME_BUFFER,  /*DRM_AGP,*/
+                 0,
+                 &sarea->front_handle) < 0) {
+     fprintf(stderr,
+            "[drm] drmAddMap(front_handle) failed. Disabling DRI\n");
+      return FALSE;
+   }
+   ctx->shared.hFrameBuffer = sarea->front_handle;
+   ctx->shared.fbSize = sarea->front_size;
+   fprintf(stderr, "[drm] Front Buffer = 0x%08x\n",
+          sarea->front_handle);
+
+   if (drmAddMap(ctx->drmFD,
+                 (drm_handle_t)(sarea->back_offset),
+                 sarea->back_size, DRM_AGP, 0,
+                 &sarea->back_handle) < 0) {
+      fprintf(stderr,
+                 "[drm] drmAddMap(back_handle) failed. Disabling DRI\n");
+      return FALSE;
+   }
+   fprintf(stderr, "[drm] Back Buffer = 0x%08x\n",
+              sarea->back_handle);
+
+   if (drmAddMap(ctx->drmFD,
+                 (drm_handle_t)sarea->depth_offset,
+                 sarea->depth_size, DRM_AGP, 0,
+                 &sarea->depth_handle) < 0) {
+      fprintf(stderr,
+                 "[drm] drmAddMap(depth_handle) failed. Disabling DRI\n");
+      return FALSE;
+   }
+   fprintf(stderr, "[drm] Depth Buffer = 0x%08x\n",
+              sarea->depth_handle);
+
+#if 0
+   if (drmAddMap(ctx->drmFD,
+                (drm_handle_t)sarea->tex_offset,
+                sarea->tex_size, DRM_AGP, 0,
+                &sarea->tex_handle) < 0) {
+      fprintf(stderr,
+                "[drm] drmAddMap(tex_handle) failed. Disabling DRI\n");
+      return FALSE;
+   }
+   fprintf(stderr, "[drm] textures = 0x%08x\n",
+             sarea->tex_handle);
+#endif
+   return TRUE;
+}
+
+
+static void
+I830DRIUnmapScreenRegions(const DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea)
+{
+#if 1
+   if (sarea->front_handle) {
+      drmRmMap(ctx->drmFD, sarea->front_handle);
+      sarea->front_handle = 0;
+   }
+#endif
+   if (sarea->back_handle) {
+      drmRmMap(ctx->drmFD, sarea->back_handle);
+      sarea->back_handle = 0;
+   }
+   if (sarea->depth_handle) {
+      drmRmMap(ctx->drmFD, sarea->depth_handle);
+      sarea->depth_handle = 0;
+   }
+   if (sarea->tex_handle) {
+      drmRmMap(ctx->drmFD, sarea->tex_handle);
+      sarea->tex_handle = 0;
+   }
+}
+
+static Bool
+I830DRIDoMappings(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea)
+{
+  if (drmAddMap(ctx->drmFD,
+               (drm_handle_t)pI830->LpRing->mem.Start,
+               pI830->LpRing->mem.Size, DRM_AGP, 0,
+               &pI830->ring_map) < 0) {
+    fprintf(stderr,
+           "[drm] drmAddMap(ring_map) failed. Disabling DRI\n");
+    return FALSE;
+  }
+  fprintf(stderr, "[drm] ring buffer = 0x%08x\n",
+         pI830->ring_map);
+
+  if (I830InitDma(ctx, pI830) == FALSE) {
+    return FALSE;
+  }
+  
+   /* init to zero to be safe */
+
+  I830DRIMapScreenRegions(ctx, pI830, sarea);
+  SetupDRIMM(ctx, pI830);
+
+   if (ctx->pciDevice != PCI_CHIP_845_G &&
+       ctx->pciDevice != PCI_CHIP_I830_M) {
+      I830SetParam(ctx, I830_SETPARAM_USE_MI_BATCHBUFFER_START, 1 );
+   }
+
+   /* Okay now initialize the dma engine */
+   {
+      pI830->irq = drmGetInterruptFromBusID(ctx->drmFD,
+                                           ctx->pciBus,
+                                           ctx->pciDevice,
+                                           ctx->pciFunc);
+
+      if (drmCtlInstHandler(ctx->drmFD, pI830->irq)) {
+        fprintf(stderr,
+                   "[drm] failure adding irq handler\n");
+        pI830->irq = 0;
+        return FALSE;
+      }
+      else
+        fprintf(stderr,
+                   "[drm] dma control initialized, using IRQ %d\n",
+                   pI830->irq);
+   }
+
+   fprintf(stderr, "[dri] visual configs initialized\n");
+
+   return TRUE;
+}
+
+static Bool
+I830ClearScreen(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea)
+{
+  /* need to drmMap front and back buffers and zero them */
+  drmAddress map_addr;
+  int ret;
+
+  ret = drmMap(ctx->drmFD,
+              sarea->front_handle,
+              sarea->front_size,
+              &map_addr);
+
+  if (ret)
+  {
+    fprintf(stderr, "Unable to map front buffer\n");
+    return FALSE;
+  }
+
+  drimemsetio((char *)map_addr,
+             0,
+             sarea->front_size);
+  drmUnmap(map_addr, sarea->front_size);
+
+
+  ret = drmMap(ctx->drmFD,
+              sarea->back_handle,
+              sarea->back_size,
+              &map_addr);
+
+  if (ret)
+  {
+    fprintf(stderr, "Unable to map back buffer\n");
+    return FALSE;
+  }
+
+  drimemsetio((char *)map_addr,
+             0,
+             sarea->back_size);
+  drmUnmap(map_addr, sarea->back_size);
+
+  return TRUE;
+}
+
+static Bool
+I830ScreenInit(DRIDriverContext *ctx, I830Rec *pI830)
+                 
+{
+   I830DRIPtr pI830DRI;
+   drmI830Sarea *pSAREAPriv;
+   int err;
+      
+   drm_page_size = getpagesize();   
+
+   pI830->registerSize = ctx->MMIOSize;
+   /* This is a hack for now.  We have to have more than a 4k page here
+    * because of the size of the state.  However, the state should be
+    * in a per-context mapping.  This will be added in the Mesa 3.5 port
+    * of the I830 driver.
+    */
+   ctx->shared.SAREASize = SAREA_MAX;
+
+   /* Note that drmOpen will try to load the kernel module, if needed. */
+   ctx->drmFD = drmOpen("i915", 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%08x\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%08x 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, 
+                &pI830->registerHandle) < 0) {
+      fprintf(stderr, "[drm] drmAddMap mmio failed\n");        
+      return 0;
+   }
+   fprintf(stderr,
+          "[drm] register handle = 0x%08x\n", pI830->registerHandle);
+
+
+   if (!I830CheckDRMVersion(ctx, pI830)) {
+     return 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 SAREA private data structure */
+   pSAREAPriv = (drmI830Sarea *)(((char*)ctx->pSAREA) + 
+                                sizeof(drm_sarea_t));
+   memset(pSAREAPriv, 0, sizeof(*pSAREAPriv));
+
+   pI830->StolenMemory.Size = I830DetectMemory(ctx, pI830);
+   pI830->StolenMemory.Start = 0;
+   pI830->StolenMemory.End = pI830->StolenMemory.Size;
+
+   pI830->MemoryAperture.Start = pI830->StolenMemory.End;
+   pI830->MemoryAperture.End = KB(40000);
+   pI830->MemoryAperture.Size = pI830->MemoryAperture.End - pI830->MemoryAperture.Start;
+
+   pI830->StolenPool.Fixed = pI830->StolenMemory;
+   pI830->StolenPool.Total = pI830->StolenMemory;
+   pI830->StolenPool.Free = pI830->StolenPool.Total;
+   pI830->FreeMemory = pI830->StolenPool.Total.Size;
+
+   if (!AgpInit(ctx, pI830))
+     return FALSE;
+
+   if (I830AllocateMemory(ctx, pI830) == FALSE)
+   {
+     return FALSE;
+   }
+
+   if (I830BindMemory(ctx, pI830) == FALSE)
+   {
+     return FALSE;
+   }
+
+   pSAREAPriv->rotated_offset = -1;
+   pSAREAPriv->rotated_size = 0;
+   pSAREAPriv->rotated_pitch = ctx->shared.virtualWidth;
+
+   pSAREAPriv->front_offset = pI830->FrontBuffer.Start;
+   pSAREAPriv->front_size = pI830->FrontBuffer.Size;
+   pSAREAPriv->width = ctx->shared.virtualWidth;
+   pSAREAPriv->height = ctx->shared.virtualHeight;
+   pSAREAPriv->pitch = ctx->shared.virtualWidth;
+   pSAREAPriv->virtualX = ctx->shared.virtualWidth;
+   pSAREAPriv->virtualY = ctx->shared.virtualHeight;
+   pSAREAPriv->back_offset = pI830->BackBuffer.Start;
+   pSAREAPriv->back_size = pI830->BackBuffer.Size;
+   pSAREAPriv->depth_offset = pI830->DepthBuffer.Start;
+   pSAREAPriv->depth_size = pI830->DepthBuffer.Size;
+#if 0
+   pSAREAPriv->tex_offset = pI830->TexMem.Start;
+   pSAREAPriv->tex_size = pI830->TexMem.Size;
+#endif
+   pSAREAPriv->log_tex_granularity = pI830->TexGranularity;
+
+   ctx->driverClientMsg = malloc(sizeof(I830DRIRec));
+   ctx->driverClientMsgSize = sizeof(I830DRIRec);
+   pI830DRI = (I830DRIPtr)ctx->driverClientMsg;
+   pI830DRI->deviceID = pI830->Chipset;
+   pI830DRI->regsSize = I830_REG_SIZE;
+   pI830DRI->width = ctx->shared.virtualWidth;
+   pI830DRI->height = ctx->shared.virtualHeight;
+   pI830DRI->mem = ctx->shared.fbSize;
+   pI830DRI->cpp = ctx->cpp;
+
+   pI830DRI->bitsPerPixel = ctx->bpp;
+   pI830DRI->sarea_priv_offset = sizeof(drm_sarea_t);
+   
+   err = I830DRIDoMappings(ctx, pI830, pSAREAPriv);
+   if (err == FALSE)
+       return FALSE;
+
+   I830SetupMemoryTiling(ctx, pI830);
+
+   /* 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.
+    */
+   I830ClearScreen(ctx, pI830, pSAREAPriv);
+
+   I830SetRingRegs(ctx, pI830);
+
+   return TRUE;
+}
+
+
+/**
+ * \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 i830ValidateMode( 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 i810ValidateMode().
+ */
+static int i830PostValidateMode( const DRIDriverContext *ctx )
+{
+  I830Rec *pI830 = ctx->driverPrivate;
+
+  I830SetRingRegs(ctx, pI830);
+  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 i830InitFBDev( DRIDriverContext *ctx )
+{
+  I830Rec *pI830 = calloc(1, sizeof(I830Rec));
+  int i;
+
+   {
+      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->shared.Width = ctx->shared.virtualWidth;
+   }
+
+
+   for (i = 0; pitches[i] != 0; i++) {
+     if (pitches[i] >= ctx->shared.virtualWidth) {
+       ctx->shared.virtualWidth = pitches[i];
+       break;
+     }
+   }
+
+   ctx->driverPrivate = (void *)pI830;
+   
+   pI830->LpRing = calloc(1, sizeof(I830RingBuffer));
+   pI830->Chipset = ctx->chipset;
+   pI830->LinearAddr = ctx->FBStart;
+
+   if (!I830ScreenInit( ctx, pI830 ))
+      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 i830HaltFBDev( DRIDriverContext *ctx )
+{
+  drmI830Sarea *pSAREAPriv;
+  I830Rec *pI830 = ctx->driverPrivate;
+
+   if (pI830->irq) {
+       drmCtlUninstHandler(ctx->drmFD);
+       pI830->irq = 0;   }
+
+   I830CleanupDma(ctx);
+
+  pSAREAPriv = (drmI830Sarea *)(((char*)ctx->pSAREA) + 
+                               sizeof(drm_sarea_t));
+
+  I830DRIUnmapScreenRegions(ctx, pI830, pSAREAPriv);
+  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 = {
+   i830ValidateMode,
+   i830PostValidateMode,
+   i830InitFBDev,
+   i830HaltFBDev,
+   NULL,//I830EngineShutdown,
+   NULL, //I830EngineRestore,  
+#ifndef _EMBEDDED
+   0,
+#else
+   i810NotifyFocus, 
+#endif
+};
index 7f558e92bc6405228617a03969be773da3babbc4..29fd654c3fbd0488fef7f01e7893b6be5d8cc7c6 100644 (file)
@@ -253,9 +253,6 @@ GLboolean mach64CreateContext( const __GLcontextModes *glVisual,
 
    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")) {
@@ -330,10 +327,15 @@ mach64MakeCurrent( __DRIcontextPrivate *driContextPriv,
       }
 
       
-      driDrawableInitVBlank( driDrawPriv, newMach64Ctx->vblank_flags,
-                            &newMach64Ctx->vbl_seq );
-
       if ( newMach64Ctx->driDrawable != driDrawPriv ) {
+        if (driDrawPriv->swap_interval == (unsigned)-1) {
+           driDrawPriv->vblFlags = (newMach64Ctx->do_irqs)
+              ? driGetDefaultVBlankFlags(&newMach64Ctx->optionCache)
+              : VBLANK_FLAG_NO_IRQ;
+
+           driDrawableInitVBlank( driDrawPriv );
+        }
+
         newMach64Ctx->driDrawable = driDrawPriv;
         mach64CalcViewport( newMach64Ctx->glCtx );
       }
index e925f18c11473273867aa9a71a66630a4ae60236..fa6e2bbd3f9094ce6a66541ede6ef5e9bdc5c512 100644 (file)
@@ -263,8 +263,6 @@ struct mach64_context {
 
    /* VBI
     */
-   GLuint vbl_seq;
-   GLuint vblank_flags;
    GLuint do_irqs;
 
    /* Configuration cache
index 6bc2b58ce940bdc388afaaa0f57879c145b86fe3..0a2df32c076595d550f77ec58e09889375b7dbff 100644 (file)
@@ -279,7 +279,7 @@ static int mach64WaitForFrameCompletion( mach64ContextPtr mmesa )
 
 /* Copy the back color buffer to the front color buffer.
  */
-void mach64CopyBuffer( const __DRIdrawablePrivate *dPriv )
+void mach64CopyBuffer( __DRIdrawablePrivate *dPriv )
 {
    mach64ContextPtr mmesa;
    GLint nbox, i, ret;
@@ -320,7 +320,7 @@ void mach64CopyBuffer( const __DRIdrawablePrivate *dPriv )
 #endif
 
    UNLOCK_HARDWARE( mmesa );
-   driWaitForVBlank( dPriv, &mmesa->vbl_seq, mmesa->vblank_flags, &missed_target );
+   driWaitForVBlank( dPriv, &missed_target );
    LOCK_HARDWARE( mmesa );
 
    /* use front buffer cliprects */
index 2153ab80d785ecc82c7fcf98fefe9c8d8f3453b1..6ef9bc0bcaf2b6b9e2575050f85c05f30a1713cd 100644 (file)
@@ -44,7 +44,7 @@ extern void mach64FlushVerticesLocked( mach64ContextPtr mmesa );
 extern void mach64FlushDMALocked( mach64ContextPtr mmesa );
 extern void mach64UploadHwStateLocked( mach64ContextPtr mmesa );
 
-static __inline void *mach64AllocDmaLow( mach64ContextPtr mmesa, int bytes )
+static INLINE void *mach64AllocDmaLow( mach64ContextPtr mmesa, int bytes )
 {
    CARD32 *head;
 
@@ -60,7 +60,7 @@ static __inline void *mach64AllocDmaLow( mach64ContextPtr mmesa, int bytes )
    return head;
 }
 
-static __inline void *mach64AllocDmaLocked( mach64ContextPtr mmesa, int bytes )
+static INLINE void *mach64AllocDmaLocked( mach64ContextPtr mmesa, int bytes )
 {
    CARD32 *head;
 
@@ -78,7 +78,7 @@ extern void mach64FireBlitLocked( mach64ContextPtr mmesa, void *buffer,
                                  GLint offset, GLint pitch, GLint format,
                                  GLint x, GLint y, GLint width, GLint height );
 
-extern void mach64CopyBuffer( const __DRIdrawablePrivate *dPriv );
+extern void mach64CopyBuffer( __DRIdrawablePrivate *dPriv );
 #if ENABLE_PERF_BOXES
 extern void mach64PerformanceCounters( mach64ContextPtr mmesa );
 extern void mach64PerformanceBoxesLocked( mach64ContextPtr mmesa );
index ea605fb0614c68b61a2c6eabc67ce1573644f240..d018ba417487c0cfc06abb31259b56a05bfc65d9 100644 (file)
@@ -70,7 +70,7 @@ void mach64GetLock( mach64ContextPtr mmesa, GLuint flags )
 
    if ( mmesa->lastStamp != dPriv->lastStamp ) {
       mmesa->lastStamp = dPriv->lastStamp;
-      if (mmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT)
+      if (mmesa->glCtx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_BACK_LEFT)
          mach64SetCliprects( mmesa->glCtx, GL_BACK_LEFT );
       else
          mach64SetCliprects( mmesa->glCtx, GL_FRONT_LEFT );
index 300a3deaaf94415cd3a2d191143fc96af8481a59..4dfffef1454c395b18a4068b9ee2ccf17684bbab 100644 (file)
@@ -69,79 +69,15 @@ static const GLuint __driNConfigOptions = 2;
 
 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 __DRIconfig **
+mach64FillInModes( __DRIscreenPrivate *psp,
+                  unsigned pixel_bits, unsigned depth_bits,
+                  unsigned stencil_bits, GLboolean have_back_buffer )
 {
-       static const uint8_t bits[2][4] = {
-       {          5,          6,          5,          0 },
-       {          8,          8,          8,          0 }
-    };
-
-    static const uint32_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;
+    __DRIconfig **configs;
     __GLcontextModes * m;
-    unsigned num_modes;
+    GLenum fb_format;
+    GLenum fb_type;
     unsigned depth_buffer_factor;
     unsigned back_buffer_factor;
     unsigned i;
@@ -155,49 +91,51 @@ mach64FillInModes( unsigned pixel_bits, unsigned depth_bits,
        GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */
     };
 
-    int depth_buffer_modes[2][2];
-
+    u_int8_t depth_bits_array[2];
+    u_int8_t stencil_bits_array[2];
 
-    depth_buffer_modes[0][0] = depth_bits;
-    depth_buffer_modes[1][0] = depth_bits;
+    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.
      */
-    depth_buffer_modes[0][1] = 0;
-    depth_buffer_modes[1][1] = (stencil_bits == 0) ? 8 : stencil_bits;
+    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;
-
-    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 );
+    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;
     }
 
-    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 );
+    configs = driCreateConfigs(fb_format, fb_type,
+                              depth_bits_array, stencil_bits_array,
+                              depth_buffer_factor, back_buffer_modes,
+                              back_buffer_factor);
+    if (configs == NULL) {
+       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;
-       }
+    for (i = 0; configs[i]; i++) {
+       m = &configs[i]->modes;
+       if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
+         m->visualRating = GLX_SLOW_CONFIG;
+       }
     }
 
-    return modes;
+    return (const __DRIconfig **) configs;
 }
 
 
@@ -208,9 +146,7 @@ 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;
+   int i;
 
    if (sPriv->devPrivSize != sizeof(ATIDRIRec)) {
       fprintf(stderr,"\nERROR!  sizeof(ATIDRIRec) does not match passed size from device driver\n");
@@ -319,15 +255,14 @@ mach64CreateScreen( __DRIscreenPrivate *sPriv )
 
    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" );
+   i = 0;
+   mach64Screen->extensions[i++] = &driFrameTrackingExtension.base;
+   if ( mach64Screen->irq != 0 ) {
+      mach64Screen->extensions[i++] = &driSwapControlExtension.base;
+      mach64Screen->extensions[i++] = &driMediaStreamCounterExtension.base;
    }
+   mach64Screen->extensions[i++] = NULL;
+   sPriv->extensions = mach64Screen->extensions;
 
    return mach64Screen;
 }
@@ -475,9 +410,48 @@ mach64InitDriver( __DRIscreenPrivate *driScreen )
    return GL_TRUE;
 }
 
+/**
+ * This is the driver specific part of the createNewScreen entry point.
+ * 
+ * \todo maybe fold this into intelInitDriver
+ *
+ * \return the __GLcontextModes supported by this driver
+ */
+static const __DRIconfig **
+mach64InitScreen(__DRIscreenPrivate *psp)
+{
+   static const __DRIversion ddx_expected = { 6, 4, 0 };
+   static const __DRIversion dri_expected = { 4, 0, 0 };
+   static const __DRIversion drm_expected = { 2, 0, 0 };
+   ATIDRIPtr dri_priv = (ATIDRIPtr) psp->pDevPriv;
 
-static struct __DriverAPIRec mach64API = {
-   .InitDriver      = mach64InitDriver,
+   if ( ! driCheckDriDdxDrmVersions2( "Mach64",
+                                     &psp->dri_version, & dri_expected,
+                                     &psp->ddx_version, & ddx_expected,
+                                     &psp->drm_version, & drm_expected ) ) {
+      return NULL;
+   }
+   
+   /* 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 );
+
+   if (!mach64InitDriver(psp))
+      return NULL;
+
+   return  mach64FillInModes( psp, dri_priv->cpp * 8, 16, 0, 1);
+}
+
+const struct __DriverAPIRec driDriverAPI = {
+   .InitScreen      = mach64InitScreen,
    .DestroyScreen   = mach64DestroyScreen,
    .CreateContext   = mach64CreateContext,
    .DestroyContext  = mach64DestroyContext,
@@ -487,71 +461,9 @@ static struct __DriverAPIRec mach64API = {
    .MakeCurrent     = mach64MakeCurrent,
    .UnbindContext   = mach64UnbindContext,
    .GetSwapInfo     = NULL,
-   .GetMSC          = driGetMSC32,
+   .GetDrawableMSC  = driDrawableGetMSC32,
    .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 = { 2, 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;
-}
index 7bf7dc474d12f84f56ec92fddc1fb352d1fe17f7..be5e29a3e58ed6e43cf2da13b936fe4cd946396f 100644 (file)
@@ -73,6 +73,8 @@ typedef struct {
    __DRIscreenPrivate *driScreen;
 
    driOptionCache optionCache;
+
+   const __DRIextension *extensions[4];
 } mach64ScreenRec, *mach64ScreenPtr;
 
 #endif /* __MACH64_SCREEN_H__ */
index 5c2403f587f64ba5894eab033d5edbcf26853300..91d46ce32eb4f76c54170e54b27b4bdd56b8f91c 100644 (file)
 
 /* 16 bit depthbuffer functions.
  */
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d )                                       \
    *(GLushort *)(buf + ((_x) + (_y) * drb->pitch) * 2) = d;
 
index 9ac51ee5b1d0bb13ace6c189bc51f0be748fe03b..d32d7ed9f6a7bfc00ba71a4c4df372ebe23f1610 100644 (file)
@@ -726,24 +726,26 @@ static void mach64DDDrawBuffer( GLcontext *ctx, GLenum mode )
 
    FLUSH_BATCH( mmesa );
 
-   /*
-    * _DrawDestMask is easier to cope with than <mode>.
-    */
-   switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
-   case BUFFER_BIT_FRONT_LEFT:
+   if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) {
+      /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
+      FALLBACK( mmesa, MACH64_FALLBACK_DRAW_BUFFER, GL_TRUE );
+      return;
+   }
+
+   switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) {
+   case BUFFER_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:
+   case BUFFER_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);
index e67661b9706fc788a15b5255c3c61c111bbb99e8..8e0b23ed15bd8c8ad032b88d6b9cad55772170c7 100644 (file)
@@ -72,9 +72,9 @@ extern void mach64InitTextureFuncs( struct dd_function_table *functions );
 #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 )
+static INLINE GLuint mach64PackColor( GLuint cpp,
+                                      GLubyte r, GLubyte g,
+                                      GLubyte b, GLubyte a )
 {
    switch ( cpp ) {
    case 2:
index e4df01106d35981f3a4e358282695ab9a88facc5..6fb4c5bd65e2186f9d6211245a2581df981211ee 100644 (file)
@@ -113,7 +113,7 @@ do {                                                                        \
 #define COPY_VERTEX_OOA( vb, vertsize, v, n )  DO_COPY_VERTEX( vb, vertsize, v, n, 1 )
 
 
-static __inline void mach64_draw_quad( mach64ContextPtr mmesa,
+static INLINE void mach64_draw_quad( mach64ContextPtr mmesa,
                                       mach64VertexPtr v0,
                                       mach64VertexPtr v1,
                                       mach64VertexPtr v2,
@@ -419,7 +419,7 @@ static __inline void mach64_draw_quad( mach64ContextPtr mmesa,
 #endif
 }
 
-static __inline void mach64_draw_triangle( mach64ContextPtr mmesa,
+static INLINE void mach64_draw_triangle( mach64ContextPtr mmesa,
                                           mach64VertexPtr v0,
                                           mach64VertexPtr v1,
                                           mach64VertexPtr v2 )
@@ -666,7 +666,7 @@ static __inline void mach64_draw_triangle( mach64ContextPtr mmesa,
 #endif
 }
 
-static __inline void mach64_draw_line( mach64ContextPtr mmesa,
+static INLINE void mach64_draw_line( mach64ContextPtr mmesa,
                                     mach64VertexPtr v0,
                                     mach64VertexPtr v1 )
 {
@@ -955,7 +955,7 @@ static __inline void mach64_draw_line( mach64ContextPtr mmesa,
 #endif
 }
 
-static __inline void mach64_draw_point( mach64ContextPtr mmesa,
+static INLINE void mach64_draw_point( mach64ContextPtr mmesa,
                                      mach64VertexPtr v0 )
 {
 #if MACH64_NATIVE_VTXFMT
index d0cf06fea5a3e2aa774a239f79ec5792f3db98dc..e7a1b3b01e86315105c9c57481ee25888d598220 100644 (file)
 #define need_GL_ARB_vertex_buffer_object
 #define need_GL_ARB_vertex_program
 #define need_GL_EXT_fog_coord
+#define need_GL_EXT_gpu_program_parameters
 #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_APPLE_vertex_array_object
 #define need_GL_NV_vertex_program
 #include "extension_helper.h"
 
@@ -109,19 +111,18 @@ static const GLuint __driNConfigOptions = 6;
 int MGA_DEBUG = 0;
 #endif
 
-static int getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo );
-
-static __GLcontextModes *
-mgaFillInModes( unsigned pixel_bits, unsigned depth_bits,
+static const __DRIconfig **
+mgaFillInModes( __DRIscreenPrivate *psp,
+               unsigned pixel_bits, unsigned depth_bits,
                unsigned stencil_bits, GLboolean have_back_buffer )
 {
-    __GLcontextModes * modes;
+    __DRIconfig **configs;
     __GLcontextModes * m;
-    unsigned num_modes;
     unsigned depth_buffer_factor;
     unsigned back_buffer_factor;
     GLenum fb_format;
     GLenum fb_type;
+    int i;
 
     /* GLX_SWAP_COPY_OML is only supported because the MGA driver doesn't
      * support pageflipping at all.
@@ -149,8 +150,6 @@ mgaFillInModes( unsigned pixel_bits, unsigned depth_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;
@@ -160,46 +159,41 @@ mgaFillInModes( unsigned pixel_bits, unsigned depth_bits,
         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 ) ) {
+    configs = driCreateConfigs(fb_format, fb_type,
+                              depth_bits_array, stencil_bits_array,
+                              depth_buffer_factor,
+                              back_buffer_modes, back_buffer_factor);
+    if (configs == NULL) {
        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;
-       }
-    }
+   /* Mark the visual as slow if there are "fake" stencil bits.
+    */
+   for (i = 0; configs[i]; i++) {
+      m = &configs[i]->modes;
+      if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
+         m->visualRating = GLX_SLOW_CONFIG;
+      }
+   }
 
-    return modes;
+   return (const __DRIconfig **) configs;
 }
 
+const __DRIextension *mgaScreenExtensions[] = {
+    &driReadDrawableExtension,
+    &driSwapControlExtension.base,
+    &driFrameTrackingExtension.base,
+    &driMediaStreamCounterExtension.base,
+    NULL
+};
 
 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");
@@ -216,7 +210,7 @@ mgaInitDriver(__DRIscreenPrivate *sPriv)
    mgaScreen->sPriv = sPriv;
    sPriv->private = (void *)mgaScreen;
 
-   if (sPriv->drmMinor >= 1) {
+   if (sPriv->drm_version.minor >= 1) {
       int ret;
       drm_mga_getparam_t gp;
 
@@ -234,13 +228,7 @@ mgaInitDriver(__DRIscreenPrivate *sPriv)
       }
    }
 
-   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" );
-   }
+   sPriv->extensions = mgaScreenExtensions;
 
    if (serverInfo->chipset != MGA_CARD_TYPE_G200 &&
        serverInfo->chipset != MGA_CARD_TYPE_G400) {
@@ -273,7 +261,7 @@ mgaInitDriver(__DRIscreenPrivate *sPriv)
     * there is a new, in-kernel mechanism for handling the wait.
     */
 
-   if (mgaScreen->sPriv->drmMinor < 2) {
+   if (mgaScreen->sPriv->drm_version.minor < 2) {
       mgaScreen->mmio.handle = serverInfo->registers.handle;
       mgaScreen->mmio.size = serverInfo->registers.size;
       if ( drmMap( sPriv->fd,
@@ -411,13 +399,15 @@ static const struct dri_extension card_extensions[] =
 #endif
    { "GL_EXT_secondary_color",        GL_EXT_secondary_color_functions },
    { "GL_EXT_stencil_wrap",           NULL },
+   { "GL_APPLE_vertex_array_object",  GL_APPLE_vertex_array_object_functions },
    { "GL_MESA_ycbcr_texture",         NULL },
    { "GL_SGIS_generate_mipmap",       NULL },
    { NULL,                            NULL }
 };
 
-static const struct dri_extension ARB_vp_extension[] = {
+static const struct dri_extension ARB_vp_extensions[] = {
    { "GL_ARB_vertex_program",         GL_ARB_vertex_program_functions },
+   { "GL_EXT_gpu_program_parameters", GL_EXT_gpu_program_parameters_functions },
    { NULL,                            NULL }
 };
 
@@ -622,7 +612,7 @@ mgaCreateContext( const __GLcontextModes *mesaVis,
    }
 
    if ( driQueryOptionb( &mmesa->optionCache, "arb_vertex_program" ) ) {
-      driInitSingleExtension( ctx, ARB_vp_extension );
+      driInitExtensions(ctx, ARB_vp_extensions, GL_FALSE);
    }
    
    if ( driQueryOptionb( &mmesa->optionCache, "nv_vertex_program" ) ) {
@@ -646,10 +636,7 @@ mgaCreateContext( const __GLcontextModes *mesaVis,
                                    debug_control );
 #endif
 
-   mmesa->vblank_flags = (mmesa->mgaScreen->irq == 0)
-       ? VBLANK_FLAG_NO_IRQ : driGetDefaultVBlankFlags(&mmesa->optionCache);
-
-   (*dri_interface->getUST)( & mmesa->swap_ust );
+   (*sPriv->systemTime->getUST)( & mmesa->swap_ust );
 
    if (driQueryOptionb(&mmesa->optionCache, "no_rast")) {
       fprintf(stderr, "disabling 3D acceleration\n");
@@ -878,8 +865,14 @@ mgaMakeCurrent(__DRIcontextPrivate *driContextPriv,
       mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate;
 
       if (mmesa->driDrawable != driDrawPriv) {
-        driDrawableInitVBlank( driDrawPriv, mmesa->vblank_flags,
-                               &mmesa->vbl_seq );
+        if (driDrawPriv->swap_interval == (unsigned)-1) {
+           driDrawPriv->vblFlags = (mmesa->mgaScreen->irq == 0)
+              ? VBLANK_FLAG_NO_IRQ
+              : driGetDefaultVBlankFlags(&mmesa->optionCache);
+
+           driDrawableInitVBlank( driDrawPriv );
+        }
+
         mmesa->driDrawable = driDrawPriv;
         mmesa->dirty = ~0; 
         mmesa->dirty_cliprects = (MGA_FRONT|MGA_BACK); 
@@ -933,88 +926,51 @@ void mgaGetLock( mgaContextPtr mmesa, GLuint flags )
 }
 
 
-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.
+ * This is the driver specific part of the createNewScreen entry point.
  * 
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on 
- *         failure.
+ * \todo maybe fold this into intelInitDriver
+ *
+ * \return the __GLcontextModes supported by this driver
  */
-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 )
-                            
+static const __DRIconfig **mgaInitScreen(__DRIscreen *psp)
 {
-   __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;
+   MGADRIPtr dri_priv = (MGADRIPtr) psp->pDevPriv;
 
    if ( ! driCheckDriDdxDrmVersions2( "MGA",
-                                     dri_version, & dri_expected,
-                                     ddx_version, & ddx_expected,
-                                     drm_version, & drm_expected ) ) {
+                                     &psp->dri_version, & dri_expected,
+                                     &psp->ddx_version, & ddx_expected,
+                                     &psp->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 );
 
-   }
+   /* 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?
+    */
 
-   return (void *) psp;
+   driInitExtensions( NULL, card_extensions, GL_FALSE );
+   driInitExtensions( NULL, g400_extensions, GL_FALSE );
+   driInitExtensions(NULL, ARB_vp_extensions, GL_FALSE);
+   driInitExtensions( NULL, NV_vp_extensions, GL_FALSE );
+
+   if (!mgaInitDriver(psp))
+       return NULL;
+
+   return mgaFillInModes( psp,
+                         dri_priv->cpp * 8,
+                         (dri_priv->cpp == 2) ? 16 : 24,
+                         (dri_priv->cpp == 2) ? 0  : 8,
+                         (dri_priv->backOffset != dri_priv->depthOffset) );
 }
 
 
@@ -1043,3 +999,20 @@ getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo )
 
    return 0;
 }
+
+const struct __DriverAPIRec driDriverAPI = {
+   .InitScreen      = mgaInitScreen,
+   .DestroyScreen   = mgaDestroyScreen,
+   .CreateContext   = mgaCreateContext,
+   .DestroyContext  = mgaDestroyContext,
+   .CreateBuffer    = mgaCreateBuffer,
+   .DestroyBuffer   = mgaDestroyBuffer,
+   .SwapBuffers     = mgaSwapBuffers,
+   .MakeCurrent     = mgaMakeCurrent,
+   .UnbindContext   = mgaUnbindContext,
+   .GetSwapInfo     = getSwapInfo,
+   .GetDrawableMSC  = driDrawableGetMSC32,
+   .WaitForMSC      = driWaitForMSC32,
+   .WaitForSBC      = NULL,
+   .SwapBuffersMSC  = NULL
+};
index 6aa92355b8a0a2bdb5570986f666031ef7327186..68bba94fd37356f92adae8544f44a5037ef6992a 100644 (file)
@@ -257,11 +257,6 @@ struct mga_context_t {
    drmBufPtr  vertex_dma_buffer;
    drmBufPtr  iload_buffer;
 
-   /* VBI
-    */
-   GLuint vbl_seq;
-   GLuint vblank_flags;
-
    int64_t swap_ust;
    int64_t swap_missed_ust;
 
@@ -333,9 +328,9 @@ extern int MGA_DEBUG;
 #define DEBUG_VERBOSE_TEXTURE   0x08
 #define DEBUG_VERBOSE_FALLBACK 0x10
 
-static __inline__ GLuint mgaPackColor(GLuint cpp,
-                                     GLubyte r, GLubyte g,
-                                     GLubyte b, GLubyte a)
+static INLINE GLuint mgaPackColor(GLuint cpp,
+                                  GLubyte r, GLubyte g,
+                                  GLubyte b, GLubyte a)
 {
    switch (cpp) {
    case 2:
index 04336b5ac7578006c1e7f4470d9b7fe1bd6c9c8e..ac7bf9f877803da72a95cb6f703b7ac5416637cd 100644 (file)
@@ -40,7 +40,7 @@
 #include "mga_xmesa.h"
 #include "utils.h"
 
-#define DRIVER_DATE    "20061030"
+#define DRIVER_DATE    "20071017"
 
 
 /***************************************
index f8587fc541ee8f50b3a930c416f1522b4c6bba44..dee93995566a1361b1fc0bb593b21684812f814c 100644 (file)
@@ -55,7 +55,7 @@ mgaSetFence( mgaContextPtr mmesa, uint32_t * fence )
 {
     int ret = ENOSYS;
 
-    if ( mmesa->driScreen->drmMinor >= 2 ) {
+    if ( mmesa->driScreen->drm_version.minor >= 2 ) {
        ret = drmCommandWriteRead( mmesa->driScreen->fd, DRM_MGA_SET_FENCE,
                                   fence, sizeof( uint32_t ));
        if (ret) {
@@ -73,7 +73,7 @@ mgaWaitFence( mgaContextPtr mmesa, uint32_t fence, uint32_t * curr_fence )
 {
     int ret = ENOSYS;
 
-    if ( mmesa->driScreen->drmMinor >= 2 ) {
+    if ( mmesa->driScreen->drm_version.minor >= 2 ) {
        uint32_t temp = fence;
        
        ret = drmCommandWriteRead( mmesa->driScreen->fd,
@@ -409,7 +409,7 @@ static void mgaWaitForFrameCompletion( mgaContextPtr mmesa )
 /*
  * Copy the back buffer to the front buffer.
  */
-void mgaCopyBuffer( const __DRIdrawablePrivate *dPriv )
+void mgaCopyBuffer( __DRIdrawablePrivate *dPriv )
 {
    mgaContextPtr mmesa;
    drm_clip_rect_t *pbox;
@@ -417,7 +417,7 @@ void mgaCopyBuffer( const __DRIdrawablePrivate *dPriv )
    GLint ret;
    GLint i;
    GLboolean   missed_target;
-
+   __DRIscreenPrivate *psp = dPriv->driScreenPriv;
 
    assert(dPriv);
    assert(dPriv->driContextPriv);
@@ -428,11 +428,10 @@ void mgaCopyBuffer( const __DRIdrawablePrivate *dPriv )
    FLUSH_BATCH( mmesa );
 
    mgaWaitForFrameCompletion( mmesa );
-   driWaitForVBlank( dPriv, & mmesa->vbl_seq, mmesa->vblank_flags,
-                    & missed_target );
+   driWaitForVBlank( dPriv, & missed_target );
    if ( missed_target ) {
       mmesa->swap_missed_count++;
-      (void) (*dri_interface->getUST)( & mmesa->swap_missed_ust );
+      (void) (*psp->systemTime->getUST)( & mmesa->swap_missed_ust );
    }
    LOCK_HARDWARE( mmesa );
 
@@ -470,7 +469,7 @@ void mgaCopyBuffer( const __DRIdrawablePrivate *dPriv )
 
    mmesa->dirty |= MGA_UPLOAD_CLIPRECTS;
    mmesa->swap_count++;
-   (void) (*dri_interface->getUST)( & mmesa->swap_ust );
+   (void) (*psp->systemTime->getUST)( & mmesa->swap_ust );
 }
 
 
index 9aa08c51585b63fa9bee8c23511e2dcbd2a89bd6..dbc823de80203e325f134bb6c83ac017d05066d1 100644 (file)
@@ -32,7 +32,7 @@
 #include "mgacontext.h"
 #include "mga_xmesa.h"
 
-void mgaCopyBuffer( const __DRIdrawablePrivate *dPriv );
+void mgaCopyBuffer( __DRIdrawablePrivate *dPriv );
 void mgaWaitForVBlank( mgaContextPtr mmesa );
 
 void mgaGetILoadBufferLocked( mgaContextPtr mmesa );
@@ -61,7 +61,7 @@ void mgaInitIoctlFuncs( struct dd_function_table *functions );
 
 extern drmBufPtr mga_get_buffer_ioctl( mgaContextPtr mmesa );
 
-static __inline
+static INLINE
 GLuint *mgaAllocDmaLow( mgaContextPtr mmesa, int bytes )
 {
    GLuint *head;
index c9e42a8040d134eec6f774433f99df40290b3041..51cddf16ed5562c7fce04c17b05b77853211b2eb 100644 (file)
@@ -143,7 +143,7 @@ static GLboolean mga_run_render( GLcontext *ctx,
 
    for (i = 0 ; i < VB->PrimitiveCount ; i++)
    {
-      GLuint prim = VB->Primitive[i].mode;
+      GLuint prim = _tnl_translate_prim(&VB->Primitive[i]);
       GLuint start = VB->Primitive[i].start;
       GLuint length = VB->Primitive[i].count;
 
index 05dcbb852639efbcbc94043d7fad8cc915dd2932..7ac59661acdc4334dd4a9dd3e446c21f23a97ebf 100644 (file)
 
 /* 16 bit depthbuffer functions.
  */
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d )       \
    *(GLushort *)(buf + (_x)*2 + (_y)*pitch) = d;
 
 
 /* 32 bit depthbuffer functions.
  */
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d )       \
    *(GLuint *)(buf + (_x)*4 + (_y)*pitch) = d;
 
 
 /* 24/8 bit interleaved depth/stencil functions
  */
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d ) {                     \
    GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*pitch);        \
    tmp &= 0xff;                                                \
index c20a76f29efbda1b28844b13d29d57920961b1a3..1d413d3473440f4edbb9ff6a88c1b3b6fdca788c 100644 (file)
@@ -778,8 +778,6 @@ void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers )
 {
    __DRIdrawablePrivate *const driDrawable = mmesa->driDrawable;
    __DRIdrawablePrivate *const driReadable = mmesa->driReadable;
-   drm_mga_sarea_t *sarea = mmesa->sarea;
-
 
    mmesa->dirty_cliprects = 0; 
 
@@ -790,9 +788,6 @@ void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers )
 
    mga_set_cliprects(mmesa);
 
-   sarea->req_drawable = driDrawable->draw;
-   sarea->req_draw_buffer = mmesa->draw_buffer;
-
    mgaUpdateClipping( mmesa->glCtx );
    mgaCalcViewport( mmesa->glCtx );
 }
@@ -804,20 +799,22 @@ static void mgaDDDrawBuffer(GLcontext *ctx, GLenum mode )
 
    FLUSH_BATCH( mmesa );
 
-   /*
-    * _DrawDestMask is easier to cope with than <mode>.
-    */
-   switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
-   case BUFFER_BIT_FRONT_LEFT:
+   if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) {
+      /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
+      FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_TRUE );
+      return;
+   }
+
+   switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) {
+   case BUFFER_FRONT_LEFT:
       mmesa->setup.dstorg = mmesa->mgaScreen->frontOffset;
       mmesa->draw_buffer = MGA_FRONT;
       break;
-   case BUFFER_BIT_BACK_LEFT:
+   case BUFFER_BACK_LEFT:
       mmesa->setup.dstorg = mmesa->mgaScreen->backOffset;
       mmesa->draw_buffer = MGA_BACK;
       break;
    default:
-      /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
       FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_TRUE );
       return;
    }
index 0c8081cfb9637821d6cc8e0d3daadcb87e92fcd4..d2a8a693d7b964415a53a4e4f7b2a566600ba8eb 100644 (file)
@@ -66,7 +66,7 @@ do {                                          \
 } while (0)
 #endif
 
-static void __inline__ mga_draw_triangle( mgaContextPtr mmesa,
+static void INLINE mga_draw_triangle( mgaContextPtr mmesa,
                                           mgaVertexPtr v0,
                                           mgaVertexPtr v1,
                                           mgaVertexPtr v2 )
@@ -81,7 +81,7 @@ static void __inline__ mga_draw_triangle( mgaContextPtr mmesa,
 }
 
 
-static void __inline__ mga_draw_quad( mgaContextPtr mmesa,
+static void INLINE mga_draw_quad( mgaContextPtr mmesa,
                                       mgaVertexPtr v0,
                                       mgaVertexPtr v1,
                                       mgaVertexPtr v2,
@@ -100,7 +100,7 @@ static void __inline__ mga_draw_quad( mgaContextPtr mmesa,
 }
 
 
-static __inline__ void mga_draw_point( mgaContextPtr mmesa,
+static INLINE void mga_draw_point( mgaContextPtr mmesa,
                                        mgaVertexPtr tmp )
 {
    const GLfloat sz = 0.5 * CLAMP(mmesa->glCtx->Point.Size,
@@ -159,7 +159,7 @@ static __inline__ void mga_draw_point( mgaContextPtr mmesa,
 }
 
 
-static __inline__ void mga_draw_line( mgaContextPtr mmesa,
+static INLINE void mga_draw_line( mgaContextPtr mmesa,
                                      mgaVertexPtr v0,
                                      mgaVertexPtr v1 )
 {
diff --git a/src/mesa/drivers/dri/nouveau/Makefile b/src/mesa/drivers/dri/nouveau/Makefile
deleted file mode 100644 (file)
index 20d2de5..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-# src/mesa/drivers/dri/nouveau/Makefile
-
-TOP = ../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = nouveau_dri.so
-
-MINIGLX_SOURCES = 
-
-DRIVER_SOURCES = \
-       nouveau_bufferobj.c      \
-       nouveau_buffers.c        \
-       nouveau_card.c           \
-       nouveau_context.c        \
-       nouveau_driver.c         \
-       nouveau_fifo.c           \
-       nouveau_lock.c           \
-       nouveau_object.c         \
-       nouveau_screen.c         \
-       nouveau_span.c           \
-       nouveau_state.c          \
-       nouveau_state_cache.c    \
-       nouveau_shader.c         \
-       nouveau_shader_0.c       \
-       nouveau_shader_1.c       \
-       nouveau_shader_2.c       \
-       nouveau_tex.c            \
-       nouveau_swtcl.c          \
-       nouveau_sync.c           \
-       nouveau_query.c          \
-       nv04_state.c             \
-       nv04_swtcl.c             \
-       nv10_state.c             \
-       nv10_swtcl.c             \
-       nv20_state.c             \
-       nv20_vertprog.c          \
-       nv30_state.c             \
-       nv30_fragprog.c          \
-       nv30_vertprog.c          \
-       nv40_fragprog.c          \
-       nv40_vertprog.c          \
-       nv50_state.c
-
-C_SOURCES = \
-       $(COMMON_SOURCES) \
-       $(DRIVER_SOURCES) 
-
-ASM_SOURCES = 
-
-
-include ../Makefile.template
-
-symlinks:
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c
deleted file mode 100644 (file)
index fc14060..0000000
+++ /dev/null
@@ -1,616 +0,0 @@
-#include "bufferobj.h"
-#include "enums.h"
-
-#include "nouveau_bufferobj.h"
-#include "nouveau_buffers.h"
-#include "nouveau_context.h"
-#include "nouveau_drm.h"
-#include "nouveau_object.h"
-#include "nouveau_msg.h"
-
-#define NOUVEAU_MEM_FREE(mem) do {      \
-       nouveau_mem_free(ctx, (mem));   \
-       (mem) = NULL;                   \
-} while(0)
-
-#define DEBUG(fmt,args...) do {                \
-       if (NOUVEAU_DEBUG & DEBUG_BUFFEROBJ) { \
-               fprintf(stderr, "%s: "fmt, __func__, ##args);  \
-       }                                      \
-} while(0)
-
-static GLboolean
-nouveau_bo_download_from_screen(GLcontext *ctx,        GLuint offset, GLuint size,
-                                               struct gl_buffer_object *bo)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       nouveau_buffer_object *nbo = (nouveau_buffer_object *)bo;
-       nouveau_mem *in_mem;
-
-       DEBUG("bo=%p, offset=%d, size=%d\n", bo, offset, size);
-
-       /* If there's a permanent backing store, blit directly into it */
-       if (nbo->cpu_mem) {
-               if (nbo->cpu_mem != nbo->gpu_mem) {
-                       DEBUG("..cpu_mem\n");
-                       nouveau_memformat_flat_emit(ctx, nbo->cpu_mem,
-                                                   nbo->gpu_mem,
-                                                   offset, offset, size);
-               }
-       } else {
-               DEBUG("..sys_mem\n");
-               in_mem = nouveau_mem_alloc(ctx, NOUVEAU_MEM_AGP, size, 0);
-               if (in_mem) {
-                       DEBUG("....via GART\n");
-                       /* otherwise, try blitting to faster memory and
-                        * copying from there
-                        */
-                       nouveau_memformat_flat_emit(ctx, in_mem, nbo->gpu_mem,
-                                                        0, offset, size);
-                       nouveau_notifier_wait_nop(ctx, nmesa->syncNotifier,
-                                                      NvSubMemFormat);
-                       _mesa_memcpy(nbo->cpu_mem_sys + offset,
-                                       in_mem->map, size);
-                       NOUVEAU_MEM_FREE(in_mem);
-               } else {
-                       DEBUG("....direct VRAM copy\n");
-                       /* worst case, copy directly from vram */
-                       _mesa_memcpy(nbo->cpu_mem_sys + offset,
-                                    nbo->gpu_mem + offset,
-                                    size);
-               }
-       }
-
-       return GL_TRUE;
-}
-
-static GLboolean
-nouveau_bo_upload_to_screen(GLcontext *ctx, GLuint offset, GLuint size,
-                                           struct gl_buffer_object *bo)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       nouveau_buffer_object *nbo = (nouveau_buffer_object *)bo;
-       nouveau_mem *out_mem;
-
-       DEBUG("bo=%p, offset=%d, size=%d\n", bo, offset, size);
-
-       if (nbo->cpu_mem) {
-               if (nbo->cpu_mem != nbo->gpu_mem) {
-                       DEBUG("..cpu_mem\n");
-                       nouveau_memformat_flat_emit(ctx, nbo->gpu_mem,
-                                                   nbo->cpu_mem,
-                                                   offset, offset, size);
-               }
-       } else {
-               out_mem = nouveau_mem_alloc(ctx, NOUVEAU_MEM_AGP |
-                                                NOUVEAU_MEM_MAPPED,
-                                                size, 0);
-               if (out_mem) {
-                       DEBUG("....via GART\n");
-                       _mesa_memcpy(out_mem->map,
-                                       nbo->cpu_mem_sys + offset, size);
-                       nouveau_memformat_flat_emit(ctx, nbo->gpu_mem, out_mem,
-                                                   offset, 0, size);
-                       nouveau_notifier_wait_nop(ctx, nmesa->syncNotifier,
-                                                      NvSubMemFormat);
-                       NOUVEAU_MEM_FREE(out_mem);
-               } else {
-                       DEBUG("....direct VRAM copy\n");
-                       _mesa_memcpy(nbo->gpu_mem->map + offset,
-                                    nbo->cpu_mem_sys + offset,
-                                    size);
-               }
-       }
-
-       return GL_TRUE;
-}
-
-GLboolean
-nouveau_bo_move_in(GLcontext *ctx, struct gl_buffer_object *bo)
-{
-       nouveau_buffer_object *nbo = (nouveau_buffer_object *)bo;
-
-       DEBUG("bo=%p\n", bo);
-
-       if (bo->OnCard)
-               return GL_TRUE;
-       assert(nbo->gpu_mem_flags);
-
-       nbo->gpu_mem = nouveau_mem_alloc(ctx, nbo->gpu_mem_flags |
-                                             NOUVEAU_MEM_MAPPED,
-                                             bo->Size, 0);
-       assert(nbo->gpu_mem);
-
-       if (nbo->cpu_mem_flags) {
-               if ((nbo->cpu_mem_flags|NOUVEAU_MEM_MAPPED) != nbo->gpu_mem->type) {
-                       DEBUG("..need cpu_mem buffer\n");
-
-                       nbo->cpu_mem = nouveau_mem_alloc(ctx,
-                                                        nbo->cpu_mem_flags |
-                                                        NOUVEAU_MEM_MAPPED,
-                                                        bo->Size, 0);
-
-                       if (nbo->cpu_mem) {
-                               DEBUG("....alloc ok, kill sys_mem buffer\n");
-                               _mesa_memcpy(nbo->cpu_mem->map,
-                                            nbo->cpu_mem_sys, bo->Size);
-                               FREE(nbo->cpu_mem_sys);
-                       }
-               } else {
-                       DEBUG("..cpu direct access to GPU buffer\n");
-                       nbo->cpu_mem = nbo->gpu_mem;
-               }
-       }
-       nouveau_bo_upload_to_screen(ctx, 0, bo->Size, bo);
-
-       bo->OnCard = GL_TRUE;
-       return GL_TRUE;
-}
-
-GLboolean
-nouveau_bo_move_out(GLcontext *ctx, struct gl_buffer_object *bo)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       nouveau_buffer_object *nbo = (nouveau_buffer_object *)bo;
-       GLuint nr_dirty;
-
-       DEBUG("bo=%p\n", bo);
-       if (!bo->OnCard)
-               return GL_TRUE;
-
-       nr_dirty = nouveau_bo_download_dirty(ctx, bo);
-       if (nbo->cpu_mem) {
-               if (nr_dirty && nbo->cpu_mem != nbo->gpu_mem)
-                       nouveau_notifier_wait_nop(ctx, nmesa->syncNotifier,
-                                                      NvSubMemFormat);
-               DEBUG("..destroy cpu_mem buffer\n");
-               nbo->cpu_mem_sys = malloc(bo->Size);
-               assert(nbo->cpu_mem_sys);
-               _mesa_memcpy(nbo->cpu_mem_sys, nbo->cpu_mem->map, bo->Size);
-               if (nbo->cpu_mem == nbo->gpu_mem)
-                       nbo->cpu_mem = NULL;
-               else
-                       NOUVEAU_MEM_FREE(nbo->cpu_mem);
-       }
-       NOUVEAU_MEM_FREE(nbo->gpu_mem);
-
-       bo->OnCard = GL_FALSE;
-       return GL_TRUE;
-}
-
-static void
-nouveau_bo_choose_storage_method(GLcontext *ctx, GLenum usage,
-                                                struct gl_buffer_object *bo)
-{
-       nouveau_buffer_object *nbo = (nouveau_buffer_object *)bo;
-       GLuint gpu_type = 0;
-       GLuint cpu_type = 0;
-
-       switch (usage) {
-       /* Client source, changes often, used by GL many times */
-       case GL_DYNAMIC_DRAW_ARB:
-               gpu_type = NOUVEAU_MEM_AGP | NOUVEAU_MEM_FB_ACCEPTABLE;
-               cpu_type = NOUVEAU_MEM_AGP;
-               break;
-       /* GL source, changes often, client reads many times */
-       case GL_DYNAMIC_READ_ARB:
-       /* Client source, specified once, used by GL many times */
-       case GL_STATIC_DRAW_ARB:
-       /* GL source, specified once, client reads many times */
-       case GL_STATIC_READ_ARB:
-       /* Client source, specified once, used by GL a few times */
-       case GL_STREAM_DRAW_ARB:
-       /* GL source, specified once, client reads a few times */
-       case GL_STREAM_READ_ARB:
-       /* GL source, changes often, used by GL many times*/
-       case GL_DYNAMIC_COPY_ARB:
-       /* GL source, specified once, used by GL many times */
-       case GL_STATIC_COPY_ARB:
-       /* GL source, specified once, used by GL a few times */
-       case GL_STREAM_COPY_ARB:
-               gpu_type = NOUVEAU_MEM_FB;
-               break;
-       default: 
-               assert(0);
-       }
-
-       nbo->gpu_mem_flags = gpu_type;
-       nbo->cpu_mem_flags = cpu_type;
-       nbo->usage         = usage;
-}
-
-void
-nouveau_bo_init_storage(GLcontext *ctx,        GLuint valid_gpu_access,
-                                       GLsizeiptrARB size,
-                                       const GLvoid *data,
-                                       GLenum usage,
-                                       struct gl_buffer_object *bo)
-{
-       nouveau_buffer_object *nbo = (nouveau_buffer_object *)bo;
-
-       DEBUG("bo=%p\n", bo);
-
-       /* Free up previous buffers if we can't reuse them */
-       if (nbo->usage != usage ||
-                       (nbo->gpu_mem && (nbo->gpu_mem->size != size))) {
-               if (nbo->cpu_mem_sys)
-                       FREE(nbo->cpu_mem_sys);
-               if (nbo->cpu_mem) {
-                       if (nbo->cpu_mem != nbo->gpu_mem)
-                               NOUVEAU_MEM_FREE(nbo->cpu_mem);
-                       else
-                               nbo->cpu_mem = NULL;
-               }
-               if (nbo->gpu_mem)
-                       NOUVEAU_MEM_FREE(nbo->gpu_mem);
-
-               bo->OnCard = GL_FALSE;
-               nbo->cpu_mem_sys = calloc(1, size);
-       }
-
-       nouveau_bo_choose_storage_method(ctx, usage, bo);
-       /* Force off flags that may not be ok for a given buffer */
-       nbo->gpu_mem_flags &= valid_gpu_access;
-
-       bo->Usage  = usage;
-       bo->Size   = size;
-
-       if (data) {
-               GLvoid *map = nouveau_bo_map(ctx, GL_WRITE_ONLY_ARB, bo);
-               _mesa_memcpy(map, data, size);
-               nouveau_bo_dirty_all(ctx, GL_FALSE, bo);
-               nouveau_bo_unmap(ctx, bo);
-       }
-}
-
-void *
-nouveau_bo_map(GLcontext *ctx, GLenum access, struct gl_buffer_object *bo)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       nouveau_buffer_object *nbo = (nouveau_buffer_object *)bo;
-
-       DEBUG("bo=%p, access=%s\n", bo, _mesa_lookup_enum_by_nr(access));
-
-       if (bo->OnCard && 
-               (access == GL_READ_ONLY_ARB || access == GL_READ_WRITE_ARB)) {
-               GLuint nr_dirty;
-
-               DEBUG("..on card\n");
-               nr_dirty = nouveau_bo_download_dirty(ctx, bo);
-
-               /* nouveau_bo_download_dirty won't wait unless it needs to
-                * free a temp buffer, which isn't the case if cpu_mem is
-                * present.
-                */
-               if (nr_dirty && nbo->cpu_mem && nbo->cpu_mem != nbo->gpu_mem)
-                       nouveau_notifier_wait_nop(ctx, nmesa->syncNotifier,
-                                                      NvSubMemFormat);
-       }
-
-       if (nbo->cpu_mem) {
-               DEBUG("..access via cpu_mem\n");
-               return nbo->cpu_mem->map;
-       } else {
-               DEBUG("..access via cpu_mem_sys\n");
-               return nbo->cpu_mem_sys;
-       }
-}
-
-void
-nouveau_bo_unmap(GLcontext *ctx, struct gl_buffer_object *bo)
-{
-       DEBUG("unmap bo=%p\n", bo);
-}
-
-uint32_t
-nouveau_bo_gpu_ref(GLcontext *ctx, struct gl_buffer_object *bo)
-{
-       nouveau_buffer_object *nbo = (nouveau_buffer_object *)bo;
-
-       assert(nbo->mapped == GL_FALSE);
-
-       DEBUG("gpu_ref\n");
-       
-       if (!bo->OnCard) {
-               nouveau_bo_move_in(ctx, bo);
-               bo->OnCard = GL_TRUE;
-       }
-       nouveau_bo_upload_dirty(ctx, bo);
-
-       return nouveau_mem_gpu_offset_get(ctx, nbo->gpu_mem);
-}
-
-void
-nouveau_bo_dirty_linear(GLcontext *ctx, GLboolean on_card,
-                       uint32_t offset, uint32_t size,
-                       struct gl_buffer_object *bo)
-{
-       nouveau_buffer_object *nbo = (nouveau_buffer_object *)bo;
-       nouveau_bufferobj_dirty *dirty;
-       uint32_t start = offset;
-       uint32_t end = offset + size;
-       int i;
-
-       if (nbo->cpu_mem == nbo->gpu_mem)
-               return;
-
-       dirty = on_card ? &nbo->gpu_dirty : &nbo->cpu_dirty;
-
-       DEBUG("on_card=%d, offset=%d, size=%d, bo=%p\n",
-                       on_card, offset, size, bo);
-
-       for (i=0; i<dirty->nr_dirty; i++) {
-               nouveau_bufferobj_region *r = &dirty->dirty[i];
-
-               /* already dirty */
-               if (start >= r->start && end <= r->end) {
-                       DEBUG("..already dirty\n");
-                       return;
-               }
-
-               /* add to the end of a region */
-               if (start >= r->start && start <= r->end) {
-                       if (end > r->end) {
-                               DEBUG("..extend end of region\n");
-                               r->end = end;
-                               return;
-                       }
-               }
-
-               /* add to the start of a region */
-               if (start < r->start && end >= r->end) {
-                       DEBUG("..extend start of region\n");
-                       r->start = start;
-                       /* .. and to the end */
-                       if (end > r->end) {
-                               DEBUG("....and end\n");
-                               r->end = end;
-                       }
-                       return;
-               }
-       }
-
-       /* new region */
-       DEBUG("..new dirty\n");
-       dirty->nr_dirty++;
-       dirty->dirty = realloc(dirty->dirty,
-                              sizeof(nouveau_bufferobj_region) *
-                              dirty->nr_dirty);
-       dirty->dirty[dirty->nr_dirty - 1].start = start;
-       dirty->dirty[dirty->nr_dirty - 1].end   = end;
-}
-
-void
-nouveau_bo_dirty_all(GLcontext *ctx, GLboolean on_card,
-                    struct gl_buffer_object *bo)
-{
-       nouveau_buffer_object *nbo = (nouveau_buffer_object *)bo;
-       nouveau_bufferobj_dirty *dirty;
-
-       dirty = on_card ? &nbo->gpu_dirty : &nbo->cpu_dirty;
-       
-       DEBUG("dirty all\n");
-       if (dirty->nr_dirty) {
-               FREE(dirty->dirty);
-               dirty->dirty    = NULL;
-               dirty->nr_dirty = 0;
-       }
-
-       nouveau_bo_dirty_linear(ctx, on_card, 0, bo->Size, bo);
-}
-
-GLuint
-nouveau_bo_upload_dirty(GLcontext *ctx, struct gl_buffer_object *bo)
-{
-       nouveau_buffer_object *nbo = (nouveau_buffer_object *)bo;
-       nouveau_bufferobj_dirty *dirty = &nbo->cpu_dirty;
-       GLuint nr_dirty;
-       int i;
-
-       nr_dirty = dirty->nr_dirty;
-       if (!nr_dirty) {
-               DEBUG("clean\n");
-               return nr_dirty;
-       }
-
-       for (i=0; i<nr_dirty; i++) {
-               nouveau_bufferobj_region *r = &dirty->dirty[i];
-
-               DEBUG("dirty %d: o=0x%08x, s=0x%08x\n",
-                               i, r->start, r->end - r->start);
-               nouveau_bo_upload_to_screen(ctx,
-                                           r->start, r->end - r->start, bo);
-       }
-
-       FREE(dirty->dirty);
-       dirty->dirty    = NULL;
-       dirty->nr_dirty = 0;
-
-       return nr_dirty;
-}
-
-GLuint
-nouveau_bo_download_dirty(GLcontext *ctx, struct gl_buffer_object *bo)
-{
-       nouveau_buffer_object *nbo = (nouveau_buffer_object *)bo;
-       nouveau_bufferobj_dirty *dirty = &nbo->gpu_dirty;
-       GLuint nr_dirty;
-       int i;
-
-       nr_dirty = dirty->nr_dirty;
-       if (nr_dirty) {
-               DEBUG("clean\n");
-               return nr_dirty;
-       }
-       
-       for (i=0; i<nr_dirty; i++) {
-               nouveau_bufferobj_region *r = &dirty->dirty[i];
-
-               DEBUG("dirty %d: o=0x%08x, s=0x%08x\n",
-                               i, r->start, r->end - r->start);
-               nouveau_bo_download_from_screen(ctx,
-                                               r->start,
-                                               r->end - r->start, bo);
-       }
-
-       FREE(dirty->dirty);
-       dirty->dirty    = NULL;
-       dirty->nr_dirty = 0;
-
-       return nr_dirty;
-}
-
-static void
-nouveauBindBuffer(GLcontext *ctx, GLenum target, struct gl_buffer_object *obj)
-{
-}
-
-static struct gl_buffer_object *
-nouveauNewBufferObject(GLcontext *ctx, GLuint buffer, GLenum target)
-{
-       nouveau_buffer_object *nbo;
-
-       nbo = CALLOC_STRUCT(nouveau_buffer_object_t);
-       if (nbo)
-               _mesa_initialize_buffer_object(&nbo->mesa, buffer, target);
-       DEBUG("bo=%p\n", nbo);
-
-       return nbo ? &nbo->mesa : NULL;
-}
-
-static void
-nouveauDeleteBuffer(GLcontext *ctx, struct gl_buffer_object *obj)
-{
-       nouveau_buffer_object *nbo = (nouveau_buffer_object *)obj;
-
-       if (nbo->gpu_dirty.nr_dirty)
-               FREE(nbo->gpu_dirty.dirty);
-       if (nbo->cpu_dirty.nr_dirty)
-               FREE(nbo->cpu_dirty.dirty);
-       if (nbo->cpu_mem) nouveau_mem_free(ctx, nbo->cpu_mem);
-       if (nbo->gpu_mem) nouveau_mem_free(ctx, nbo->gpu_mem);
-
-       _mesa_delete_buffer_object(ctx, obj);
-}
-
-static void
-nouveauBufferData(GLcontext *ctx, GLenum target, GLsizeiptrARB size,
-                 const GLvoid *data, GLenum usage,
-                 struct gl_buffer_object *obj)
-{
-       GLuint gpu_flags;
-
-       DEBUG("target=%s, size=%d, data=%p, usage=%s, obj=%p\n",
-                       _mesa_lookup_enum_by_nr(target),
-                       (GLuint)size, data,
-                       _mesa_lookup_enum_by_nr(usage),
-                       obj);
-
-       switch (target) {
-       case GL_ELEMENT_ARRAY_BUFFER_ARB:
-               gpu_flags = 0;
-               break;
-       default:
-               gpu_flags = NOUVEAU_BO_VRAM_OK | NOUVEAU_BO_GART_OK;
-               break;
-       }
-       nouveau_bo_init_storage(ctx, gpu_flags, size, data, usage, obj);
-}
-
-static void
-nouveauBufferSubData(GLcontext *ctx, GLenum target, GLintptrARB offset,
-                    GLsizeiptrARB size, const GLvoid *data,
-                    struct gl_buffer_object *obj)
-{
-       GLvoid *out;
-
-       DEBUG("target=%s, offset=0x%x, size=%d, data=%p, obj=%p\n",
-                       _mesa_lookup_enum_by_nr(target),
-                       (GLuint)offset, (GLuint)size, data, obj);
-
-       out = nouveau_bo_map(ctx, GL_WRITE_ONLY_ARB, obj);
-       _mesa_memcpy(out + offset, data, size);
-       nouveau_bo_dirty_linear(ctx, GL_FALSE, offset, size, obj);
-       nouveau_bo_unmap(ctx, obj);
-}
-
-static void
-nouveauGetBufferSubData(GLcontext *ctx, GLenum target, GLintptrARB offset,
-                    GLsizeiptrARB size, GLvoid *data,
-                    struct gl_buffer_object *obj)
-{
-       const GLvoid *in;
-
-       DEBUG("target=%s, offset=0x%x, size=%d, data=%p, obj=%p\n",
-                       _mesa_lookup_enum_by_nr(target),
-                       (GLuint)offset, (GLuint)size, data, obj);
-
-       in = nouveau_bo_map(ctx, GL_READ_ONLY_ARB, obj);
-       _mesa_memcpy(data, in + offset, size);
-       nouveau_bo_unmap(ctx, obj);
-}
-
-static void *
-nouveauMapBuffer(GLcontext *ctx, GLenum target, GLenum access,
-                struct gl_buffer_object *obj)
-{
-       DEBUG("target=%s, access=%s, obj=%p\n",
-                       _mesa_lookup_enum_by_nr(target),
-                       _mesa_lookup_enum_by_nr(access),
-                       obj
-                       );
-
-       /* Already mapped.. */
-       if (obj->Pointer)
-               return NULL;
-
-       /* Have to pass READ_WRITE here, nouveau_bo_map will only ensure that
-        * the cpu_mem buffer is up-to-date if we ask for read access.
-        *
-        * However, even if the client only asks for write access, we're still
-        * forced to reupload the entire buffer.  So, we need the cpu_mem buffer
-        * to have the correct data all the time.
-        */
-       obj->Pointer = nouveau_bo_map(ctx, GL_READ_WRITE_ARB, obj);
-
-       /* The GL spec says that a client attempting to write to a bufferobj
-        * mapped READ_ONLY object may have unpredictable results, possibly
-        * even program termination.
-        *
-        * We're going to use this, and only mark the buffer as dirtied if
-        * the client asks for write access.
-        */
-       if (target != GL_READ_ONLY_ARB) {
-               /* We have no way of knowing what was modified by the client,
-                * so the entire buffer gets dirtied. */
-               nouveau_bo_dirty_all(ctx, GL_FALSE, obj);
-       }
-
-       return obj->Pointer;
-}
-
-static GLboolean
-nouveauUnmapBuffer(GLcontext *ctx, GLenum target, struct gl_buffer_object *obj)
-{
-       DEBUG("target=%s, obj=%p\n", _mesa_lookup_enum_by_nr(target), obj);
-
-       assert(obj->Pointer);
-
-       nouveau_bo_unmap(ctx, obj);
-       obj->Pointer = NULL;
-       return GL_TRUE;
-}
-         
-void
-nouveauInitBufferObjects(GLcontext *ctx)
-{
-       ctx->Driver.BindBuffer          = nouveauBindBuffer;
-       ctx->Driver.NewBufferObject     = nouveauNewBufferObject;
-       ctx->Driver.DeleteBuffer        = nouveauDeleteBuffer;
-       ctx->Driver.BufferData          = nouveauBufferData;
-       ctx->Driver.BufferSubData       = nouveauBufferSubData;
-       ctx->Driver.GetBufferSubData    = nouveauGetBufferSubData;
-       ctx->Driver.MapBuffer           = nouveauMapBuffer;
-       ctx->Driver.UnmapBuffer         = nouveauUnmapBuffer;
-}
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.h b/src/mesa/drivers/dri/nouveau/nouveau_bufferobj.h
deleted file mode 100644 (file)
index 3439a35..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-#ifndef __NOUVEAU_BUFFEROBJ_H__
-#define __NOUVEAU_BUFFEROBJ_H__
-
-#include "mtypes.h"
-#include "nouveau_buffers.h"
-
-#define NOUVEAU_BO_VRAM_OK (NOUVEAU_MEM_FB | NOUVEAU_MEM_FB_ACCEPTABLE)
-#define NOUVEAU_BO_GART_OK  (NOUVEAU_MEM_AGP | NOUVEAU_MEM_AGP_ACCEPTABLE)
-
-typedef struct nouveau_bufferobj_region_t {
-       uint32_t start;
-       uint32_t end;
-} nouveau_bufferobj_region;
-
-typedef struct nouveau_bufferobj_dirty_t {
-       nouveau_bufferobj_region *dirty;
-       int nr_dirty;
-} nouveau_bufferobj_dirty;
-
-typedef struct nouveau_buffer_object_t {
-       /* Base class, must be first */
-       struct gl_buffer_object mesa;
-
-       GLboolean               mapped;
-       GLenum                  usage;
-
-       /* Memory used for GPU access to the buffer*/
-       GLuint                  gpu_mem_flags;
-       nouveau_mem *           gpu_mem;
-       nouveau_bufferobj_dirty gpu_dirty;
-
-       /* Memory used for CPU access to the buffer */
-       GLuint                  cpu_mem_flags;
-       nouveau_mem *           cpu_mem;
-       GLvoid *                cpu_mem_sys;
-       nouveau_bufferobj_dirty cpu_dirty;
-} nouveau_buffer_object;
-
-extern void
-nouveau_bo_init_storage(GLcontext *ctx, GLuint valid_gpu_access,
-                       GLsizeiptrARB size, const GLvoid *data, GLenum usage,
-                       struct gl_buffer_object *bo);
-
-extern GLboolean
-nouveau_bo_move_in(GLcontext *ctx, struct gl_buffer_object *bo);
-
-extern GLboolean
-nouveau_bo_move_out(GLcontext *ctx, struct gl_buffer_object *bo);
-
-extern void *
-nouveau_bo_map(GLcontext *ctx, GLenum usage, struct gl_buffer_object *bo);
-
-extern void
-nouveau_bo_unmap(GLcontext *ctx, struct gl_buffer_object *bo);
-
-extern uint32_t
-nouveau_bo_gpu_ref(GLcontext *ctx, struct gl_buffer_object *bo);
-
-extern void
-nouveau_bo_dirty_linear(GLcontext *ctx, GLboolean on_card,
-                       uint32_t offset, uint32_t size,
-                       struct gl_buffer_object *bo);
-
-extern void
-nouveau_bo_dirty_all(GLcontext *ctx, GLboolean on_card,
-                    struct gl_buffer_object *bo);
-
-extern GLuint
-nouveau_bo_upload_dirty(GLcontext *ctx, struct gl_buffer_object *bo);
-
-extern GLuint
-nouveau_bo_download_dirty(GLcontext *ctx, struct gl_buffer_object *bo);
-
-extern void
-nouveauInitBufferObjects(GLcontext *ctx);
-
-#endif
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_buffers.c b/src/mesa/drivers/dri/nouveau/nouveau_buffers.c
deleted file mode 100644 (file)
index d498f61..0000000
+++ /dev/null
@@ -1,436 +0,0 @@
-#include "utils.h"
-#include "framebuffer.h"
-#include "renderbuffer.h"
-#include "fbobject.h"
-
-#include "nouveau_context.h"
-#include "nouveau_buffers.h"
-#include "nouveau_object.h"
-#include "nouveau_fifo.h"
-#include "nouveau_reg.h"
-#include "nouveau_msg.h"
-
-#define MAX_MEMFMT_LENGTH 32768
-
-/* Unstrided blit using NV_MEMORY_TO_MEMORY_FORMAT */
-GLboolean
-nouveau_memformat_flat_emit(GLcontext *ctx,
-                           nouveau_mem *dst, nouveau_mem *src,
-                           GLuint dst_offset, GLuint src_offset,
-                           GLuint size)
-{
-   nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-   uint32_t src_handle, dst_handle;
-   GLuint count;
-
-   if (src_offset + size > src->size) {
-      MESSAGE("src out of nouveau_mem bounds\n");
-      return GL_FALSE;
-   }
-   if (dst_offset + size > dst->size) {
-      MESSAGE("dst out of nouveau_mem bounds\n");
-      return GL_FALSE;
-   }
-
-   src_handle = (src->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaTT;
-   dst_handle = (dst->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaTT;
-   src_offset += nouveau_mem_gpu_offset_get(ctx, src);
-   dst_offset += nouveau_mem_gpu_offset_get(ctx, dst);
-
-   BEGIN_RING_SIZE(NvSubMemFormat, NV_MEMORY_TO_MEMORY_FORMAT_OBJECT_IN, 2);
-   OUT_RING       (src_handle);
-   OUT_RING       (dst_handle);
-
-   count = (size / MAX_MEMFMT_LENGTH) + ((size % MAX_MEMFMT_LENGTH) ? 1 : 0);
-
-   while (count--) {
-      GLuint length = (size > MAX_MEMFMT_LENGTH) ? MAX_MEMFMT_LENGTH : size;
-
-      BEGIN_RING_SIZE(NvSubMemFormat, NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN, 8);
-      OUT_RING       (src_offset);
-      OUT_RING       (dst_offset);
-      OUT_RING       (0); /* pitch in */
-      OUT_RING       (0); /* pitch out */
-      OUT_RING       (length); /* line length */
-      OUT_RING       (1); /* number of lines */
-      OUT_RING       ((1 << 8) /* dst_inc */ | (1 << 0) /* src_inc */);
-      OUT_RING       (0); /* buffer notify? */
-      FIRE_RING();
-
-      src_offset += length;
-      dst_offset += length;
-      size       -= length;
-   }
-
-   return GL_TRUE;
-}
-
-void
-nouveau_mem_free(GLcontext *ctx, nouveau_mem *mem)
-{
-   nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-   struct drm_nouveau_mem_free memf;
-
-   if (NOUVEAU_DEBUG & DEBUG_MEM)  {
-      fprintf(stderr, "%s: type=0x%x, offset=0x%x, size=0x%x\n",
-           __func__, mem->type, (GLuint)mem->offset, (GLuint)mem->size);
-   }
-
-   if (mem->map)
-      drmUnmap(mem->map, mem->size);
-   memf.flags  = mem->type;
-   memf.offset = mem->offset;
-   drmCommandWrite(nmesa->driFd, DRM_NOUVEAU_MEM_FREE, &memf, sizeof(memf));
-   FREE(mem);
-}
-
-nouveau_mem *
-nouveau_mem_alloc(GLcontext *ctx, int type, GLuint size, GLuint align)
-{
-   nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-   struct drm_nouveau_mem_alloc mema;
-   nouveau_mem *mem;
-   int ret;
-
-   if (NOUVEAU_DEBUG & DEBUG_MEM)  {
-      fprintf(stderr, "%s: requested: type=0x%x, size=0x%x, align=0x%x\n",
-           __func__, type, (GLuint)size, align);
-   }
-
-   mem = CALLOC(sizeof(nouveau_mem));
-   if (!mem)
-      return NULL;
-
-   mema.flags     = type;
-   mema.size      = mem->size = size;
-   mema.alignment = align;
-   mem->map       = NULL;
-   ret = drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_MEM_ALLOC,
-                            &mema, sizeof(mema));
-   if (ret) {
-      FREE(mem);
-      return NULL;
-   }
-   mem->offset = mema.offset;
-   mem->type   = mema.flags;
-
-   if (NOUVEAU_DEBUG & DEBUG_MEM)  {
-      fprintf(stderr, "%s: actual: type=0x%x, offset=0x%x, size=0x%x\n",
-           __func__, mem->type, (GLuint)mem->offset, (GLuint)mem->size);
-   }
-
-   if (type & NOUVEAU_MEM_MAPPED)
-      ret = drmMap(nmesa->driFd, mema.map_handle, mem->size, &mem->map);
-   if (ret) {
-      mem->map = NULL;
-      nouveau_mem_free(ctx, mem);
-      mem = NULL;
-   }
-
-   return mem;
-}
-
-uint32_t
-nouveau_mem_gpu_offset_get(GLcontext *ctx, nouveau_mem *mem)
-{
-   nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-   return mem->offset;
-}
-
-static GLboolean
-nouveau_renderbuffer_pixelformat(nouveau_renderbuffer *nrb,
-                                GLenum internalFormat)
-{
-      nrb->mesa.InternalFormat = internalFormat;
-
-   /*TODO: We probably want to extend this a bit, and maybe make
-    *      card-specific? 
-    */
-      switch (internalFormat) {
-      case GL_RGBA:
-      case GL_RGBA8:
-        nrb->mesa._BaseFormat  = GL_RGBA;
-        nrb->mesa._ActualFormat= GL_RGBA8;
-        nrb->mesa.DataType     = GL_UNSIGNED_BYTE;
-        nrb->mesa.RedBits      = 8;
-        nrb->mesa.GreenBits    = 8;
-        nrb->mesa.BlueBits     = 8;
-        nrb->mesa.AlphaBits    = 8;
-        nrb->cpp               = 4;
-        break;
-      case GL_RGB:
-      case GL_RGB5:
-        nrb->mesa._BaseFormat  = GL_RGB;
-        nrb->mesa._ActualFormat= GL_RGB5;
-        nrb->mesa.DataType     = GL_UNSIGNED_BYTE;
-        nrb->mesa.RedBits      = 5;
-        nrb->mesa.GreenBits    = 6;
-        nrb->mesa.BlueBits     = 5;
-        nrb->mesa.AlphaBits    = 0;
-        nrb->cpp               = 2;
-        break;
-      case GL_DEPTH_COMPONENT16:
-        nrb->mesa._BaseFormat  = GL_DEPTH_COMPONENT;
-        nrb->mesa._ActualFormat= GL_DEPTH_COMPONENT16;
-        nrb->mesa.DataType     = GL_UNSIGNED_SHORT;
-        nrb->mesa.DepthBits    = 16;
-        nrb->cpp               = 2;
-        break;
-      case GL_DEPTH_COMPONENT24:
-        nrb->mesa._BaseFormat  = GL_DEPTH_COMPONENT;
-        nrb->mesa._ActualFormat= GL_DEPTH24_STENCIL8_EXT;
-        nrb->mesa.DataType     = GL_UNSIGNED_INT_24_8_EXT;
-        nrb->mesa.DepthBits    = 24;
-        nrb->cpp               = 4;
-        break;
-      case GL_STENCIL_INDEX8_EXT:
-        nrb->mesa._BaseFormat  = GL_STENCIL_INDEX;
-        nrb->mesa._ActualFormat= GL_DEPTH24_STENCIL8_EXT;
-        nrb->mesa.DataType     = GL_UNSIGNED_INT_24_8_EXT;
-        nrb->mesa.StencilBits  = 8;
-        nrb->cpp               = 4;
-        break;
-      case GL_DEPTH24_STENCIL8_EXT:
-        nrb->mesa._BaseFormat  = GL_DEPTH_STENCIL_EXT;
-        nrb->mesa._ActualFormat= GL_DEPTH24_STENCIL8_EXT;
-        nrb->mesa.DataType     = GL_UNSIGNED_INT_24_8_EXT;
-        nrb->mesa.DepthBits    = 24;
-        nrb->mesa.StencilBits  = 8;
-        nrb->cpp               = 4;
-        break;
-      default:
-        return GL_FALSE;
-        break;
-      }
-
-      return GL_TRUE;
-}
-
-static GLboolean
-nouveau_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
-                            GLenum internalFormat,
-                            GLuint width,
-                            GLuint height)
-{
-   nouveau_renderbuffer *nrb = (nouveau_renderbuffer*)rb;
-
-   if (!nouveau_renderbuffer_pixelformat(nrb, internalFormat)) {
-      fprintf(stderr, "%s: unknown internalFormat\n", __func__);
-      return GL_FALSE;
-   }
-
-   /* If this buffer isn't statically alloc'd, we may need to ask the
-    * drm for more memory */
-   if (!nrb->dPriv && (rb->Width != width || rb->Height != height)) {
-      GLuint pitch;
-
-      /* align pitches to 64 bytes */
-      pitch = ((width * nrb->cpp) + 63) & ~63;
-
-      if (nrb->mem)
-        nouveau_mem_free(ctx, nrb->mem);
-      nrb->mem = nouveau_mem_alloc(ctx,
-                                  NOUVEAU_MEM_FB | NOUVEAU_MEM_MAPPED,
-                                  pitch*height,
-                                  0);
-      if (!nrb->mem)
-        return GL_FALSE;
-
-      /* update nouveau_renderbuffer info */
-      nrb->offset = nouveau_mem_gpu_offset_get(ctx, nrb->mem);
-      nrb->pitch  = pitch;
-   }
-
-   rb->Width = width;
-   rb->Height = height;
-   rb->InternalFormat = internalFormat;
-   return GL_TRUE;
-}
-
-static void
-nouveau_renderbuffer_delete(struct gl_renderbuffer *rb)
-{
-   GET_CURRENT_CONTEXT(ctx);
-   nouveau_renderbuffer *nrb = (nouveau_renderbuffer*)rb;
-
-   if (nrb->mem)
-      nouveau_mem_free(ctx, nrb->mem);
-   FREE(nrb);
-}
-
-nouveau_renderbuffer *
-nouveau_renderbuffer_new(GLenum internalFormat, GLvoid *map,
-                        GLuint offset,  GLuint pitch,
-                        __DRIdrawablePrivate *dPriv)
-{
-   nouveau_renderbuffer *nrb;
-
-   nrb = CALLOC_STRUCT(nouveau_renderbuffer_t);
-   if (nrb) {
-      _mesa_init_renderbuffer(&nrb->mesa, 0);
-
-      nouveau_renderbuffer_pixelformat(nrb, internalFormat);
-
-      nrb->mesa.AllocStorage   = nouveau_renderbuffer_storage;
-      nrb->mesa.Delete         = nouveau_renderbuffer_delete;
-
-      nrb->dPriv  = dPriv;
-      nrb->offset = offset;
-      nrb->pitch  = pitch;
-      nrb->map    = map;
-   }
-
-   return nrb;
-}
-
-static void
-nouveau_cliprects_drawable_set(nouveauContextPtr nmesa,
-                              nouveau_renderbuffer *nrb)
-{
-   __DRIdrawablePrivate *dPriv = nrb->dPriv;
-
-   nmesa->numClipRects = dPriv->numClipRects;
-   nmesa->pClipRects   = dPriv->pClipRects;
-   nmesa->drawX                = dPriv->x;
-   nmesa->drawY                = dPriv->y;
-   nmesa->drawW                = dPriv->w;
-   nmesa->drawH                = dPriv->h;
-}
-
-static void
-nouveau_cliprects_renderbuffer_set(nouveauContextPtr nmesa,
-                                  nouveau_renderbuffer *nrb)
-{
-   nmesa->numClipRects = 1;
-   nmesa->pClipRects   = &nmesa->osClipRect;
-   nmesa->osClipRect.x1        = 0;
-   nmesa->osClipRect.y1        = 0;
-   nmesa->osClipRect.x2        = nrb->mesa.Width;
-   nmesa->osClipRect.y2        = nrb->mesa.Height;
-   nmesa->drawX                = 0;
-   nmesa->drawY                = 0;
-   nmesa->drawW                = nrb->mesa.Width;
-   nmesa->drawH                = nrb->mesa.Height;
-}
-
-void
-nouveau_window_moved(GLcontext *ctx)
-{
-   nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-   nouveau_renderbuffer *nrb;
-
-   nrb = (nouveau_renderbuffer *)ctx->DrawBuffer->_ColorDrawBuffers[0][0];
-   if (!nrb)
-      return;
-
-   if (!nrb->dPriv)
-      nouveau_cliprects_renderbuffer_set(nmesa, nrb);
-   else
-      nouveau_cliprects_drawable_set(nmesa, nrb);
-
-   /* Viewport depends on window size/position, nouveauCalcViewport
-    * will take care of calling the hw-specific WindowMoved
-    */
-   ctx->Driver.Viewport(ctx, ctx->Viewport.X, ctx->Viewport.Y,
-                            ctx->Viewport.Width, ctx->Viewport.Height);
-   /* Scissor depends on window position */
-   ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
-                           ctx->Scissor.Width, ctx->Scissor.Height);
-}
-
-GLboolean
-nouveau_build_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
-{
-   nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-   nouveau_renderbuffer *color[MAX_DRAW_BUFFERS];
-   nouveau_renderbuffer *depth;
-
-   _mesa_update_framebuffer(ctx);
-   _mesa_update_draw_buffer_bounds(ctx);
-
-   color[0] = (nouveau_renderbuffer *)fb->_ColorDrawBuffers[0][0];
-   if (fb->_DepthBuffer && fb->_DepthBuffer->Wrapped)
-      depth = (nouveau_renderbuffer *)fb->_DepthBuffer->Wrapped;
-   else
-      depth = (nouveau_renderbuffer *)fb->_DepthBuffer;
-
-   if (!nmesa->hw_func.BindBuffers(nmesa, 1, color, depth))
-      return GL_FALSE;
-   nouveau_window_moved(ctx);
-
-   return GL_TRUE;
-}
-
-static void
-nouveauDrawBuffer(GLcontext *ctx, GLenum buffer)
-{
-   nouveau_build_framebuffer(ctx, ctx->DrawBuffer);
-}
-
-static struct gl_framebuffer *
-nouveauNewFramebuffer(GLcontext *ctx, GLuint name)
-{
-   return _mesa_new_framebuffer(ctx, name);
-}
-
-static struct gl_renderbuffer *
-nouveauNewRenderbuffer(GLcontext *ctx, GLuint name)
-{
-   nouveau_renderbuffer *nrb;
-
-   nrb = CALLOC_STRUCT(nouveau_renderbuffer_t);
-   if (nrb) {
-      _mesa_init_renderbuffer(&nrb->mesa, name);
-
-      nrb->mesa.AllocStorage   = nouveau_renderbuffer_storage;
-      nrb->mesa.Delete         = nouveau_renderbuffer_delete;
-   }
-   return &nrb->mesa;
-}
-
-static void
-nouveauBindFramebuffer(GLcontext *ctx, GLenum target,
-                       struct gl_framebuffer *fb, struct gl_framebuffer *fbread)
-{
-   if (target == GL_FRAMEBUFFER_EXT || target == GL_DRAW_FRAMEBUFFER_EXT) {
-      nouveau_build_framebuffer(ctx, fb);
-   }
-}
-
-static void
-nouveauFramebufferRenderbuffer(GLcontext *ctx,
-                              struct gl_framebuffer *fb,
-                              GLenum attachment,
-                              struct gl_renderbuffer *rb)
-{
-   _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb);
-   nouveau_build_framebuffer(ctx, fb);
-}
-
-static void
-nouveauRenderTexture(GLcontext *ctx,
-                    struct gl_framebuffer *fb,
-                    struct gl_renderbuffer_attachment *att)
-{
-}
-
-static void
-nouveauFinishRenderTexture(GLcontext *ctx,
-                          struct gl_renderbuffer_attachment *att)
-{
-}
-
-void
-nouveauInitBufferFuncs(struct dd_function_table *func)
-{
-   func->DrawBuffer             = nouveauDrawBuffer;
-
-   func->NewFramebuffer                 = nouveauNewFramebuffer;
-   func->NewRenderbuffer        = nouveauNewRenderbuffer;
-   func->BindFramebuffer        = nouveauBindFramebuffer;
-   func->FramebufferRenderbuffer = nouveauFramebufferRenderbuffer;
-   func->RenderTexture          = nouveauRenderTexture;
-   func->FinishRenderTexture    = nouveauFinishRenderTexture;
-}
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_buffers.h b/src/mesa/drivers/dri/nouveau/nouveau_buffers.h
deleted file mode 100644 (file)
index d864551..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef __NOUVEAU_BUFFERS_H__
-#define __NOUVEAU_BUFFERS_H__
-
-#include <stdint.h>
-#include "mtypes.h"
-#include "utils.h"
-#include "renderbuffer.h"
-
-typedef struct nouveau_mem_t {
-   int type;
-   uint64_t offset;
-   uint64_t size;
-   void*    map;
-} nouveau_mem;
-
-extern nouveau_mem *nouveau_mem_alloc(GLcontext *ctx, int type,
-                                     GLuint size, GLuint align);
-extern void nouveau_mem_free(GLcontext *ctx, nouveau_mem *mem);
-extern uint32_t nouveau_mem_gpu_offset_get(GLcontext *ctx, nouveau_mem *mem);
-
-extern GLboolean nouveau_memformat_flat_emit(GLcontext *ctx,
-                                            nouveau_mem *dst,
-                                            nouveau_mem *src,
-                                            GLuint dst_offset,
-                                            GLuint src_offset,
-                                            GLuint size);
-
-typedef struct nouveau_renderbuffer_t {
-   struct gl_renderbuffer mesa; /* must be first! */
-   __DRIdrawablePrivate  *dPriv;
-
-   nouveau_mem *mem;
-   void *      map;
-
-   int         cpp;
-   uint32_t    offset;
-   uint32_t    pitch;
-} nouveau_renderbuffer;
-
-extern nouveau_renderbuffer *nouveau_renderbuffer_new(GLenum internalFormat,
-      GLvoid *map, GLuint offset, GLuint pitch, __DRIdrawablePrivate *dPriv);
-extern void nouveau_window_moved(GLcontext *ctx);
-extern GLboolean nouveau_build_framebuffer(GLcontext *, struct gl_framebuffer *);
-extern nouveau_renderbuffer *nouveau_current_draw_buffer(GLcontext *ctx);
-
-extern void nouveauInitBufferFuncs(struct dd_function_table *func);
-
-#endif
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_card.c b/src/mesa/drivers/dri/nouveau/nouveau_card.c
deleted file mode 100644 (file)
index 91f12f0..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-
-#include "nouveau_card.h"
-#include "nouveau_reg.h"
-#include "nouveau_drm.h"
-#include "nouveau_card_list.h"
-
-
-nouveau_card* nouveau_card_lookup(uint32_t device_id)
-{
-       int i;
-       for(i=0;i<sizeof(nouveau_card_list)/sizeof(nouveau_card)-1;i++)
-               if (nouveau_card_list[i].id==(device_id&0xffff))
-                       return &(nouveau_card_list[i]);
-       return NULL;
-}
-
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_card.h b/src/mesa/drivers/dri/nouveau/nouveau_card.h
deleted file mode 100644 (file)
index 8a4c5f2..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/**************************************************************************
-
-Copyright 2006 Stephane Marchesin
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-
-#ifndef __NOUVEAU_CARD_H__
-#define __NOUVEAU_CARD_H__
-
-#include "dri_util.h"
-#include "drm.h"
-#include "nouveau_drm.h"
-
-typedef struct nouveau_card_t {
-       uint16_t id; /* last 4 digits of pci id, last digit is always 0 */
-       char* name; /* the user-friendly card name */
-       uint32_t class_3d; /* the object class this card uses for 3D */
-       uint32_t type; /* the major card family */
-       uint32_t flags;
-}
-nouveau_card;
-
-#define NV_HAS_LMA 0x00000001
-
-extern nouveau_card* nouveau_card_lookup(uint32_t device_id);
-
-#endif
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_card_list.h b/src/mesa/drivers/dri/nouveau/nouveau_card_list.h
deleted file mode 100644 (file)
index 8ec5c4a..0000000
+++ /dev/null
@@ -1,232 +0,0 @@
-static nouveau_card nouveau_card_list[]={
-{0x0008,  "EDGE 3D",                               0,                             NV_03, 0},
-{0x0009,  "EDGE 3D",                               0,                             NV_03, 0},
-{0x0010,  "Mutara V08",                            0,                             NV_03, 0},
-{0x0020,  "RIVA TNT",                              NV04_DX5_TEXTURED_TRIANGLE,    NV_04, 0},
-{0x0028,  "RIVA TNT2/TNT2 Pro",                    NV04_DX5_TEXTURED_TRIANGLE,    NV_04, 0},
-{0x0029,  "RIVA TNT2 Ultra",                       NV04_DX5_TEXTURED_TRIANGLE,    NV_04, 0},
-{0x002A,  "Riva TnT2",                             NV04_DX5_TEXTURED_TRIANGLE,    NV_04, 0},
-{0x002B,  "Riva TnT2",                             NV04_DX5_TEXTURED_TRIANGLE,    NV_04, 0},
-{0x002C,  "Vanta/Vanta LT",                        NV04_DX5_TEXTURED_TRIANGLE,    NV_04, 0},
-{0x002D,  "RIVA TNT2 Model 64/Model 64 Pro",       NV04_DX5_TEXTURED_TRIANGLE,    NV_04, 0},
-{0x002E,  "Vanta",                                 NV04_DX5_TEXTURED_TRIANGLE,    NV_04, 0},
-{0x002F,  "Vanta",                                 NV04_DX5_TEXTURED_TRIANGLE,    NV_04, 0},
-{0x0040,  "GeForce 6800 Ultra",                    NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0041,  "GeForce 6800",                          NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0042,  "GeForce 6800 LE",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0043,  "NV40.3",                                NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0044,  "GeForce 6800 XT",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0045,  "GeForce 6800 GT",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0046,  "GeForce 6800 GT",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0047,  "GeForce 6800 GS",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0048,  "GeForce 6800 XT",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0049,  "NV40GL",                                NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x004D,  "Quadro FX 4000",                        NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x004E,  "Quadro FX 4000",                        NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0090,  "GeForce 7800 GTX",                      NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0091,  "GeForce 7800 GTX",                      NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0092,  "GeForce 7800 GT",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0093,  "GeForce 7800 GS",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0098,  "GeForce Go 7800",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0099,  "GE Force Go 7800 GTX",                  NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x009D,  "Quadro FX4500",                         NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x00A0,  "Aladdin TNT2",                          NV04_DX5_TEXTURED_TRIANGLE,    NV_04, 0},
-{0x00C0,  "GeForce 6800 GS",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x00C1,  "GeForce 6800",                          NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x00C2,  "GeForce 6800 LE",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x00C3,  "Geforce 6800 XT",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x00C8,  "GeForce Go 6800",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x00C9,  "GeForce Go 6800 Ultra",                 NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x00CC,  "Quadro FX Go1400",                      NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x00CD,  "Quadro FX 3450/4000 SDI",               NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x00CE,  "Quadro FX 1400",                        NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x00F0,  "GeForce 6800/GeForce 6800 Ultra",       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x00F1,  "GeForce 6600/GeForce 6600 GT",          NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x00F2,  "GeForce 6600/GeForce 6600 GT",          NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x00F3,  "GeForce 6200",                          NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x00F4,  "GeForce 6600 LE",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x00F5,  "GeForce 7800 GS",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x00F6,  "GeForce 6600 GS",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x00F8,  "Quadro FX 3400/4400",                   NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x00F9,  "GeForce 6800 Ultra/GeForce 6800 GT",    NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x00FA,  "GeForce PCX 5750",                      NV30_TCL_PRIMITIVE_3D|0x0400,  NV_30, 0},
-{0x00FB,  "GeForce PCX 5900",                      NV30_TCL_PRIMITIVE_3D|0x0400,  NV_30, 0},
-{0x00FC,  "Quadro FX 330/GeForce PCX 5300",        NV30_TCL_PRIMITIVE_3D|0x0600,  NV_30, 0},
-{0x00FD,  "Quadro FX 330/Quadro NVS280",           NV30_TCL_PRIMITIVE_3D|0x0600,  NV_30, 0},
-{0x00FE,  "Quadro FX 1300",                        NV30_TCL_PRIMITIVE_3D|0x0400,  NV_30, 0},
-{0x00FF,  "GeForce PCX 4300",                      NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x0100,  "GeForce 256 SDR",                       NV10_TCL_PRIMITIVE_3D,         NV_10, 0},
-{0x0101,  "GeForce 256 DDR",                       NV10_TCL_PRIMITIVE_3D,         NV_10, 0},
-{0x0103,  "Quadro",                                NV10_TCL_PRIMITIVE_3D,         NV_10, 0},
-{0x0110,  "GeForce2 MX/MX 400",                    NV11_TCL_PRIMITIVE_3D,         NV_11, 0},
-{0x0111,  "GeForce2 MX 100 DDR/200 DDR",           NV11_TCL_PRIMITIVE_3D,         NV_11, 0},
-{0x0112,  "GeForce2 Go",                           NV11_TCL_PRIMITIVE_3D,         NV_11, 0},
-{0x0113,  "Quadro2 MXR/EX/Go",                     NV11_TCL_PRIMITIVE_3D,         NV_11, 0},
-{0x0140,  "GeForce 6600 GT",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0141,  "GeForce 6600",                          NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0142,  "GeForce 6600 PCIe",                     NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0144,  "GeForce Go 6600",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0145,  "GeForce 6610 XL",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0146,  "Geforce Go 6600TE/6200TE",              NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0148,  "GeForce Go 6600",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0149,  "GeForce Go 6600 GT",                    NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x014A,  "Quadro NVS 440",                        NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x014C,  "Quadro FX 550",                         NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x014D,  "Quadro FX 550",                         NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x014E,  "Quadro FX 540",                         NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x014F,  "GeForce 6200",                          NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0150,  "GeForce2 GTS/Pro",                      NV11_TCL_PRIMITIVE_3D,         NV_15, 0},
-{0x0151,  "GeForce2 Ti",                           NV11_TCL_PRIMITIVE_3D,         NV_15, 0},
-{0x0152,  "GeForce2 Ultra, Bladerunner",           NV11_TCL_PRIMITIVE_3D,         NV_15, 0},
-{0x0153,  "Quadro2 Pro",                           NV11_TCL_PRIMITIVE_3D,         NV_15, 0},
-{0x0161,  "GeForce 6200 TurboCache(TM)",           NV30_TCL_PRIMITIVE_3D|0x4400,  NV_44, 0},
-{0x0162,  "GeForce 6200 SE TurboCache (TM)",       NV30_TCL_PRIMITIVE_3D|0x4400,  NV_44, 0},
-{0x0163,  "GeForce 6200 LE",                       NV30_TCL_PRIMITIVE_3D|0x4400,  NV_44, 0},
-{0x0164,  "GeForce Go 6200",                       NV30_TCL_PRIMITIVE_3D|0x4400,  NV_44, 0},
-{0x0165,  "Quadro NVS 285",                        NV30_TCL_PRIMITIVE_3D|0x4400,  NV_44, 0},
-{0x0166,  "GeForce Go 6400",                       NV30_TCL_PRIMITIVE_3D|0x4400,  NV_44, 0},
-{0x0167,  "GeForce Go 6200 TurboCache",            NV30_TCL_PRIMITIVE_3D|0x4400,  NV_44, 0},
-{0x0168,  "GeForce Go 6200 TurboCache",            NV30_TCL_PRIMITIVE_3D|0x4400,  NV_44, 0},
-{0x0170,  "GeForce4 MX 460",                       NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x0171,  "GeForce4 MX 440",                       NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x0172,  "GeForce4 MX 420",                       NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x0173,  "GeForce4 MX 440-SE",                    NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x0174,  "GeForce4 440 Go",                       NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x0175,  "GeForce4 420 Go",                       NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x0176,  "GeForce4 420 Go 32M",                   NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x0177,  "GeForce4 460 Go",                       NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x0178,  "Quadro4 550 XGL",                       NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x0179,  "GeForce4 420 Go 32M",                   NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x017A,  "Quadro4 200/400 NVS",                   NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x017B,  "Quadro4 550 XGL",                       NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x017C,  "Quadro4 500 GoGL",                      NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x017D,  "GeForce4 410 Go 16M",                   NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x0181,  "GeForce4 MX 440 AGP 8x",                NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x0182,  "GeForce4 MX 440SE AGP 8x",              NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x0183,  "GeForce4 MX 420 AGP 8x",                NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x0185,  "GeForce4 MX 4000 AGP 8x",               NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x0186,  "GeForce4 448 Go",                       NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x0187,  "GeForce4 488 Go",                       NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x0188,  "Quadro4 580 XGL",                       NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x018A,  "Quadro4 NVS AGP 8x",                    NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x018B,  "Quadro4 380 XGL",                       NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x018C,  "Quadro NVS 50 PCI",                     NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x018D,  "GeForce4 448 Go",                       NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x0191,  "GeForce 8800 GTX",                      NV30_TCL_PRIMITIVE_3D|0x5000,  NV_50, 0},
-{0x0193,  "GeForce 8800 GTS",                      NV30_TCL_PRIMITIVE_3D|0x5000,  NV_50, 0},
-{0x01A0,  "GeForce2 MX Integrated Graphics",       NV11_TCL_PRIMITIVE_3D,         NV_11, 0},
-{0x01D1,  "GeForce 7300 LE",                       NV30_TCL_PRIMITIVE_3D|0x4400,  NV_44, 0},
-{0x01D6,  "GeForce Go 7200",                       NV30_TCL_PRIMITIVE_3D|0x4400,  NV_44, 0},
-{0x01D7,  "Quadro NVS 110M / GeForce Go 7300",     NV30_TCL_PRIMITIVE_3D|0x4400,  NV_44, 0},
-{0x01D8,  "GeForce Go 7400",                       NV30_TCL_PRIMITIVE_3D|0x4400,  NV_44, 0},
-{0x01DA,  "Quadro NVS 110M",                       NV30_TCL_PRIMITIVE_3D|0x4400,  NV_44, 0},
-{0x01DF,  "GeForce 7300 GS",                       NV30_TCL_PRIMITIVE_3D|0x4400,  NV_44, 0},
-{0x01F0,  "GeForce4 MX - nForce GPU",              NV17_TCL_PRIMITIVE_3D,         NV_17, 0},
-{0x0200,  "GeForce3",                              NV20_TCL_PRIMITIVE_3D,         NV_20, 0},
-{0x0201,  "GeForce3 Ti 200",                       NV20_TCL_PRIMITIVE_3D,         NV_20, 0},
-{0x0202,  "GeForce3 Ti 500",                       NV20_TCL_PRIMITIVE_3D,         NV_20, 0},
-{0x0203,  "Quadro DCC",                            NV20_TCL_PRIMITIVE_3D,         NV_20, 0},
-{0x0211,  "GeForce 6800",                          NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0212,  "GeForce 6800 LE",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0215,  "GeForce 6800 GT",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0218,  "GeForce 6800 XT",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0221,  "GeForce 6200",                          NV30_TCL_PRIMITIVE_3D|0x4400,  NV_44, 0},
-{0x0240,  "GeForce 6150",                          NV30_TCL_PRIMITIVE_3D|0x4400,  NV_44, 0},
-{0x0242,  "GeForce 6100",                          NV30_TCL_PRIMITIVE_3D|0x4400,  NV_44, 0},
-{0x0244,  "Geforce 6150 Go",                       NV30_TCL_PRIMITIVE_3D|0x4400,  NV_44, 0},
-{0x0250,  "GeForce4 Ti 4600",                      NV20_TCL_PRIMITIVE_3D|0x0500,  NV_25, 0},
-{0x0251,  "GeForce4 Ti 4400",                      NV20_TCL_PRIMITIVE_3D|0x0500,  NV_25, 0},
-{0x0252,  "GeForce4 Ti",                           NV20_TCL_PRIMITIVE_3D|0x0500,  NV_25, 0},
-{0x0253,  "GeForce4 Ti 4200",                      NV20_TCL_PRIMITIVE_3D|0x0500,  NV_25, 0},
-{0x0258,  "Quadro4 900 XGL",                       NV20_TCL_PRIMITIVE_3D|0x0500,  NV_25, 0},
-{0x0259,  "Quadro4 750 XGL",                       NV20_TCL_PRIMITIVE_3D|0x0500,  NV_25, 0},
-{0x025B,  "Quadro4 700 XGL",                       NV20_TCL_PRIMITIVE_3D|0x0500,  NV_25, 0},
-{0x0280,  "GeForce4 Ti 4800",                      NV20_TCL_PRIMITIVE_3D|0x0500,  NV_25, 0},
-{0x0281,  "GeForce4 Ti 4200 AGP 8x",               NV20_TCL_PRIMITIVE_3D|0x0500,  NV_25, 0},
-{0x0282,  "GeForce4 Ti 4800 SE",                   NV20_TCL_PRIMITIVE_3D|0x0500,  NV_25, 0},
-{0x0286,  "GeForce4 Ti 4200 Go AGP 8x",            NV20_TCL_PRIMITIVE_3D|0x0500,  NV_25, 0},
-{0x0288,  "Quadro4 980 XGL",                       NV20_TCL_PRIMITIVE_3D|0x0500,  NV_25, 0},
-{0x0289,  "Quadro4 780 XGL",                       NV20_TCL_PRIMITIVE_3D|0x0500,  NV_25, 0},
-{0x028C,  "Quadro4 700 GoGL",                      NV20_TCL_PRIMITIVE_3D|0x0500,  NV_25, 0},
-{0x0290,  "GeForce 7900 GTX",                      NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0291,  "GeForce 7900 GT",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0292,  "GeForce 7900 GS",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0298,  "GeForce Go 7900 GS",                    NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0299,  "GeForce Go 7900 GTX",                   NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x029A,  "Quadro FX 2500M",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x029B,  "Quadro FX 1500M",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x029C,  "Quadro FX 5500",                        NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x029D,  "Quadro FX 3500",                        NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x029E,  "Quadro FX 1500",                        NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x029F,  "Quadro FX 4500 X2",                     NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x02A0,  "XGPU",                                  NV20_TCL_PRIMITIVE_3D,         NV_20, 0},
-{0x02E1,  "GeForce 7600 GS",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0300,  "GeForce FX",                            NV30_TCL_PRIMITIVE_3D|0x0300,  NV_30, 0},
-{0x0301,  "GeForce FX 5800 Ultra",                 NV30_TCL_PRIMITIVE_3D|0x0300,  NV_30, 0},
-{0x0302,  "GeForce FX 5800",                       NV30_TCL_PRIMITIVE_3D|0x0300,  NV_30, 0},
-{0x0308,  "Quadro FX 2000",                        NV30_TCL_PRIMITIVE_3D|0x0300,  NV_30, 0},
-{0x0309,  "Quadro FX 1000",                        NV30_TCL_PRIMITIVE_3D|0x0300,  NV_30, 0},
-{0x0311,  "GeForce FX 5600 Ultra",                 NV30_TCL_PRIMITIVE_3D|0x0300,  NV_30, 0},
-{0x0312,  "GeForce FX 5600",                       NV30_TCL_PRIMITIVE_3D|0x0300,  NV_30, 0},
-{0x0313,  "NV31",                                  NV30_TCL_PRIMITIVE_3D|0x0300,  NV_30, 0},
-{0x0314,  "GeForce FX 5600XT",                     NV30_TCL_PRIMITIVE_3D|0x0300,  NV_30, 0},
-{0x0316,  "NV31M",                                 NV30_TCL_PRIMITIVE_3D|0x0300,  NV_30, 0},
-{0x0317,  "NV31M Pro",                             NV30_TCL_PRIMITIVE_3D|0x0300,  NV_30, 0},
-{0x031A,  "GeForce FX Go5600",                     NV30_TCL_PRIMITIVE_3D|0x0300,  NV_30, 0},
-{0x031B,  "GeForce FX Go5650",                     NV30_TCL_PRIMITIVE_3D|0x0300,  NV_30, 0},
-{0x031C,  "NVIDIA Quadro FX Go700",                NV30_TCL_PRIMITIVE_3D|0x0300,  NV_30, 0},
-{0x031D,  "NV31GLM",                               NV30_TCL_PRIMITIVE_3D|0x0300,  NV_30, 0},
-{0x031E,  "NV31GLM Pro",                           NV30_TCL_PRIMITIVE_3D|0x0300,  NV_30, 0},
-{0x031F,  "NV31GLM Pro",                           NV30_TCL_PRIMITIVE_3D|0x0300,  NV_30, 0},
-{0x0320,  "GeForce FX 5200",                       NV30_TCL_PRIMITIVE_3D|0x0600,  NV_34, 0},
-{0x0321,  "GeForce FX 5200 Ultra",                 NV30_TCL_PRIMITIVE_3D|0x0600,  NV_34, 0},
-{0x0322,  "GeForce FX 5200",                       NV30_TCL_PRIMITIVE_3D|0x0600,  NV_34, 0},
-{0x0323,  "GeForce FX 5200LE",                     NV30_TCL_PRIMITIVE_3D|0x0600,  NV_34, 0},
-{0x0324,  "GeForce FX Go5200",                     NV30_TCL_PRIMITIVE_3D|0x0600,  NV_34, 0},
-{0x0325,  "GeForce FX Go5250",                     NV30_TCL_PRIMITIVE_3D|0x0600,  NV_34, 0},
-{0x0326,  "GeForce FX 5500",                       NV30_TCL_PRIMITIVE_3D|0x0600,  NV_34, 0},
-{0x0327,  "GeForce FX 5100",                       NV30_TCL_PRIMITIVE_3D|0x0600,  NV_34, 0},
-{0x0328,  "GeForce FX Go5200 32M/64M",             NV30_TCL_PRIMITIVE_3D|0x0600,  NV_34, 0},
-{0x0329,  "GeForce FX Go5200",                     NV30_TCL_PRIMITIVE_3D|0x0600,  NV_34, 0},
-{0x032A,  "Quadro NVS 280 PCI",                    NV30_TCL_PRIMITIVE_3D|0x0600,  NV_34, 0},
-{0x032B,  "Quadro FX 500/600 PCI",                 NV30_TCL_PRIMITIVE_3D|0x0600,  NV_34, 0},
-{0x032C,  "GeForce FX Go 5300",                    NV30_TCL_PRIMITIVE_3D|0x0600,  NV_34, 0},
-{0x032D,  "GeForce FX Go5100",                     NV30_TCL_PRIMITIVE_3D|0x0600,  NV_34, 0},
-{0x032F,  "NV34GL",                                NV30_TCL_PRIMITIVE_3D|0x0600,  NV_34, 0},
-{0x0330,  "GeForce FX 5900 Ultra",                 NV30_TCL_PRIMITIVE_3D|0x0400,  NV_30, 0},
-{0x0331,  "GeForce FX 5900",                       NV30_TCL_PRIMITIVE_3D|0x0400,  NV_30, 0},
-{0x0332,  "GeForce FX 5900XT",                     NV30_TCL_PRIMITIVE_3D|0x0400,  NV_30, 0},
-{0x0333,  "GeForce FX 5950 Ultra",                 NV30_TCL_PRIMITIVE_3D|0x0400,  NV_30, 0},
-{0x0334,  "GeForce FX 5900ZT",                     NV30_TCL_PRIMITIVE_3D|0x0400,  NV_30, 0},
-{0x0338,  "Quadro FX 3000",                        NV30_TCL_PRIMITIVE_3D|0x0400,  NV_30, 0},
-{0x033F,  "Quadro FX 700",                         NV30_TCL_PRIMITIVE_3D|0x0400,  NV_30, 0},
-{0x0341,  "GeForce FX 5700 Ultra",                 NV30_TCL_PRIMITIVE_3D|0x0400,  NV_30, 0},
-{0x0342,  "GeForce FX 5700",                       NV30_TCL_PRIMITIVE_3D|0x0400,  NV_30, 0},
-{0x0343,  "GeForce FX 5700LE",                     NV30_TCL_PRIMITIVE_3D|0x0400,  NV_30, 0},
-{0x0344,  "GeForce FX 5700VE",                     NV30_TCL_PRIMITIVE_3D|0x0400,  NV_30, 0},
-{0x0345,  "NV36.5",                                NV30_TCL_PRIMITIVE_3D|0x0400,  NV_30, 0},
-{0x0347,  "GeForce FX Go5700",                     NV30_TCL_PRIMITIVE_3D|0x0400,  NV_30, 0},
-{0x0348,  "GeForce FX Go5700",                     NV30_TCL_PRIMITIVE_3D|0x0400,  NV_30, 0},
-{0x0349,  "NV36M Pro",                             NV30_TCL_PRIMITIVE_3D|0x0400,  NV_30, 0},
-{0x034B,  "NV36MAP",                               NV30_TCL_PRIMITIVE_3D|0x0400,  NV_30, 0},
-{0x034C,  "Quadro FX Go1000",                      NV30_TCL_PRIMITIVE_3D|0x0400,  NV_30, 0},
-{0x034E,  "Quadro FX 1100",                        NV30_TCL_PRIMITIVE_3D|0x0400,  NV_30, 0},
-{0x034F,  "NV36GL",                                NV30_TCL_PRIMITIVE_3D|0x0400,  NV_30, 0},
-{0x0391,  "GeForce 7600 GT",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0392,  "GeForce 7600 GS",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0393,  "GeForce 7300 GT",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x0398,  "GeForce Go 7600",                       NV30_TCL_PRIMITIVE_3D|0x4000,  NV_40, 0},
-{0x03D0,  "GeForce 6100 nForce 430",               NV30_TCL_PRIMITIVE_3D|0x4400,  NV_44, 0},
-{0x03D1,  "GeForce 6100 nForce 405",               NV30_TCL_PRIMITIVE_3D|0x4400,  NV_44, 0},
-{0x03D2,  "GeForce 6100 nForce 400",               NV30_TCL_PRIMITIVE_3D|0x4400,  NV_44, 0},
-{0x03D5,  "GeForce 6100 nForce 420",               NV30_TCL_PRIMITIVE_3D|0x4400,  NV_44, 0},
-{0x0008,  "NV1",                                   0,                             NV_03, 0},
-{0x0009,  "DAC64",                                 0,                             NV_03, 0},
-{0x0018,  "Riva128",                               0,                             NV_03, 0},
-{0x0019,  "Riva128ZX",                             0,                             NV_03, 0},
-{0x0020,  "TNT",                                   NV04_DX5_TEXTURED_TRIANGLE,    NV_04, 0},
-{0x0028,  "TNT2",                                  NV04_DX5_TEXTURED_TRIANGLE,    NV_04, 0},
-{0x0029,  "UTNT2",                                 NV04_DX5_TEXTURED_TRIANGLE,    NV_04, 0},
-{0x002C,  "VTNT2",                                 NV04_DX5_TEXTURED_TRIANGLE,    NV_04, 0},
-{0x00A0,  "ITNT2",                                 NV04_DX5_TEXTURED_TRIANGLE,    NV_04, 0},
-};
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c
deleted file mode 100644 (file)
index 44392c0..0000000
+++ /dev/null
@@ -1,380 +0,0 @@
-/**************************************************************************
-
-Copyright 2006 Stephane Marchesin
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-#include "glheader.h"
-#include "context.h"
-#include "simple_list.h"
-#include "imports.h"
-#include "matrix.h"
-#include "swrast/swrast.h"
-#include "swrast_setup/swrast_setup.h"
-#include "framebuffer.h"
-
-#include "tnl/tnl.h"
-#include "tnl/t_pipeline.h"
-#include "tnl/t_vp_build.h"
-
-#include "drivers/common/driverfuncs.h"
-
-#include "nouveau_context.h"
-#include "nouveau_driver.h"
-//#include "nouveau_state.h"
-#include "nouveau_span.h"
-#include "nouveau_object.h"
-#include "nouveau_fifo.h"
-#include "nouveau_tex.h"
-#include "nouveau_msg.h"
-#include "nouveau_reg.h"
-#include "nouveau_lock.h"
-#include "nouveau_query.h"
-#include "nv04_swtcl.h"
-#include "nv10_swtcl.h"
-
-#include "vblank.h"
-#include "utils.h"
-#include "texmem.h"
-#include "xmlpool.h" /* for symbolic values of enum-type options */
-
-#ifndef NOUVEAU_DEBUG
-int NOUVEAU_DEBUG = 0;
-#endif
-
-static const struct dri_debug_control debug_control[] =
-{
-       { "shaders"   , DEBUG_SHADERS    },
-       { "mem"       , DEBUG_MEM        },
-       { "bufferobj" , DEBUG_BUFFEROBJ  },
-       { NULL        , 0                }
-};
-
-#define need_GL_ARB_vertex_program
-#define need_GL_ARB_occlusion_query
-#include "extension_helper.h"
-
-const struct dri_extension common_extensions[] =
-{
-       { NULL,    0 }
-};
-
-const struct dri_extension nv10_extensions[] =
-{
-       { NULL,    0 }
-};
-
-const struct dri_extension nv20_extensions[] =
-{
-       { NULL,    0 }
-};
-
-const struct dri_extension nv30_extensions[] =
-{
-       { "GL_ARB_fragment_program",    NULL                            },
-       { NULL,    0 }
-};
-
-const struct dri_extension nv40_extensions[] =
-{
-   /* ARB_vp can be moved to nv20/30 once the shader backend has been
-    * written for those cards.
-    */
-       { "GL_ARB_vertex_program",      GL_ARB_vertex_program_functions },
-       { "GL_ARB_occlusion_query",     GL_ARB_occlusion_query_functions},
-       { NULL, 0 }
-};
-
-const struct dri_extension nv50_extensions[] =
-{
-       { NULL,    0 }
-};
-
-/* Create the device specific context.
- */
-GLboolean nouveauCreateContext( const __GLcontextModes *glVisual,
-               __DRIcontextPrivate *driContextPriv,
-               void *sharedContextPrivate )
-{
-       GLcontext *ctx, *shareCtx;
-       __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
-       struct dd_function_table functions;
-       nouveauContextPtr nmesa;
-       nouveauScreenPtr screen;
-
-       /* Allocate the context */
-       nmesa = (nouveauContextPtr) CALLOC( sizeof(*nmesa) );
-       if ( !nmesa )
-               return GL_FALSE;
-
-       nmesa->driContext = driContextPriv;
-       nmesa->driScreen = sPriv;
-       nmesa->driDrawable = NULL;
-       nmesa->hHWContext = driContextPriv->hHWContext;
-       nmesa->driHwLock = &sPriv->pSAREA->lock;
-       nmesa->driFd = sPriv->fd;
-
-       nmesa->screen = (nouveauScreenPtr)(sPriv->private);
-       screen=nmesa->screen;
-
-       /* Create the hardware context */
-       if (!nouveauDRMGetParam(nmesa, NOUVEAU_GETPARAM_FB_PHYSICAL,
-                               &nmesa->vram_phys))
-          return GL_FALSE;
-       if (!nouveauDRMGetParam(nmesa, NOUVEAU_GETPARAM_FB_SIZE,
-                               &nmesa->vram_size))
-          return GL_FALSE;
-       if (!nouveauDRMGetParam(nmesa, NOUVEAU_GETPARAM_AGP_PHYSICAL,
-                               &nmesa->gart_phys))
-          return GL_FALSE;
-       if (!nouveauDRMGetParam(nmesa, NOUVEAU_GETPARAM_AGP_SIZE,
-                               &nmesa->gart_size))
-          return GL_FALSE;
-       if (!nouveauFifoInit(nmesa))
-          return GL_FALSE;
-       nouveauObjectInit(nmesa);
-
-
-       /* Init default driver functions then plug in our nouveau-specific functions
-        * (the texture functions are especially important)
-        */
-       _mesa_init_driver_functions( &functions );
-       nouveauDriverInitFunctions( &functions );
-       nouveauTexInitFunctions( &functions );
-
-       /* Allocate the Mesa context */
-       if (sharedContextPrivate)
-               shareCtx = ((nouveauContextPtr) sharedContextPrivate)->glCtx;
-       else 
-               shareCtx = NULL;
-       nmesa->glCtx = _mesa_create_context(glVisual, shareCtx,
-                       &functions, (void *) nmesa);
-       if (!nmesa->glCtx) {
-               FREE(nmesa);
-               return GL_FALSE;
-       }
-       driContextPriv->driverPrivate = nmesa;
-       ctx = nmesa->glCtx;
-
-       /* Parse configuration files */
-       driParseConfigFiles (&nmesa->optionCache, &screen->optionCache,
-                       screen->driScreen->myNum, "nouveau");
-
-       nmesa->sarea = (struct drm_nouveau_sarea *)((char *)sPriv->pSAREA +
-                       screen->sarea_priv_offset);
-
-       /* Enable any supported extensions */
-       driInitExtensions(ctx, common_extensions, GL_TRUE);
-       if (nmesa->screen->card->type >= NV_10)
-               driInitExtensions(ctx, nv10_extensions, GL_FALSE);
-       if (nmesa->screen->card->type >= NV_20)
-               driInitExtensions(ctx, nv20_extensions, GL_FALSE);
-       if (nmesa->screen->card->type >= NV_30)
-               driInitExtensions(ctx, nv30_extensions, GL_FALSE);
-       if (nmesa->screen->card->type >= NV_40)
-               driInitExtensions(ctx, nv40_extensions, GL_FALSE);
-       if (nmesa->screen->card->type >= NV_50)
-               driInitExtensions(ctx, nv50_extensions, GL_FALSE);
-
-       nmesa->current_primitive = -1;
-
-       nouveauShaderInitFuncs(ctx);
-       /* Install Mesa's fixed-function texenv shader support */
-       if (nmesa->screen->card->type >= NV_40)
-               ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
-
-       /* Initialize the swrast */
-       _swrast_CreateContext( ctx );
-       _vbo_CreateContext( ctx );
-       _tnl_CreateContext( ctx );
-       _swsetup_CreateContext( ctx );
-
-       _math_matrix_ctr(&nmesa->viewport);
-
-       nouveauDDInitStateFuncs( ctx );
-       nouveauSpanInitFunctions( ctx );
-       nouveauDDInitState( nmesa );
-       switch(nmesa->screen->card->type)
-       {
-               case NV_03:
-                       //nv03TriInitFunctions( ctx );
-                       break;
-               case NV_04:
-               case NV_05:
-                       nv04TriInitFunctions( ctx );
-                       break;
-               case NV_10:
-               case NV_11:
-               case NV_17:
-               case NV_20:
-               case NV_30:
-               case NV_40:
-               case NV_44:
-               case NV_50:
-               default:
-                       nv10TriInitFunctions( ctx );
-                       break;
-       }
-
-       nouveauInitBufferObjects(ctx);
-       if (!nouveauSyncInitFuncs(ctx))
-          return GL_FALSE;
-       nouveauQueryInitFuncs(ctx);
-       nmesa->hw_func.InitCard(nmesa);
-        nouveauInitState(ctx);
-
-       driContextPriv->driverPrivate = (void *)nmesa;
-
-       NOUVEAU_DEBUG = driParseDebugString( getenv( "NOUVEAU_DEBUG" ),
-                       debug_control );
-
-       if (driQueryOptionb(&nmesa->optionCache, "no_rast")) {
-               fprintf(stderr, "disabling 3D acceleration\n");
-               FALLBACK(nmesa, NOUVEAU_FALLBACK_DISABLE, 1);
-       }
-
-       return GL_TRUE;
-}
-
-/* Destroy the device specific context. */
-void nouveauDestroyContext( __DRIcontextPrivate *driContextPriv  )
-{
-       nouveauContextPtr nmesa = (nouveauContextPtr) driContextPriv->driverPrivate;
-
-       assert(nmesa);
-       if ( nmesa ) {
-               /* free the option cache */
-               driDestroyOptionCache (&nmesa->optionCache);
-
-               FREE( nmesa );
-       }
-
-}
-
-
-/* Force the context `c' to be the current context and associate with it
- * buffer `b'.
- */
-GLboolean nouveauMakeCurrent( __DRIcontextPrivate *driContextPriv,
-               __DRIdrawablePrivate *driDrawPriv,
-               __DRIdrawablePrivate *driReadPriv )
-{
-       if ( driContextPriv ) {
-               nouveauContextPtr nmesa = (nouveauContextPtr) driContextPriv->driverPrivate;
-               struct gl_framebuffer *draw_fb =
-                       (struct gl_framebuffer*)driDrawPriv->driverPrivate;
-               struct gl_framebuffer *read_fb =
-                       (struct gl_framebuffer*)driReadPriv->driverPrivate;
-
-               driDrawableInitVBlank(driDrawPriv, nmesa->vblank_flags, &nmesa->vblank_seq );
-               nmesa->driDrawable = driDrawPriv;
-
-               _mesa_resize_framebuffer(nmesa->glCtx, draw_fb,
-                                        driDrawPriv->w, driDrawPriv->h);
-               if (draw_fb != read_fb) {
-                       _mesa_resize_framebuffer(nmesa->glCtx, draw_fb,
-                                                driReadPriv->w,
-                                                driReadPriv->h);
-               }
-               _mesa_make_current(nmesa->glCtx, draw_fb, read_fb);
-
-               nouveau_build_framebuffer(nmesa->glCtx,
-                                         driDrawPriv->driverPrivate);
-       } else {
-               _mesa_make_current( NULL, NULL, NULL );
-       }
-
-       return GL_TRUE;
-}
-
-
-/* Force the context `c' to be unbound from its buffer.
- */
-GLboolean nouveauUnbindContext( __DRIcontextPrivate *driContextPriv )
-{
-       return GL_TRUE;
-}
-
-static void nouveauDoSwapBuffers(nouveauContextPtr nmesa,
-                                __DRIdrawablePrivate *dPriv)
-{
-       struct gl_framebuffer *fb;
-       nouveau_renderbuffer *src, *dst;
-       drm_clip_rect_t *box;
-       int nbox, i;
-
-       fb = (struct gl_framebuffer *)dPriv->driverPrivate;
-       dst = (nouveau_renderbuffer*)
-               fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
-       src = (nouveau_renderbuffer*)
-               fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer;
-
-#ifdef ALLOW_MULTI_SUBCHANNEL
-       LOCK_HARDWARE(nmesa);
-       nbox = dPriv->numClipRects;
-       box  = dPriv->pClipRects;
-
-       if (nbox) {
-               BEGIN_RING_SIZE(NvSubCtxSurf2D,
-                               NV10_CONTEXT_SURFACES_2D_FORMAT, 4);
-               if (src->mesa._ActualFormat == GL_RGBA8)
-                       OUT_RING       (6); /* X8R8G8B8 */
-               else
-                       OUT_RING       (4); /* R5G6B5 */
-               OUT_RING       ((dst->pitch << 16) | src->pitch);
-               OUT_RING       (src->offset);
-               OUT_RING       (dst->offset);
-       }
-
-       for (i=0; i<nbox; i++, box++) {
-               BEGIN_RING_SIZE(NvSubImageBlit, NV10_IMAGE_BLIT_SET_POINT, 3);
-               OUT_RING       (((box->y1 - dPriv->y) << 16) |
-                               (box->x1 - dPriv->x));
-               OUT_RING       ((box->y1 << 16) | box->x1);
-               OUT_RING       (((box->y2 - box->y1) << 16) |
-                               (box->x2 - box->x1));
-       }
-       FIRE_RING();
-
-       UNLOCK_HARDWARE(nmesa);
-#endif
-}
-
-void nouveauSwapBuffers(__DRIdrawablePrivate *dPriv)
-{
-       if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
-               nouveauContextPtr nmesa = dPriv->driContextPriv->driverPrivate;
-
-               if (nmesa->glCtx->Visual.doubleBufferMode) {
-                       _mesa_notifySwapBuffers(nmesa->glCtx);
-                       nouveauDoSwapBuffers(nmesa, dPriv);
-               }
-
-       }
-}
-
-void nouveauCopySubBuffer(__DRIdrawablePrivate *dPriv,
-                         int x, int y, int w, int h)
-{
-}
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_ctrlreg.h b/src/mesa/drivers/dri/nouveau/nouveau_ctrlreg.h
deleted file mode 100644 (file)
index c9b2d59..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/**************************************************************************
-
-Copyright 2006 Stephane Marchesin, Sylvain Munaut
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-
-
-
-#define NV03_STATUS                                        0x004006b0
-#define NV04_STATUS                                        0x00400700
-
-#define NV03_FIFO_REGS_SIZE                                0x10000
-#    define NV03_FIFO_REGS_DMAPUT                          0x00000040
-#    define NV03_FIFO_REGS_DMAGET                          0x00000044
-
-/* Fifo commands. These are not regs, neither masks */
-#define NV03_FIFO_CMD_JUMP                                 0x20000000
-#define NV03_FIFO_CMD_JUMP_OFFSET_MASK                     0x1ffffffc
-#define NV03_FIFO_CMD_REWIND                               (NV03_FIFO_CMD_JUMP | (0 & NV03_FIFO_CMD_JUMP_OFFSET_MASK))
-
-
-#define NONINC_METHOD                                      0x40000000
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_dri.h b/src/mesa/drivers/dri/nouveau/nouveau_dri.h
deleted file mode 100644 (file)
index ce3c3fb..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef _NOUVEAU_DRI_
-#define _NOUVEAU_DRI_
-
-#include "xf86drm.h"
-#include "drm.h"
-#include "nouveau_drm.h"
-
-typedef struct {
-       uint32_t device_id;     /**< \brief PCI device ID */
-       uint32_t width;         /**< \brief width in pixels of display */
-       uint32_t height;        /**< \brief height in scanlines of display */
-       uint32_t depth;         /**< \brief depth of display (8, 15, 16, 24) */
-       uint32_t bpp;           /**< \brief bit depth of display (8, 16, 24, 32) */
-
-       uint32_t bus_type;      /**< \brief ths bus type */
-       uint32_t bus_mode;      /**< \brief bus mode (used for AGP, maybe also for PCI-E ?) */
-
-       uint32_t front_offset;  /**< \brief front buffer offset */
-       uint32_t front_pitch;   /**< \brief front buffer pitch */
-       uint32_t back_offset;   /**< \brief private back buffer offset */
-       uint32_t back_pitch;    /**< \brief private back buffer pitch */
-       uint32_t depth_offset;  /**< \brief private depth buffer offset */
-       uint32_t depth_pitch;   /**< \brief private depth buffer pitch */
-
-} NOUVEAUDRIRec, *NOUVEAUDRIPtr;
-
-#endif
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_driver.c b/src/mesa/drivers/dri/nouveau/nouveau_driver.c
deleted file mode 100644 (file)
index ddc9535..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-/**************************************************************************
-
-Copyright 2006 Stephane Marchesin
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-#include "nouveau_context.h"
-//#include "nouveau_state.h"
-#include "nouveau_lock.h"
-#include "nouveau_fifo.h"
-#include "nouveau_driver.h"
-#include "swrast/swrast.h"
-
-#include "context.h"
-#include "framebuffer.h"
-
-#include "utils.h"
-
-/* Wrapper for DRM_NOUVEAU_GETPARAM ioctl */
-GLboolean nouveauDRMGetParam(nouveauContextPtr nmesa,
-                            unsigned int      param,
-                            uint64_t*         value)
-{
-       struct drm_nouveau_getparam getp;
-
-       getp.param = param;
-       if (!value || drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_GETPARAM,
-                                         &getp, sizeof(getp)))
-               return GL_FALSE;
-       *value = getp.value;
-       return GL_TRUE;
-}
-
-/* Wrapper for DRM_NOUVEAU_GETPARAM ioctl */
-GLboolean nouveauDRMSetParam(nouveauContextPtr nmesa,
-                            unsigned int      param,
-                            uint64_t          value)
-{
-       struct drm_nouveau_setparam setp;
-
-       setp.param = param;
-       setp.value = value;
-       if (drmCommandWrite(nmesa->driFd, DRM_NOUVEAU_SETPARAM, &setp,
-                               sizeof(setp)))
-               return GL_FALSE;
-       return GL_TRUE;
-}
-
-/* Return the width and height of the current color buffer */
-static void nouveauGetBufferSize( GLframebuffer *buffer,
-               GLuint *width, GLuint *height )
-{
-       GET_CURRENT_CONTEXT(ctx);
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       LOCK_HARDWARE( nmesa );
-       *width  = nmesa->driDrawable->w;
-       *height = nmesa->driDrawable->h;
-       UNLOCK_HARDWARE( nmesa );
-}
-
-/* glGetString */
-static const GLubyte *nouveauGetString( GLcontext *ctx, GLenum name )
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       static char buffer[128];
-       const char * card_name = "Unknown";
-       GLuint agp_mode = 0;
-
-       switch ( name ) {
-               case GL_VENDOR:
-                       return (GLubyte *)DRIVER_AUTHOR;
-
-               case GL_RENDERER:
-                       card_name=nmesa->screen->card->name;
-
-                       switch(nmesa->screen->bus_type)
-                       {
-                               case NV_PCI:
-                               case NV_PCIE:
-                               default:
-                                       agp_mode=0;
-                                       break;
-                               case NV_AGP:
-                                       agp_mode=nmesa->screen->agp_mode;
-                                       break;
-                       }
-                       driGetRendererString( buffer, card_name, DRIVER_DATE,
-                                       agp_mode );
-                       return (GLubyte *)buffer;
-               default:
-                       return NULL;
-       }
-}
-
-/* glFlush */
-static void nouveauFlush( GLcontext *ctx )
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       FIRE_RING();
-}
-
-/* glFinish */
-static void nouveauFinish( GLcontext *ctx )
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       nouveauFlush( ctx );
-       nouveauWaitForIdle( nmesa );
-}
-
-/* glClear */
-static void nouveauClear( GLcontext *ctx, GLbitfield mask )
-{
-       // XXX we really should do something here...
-}
-
-void nouveauDriverInitFunctions( struct dd_function_table *functions )
-{
-       functions->GetBufferSize        = nouveauGetBufferSize;
-       functions->ResizeBuffers        = _mesa_resize_framebuffer;
-       functions->GetString            = nouveauGetString;
-       functions->Flush                = nouveauFlush;
-       functions->Finish               = nouveauFinish;
-       functions->Clear                = nouveauClear;
-}
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_driver.h b/src/mesa/drivers/dri/nouveau/nouveau_driver.h
deleted file mode 100644 (file)
index 6164012..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/**************************************************************************
-
-Copyright 2006 Stephane Marchesin
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-
-
-#ifndef __NOUVEAU_DRIVER_H__
-#define __NOUVEAU_DRIVER_H__
-
-#define DRIVER_DATE    "20060219"
-#define DRIVER_AUTHOR  "Stephane Marchesin"
-
-extern void nouveauDriverInitFunctions( struct dd_function_table *functions );
-extern GLboolean nouveauDRMGetParam(nouveauContextPtr nmesa, unsigned int param,
-                                   uint64_t *value);
-extern GLboolean nouveauDRMSetParam(nouveauContextPtr nmesa, unsigned int param,
-                                   uint64_t value);
-
-#endif /* __NOUVEAU_DRIVER_H__ */
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_lock.c b/src/mesa/drivers/dri/nouveau/nouveau_lock.c
deleted file mode 100644 (file)
index aa86c9e..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/**************************************************************************
-
-Copyright 2006 Stephane Marchesin
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-
-#include "nouveau_context.h"
-#include "nouveau_lock.h"
-
-#include "drirenderbuffer.h"
-#include "framebuffer.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 nouveauGetLock( nouveauContextPtr nmesa, GLuint flags )
-{
-   __DRIdrawablePrivate *dPriv = nmesa->driDrawable;
-   __DRIscreenPrivate *sPriv = nmesa->driScreen;
-   struct drm_nouveau_sarea *sarea = nmesa->sarea;
-
-   drmGetLock( nmesa->driFd, nmesa->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 timestamps don't match, the window has been changed */
-   if (nmesa->lastStamp != dPriv->lastStamp) {
-      struct gl_framebuffer *fb = (struct gl_framebuffer *)dPriv->driverPrivate;
-
-      /* _mesa_resize_framebuffer will take care of calling the renderbuffer's
-       * AllocStorage function if we need more memory to hold it */
-      if (fb->Width != dPriv->w || fb->Height != dPriv->h) {
-        _mesa_resize_framebuffer(nmesa->glCtx, fb, dPriv->w, dPriv->h);
-        /* resize buffers, will call nouveau_window_moved */
-        nouveau_build_framebuffer(nmesa->glCtx, fb);
-      } else {
-        nouveau_window_moved(nmesa->glCtx);
-      }
-
-      nmesa->lastStamp = dPriv->lastStamp;
-   }
-
-   nmesa->numClipRects = dPriv->numClipRects;
-   nmesa->pClipRects = dPriv->pClipRects;
-
-}
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_lock.h b/src/mesa/drivers/dri/nouveau/nouveau_lock.h
deleted file mode 100644 (file)
index 38bb001..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/**************************************************************************
-
-Copyright 2006 Stephane Marchesin
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-
-#ifndef __NOUVEAU_LOCK_H__
-#define __NOUVEAU_LOCK_H__
-
-#include "nouveau_context.h"
-
-extern void nouveauGetLock( nouveauContextPtr nmesa, GLuint flags );
-
-/*
- * !!! 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( nmesa )                                         \
-   do {                                                                        \
-      char __ret = 0;                                                  \
-      DEBUG_CHECK_LOCK();                                              \
-      DRM_CAS( nmesa->driHwLock, nmesa->hHWContext,                    \
-              (DRM_LOCK_HELD | nmesa->hHWContext), __ret );            \
-      if ( __ret )                                                     \
-        nouveauGetLock( nmesa, 0 );                                    \
-      DEBUG_LOCK();                                                    \
-   } while (0)
-
-/* Unlock the hardware.
- */
-#define UNLOCK_HARDWARE( nmesa )                                       \
-   do {                                                                        \
-      DRM_UNLOCK( nmesa->driFd,                                                \
-                 nmesa->driHwLock,                                     \
-                 nmesa->hHWContext );                                  \
-      DEBUG_RESET();                                                   \
-   } while (0)
-
-#define DEBUG_LOCK()
-#define DEBUG_RESET()
-#define DEBUG_CHECK_LOCK()
-
-
-#endif /* __NOUVEAU_LOCK_H__ */
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_msg.h b/src/mesa/drivers/dri/nouveau/nouveau_msg.h
deleted file mode 100644 (file)
index 5dea218..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
-Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.
-Copyright 2006 Stephane Marchesin. 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 __NOUVEAU_MSG_H__
-#define __NOUVEAU_MSG_H__
-
-#define WARN_ONCE(a, ...) do {\
-               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;\
-                                       } \
-               }while(0)
-
-#define MESSAGE(a, ...) do{\
-                       fprintf(stderr, "************************************INFO***********************************\n");\
-                       fprintf(stderr, "File %s function %s line %d\n", __FILE__, __FUNCTION__, __LINE__); \
-                       fprintf(stderr,  a, ## __VA_ARGS__);\
-                       fprintf(stderr, "***************************************************************************\n");\
-               }while(0)
-
-#define FATAL(a, ...) do{\
-                       fprintf(stderr, "***********************************FATAL***********************************\n");\
-                       fprintf(stderr, "File %s function %s line %d\n", __FILE__, __FUNCTION__, __LINE__); \
-                       fprintf(stderr,  a, ## __VA_ARGS__);\
-                       fprintf(stderr, "***************************************************************************\n");\
-               }while(0)
-
-#endif /* __NOUVEAU_MSG_H__ */
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_object.c b/src/mesa/drivers/dri/nouveau/nouveau_object.c
deleted file mode 100644 (file)
index a143488..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-
-#include "nouveau_fifo.h"
-#include "nouveau_object.h"
-#include "nouveau_reg.h"
-
-
-GLboolean nouveauCreateContextObject(nouveauContextPtr nmesa,
-                                    uint32_t handle, int class)
-{
-       struct drm_nouveau_grobj_alloc cto;
-       int ret;
-
-       cto.channel = nmesa->fifo.channel;
-       cto.handle  = handle;
-       cto.class   = class;
-       ret = drmCommandWrite(nmesa->driFd, DRM_NOUVEAU_GROBJ_ALLOC,
-                             &cto, sizeof(cto));
-
-       return ret == 0;
-}
-
-void nouveauObjectOnSubchannel(nouveauContextPtr nmesa, int subchannel, int handle)
-{
-       BEGIN_RING_SIZE(subchannel, 0, 1);
-       OUT_RING(handle);
-}
-
-void nouveauObjectInit(nouveauContextPtr nmesa)
-{
-#ifdef NOUVEAU_RING_DEBUG
-       return;
-#endif
-
-       nouveauCreateContextObject(nmesa, Nv3D, nmesa->screen->card->class_3d);
-       if (nmesa->screen->card->type>=NV_10) {
-               nouveauCreateContextObject(nmesa, NvCtxSurf2D, NV10_CONTEXT_SURFACES_2D);
-       } else {
-               nouveauCreateContextObject(nmesa, NvCtxSurf2D, NV04_CONTEXT_SURFACES_2D);
-               nouveauCreateContextObject(nmesa, NvCtxSurf3D, NV04_CONTEXT_SURFACES_3D);
-       }
-       if (nmesa->screen->card->type>=NV_11) {
-               nouveauCreateContextObject(nmesa, NvImageBlit, NV10_IMAGE_BLIT);
-       } else {
-               nouveauCreateContextObject(nmesa, NvImageBlit, NV_IMAGE_BLIT);
-       }
-       nouveauCreateContextObject(nmesa, NvMemFormat, NV_MEMORY_TO_MEMORY_FORMAT);
-
-#ifdef ALLOW_MULTI_SUBCHANNEL
-       nouveauObjectOnSubchannel(nmesa, NvSubCtxSurf2D, NvCtxSurf2D);
-       BEGIN_RING_SIZE(NvSubCtxSurf2D, NV10_CONTEXT_SURFACES_2D_SET_DMA_IN_MEMORY0, 2);
-       OUT_RING(NvDmaFB);
-       OUT_RING(NvDmaFB);
-
-       nouveauObjectOnSubchannel(nmesa, NvSubImageBlit, NvImageBlit);
-       BEGIN_RING_SIZE(NvSubImageBlit, NV10_IMAGE_BLIT_SET_CONTEXT_SURFACES_2D, 1);
-       OUT_RING(NvCtxSurf2D);
-       BEGIN_RING_SIZE(NvSubImageBlit, NV10_IMAGE_BLIT_SET_OPERATION, 1);
-       OUT_RING(3); /* SRCCOPY */
-
-       nouveauObjectOnSubchannel(nmesa, NvSubMemFormat, NvMemFormat);
-#endif
-
-       nouveauObjectOnSubchannel(nmesa, NvSub3D, Nv3D);
-}
-
-
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_object.h b/src/mesa/drivers/dri/nouveau/nouveau_object.h
deleted file mode 100644 (file)
index 8c72d01..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef __NOUVEAU_OBJECT_H__
-#define __NOUVEAU_OBJECT_H__
-
-#include "nouveau_context.h"
-
-#define ALLOW_MULTI_SUBCHANNEL
-
-void nouveauObjectInit(nouveauContextPtr nmesa);
-
-enum DMAObjects {
-       Nv3D                    = 0x80000019,
-       NvCtxSurf2D             = 0x80000020,
-       NvImageBlit             = 0x80000021,
-       NvMemFormat             = 0x80000022,
-       NvCtxSurf3D             = 0x80000023,
-       NvDmaFB                 = 0xD0FB0001,
-       NvDmaTT                 = 0xD0AA0001,
-       NvSyncNotify            = 0xD0000001,
-       NvQueryNotify           = 0xD0000002
-};
-
-enum DMASubchannel {
-       NvSubCtxSurf2D  = 0,
-       NvSubImageBlit  = 1,
-       NvSubMemFormat  = 2,
-       NvSubCtxSurf3D  = 3,
-       NvSub3D         = 7,
-};
-
-extern void nouveauObjectOnSubchannel(nouveauContextPtr nmesa, int subchannel, int handle);
-
-extern GLboolean nouveauCreateContextObject(nouveauContextPtr nmesa,
-                                           uint32_t handle, int class);
-
-#endif
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_query.c b/src/mesa/drivers/dri/nouveau/nouveau_query.c
deleted file mode 100644 (file)
index 0154140..0000000
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright (C) 2007 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.
- *
- */
-
-/* GL_ARB_occlusion_query support for NV20/30/40 */
-
-#include "mtypes.h"
-
-#include "nouveau_fifo.h"
-#include "nouveau_msg.h"
-#include "nouveau_object.h"
-#include "nouveau_reg.h"
-#include "nouveau_sync.h"
-#include "nouveau_query.h"
-
-static struct gl_query_object *
-nouveauNewQueryObject(GLcontext *ctx, GLuint id)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       nouveau_query_object *nq;
-       int i;
-
-       for (i=0; i<nmesa->query_object_max; i++)
-               if (nmesa->query_alloc[i] == GL_FALSE)
-                       break;
-       if (i==nmesa->query_object_max)
-               return NULL;
-
-       nq = CALLOC_STRUCT(nouveau_query_object_t);
-       if (nq) {
-               nq->notifier_id = i;
-
-               nq->mesa.Id     = id;
-               nq->mesa.Result = 0;
-               nq->mesa.Active = GL_FALSE;
-               nq->mesa.Ready  = GL_TRUE;
-       }
-
-       return (struct gl_query_object *)nq;
-}
-
-static void
-nouveauBeginQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       nouveau_query_object *nq = (nouveau_query_object *)q;
-
-       nouveau_notifier_reset(ctx, nmesa->queryNotifier, nq->notifier_id);
-
-       switch (nmesa->screen->card->type) {
-       case NV_20:
-               BEGIN_RING_CACHE(NvSub3D, 0x17c8, 1);
-               OUT_RING_CACHE  (1);
-               BEGIN_RING_CACHE(NvSub3D, 0x17cc, 1);
-               OUT_RING_CACHE  (1);
-               break;
-       case NV_30:
-       case NV_40:
-       case NV_44:
-               /* I don't think this is OCC_QUERY enable, but it *is* needed to make
-                * the SET_OBJECT7 notifier block work with STORE_RESULT.
-                *
-                * Also, this appears to reset the pixel pass counter */
-               BEGIN_RING_SIZE(NvSub3D,
-                                NV30_TCL_PRIMITIVE_3D_OCC_QUERY_OR_COLOR_BUFF_ENABLE,
-                                1);
-               OUT_RING        (1);
-               /* Probably OCC_QUERY_ENABLE */
-               BEGIN_RING_CACHE(NvSub3D, 0x17cc, 1);
-               OUT_RING_CACHE  (1);
-               break;
-       default:
-               WARN_ONCE("no support for this card\n");
-               break;
-       }
-}
-
-static void
-nouveauUpdateQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       nouveau_query_object *nq = (nouveau_query_object *)q;
-       int status;
-
-       status = nouveau_notifier_status(ctx, nmesa->queryNotifier,
-                                        nq->notifier_id);
-
-       q->Ready = (status == NV_NOTIFY_STATE_STATUS_COMPLETED);
-       if (q->Ready)
-               q->Result = nouveau_notifier_return_val(ctx,
-                                                       nmesa->queryNotifier,
-                                                       nq->notifier_id);
-}
-
-static void
-nouveauWaitQueryResult(GLcontext *ctx, GLenum target, struct gl_query_object *q)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       nouveau_query_object *nq = (nouveau_query_object *)q;
-
-       nouveau_notifier_wait_status(ctx, nmesa->queryNotifier, nq->notifier_id,
-                                    NV_NOTIFY_STATE_STATUS_COMPLETED, 0);
-       nouveauUpdateQuery(ctx, target, q);
-}
-
-static void
-nouveauEndQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q)
-{
-       nouveau_query_object *nq = (nouveau_query_object *)q;
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       switch (nmesa->screen->card->type) {
-       case NV_20:
-               BEGIN_RING_SIZE(NvSub3D, 0x17d0, 1);
-               OUT_RING       (0x01000000 | nq->notifier_id*32);
-               break;
-       case NV_30:
-       case NV_40:
-       case NV_44:
-               BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_STORE_RESULT, 1);
-               OUT_RING       (0x01000000 | nq->notifier_id*32);
-               break;
-       default:
-               WARN_ONCE("no support for this card\n");
-               break;
-       }
-       FIRE_RING();
-
-       /*XXX: wait for query to complete, mesa doesn't give the driver
-        *     an interface to query the status of a query object so 
-        *     this has to stall the channel.
-        */
-       nouveauWaitQueryResult(ctx, target, q);
-
-       BEGIN_RING_CACHE(NvSub3D, 0x17cc, 1);
-       OUT_RING_CACHE  (0);
-}
-
-void
-nouveauQueryInitFuncs(GLcontext *ctx)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       if (nmesa->screen->card->type < NV_20)
-               return;
-
-       nmesa->query_object_max = (0x4000 / 32);
-       nmesa->queryNotifier =
-               nouveau_notifier_new(ctx, NvQueryNotify,
-                                         nmesa->query_object_max);
-       nmesa->query_alloc = calloc(nmesa->query_object_max, sizeof(GLboolean));
-
-       switch (nmesa->screen->card->type) {
-       case NV_20:
-               BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_SET_OBJECT8, 1);
-               OUT_RING_CACHE  (NvQueryNotify);
-               break;
-       case NV_30:
-       case NV_40:
-       case NV_44:
-               BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_SET_OBJECT7, 1);
-               OUT_RING_CACHE  (NvQueryNotify);
-               break;
-       default:
-               break;
-       };
-
-       ctx->Driver.NewQueryObject      = nouveauNewQueryObject;
-       ctx->Driver.BeginQuery          = nouveauBeginQuery;
-       ctx->Driver.EndQuery            = nouveauEndQuery;
-#if 0
-       ctx->Driver.UpdateQuery         = nouveauUpdateQuery;
-       ctx->Driver.WaitQueryResult     = nouveauWaitQueryResult;
-#endif
-}
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_query.h b/src/mesa/drivers/dri/nouveau/nouveau_query.h
deleted file mode 100644 (file)
index 3ded414..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2007 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.
- *
- */
-
-#ifndef __NOUVEAU_QUERY_H__
-#define __NOUVEAU_QUERY_H__
-
-typedef struct nouveau_query_object_t {
-       struct gl_query_object mesa;
-
-       int notifier_id;
-} nouveau_query_object;
-
-extern void nouveauQueryInitFuncs(GLcontext *ctx);
-#endif
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_reg.h b/src/mesa/drivers/dri/nouveau/nouveau_reg.h
deleted file mode 100644 (file)
index 8758b53..0000000
+++ /dev/null
@@ -1,1505 +0,0 @@
-/*
-   Autogenerated file, do not edit !
-
-**************************************************************************
-
-   Copyright (C) 2006 :
-   Dmitry Baryshkov,
-   Laurent Carlier,
-   Matthieu Castet,
-   Dawid Gajownik,
-   Jeremy Kolb,
-   Stephane Loeuillet,
-   Patrice Mandin,
-   Stephane Marchesin,
-   Serge Martin,
-   Sylvain Munaut,
-   Ben Skeggs,
-   Erik Waling,
-   koala_br,
-   sturmflut.
-
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial
-portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
-
-**************************************************************************
-
-   Created from objects.c rev. 1.398
-*/
-
-#ifndef _NOUVEAU_REG_H
-#define _NOUVEAU_REG_H
-
-/****************************************** 
-Object NV01_CONTEXT_CLIP_RECTANGLE used on: NV03 NV04 NV10 NV15 NV20 NV40 G70
-*/
-#define                        NV01_CONTEXT_CLIP_RECTANGLE                             0x00000019
-#      define          NV01_CONTEXT_CLIP_RECTANGLE_SET_POINT                   0x00000300      /* Parameters: x y */
-#      define          NV01_CONTEXT_CLIP_RECTANGLE_SET_SIZE                    0x00000304      /* Parameters: width height */
-
-/****************************************** 
-Object NV_MEMORY_TO_MEMORY_FORMAT used on: NV04 NV10 NV15 NV20 NV30 NV40 G70
-*/
-#define                        NV_MEMORY_TO_MEMORY_FORMAT                              0x00000039
-#      define          NV_MEMORY_TO_MEMORY_FORMAT_NOP                          0x00000100
-#      define          NV_MEMORY_TO_MEMORY_FORMAT_NOTIFY                       0x00000104
-#      define          NV_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY                   0x00000180
-#      define          NV_MEMORY_TO_MEMORY_FORMAT_OBJECT_IN                    0x00000184
-#      define          NV_MEMORY_TO_MEMORY_FORMAT_OBJECT_OUT                   0x00000188
-#      define          NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN                    0x0000030c
-#      define          NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_OUT                   0x00000310
-#      define          NV_MEMORY_TO_MEMORY_FORMAT_PITCH_IN                     0x00000314
-#      define          NV_MEMORY_TO_MEMORY_FORMAT_PITCH_OUT                    0x00000318
-#      define          NV_MEMORY_TO_MEMORY_FORMAT_LINE_LENGTH_IN               0x0000031c
-#      define          NV_MEMORY_TO_MEMORY_FORMAT_LINE_COUNT                   0x00000320
-#      define          NV_MEMORY_TO_MEMORY_FORMAT_FORMAT                       0x00000324      /* Parameters: src_inc dst_inc */
-#      define          NV_MEMORY_TO_MEMORY_FORMAT_BUF_NOTIFY                   0x00000328
-
-/****************************************** 
-Object NV03_PRIMITIVE_RASTER_OP used on: NV03 NV04 NV10 NV15 NV20 NV30 NV40 G70
-*/
-#define                        NV03_PRIMITIVE_RASTER_OP                                0x00000043
-#      define          NV03_PRIMITIVE_RASTER_OP_NOTIFY                         0x00000100
-#      define          NV03_PRIMITIVE_RASTER_OP_DMA_NOTIFY                     0x00000180
-#      define          NV03_PRIMITIVE_RASTER_OP_LOGIC_OP                       0x00000300      /* Parameters: logic_op */
-
-/****************************************** 
-Object NV04_GDI_RECTANGLE_TEXT used on: NV04 NV10 NV15 NV20 NV30 NV40 G70
-*/
-#define                        NV04_GDI_RECTANGLE_TEXT                                 0x0000004a
-#      define          NV04_GDI_RECTANGLE_TEXT_SET_DMA_NOTIFY                  0x00000180
-#      define          NV04_GDI_RECTANGLE_TEXT_PATTERN                         0x00000188
-#      define          NV04_GDI_RECTANGLE_TEXT_ROP5                            0x0000018c
-#      define          NV04_GDI_RECTANGLE_TEXT_SURFACE                         0x00000198
-#      define          NV04_GDI_RECTANGLE_TEXT_OPERATION                       0x000002fc
-#      define          NV04_GDI_RECTANGLE_TEXT_FORMAT                          0x00000300
-#      define          NV04_GDI_RECTANGLE_TEXT_BLOCK_LEVEL1_TL                 0x000005f4      /* Parameters: left top */
-#      define          NV04_GDI_RECTANGLE_TEXT_BLOCK_LEVEL1_BR                 0x000005f8      /* Parameters: right bottom */
-#      define          NV04_GDI_RECTANGLE_TEXT_FILL_VALUE                      0x000005fc
-#      define          NV04_GDI_RECTANGLE_TEXT_BLOCK_LEVEL2_TL                 0x00000600      /* Parameters: left top */
-#      define          NV04_GDI_RECTANGLE_TEXT_BLOCK_LEVEL2_BR                 0x00000604      /* Parameters: right bottom */
-
-/****************************************** 
-Object NV04_SWIZZLED_SURFACE used on: NV04 NV10 NV15 
-*/
-#define                        NV04_SWIZZLED_SURFACE                                   0x00000052
-#      define          NV04_SWIZZLED_SURFACE_DMA_NOTIFY                        0x00000180
-#      define          NV04_SWIZZLED_SURFACE_DMA_IMAGE                         0x00000184
-#      define          NV04_SWIZZLED_SURFACE_FORMAT                            0x00000300      /* Parameters: log2(height) log2(width) color */
-#      define          NV04_SWIZZLED_SURFACE_OFFSET                            0x00000304
-
-/****************************************** 
-Object NV04_CONTEXT_SURFACES_3D used on: NV04 
-*/
-#define                        NV04_CONTEXT_SURFACES_3D                                0x00000053
-#      define          NV04_CONTEXT_SURFACES_3D_DMA_NOTIFY                     0x00000180
-#      define          NV04_CONTEXT_SURFACES_3D_DMA_COLOR                      0x00000184
-#      define          NV04_CONTEXT_SURFACES_3D_DMA_ZETA                       0x00000188
-#      define          NV04_CONTEXT_SURFACES_3D_CLIP_HORIZONTAL                0x000002f8      /* Parameters: x width */
-#      define          NV04_CONTEXT_SURFACES_3D_CLIP_VERTICAL                  0x000002fc      /* Parameters: y height */
-#      define          NV04_CONTEXT_SURFACES_3D_FORMAT                         0x00000300      /* Parameters: color type width height */
-#      define          NV04_CONTEXT_SURFACES_3D_CLIP_SIZE                      0x00000304      /* Parameters: width height */
-#      define          NV04_CONTEXT_SURFACES_3D_PITCH                          0x00000308      /* Parameters: color zeta */
-#      define          NV04_CONTEXT_SURFACES_3D_OFFSET_COLOR                   0x0000030c
-#      define          NV04_CONTEXT_SURFACES_3D_OFFSET_ZETA                    0x00000310
-
-/****************************************** 
-Object NV04_DX5_TEXTURED_TRIANGLE used on: NV04 
-*/
-#define                        NV04_DX5_TEXTURED_TRIANGLE                              0x00000054
-#      define          NV04_DX5_TEXTURED_TRIANGLE_NOP                          0x00000100
-#      define          NV04_DX5_TEXTURED_TRIANGLE_NOTIFY                       0x00000104
-#      define          NV04_DX5_TEXTURED_TRIANGLE_DMA_NOTIFY                   0x00000180
-#      define          NV04_DX5_TEXTURED_TRIANGLE_DMA_1                        0x00000184
-#      define          NV04_DX5_TEXTURED_TRIANGLE_DMA_2                        0x00000188
-#      define          NV04_DX5_TEXTURED_TRIANGLE_SURFACE                      0x0000018c
-#      define          NV04_DX5_TEXTURED_TRIANGLE_COLOR_KEY                    0x00000300
-#      define          NV04_DX5_TEXTURED_TRIANGLE_TEXTURE_OFFSET               0x00000304
-#      define          NV04_DX5_TEXTURED_TRIANGLE_TEXTURE_FORMAT               0x00000308      /* Parameters: color mipmaps log(u) log(v) wrap_s wrap_t */
-#      define          NV04_DX5_TEXTURED_TRIANGLE_TEXTURE_FILTER               0x0000030c      /* Parameters: magfilter minfilter lodbias */
-#      define          NV04_DX5_TEXTURED_TRIANGLE_BLEND                        0x00000310      /* Parameters: texture benable dst src */
-#      define          NV04_DX5_TEXTURED_TRIANGLE_CONTROL                      0x00000314      /* Parameters: alpharef alphafunc alphaenable zenable zwrite zfunc cullmode */
-#      define          NV04_DX5_TEXTURED_TRIANGLE_FOG_COLOR                    0x00000318
-#      define          NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX( d)              (0x00000400 + d * 0x0020)
-#      define          NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SY( d)              (0x00000404 + d * 0x0020)
-#      define          NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SZ( d)              (0x00000408 + d * 0x0020)
-#      define          NV04_DX5_TEXTURED_TRIANGLE_INV_W( d)                    (0x0000040c + d * 0x0020)
-#      define          NV04_DX5_TEXTURED_TRIANGLE_COLOR( d)                    (0x00000410 + d * 0x0020)
-#      define          NV04_DX5_TEXTURED_TRIANGLE_SPECULAR( d)                 (0x00000414 + d * 0x0020)
-#      define          NV04_DX5_TEXTURED_TRIANGLE_TEXTURE_S( d)                (0x00000418 + d * 0x0020)
-#      define          NV04_DX5_TEXTURED_TRIANGLE_TEXTURE_T( d)                (0x0000041c + d * 0x0020)
-#      define          NV04_DX5_TEXTURED_TRIANGLE_DRAW                         0x00000600      /* Parameters: v0 v1 v2 v3 v4 v5 */
-
-/****************************************** 
-Object NV04_DX6_MULTITEX_TRIANGLE used on: NV04 NV10 NV15 
-*/
-#define                        NV04_DX6_MULTITEX_TRIANGLE                              0x00000055
-#      define          NV04_DX6_MULTITEX_TRIANGLE_NOP                          0x00000100
-#      define          NV04_DX6_MULTITEX_TRIANGLE_NOTIFY                       0x00000104
-#      define          NV04_DX6_MULTITEX_TRIANGLE_DMA_NOTIFY                   0x00000180
-#      define          NV04_DX6_MULTITEX_TRIANGLE_DMA_1                        0x00000184
-#      define          NV04_DX6_MULTITEX_TRIANGLE_DMA_2                        0x00000188
-#      define          NV04_DX6_MULTITEX_TRIANGLE_SURFACE                      0x0000018c
-#      define          NV04_DX6_MULTITEX_TRIANGLE_OFFSET0                      0x00000308
-#      define          NV04_DX6_MULTITEX_TRIANGLE_OFFSET1                      0x0000030c
-#      define          NV04_DX6_MULTITEX_TRIANGLE_FORMAT0                      0x00000310      /* Parameters: color mipmaps log(u) log(v) wrap_s wrap_t */
-#      define          NV04_DX6_MULTITEX_TRIANGLE_FORMAT1                      0x00000314      /* Parameters: color mipmaps log(u) log(v) wrap_s wrap_t */
-#      define          NV04_DX6_MULTITEX_TRIANGLE_FILTER0                      0x00000318      /* Parameters: magfilter minfilter lodbias */
-#      define          NV04_DX6_MULTITEX_TRIANGLE_FILTER1                      0x0000031c      /* Parameters: magfilter minfilter lodbias */
-#      define          NV04_DX6_MULTITEX_TRIANGLE_COMBINE_0_ALPHA              0x00000320
-#      define          NV04_DX6_MULTITEX_TRIANGLE_COMBINE_0_COLOR              0x00000324
-#      define          NV04_DX6_MULTITEX_TRIANGLE_COMBINE_1_ALPHA              0x0000032c
-#      define          NV04_DX6_MULTITEX_TRIANGLE_COMBINE_1_COLOR              0x00000330
-#      define          NV04_DX6_MULTITEX_TRIANGLE_COMBINE_FACTOR               0x00000334
-#      define          NV04_DX6_MULTITEX_TRIANGLE_BLEND                        0x00000338      /* Parameters: benable dst src */
-#      define          NV04_DX6_MULTITEX_TRIANGLE_CONTROL0                     0x0000033c      /* Parameters: red_write green_write blue_write alpha_write alpha_write stencil_write alpharef alphafunc alphaenable zenable zwrite zfunc cullmode */
-#      define          NV04_DX6_MULTITEX_TRIANGLE_CONTROL1                     0x00000340      /* Parameters: stencil_enable stencil_mask_write stencil_mask_read stencilref stencilfunc */
-#      define          NV04_DX6_MULTITEX_TRIANGLE_CONTROL2                     0x00000344      /* Parameters: stencil_fail stencil_zfail stencil_zpass */
-#      define          NV04_DX6_MULTITEX_TRIANGLE_FOG_COLOR                    0x00000348
-#      define          NV04_DX6_MULTITEX_TRIANGLE_TLVERTEX_SX( d)              (0x00000400 + d * 0x0028)
-#      define          NV04_DX6_MULTITEX_TRIANGLE_TLVERTEX_SY( d)              (0x00000404 + d * 0x0028)
-#      define          NV04_DX6_MULTITEX_TRIANGLE_TLVERTEX_SZ( d)              (0x00000408 + d * 0x0028)
-#      define          NV04_DX6_MULTITEX_TRIANGLE_INV_W( d)                    (0x0000040c + d * 0x0028)
-#      define          NV04_DX6_MULTITEX_TRIANGLE_COLOR( d)                    (0x00000410 + d * 0x0028)
-#      define          NV04_DX6_MULTITEX_TRIANGLE_SPECULAR( d)                 (0x00000414 + d * 0x0028)
-#      define          NV04_DX6_MULTITEX_TRIANGLE_TEXTURE0_S( d)               (0x00000418 + d * 0x0028)
-#      define          NV04_DX6_MULTITEX_TRIANGLE_TEXTURE0_T( d)               (0x0000041c + d * 0x0028)
-#      define          NV04_DX6_MULTITEX_TRIANGLE_TEXTURE1_S( d)               (0x00000420 + d * 0x0028)
-#      define          NV04_DX6_MULTITEX_TRIANGLE_TEXTURE1_T( d)               (0x00000424 + d * 0x0028)
-#      define          NV04_DX6_MULTITEX_TRIANGLE_DRAW                         0x00000540      /* Parameters: v0 v1 v2 v3 v4 v5 */
-
-/****************************************** 
-Object NV04_COLOR_KEY used on: NV04 NV10 NV15 NV20 NV40 
-*/
-#define                        NV04_COLOR_KEY                                          0x00000057
-#      define          NV04_COLOR_KEY_SET_DMA_NOTIFY                           0x00000180
-#      define          NV04_COLOR_KEY_FORMAT                                   0x00000300
-#      define          NV04_COLOR_KEY_VALUE                                    0x00000304
-
-/****************************************** 
-Object NV04_SOLID_LINE used on: NV04 
-*/
-#define                        NV04_SOLID_LINE                                         0x0000005c
-#      define          NV04_SOLID_LINE_CLIP_RECTANGLE                          0x00000184
-#      define          NV04_SOLID_LINE_PATTERN                                 0x00000188
-#      define          NV04_SOLID_LINE_ROP                                     0x0000018c
-#      define          NV04_SOLID_LINE_SURFACE                                 0x00000198
-#      define          NV04_SOLID_LINE_OPERATION                               0x000002fc
-#      define          NV04_SOLID_LINE_COLOR_FORMAT                            0x00000300
-#      define          NV04_SOLID_LINE_COLOR_VALUE                             0x00000304
-#      define          NV04_SOLID_LINE_START                                   0x00000400      /* Parameters: x y */
-#      define          NV04_SOLID_LINE_END                                     0x00000400      /* Parameters: x y */
-
-/****************************************** 
-Object NV04_UNK005E used on: NV04 
-*/
-#define                        NV04_UNK005E                                            0x0000005e
-#      define          NV04_UNK005E_SET_SURFACE                                0x00000198
-#      define          NV04_UNK005E_UNK02fc                                    0x000002fc
-#      define          NV04_UNK005E_UNK0300                                    0x00000300
-#      define          NV04_UNK005E_COUNTER                                    0x00000304
-
-/****************************************** 
-Object NV05_SCALED_IMAGE_FROM_MEMORY used on: NV04 
-*/
-#define                        NV05_SCALED_IMAGE_FROM_MEMORY                           0x00000063
-#      define          NV05_SCALED_IMAGE_FROM_MEMORY_SURFACE                   0x00000198
-#      define          NV05_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION          0x000002fc
-#      define          NV05_SCALED_IMAGE_FROM_MEMORY_OPERATION                 0x00000304
-
-/****************************************** 
-Object NV04_SCALED_IMAGE_FROM_MEMORY used on: NV04 
-*/
-#define                        NV04_SCALED_IMAGE_FROM_MEMORY                           0x00000077
-#      define          NV04_SCALED_IMAGE_FROM_MEMORY_DMA_NOTIFY                0x00000180
-#      define          NV04_SCALED_IMAGE_FROM_MEMORY_DMA_IMAGE                 0x00000184
-#      define          NV04_SCALED_IMAGE_FROM_MEMORY_SURFACE                   0x00000198
-#      define          NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT              0x00000300
-#      define          NV04_SCALED_IMAGE_FROM_MEMORY_OPERATION                 0x00000304
-#      define          NV04_SCALED_IMAGE_FROM_MEMORY_CLIP_POS                  0x00000308      /* Parameters: x y */
-#      define          NV04_SCALED_IMAGE_FROM_MEMORY_CLIP_SIZE                 0x0000030c      /* Parameters: width height */
-#      define          NV04_SCALED_IMAGE_FROM_MEMORY_OUT_POS                   0x00000310      /* Parameters: x y */
-#      define          NV04_SCALED_IMAGE_FROM_MEMORY_OUT_SIZE                  0x00000314      /* Parameters: width height */
-#      define          NV04_SCALED_IMAGE_FROM_MEMORY_DU_DX                     0x00000318      /* Parameters: int frac*0x100000 */
-#      define          NV04_SCALED_IMAGE_FROM_MEMORY_DV_DY                     0x0000031c      /* Parameters: int frac*0x100000 */
-#      define          NV04_SCALED_IMAGE_FROM_MEMORY_SIZE                      0x00000400      /* Parameters: width height */
-#      define          NV04_SCALED_IMAGE_FROM_MEMORY_FORMAT                    0x00000404      /* Parameters: pitch origin filter */
-#      define          NV04_SCALED_IMAGE_FROM_MEMORY_OFFSET                    0x00000408
-#      define          NV04_SCALED_IMAGE_FROM_MEMORY_POINT                     0x0000040c      /* Parameters: u_int u_frac*0x10 v_int v_frac*0x10 */
-
-/****************************************** 
-Object NV_IMAGE_FROM_CPU used on: NV04 
-*/
-#define                        NV_IMAGE_FROM_CPU                                       0x00000061
-#      define          NV_IMAGE_FROM_CPU_DMA_NOTIFY                            0x00000180
-#      define          NV_IMAGE_FROM_CPU_CLIP_RECTANGLE                        0x00000188
-#      define          NV_IMAGE_FROM_CPU_PATTERN                               0x0000018c
-#      define          NV_IMAGE_FROM_CPU_ROP                                   0x00000190
-#      define          NV_IMAGE_FROM_CPU_SURFACE                               0x0000019c
-#      define          NV_IMAGE_FROM_CPU_OPERATION                             0x000002fc
-#      define          NV_IMAGE_FROM_CPU_FORMAT                                0x00000300
-
-/****************************************** 
-Object NV05_IMAGE_FROM_CPU used on: NV04 
-*/
-#define                        NV05_IMAGE_FROM_CPU                                     0x00000065
-#      define          NV05_IMAGE_FROM_CPU_DMA_NOTIFY                          0x00000180
-#      define          NV05_IMAGE_FROM_CPU_CLIP_RECTANGLE                      0x00000188
-#      define          NV05_IMAGE_FROM_CPU_PATTERN                             0x0000018c
-#      define          NV05_IMAGE_FROM_CPU_ROP                                 0x00000190
-#      define          NV05_IMAGE_FROM_CPU_SURFACE                             0x0000019c
-#      define          NV05_IMAGE_FROM_CPU_OPERATION                           0x000002fc
-#      define          NV05_IMAGE_FROM_CPU_FORMAT                              0x00000300
-#      define          NV05_IMAGE_FROM_CPU_POINT                               0x00000304      /* Parameters: x y */
-#      define          NV05_IMAGE_FROM_CPU_SIZE_OUT                            0x00000308      /* Parameters: x y */
-#      define          NV05_IMAGE_FROM_CPU_SIZE_IN                             0x0000030c      /* Parameters: x y */
-#      define          NV05_IMAGE_FROM_CPU_COLOR( d)                           (0x00000400 + d * 0x0004)
-
-/****************************************** 
-Object NV_IMAGE_BLIT used on: NV04 NV10 NV15 NV20 NV40 
-*/
-#define                        NV_IMAGE_BLIT                                           0x0000005f
-#      define          NV_IMAGE_BLIT_DMA_NOTIFY                                0x00000180
-#      define          NV_IMAGE_BLIT_COLOR_KEY                                 0x00000184
-#      define          NV_IMAGE_BLIT_CLIP_RECTANGLE                            0x00000188
-#      define          NV_IMAGE_BLIT_PATTERN                                   0x0000018c
-#      define          NV_IMAGE_BLIT_ROP5                                      0x00000190
-#      define          NV_IMAGE_BLIT_SURFACE                                   0x0000019c
-#      define          NV_IMAGE_BLIT_OPERATION                                 0x000002fc
-#      define          NV_IMAGE_BLIT_POINT_IN                                  0x00000300      /* Parameters: x y */
-#      define          NV_IMAGE_BLIT_POINT_OUT                                 0x00000304      /* Parameters: x y */
-#      define          NV_IMAGE_BLIT_SIZE                                      0x00000308      /* Parameters: width height */
-
-/****************************************** 
-Object NV10_TCL_PRIMITIVE_3D used on: NV10 
-*/
-#define                        NV10_TCL_PRIMITIVE_3D                                   0x00000056
-
-/****************************************** 
-Object NV17_TCL_PRIMITIVE_3D used on: NV15 
-*/
-#define                        NV17_TCL_PRIMITIVE_3D                                   0x00000099
-
-/****************************************** 
-Object NV11_TCL_PRIMITIVE_3D used on: NV15 
-*/
-#define                        NV11_TCL_PRIMITIVE_3D                                   0x00000096
-#      define          NV10_TCL_PRIMITIVE_3D_NOP                               0x00000100
-#      define          NV10_TCL_PRIMITIVE_3D_NOTIFY                            0x00000104
-#      define          NV10_TCL_PRIMITIVE_3D_SET_DMA_NOTIFY                    0x00000180
-#      define          NV10_TCL_PRIMITIVE_3D_SET_DMA_IN_MEMORY0                0x00000184
-#      define          NV10_TCL_PRIMITIVE_3D_SET_DMA_IN_MEMORY1                0x00000188
-#      define          NV10_TCL_PRIMITIVE_3D_SET_DISPLAY_LIST                  0x0000018c
-#      define          NV10_TCL_PRIMITIVE_3D_SET_DMA_IN_MEMORY2                0x00000194
-#      define          NV10_TCL_PRIMITIVE_3D_SET_DMA_IN_MEMORY3                0x00000198
-#      define          NV17_TCL_PRIMITIVE_3D_SET_DMA_IN_MEMORY4                0x000001ac
-#      define          NV17_TCL_PRIMITIVE_3D_SET_DMA_IN_MEMORY5                0x000001b0
-#      define          NV10_TCL_PRIMITIVE_3D_VIEWPORT_HORIZ                    0x00000200      /* Parameters: width x */
-#      define          NV10_TCL_PRIMITIVE_3D_VIEWPORT_VERT                     0x00000204      /* Parameters: height y */
-#      define          NV10_TCL_PRIMITIVE_3D_BUFFER_FORMAT                     0x00000208      /* Parameters: type color */
-#      define          NV10_TCL_PRIMITIVE_3D_BUFFER_PITCH                      0x0000020c      /* Parameters: depth/stencil buffer pitch color buffer pitch */
-#      define          NV10_TCL_PRIMITIVE_3D_COLOR_OFFSET                      0x00000210
-#      define          NV10_TCL_PRIMITIVE_3D_DEPTH_OFFSET                      0x00000214
-#      define          NV10_TCL_PRIMITIVE_3D_TX_OFFSET(d)                      (0x00000218 + d * 0x0004)
-#      define          NV10_TCL_PRIMITIVE_3D_TX_FORMAT(d)                      (0x00000220 + d * 0x0004)       /* Parameters: wrap_t wrap_s log2(height) log2(width) lod npot format cube_map */
-#      define          NV10_TCL_PRIMITIVE_3D_TX_ENABLE(d)                      (0x00000228 + d * 0x0004)       /* Parameters: enable anisotropy */
-#      define          NV10_TCL_PRIMITIVE_3D_TX_NPOT_PITCH(d)                  (0x00000230 + d * 0x0004)       /* Parameters: pitch */
-#      define          NV10_TCL_PRIMITIVE_3D_TX_NPOT_SIZE(d)                   (0x00000240 + d * 0x0004)       /* Parameters: width height */
-#      define          NV10_TCL_PRIMITIVE_3D_TX_FILTER(d)                      (0x00000248 + d * 0x0004)       /* Parameters: mag_filter min_filter */
-#      define          NV10_TCL_PRIMITIVE_3D_TX_PALETTE_OFFSET(d)              (0x00000250 + d * 0x0004)
-#      define          NV10_TCL_PRIMITIVE_3D_TX_MATRIX_ENABLE(d)               (0x000003e0 + d * 0x0004)
-#      define          NV10_TCL_PRIMITIVE_3D_TX_MATRIX(x,y)                    (0x00000540 + y * 0x0010 + x * 0x0004)
-#      define          NV10_TCL_PRIMITIVE_3D_RC_IN_ALPHA(d)                    (0x00000260 + d * 0x0004)       /* Parameters: vara_mapping vara_component_usage vara_input varb_mapping varb_component_usage varb_input varc_mapping varc_component_usage varc_input vard_mapping vard_component_usage vard_input */
-#      define          NV10_TCL_PRIMITIVE_3D_RC_IN_RGB(d)                      (0x00000268 + d * 0x0004)       /* Parameters: vara_mapping vara_component_usage vara_input varb_mapping varb_component_usage varb_input varc_mapping varc_component_usage varc_input vard_mapping vard_component_usage vard_input */
-#      define          NV10_TCL_PRIMITIVE_3D_RC_OUT_ALPHA(d)                   (0x00000278 + d * 0x0004)       /* Parameters: scale bias mux_sum ab_dot_product cd_dot_product sum_output ab_output cd_output */
-#      define          NV10_TCL_PRIMITIVE_3D_RC_OUT_RGB(d)                     (0x00000280 + d * 0x0004)       /* Parameters: rc1_tx_units_enabled rc1_rc_enabled scale bias mux_sum ab_dot_product cd_dot_product sum_output ab_output cd_output */
-#      define          NV10_TCL_PRIMITIVE_3D_RC_COLOR0                         0x00000270      /* Parameters: a r g b */
-#      define          NV10_TCL_PRIMITIVE_3D_RC_COLOR1                         0x00000274      /* Parameters: a r g b */
-#      define          NV10_TCL_PRIMITIVE_3D_RC_FINAL0                         0x00000288      /* Parameters: vara_mapping vara_component_usage vara_input varb_mapping varb_component_usage varb_input varc_mapping varc_component_usage varc_input vard_mapping vard_component_usage vard_input */
-#      define          NV10_TCL_PRIMITIVE_3D_RC_FINAL1                         0x0000028c      /* Parameters: vare_mapping vare_component_usage vare_input varf_mapping varf_component_usage varf_input varg_mapping varg_component_usage varg_input color_sum_clamp */
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_MODEL                       0x00000294      /* Parameters: local_viewer color_control */
-#      define          NV10_TCL_PRIMITIVE_3D_COLOR_MATERIAL_ENABLE             0x00000298      /* Parameters: specular diffuse ambient emission */
-#      define          NV10_TCL_PRIMITIVE_3D_FOG_MODE                          0x0000029c
-#      define          NV10_TCL_PRIMITIVE_3D_FOG_COORD_DIST                    0x000002a0
-#      define          NV10_TCL_PRIMITIVE_3D_FOG_ENABLE                        0x000002a4
-#      define          NV10_TCL_PRIMITIVE_3D_FOG_COLOR                         0x000002a8      /* Parameters: a b g r */
-#      define          NV17_TCL_PRIMITIVE_3D_COLOR_MASK_ENABLE                 0x000002bc
-#      define          NV10_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(d)            (0x000002c0 + d * 0x0004)       /* Parameters: x2 x1 */
-#      define          NV10_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_VERT(d)             (0x000002e0 + d * 0x0004)       /* Parameters: y2 y1 */
-#      define          NV10_TCL_PRIMITIVE_3D_ALPHA_FUNC_ENABLE                 0x00000300
-#      define          NV10_TCL_PRIMITIVE_3D_BLEND_FUNC_ENABLE                 0x00000304
-#      define          NV10_TCL_PRIMITIVE_3D_CULL_FACE_ENABLE                  0x00000308
-#      define          NV10_TCL_PRIMITIVE_3D_DEPTH_TEST_ENABLE                 0x0000030c
-#      define          NV10_TCL_PRIMITIVE_3D_DITHER_ENABLE                     0x00000310
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHTING_ENABLE                   0x00000314
-#      define          NV10_TCL_PRIMITIVE_3D_POINT_PARAMETERS_ENABLE           0x00000318
-#      define          NV10_TCL_PRIMITIVE_3D_POINT_SMOOTH_ENABLE               0x0000031c
-#      define          NV10_TCL_PRIMITIVE_3D_LINE_SMOOTH_ENABLE                0x00000320
-#      define          NV10_TCL_PRIMITIVE_3D_POLYGON_SMOOTH_ENABLE             0x00000324
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_WEIGHT_ENABLE              0x00000328
-#      define          NV10_TCL_PRIMITIVE_3D_STENCIL_ENABLE                    0x0000032c
-#      define          NV10_TCL_PRIMITIVE_3D_POLYGON_OFFSET_POINT_ENABLE       0x00000330
-#      define          NV10_TCL_PRIMITIVE_3D_POLYGON_OFFSET_LINE_ENABLE        0x00000334
-#      define          NV10_TCL_PRIMITIVE_3D_POLYGON_OFFSET_FILL_ENABLE        0x00000338
-#      define          NV10_TCL_PRIMITIVE_3D_ALPHA_FUNC_FUNC                   0x0000033c
-#      define          NV10_TCL_PRIMITIVE_3D_ALPHA_FUNC_REF                    0x00000340
-#      define          NV10_TCL_PRIMITIVE_3D_BLEND_FUNC_SRC                    0x00000344
-#      define          NV10_TCL_PRIMITIVE_3D_BLEND_FUNC_DST                    0x00000348
-#      define          NV10_TCL_PRIMITIVE_3D_BLEND_COLOR                       0x0000034c      /* Parameters: a r g b */
-#      define          NV10_TCL_PRIMITIVE_3D_BLEND_EQUATION                    0x00000350
-#      define          NV10_TCL_PRIMITIVE_3D_DEPTH_FUNC                        0x00000354
-#      define          NV10_TCL_PRIMITIVE_3D_COLOR_MASK                        0x00000358      /* Parameters: a r g b */
-#      define          NV10_TCL_PRIMITIVE_3D_DEPTH_WRITE_ENABLE                0x0000035c
-#      define          NV10_TCL_PRIMITIVE_3D_STENCIL_MASK                      0x00000360
-#      define          NV10_TCL_PRIMITIVE_3D_STENCIL_FUNC_FUNC                 0x00000364
-#      define          NV10_TCL_PRIMITIVE_3D_STENCIL_FUNC_REF                  0x00000368
-#      define          NV10_TCL_PRIMITIVE_3D_STENCIL_FUNC_MASK                 0x0000036c
-#      define          NV10_TCL_PRIMITIVE_3D_STENCIL_OP_FAIL                   0x00000370
-#      define          NV10_TCL_PRIMITIVE_3D_STENCIL_OP_ZFAIL                  0x00000374
-#      define          NV10_TCL_PRIMITIVE_3D_STENCIL_OP_ZPASS                  0x00000378
-#      define          NV10_TCL_PRIMITIVE_3D_SHADE_MODEL                       0x0000037c
-#      define          NV10_TCL_PRIMITIVE_3D_LINE_WIDTH                        0x00000380
-#      define          NV10_TCL_PRIMITIVE_3D_POLYGON_OFFSET_FACTOR             0x00000384
-#      define          NV10_TCL_PRIMITIVE_3D_POLYGON_OFFSET_UNITS              0x00000388
-#      define          NV10_TCL_PRIMITIVE_3D_POLYGON_MODE_FRONT                0x0000038c
-#      define          NV10_TCL_PRIMITIVE_3D_POLYGON_MODE_BACK                 0x00000390
-#      define          NV10_TCL_PRIMITIVE_3D_DEPTH_RANGE_NEAR                  0x00000394
-#      define          NV10_TCL_PRIMITIVE_3D_DEPTH_RANGE_FAR                   0x00000398
-#      define          NV10_TCL_PRIMITIVE_3D_CULL_FACE                         0x0000039c
-#      define          NV10_TCL_PRIMITIVE_3D_FRONT_FACE                        0x000003a0
-#      define          NV10_TCL_PRIMITIVE_3D_NORMALIZE_ENABLE                  0x000003a4
-#      define          NV10_TCL_PRIMITIVE_3D_COLOR_MATERIAL_R                  0x000003a8
-#      define          NV10_TCL_PRIMITIVE_3D_COLOR_MATERIAL_G                  0x000003ac
-#      define          NV10_TCL_PRIMITIVE_3D_COLOR_MATERIAL_B                  0x000003b0
-#      define          NV10_TCL_PRIMITIVE_3D_COLOR_MATERIAL_A                  0x000003b4
-#      define          NV10_TCL_PRIMITIVE_3D_COLOR_CONTROL                     0x000003b8      /* Parameters: color_control */
-#      define          NV10_TCL_PRIMITIVE_3D_ENABLED_LIGHTS                    0x000003bc      /* Parameters: light 7 light 6 light 5 light 4 light 3 light 2 light 1 light 0 */
-#      define          NV10_TCL_PRIMITIVE_3D_CLIP_PLANE_ENABLE( d)             (0x000003c0 + d * 0x0004)
-#      define          NV10_TCL_PRIMITIVE_3D_VIEW_MATRIX_ENABLE                0x000003e8      /* Parameters: projection modelview0 modelview1 */
-#      define          NV10_TCL_PRIMITIVE_3D_POINT_SIZE                        0x000003ec
-#      define          NV10_TCL_PRIMITIVE_3D_MODELVIEW0_MATRIX( d)             (0x00000400 + d * 0x0004)
-#      define          NV10_TCL_PRIMITIVE_3D_MODELVIEW1_MATRIX( d)             (0x00000440 + d * 0x0004)
-#      define          NV10_TCL_PRIMITIVE_3D_INVERSE_MODELVIEW0_MATRIX( d)     (0x00000480 + d * 0x0004)
-#      define          NV10_TCL_PRIMITIVE_3D_INVERSE_MODELVIEW1_MATRIX( d)     (0x000004c0 + d * 0x0004)
-#      define          NV10_TCL_PRIMITIVE_3D_PROJECTION_MATRIX( d)             (0x00000500 + d * 0x0004)
-#      define          NV10_TCL_PRIMITIVE_3D_CLIP_PLANE_A(d)                   (0x00000600 + d * 0x0010)
-#      define          NV10_TCL_PRIMITIVE_3D_CLIP_PLANE_B(d)                   (0x00000604 + d * 0x0010)
-#      define          NV10_TCL_PRIMITIVE_3D_CLIP_PLANE_C(d)                   (0x00000608 + d * 0x0010)
-#      define          NV10_TCL_PRIMITIVE_3D_CLIP_PLANE_D(d)                   (0x0000060c + d * 0x0010)
-#      define          NV10_TCL_PRIMITIVE_3D_FOG_EQUATION_CONSTANT             0x00000680
-#      define          NV10_TCL_PRIMITIVE_3D_FOG_EQUATION_LINEAR               0x00000684
-#      define          NV10_TCL_PRIMITIVE_3D_FOG_EQUATION_QUADRATIC            0x00000688
-#      define          NV10_TCL_PRIMITIVE_3D_FRONT_MATERIAL_SHININESS_A        0x000006a0
-#      define          NV10_TCL_PRIMITIVE_3D_FRONT_MATERIAL_SHININESS_B        0x000006a4
-#      define          NV10_TCL_PRIMITIVE_3D_FRONT_MATERIAL_SHININESS_C        0x000006a8
-#      define          NV10_TCL_PRIMITIVE_3D_FRONT_MATERIAL_SHININESS_D        0x000006ac
-#      define          NV10_TCL_PRIMITIVE_3D_FRONT_MATERIAL_SHININESS_E        0x000006b0
-#      define          NV10_TCL_PRIMITIVE_3D_FRONT_MATERIAL_SHININESS_F        0x000006b4
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_MODEL_FRONT_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_R    0x000006c4
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_MODEL_FRONT_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_G    0x000006c8
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_MODEL_FRONT_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_B    0x000006cc
-#      define          NV10_TCL_PRIMITIVE_3D_VIEWPORT_SCALE_X                  0x000006e8
-#      define          NV10_TCL_PRIMITIVE_3D_VIEWPORT_SCALE_Y                  0x000006ec
-#      define          NV10_TCL_PRIMITIVE_3D_VIEWPORT_SCALE_Z                  0x000006f0
-#      define          NV10_TCL_PRIMITIVE_3D_VIEWPORT_SCALE_W                  0x000006f4
-#      define          NV10_TCL_PRIMITIVE_3D_POINT_PARAMETER_A                 0x000006f8
-#      define          NV10_TCL_PRIMITIVE_3D_POINT_PARAMETER_B                 0x000006fc
-#      define          NV10_TCL_PRIMITIVE_3D_POINT_PARAMETER_C                 0x00000700
-#      define          NV10_TCL_PRIMITIVE_3D_POINT_PARAMETER_D                 0x00000704
-#      define          NV10_TCL_PRIMITIVE_3D_POINT_PARAMETER_E                 0x00000708
-#      define          NV10_TCL_PRIMITIVE_3D_POINT_PARAMETER_F                 0x0000070c
-#      define          NV10_TCL_PRIMITIVE_3D_POINT_PARAMETER_G                 0x00000710
-#      define          NV10_TCL_PRIMITIVE_3D_POINT_PARAMETER_H                 0x00000714
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_AMBIENT_R(d)     (0x00000800 + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_AMBIENT_G(d)     (0x00000804 + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_AMBIENT_B(d)     (0x00000808 + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_DIFFUSE_R(d)     (0x0000080c + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_DIFFUSE_G(d)     (0x00000810 + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_DIFFUSE_B(d)     (0x00000814 + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_SPECULAR_R(d)    (0x00000818 + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_SPECULAR_G(d)    (0x0000081c + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_SPECULAR_B(d)    (0x00000820 + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_HALF_VECTOR_X(d)            (0x00000828 + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_HALF_VECTOR_Y(d)            (0x0000082c + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_HALF_VECTOR_Z(d)            (0x00000830 + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_DIRECTION_X(d)              (0x00000834 + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_DIRECTION_Y(d)              (0x00000838 + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_DIRECTION_Z(d)              (0x0000083c + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_SPOT_CUTOFF_A(d)            (0x00000840 + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_SPOT_EXPONENT(d)            (0x00000844 + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_SPOT_CUTOFF_B(d)            (0x00000848 + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_SPOT_DIR_X(d)               (0x0000084c + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_SPOT_DIR_Y(d)               (0x00000850 + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_SPOT_DIR_Z(d)               (0x00000854 + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_SPOT_CUTOFF_C(d)            (0x00000858 + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_POSITION_X(d)               (0x0000085c + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_POSITION_Y(d)               (0x00000860 + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_POSITION_Z(d)               (0x00000864 + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_CONSTANT_ATTENUATION(d)     (0x00000868 + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_LINEAR_ATTENUATION(d)       (0x0000086c + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_LIGHT_QUADRATIC_ATTENUATION(d)    (0x00000870 + d * 0x0080)
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_POS_3F_X                   0x00000c00
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_POS_3F_Y                   0x00000c04
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_POS_3F_Z                   0x00000c08
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_POS_4F_X                   0x00000c18
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_POS_4F_Y                   0x00000c1c
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_POS_4F_Z                   0x00000c20
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_POS_4F_W                   0x00000c24
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_NOR_3F_X                   0x00000c30
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_NOR_3F_Y                   0x00000c34
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_NOR_3F_Z                   0x00000c38
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_NOR_3I_XY                  0x00000c40      /* Parameters: y x */
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_NOR_3I_Z                   0x00000c44      /* Parameters: z */
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_COL_4F_R                   0x00000c50
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_COL_4F_G                   0x00000c54
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_COL_4F_B                   0x00000c58
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_COL_4F_A                   0x00000c5c
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_COL_3F_R                   0x00000c60
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_COL_3F_G                   0x00000c64
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_COL_3F_B                   0x00000c68
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_COL_4I                     0x00000c6c      /* Parameters: a b g r */
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_COL2_3F_R                  0x00000c80
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_COL2_3F_G                  0x00000c84
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_COL2_3F_B                  0x00000c88
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_COL2_3I                    0x00000c8c      /* Parameters: a b g r */
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_TX0_2F_S                   0x00000c90
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_TX0_2F_T                   0x00000c94
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_TX0_2I                     0x00000c98      /* Parameters: t s */
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_TX0_4F_S                   0x00000ca0
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_TX0_4F_T                   0x00000ca4
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_TX0_4F_R                   0x00000ca8
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_TX0_4F_Q                   0x00000cac
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_TX0_4I_ST                  0x00000cb0      /* Parameters: t s */
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_TX0_4I_RQ                  0x00000cb4      /* Parameters: q r */
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_TX1_2F_S                   0x00000cb8
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_TX1_2F_T                   0x00000cbc
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_TX1_2I                     0x00000cc0      /* Parameters: t s */
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_TX1_4F_S                   0x00000cc8
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_TX1_4F_T                   0x00000ccc
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_TX1_4F_R                   0x00000cd0
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_TX1_4F_Q                   0x00000cd4
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_TX1_4I_ST                  0x00000cd8      /* Parameters: t s */
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_TX1_4I_RQ                  0x00000cdc      /* Parameters: q r */
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_FOG_1F                     0x00000ce0
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_WGH_1F                     0x00000ce4
-#      define          NV10_TCL_PRIMITIVE_3D_EDGEFLAG_ENABLE                   0x00000cec
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_ATTR( d)                   (0x00000d04 + d * 0x0008)       /* Parameters: stride fields type */
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_VALIDATE             0x00000cf0
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_OFFSET_POS           0x00000d00
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_FORMAT_POS           0x00000d04      /* Parameters: stride fields type */
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_OFFSET_COL           0x00000d08
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_FORMAT_COL           0x00000d0c      /* Parameters: stride fields type */
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_OFFSET_COL2          0x00000d10
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_FORMAT_COL2          0x00000d14      /* Parameters: stride fields type */
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_OFFSET_TX0           0x00000d18
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_FORMAT_TX0           0x00000d1c      /* Parameters: stride fields type */
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_OFFSET_TX1           0x00000d20
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_FORMAT_TX1           0x00000d24      /* Parameters: stride fields type */
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_OFFSET_NOR           0x00000d28
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_FORMAT_NOR           0x00000d2c      /* Parameters: stride fields type */
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_OFFSET_WGH           0x00000d30
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_FORMAT_WGH           0x00000d34      /* Parameters: stride fields type */
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_OFFSET_FOG           0x00000d38
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_FORMAT_FOG           0x00000d3c      /* Parameters: stride fields type */
-#      define          NV10_TCL_PRIMITIVE_3D_COLOR_LOGIC_OP_ENABLE             0x00000d40
-#      define          NV10_TCL_PRIMITIVE_3D_COLOR_LOGIC_OP_OP                 0x00000d44
-#      define          NV17_TCL_PRIMITIVE_3D_LMA_DEPTH_BUFFER_PITCH            0x00000d5c      /* Parameters: pitch */
-#      define          NV17_TCL_PRIMITIVE_3D_LMA_DEPTH_BUFFER_OFFSET           0x00000d60
-#      define          NV17_TCL_PRIMITIVE_3D_LMA_DEPTH_FILL_VALUE              0x00000d68
-#      define          NV17_TCL_PRIMITIVE_3D_LMA_DEPTH_CLEAR_ENABLE            0x00000d6c
-#      define          NV10_TCL_PRIMITIVE_3D_BEGIN_END                         0x00000dfc
-#      define          NV10_TCL_PRIMITIVE_3D_INDEX_DATA                        0x00000e00      /* Parameters: index1 index0 */
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_BUFFER_BEGIN_END           0x000013fc
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_BUFFER_DRAW_ARRAYS         0x00001400      /* Parameters: count-1 first */
-#      define          NV10_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_X                 0x00001638
-#      define          NV10_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_Y                 0x0000163c
-#      define          NV10_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_Z                 0x00001640
-#      define          NV10_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_W                 0x00001644
-#      define          NV17_TCL_PRIMITIVE_3D_LMA_DEPTH_ENABLE                  0x00001658
-#      define          NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_DATA                 0x00001800
-
-/****************************************** 
-Object NV10_IMAGE_FROM_CPU used on: NV10 NV15 NV20 NV30 NV40 G70
-*/
-#define                        NV10_IMAGE_FROM_CPU                                     0x0000008a
-#      define          NV10_IMAGE_FROM_CPU_SET_DMA_NOTIFY                      0x00000180
-#      define          NV10_IMAGE_FROM_CPU_SET_CONTEXT_CLIP_RECTANGLE          0x00000188
-#      define          NV10_IMAGE_FROM_CPU_SET_IMAGE_PATTERN                   0x0000018c
-#      define          NV10_IMAGE_FROM_CPU_SET_RASTER_OP                       0x00000190
-#      define          NV10_IMAGE_FROM_CPU_SET_CONTEXT_SURFACES_2D             0x0000019c
-#      define          NV10_IMAGE_FROM_CPU_OPERATION                           0x000002fc
-#      define          NV10_IMAGE_FROM_CPU_FORMAT                              0x00000300
-#      define          NV10_IMAGE_FROM_CPU_POINT                               0x00000304      /* Parameters: x y */
-#      define          NV10_IMAGE_FROM_CPU_SIZE_OUT                            0x00000308      /* Parameters: width height */
-#      define          NV10_IMAGE_FROM_CPU_SIZE_IN                             0x0000030c      /* Parameters: width height */
-#      define          NV10_IMAGE_FROM_CPU_HLINE                               0x00000400
-
-/****************************************** 
-Object NV10_PRIMITIVE_2D used on: NV10 NV15 NV20 NV30 NV40 G70
-*/
-#define                        NV10_PRIMITIVE_2D                                       0x0000007b
-#      define          NV10_PRIMITIVE_2D_SET_DMA_NOTIFY                        0x00000180
-#      define          NV10_PRIMITIVE_2D_SET_SURFACE                           0x00000184
-#      define          NV10_PRIMITIVE_2D_SET_FORMAT                            0x00000300
-#      define          NV10_PRIMITIVE_2D_SET_POINT                             0x00000304      /* Parameters: x y */
-#      define          NV10_PRIMITIVE_2D_SET_SIZE                              0x00000308      /* Parameters: width height */
-#      define          NV10_PRIMITIVE_2D_SET_CLIP_HORIZ                        0x0000030c      /* Parameters: width x */
-#      define          NV10_PRIMITIVE_2D_SET_CLIP_VERT                         0x00000310      /* Parameters: height y */
-#      define          NV10_PRIMITIVE_2D_SET_DATA( d)                          (0x00000400 + d * 0x0004)
-
-/****************************************** 
-Object NV10_IMAGE_BLIT used on: NV10 NV15 NV20 NV30 NV40 G70
-*/
-#define                        NV10_IMAGE_BLIT                                         0x0000009f
-#      define          NV10_IMAGE_BLIT_NOP                                     0x00000100
-#      define          NV10_IMAGE_BLIT_NOTIFY                                  0x00000104
-#      define          NV10_IMAGE_BLIT_SET_DMA_NOTIFY                          0x00000180
-#      define          NV10_IMAGE_BLIT_SET_CONTEXT_CLIP_RECTANGLE              0x00000188
-#      define          NV10_IMAGE_BLIT_SET_IMAGE_PATTERN                       0x0000018c
-#      define          NV10_IMAGE_BLIT_SET_RASTER_OP                           0x00000190
-#      define          NV10_IMAGE_BLIT_SET_CONTEXT_SURFACES_2D                 0x0000019c
-#      define          NV10_IMAGE_BLIT_SET_OPERATION                           0x000002fc
-#      define          NV10_IMAGE_BLIT_SET_POINT                               0x00000300      /* Parameters: x y */
-#      define          NV10_IMAGE_BLIT_SET_PITCH                               0x00000304      /* Parameters: skip */
-#      define          NV10_IMAGE_BLIT_SET_SIZE                                0x00000308      /* Parameters: width height */
-
-/****************************************** 
-Object NV10_VIDEO_DISPLAY used on: NV10 NV15 NV20 NV30 NV40 G70
-*/
-#define                        NV10_VIDEO_DISPLAY                                      0x0000007c
-#      define          NV10_VIDEO_DISPLAY_COUNTER                              0x00000050
-#      define          NV10_VIDEO_DISPLAY_SET_DMA_FROM_MEMORY                  0x00000180
-#      define          NV10_VIDEO_DISPLAY_SET_DMA_IN_MEMORY0                   0x00000184
-#      define          NV10_VIDEO_DISPLAY_SET_DMA_IN_MEMORY1                   0x00000188
-#      define          NV10_VIDEO_DISPLAY_SET_OBJECT3                          0x0000019c
-#      define          NV10_VIDEO_DISPLAY_SIZE                                 0x000002f8      /* Parameters: height width */
-#      define          NV10_VIDEO_DISPLAY_OFFSET                               0x00000300
-
-/****************************************** 
-Object NV10_UNK0072 used on: NV10 NV15 NV20 NV40 G70
-*/
-#define                        NV10_UNK0072                                            0x00000072
-#      define          NV10_UNK0072_COUNTER                                    0x00000050
-#      define          NV40_UNK0072_SET_OBJECT                                 0x00000060
-#      define          NV10_UNK0072_SET_DMA_NOTIFY                             0x00000180
-
-/****************************************** 
-Object NV10_SCALED_IMAGE_FROM_MEMORY used on: NV10 NV15 NV20 NV30 NV40 G70
-*/
-#define                        NV10_SCALED_IMAGE_FROM_MEMORY                           0x00000089
-#      define          NV10_SCALED_IMAGE_FROM_MEMORY_COUNTER                   0x00000050
-#      define          NV10_SCALED_IMAGE_FROM_MEMORY_SET_DMA_IN_MEMORY         0x00000184
-#      define          NV10_SCALED_IMAGE_FROM_MEMORY_SET_RASTER_OP             0x0000018c
-#      define          NV10_SCALED_IMAGE_FROM_MEMORY_SET_IMAGE_PATTERN         0x00000188
-#      define          NV10_SCALED_IMAGE_FROM_MEMORY_SET_SURFACE               0x00000198
-#      define          NV10_SCALED_IMAGE_FROM_MEMORY_OPERATION                 0x00000304
-#      define          NV10_SCALED_IMAGE_FROM_MEMORY_CLIP_POS                  0x00000308      /* Parameters: x y */
-#      define          NV10_SCALED_IMAGE_FROM_MEMORY_CLIP_SIZE                 0x0000030c      /* Parameters: width height */
-#      define          NV10_SCALED_IMAGE_FROM_MEMORY_OUT_POS                   0x00000310      /* Parameters: x y */
-#      define          NV10_SCALED_IMAGE_FROM_MEMORY_OUT_SIZE                  0x00000314      /* Parameters: width height */
-#      define          NV10_SCALED_IMAGE_FROM_MEMORY_SIZE                      0x00000400      /* Parameters: width height */
-#      define          NV10_SCALED_IMAGE_FROM_MEMORY_FORMAT                    0x00000404      /* Parameters: pitch */
-#      define          NV10_SCALED_IMAGE_FROM_MEMORY_OFFSET                    0x00000408
-#      define          NV10_SCALED_IMAGE_FROM_MEMORY_POINT                     0x0000040c      /* Parameters: u_int u_frac*0x10 v_int v_frac*0x10 */
-
-/****************************************** 
-Object NV10_CONTEXT_SURFACES_2D used on: NV10 NV15 NV20 NV30 NV40 G70
-*/
-#define                        NV10_CONTEXT_SURFACES_2D                                0x00000062
-#      define          NV10_CONTEXT_SURFACES_2D_SET_DMA_NOTIFY                 0x00000180
-#      define          NV10_CONTEXT_SURFACES_2D_SET_DMA_IN_MEMORY0             0x00000184
-#      define          NV10_CONTEXT_SURFACES_2D_SET_DMA_IN_MEMORY1             0x00000188
-#      define          NV10_CONTEXT_SURFACES_2D_FORMAT                         0x00000300      /* Parameters: color type width height */
-#      define          NV10_CONTEXT_SURFACES_2D_PITCH                          0x00000304      /* Parameters: src dst */
-#      define          NV10_CONTEXT_SURFACES_2D_OFFSET_SRC                     0x00000308
-#      define          NV10_CONTEXT_SURFACES_2D_OFFSET_DST                     0x0000030c
-
-/****************************************** 
-Object NV04_CONTEXT_SURFACES_2D used on: NV04 NV10 NV15 
-*/
-#define                        NV04_CONTEXT_SURFACES_2D                                0x00000042
-#      define          NV04_CONTEXT_SURFACES_2D_NOTIFY                         0x00000104
-#      define          NV04_CONTEXT_SURFACES_2D_SET_DMA_NOTIFY                 0x00000180
-#      define          NV04_CONTEXT_SURFACES_2D_SET_DMA_IMAGE_SRC              0x00000184
-#      define          NV04_CONTEXT_SURFACES_2D_SET_DMA_IMAGE_DST              0x00000188
-#      define          NV04_CONTEXT_SURFACES_2D_FORMAT                         0x00000300
-#      define          NV04_CONTEXT_SURFACES_2D_PITCH                          0x00000304      /* Parameters: src dst */
-#      define          NV04_CONTEXT_SURFACES_2D_OFFSET_SRC                     0x00000308
-#      define          NV04_CONTEXT_SURFACES_2D_OFFSET_DST                     0x0000030c
-
-/****************************************** 
-Object NV04_IMAGE_PATTERN used on: NV04 NV10 NV15 NV20 NV30 NV40 G70
-*/
-#define                        NV04_IMAGE_PATTERN                                      0x00000044
-#      define          NV04_IMAGE_PATTERN_COLOR_FORMAT                         0x00000300
-#      define          NV04_IMAGE_PATTERN_MONO_FORMAT                          0x00000304
-#      define          NV04_IMAGE_PATTERN_SELECT                               0x0000030c
-#      define          NV04_IMAGE_PATTERN_MONOCHROME_SHAPE                     0x00000308
-#      define          NV04_IMAGE_PATTERN_MONOCHROME_COLOR0                    0x00000310
-#      define          NV04_IMAGE_PATTERN_MONOCHROME_COLOR1                    0x00000314
-#      define          NV04_IMAGE_PATTERN_MONOCHROME_PATTERN0                  0x00000318
-#      define          NV04_IMAGE_PATTERN_MONOCHROME_PATTERN1                  0x0000031c
-
-/****************************************** 
-Object NV20_SWIZZLED_SURFACE used on: NV20 NV30 NV40 G70
-*/
-#define                        NV20_SWIZZLED_SURFACE                                   0x0000009e
-#      define          NV20_SWIZZLED_SURFACE_SET_OBJECT0                       0x00000180
-#      define          NV20_SWIZZLED_SURFACE_SET_OBJECT1                       0x00000184
-#      define          NV20_SWIZZLED_SURFACE_FORMAT                            0x00000300      /* Parameters: log2(height) log2(width) color */
-#      define          NV20_SWIZZLED_SURFACE_OFFSET                            0x00000304
-
-/****************************************** 
-Object NV20_TCL_PRIMITIVE_3D used on: NV20 
-*/
-#define                        NV20_TCL_PRIMITIVE_3D                                   0x00000097
-#      define          NV20_TCL_PRIMITIVE_3D_NOP                               0x00000100
-#      define          NV20_TCL_PRIMITIVE_3D_NOTIFY                            0x00000104
-#      define          NV20_TCL_PRIMITIVE_3D_SET_OBJECT0                       0x00000180
-#      define          NV20_TCL_PRIMITIVE_3D_SET_OBJECT1                       0x00000184
-#      define          NV20_TCL_PRIMITIVE_3D_SET_OBJECT2                       0x00000188
-#      define          NV20_TCL_PRIMITIVE_3D_SET_OBJECT3                       0x00000194
-#      define          NV20_TCL_PRIMITIVE_3D_SET_OBJECT4                       0x00000198
-#      define          NV20_TCL_PRIMITIVE_3D_SET_OBJECT5                       0x0000019c
-#      define          NV20_TCL_PRIMITIVE_3D_SET_OBJECT6                       0x000001a0
-#      define          NV20_TCL_PRIMITIVE_3D_SET_OBJECT7                       0x000001a4
-#      define          NV20_TCL_PRIMITIVE_3D_SET_OBJECT8                       0x000001a8
-#      define          NV20_TCL_PRIMITIVE_3D_SET_OBJECT9                       0x000001ac
-#      define          NV20_TCL_PRIMITIVE_3D_SET_OBJECT10                      0x000001b0
-#      define          NV20_TCL_PRIMITIVE_3D_VIEWPORT_HORIZ                    0x00000200      /* Parameters: width x */
-#      define          NV20_TCL_PRIMITIVE_3D_VIEWPORT_VERT                     0x00000204      /* Parameters: height y */
-#      define          NV20_TCL_PRIMITIVE_3D_BUFFER_FORMAT                     0x00000208      /* Parameters: type color */
-#      define          NV20_TCL_PRIMITIVE_3D_BUFFER_PITCH                      0x0000020c      /* Parameters: depth/stencil buffer pitch color buffer pitch */
-#      define          NV20_TCL_PRIMITIVE_3D_COLOR_OFFSET                      0x00000210
-#      define          NV20_TCL_PRIMITIVE_3D_DEPTH_OFFSET                      0x00000214
-#      define          NV20_TCL_PRIMITIVE_3D_LMA_DEPTH_BUFFER_PITCH            0x0000022c      /* Parameters: pitch */
-#      define          NV20_TCL_PRIMITIVE_3D_LMA_DEPTH_BUFFER_OFFSET           0x00000230
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_CONTROL                     0x00000294
-#      define          NV20_TCL_PRIMITIVE_3D_COLOR_MATERIAL_CONTROL            0x00000298      /* Parameters: back_specular back_ambient back_diffuse back_emission front_specular front_ambient front_diffuse front_emission */
-#      define          NV20_TCL_PRIMITIVE_3D_FOG_MODE                          0x0000029c
-#      define          NV20_TCL_PRIMITIVE_3D_FOG_COORD_DIST                    0x000002a0
-#      define          NV20_TCL_PRIMITIVE_3D_FOG_ENABLE                        0x000002a4
-#      define          NV20_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(d)            (0x000002c0 + d * 0x0004)       /* Parameters: x2 x1 */
-#      define          NV20_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_VERT(d)             (0x000002e0 + d * 0x0004)       /* Parameters: y2 y1 */
-#      define          NV20_TCL_PRIMITIVE_3D_ALPHA_FUNC_ENABLE                 0x00000300
-#      define          NV20_TCL_PRIMITIVE_3D_BLEND_FUNC_ENABLE                 0x00000304
-#      define          NV20_TCL_PRIMITIVE_3D_CULL_FACE_ENABLE                  0x00000308
-#      define          NV20_TCL_PRIMITIVE_3D_DEPTH_TEST_ENABLE                 0x0000030c
-#      define          NV20_TCL_PRIMITIVE_3D_DITHER_ENABLE                     0x00000310
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHTING_ENABLE                   0x00000314
-#      define          NV20_TCL_PRIMITIVE_3D_POINT_SMOOTH_ENABLE               0x0000031c
-#      define          NV20_TCL_PRIMITIVE_3D_POINT_PARAMETERS_ENABLE           0x00000318
-#      define          NV20_TCL_PRIMITIVE_3D_LINE_SMOOTH_ENABLE                0x00000320
-#      define          NV20_TCL_PRIMITIVE_3D_POLYGON_SMOOTH_ENABLE             0x00000324
-#      define          NV20_TCL_PRIMITIVE_3D_STENCIL_ENABLE                    0x0000032c
-#      define          NV20_TCL_PRIMITIVE_3D_POLYGON_OFFSET_POINT_ENABLE       0x00000330
-#      define          NV20_TCL_PRIMITIVE_3D_POLYGON_OFFSET_LINE_ENABLE        0x00000334
-#      define          NV20_TCL_PRIMITIVE_3D_POLYGON_OFFSET_FILL_ENABLE        0x00000338
-#      define          NV20_TCL_PRIMITIVE_3D_ALPHA_FUNC_FUNC                   0x0000033c
-#      define          NV20_TCL_PRIMITIVE_3D_ALPHA_FUNC_REF                    0x00000340
-#      define          NV20_TCL_PRIMITIVE_3D_BLEND_FUNC_SRC                    0x00000344
-#      define          NV20_TCL_PRIMITIVE_3D_BLEND_FUNC_DST                    0x00000348
-#      define          NV20_TCL_PRIMITIVE_3D_BLEND_COLOR                       0x0000034c      /* Parameters: a r g b */
-#      define          NV20_TCL_PRIMITIVE_3D_BLEND_EQUATION                    0x00000350
-#      define          NV20_TCL_PRIMITIVE_3D_DEPTH_FUNC                        0x00000354
-#      define          NV20_TCL_PRIMITIVE_3D_COLOR_MASK                        0x00000358      /* Parameters: a r g b */
-#      define          NV20_TCL_PRIMITIVE_3D_DEPTH_WRITE_ENABLE                0x0000035c
-#      define          NV20_TCL_PRIMITIVE_3D_STENCIL_MASK                      0x00000360
-#      define          NV20_TCL_PRIMITIVE_3D_STENCIL_FUNC_FUNC                 0x00000364
-#      define          NV20_TCL_PRIMITIVE_3D_STENCIL_FUNC_REF                  0x00000368
-#      define          NV20_TCL_PRIMITIVE_3D_STENCIL_FUNC_MASK                 0x0000036c
-#      define          NV20_TCL_PRIMITIVE_3D_STENCIL_OP_FAIL                   0x00000370
-#      define          NV20_TCL_PRIMITIVE_3D_STENCIL_OP_ZFAIL                  0x00000374
-#      define          NV20_TCL_PRIMITIVE_3D_STENCIL_OP_ZPASS                  0x00000378
-#      define          NV20_TCL_PRIMITIVE_3D_SHADE_MODEL                       0x0000037c
-#      define          NV20_TCL_PRIMITIVE_3D_LINE_WIDTH                        0x00000380
-#      define          NV20_TCL_PRIMITIVE_3D_POLYGON_OFFSET_FACTOR             0x00000384
-#      define          NV20_TCL_PRIMITIVE_3D_POLYGON_OFFSET_UNITS              0x00000388
-#      define          NV20_TCL_PRIMITIVE_3D_POLYGON_MODE_FRONT                0x0000038c
-#      define          NV20_TCL_PRIMITIVE_3D_POLYGON_MODE_BACK                 0x00000390
-#      define          NV20_TCL_PRIMITIVE_3D_DEPTH_RANGE_NEAR                  0x00000394
-#      define          NV20_TCL_PRIMITIVE_3D_DEPTH_RANGE_FAR                   0x00000398
-#      define          NV20_TCL_PRIMITIVE_3D_CULL_FACE                         0x0000039c
-#      define          NV20_TCL_PRIMITIVE_3D_FRONT_FACE                        0x000003a0
-#      define          NV20_TCL_PRIMITIVE_3D_NORMALIZE_ENABLE                  0x000003a4
-#      define          NV20_TCL_PRIMITIVE_3D_COLOR_MATERIAL_FRONT_R            0x000003a8
-#      define          NV20_TCL_PRIMITIVE_3D_COLOR_MATERIAL_FRONT_G            0x000003ac
-#      define          NV20_TCL_PRIMITIVE_3D_COLOR_MATERIAL_FRONT_B            0x000003b0
-#      define          NV20_TCL_PRIMITIVE_3D_COLOR_MATERIAL_FRONT_A            0x000003b4
-#      define          NV20_TCL_PRIMITIVE_3D_SEPARATE_SPECULAR_ENABLE          0x000003b8
-#      define          NV20_TCL_PRIMITIVE_3D_ENABLED_LIGHTS                    0x000003bc      /* Parameters: light 7 light 6 light 5 light 4 light 3 light 2 light 1 light 0 */
-#      define          NV20_TCL_PRIMITIVE_3D_CLIP_PLANE_ENABLE(d)              (0x000003c0 + d * 0x0004)
-#      define          NV20_TCL_PRIMITIVE_3D_TX_MATRIX_ENABLE(d)               (0x00000420 + d * 0x0004)
-#      define          NV20_TCL_PRIMITIVE_3D_POINT_SIZE                        0x0000043c
-#      define          NV20_TCL_PRIMITIVE_3D_MODELVIEW_MATRIX( d)              (0x00000480 + d * 0x0004)
-#      define          NV20_TCL_PRIMITIVE_3D_INVERSE_MODELVIEW_MATRIX( d)      (0x00000580 + d * 0x0004)
-#      define          NV20_TCL_PRIMITIVE_3D_PROJECTION_MATRIX( d)             (0x00000680 + d * 0x0004)
-#      define          NV20_TCL_PRIMITIVE_3D_TX_MATRIX(x,y)                    (0x000006c0 + y * 0x0010 + x * 0x0004)
-#      define          NV20_TCL_PRIMITIVE_3D_CLIP_PLANE_A(d)                   (0x00000840 + d * 0x0010)
-#      define          NV20_TCL_PRIMITIVE_3D_CLIP_PLANE_B(d)                   (0x00000844 + d * 0x0010)
-#      define          NV20_TCL_PRIMITIVE_3D_CLIP_PLANE_C(d)                   (0x00000848 + d * 0x0010)
-#      define          NV20_TCL_PRIMITIVE_3D_CLIP_PLANE_D(d)                   (0x0000084c + d * 0x0010)
-#      define          NV20_TCL_PRIMITIVE_3D_FOG_EQUATION_CONSTANT             0x000009c0
-#      define          NV20_TCL_PRIMITIVE_3D_FOG_EQUATION_LINEAR               0x000009c4
-#      define          NV20_TCL_PRIMITIVE_3D_FOG_EQUATION_QUADRATIC            0x000009c8
-#      define          NV20_TCL_PRIMITIVE_3D_FRONT_MATERIAL_SHININESS_A        0x000009e0
-#      define          NV20_TCL_PRIMITIVE_3D_FRONT_MATERIAL_SHININESS_B        0x000009e4
-#      define          NV20_TCL_PRIMITIVE_3D_FRONT_MATERIAL_SHININESS_C        0x000009e8
-#      define          NV20_TCL_PRIMITIVE_3D_FRONT_MATERIAL_SHININESS_D        0x000009ec
-#      define          NV20_TCL_PRIMITIVE_3D_FRONT_MATERIAL_SHININESS_E        0x000009f0
-#      define          NV20_TCL_PRIMITIVE_3D_FRONT_MATERIAL_SHININESS_F        0x000009f4
-#      define          NV20_TCL_PRIMITIVE_3D_POINT_SPRITE                      0x00000a1c      /* Parameters: coord_replace r_mode enable */
-#      define          NV20_TCL_PRIMITIVE_3D_VIEWPORT_OX                       0x00000a20
-#      define          NV20_TCL_PRIMITIVE_3D_VIEWPORT_OY                       0x00000a24
-#      define          NV20_TCL_PRIMITIVE_3D_VIEWPORT_DEPTH_AVG_S              0x00000a28
-#      define          NV20_TCL_PRIMITIVE_3D_VIEWPORT_UNKNOWN_A                0x00000a2c
-#      define          NV20_TCL_PRIMITIVE_3D_POINT_PARAMETER_A                 0x00000a30
-#      define          NV20_TCL_PRIMITIVE_3D_POINT_PARAMETER_B                 0x00000a34
-#      define          NV20_TCL_PRIMITIVE_3D_POINT_PARAMETER_C                 0x00000a38
-#      define          NV20_TCL_PRIMITIVE_3D_POINT_PARAMETER_D                 0x00000a3c
-#      define          NV20_TCL_PRIMITIVE_3D_POINT_PARAMETER_E                 0x00000a40
-#      define          NV20_TCL_PRIMITIVE_3D_POINT_PARAMETER_F                 0x00000a44
-#      define          NV20_TCL_PRIMITIVE_3D_POINT_PARAMETER_G                 0x00000a48
-#      define          NV20_TCL_PRIMITIVE_3D_POINT_PARAMETER_H                 0x00000a4c
-#      define          NV20_TCL_PRIMITIVE_3D_VIEWPORT_PX_DIV2                  0x00000af0
-#      define          NV20_TCL_PRIMITIVE_3D_VIEWPORT_PY_DIV2                  0x00000af4
-#      define          NV20_TCL_PRIMITIVE_3D_VIEWPORT_DEPTH_HALF_S             0x00000af8
-#      define          NV20_TCL_PRIMITIVE_3D_VIEWPORT_UNKNOWN_B                0x00000afc
-#      define          NV20_TCL_PRIMITIVE_3D_VP_UPLOAD_INST0                   0x00000b00
-#      define          NV20_TCL_PRIMITIVE_3D_VP_UPLOAD_INST1                   0x00000b04
-#      define          NV20_TCL_PRIMITIVE_3D_VP_UPLOAD_INST2                   0x00000b08
-#      define          NV20_TCL_PRIMITIVE_3D_VP_UPLOAD_INST3                   0x00000b0c
-#      define          NV20_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_X                 0x00000b80
-#      define          NV20_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_Y                 0x00000b84
-#      define          NV20_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_Z                 0x00000b88
-#      define          NV20_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_W                 0x00000b8c
-#      define          NV20_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_ID                0x00001ea4
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_MODEL_FRONT_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_R    0x00000a10
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_MODEL_FRONT_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_G    0x00000a14
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_MODEL_FRONT_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_B    0x00000a18
-#      define          NV20_TCL_PRIMITIVE_3D_TX_OFFSET(d)                      (0x00001b00 + d * 0x0040)
-#      define          NV20_TCL_PRIMITIVE_3D_TX_FORMAT(d)                      (0x00001b04 + d * 0x0040)       /* Parameters: log2(height) log2(width) lod format cube_map */
-#      define          NV20_TCL_PRIMITIVE_3D_TX_WRAP(d)                        (0x00001b08 + d * 0x0040)       /* Parameters: wrap_s wrap_t wrap_r */
-#      define          NV20_TCL_PRIMITIVE_3D_TX_ENABLE(d)                      (0x00001b0c + d * 0x0040)       /* Parameters: enable anisotropy */
-#      define          NV20_TCL_PRIMITIVE_3D_TX_NPOT_PITCH(d)                  (0x00001b10 + d * 0x0040)       /* Parameters: pitch */
-#      define          NV20_TCL_PRIMITIVE_3D_TX_FILTER(d)                      (0x00001b14 + d * 0x0040)       /* Parameters: mag_filter min_filter */
-#      define          NV20_TCL_PRIMITIVE_3D_TX_NPOT_SIZE(d)                   (0x00001b1c + d * 0x0040)       /* Parameters: width height */
-#      define          NV20_TCL_PRIMITIVE_3D_TX_PALETTE_OFFSET(d)              (0x00001b20 + d * 0x0040)
-#      define          NV20_TCL_PRIMITIVE_3D_RC_ENABLE                         0x00001e60      /* Parameters: number of rc enabled */
-#      define          NV20_TCL_PRIMITIVE_3D_TX_SHADER_OP                      0x00001e70      /* Parameters: op0 op1 op2 op3 */
-#      define          NV20_TCL_PRIMITIVE_3D_TX_SHADER_CULL_MODE               0x000017f8      /* Parameters: cull0 cull1 cull2 cull3 */
-#      define          NV20_TCL_PRIMITIVE_3D_TX_SHADER_PREVIOUS                0x00001e78      /* Parameters: prev2 prev3 */
-#      define          NV20_TCL_PRIMITIVE_3D_RC_COLOR0                         0x00001e20      /* Parameters: a r g b */
-#      define          NV20_TCL_PRIMITIVE_3D_RC_COLOR1                         0x00001e24      /* Parameters: a r g b */
-#      define          NV20_TCL_PRIMITIVE_3D_RC_FINAL0                         0x00000288      /* Parameters: vara_mapping vara_component_usage vara_input varb_mapping varb_component_usage varb_input varc_mapping varc_component_usage varc_input vard_mapping vard_component_usage vard_input */
-#      define          NV20_TCL_PRIMITIVE_3D_RC_FINAL1                         0x0000028c      /* Parameters: vare_mapping vare_component_usage vare_input varf_mapping varf_component_usage varf_input varg_mapping varg_component_usage varg_input color_sum_clamp */
-#      define          NV20_TCL_PRIMITIVE_3D_RC_IN_ALPHA(d)                    (0x00000260 + d * 0x0004)       /* Parameters: vara_mapping vara_component_usage vara_input varb_mapping varb_component_usage varb_input varc_mapping varc_component_usage varc_input vard_mapping vard_component_usage vard_input */
-#      define          NV20_TCL_PRIMITIVE_3D_RC_IN_RGB(d)                      (0x00000ac0 + d * 0x0004)       /* Parameters: vara_mapping vara_component_usage vara_input varb_mapping varb_component_usage varb_input varc_mapping varc_component_usage varc_input vard_mapping vard_component_usage vard_input */
-#      define          NV20_TCL_PRIMITIVE_3D_RC_CONSTANT_COLOR0(d)             (0x00000a60 + d * 0x0004)       /* Parameters: a r g b */
-#      define          NV20_TCL_PRIMITIVE_3D_RC_CONSTANT_COLOR1(d)             (0x00000a80 + d * 0x0004)       /* Parameters: a r g b */
-#      define          NV20_TCL_PRIMITIVE_3D_RC_OUT_ALPHA(d)                   (0x00000aa0 + d * 0x0004)       /* Parameters: scale bias mux_sum ab_dot_product cd_dot_product sum_output ab_output cd_output */
-#      define          NV20_TCL_PRIMITIVE_3D_RC_OUT_RGB(d)                     (0x00001e40 + d * 0x0004)       /* Parameters: scale bias mux_sum ab_dot_product cd_dot_product sum_output ab_output cd_output */
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_POSITION_X(d)               (0x0000105c + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_POSITION_Y(d)               (0x00001060 + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_POSITION_Z(d)               (0x00001064 + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_HALF_VECTOR_X(d)            (0x00001028 + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_HALF_VECTOR_Y(d)            (0x0000102c + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_HALF_VECTOR_Z(d)            (0x00001030 + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_DIRECTION_X(d)              (0x00001034 + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_DIRECTION_Y(d)              (0x00001038 + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_DIRECTION_Z(d)              (0x0000103c + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_AMBIENT_R(d)     (0x00001000 + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_AMBIENT_G(d)     (0x00001004 + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_AMBIENT_B(d)     (0x00001008 + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_DIFFUSE_R(d)     (0x0000100c + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_DIFFUSE_G(d)     (0x00001010 + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_DIFFUSE_B(d)     (0x00001014 + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_SPECULAR_R(d)    (0x00001018 + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_SPECULAR_G(d)    (0x0000101c + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_SPECULAR_B(d)    (0x00001020 + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_BACK_SIDE_PRODUCT_AMBIENT(d)        (0x00000c00 + d * 0x0040)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_BACK_SIDE_PRODUCT_DIFFUSE(d)        (0x00000c0c + d * 0x0040)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_BACK_SIDE_PRODUCT_SPECULAR(d)       (0x00000c18 + d * 0x0040)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_CONSTANT_ATTENUATION(d)     (0x00001068 + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_LINEAR_ATTENUATION(d)       (0x0000106c + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_QUADRATIC_ATTENUATION(d)    (0x00001070 + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_SPOT_CUTOFF_A(d)            (0x00001040 + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_SPOT_EXPONENT(d)            (0x00001044 + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_SPOT_CUTOFF_B(d)            (0x00001048 + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_SPOT_DIR_X(d)               (0x0000104c + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_SPOT_DIR_Y(d)               (0x00001050 + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_SPOT_DIR_Z(d)               (0x00001054 + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_SPOT_CUTOFF_C(d)            (0x00001058 + d * 0x0080)
-#      define          NV20_TCL_PRIMITIVE_3D_BACK_MATERIAL_SHININESS_A         0x00001e28
-#      define          NV20_TCL_PRIMITIVE_3D_BACK_MATERIAL_SHININESS_B         0x00001e2c
-#      define          NV20_TCL_PRIMITIVE_3D_BACK_MATERIAL_SHININESS_C         0x00001e30
-#      define          NV20_TCL_PRIMITIVE_3D_BACK_MATERIAL_SHININESS_D         0x00001e34
-#      define          NV20_TCL_PRIMITIVE_3D_BACK_MATERIAL_SHININESS_E         0x00001e38
-#      define          NV20_TCL_PRIMITIVE_3D_BACK_MATERIAL_SHININESS_F         0x00001e3c
-#      define          NV20_TCL_PRIMITIVE_3D_POLYGON_STIPPLE_ENABLE            0x0000147c
-#      define          NV20_TCL_PRIMITIVE_3D_POLYGON_STIPPLE_PATTERN(d)        (0x00001480 + d * 0x0004)
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_POS_3F_X                   0x00001500
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_POS_3F_Y                   0x00001504
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_POS_3F_Z                   0x00001508
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_POS_4F_X                   0x00001518
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_POS_4F_Y                   0x0000151c
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_POS_4F_Z                   0x00001520
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_POS_4F_W                   0x00001524
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_POS_4I_XY                  0x00001528      /* Parameters: y x */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_POS_4I_ZW                  0x0000152c      /* Parameters: w z */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_NOR_3F_X                   0x00001530
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_NOR_3F_Y                   0x00001534
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_NOR_3F_Z                   0x00001538
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_NOR_3I_XY                  0x00001540      /* Parameters: y x */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_NOR_3I_Z                   0x00001544      /* Parameters: z */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_COL_4F_R                   0x00001550
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_COL_4F_G                   0x00001554
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_COL_4F_B                   0x00001558
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_COL_4F_A                   0x0000155c
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_COL_3F_R                   0x00001560
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_COL_3F_G                   0x00001564
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_COL_3F_B                   0x00001568
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_COL_4I                     0x0000156c      /* Parameters: a b g r */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_COL2_3F_R                  0x00001580
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_COL2_3F_G                  0x00001584
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_COL2_3F_B                  0x00001588
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_COL2_3I                    0x0000158c      /* Parameters: a b g r */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX0_2F_S                   0x00001590
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX0_2F_T                   0x00001594
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX0_2I                     0x00001598      /* Parameters: t s */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX0_4F_S                   0x000015a0
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX0_4F_T                   0x000015a4
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX0_4F_R                   0x000015a8
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX0_4F_Q                   0x000015ac
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX0_4I_ST                  0x000015b0      /* Parameters: t s */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX0_4I_RQ                  0x000015b4      /* Parameters: q r */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX1_2F_S                   0x000015b8
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX1_2F_T                   0x000015bc
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX1_2I                     0x000015c0      /* Parameters: t s */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX1_4F_S                   0x000015c8
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX1_4F_T                   0x000015cc
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX1_4F_R                   0x000015d0
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX1_4F_Q                   0x000015d4
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX1_4I_ST                  0x000015d8      /* Parameters: t s */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX1_4I_RQ                  0x000015dc      /* Parameters: q r */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX2_2F_S                   0x000015e0
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX2_2F_T                   0x000015e4
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX2_2I                     0x000015e8      /* Parameters: t s */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX2_4F_S                   0x000015f0
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX2_4F_T                   0x000015f4
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX2_4F_R                   0x000015f8
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX2_4F_Q                   0x000015fc
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX2_4I_ST                  0x00001600      /* Parameters: t s */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX2_4I_RQ                  0x00001604      /* Parameters: q r */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX3_2F_S                   0x00001608
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX3_2F_T                   0x0000160c
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX3_2I                     0x00001610      /* Parameters: t s */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX3_4F_S                   0x00001620
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX3_4F_T                   0x00001624
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX3_4F_R                   0x00001628
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX3_4F_Q                   0x0000162c
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX3_4I_ST                  0x00001630      /* Parameters: t s */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_TX3_4I_RQ                  0x00001634      /* Parameters: q r */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_FOG_1F                     0x00001698
-#      define          NV20_TCL_PRIMITIVE_3D_EDGE_FLAG                         0x000016bc
-#      define          NV20_TCL_PRIMITIVE_3D_VB_POINTER_ATTR0_POS              0x00001720      /* Parameters: enabled? offset */
-#      define          NV20_TCL_PRIMITIVE_3D_VB_POINTER_ATTR1_WGH              0x00001724      /* Parameters: enabled? offset */
-#      define          NV20_TCL_PRIMITIVE_3D_VB_POINTER_ATTR2_NOR              0x00001728      /* Parameters: enabled? offset */
-#      define          NV20_TCL_PRIMITIVE_3D_VB_POINTER_ATTR3_COL              0x0000172c      /* Parameters: enabled? offset */
-#      define          NV20_TCL_PRIMITIVE_3D_VB_POINTER_ATTR4_COL2             0x00001730      /* Parameters: enabled? offset */
-#      define          NV20_TCL_PRIMITIVE_3D_VB_POINTER_ATTR5_FOG              0x00001734      /* Parameters: enabled? offset */
-#      define          NV20_TCL_PRIMITIVE_3D_VB_POINTER_ATTR6                  0x00001738      /* Parameters: enabled? offset */
-#      define          NV20_TCL_PRIMITIVE_3D_VB_POINTER_ATTR7                  0x0000173c      /* Parameters: enabled? offset */
-#      define          NV20_TCL_PRIMITIVE_3D_VB_POINTER_ATTR8_TX0              0x00001740      /* Parameters: enabled? offset */
-#      define          NV20_TCL_PRIMITIVE_3D_VB_POINTER_ATTR9_TX1              0x00001744      /* Parameters: enabled? offset */
-#      define          NV20_TCL_PRIMITIVE_3D_VB_POINTER_ATTR10_TX2             0x00001748      /* Parameters: enabled? offset */
-#      define          NV20_TCL_PRIMITIVE_3D_VB_POINTER_ATTR11_TX3             0x0000174c      /* Parameters: enabled? offset */
-#      define          NV20_TCL_PRIMITIVE_3D_VB_POINTER_ATTR12_TX4             0x00001750      /* Parameters: enabled? offset */
-#      define          NV20_TCL_PRIMITIVE_3D_VB_POINTER_ATTR13_TX5             0x00001754      /* Parameters: enabled? offset */
-#      define          NV20_TCL_PRIMITIVE_3D_VB_POINTER_ATTR14_TX6             0x00001758      /* Parameters: enabled? offset */
-#      define          NV20_TCL_PRIMITIVE_3D_VB_POINTER_ATTR15_TX7             0x0000175c      /* Parameters: enabled? offset */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_ATTR( d)                   (0x00001760 + d * 0x0004)
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_ATTR0_POS                  0x00001760      /* Parameters: stride fields type */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_ATTR1_WGH                  0x00001764      /* Parameters: stride fields type */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_ATTR2_NOR                  0x00001768      /* Parameters: stride fields type */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_ATTR3_COL                  0x0000176c      /* Parameters: stride fields type */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_ATTR4_COL2                 0x00001770      /* Parameters: stride fields type */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_ATTR5_FOG                  0x00001774      /* Parameters: stride fields type */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_ATTR6                      0x00001778      /* Parameters: stride fields type */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_ATTR7                      0x0000177c      /* Parameters: stride fields type */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_ATTR8_TX0                  0x00001780      /* Parameters: stride fields type */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_ATTR9_TX1                  0x00001784      /* Parameters: stride fields type */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_ATTR10_TX2                 0x00001788      /* Parameters: stride fields type */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_ATTR11_TX3                 0x0000178c      /* Parameters: stride fields type */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_ATTR12_TX4                 0x00001790      /* Parameters: stride fields type */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_ATTR13_TX5                 0x00001794      /* Parameters: stride fields type */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_ATTR14_TX6                 0x00001798      /* Parameters: stride fields type */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_ATTR15_TX7                 0x0000179c      /* Parameters: stride fields type */
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_MODEL_BACK_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_R     0x000017a0
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_MODEL_BACK_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_G     0x000017a4
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_MODEL_BACK_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_B     0x000017a8
-#      define          NV20_TCL_PRIMITIVE_3D_COLOR_MATERIAL_BACK_A             0x000017ac
-#      define          NV20_TCL_PRIMITIVE_3D_COLOR_MATERIAL_BACK_R             0x000017b0
-#      define          NV20_TCL_PRIMITIVE_3D_COLOR_MATERIAL_BACK_G             0x000017b4
-#      define          NV20_TCL_PRIMITIVE_3D_COLOR_MATERIAL_BACK_B             0x000017b8
-#      define          NV20_TCL_PRIMITIVE_3D_COLOR_LOGIC_OP_ENABLE             0x000017bc
-#      define          NV20_TCL_PRIMITIVE_3D_COLOR_LOGIC_OP_OP                 0x000017c0
-#      define          NV20_TCL_PRIMITIVE_3D_LIGHT_MODEL_TWO_SIDE_ENABLE       0x000017c4
-#      define          NV20_TCL_PRIMITIVE_3D_BEGIN_END                         0x000017fc
-#      define          NV20_TCL_PRIMITIVE_3D_SCISSOR_X2_X1                     0x00001c30      /* Parameters: x2 x1 */
-#      define          NV20_TCL_PRIMITIVE_3D_SCISSOR_Y2_Y1                     0x00001c50      /* Parameters: y2 y1 */
-#      define          NV20_TCL_PRIMITIVE_3D_CLEAR_VALUE_DEPTH                 0x00001d8c
-#      define          NV20_TCL_PRIMITIVE_3D_CLEAR_VALUE_ARGB                  0x00001d90
-#      define          NV20_TCL_PRIMITIVE_3D_CLEAR_WHICH_BUFFERS               0x00001d94      /* Parameters: clear color a clear color b clear color g clear color r clear depth clear stencil */
-#      define          NV20_TCL_PRIMITIVE_3D_INDEX_DATA                        0x00001800      /* Parameters: index1 index0 */
-#      define          NV20_TCL_PRIMITIVE_3D_VB_VERTEX_BATCH                   0x00001810      /* Parameters: count_vertices offset_vertices */
-#      define          NV20_TCL_PRIMITIVE_3D_VERTEX_DATA                       0x00001818
-#      define          NV20_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_X                 0x00001f00
-#      define          NV20_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_Y                 0x00001f04
-#      define          NV20_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_Z                 0x00001f08
-#      define          NV20_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_W                 0x00001f0c
-
-/****************************************** 
-Object NV30_TCL_PRIMITIVE_3D used on: NV30 NV40 G70
-*/
-#define                        NV30_TCL_PRIMITIVE_3D                                   0x00000097
-#      define          NV30_TCL_PRIMITIVE_3D_SET_OBJECT0                       0x00000180
-#      define          NV30_TCL_PRIMITIVE_3D_SET_OBJECT1                       0x00000184
-#      define          NV30_TCL_PRIMITIVE_3D_SET_OBJECT2                       0x00000188
-#      define          NV30_TCL_PRIMITIVE_3D_SET_OBJECT3                       0x0000018c
-#      define          NV30_TCL_PRIMITIVE_3D_SET_OBJECT4                       0x00000194
-#      define          NV30_TCL_PRIMITIVE_3D_SET_OBJECT5                       0x00000198
-#      define          NV30_TCL_PRIMITIVE_3D_SET_OBJECT6                       0x000001a4
-#      define          NV30_TCL_PRIMITIVE_3D_SET_OBJECT7                       0x000001a8
-#      define          NV30_TCL_PRIMITIVE_3D_SET_OBJECT8                       0x000001ac
-#      define          NV30_TCL_PRIMITIVE_3D_SET_OBJECT9                       0x000001b4
-#      define          NV30_TCL_PRIMITIVE_3D_SET_OBJECT10                      0x000001b8
-#      define          NV30_TCL_PRIMITIVE_3D_SET_VB_SRC0_OBJECT                0x0000019c
-#      define          NV30_TCL_PRIMITIVE_3D_SET_VB_SRC1_OBJECT                0x000001a0
-#      define          NV30_TCL_PRIMITIVE_3D_BUFFER0_PITCH                     0x0000020c      /* Parameters: depth/stencil buffer pitch color0 buffer pitch */
-#      define          NV30_TCL_PRIMITIVE_3D_COLOR0_OFFSET                     0x00000210
-#      define          NV30_TCL_PRIMITIVE_3D_DEPTH_OFFSET                      0x00000214
-#      define          NV30_TCL_PRIMITIVE_3D_COLOR1_OFFSET                     0x00000218
-#      define          NV30_TCL_PRIMITIVE_3D_BUFFER1_PITCH                     0x0000021c      /* Parameters: color1 buffer pitch */
-#      define          NV30_TCL_PRIMITIVE_3D_LMA_DEPTH_BUFFER_PITCH            0x0000022c      /* Parameters: pitch */
-#      define          NV30_TCL_PRIMITIVE_3D_LMA_DEPTH_BUFFER_OFFSET           0x00000230
-#      define          NV30_TCL_PRIMITIVE_3D_TX_MATRIX_ENABLE(d)               (0x00000240 + d * 0x0004)
-#      define          NV30_TCL_PRIMITIVE_3D_BUFFER2_PITCH                     0x00000280
-#      define          NV30_TCL_PRIMITIVE_3D_BUFFER3_PITCH                     0x00000284
-#      define          NV30_TCL_PRIMITIVE_3D_BUFFER2_OFFSET                    0x00000288
-#      define          NV30_TCL_PRIMITIVE_3D_BUFFER3_OFFSET                    0x0000028c
-#      define          NV30_TCL_PRIMITIVE_3D_DITHER_ENABLE                     0x00000300
-#      define          NV30_TCL_PRIMITIVE_3D_ALPHA_FUNC_ENABLE                 0x00000304
-#      define          NV30_TCL_PRIMITIVE_3D_ALPHA_FUNC_FUNC                   0x00000308
-#      define          NV30_TCL_PRIMITIVE_3D_ALPHA_FUNC_REF                    0x0000030c
-#      define          NV30_TCL_PRIMITIVE_3D_BLEND_FUNC_ENABLE                 0x00000310
-#      define          NV30_TCL_PRIMITIVE_3D_BLEND_FUNC_SRC                    0x00000314
-#      define          NV30_TCL_PRIMITIVE_3D_BLEND_FUNC_DST                    0x00000318
-#      define          NV30_TCL_PRIMITIVE_3D_BLEND_COLOR                       0x0000031c      /* Parameters: a r g b */
-#      define          NV30_TCL_PRIMITIVE_3D_BLEND_EQUATION                    0x00000320
-#      define          NV30_TCL_PRIMITIVE_3D_COLOR_MASK                        0x00000324      /* Parameters: a r g b */
-#      define          NV30_TCL_PRIMITIVE_3D_STENCIL_BACK_ENABLE               0x00000328
-#      define          NV30_TCL_PRIMITIVE_3D_STENCIL_BACK_MASK                 0x0000032c
-#      define          NV30_TCL_PRIMITIVE_3D_STENCIL_BACK_FUNC_FUNC            0x00000330
-#      define          NV30_TCL_PRIMITIVE_3D_STENCIL_BACK_FUNC_REF             0x00000334
-#      define          NV30_TCL_PRIMITIVE_3D_STENCIL_BACK_FUNC_MASK            0x00000338
-#      define          NV30_TCL_PRIMITIVE_3D_STENCIL_BACK_OP_FAIL              0x0000033c
-#      define          NV30_TCL_PRIMITIVE_3D_STENCIL_BACK_OP_ZFAIL             0x00000340
-#      define          NV30_TCL_PRIMITIVE_3D_STENCIL_BACK_OP_ZPASS             0x00000344
-#      define          NV30_TCL_PRIMITIVE_3D_STENCIL_FRONT_ENABLE              0x00000348
-#      define          NV30_TCL_PRIMITIVE_3D_STENCIL_FRONT_MASK                0x0000034c
-#      define          NV30_TCL_PRIMITIVE_3D_STENCIL_FRONT_FUNC_FUNC           0x00000350
-#      define          NV30_TCL_PRIMITIVE_3D_STENCIL_FRONT_FUNC_REF            0x00000354
-#      define          NV30_TCL_PRIMITIVE_3D_STENCIL_FRONT_FUNC_MASK           0x00000358
-#      define          NV30_TCL_PRIMITIVE_3D_STENCIL_FRONT_OP_FAIL             0x0000035c
-#      define          NV30_TCL_PRIMITIVE_3D_STENCIL_FRONT_OP_ZFAIL            0x00000360
-#      define          NV30_TCL_PRIMITIVE_3D_STENCIL_FRONT_OP_ZPASS            0x00000364
-#      define          NV30_TCL_PRIMITIVE_3D_SHADE_MODEL                       0x00000368
-#      define          NV30_TCL_PRIMITIVE_3D_FOG_ENABLE                        0x0000036c
-#      define          NV30_TCL_PRIMITIVE_3D_FOG_COLOR                         0x00000370
-#      define          NV40_TCL_PRIMITIVE_3D_COLOR_MASK_BUFFER123              0x00000370      /* Parameters: buffer3 b buffer3 g buffer3 r buffer3 a buffer2 b buffer2 g buffer2 r buffer2 a buffer1 b buffer1 g buffer1 r buffer1 a */
-#      define          NV30_TCL_PRIMITIVE_3D_NORMALIZE_ENABLE                  0x0000037c
-#      define          NV30_TCL_PRIMITIVE_3D_DEPTH_RANGE_NEAR                  0x00000394
-#      define          NV30_TCL_PRIMITIVE_3D_DEPTH_RANGE_FAR                   0x00000398
-#      define          NV30_TCL_PRIMITIVE_3D_COLOR_MATERIAL_FRONT_R            0x000003a0
-#      define          NV30_TCL_PRIMITIVE_3D_COLOR_MATERIAL_FRONT_G            0x000003a4
-#      define          NV30_TCL_PRIMITIVE_3D_COLOR_MATERIAL_FRONT_B            0x000003a8
-#      define          NV30_TCL_PRIMITIVE_3D_COLOR_MATERIAL_FRONT_A            0x000003b4
-#      define          NV30_TCL_PRIMITIVE_3D_LINE_WIDTH_SMOOTH                 0x000003b8
-#      define          NV30_TCL_PRIMITIVE_3D_LINE_SMOOTH_ENABLE                0x000003bc
-#      define          NV30_TCL_PRIMITIVE_3D_CLIP_PLANE_ENABLE(d)              (0x00000400 + d * 0x0004)
-#      define          NV30_TCL_PRIMITIVE_3D_MODELVIEW_MATRIX( d)              (0x00000480 + d * 0x0004)
-#      define          NV30_TCL_PRIMITIVE_3D_INVERSE_MODELVIEW_MATRIX( d)      (0x00000580 + d * 0x0004)
-#      define          NV30_TCL_PRIMITIVE_3D_PROJECTION_MATRIX( d)             (0x00000680 + d * 0x0004)
-#      define          NV30_TCL_PRIMITIVE_3D_TX_MATRIX(x,y)                    (0x000006c0 + y * 0x0010 + x * 0x0004)
-#      define          NV30_TCL_PRIMITIVE_3D_FP_ACTIVE_PROGRAM                 0x000008e4
-#      define          NV30_TCL_PRIMITIVE_3D_FOG_COORD_DIST                    0x000008c8
-#      define          NV30_TCL_PRIMITIVE_3D_FOG_MODE                          0x000008cc
-#      define          NV30_TCL_PRIMITIVE_3D_FOG_EQUATION_CONSTANT             0x000008d0
-#      define          NV30_TCL_PRIMITIVE_3D_FOG_EQUATION_LINEAR               0x000008d4
-#      define          NV30_TCL_PRIMITIVE_3D_FOG_EQUATION_QUADRATIC            0x000008d8
-#      define          NV30_TCL_PRIMITIVE_3D_RC_COLOR0                         0x000008ec      /* Parameters: a r g b */
-#      define          NV30_TCL_PRIMITIVE_3D_RC_COLOR1                         0x000008f0      /* Parameters: a r g b */
-#      define          NV30_TCL_PRIMITIVE_3D_RC_FINAL0                         0x000008f4      /* Parameters: vara_mapping vara_component_usage vara_input varb_mapping varb_component_usage varb_input varc_mapping varc_component_usage varc_input vard_mapping vard_component_usage vard_input */
-#      define          NV30_TCL_PRIMITIVE_3D_RC_FINAL1                         0x000008f8      /* Parameters: vare_mapping vare_component_usage vare_input varf_mapping varf_component_usage varf_input varg_mapping varg_component_usage varg_input color_sum_clamp */
-#      define          NV30_TCL_PRIMITIVE_3D_RC_ENABLE                         0x000008fc      /* Parameters: number of rc enabled */
-#      define          NV30_TCL_PRIMITIVE_3D_RC_IN_ALPHA(d)                    (0x00000900 + d * 0x0020)       /* Parameters: vara_mapping vara_component_usage vara_input varb_mapping varb_component_usage varb_input varc_mapping varc_component_usage varc_input vard_mapping vard_component_usage vard_input */
-#      define          NV30_TCL_PRIMITIVE_3D_RC_IN_RGB(d)                      (0x00000904 + d * 0x0020)       /* Parameters: vara_mapping vara_component_usage vara_input varb_mapping varb_component_usage varb_input varc_mapping varc_component_usage varc_input vard_mapping vard_component_usage vard_input */
-#      define          NV30_TCL_PRIMITIVE_3D_RC_CONSTANT_COLOR0(d)             (0x00000908 + d * 0x0020)       /* Parameters: a r g b */
-#      define          NV30_TCL_PRIMITIVE_3D_RC_CONSTANT_COLOR1(d)             (0x0000090c + d * 0x0020)       /* Parameters: a r g b */
-#      define          NV30_TCL_PRIMITIVE_3D_RC_OUT_ALPHA(d)                   (0x00000910 + d * 0x0020)       /* Parameters: scale bias mux_sum ab_dot_product cd_dot_product sum_output ab_output cd_output */
-#      define          NV30_TCL_PRIMITIVE_3D_RC_OUT_RGB(d)                     (0x00000914 + d * 0x0020)       /* Parameters: scale bias mux_sum ab_dot_product cd_dot_product sum_output ab_output cd_output */
-#      define          NV30_TCL_PRIMITIVE_3D_VIEWPORT_COLOR_BUFFER_DIM0        0x00000200      /* Parameters: width x_offset */
-#      define          NV30_TCL_PRIMITIVE_3D_VIEWPORT_COLOR_BUFFER_DIM1        0x00000204      /* Parameters: height y_offset */
-#      define          NV30_TCL_PRIMITIVE_3D_VIEWPORT_COLOR_BUFFER_OFS0        0x000002c0      /* Parameters: width x_offset */
-#      define          NV30_TCL_PRIMITIVE_3D_VIEWPORT_COLOR_BUFFER_OFS1        0x000002c4      /* Parameters: height y_offset */
-#      define          NV30_TCL_PRIMITIVE_3D_VIEWPORT_DIMS_0                   0x00000a00      /* Parameters: width x_offset */
-#      define          NV30_TCL_PRIMITIVE_3D_VIEWPORT_DIMS_1                   0x00000a04      /* Parameters: height y_offset */
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_MODEL_FRONT_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_R    0x00000a10
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_MODEL_FRONT_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_G    0x00000a14
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_MODEL_FRONT_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_B    0x00000a18
-#      define          NV30_TCL_PRIMITIVE_3D_SCISSOR_WIDTH_XPOS                0x000008c0      /* Parameters: width x_offset */
-#      define          NV30_TCL_PRIMITIVE_3D_SCISSOR_HEIGHT_YPOS               0x000008c4      /* Parameters: height y_offset */
-#      define          NV30_TCL_PRIMITIVE_3D_POINT_SPRITE                      0x00001ee8      /* Parameters: coord_replace r_mode enable */
-#      define          NV30_TCL_PRIMITIVE_3D_POINT_SIZE                        0x00001ee0
-#      define          NV30_TCL_PRIMITIVE_3D_POINT_PARAMETER_A                 0x00001ec0
-#      define          NV30_TCL_PRIMITIVE_3D_POINT_PARAMETER_B                 0x00001ec4
-#      define          NV30_TCL_PRIMITIVE_3D_POINT_PARAMETER_C                 0x00001ec8
-#      define          NV30_TCL_PRIMITIVE_3D_POINT_PARAMETER_D                 0x00001ecc
-#      define          NV30_TCL_PRIMITIVE_3D_POINT_PARAMETER_E                 0x00001ed0
-#      define          NV30_TCL_PRIMITIVE_3D_POINT_PARAMETER_F                 0x00001ed4
-#      define          NV30_TCL_PRIMITIVE_3D_POINT_PARAMETER_G                 0x00001ed8
-#      define          NV30_TCL_PRIMITIVE_3D_POINT_PARAMETER_H                 0x00001edc
-#      define          NV30_TCL_PRIMITIVE_3D_POINT_PARAMETERS_ENABLE           0x00001ee4
-#      define          NV30_TCL_PRIMITIVE_3D_VIEWPORT_XFRM_OX                  0x00000a20
-#      define          NV30_TCL_PRIMITIVE_3D_VIEWPORT_XFRM_OY                  0x00000a24
-#      define          NV30_TCL_PRIMITIVE_3D_VIEWPORT_XFRM_NPF_DIV2            0x00000a28
-#      define          NV30_TCL_PRIMITIVE_3D_VIEWPORT_XFRM_UNK0_0x0            0x00000a2c
-#      define          NV30_TCL_PRIMITIVE_3D_VIEWPORT_XFRM_PX_DIV2             0x00000a30
-#      define          NV30_TCL_PRIMITIVE_3D_VIEWPORT_XFRM_PY_DIV2             0x00000a34
-#      define          NV30_TCL_PRIMITIVE_3D_VIEWPORT_XFRM_FMN_DIV2            0x00000a38
-#      define          NV30_TCL_PRIMITIVE_3D_VIEWPORT_XFRM_UNK1_0x0            0x00000a3c
-#      define          NV30_TCL_PRIMITIVE_3D_POLYGON_OFFSET_FILL_ENABLE        0x00000a60
-#      define          NV30_TCL_PRIMITIVE_3D_POLYGON_OFFSET_LINE_ENABLE        0x00000a64
-#      define          NV30_TCL_PRIMITIVE_3D_POLYGON_OFFSET_POINT_ENABLE       0x00000a68
-#      define          NV30_TCL_PRIMITIVE_3D_DEPTH_FUNC                        0x00000a6c
-#      define          NV30_TCL_PRIMITIVE_3D_DEPTH_WRITE_ENABLE                0x00000a70
-#      define          NV30_TCL_PRIMITIVE_3D_DEPTH_TEST_ENABLE                 0x00000a74
-#      define          NV30_TCL_PRIMITIVE_3D_POLYGON_OFFSET_FACTOR             0x00000a78
-#      define          NV30_TCL_PRIMITIVE_3D_POLYGON_OFFSET_UNITS              0x00000a7c
-#      define          NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_INST0                   0x00000b80
-#      define          NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_INST1                   0x00000b84
-#      define          NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_INST2                   0x00000b88
-#      define          NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_INST3                   0x00000b8c
-#      define          NV30_TCL_PRIMITIVE_3D_COLOR_MATERIAL_BACK_R             0x000017b0
-#      define          NV30_TCL_PRIMITIVE_3D_COLOR_MATERIAL_BACK_G             0x000017b4
-#      define          NV30_TCL_PRIMITIVE_3D_COLOR_MATERIAL_BACK_B             0x000017b8
-#      define          NV30_TCL_PRIMITIVE_3D_COLOR_MATERIAL_BACK_A             0x000017c0
-#      define          NV30_TCL_PRIMITIVE_3D_OCC_QUERY_OR_COLOR_BUFF_ENABLE    0x000017c8
-#      define          NV30_TCL_PRIMITIVE_3D_STORE_RESULT                      0x00001800
-#      define          NV30_TCL_PRIMITIVE_3D_CLIP_PLANE_A(d)                   (0x00000e00 + d * 0x0010)
-#      define          NV30_TCL_PRIMITIVE_3D_CLIP_PLANE_B(d)                   (0x00000e04 + d * 0x0010)
-#      define          NV30_TCL_PRIMITIVE_3D_CLIP_PLANE_C(d)                   (0x00000e08 + d * 0x0010)
-#      define          NV30_TCL_PRIMITIVE_3D_CLIP_PLANE_D(d)                   (0x00000e0c + d * 0x0010)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_AMBIENT_R(d)     (0x00001000 + d * 0x0040)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_AMBIENT_G(d)     (0x00001004 + d * 0x0040)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_AMBIENT_B(d)     (0x00001008 + d * 0x0040)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_DIFFUSE_R(d)     (0x0000100c + d * 0x0040)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_DIFFUSE_G(d)     (0x00001010 + d * 0x0040)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_DIFFUSE_B(d)     (0x00001014 + d * 0x0040)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_SPECULAR_R(d)    (0x00001018 + d * 0x0040)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_SPECULAR_G(d)    (0x0000101c + d * 0x0040)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_SPECULAR_B(d)    (0x00001020 + d * 0x0040)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_HALF_VECTOR_X(d)            (0x00001028 + d * 0x0080)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_HALF_VECTOR_Y(d)            (0x0000102c + d * 0x0080)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_HALF_VECTOR_Z(d)            (0x00001030 + d * 0x0080)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_DIRECTION_X(d)              (0x00001034 + d * 0x0080)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_DIRECTION_Y(d)              (0x00001038 + d * 0x0080)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_DIRECTION_Z(d)              (0x0000103c + d * 0x0080)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_CONSTANT_ATTENUATION(d)     (0x00001228 + d * 0x0040)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_LINEAR_ATTENUATION(d)       (0x0000122c + d * 0x0040)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_QUADRATIC_ATTENUATION(d)    (0x00001230 + d * 0x0040)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_SPOT_CUTOFF_A(d)            (0x00001200 + d * 0x0040)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_SPOT_EXPONENT(d)            (0x00001204 + d * 0x0040)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_SPOT_CUTOFF_B(d)            (0x00001208 + d * 0x0040)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_SPOT_DIR_X(d)               (0x0000120c + d * 0x0040)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_SPOT_DIR_Y(d)               (0x00001210 + d * 0x0040)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_SPOT_DIR_Z(d)               (0x00001214 + d * 0x0040)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_SPOT_CUTOFF_C(d)            (0x00001218 + d * 0x0040)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_POSITION_X(d)               (0x0000121c + d * 0x0040)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_POSITION_Y(d)               (0x00001220 + d * 0x0040)
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_POSITION_Z(d)               (0x00001224 + d * 0x0040)
-#      define          NV30_TCL_PRIMITIVE_3D_FRONT_MATERIAL_SHININESS_A        0x00001400
-#      define          NV30_TCL_PRIMITIVE_3D_FRONT_MATERIAL_SHININESS_B        0x00001404
-#      define          NV30_TCL_PRIMITIVE_3D_FRONT_MATERIAL_SHININESS_C        0x00001408
-#      define          NV30_TCL_PRIMITIVE_3D_FRONT_MATERIAL_SHININESS_D        0x0000140c
-#      define          NV30_TCL_PRIMITIVE_3D_FRONT_MATERIAL_SHININESS_E        0x00001410
-#      define          NV30_TCL_PRIMITIVE_3D_FRONT_MATERIAL_SHININESS_F        0x00001414
-#      define          NV30_TCL_PRIMITIVE_3D_ENABLED_LIGHTS                    0x00001420      /* Parameters: light 7 light 6 light 5 light 4 light 3 light 2 light 1 light 0 */
-#      define          NV30_TCL_PRIMITIVE_3D_UNK1D6C_OFFSET                    0x00001d6c
-#      define          NV30_TCL_PRIMITIVE_3D_UNK1D70_VALUE                     0x00001d70
-#      define          NV30_TCL_PRIMITIVE_3D_LINE_STIPPLE_ENABLE               0x00001db4
-#      define          NV30_TCL_PRIMITIVE_3D_LINE_STIPPLE_PATTERN              0x00001db8      /* Parameters: factor pattern */
-#      define          NV30_TCL_PRIMITIVE_3D_BEGIN_END                         0x00001808
-#      define          NV30_TCL_PRIMITIVE_3D_CULL_FACE                         0x00001830
-#      define          NV30_TCL_PRIMITIVE_3D_FRONT_FACE                        0x00001834
-#      define          NV30_TCL_PRIMITIVE_3D_POLYGON_SMOOTH_ENABLE             0x00001838
-#      define          NV30_TCL_PRIMITIVE_3D_CULL_FACE_ENABLE                  0x0000183c
-#      define          NV30_TCL_PRIMITIVE_3D_CLEAR_VALUE_DEPTH                 0x00001d8c
-#      define          NV30_TCL_PRIMITIVE_3D_CLEAR_VALUE_ARGB                  0x00001d90      /* Parameters: a r g b */
-#      define          NV30_TCL_PRIMITIVE_3D_CLEAR_WHICH_BUFFERS               0x00001d94
-#      define          NV30_TCL_PRIMITIVE_3D_BACK_MATERIAL_SHININESS_A         0x00001e20
-#      define          NV30_TCL_PRIMITIVE_3D_BACK_MATERIAL_SHININESS_B         0x00001e24
-#      define          NV30_TCL_PRIMITIVE_3D_BACK_MATERIAL_SHININESS_C         0x00001e28
-#      define          NV30_TCL_PRIMITIVE_3D_BACK_MATERIAL_SHININESS_D         0x00001e2c
-#      define          NV30_TCL_PRIMITIVE_3D_BACK_MATERIAL_SHININESS_E         0x00001e30
-#      define          NV30_TCL_PRIMITIVE_3D_BACK_MATERIAL_SHININESS_F         0x00001e34
-#      define          NV30_TCL_PRIMITIVE_3D_DO_VERTICES                       0x00001dac
-#      define          NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_FROM_ID                 0x00001e9c
-#      define          NV30_TCL_PRIMITIVE_3D_VP_PROGRAM_START_ID               0x00001ea0
-#      define          NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_ID                0x00001efc
-#      define          NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_P0_X              0x00001f00
-#      define          NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_P0_Y              0x00001f04
-#      define          NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_P0_Z              0x00001f08
-#      define          NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_P0_W              0x00001f0c
-#      define          NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_P1_X              0x00001f10
-#      define          NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_P1_Y              0x00001f14
-#      define          NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_P1_Z              0x00001f18
-#      define          NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_P1_W              0x00001f1c
-#      define          NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_P2_X              0x00001f20
-#      define          NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_P2_Y              0x00001f24
-#      define          NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_P2_Z              0x00001f28
-#      define          NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_P2_W              0x00001f2c
-#      define          NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_P3_X              0x00001f30
-#      define          NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_P3_Y              0x00001f34
-#      define          NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_P3_Z              0x00001f38
-#      define          NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_P3_W              0x00001f3c
-#      define          NV30_TCL_PRIMITIVE_3D_VTX_ATTR_3X(d)                    (0x00001500 + d * 0x0010)
-#      define          NV30_TCL_PRIMITIVE_3D_VTX_ATTR_3Y(d)                    (0x00001504 + d * 0x0010)
-#      define          NV30_TCL_PRIMITIVE_3D_VTX_ATTR_3Z(d)                    (0x00001508 + d * 0x0010)
-#      define          NV30_TCL_PRIMITIVE_3D_VTX_ATTR_3W(d)                    (0x0000150c + d * 0x0010)
-#      define          NV30_TCL_PRIMITIVE_3D_VTX_ATTR_4X(d)                    (0x00001c00 + d * 0x0010)
-#      define          NV30_TCL_PRIMITIVE_3D_VTX_ATTR_4Y(d)                    (0x00001c04 + d * 0x0010)
-#      define          NV30_TCL_PRIMITIVE_3D_VTX_ATTR_4Z(d)                    (0x00001c08 + d * 0x0010)
-#      define          NV30_TCL_PRIMITIVE_3D_VTX_ATTR_4W(d)                    (0x00001c0c + d * 0x0010)
-#      define          NV30_TCL_PRIMITIVE_3D_VB_POINTER_ATTR(d)                (0x00001680 + d * 0x0004)       /* Parameters: source: offset */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_NOR_3I_XY                  0x00000a90      /* Parameters: y x */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_NOR_3I_Z                   0x00000a94      /* Parameters: z */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_TX0_2F_S                   0x000018c0
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_TX0_2F_T                   0x000018c4
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_TX1_2F_S                   0x000018c8
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_TX1_2F_T                   0x000018cc
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_TX2_2F_S                   0x000018d0
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_TX2_2F_T                   0x000018d4
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_TX3_2F_S                   0x000018d8
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_TX3_2F_T                   0x000018dc
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_TX0_2I                     0x00001920      /* Parameters: t s */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_TX1_2I                     0x00001924      /* Parameters: t s */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_TX2_2I                     0x00001928      /* Parameters: t s */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_TX3_2I                     0x0000192c      /* Parameters: t s */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_COL_4I                     0x0000194c      /* Parameters: a b g r */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_COL2_3I                    0x00001950      /* Parameters: a b g r */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_TX0_4I_ST                  0x000019c0      /* Parameters: t s */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_TX0_4I_RQ                  0x000019c4      /* Parameters: q r */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_TX1_4I_ST                  0x000019c8      /* Parameters: t s */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_TX1_4I_RQ                  0x000019cc      /* Parameters: q r */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_TX2_4I_ST                  0x000019d0      /* Parameters: t s */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_TX2_4I_RQ                  0x000019d4      /* Parameters: q r */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_TX3_4I_ST                  0x000019d8      /* Parameters: t s */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_TX3_4I_RQ                  0x000019dc      /* Parameters: q r */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_FOG_1F                     0x00001e54
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_UNK_0                      0x00001718
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_ATTR( d)                   (0x00001740 + d * 0x0004)
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_ATTR0_POS                  0x00001740      /* Parameters: stride fields type */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_ATTR1_WGH                  0x00001744      /* Parameters: stride fields type */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_ATTR2_NOR                  0x00001748      /* Parameters: stride fields type */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_ATTR3_COL                  0x0000174c      /* Parameters: stride fields type */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_ATTR4_COL2                 0x00001750      /* Parameters: stride fields type */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_ATTR5_FOG                  0x00001754      /* Parameters: stride fields type */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_ATTR6                      0x00001758      /* Parameters: stride fields type */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_ATTR7                      0x0000175c      /* Parameters: stride fields type */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_ATTR8_TX0                  0x00001760      /* Parameters: stride fields type */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_ATTR9_TX1                  0x00001764      /* Parameters: stride fields type */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_ATTR10_TX2                 0x00001768      /* Parameters: stride fields type */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_ATTR11_TX3                 0x0000176c      /* Parameters: stride fields type */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_ATTR12_TX4                 0x00001770      /* Parameters: stride fields type */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_ATTR13_TX5                 0x00001774      /* Parameters: stride fields type */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_ATTR14_TX6                 0x00001778      /* Parameters: stride fields type */
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_ATTR15_TX7                 0x0000177c      /* Parameters: stride fields type */
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_MODEL_BACK_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_R     0x000017a0
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_MODEL_BACK_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_G     0x000017a4
-#      define          NV30_TCL_PRIMITIVE_3D_LIGHT_MODEL_BACK_SIDE_PRODUCT_AMBIENT_PLUS_EMISSION_B     0x000017a8
-#      define          NV30_TCL_PRIMITIVE_3D_FP_ACTIVE_PROGRAM                 0x000008e4
-#      define          NV30_TCL_PRIMITIVE_3D_TX_ADDRESS_UNIT(d)                (0x00001a00 + d * 0x0020)
-#      define          NV30_TCL_PRIMITIVE_3D_TX_FORMAT_UNIT(d)                 (0x00001a04 + d * 0x0020)       /* Parameters: mipmap type format ncomp cubic */
-#      define          NV30_TCL_PRIMITIVE_3D_TX_WRAP_UNIT(d)                   (0x00001a08 + d * 0x0020)       /* Parameters: wrap_s wrap_t wrap_r */
-#      define          NV30_TCL_PRIMITIVE_3D_TX_ENABLE_UNIT(d)                 (0x00001a0c + d * 0x0020)       /* Parameters: nv40_enable nv30_enable anisotropy */
-#      define          NV30_TCL_PRIMITIVE_3D_TX_SWIZZLE_UNIT(d)                (0x00001a10 + d * 0x0020)
-#      define          NV30_TCL_PRIMITIVE_3D_TX_FILTER_UNIT(d)                 (0x00001a14 + d * 0x0020)       /* Parameters: filter_min filter_mag */
-#      define          NV30_TCL_PRIMITIVE_3D_TX_XY_DIM_UNIT(d)                 (0x00001a18 + d * 0x0020)       /* Parameters: width height */
-#      define          NV30_TCL_PRIMITIVE_3D_TX_UNK07_UNIT(d)                  (0x00001a1c + d * 0x0020)
-#      define          NV30_TCL_PRIMITIVE_3D_TX_DEPTH_UNIT(d)                  (0x00001840 + d * 0x0004)       /* Parameters: depth NPOT pitch */
-#      define          NV30_TCL_PRIMITIVE_3D_VB_VERTEX_BATCH                   0x00001814      /* Parameters: count_vertices offset_vertices */
-#      define          NV30_TCL_PRIMITIVE_3D_VB_ELEMENT_U16                    0x0000180c      /* Parameters: 1: 0: */
-#      define          NV30_TCL_PRIMITIVE_3D_VB_ELEMENT_U32                    0x00001810
-#      define          NV30_TCL_PRIMITIVE_3D_VERTEX_DATA                       0x00001818
-#      define          NV30_TCL_PRIMITIVE_3D_COLOR_LOGIC_OP_ENABLE             0x00000374
-#      define          NV30_TCL_PRIMITIVE_3D_COLOR_LOGIC_OP_OP                 0x00000378
-#      define          NV30_TCL_PRIMITIVE_3D_SET_DISPLAY_LIST_MEM_OFFSET       0x0000181c
-#      define          NV30_TCL_PRIMITIVE_3D_EXECUTE_DISPLAY_LIST              0x00001824      /* Parameters: length start offset */
-#      define          NV30_TCL_PRIMITIVE_3D_POLYGON_MODE_FRONT                0x00001828
-#      define          NV30_TCL_PRIMITIVE_3D_POLYGON_MODE_BACK                 0x0000182c
-#      define          NV30_TCL_PRIMITIVE_3D_POLYGON_STIPPLE_ENABLE            0x0000147c
-#      define          NV30_TCL_PRIMITIVE_3D_POLYGON_STIPPLE_PATTERN( d)       (0x00001480 + d * 0x0004)
-#      define          NV30_TCL_PRIMITIVE_3D_SET_CLIPPING_PLANES               0x00001478
-#      define          NV30_TCL_PRIMITIVE_3D_VP_IN_REG                         0x00001ff0      /* Parameters: vertex pos weight normal primary color secondary color fogcoord texture coords 0 texture ccords 1 texture coords 2 texture coords 3 texture coords 4 texture coords 5 texture coords 6 texture coords 7 */
-#      define          NV30_TCL_PRIMITIVE_3D_VP_OUT_REG                        0x00001ff4      /* Parameters: primary color secondary color backface primary color backface secondary color fogcoord pointsize clip plane 0 clip plane 1 clip plane 2 clip plane 3 clip plane 4 clip plane 5 texture coords 0 texture coords 1 texture coords 2 texture coords 3 texture coords 4 texture coords 5 texture coords 6 texture coords 7 */
-
-/****************************************** 
-Object NV30_CLEAR_BUFFER used on: NV30 NV40 G70
-*/
-#define                        NV30_CLEAR_BUFFER                                       0x00000066
-#      define          NV30_CLEAR_BUFFER_SET_DMA_NOTIFY                        0x00000180
-#      define          NV30_CLEAR_BUFFER_SET_IMAGE_PATTERN                     0x00000188
-#      define          NV30_CLEAR_BUFFER_SET_RASTER_OP                         0x0000018c
-#      define          NV30_CLEAR_BUFFER_SET_CONTEXT_SURFACE_2D                0x00000198
-#      define          NV30_CLEAR_BUFFER_UNK002fc                              0x000002fc
-
-/****************************************** 
-Object NV50_TCL_PRIMITIVE_3D used on: 
-*/
-#define                        NV50_TCL_PRIMITIVE_3D                                   0x00000097
-#      define          NV50_TCL_PRIMITIVE_3D_SET_OBJECT_0( d)                  (0x00000180 + d * 0x0004)
-#      define          NV50_TCL_PRIMITIVE_3D_SET_OBJECT_1( d)                  (0x000001c0 + d * 0x0004)
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_FOG_1F                     0x00000314
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_POS_2F_X                   0x00000380
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_POS_2F_Y                   0x00000384
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX0_2F_S                   0x000003c0
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX0_2F_T                   0x000003c4
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX1_2F_S                   0x000003c8
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX1_2F_T                   0x000003cc
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX2_2F_S                   0x000003d0
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX2_2F_T                   0x000003d4
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX3_2F_S                   0x000003d8
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX3_2F_T                   0x000003dc
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_POS_3F_X                   0x00000400
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_POS_3F_Y                   0x00000404
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_POS_3F_Z                   0x00000408
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_NOR_3F_X                   0x00000420
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_NOR_3F_Y                   0x00000424
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_NOR_3F_Z                   0x00000428
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_COL_3F_R                   0x00000430
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_COL_3F_G                   0x00000434
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_COL_3F_B                   0x00000438
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_COL2_3F_R                  0x00000440
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_COL2_3F_G                  0x00000444
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_COL2_3F_B                  0x00000448
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_POS_4F_X                   0x00000500
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_POS_4F_Y                   0x00000504
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_POS_4F_Z                   0x00000508
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_POS_4F_W                   0x0000050c
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_COL_4F_R                   0x00000530
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_COL_4F_G                   0x00000534
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_COL_4F_B                   0x00000538
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_COL_4F_A                   0x0000053c
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX0_4F_S                   0x00000580
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX0_4F_T                   0x00000584
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX0_4F_R                   0x00000588
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX0_4F_Q                   0x0000058c
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX1_4F_S                   0x00000590
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX1_4F_T                   0x00000594
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX1_4F_R                   0x00000598
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX1_4F_Q                   0x0000059c
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX2_4F_S                   0x000005a0
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX2_4F_T                   0x000005a4
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX2_4F_R                   0x000005a8
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX2_4F_Q                   0x000005ac
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX3_4F_S                   0x000005b0
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX3_4F_T                   0x000005b4
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX3_4F_R                   0x000005b8
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX3_4F_Q                   0x000005bc
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX0_2I                     0x000006a0      /* Parameters: t s */
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX1_2I                     0x000006a4      /* Parameters: t s */
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX2_2I                     0x000006a8      /* Parameters: t s */
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX3_2I                     0x000006ac      /* Parameters: t s */
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_POS_4I_XY                  0x00000700      /* Parameters: y x */
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_POS_4I_ZW                  0x00000704      /* Parameters: w z */
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX0_4I_ST                  0x00000740      /* Parameters: t s */
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX0_4I_RQ                  0x00000744      /* Parameters: q r */
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX1_4I_ST                  0x00000748      /* Parameters: t s */
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX1_4I_RQ                  0x0000074c      /* Parameters: q r */
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX2_4I_ST                  0x00000750      /* Parameters: t s */
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX2_4I_RQ                  0x00000754      /* Parameters: q r */
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX3_4I_ST                  0x00000758      /* Parameters: t s */
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_TX3_4I_RQ                  0x0000075c      /* Parameters: q r */
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_NOR_3I_XY                  0x00000790      /* Parameters: y x */
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_NOR_3I_Z                   0x00000794      /* Parameters: z */
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_COL_4I                     0x0000088c      /* Parameters: a b g r */
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_COL2_3I                    0x00000890      /* Parameters: a b g r */
-#      define          NV50_TCL_PRIMITIVE_3D_VIEWPORT_UNK0_X                   0x00000a00
-#      define          NV50_TCL_PRIMITIVE_3D_VIEWPORT_UNK0_Y                   0x00000a04
-#      define          NV50_TCL_PRIMITIVE_3D_VIEWPORT_UNK0_Z                   0x00000a08
-#      define          NV50_TCL_PRIMITIVE_3D_VIEWPORT_UNK1_X                   0x00000a0c
-#      define          NV50_TCL_PRIMITIVE_3D_VIEWPORT_UNK1_Y                   0x00000a10
-#      define          NV50_TCL_PRIMITIVE_3D_VIEWPORT_UNK1_Z                   0x00000a14
-#      define          NV50_TCL_PRIMITIVE_3D_DEPTH_RANGE_NEAR                  0x00000c08
-#      define          NV50_TCL_PRIMITIVE_3D_DEPTH_RANGE_FAR                   0x00000c0c
-#      define          NV50_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(d)            (0x00000d00 + d * 0x0008)       /* Parameters: x2 x1 */
-#      define          NV50_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_VERT(d)             (0x00000d04 + d * 0x0008)       /* Parameters: y2 y1 */
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_BUFFER_FIRST               0x00000d74
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_BUFFER_COUNT               0x00000d78
-#      define          NV50_TCL_PRIMITIVE_3D_CLEAR_COLOR_R                     0x00000d80
-#      define          NV50_TCL_PRIMITIVE_3D_CLEAR_COLOR_G                     0x00000d84
-#      define          NV50_TCL_PRIMITIVE_3D_CLEAR_COLOR_B                     0x00000d88
-#      define          NV50_TCL_PRIMITIVE_3D_CLEAR_COLOR_A                     0x00000d8c
-#      define          NV50_TCL_PRIMITIVE_3D_CLEAR_DEPTH                       0x00000d90
-#      define          NV50_TCL_PRIMITIVE_3D_CLEAR_STENCIL                     0x00000da0
-#      define          NV50_TCL_PRIMITIVE_3D_POLYGON_MODE_FRONT                0x00000dac
-#      define          NV50_TCL_PRIMITIVE_3D_POLYGON_MODE_BACK                 0x00000db0
-#      define          NV50_TCL_PRIMITIVE_3D_POLYGON_SMOOTH_ENABLE             0x00000db4
-#      define          NV50_TCL_PRIMITIVE_3D_POLYGON_OFFSET_POINT_ENABLE       0x00000dc0
-#      define          NV50_TCL_PRIMITIVE_3D_POLYGON_OFFSET_LINE_ENABLE        0x00000dc4
-#      define          NV50_TCL_PRIMITIVE_3D_POLYGON_OFFSET_FILL_ENABLE        0x00000dc8
-#      define          NV50_TCL_PRIMITIVE_3D_SCISSOR_WIDTH_XPOS                0x00000e04      /* Parameters: w x */
-#      define          NV50_TCL_PRIMITIVE_3D_SCISSOR_HEIGHT_YPOS               0x00000e08      /* Parameters: h y */
-#      define          NV50_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_ID                0x00000f00
-#      define          NV50_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_X                 0x00000f04
-#      define          NV50_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_Y                 0x00000f08
-#      define          NV50_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_Z                 0x00000f0c
-#      define          NV50_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_W                 0x00000f10
-#      define          NV50_TCL_PRIMITIVE_3D_STENCIL_FRONT_FUNC_REF            0x00000f54
-#      define          NV50_TCL_PRIMITIVE_3D_STENCIL_FRONT_MASK                0x00000f58
-#      define          NV50_TCL_PRIMITIVE_3D_STENCIL_FRONT_FUNC_MASK           0x00000f5c
-#      define          NV50_TCL_PRIMITIVE_3D_DEPTH_TEST_ENABLE                 0x000012cc
-#      define          NV50_TCL_PRIMITIVE_3D_SHADE_MODEL                       0x000012d4
-#      define          NV50_TCL_PRIMITIVE_3D_DEPTH_WRITE_ENABLE                0x000012e8
-#      define          NV50_TCL_PRIMITIVE_3D_ALPHA_FUNC_ENABLE                 0x000012ec
-#      define          NV50_TCL_PRIMITIVE_3D_DEPTH_FUNC                        0x0000130c
-#      define          NV50_TCL_PRIMITIVE_3D_ALPHA_FUNC_REF                    0x00001310
-#      define          NV50_TCL_PRIMITIVE_3D_ALPHA_FUNC_FUNC                   0x00001314
-#      define          NV50_TCL_PRIMITIVE_3D_BLEND_COLOR_R                     0x0000131c
-#      define          NV50_TCL_PRIMITIVE_3D_BLEND_COLOR_G                     0x00001320
-#      define          NV50_TCL_PRIMITIVE_3D_BLEND_COLOR_B                     0x00001324
-#      define          NV50_TCL_PRIMITIVE_3D_BLEND_COLOR_A                     0x00001328
-#      define          NV50_TCL_PRIMITIVE_3D_BLEND_EQUATION_RGB                0x00001340
-#      define          NV50_TCL_PRIMITIVE_3D_BLEND_FUNC_SRC_RGB                0x00001344
-#      define          NV50_TCL_PRIMITIVE_3D_BLEND_FUNC_DST_RGB                0x00001348
-#      define          NV50_TCL_PRIMITIVE_3D_BLEND_EQUATION_ALPHA              0x0000134c
-#      define          NV50_TCL_PRIMITIVE_3D_BLEND_FUNC_SRC_ALPHA              0x00001350
-#      define          NV50_TCL_PRIMITIVE_3D_BLEND_FUNC_DST_ALPHA              0x00001358
-#      define          NV50_TCL_PRIMITIVE_3D_STENCIL_BACK_ENABLE               0x00001380
-#      define          NV50_TCL_PRIMITIVE_3D_STENCIL_BACK_OP_FAIL              0x00001384
-#      define          NV50_TCL_PRIMITIVE_3D_STENCIL_BACK_OP_ZFAIL             0x00001388
-#      define          NV50_TCL_PRIMITIVE_3D_STENCIL_BACK_OP_ZPASS             0x0000138c
-#      define          NV50_TCL_PRIMITIVE_3D_STENCIL_BACK_FUNC_FUNC            0x00001390
-#      define          NV50_TCL_PRIMITIVE_3D_STENCIL_BACK_FUNC_REF             0x00001394
-#      define          NV50_TCL_PRIMITIVE_3D_STENCIL_BACK_MASK                 0x00001398
-#      define          NV50_TCL_PRIMITIVE_3D_STENCIL_BACK_FUNC_MASK            0x0000139c
-#      define          NV50_TCL_PRIMITIVE_3D_LINE_WIDTH                        0x000013b0
-#      define          NV50_TCL_PRIMITIVE_3D_POINT_SIZE                        0x00001518
-#      define          NV50_TCL_PRIMITIVE_3D_POLYGON_OFFSET_FACTOR             0x0000156c
-#      define          NV50_TCL_PRIMITIVE_3D_LINE_SMOOTH_ENABLE                0x00001570
-#      define          NV50_TCL_PRIMITIVE_3D_STENCIL_FRONT_ENABLE              0x00001594
-#      define          NV50_TCL_PRIMITIVE_3D_STENCIL_FRONT_OP_FAIL             0x00001598
-#      define          NV50_TCL_PRIMITIVE_3D_STENCIL_FRONT_OP_ZFAIL            0x0000159c
-#      define          NV50_TCL_PRIMITIVE_3D_STENCIL_FRONT_OP_ZPASS            0x000015a0
-#      define          NV50_TCL_PRIMITIVE_3D_STENCIL_FRONT_FUNC_FUNC           0x000015a4
-#      define          NV50_TCL_PRIMITIVE_3D_POLYGON_OFFSET_UNITS              0x000015bc
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_BEGIN                      0x000015dc
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_END                        0x000015e0
-#      define          NV50_TCL_PRIMITIVE_3D_VERTEX_DATA                       0x00001640
-#      define          NV50_TCL_PRIMITIVE_3D_LINE_STIPPLE_ENABLE               0x0000166c
-#      define          NV50_TCL_PRIMITIVE_3D_LINE_STIPPLE_PATTERN              0x00001680      /* Parameters: pattern factor */
-#      define          NV50_TCL_PRIMITIVE_3D_POLYGON_STIPPLE_ENABLE            0x0000168c
-#      define          NV50_TCL_PRIMITIVE_3D_POLYGON_STIPPLE_PATTERN( d)       (0x00001700 + d * 0x0004)
-#      define          NV50_TCL_PRIMITIVE_3D_CULL_FACE_ENABLE                  0x00001918
-#      define          NV50_TCL_PRIMITIVE_3D_FRONT_FACE                        0x0000191c
-#      define          NV50_TCL_PRIMITIVE_3D_CULL_FACE                         0x00001920
-#      define          NV50_TCL_PRIMITIVE_3D_LOGIC_OP_ENABLE                   0x000019c4
-#      define          NV50_TCL_PRIMITIVE_3D_LOGIC_OP_OP                       0x000019c8
-#      define          NV50_TCL_PRIMITIVE_3D_CLEAR_BUFFERS                     0x000019d0      /* Parameters: color stencil depth */
-#      define          NV50_TCL_PRIMITIVE_3D_COLOR_MASK( d)                    (0x00001a00 + d * 0x0004)       /* Parameters: a b g r */
-
-/****************************************** 
-Object NV_DMA_FROM_MEMORY used on: NV03 NV04 NV10 NV15 NV20 NV30 NV40 G70
-*/
-#define                        NV_DMA_FROM_MEMORY                                      0x00000002
-
-/****************************************** 
-Object NV_DMA_TO_MEMORY used on: NV03 NV04 NV10 NV15 NV20 NV30 NV40 G70
-*/
-#define                        NV_DMA_TO_MEMORY                                        0x00000003
-
-/****************************************** 
-Object NV_DMA_IN_MEMORY used on: NV03 NV04 NV10 NV15 NV20 NV30 NV40 G70
-*/
-#define                        NV_DMA_IN_MEMORY                                        0x0000003d
-
-/****************************************** 
-Object NvType0046 used on: NV04 
-*/
-#define                        NvType0046                                              0x00000046
-#      define          NvType0046_DMA_NOTIFY                                   0x00000180
-#      define          NvType0046_DMA_MEM_1                                    0x00000184
-#      define          NvType0046_DMA_MEM_2                                    0x00000188
-#      define          NvType0046_DMA_3                                        0x0000018c
-#      define          NvType0046_DMA_4                                        0x00000190
-#      define          NvType0046_OBJ_5                                        0x00000194
-#      define          NvType0046_OBJ_6                                        0x00000198
-#      define          NvType0046_PITCH1                                       0x00000304
-#      define          NvType0046_PITCH2                                       0x0000030c
-#      define          NvType0046_SIZE                                         0x00000340      /* Parameters: width height */
-#      define          NvType0046_WIDTH                                        0x00000344      /* Parameters: visible_width blank_width */
-#      define          NvType0046_HSYNC                                        0x00000348      /* Parameters: hsync_start hsync_len */
-#      define          NvType0046_HEIGHT                                       0x0000034c      /* Parameters: visible_height blank_height */
-#      define          NvType0046_VSYNC                                        0x00000350      /* Parameters: vsync_start vsync_len */
-#      define          NvType0046_FULL_SIZE                                    0x00000354      /* Parameters: full_width full_height */
-#      define          NvType0046_PIXEL_CLK                                    0x00000358
-#      define          NvType0046_FLAGS                                        0x0000035c      /* Parameters: doublescan -hsync -vsync depth */
-
-/****************************************** 
-Object NvType0047 used on: NV04 
-*/
-#define                        NvType0047                                              0x00000047
-#      define          NvType0047_DMA_NOTIFY                                   0x00000180
-#      define          NvType0047_UNK19C                                       0x0000019c
-#      define          NvType0047_UNK1A0                                       0x000001a0
-
-/****************************************** 
-Object NvType0049 used on: NV04 
-*/
-#define                        NvType0049                                              0x00000049
-#      define          NvType0049_DMA_NOTIFY                                   0x00000180
-#      define          NvType0049_DMA_MEM_1                                    0x00000184
-#      define          NvType0049_DMA_MEM_2                                    0x00000188
-
-/****************************************** 
-Object NvType004D used on: NV04 
-*/
-#define                        NvType004D                                              0x0000004d
-#      define          NvType004D_DMA_NOTIFY                                   0x00000180
-#      define          NvType004D_DMA_MEM_1                                    0x00000184
-#      define          NvType004D_DMA_MEM_2                                    0x00000188
-#      define          NvType004D_DMA_MEM_3                                    0x0000018c
-#      define          NvType004D_DMA_MEM_4                                    0x00000190
-
-#endif /* _NOUVEAU_REG_H */
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader.c b/src/mesa/drivers/dri/nouveau/nouveau_shader.c
deleted file mode 100644 (file)
index b6837c5..0000000
+++ /dev/null
@@ -1,833 +0,0 @@
-/*
- * Copyright (C) 2006 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>
- */
-
-#include "glheader.h"
-#include "macros.h"
-#include "enums.h"
-#include "extensions.h"
-
-#include "shader/program.h"
-#include "shader/prog_instruction.h"
-/*#include "shader/arbprogparse.h"*/
-#include "tnl/tnl.h"
-
-#include "nouveau_context.h"
-#include "nouveau_shader.h"
-
-/*****************************************************************************
- * Mesa entry points
- */
-static void
-nouveauBindProgram(GLcontext *ctx, GLenum target, struct gl_program *prog)
-{
-   NVSDBG("target=%s, prog=%p\n", _mesa_lookup_enum_by_nr(target), prog);
-}
-
-static struct gl_program *
-nouveauNewProgram(GLcontext *ctx, GLenum target, GLuint id)
-{
-   nouveauShader *nvs;
-
-   NVSDBG("target=%s, id=%d\n", _mesa_lookup_enum_by_nr(target), id);
-
-   nvs = CALLOC_STRUCT(_nouveauShader);
-   NVSDBG("prog=%p\n", nvs);
-   switch (target) {
-   case GL_VERTEX_PROGRAM_ARB:
-      return _mesa_init_vertex_program(ctx, &nvs->mesa.vp, target, id);
-   case GL_FRAGMENT_PROGRAM_ARB:
-      return _mesa_init_fragment_program(ctx, &nvs->mesa.fp, target, id);
-   default:
-      _mesa_problem(ctx, "Unsupported shader target");
-      break;
-   }
-
-   FREE(nvs);
-   return NULL;
-}
-
-static void
-nouveauDeleteProgram(GLcontext *ctx, struct gl_program *prog)
-{
-   nouveauShader *nvs = (nouveauShader *)prog;
-
-   NVSDBG("prog=%p\n", prog);
-
-   if (nvs->translated)
-      FREE(nvs->program);
-   _mesa_delete_program(ctx, prog);
-}
-
-static void
-nouveauProgramStringNotify(GLcontext *ctx, GLenum target,
-                          struct gl_program *prog)
-{
-   nouveauShader *nvs = (nouveauShader *)prog;
-
-   NVSDBG("target=%s, prog=%p\n", _mesa_lookup_enum_by_nr(target), prog);
-
-   if (nvs->translated)
-      FREE(nvs->program);
-
-   nvs->error      = GL_FALSE;
-   nvs->translated = GL_FALSE;
-
-   _tnl_program_string(ctx, target, prog);
-}
-
-static GLboolean
-nouveauIsProgramNative(GLcontext * ctx, GLenum target, struct gl_program *prog)
-{
-   nouveauShader *nvs = (nouveauShader *)prog;
-
-   NVSDBG("target=%s, prog=%p\n", _mesa_lookup_enum_by_nr(target), prog);
-
-   return nvs->translated;
-}
-
-GLboolean
-nvsUpdateShader(GLcontext *ctx, nouveauShader *nvs)
-{
-   nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-   struct gl_program_parameter_list *plist;
-   int i;
-
-   NVSDBG("prog=%p\n", nvs);
-
-   /* Translate to HW format now if necessary */
-   if (!nvs->translated) {
-      /* Mesa ASM shader -> nouveauShader */
-      if (!nouveau_shader_pass0(ctx, nvs))
-        return GL_FALSE;
-      /* Basic dead code elimination + register usage info */
-      if (!nouveau_shader_pass1(nvs))
-        return GL_FALSE;
-      /* nouveauShader -> HW bytecode, HW register alloc */
-      if (!nouveau_shader_pass2(nvs))
-        return GL_FALSE;
-      assert(nvs->translated);
-      assert(nvs->program);
-   }
-   
-   /* Update state parameters */
-   plist = nvs->mesa.vp.Base.Parameters;
-   _mesa_load_state_parameters(ctx, plist);
-   for (i=0; i<nvs->param_high; i++) {
-      if (!nvs->params[i].in_use)
-        continue;
-
-      if (!nvs->on_hardware) {
-        /* if we've been kicked off the hardware there's no guarantee our
-         * consts are still there.. reupload them all
-         */
-        nvs->func->UpdateConst(ctx, nvs, i);
-      } else if (nvs->params[i].source_val) {
-        /* update any changed state parameters */
-        if (!TEST_EQ_4V(nvs->params[i].val, nvs->params[i].source_val))
-           nvs->func->UpdateConst(ctx, nvs, i);
-      }
-   }
-
-   /* Upload program to hardware, this must come after state param update
-    * as >=NV30 fragprogs inline consts into the bytecode.
-    */
-   if (!nvs->on_hardware) {
-      nouveauShader **current;
-
-      if (nvs->mesa.vp.Base.Target == GL_VERTEX_PROGRAM_ARB)
-        current = &nmesa->current_vertprog;
-      else
-        current = &nmesa->current_fragprog;
-      if (*current) (*current)->on_hardware = 0;
-
-      nvs->func->UploadToHW(ctx, nvs);
-      nvs->on_hardware = 1;
-
-      *current = nvs;
-   }
-
-   return GL_TRUE;
-}
-
-nouveauShader *
-nvsBuildTextShader(GLcontext *ctx, GLenum target, const char *text)
-{
-   nouveauShader *nvs;
-
-   nvs = CALLOC_STRUCT(_nouveauShader);
-   if (!nvs)
-      return NULL;
-
-   if (target == GL_VERTEX_PROGRAM_ARB) {
-      _mesa_init_vertex_program(ctx, &nvs->mesa.vp, GL_VERTEX_PROGRAM_ARB, 0);
-      _mesa_parse_arb_vertex_program(ctx,
-                                    GL_VERTEX_PROGRAM_ARB,
-                                    text,
-                                    strlen(text),
-                                    &nvs->mesa.vp);
-   } else if (target == GL_FRAGMENT_PROGRAM_ARB) {
-      _mesa_init_fragment_program(ctx, &nvs->mesa.fp, GL_FRAGMENT_PROGRAM_ARB, 0);
-      _mesa_parse_arb_fragment_program(ctx,
-                                      GL_FRAGMENT_PROGRAM_ARB,
-                                      text,
-                                      strlen(text),
-                                      &nvs->mesa.fp);
-   }
-
-   nouveau_shader_pass0(ctx, nvs);
-   nouveau_shader_pass1(nvs);
-   nouveau_shader_pass2(nvs);
-
-   return nvs;
-}
-
-static void
-nvsBuildPassthroughVP(GLcontext *ctx)
-{
-   nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-   const char *vp_text =
-      "!!ARBvp1.0\n"
-      "OPTION ARB_position_invariant;"
-      ""
-      "MOV result.color, vertex.color;\n"
-      "MOV result.texcoord[0], vertex.texcoord[0];\n"
-      "MOV result.texcoord[1], vertex.texcoord[1];\n"
-      "MOV result.texcoord[2], vertex.texcoord[2];\n"
-      "MOV result.texcoord[3], vertex.texcoord[3];\n"
-      "MOV result.texcoord[4], vertex.texcoord[4];\n"
-      "MOV result.texcoord[5], vertex.texcoord[5];\n"
-      "MOV result.texcoord[6], vertex.texcoord[6];\n"
-      "MOV result.texcoord[7], vertex.texcoord[7];\n"
-      "END";
-
-   nmesa->passthrough_vp = nvsBuildTextShader(ctx,
-                                             GL_VERTEX_PROGRAM_ARB,
-                                             vp_text);
-}
-
-static void
-nvsBuildPassthroughFP(GLcontext *ctx)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       const char *fp_text =
-               "!!ARBfp1.0\n"
-               "MOV result.color, fragment.color;\n"
-               "END";
-
-       nmesa->passthrough_fp = nvsBuildTextShader(ctx,
-                                                  GL_FRAGMENT_PROGRAM_ARB,
-                                                  fp_text);
-}
-
-void
-nouveauShaderInitFuncs(GLcontext * ctx)
-{
-   nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-   switch (nmesa->screen->card->type) {
-   case NV_20:
-      NV20VPInitShaderFuncs(&nmesa->VPfunc);
-      break;
-   case NV_30:
-      NV30VPInitShaderFuncs(&nmesa->VPfunc);
-      NV30FPInitShaderFuncs(&nmesa->FPfunc);
-      break;
-   case NV_40:
-   case NV_44:
-      NV40VPInitShaderFuncs(&nmesa->VPfunc);
-      NV40FPInitShaderFuncs(&nmesa->FPfunc);
-      break;
-   case NV_50:
-   default:
-      return;
-   }
-
-   /* Build a vertex program that simply passes through all attribs.
-    * Needed to do swtcl on nv40
-    */
-   if (nmesa->screen->card->type >= NV_40)
-      nvsBuildPassthroughVP(ctx);
-
-   /* Needed on NV30, even when using swtcl, if you want to get colours */
-   if (nmesa->screen->card->type >= NV_30)
-      nvsBuildPassthroughFP(ctx);
-
-   ctx->Const.VertexProgram.MaxNativeInstructions    = nmesa->VPfunc.MaxInst;
-   ctx->Const.VertexProgram.MaxNativeAluInstructions = nmesa->VPfunc.MaxInst;
-   ctx->Const.VertexProgram.MaxNativeTexInstructions = nmesa->VPfunc.MaxInst;
-   ctx->Const.VertexProgram.MaxNativeTexIndirections =
-      ctx->Const.VertexProgram.MaxNativeTexInstructions;
-   ctx->Const.VertexProgram.MaxNativeAttribs         = nmesa->VPfunc.MaxAttrib;
-   ctx->Const.VertexProgram.MaxNativeTemps           = nmesa->VPfunc.MaxTemp;
-   ctx->Const.VertexProgram.MaxNativeAddressRegs     = nmesa->VPfunc.MaxAddress;
-   ctx->Const.VertexProgram.MaxNativeParameters      = nmesa->VPfunc.MaxConst;
-
-   if (nmesa->screen->card->type >= NV_30) {
-      ctx->Const.FragmentProgram.MaxNativeInstructions    = nmesa->FPfunc.MaxInst;
-      ctx->Const.FragmentProgram.MaxNativeAluInstructions = nmesa->FPfunc.MaxInst;
-      ctx->Const.FragmentProgram.MaxNativeTexInstructions = nmesa->FPfunc.MaxInst;
-      ctx->Const.FragmentProgram.MaxNativeTexIndirections =
-        ctx->Const.FragmentProgram.MaxNativeTexInstructions;
-      ctx->Const.FragmentProgram.MaxNativeAttribs         = nmesa->FPfunc.MaxAttrib;
-      ctx->Const.FragmentProgram.MaxNativeTemps           = nmesa->FPfunc.MaxTemp;
-      ctx->Const.FragmentProgram.MaxNativeAddressRegs     = nmesa->FPfunc.MaxAddress;
-      ctx->Const.FragmentProgram.MaxNativeParameters      = nmesa->FPfunc.MaxConst;
-   }
-
-   ctx->Driver.NewProgram              = nouveauNewProgram;
-   ctx->Driver.BindProgram             = nouveauBindProgram;
-   ctx->Driver.DeleteProgram           = nouveauDeleteProgram;
-   ctx->Driver.ProgramStringNotify     = nouveauProgramStringNotify;
-   ctx->Driver.IsProgramNative         = nouveauIsProgramNative;
-}
-
-
-/*****************************************************************************
- * Disassembly support structs
- */
-#define CHECK_RANGE(idx, arr) ((idx)<sizeof(_##arr)/sizeof(const char *)) \
-       ? _##arr[(idx)] : #arr"_OOB"
-
-#define NODS      (1<<0)
-#define BRANCH_TR (1<<1)
-#define BRANCH_EL (1<<2)
-#define BRANCH_EN (1<<3)
-#define BRANCH_RE (1<<4)
-#define BRANCH_ALL (BRANCH_TR|BRANCH_EL|BRANCH_EN)
-#define COUNT_INC (1<<4)
-#define COUNT_IND (1<<5)
-#define COUNT_NUM (1<<6)
-#define COUNT_ALL (COUNT_INC|COUNT_IND|COUNT_NUM)
-#define TI_UNIT   (1<<7)
-struct _opcode_info
-{
-   const char *name;
-   int numsrc;
-   int flags;
-};
-
-static struct _opcode_info ops[] = {
-   [NVS_OP_ABS] = {"ABS", 1, 0},
-   [NVS_OP_ADD] = {"ADD", 2, 0},
-   [NVS_OP_ARA] = {"ARA", 1, 0},
-   [NVS_OP_ARL] = {"ARL", 1, 0},
-   [NVS_OP_ARR] = {"ARR", 1, 0},
-   [NVS_OP_BRA] = {"BRA", 0, NODS | BRANCH_TR},
-   [NVS_OP_BRK] = {"BRK", 0, NODS},
-   [NVS_OP_CAL] = {"CAL", 0, NODS | BRANCH_TR},
-   [NVS_OP_CMP] = {"CMP", 2, 0},
-   [NVS_OP_COS] = {"COS", 1, 0},
-   [NVS_OP_DIV] = {"DIV", 2, 0},
-   [NVS_OP_DDX] = {"DDX", 1, 0},
-   [NVS_OP_DDY] = {"DDY", 1, 0},
-   [NVS_OP_DP2] = {"DP2", 2, 0},
-   [NVS_OP_DP2A] = {"DP2A", 3, 0},
-   [NVS_OP_DP3] = {"DP3", 2, 0},
-   [NVS_OP_DP4] = {"DP4", 2, 0},
-   [NVS_OP_DPH] = {"DPH", 2, 0},
-   [NVS_OP_DST] = {"DST", 2, 0},
-   [NVS_OP_EX2] = {"EX2", 1, 0},
-   [NVS_OP_EXP] = {"EXP", 1, 0},
-   [NVS_OP_FLR] = {"FLR", 1, 0},
-   [NVS_OP_FRC] = {"FRC", 1, 0},
-   [NVS_OP_IF] = {"IF", 0, NODS | BRANCH_EL | BRANCH_EN},
-   [NVS_OP_KIL] = {"KIL", 1, 0},
-   [NVS_OP_LG2] = {"LG2", 1, 0},
-   [NVS_OP_LIT] = {"LIT", 1, 0},
-   [NVS_OP_LOG] = {"LOG", 1, 0},
-   [NVS_OP_LOOP] = {"LOOP", 0, NODS | COUNT_ALL | BRANCH_EN},
-   [NVS_OP_LRP] = {"LRP", 3, 0},
-   [NVS_OP_MAD] = {"MAD", 3, 0},
-   [NVS_OP_MAX] = {"MAX", 2, 0},
-   [NVS_OP_MIN] = {"MIN", 2, 0},
-   [NVS_OP_MOV] = {"MOV", 1, 0},
-   [NVS_OP_MUL] = {"MUL", 2, 0},
-   [NVS_OP_NRM] = {"NRM", 1, 0},
-   [NVS_OP_PK2H] = {"PK2H", 1, 0},
-   [NVS_OP_PK2US] = {"PK2US", 1, 0},
-   [NVS_OP_PK4B] = {"PK4B", 1, 0},
-   [NVS_OP_PK4UB] = {"PK4UB", 1, 0},
-   [NVS_OP_POW] = {"POW", 2, 0},
-   [NVS_OP_POPA] = {"POPA", 0, 0},
-   [NVS_OP_PUSHA] = {"PUSHA", 1, NODS},
-   [NVS_OP_RCC] = {"RCC", 1, 0},
-   [NVS_OP_RCP] = {"RCP", 1, 0},
-   [NVS_OP_REP] = {"REP", 0, NODS | BRANCH_EN | COUNT_NUM},
-   [NVS_OP_RET] = {"RET", 0, NODS},
-   [NVS_OP_RFL] = {"RFL", 1, 0},
-   [NVS_OP_RSQ] = {"RSQ", 1, 0},
-   [NVS_OP_SCS] = {"SCS", 1, 0},
-   [NVS_OP_SEQ] = {"SEQ", 2, 0},
-   [NVS_OP_SFL] = {"SFL", 2, 0},
-   [NVS_OP_SGE] = {"SGE", 2, 0},
-   [NVS_OP_SGT] = {"SGT", 2, 0},
-   [NVS_OP_SIN] = {"SIN", 1, 0},
-   [NVS_OP_SLE] = {"SLE", 2, 0},
-   [NVS_OP_SLT] = {"SLT", 2, 0},
-   [NVS_OP_SNE] = {"SNE", 2, 0},
-   [NVS_OP_SSG] = {"SSG", 1, 0},
-   [NVS_OP_STR] = {"STR", 2, 0},
-   [NVS_OP_SUB] = {"SUB", 2, 0},
-   [NVS_OP_TEX] = {"TEX", 1, TI_UNIT},
-   [NVS_OP_TXB] = {"TXB", 1, TI_UNIT},
-   [NVS_OP_TXD] = {"TXD", 3, TI_UNIT},
-   [NVS_OP_TXL] = {"TXL", 1, TI_UNIT},
-   [NVS_OP_TXP] = {"TXP", 1, TI_UNIT},
-   [NVS_OP_UP2H] = {"UP2H", 1, 0},
-   [NVS_OP_UP2US] = {"UP2US", 1, 0},
-   [NVS_OP_UP4B] = {"UP4B", 1, 0},
-   [NVS_OP_UP4UB] = {"UP4UB", 1, 0},
-   [NVS_OP_X2D] = {"X2D", 3, 0},
-   [NVS_OP_XPD] = {"XPD", 2, 0},
-   [NVS_OP_NOP] = {"NOP", 0, NODS},
-};
-
-static struct _opcode_info *
-_get_op_info(int op)
-{
-   if (op >= (sizeof(ops) / sizeof(struct _opcode_info)))
-      return NULL;
-   if (ops[op].name == NULL)
-      return NULL;
-   return &ops[op];
-}
-
-static const char *_SFR_STRING[] = {
-   [NVS_FR_POSITION] = "position",
-   [NVS_FR_WEIGHT] = "weight",
-   [NVS_FR_NORMAL] = "normal",
-   [NVS_FR_COL0] = "color",
-   [NVS_FR_COL1] = "color.secondary",
-   [NVS_FR_BFC0] = "bfc",
-   [NVS_FR_BFC1] = "bfc.secondary",
-   [NVS_FR_FOGCOORD] = "fogcoord",
-   [NVS_FR_POINTSZ] = "pointsize",
-   [NVS_FR_TEXCOORD0] = "texcoord[0]",
-   [NVS_FR_TEXCOORD1] = "texcoord[1]",
-   [NVS_FR_TEXCOORD2] = "texcoord[2]",
-   [NVS_FR_TEXCOORD3] = "texcoord[3]",
-   [NVS_FR_TEXCOORD4] = "texcoord[4]",
-   [NVS_FR_TEXCOORD5] = "texcoord[5]",
-   [NVS_FR_TEXCOORD6] = "texcoord[6]",
-   [NVS_FR_TEXCOORD7] = "texcoord[7]",
-   [NVS_FR_FRAGDATA0] = "data[0]",
-   [NVS_FR_FRAGDATA1] = "data[1]",
-   [NVS_FR_FRAGDATA2] = "data[2]",
-   [NVS_FR_FRAGDATA3] = "data[3]",
-   [NVS_FR_CLIP0] = "clip_plane[0]",
-   [NVS_FR_CLIP1] = "clip_plane[1]",
-   [NVS_FR_CLIP2] = "clip_plane[2]",
-   [NVS_FR_CLIP3] = "clip_plane[3]",
-   [NVS_FR_CLIP4] = "clip_plane[4]",
-   [NVS_FR_CLIP5] = "clip_plane[5]",
-   [NVS_FR_CLIP6] = "clip_plane[6]",
-   [NVS_FR_FACING] = "facing",
-};
-
-#define SFR_STRING(idx) CHECK_RANGE((idx), SFR_STRING)
-
-static const char *_SWZ_STRING[] = {
-   [NVS_SWZ_X] = "x",
-   [NVS_SWZ_Y] = "y",
-   [NVS_SWZ_Z] = "z",
-   [NVS_SWZ_W] = "w"
-};
-
-#define SWZ_STRING(idx) CHECK_RANGE((idx), SWZ_STRING)
-
-static const char *_NVS_PREC_STRING[] = {
-   [NVS_PREC_FLOAT32] = "R",
-   [NVS_PREC_FLOAT16] = "H",
-   [NVS_PREC_FIXED12] = "X",
-   [NVS_PREC_UNKNOWN] = "?"
-};
-
-#define NVS_PREC_STRING(idx) CHECK_RANGE((idx), NVS_PREC_STRING)
-
-static const char *_NVS_COND_STRING[] = {
-   [NVS_COND_FL] = "FL",
-   [NVS_COND_LT] = "LT",
-   [NVS_COND_EQ] = "EQ",
-   [NVS_COND_LE] = "LE",
-   [NVS_COND_GT] = "GT",
-   [NVS_COND_NE] = "NE",
-   [NVS_COND_GE] = "GE",
-   [NVS_COND_TR] = "TR",
-   [NVS_COND_UNKNOWN] = "??"
-};
-
-#define NVS_COND_STRING(idx) CHECK_RANGE((idx), NVS_COND_STRING)
-
-/*****************************************************************************
- * ShaderFragment dumping
- */
-static void
-nvsDumpIndent(int lvl)
-{
-   while (lvl--)
-      printf("  ");
-}
-
-static void
-nvsDumpSwizzle(nvsSwzComp *swz)
-{
-   printf(".%s%s%s%s",
-         SWZ_STRING(swz[0]),
-         SWZ_STRING(swz[1]), SWZ_STRING(swz[2]), SWZ_STRING(swz[3])
-      );
-}
-
-static void
-nvsDumpReg(nvsInstruction * inst, nvsRegister * reg)
-{
-   if (reg->negate)
-      printf("-");
-   if (reg->abs)
-      printf("abs(");
-
-   switch (reg->file) {
-   case NVS_FILE_TEMP:
-      printf("R%d", reg->index);
-      nvsDumpSwizzle(reg->swizzle);
-      break;
-   case NVS_FILE_ATTRIB:
-      printf("attrib.%s", SFR_STRING(reg->index));
-      nvsDumpSwizzle(reg->swizzle);
-      break;
-   case NVS_FILE_ADDRESS:
-      printf("A%d", reg->index);
-      break;
-   case NVS_FILE_CONST:
-      if (reg->indexed)
-        printf("const[A%d.%s + %d]",
-               reg->addr_reg, SWZ_STRING(reg->addr_comp), reg->index);
-      else
-        printf("const[%d]", reg->index);
-      nvsDumpSwizzle(reg->swizzle);
-      break;
-   default:
-      printf("UNKNOWN_FILE");
-      break;
-   }
-
-   if (reg->abs)
-      printf(")");
-}
-
-static void
-nvsDumpInstruction(nvsInstruction * inst, int slot, int lvl)
-{
-   struct _opcode_info *opr = &ops[inst->op];
-   int i;
-
-   nvsDumpIndent(lvl);
-   printf("%s ", opr->name);
-
-   if (!opr->flags & NODS) {
-      switch (inst->dest.file) {
-      case NVS_FILE_RESULT:
-        printf("result.%s", SFR_STRING(inst->dest.index));
-        break;
-      case NVS_FILE_TEMP:
-        printf("R%d", inst->dest.index);
-        break;
-      case NVS_FILE_ADDRESS:
-        printf("A%d", inst->dest.index);
-        break;
-      default:
-        printf("UNKNOWN_DST_FILE");
-        break;
-      }
-
-      if (inst->mask != SMASK_ALL) {
-        printf(".");
-        if (inst->mask & SMASK_X)
-           printf("x");
-        if (inst->mask & SMASK_Y)
-           printf("y");
-        if (inst->mask & SMASK_Z)
-           printf("z");
-        if (inst->mask & SMASK_W)
-           printf("w");
-      }
-
-      if (opr->numsrc)
-        printf(", ");
-   }
-
-   for (i = 0; i < opr->numsrc; i++) {
-      nvsDumpReg(inst, &inst->src[i]);
-      if (i != opr->numsrc - 1)
-        printf(", ");
-   }
-   if (opr->flags & TI_UNIT)
-      printf(", texture[%d]", inst->tex_unit);
-
-   printf("\n");
-}
-
-void
-nvsDumpFragmentList(nvsFragmentHeader *f, int lvl)
-{
-   while (f) {
-      switch (f->type) {
-      case NVS_INSTRUCTION:
-        nvsDumpInstruction((nvsInstruction*)f, 0, lvl);
-        break;
-      default:
-        fprintf(stderr, "%s: Only NVS_INSTRUCTION fragments can be in"
-                        "nvsFragmentList!\n", __func__);
-        return;
-      }
-      f = f->next;
-   }
-}
-
-/*****************************************************************************
- * HW shader disassembly
- */
-static void
-nvsDisasmHWShaderOp(nvsFunc * shader, int merged)
-{
-   struct _opcode_info *opi;
-   nvsOpcode op;
-   nvsRegFile file;
-   nvsSwzComp swz[4];
-   int i;
-
-   op = shader->GetOpcode(shader, merged);
-   opi = _get_op_info(op);
-   if (!opi) {
-      printf("NO OPINFO!");
-      return;
-   }
-
-   printf("%s", opi->name);
-   if (shader->GetPrecision &&
-       (!(opi->flags & BRANCH_ALL)) && (!(opi->flags * NODS)) &&
-       (op != NVS_OP_NOP))
-      printf("%s", NVS_PREC_STRING(shader->GetPrecision(shader)));
-   if (shader->SupportsConditional && shader->SupportsConditional(shader)) {
-      if (shader->GetConditionUpdate(shader)) {
-        printf("C%d", shader->GetCondRegID(shader));
-      }
-   }
-   if (shader->GetSaturate && shader->GetSaturate(shader))
-      printf("_SAT");
-
-   if (!(opi->flags & NODS)) {
-      int mask = shader->GetDestMask(shader, merged);
-
-      switch (shader->GetDestFile(shader, merged)) {
-      case NVS_FILE_ADDRESS:
-        printf(" A%d", shader->GetDestID(shader, merged));
-        break;
-      case NVS_FILE_TEMP:
-        printf(" R%d", shader->GetDestID(shader, merged));
-        break;
-      case NVS_FILE_RESULT:
-        printf(" result.%s", (SFR_STRING(shader->GetDestID(shader, merged))));
-        break;
-      default:
-        printf(" BAD_RESULT_FILE");
-        break;
-      }
-
-      if (mask != SMASK_ALL) {
-        printf(".");
-        if (mask & SMASK_X) printf("x");
-        if (mask & SMASK_Y) printf("y");
-        if (mask & SMASK_Z) printf("z");
-        if (mask & SMASK_W) printf("w");
-      }
-   }
-
-   if (shader->SupportsConditional && shader->SupportsConditional(shader) &&
-       shader->GetConditionTest(shader)) {
-      shader->GetCondRegSwizzle(shader, swz);
-
-      printf(" (%s%d.%s%s%s%s)",
-           NVS_COND_STRING(shader->GetCondition(shader)),
-           shader->GetCondRegID(shader),
-           SWZ_STRING(swz[NVS_SWZ_X]),
-           SWZ_STRING(swz[NVS_SWZ_Y]),
-           SWZ_STRING(swz[NVS_SWZ_Z]),
-           SWZ_STRING(swz[NVS_SWZ_W])
-           );
-   }
-
-   /* looping */
-   if (opi->flags & COUNT_ALL) {
-      printf(" { ");
-      if (opi->flags & COUNT_NUM) {
-        printf("%d", shader->GetLoopCount(shader));
-      }
-      if (opi->flags & COUNT_IND) {
-        printf(", %d", shader->GetLoopInitial(shader));
-      }
-      if (opi->flags & COUNT_INC) {
-        printf(", %d", shader->GetLoopIncrement(shader));
-      }
-      printf(" }");
-   }
-
-   /* branching */
-   if (opi->flags & BRANCH_TR)
-      printf(" %d", shader->GetBranch(shader));
-   if (opi->flags & BRANCH_EL)
-      printf(" ELSE %d", shader->GetBranchElse(shader));
-   if (opi->flags & BRANCH_EN)
-      printf(" END %d", shader->GetBranchEnd(shader));
-
-   if (!(opi->flags & NODS) && opi->numsrc)
-      printf(",");
-   printf(" ");
-
-   for (i = 0; i < opi->numsrc; i++) {
-      if (shader->GetSourceAbs(shader, merged, i))
-        printf("abs(");
-      if (shader->GetSourceNegate(shader, merged, i))
-        printf("-");
-
-      file = shader->GetSourceFile(shader, merged, i);
-      switch (file) {
-      case NVS_FILE_TEMP:
-        printf("R%d", shader->GetSourceID(shader, merged, i));
-        break;
-      case NVS_FILE_CONST:
-        if (shader->GetSourceIndexed(shader, merged, i)) {
-           printf("c[A%d.%s + 0x%x]",
-                    shader->GetRelAddressRegID(shader),
-                    SWZ_STRING(shader->GetRelAddressSwizzle(shader)),
-                    shader->GetSourceID(shader, merged, i)
-                 );
-        } else {
-           float val[4];
-
-           if (shader->GetSourceConstVal) {
-              shader->GetSourceConstVal(shader, merged, i, val);
-              printf("{ %.02f, %.02f, %.02f, %.02f }",
-                    val[0], val[1], val[2], val[3]);
-           } else {
-              printf("c[0x%x]", shader->GetSourceID(shader, merged, i));
-           }
-        }
-        break;
-      case NVS_FILE_ATTRIB:
-        if (shader->GetSourceIndexed(shader, merged, i)) {
-           printf("attrib[A%d.%s + %d]",
-                    shader->GetRelAddressRegID(shader),
-                    SWZ_STRING(shader->GetRelAddressSwizzle(shader)),
-                    shader->GetSourceID(shader, merged, i)
-                 );
-        }
-        else {
-           printf("attrib.%s",
-                    SFR_STRING(shader->GetSourceID(shader, merged, i))
-                 );
-        }
-        break;
-      case NVS_FILE_ADDRESS:
-        printf("A%d", shader->GetRelAddressRegID(shader));
-        break;
-      default:
-        printf("UNKNOWN_SRC_FILE");
-        break;
-      }
-
-      shader->GetSourceSwizzle(shader, merged, i, swz);
-      if (file != NVS_FILE_ADDRESS &&
-         (swz[NVS_SWZ_X] != NVS_SWZ_X || swz[NVS_SWZ_Y] != NVS_SWZ_Y ||
-          swz[NVS_SWZ_Z] != NVS_SWZ_Z || swz[NVS_SWZ_W] != NVS_SWZ_W)) {
-        printf(".%s%s%s%s", SWZ_STRING(swz[NVS_SWZ_X]),
-                            SWZ_STRING(swz[NVS_SWZ_Y]),
-                            SWZ_STRING(swz[NVS_SWZ_Z]),
-                            SWZ_STRING(swz[NVS_SWZ_W]));
-      }
-
-      if (shader->GetSourceAbs(shader, merged, i))
-        printf(")");
-      if (shader->GetSourceScale) {
-        int scale = shader->GetSourceScale(shader, merged, i);
-        if (scale > 1)
-           printf("{scaled %dx}", scale);
-      }
-      if (i < (opi->numsrc - 1))
-        printf(", ");
-   }
-
-   if (shader->IsLastInst(shader))
-      printf(" + END");
-}
-
-void
-nvsDisasmHWShader(nvsPtr nvs)
-{
-   nvsFunc *shader = nvs->func;
-   unsigned int iaddr = 0;
-
-   if (!nvs->program) {
-      fprintf(stderr, "No HW program present");
-      return;
-   }
-
-   shader->inst = nvs->program;
-   while (1) {
-      if (shader->inst >= (nvs->program + nvs->program_size)) {
-        fprintf(stderr, "Reached end of program, but HW inst has no END");
-        break;
-      }
-
-      printf("\t0x%08x:\n", shader->inst[0]);
-      printf("\t0x%08x:\n", shader->inst[1]);
-      printf("\t0x%08x:\n", shader->inst[2]);
-      printf("\t0x%08x:", shader->inst[3]);
-
-      printf("\n\t\tINST %d.0: ", iaddr);
-      nvsDisasmHWShaderOp(shader, 0);
-      if (shader->HasMergedInst(shader)) {
-        printf("\n\t\tINST %d.1: ", iaddr);
-        nvsDisasmHWShaderOp(shader, 1);
-      }
-      printf("\n");
-
-      if (shader->IsLastInst(shader))
-        break;
-
-      shader->inst += shader->GetOffsetNext(shader);
-      iaddr++;
-   }
-
-   printf("\n");
-}
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader.h b/src/mesa/drivers/dri/nouveau/nouveau_shader.h
deleted file mode 100644 (file)
index 7125a2a..0000000
+++ /dev/null
@@ -1,454 +0,0 @@
-#ifndef __SHADER_COMMON_H__
-#define __SHADER_COMMON_H__
-
-#include "mtypes.h"
-#include "bufferobj.h"
-
-#define NVSDBG(fmt, args...) do {                             \
-       if (NOUVEAU_DEBUG & DEBUG_SHADERS) {                  \
-               fprintf(stderr, "%s: "fmt, __func__, ##args); \
-       }                                                     \
-} while(0)
-
-typedef struct _nvsFunc nvsFunc;
-
-#define NVS_MAX_TEMPS   32
-#define NVS_MAX_ATTRIBS 16
-#define NVS_MAX_CONSTS  256
-#define NVS_MAX_ADDRESS 2
-#define NVS_MAX_INSNS   4096
-
-typedef struct _nvs_fragment_header {
-   struct _nvs_fragment_header *parent;
-   struct _nvs_fragment_header *prev;
-   struct _nvs_fragment_header *next;
-   enum {
-      NVS_INSTRUCTION,
-      NVS_BRANCH,
-      NVS_LOOP,
-      NVS_SUBROUTINE
-   } type;
-} nvsFragmentHeader;
-
-typedef union {
-       struct {
-               GLboolean uses_kil;
-               GLuint    num_regs;
-       } NV30FP;
-       struct {
-               uint32_t vp_in_reg;
-               uint32_t vp_out_reg;
-               uint32_t clip_enables;
-       } NV30VP;
-} nvsCardPriv;
-
-typedef struct _nouveauShader {
-   union {
-      struct gl_vertex_program vp;
-      struct gl_fragment_program fp;
-   } mesa;
-   GLcontext *ctx;
-   nvsFunc *func;
-
-   /* State of the final program */
-   GLboolean error;
-   GLboolean translated;
-   GLboolean on_hardware;
-   unsigned int *program;
-   unsigned int program_size;
-   unsigned int program_alloc_size;
-   unsigned int program_start_id;
-   unsigned int program_current;
-   struct gl_buffer_object *program_buffer;
-   int         inst_count;
-
-   nvsCardPriv card_priv;
-   int         vp_attrib_map[NVS_MAX_ATTRIBS];
-
-   struct {
-      GLboolean in_use;
-
-      GLfloat  *source_val;    /* NULL if invariant */
-      float    val[4];
-      /* Hardware-specific tracking, currently only nv30_fragprog
-       * makes use of it.
-       */
-      int      *hw_index;
-      int        hw_index_cnt;
-   } params[NVS_MAX_CONSTS];
-   int param_high;
-
-   /* Pass-private data */
-   void *pass_rec;
-
-   nvsFragmentHeader *program_tree;
-} nouveauShader, *nvsPtr;
-
-typedef enum {
-   NVS_FILE_NONE,
-   NVS_FILE_TEMP,
-   NVS_FILE_ATTRIB,
-   NVS_FILE_CONST,
-   NVS_FILE_RESULT,
-   NVS_FILE_ADDRESS,
-   NVS_FILE_UNKNOWN
-} nvsRegFile;
-
-typedef enum {
-   NVS_OP_UNKNOWN = 0,
-   NVS_OP_NOP,
-   NVS_OP_ABS, NVS_OP_ADD, NVS_OP_ARA, NVS_OP_ARL, NVS_OP_ARR,
-   NVS_OP_BRA, NVS_OP_BRK,
-   NVS_OP_CAL, NVS_OP_CMP, NVS_OP_COS,
-   NVS_OP_DDX, NVS_OP_DDY, NVS_OP_DIV, NVS_OP_DP2, NVS_OP_DP2A, NVS_OP_DP3,
-   NVS_OP_DP4, NVS_OP_DPH, NVS_OP_DST,
-   NVS_OP_EX2, NVS_OP_EXP,
-   NVS_OP_FLR, NVS_OP_FRC,
-   NVS_OP_IF,
-   NVS_OP_KIL,
-   NVS_OP_LG2, NVS_OP_LIT, NVS_OP_LOG, NVS_OP_LOOP, NVS_OP_LRP,
-   NVS_OP_MAD, NVS_OP_MAX, NVS_OP_MIN, NVS_OP_MOV, NVS_OP_MUL,
-   NVS_OP_NRM,
-   NVS_OP_PK2H, NVS_OP_PK2US, NVS_OP_PK4B, NVS_OP_PK4UB, NVS_OP_POW,
-   NVS_OP_POPA, NVS_OP_PUSHA,
-   NVS_OP_RCC, NVS_OP_RCP, NVS_OP_REP, NVS_OP_RET, NVS_OP_RFL, NVS_OP_RSQ,
-   NVS_OP_SCS, NVS_OP_SEQ, NVS_OP_SFL, NVS_OP_SGE, NVS_OP_SGT, NVS_OP_SIN,
-   NVS_OP_SLE, NVS_OP_SLT, NVS_OP_SNE, NVS_OP_SSG, NVS_OP_STR, NVS_OP_SUB,
-   NVS_OP_SWZ,
-   NVS_OP_TEX, NVS_OP_TXB, NVS_OP_TXD, NVS_OP_TXL, NVS_OP_TXP,
-   NVS_OP_UP2H, NVS_OP_UP2US, NVS_OP_UP4B, NVS_OP_UP4UB,
-   NVS_OP_X2D, NVS_OP_XPD,
-   NVS_OP_EMUL
-} nvsOpcode;
-
-typedef enum {
-   NVS_PREC_FLOAT32,
-   NVS_PREC_FLOAT16,
-   NVS_PREC_FIXED12,
-   NVS_PREC_UNKNOWN
-} nvsPrecision;
-
-typedef enum {
-   NVS_SWZ_X = 0,
-   NVS_SWZ_Y = 1,
-   NVS_SWZ_Z = 2,
-   NVS_SWZ_W = 3
-} nvsSwzComp;
-
-typedef enum {
-   NVS_FR_POSITION     = 0,
-   NVS_FR_WEIGHT       = 1,
-   NVS_FR_NORMAL       = 2,
-   NVS_FR_COL0         = 3,
-   NVS_FR_COL1         = 4,
-   NVS_FR_FOGCOORD     = 5,
-   NVS_FR_TEXCOORD0    = 8,
-   NVS_FR_TEXCOORD1    = 9,
-   NVS_FR_TEXCOORD2    = 10,
-   NVS_FR_TEXCOORD3    = 11,
-   NVS_FR_TEXCOORD4    = 12,
-   NVS_FR_TEXCOORD5    = 13,
-   NVS_FR_TEXCOORD6    = 14,
-   NVS_FR_TEXCOORD7    = 15,
-   NVS_FR_BFC0         = 16,
-   NVS_FR_BFC1         = 17,
-   NVS_FR_POINTSZ      = 18,
-   NVS_FR_FRAGDATA0    = 19,
-   NVS_FR_FRAGDATA1    = 20,
-   NVS_FR_FRAGDATA2    = 21,
-   NVS_FR_FRAGDATA3    = 22,
-   NVS_FR_CLIP0                = 23,
-   NVS_FR_CLIP1                = 24,
-   NVS_FR_CLIP2                = 25,
-   NVS_FR_CLIP3                = 26,
-   NVS_FR_CLIP4                = 27,
-   NVS_FR_CLIP5                = 28,
-   NVS_FR_CLIP6                = 29,
-   NVS_FR_FACING       = 30,
-   NVS_FR_UNKNOWN
-} nvsFixedReg;
-
-typedef enum {
-   NVS_COND_FL, NVS_COND_LT, NVS_COND_EQ, NVS_COND_LE, NVS_COND_GT,
-   NVS_COND_NE, NVS_COND_GE, NVS_COND_TR, NVS_COND_UN,
-   NVS_COND_UNKNOWN
-} nvsCond;
-
-typedef struct {
-   nvsRegFile  file;
-   unsigned int                index;
-
-   unsigned int                indexed;
-   unsigned int                addr_reg;
-   nvsSwzComp          addr_comp;
-
-   nvsSwzComp          swizzle[4];
-   int                 negate;
-   int                 abs;
-} nvsRegister;
-
-static const nvsRegister nvr_unused = {
-   .file       = NVS_FILE_ATTRIB,
-   .index      = 0,
-   .indexed    = 0,
-   .addr_reg   = 0,
-   .addr_comp  = NVS_SWZ_X,
-   .swizzle    = {NVS_SWZ_X, NVS_SWZ_Y, NVS_SWZ_Z, NVS_SWZ_W},
-   .negate     = 0,
-   .abs                = 0,
-};
-
-typedef enum {
-   NVS_TEX_TARGET_1D,
-   NVS_TEX_TARGET_2D,
-   NVS_TEX_TARGET_3D,
-   NVS_TEX_TARGET_CUBE,
-   NVS_TEX_TARGET_RECT,
-   NVS_TEX_TARGET_UNKNOWN = 0
-} nvsTexTarget;
-
-typedef enum {
-       NVS_SCALE_1X     = 0,
-       NVS_SCALE_2X     = 1,
-       NVS_SCALE_4X     = 2,
-       NVS_SCALE_8X     = 3,
-       NVS_SCALE_INV_2X = 5,
-       NVS_SCALE_INV_4X = 6,
-       NVS_SCALE_INV_8X = 7,
-} nvsScale;
-
-/* Arith/TEX instructions */
-typedef struct nvs_instruction {
-   nvsFragmentHeader header;
-
-   nvsOpcode   op;
-   unsigned int saturate;
-
-   nvsRegister dest;
-   unsigned int        mask;
-   nvsScale    dest_scale;
-
-   nvsRegister src[3];
-
-   unsigned int tex_unit;
-   nvsTexTarget tex_target;
-
-   nvsCond     cond;
-   nvsSwzComp  cond_swizzle[4];
-   int         cond_reg;
-   int         cond_test;
-   int         cond_update;
-} nvsInstruction;
-
-/* BRA, CAL, IF */
-typedef struct nvs_branch {
-       nvsFragmentHeader  header;
-
-       nvsOpcode       op;
-
-       nvsCond         cond;
-       nvsSwzComp      cond_swizzle[4];
-       int             cond_test;
-
-       nvsFragmentHeader *target_head;
-       nvsFragmentHeader *target_tail;
-       nvsFragmentHeader *else_head;
-       nvsFragmentHeader *else_tail;
-} nvsBranch;
-
-/* LOOP+ENDLOOP */
-typedef struct {
-       nvsFragmentHeader  header;
-
-       int                count;
-       int                initial;
-       int                increment;
-
-       nvsFragmentHeader *insn_head;
-       nvsFragmentHeader *insn_tail;
-} nvsLoop;
-
-/* label+following instructions */
-typedef struct nvs_subroutine {
-       nvsFragmentHeader  header;
-
-       char *             label;
-       nvsFragmentHeader *insn_head;
-       nvsFragmentHeader *insn_tail;
-} nvsSubroutine;
-
-#define SMASK_X (1<<0)
-#define SMASK_Y (1<<1)
-#define SMASK_Z (1<<2)
-#define SMASK_W (1<<3)
-#define SMASK_ALL (SMASK_X|SMASK_Y|SMASK_Z|SMASK_W)
-
-#define SPOS_ADDRESS 3
-struct _op_xlat {
-       unsigned int    NV;
-       nvsOpcode       SOP;
-       int             srcpos[3];
-};
-#define MOD_OPCODE(t,hw,sop,s0,s1,s2) do { \
-       t[hw].NV = hw; \
-       t[hw].SOP = sop; \
-       t[hw].srcpos[0] = s0; \
-       t[hw].srcpos[1] = s1; \
-       t[hw].srcpos[2] = s2; \
-} while(0)
-
-extern unsigned int NVVP_TX_VOP_COUNT;
-extern unsigned int NVVP_TX_NVS_OP_COUNT;
-extern struct _op_xlat NVVP_TX_VOP[];
-extern struct _op_xlat NVVP_TX_SOP[];
-
-extern unsigned int NVFP_TX_AOP_COUNT;
-extern unsigned int NVFP_TX_BOP_COUNT;
-extern struct _op_xlat NVFP_TX_AOP[];
-extern struct _op_xlat NVFP_TX_BOP[];
-
-extern void NV20VPTXSwizzle(int hwswz, nvsSwzComp *swz);
-extern nvsSwzComp NV20VP_TX_SWIZZLE[4];
-
-#define SCAP_SRC_ABS   (1<<0)
-
-struct _nvsFunc {
-   nvsCardPriv *card_priv;
-
-   unsigned int        MaxInst;
-   unsigned int        MaxAttrib;
-   unsigned int        MaxTemp;
-   unsigned int        MaxAddress;
-   unsigned int        MaxConst;
-   unsigned int        caps;
-
-   unsigned int *inst;
-   void                (*UploadToHW)           (GLcontext *, nouveauShader *);
-   void                (*UpdateConst)          (GLcontext *, nouveauShader *, int);
-
-   struct _op_xlat*(*GetOPTXRec)       (nvsFunc *, int merged);
-   struct _op_xlat*(*GetOPTXFromSOP)   (nvsOpcode, int *id);
-
-   void                (*InitInstruction)      (nvsFunc *);
-   int         (*SupportsOpcode)       (nvsFunc *, nvsOpcode);
-   int         (*SupportsResultScale)  (nvsFunc *, nvsScale);
-   void                (*SetOpcode)            (nvsFunc *, unsigned int opcode,
-                                        int slot);
-   void                (*SetCCUpdate)          (nvsFunc *);
-   void                (*SetCondition)         (nvsFunc *, int on, nvsCond, int reg,
-                                        nvsSwzComp *swizzle);
-   void                (*SetResult)            (nvsFunc *, nvsRegister *,
-                                        unsigned int mask, int slot);
-   void                (*SetResultScale)       (nvsFunc *, nvsScale);
-   void                (*SetSource)            (nvsFunc *, nvsRegister *, int pos);
-   void                (*SetTexImageUnit)      (nvsFunc *, int unit);
-   void                (*SetSaturate)          (nvsFunc *);
-   void                (*SetLastInst)          (nvsFunc *);
-
-   void                (*SetBranchTarget)      (nvsFunc *, int addr);
-   void                (*SetBranchElse)        (nvsFunc *, int addr);
-   void                (*SetBranchEnd)         (nvsFunc *, int addr);
-   void                (*SetLoopParams)        (nvsFunc *, int cnt, int init, int inc);
-
-   int         (*HasMergedInst)        (nvsFunc *);
-   int         (*IsLastInst)           (nvsFunc *);
-   int         (*GetOffsetNext)        (nvsFunc *);
-
-   int         (*GetOpcodeSlot)        (nvsFunc *, int merged);
-   unsigned int        (*GetOpcodeHW)          (nvsFunc *, int slot);
-   nvsOpcode   (*GetOpcode)            (nvsFunc *, int merged);
-
-   nvsPrecision        (*GetPrecision)         (nvsFunc *);
-   int         (*GetSaturate)          (nvsFunc *);
-
-   nvsRegFile  (*GetDestFile)          (nvsFunc *, int merged);
-   unsigned int        (*GetDestID)            (nvsFunc *, int merged);
-   unsigned int        (*GetDestMask)          (nvsFunc *, int merged);
-
-   unsigned int        (*GetSourceHW)          (nvsFunc *, int merged, int pos);
-   nvsRegFile  (*GetSourceFile)        (nvsFunc *, int merged, int pos);
-   int         (*GetSourceID)          (nvsFunc *, int merged, int pos);
-   int         (*GetTexImageUnit)      (nvsFunc *);
-   int         (*GetSourceNegate)      (nvsFunc *, int merged, int pos);
-   int         (*GetSourceAbs)         (nvsFunc *, int merged, int pos);
-   void                (*GetSourceSwizzle)     (nvsFunc *, int merged, int pos,
-                                        nvsSwzComp *swz);
-   int         (*GetSourceIndexed)     (nvsFunc *, int merged, int pos);
-   void                (*GetSourceConstVal)    (nvsFunc *, int merged, int pos,
-                                        float *val);
-   int         (*GetSourceScale)       (nvsFunc *, int merged, int pos);
-
-   int         (*GetRelAddressRegID)   (nvsFunc *);
-   nvsSwzComp  (*GetRelAddressSwizzle) (nvsFunc *);
-
-   int         (*SupportsConditional)  (nvsFunc *);
-   int         (*GetConditionUpdate)   (nvsFunc *);
-   int         (*GetConditionTest)     (nvsFunc *);
-   nvsCond     (*GetCondition)         (nvsFunc *);
-   void                (*GetCondRegSwizzle)    (nvsFunc *, nvsSwzComp *swz);
-   int         (*GetCondRegID)         (nvsFunc *);
-   int         (*GetBranch)            (nvsFunc *);
-   int         (*GetBranchElse)        (nvsFunc *);
-   int         (*GetBranchEnd)         (nvsFunc *);
-
-   int         (*GetLoopCount)         (nvsFunc *);
-   int         (*GetLoopInitial)       (nvsFunc *);
-   int         (*GetLoopIncrement)     (nvsFunc *);
-};
-
-static inline nvsRegister
-nvsNegate(nvsRegister reg)
-{
-   reg.negate = !reg.negate;
-   return reg;
-}
-
-static inline nvsRegister
-nvsAbs(nvsRegister reg)
-{
-   reg.abs = 1;
-   return reg;
-}
-
-static inline nvsRegister
-nvsSwizzle(nvsRegister reg, nvsSwzComp x, nvsSwzComp y,
-          nvsSwzComp z, nvsSwzComp w)
-{
-   nvsSwzComp sc[4] = { x, y, z, w };
-   nvsSwzComp oc[4];
-   int i;
-
-   for (i=0;i<4;i++)
-      oc[i] = reg.swizzle[i];
-   for (i=0;i<4;i++)
-      reg.swizzle[i] = oc[sc[i]];
-   return reg;
-}
-
-#define nvsProgramError(nvs,fmt,args...) do {                           \
-       fprintf(stderr, "nvsProgramError (%s): "fmt, __func__, ##args); \
-       (nvs)->error = GL_TRUE;                                         \
-       (nvs)->translated = GL_FALSE;                                   \
-} while(0)
-
-extern GLboolean nvsUpdateShader(GLcontext *ctx, nouveauShader *nvs);
-extern void nvsDisasmHWShader(nvsPtr);
-extern void nvsDumpFragmentList(nvsFragmentHeader *f, int lvl);
-extern nouveauShader *nvsBuildTextShader(GLcontext *ctx, GLenum target,
-                                        const char *text);
-
-extern void NV20VPInitShaderFuncs(nvsFunc *);
-extern void NV30VPInitShaderFuncs(nvsFunc *);
-extern void NV40VPInitShaderFuncs(nvsFunc *);
-
-extern void NV30FPInitShaderFuncs(nvsFunc *);
-extern void NV40FPInitShaderFuncs(nvsFunc *);
-
-extern void nouveauShaderInitFuncs(GLcontext *ctx);
-
-extern GLboolean nouveau_shader_pass0(GLcontext *ctx, nouveauShader *nvs);
-extern GLboolean nouveau_shader_pass1(nvsPtr nvs);
-extern GLboolean nouveau_shader_pass2(nvsPtr nvs);
-
-#endif
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader_0.c b/src/mesa/drivers/dri/nouveau/nouveau_shader_0.c
deleted file mode 100644 (file)
index 8c203cc..0000000
+++ /dev/null
@@ -1,1050 +0,0 @@
-/*
- * Copyright (C) 2006 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>
- */
-
-#include "glheader.h"
-#include "macros.h"
-#include "enums.h"
-
-#include "shader/prog_instruction.h"
-#include "shader/prog_parameter.h"
-#include "shader/prog_statevars.h"
-#include "shader/programopt.h"
-
-#include "nouveau_context.h"
-#include "nouveau_shader.h"
-#include "nouveau_msg.h"
-
-static nvsFixedReg _tx_mesa_vp_dst_reg[VERT_RESULT_MAX] = {
-   NVS_FR_POSITION, NVS_FR_COL0, NVS_FR_COL1, NVS_FR_FOGCOORD,
-   NVS_FR_TEXCOORD0, NVS_FR_TEXCOORD1, NVS_FR_TEXCOORD2, NVS_FR_TEXCOORD3,
-   NVS_FR_TEXCOORD4, NVS_FR_TEXCOORD5, NVS_FR_TEXCOORD6, NVS_FR_TEXCOORD7,
-   NVS_FR_POINTSZ, NVS_FR_BFC0, NVS_FR_BFC1, NVS_FR_UNKNOWN /* EDGE */
-};
-
-static nvsFixedReg _tx_mesa_fp_dst_reg[FRAG_RESULT_MAX] = {
-   NVS_FR_FRAGDATA0 /* COLR */, NVS_FR_FRAGDATA0 /* COLH */,
-   NVS_FR_UNKNOWN /* DEPR */
-};
-
-static nvsFixedReg _tx_mesa_fp_src_reg[FRAG_ATTRIB_MAX] = {
-   NVS_FR_POSITION, NVS_FR_COL0, NVS_FR_COL1, NVS_FR_FOGCOORD,
-   NVS_FR_TEXCOORD0, NVS_FR_TEXCOORD1, NVS_FR_TEXCOORD2, NVS_FR_TEXCOORD3,
-   NVS_FR_TEXCOORD4, NVS_FR_TEXCOORD5, NVS_FR_TEXCOORD6, NVS_FR_TEXCOORD7
-};
-
-static nvsSwzComp _tx_mesa_swizzle[4] = {
-   NVS_SWZ_X, NVS_SWZ_Y, NVS_SWZ_Z, NVS_SWZ_W
-};
-
-static nvsOpcode _tx_mesa_opcode[] = {
-   [OPCODE_ABS] = NVS_OP_ABS, [OPCODE_ADD] = NVS_OP_ADD,
-   [OPCODE_ARA] = NVS_OP_ARA, [OPCODE_ARL] = NVS_OP_ARL,
-   [OPCODE_ARL_NV] = NVS_OP_ARL, [OPCODE_ARR] = NVS_OP_ARR,
-   [OPCODE_CMP] = NVS_OP_CMP, [OPCODE_COS] = NVS_OP_COS,
-   [OPCODE_DDX] = NVS_OP_DDX, [OPCODE_DDY] = NVS_OP_DDY,
-   [OPCODE_DP3] = NVS_OP_DP3, [OPCODE_DP4] = NVS_OP_DP4,
-   [OPCODE_DPH] = NVS_OP_DPH, [OPCODE_DST] = NVS_OP_DST,
-   [OPCODE_EX2] = NVS_OP_EX2, [OPCODE_EXP] = NVS_OP_EXP,
-   [OPCODE_FLR] = NVS_OP_FLR, [OPCODE_FRC] = NVS_OP_FRC,
-   [OPCODE_KIL] = NVS_OP_EMUL, [OPCODE_KIL_NV] = NVS_OP_KIL,
-   [OPCODE_LG2] = NVS_OP_LG2, [OPCODE_LIT] = NVS_OP_LIT,
-   [OPCODE_LOG] = NVS_OP_LOG,
-   [OPCODE_LRP] = NVS_OP_LRP,
-   [OPCODE_MAD] = NVS_OP_MAD, [OPCODE_MAX] = NVS_OP_MAX,
-   [OPCODE_MIN] = NVS_OP_MIN, [OPCODE_MOV] = NVS_OP_MOV,
-   [OPCODE_MUL] = NVS_OP_MUL,
-   [OPCODE_PK2H] = NVS_OP_PK2H, [OPCODE_PK2US] = NVS_OP_PK2US,
-   [OPCODE_PK4B] = NVS_OP_PK4B, [OPCODE_PK4UB] = NVS_OP_PK4UB,
-   [OPCODE_POW] = NVS_OP_POW, [OPCODE_POPA] = NVS_OP_POPA,
-   [OPCODE_PUSHA] = NVS_OP_PUSHA,
-   [OPCODE_RCC] = NVS_OP_RCC, [OPCODE_RCP] = NVS_OP_RCP,
-   [OPCODE_RFL] = NVS_OP_RFL, [OPCODE_RSQ] = NVS_OP_RSQ,
-   [OPCODE_SCS] = NVS_OP_SCS, [OPCODE_SEQ] = NVS_OP_SEQ,
-   [OPCODE_SFL] = NVS_OP_SFL, [OPCODE_SGE] = NVS_OP_SGE,
-   [OPCODE_SGT] = NVS_OP_SGT, [OPCODE_SIN] = NVS_OP_SIN,
-   [OPCODE_SLE] = NVS_OP_SLE, [OPCODE_SLT] = NVS_OP_SLT,
-   [OPCODE_SNE] = NVS_OP_SNE, [OPCODE_SSG] = NVS_OP_SSG,
-   [OPCODE_STR] = NVS_OP_STR, [OPCODE_SUB] = NVS_OP_SUB,
-   [OPCODE_SWZ] = NVS_OP_MOV,
-   [OPCODE_TEX] = NVS_OP_TEX, [OPCODE_TXB] = NVS_OP_TXB,
-   [OPCODE_TXD] = NVS_OP_TXD,
-   [OPCODE_TXL] = NVS_OP_TXL, [OPCODE_TXP] = NVS_OP_TXP,
-   [OPCODE_TXP_NV] = NVS_OP_TXP,
-   [OPCODE_UP2H] = NVS_OP_UP2H, [OPCODE_UP2US] = NVS_OP_UP2US,
-   [OPCODE_UP4B] = NVS_OP_UP4B, [OPCODE_UP4UB] = NVS_OP_UP4UB,
-   [OPCODE_X2D] = NVS_OP_X2D,
-   [OPCODE_XPD] = NVS_OP_XPD
-};
-
-static nvsCond _tx_mesa_condmask[] = {
-   NVS_COND_TR, /* workaround mesa not filling a valid value */
-   NVS_COND_GT, NVS_COND_LT, NVS_COND_UN, NVS_COND_GE,
-   NVS_COND_LE, NVS_COND_NE, NVS_COND_NE, NVS_COND_TR, NVS_COND_FL
-};
-
-struct pass0_rec {
-   int nvs_ipos;
-   int next_temp;
-
-   int mesa_const_base;
-   int mesa_const_last;
-
-   int swzconst_done;
-   int swzconst_id;
-   nvsRegister const_half;
-};
-
-#define X NVS_SWZ_X
-#define Y NVS_SWZ_Y
-#define Z NVS_SWZ_Z
-#define W NVS_SWZ_W
-
-#define FILL_CONDITION_FLAGS(fragment) do {                                    \
-       (fragment)->cond =                                                     \
-       pass0_make_condmask(inst->DstReg.CondMask);                            \
-       if ((fragment)->cond != NVS_COND_TR)                                   \
-               (fragment)->cond_test = 1;                                     \
-       (fragment)->cond_reg = inst->CondDst;                                  \
-       pass0_make_swizzle((fragment)->cond_swizzle, inst->DstReg.CondSwizzle);\
-} while(0)
-
-#define ARITH(op,dest,mask,sat,s0,s1,s2) do {               \
-       nvsinst = pass0_emit(nvs, parent, fpos, (op),       \
-                  (dest), (mask), (sat), (s0), (s1), (s2));\
-       FILL_CONDITION_FLAGS(nvsinst);                      \
-} while(0)
-
-#define ARITHu(op,dest,mask,sat,s0,s1,s2) do {              \
-       nvsinst = pass0_emit(nvs, parent, fpos, (op),       \
-                  (dest), (mask), (sat), (s0), (s1), (s2));\
-} while(0)
-
-static void
-pass0_append_fragment(nvsFragmentHeader *parent,
-                     nvsFragmentHeader *fragment,
-                     int pos)
-{
-       nvsFragmentHeader **head, **tail;
-       assert(parent && fragment);
-
-       switch (parent->type) {
-       case NVS_BRANCH:
-               if (pos == 0) {
-                       head = &((nvsBranch *)parent)->target_head;
-                       tail = &((nvsBranch *)parent)->target_tail;
-               } else {
-                       head = &((nvsBranch *)parent)->else_head;
-                       tail = &((nvsBranch *)parent)->else_tail;
-               }
-               break;
-       case NVS_LOOP:
-               head = &((nvsLoop *)parent)->insn_head;
-               tail = &((nvsLoop *)parent)->insn_tail;
-               break;
-       case NVS_SUBROUTINE:
-               head = &((nvsSubroutine *)parent)->insn_head;
-               tail = &((nvsSubroutine *)parent)->insn_tail;
-               break;
-       default:
-               assert(0);
-               break;
-       }
-
-       fragment->parent = parent;
-       fragment->prev   = *tail;
-       fragment->next   = NULL;
-       if (!(*head))
-               *head = fragment;
-       else
-               (*tail)->next = fragment;
-       *tail = fragment;
-
-}
-
-static nvsSubroutine *
-pass0_create_subroutine(nouveauShader *nvs, const char *label)
-{
-       nvsSubroutine *sub;
-
-       sub = CALLOC_STRUCT(nvs_subroutine);
-       if (sub) {
-               sub->header.type = NVS_SUBROUTINE;
-               sub->label       = strdup(label);
-               if (!nvs->program_tree)
-                       nvs->program_tree = &sub->header;
-               else
-                       pass0_append_fragment(nvs->program_tree,
-                                             &sub->header, 0);
-       }
-
-       return sub;
-}
-
-static void
-pass0_make_reg(nouveauShader *nvs, nvsRegister *reg,
-              nvsRegFile file, unsigned int index)
-{
-       struct pass0_rec *rec = nvs->pass_rec;
-
-       /* defaults */
-       *reg = nvr_unused;
-       /* -1 == quick-and-dirty temp alloc */
-       if (file == NVS_FILE_TEMP && index == -1) {
-               index = rec->next_temp++;
-               assert(index < NVS_MAX_TEMPS);
-       }
-       reg->file   = file;
-       reg->index  = index;
-}
-
-static void
-pass0_make_swizzle(nvsSwzComp *swz, unsigned int mesa)
-{
-       int i;
-
-       for (i=0;i<4;i++)
-               swz[i] = _tx_mesa_swizzle[GET_SWZ(mesa, i)];
-}
-
-static nvsOpcode
-pass0_make_opcode(enum prog_opcode op)
-{
-       if (op > MAX_OPCODE)
-               return NVS_OP_UNKNOWN;
-       return _tx_mesa_opcode[op];
-}
-
-static nvsCond
-pass0_make_condmask(GLuint mesa)
-{
-       if (mesa > COND_FL)
-               return NVS_COND_UNKNOWN;
-       return _tx_mesa_condmask[mesa];
-}
-
-static unsigned int
-pass0_make_mask(GLuint mesa_mask)
-{
-       unsigned int mask = 0;
-
-       if (mesa_mask & WRITEMASK_X) mask |= SMASK_X;
-       if (mesa_mask & WRITEMASK_Y) mask |= SMASK_Y;
-       if (mesa_mask & WRITEMASK_Z) mask |= SMASK_Z;
-       if (mesa_mask & WRITEMASK_W) mask |= SMASK_W;
-
-       return mask;
-}
-
-static GLboolean
-pass0_opcode_is_tex(enum prog_opcode op)
-{
-       switch (op) {
-       case OPCODE_TEX:
-       case OPCODE_TXB:
-       case OPCODE_TXD:
-       case OPCODE_TXL:
-       case OPCODE_TXP:
-               return GL_TRUE;
-       default:
-               break;
-       }
-
-       return GL_FALSE;
-}
-
-static nvsTexTarget
-pass0_make_tex_target(GLuint mesa)
-{
-       switch (mesa) {
-       case TEXTURE_1D_INDEX: return NVS_TEX_TARGET_1D;
-       case TEXTURE_2D_INDEX: return NVS_TEX_TARGET_2D;
-       case TEXTURE_3D_INDEX: return NVS_TEX_TARGET_3D;
-       case TEXTURE_CUBE_INDEX: return NVS_TEX_TARGET_CUBE;
-       case TEXTURE_RECT_INDEX: return NVS_TEX_TARGET_RECT;
-       default:
-               return NVS_TEX_TARGET_UNKNOWN;
-       }
-}
-
-static void
-pass0_make_dst_reg(nvsPtr nvs, nvsRegister *reg,
-                  struct prog_dst_register *dst)
-{
-       struct gl_program *mesa = (struct gl_program*)&nvs->mesa.vp;
-       nvsFixedReg sfr;
-
-       switch (dst->File) {
-       case PROGRAM_OUTPUT:
-               if (mesa->Target == GL_VERTEX_PROGRAM_ARB) {
-                       sfr = (dst->Index < VERT_RESULT_MAX) ?
-                               _tx_mesa_vp_dst_reg[dst->Index] :
-                               NVS_FR_UNKNOWN;
-               } else {
-                       sfr = (dst->Index < FRAG_RESULT_MAX) ?
-                               _tx_mesa_fp_dst_reg[dst->Index] :
-                               NVS_FR_UNKNOWN;
-               }
-               pass0_make_reg(nvs, reg, NVS_FILE_RESULT, sfr);
-               break;
-       case PROGRAM_TEMPORARY:
-               pass0_make_reg(nvs, reg, NVS_FILE_TEMP, dst->Index);
-               break;
-       case PROGRAM_ADDRESS:
-               pass0_make_reg(nvs, reg, NVS_FILE_ADDRESS, dst->Index);
-               break;
-       default:
-               fprintf(stderr, "Unknown dest file %d\n", dst->File);
-               assert(0);
-       }
-}
-
-static void
-pass0_make_src_reg(nvsPtr nvs, nvsRegister *reg, struct prog_src_register *src)
-{
-       struct pass0_rec *rec = nvs->pass_rec;
-       struct gl_program *mesa = (struct gl_program *)&nvs->mesa.vp.Base;
-       int i;
-
-       *reg = nvr_unused;
-
-       switch (src->File) {
-       case PROGRAM_INPUT:
-               reg->file = NVS_FILE_ATTRIB;
-               if (mesa->Target == GL_VERTEX_PROGRAM_ARB) {
-                       for (i=0; i<NVS_MAX_ATTRIBS; i++) {
-                               if (nvs->vp_attrib_map[i] == src->Index) {
-                                       reg->index = i;
-                                       break;
-                               }
-                       }
-                       if (i==NVS_MAX_ATTRIBS)
-                               reg->index = NVS_FR_UNKNOWN;
-               } else {
-                       reg->index = (src->Index < FRAG_ATTRIB_MAX) ?
-                               _tx_mesa_fp_src_reg[src->Index] :
-                               NVS_FR_UNKNOWN;
-               }
-               break;
-       case PROGRAM_STATE_VAR:
-       case PROGRAM_NAMED_PARAM:
-       case PROGRAM_CONSTANT:
-               reg->file    = NVS_FILE_CONST;
-               reg->index   = src->Index + rec->mesa_const_base;
-               reg->indexed = src->RelAddr;
-               if (reg->indexed) {
-                       reg->addr_reg  = 0;
-                       reg->addr_comp = NVS_SWZ_X;
-               }
-               break;
-       case PROGRAM_TEMPORARY:
-               reg->file  = NVS_FILE_TEMP;
-               reg->index = src->Index;
-               break;
-       default:
-               fprintf(stderr, "Unknown source type %d\n", src->File);
-               assert(0);
-       }
-
-       /* per-component negate handled elsewhere */
-       reg->negate = src->NegateBase != 0;
-       reg->abs    = src->Abs;
-       pass0_make_swizzle(reg->swizzle, src->Swizzle);
-}
-
-static nvsInstruction *
-pass0_emit(nouveauShader *nvs, nvsFragmentHeader *parent, int fpos,
-          nvsOpcode op, nvsRegister dst,
-          unsigned int mask, int saturate,
-          nvsRegister src0, nvsRegister src1, nvsRegister src2)
-{
-       nvsInstruction *sif;
-
-       sif = CALLOC_STRUCT(nvs_instruction);
-       if (!sif)
-               return NULL;
-
-       /* Seems mesa doesn't explicitly 0 this.. */
-       if (nvs->mesa.vp.Base.Target == GL_VERTEX_PROGRAM_ARB)
-               saturate = 0;
-
-       sif->op         = op;
-       sif->saturate   = saturate;
-       sif->dest       = dst;
-       sif->mask       = mask;
-       sif->dest_scale = NVS_SCALE_1X;
-       sif->src[0]     = src0;
-       sif->src[1]     = src1;
-       sif->src[2]     = src2;
-       sif->cond       = COND_TR;
-       sif->cond_reg   = 0;
-       sif->cond_test  = 0;
-       sif->cond_update= 0;
-       pass0_make_swizzle(sif->cond_swizzle, SWIZZLE_NOOP);
-       pass0_append_fragment(parent, &sif->header, fpos);
-
-       return sif;
-}
-
-static void
-pass0_fixup_swizzle(nvsPtr nvs, nvsFragmentHeader *parent, int fpos,
-                   struct prog_src_register *src,
-                   unsigned int sm1,
-                   unsigned int sm2)
-{
-       static const float sc[4] = { 1.0, 0.0, -1.0, 0.0 };
-       struct pass0_rec *rec = nvs->pass_rec;
-       int fixup_1, fixup_2;
-       nvsInstruction *nvsinst;
-       nvsRegister sr, dr = nvr_unused;
-       nvsRegister sm1const, sm2const;
-
-       if (!rec->swzconst_done) {
-               struct gl_program *prog = &nvs->mesa.vp.Base;
-                GLuint swizzle;
-               rec->swzconst_id = _mesa_add_unnamed_constant(prog->Parameters,
-                                                             sc, 4, &swizzle);
-                /* XXX what about swizzle? */
-               rec->swzconst_done = 1;
-               COPY_4V(nvs->params[rec->swzconst_id].val, sc);
-       }
-
-       fixup_1 = (sm1 != MAKE_SWIZZLE4(0,0,0,0) &&
-                       sm2 != MAKE_SWIZZLE4(2,2,2,2));
-       fixup_2 = (sm2 != MAKE_SWIZZLE4(2,2,2,2));
-
-       if (src->File != PROGRAM_TEMPORARY && src->File != PROGRAM_INPUT) {
-               /* We can't use more than one const in an instruction,
-                * so move the const into a temp, and swizzle from there.
-                *
-                * TODO: should just emit the swizzled const, instead of
-                *       swizzling it in the shader.. would need to reswizzle
-                *       any state params when they change however..
-                */
-               pass0_make_reg(nvs, &dr, NVS_FILE_TEMP, -1);
-               pass0_make_src_reg(nvs, &sr, src);
-               ARITHu(NVS_OP_MOV, dr, SMASK_ALL, 0,
-                                sr, nvr_unused, nvr_unused);
-               pass0_make_reg(nvs, &sr, NVS_FILE_TEMP, dr.index);
-       } else {
-               if (fixup_1)
-                       src->NegateBase = 0;
-               pass0_make_src_reg(nvs, &sr, src);
-               pass0_make_reg(nvs, &dr, NVS_FILE_TEMP, -1);
-       }
-
-       pass0_make_reg(nvs, &sm1const, NVS_FILE_CONST, rec->swzconst_id);
-       pass0_make_swizzle(sm1const.swizzle, sm1);
-       if (fixup_1 && fixup_2) {
-               /* Any combination with SWIZZLE_ONE */
-               pass0_make_reg(nvs, &sm2const,
-                                   NVS_FILE_CONST, rec->swzconst_id);
-               pass0_make_swizzle(sm2const.swizzle, sm2);
-               ARITHu(NVS_OP_MAD, dr, SMASK_ALL, 0, sr, sm1const, sm2const);
-       } else {
-               /* SWIZZLE_ZERO || arbitrary negate */
-               ARITHu(NVS_OP_MUL, dr, SMASK_ALL, 0, sr, sm1const, nvr_unused);
-       }
-
-       src->File       = PROGRAM_TEMPORARY;
-       src->Index      = dr.index;
-       src->Swizzle    = SWIZZLE_NOOP;
-}
-
-#define SET_SWZ(fs, cp, c) fs = (fs & ~(0x7<<(cp*3))) | (c<<(cp*3))
-static void
-pass0_check_sources(nvsPtr nvs, nvsFragmentHeader *parent, int fpos,
-                   struct prog_instruction *inst)
-{
-       unsigned int insrc = -1, constsrc = -1;
-       int i;
-
-       for (i=0;i<_mesa_num_inst_src_regs(inst->Opcode);i++) {
-               struct prog_src_register *src = &inst->SrcReg[i];
-               unsigned int sm_1 = 0, sm_2 = 0;
-               nvsRegister sr, dr;
-               int do_mov = 0, c;
-
-               /* Build up swizzle masks as if we were going to use
-                * "MAD new, src, const1, const2" to support arbitrary negation
-                * and SWIZZLE_ZERO/SWIZZLE_ONE.
-                */
-               for (c=0;c<4;c++) {
-                       if (GET_SWZ(src->Swizzle, c) == SWIZZLE_ZERO) {
-                               SET_SWZ(sm_1, c, SWIZZLE_Y); /* 0.0 */
-                               SET_SWZ(sm_2, c, SWIZZLE_Y);
-                               SET_SWZ(src->Swizzle, c, SWIZZLE_X);
-                       } else if (GET_SWZ(src->Swizzle, c) == SWIZZLE_ONE) {
-                               SET_SWZ(sm_1, c, SWIZZLE_Y);
-                               if (src->NegateBase & (1<<c))
-                                       SET_SWZ(sm_2, c, SWIZZLE_Z); /* -1.0 */
-                               else
-                                       SET_SWZ(sm_2, c, SWIZZLE_X); /* 1.0 */
-                               SET_SWZ(src->Swizzle, c, SWIZZLE_X);
-                       } else {
-                               if (src->NegateBase & (1<<c))
-                                       SET_SWZ(sm_1, c, SWIZZLE_Z); /* -[xyzw] */
-                               else
-                                       SET_SWZ(sm_1, c, SWIZZLE_X); /*[xyzw]*/
-                               SET_SWZ(sm_2, c, SWIZZLE_Y);
-                       }
-               }
-
-               /* Unless we're multiplying by 1.0 or -1.0 on all components,
-                * and we're adding nothing to any component we have to
-                * emulate the swizzle.
-                */
-               if ((sm_1 != MAKE_SWIZZLE4(0,0,0,0) &&
-                                       sm_1 != MAKE_SWIZZLE4(2,2,2,2)) ||
-                               sm_2 != MAKE_SWIZZLE4(1,1,1,1)) {
-                       pass0_fixup_swizzle(nvs, parent, fpos, src, sm_1, sm_2);
-                       /* The source is definitely in a temp now, so don't
-                        * bother checking  for multiple ATTRIB/CONST regs.
-                        */
-                       continue;
-               }
-
-               /* HW can't use more than one ATTRIB or PARAM in a single
-                * instruction */
-               switch (src->File) {
-               case PROGRAM_INPUT:
-                       if (insrc != -1 && insrc != src->Index) 
-                               do_mov = 1;
-                       else insrc = src->Index;
-                       break;
-               case PROGRAM_STATE_VAR:
-                       if (constsrc != -1 && constsrc != src->Index)
-                               do_mov = 1;
-                       else constsrc = src->Index;
-                       break;
-               default:
-                       break;
-               }
-
-               /* Emit any extra ATTRIB/CONST to a temp, and modify the Mesa
-                * instruction to point at the temp.
-                */
-               if (do_mov) {
-                       pass0_make_src_reg(nvs, &sr, src);
-                       pass0_make_reg(nvs, &dr, NVS_FILE_TEMP, -1);
-                       pass0_emit(nvs, parent, fpos, NVS_OP_MOV,
-                                       dr, SMASK_ALL, 0,
-                                       sr, nvr_unused, nvr_unused);
-
-                       src->File       = PROGRAM_TEMPORARY;
-                       src->Index      = dr.index;
-                       src->Swizzle= SWIZZLE_NOOP;
-               }
-       }
-}
-
-static GLboolean
-pass0_emulate_instruction(nouveauShader *nvs,
-                         nvsFragmentHeader *parent, int fpos,
-                         struct prog_instruction *inst)
-{
-       nvsFunc *shader = nvs->func;
-       nvsRegister src[3], dest, temp;
-       nvsInstruction *nvsinst;
-       unsigned int mask = pass0_make_mask(inst->DstReg.WriteMask);
-       int i, sat;
-
-       sat = (inst->SaturateMode == SATURATE_ZERO_ONE);
-
-       /* Build all the "real" regs for the instruction */
-       for (i=0; i<_mesa_num_inst_src_regs(inst->Opcode); i++)
-               pass0_make_src_reg(nvs, &src[i], &inst->SrcReg[i]);
-       if (inst->Opcode != OPCODE_KIL)
-               pass0_make_dst_reg(nvs, &dest, &inst->DstReg);
-
-       switch (inst->Opcode) {
-       case OPCODE_ABS:
-               if (shader->caps & SCAP_SRC_ABS)
-                       ARITH(NVS_OP_MOV, dest, mask, sat,
-                                       nvsAbs(src[0]), nvr_unused, nvr_unused);
-               else
-                       ARITH(NVS_OP_MAX, dest, mask, sat,
-                                       src[0], nvsNegate(src[0]), nvr_unused);
-               break;
-       case OPCODE_CMP:
-               /*XXX: this will clobber CC0... */
-               ARITH (NVS_OP_MOV, dest, mask, sat,
-                               src[2], nvr_unused, nvr_unused);
-               pass0_make_reg(nvs, &temp, NVS_FILE_TEMP, -1);
-               ARITHu(NVS_OP_MOV, temp, SMASK_ALL, 0,
-                               src[0], nvr_unused, nvr_unused);
-               nvsinst->cond_update = 1;
-               nvsinst->cond_reg    = 0;
-               ARITH (NVS_OP_MOV, dest, mask, sat,
-                               src[1], nvr_unused, nvr_unused);
-               nvsinst->cond      = COND_LT;
-               nvsinst->cond_reg  = 0;
-               nvsinst->cond_test = 1;
-               break;
-       case OPCODE_DPH:
-               pass0_make_reg(nvs, &temp, NVS_FILE_TEMP, -1);
-               ARITHu(NVS_OP_DP3, temp, SMASK_X, 0,
-                                src[0], src[1], nvr_unused);
-               ARITH (NVS_OP_ADD, dest, mask, sat,
-                                nvsSwizzle(temp, X, X, X, X),
-                                nvsSwizzle(src[1], W, W, W, W),
-                                nvr_unused);
-               break;
-       case OPCODE_KIL:
-               /* This is only in ARB shaders, so we don't have to worry
-                * about clobbering a CC reg as they aren't supported anyway.
-                *XXX: might have to worry with GLSL however...
-                */
-               /* MOVC0 temp, src */
-               pass0_make_reg(nvs, &temp, NVS_FILE_TEMP, -1);
-               ARITHu(NVS_OP_MOV, temp, SMASK_ALL, 0,
-                                src[0], nvr_unused, nvr_unused);
-               nvsinst->cond_update = 1;
-               nvsinst->cond_reg    = 0;
-               /* KIL_NV (LT0.xyzw) temp */
-               ARITHu(NVS_OP_KIL, nvr_unused, 0, 0,
-                                nvr_unused, nvr_unused, nvr_unused);
-               nvsinst->cond      = COND_LT;
-               nvsinst->cond_reg  = 0;
-               nvsinst->cond_test = 1;
-               pass0_make_swizzle(nvsinst->cond_swizzle, SWIZZLE_NOOP);
-               break;
-       case OPCODE_LRP:
-               pass0_make_reg(nvs, &temp, NVS_FILE_TEMP, -1);
-               ARITHu(NVS_OP_MAD, temp, mask, 0,
-                                nvsNegate(src[0]), src[2], src[2]);
-               ARITH (NVS_OP_MAD, dest, mask, sat, src[0], src[1], temp);
-               break;
-       case OPCODE_POW:
-               if (shader->SupportsOpcode(shader, NVS_OP_LG2) &&
-                               shader->SupportsOpcode(shader, NVS_OP_EX2)) {
-                       pass0_make_reg(nvs, &temp, NVS_FILE_TEMP, -1);
-                       /* LG2 temp.x, src0.c */
-                       ARITHu(NVS_OP_LG2, temp, SMASK_X, 0,
-                                        nvsSwizzle(src[0], X, X, X, X),
-                                        nvr_unused, nvr_unused);
-                       /* MUL temp.x, temp.x, src1.c */
-                       ARITHu(NVS_OP_MUL, temp, SMASK_X, 0,
-                                        nvsSwizzle(temp, X, X, X, X),
-                                        nvsSwizzle(src[1], X, X, X, X),
-                                        nvr_unused);
-                       /* EX2 dest, temp.x */
-                       ARITH (NVS_OP_EX2, dest, mask, sat,
-                                        nvsSwizzle(temp, X, X, X, X),
-                                        nvr_unused, nvr_unused);
-               } else {
-                       /* can we use EXP/LOG instead of EX2/LG2?? */
-                       fprintf(stderr, "Implement POW for NV20 vtxprog!\n");
-                       return GL_FALSE;
-               }
-               break;
-       case OPCODE_RSQ:
-               pass0_make_reg(nvs, &temp, NVS_FILE_TEMP, -1);
-               ARITHu(NVS_OP_LG2, temp, SMASK_X, 0,
-                                nvsAbs(nvsSwizzle(src[0], X, X, X, X)),
-                                nvr_unused, nvr_unused);
-               nvsinst->dest_scale = NVS_SCALE_INV_2X;
-               ARITH (NVS_OP_EX2, dest, mask, sat,
-                                nvsNegate(nvsSwizzle(temp, X, X, X, X)),
-                                nvr_unused, nvr_unused);
-               break;
-       case OPCODE_SCS:
-               if (mask & SMASK_X)
-                       ARITH(NVS_OP_COS, dest, SMASK_X, sat,
-                                       nvsSwizzle(src[0], X, X, X, X),
-                                       nvr_unused, nvr_unused);
-               if (mask & SMASK_Y)
-                       ARITH(NVS_OP_SIN, dest, SMASK_Y, sat,
-                                       nvsSwizzle(src[0], X, X, X, X),
-                                       nvr_unused, nvr_unused);
-               break;
-       case OPCODE_SUB:
-               ARITH(NVS_OP_ADD, dest, mask, sat,
-                               src[0], nvsNegate(src[1]), nvr_unused);
-               break;
-       case OPCODE_XPD:
-               pass0_make_reg(nvs, &temp, NVS_FILE_TEMP, -1);
-               ARITHu(NVS_OP_MUL, temp, SMASK_ALL, 0,
-                                nvsSwizzle(src[0], Z, X, Y, Y),
-                                nvsSwizzle(src[1], Y, Z, X, X),
-                                nvr_unused);
-               ARITH (NVS_OP_MAD, dest, (mask & ~SMASK_W), sat,
-                                nvsSwizzle(src[0], Y, Z, X, X),
-                                nvsSwizzle(src[1], Z, X, Y, Y),
-                                nvsNegate(temp));
-               break;
-       default:
-               WARN_ONCE("hw doesn't support opcode \"%s\","
-                         "and no emulation found\n",
-                         _mesa_opcode_string(inst->Opcode));
-               return GL_FALSE;
-       }
-
-       return GL_TRUE;
-}
-
-static GLboolean
-pass0_translate_arith(nouveauShader *nvs, struct gl_program *prog,
-                                         int ipos, int fpos,
-                                         nvsFragmentHeader *parent)
-{
-       struct prog_instruction *inst = &prog->Instructions[ipos];
-       nvsFunc *shader = nvs->func;
-       nvsInstruction *nvsinst;
-       GLboolean ret;
-
-       /* Deal with multiple ATTRIB/PARAM in a single instruction */
-       pass0_check_sources(nvs, parent, fpos, inst);
-
-       /* Now it's safe to do the prog_instruction->nvsInstruction
-        * conversion
-        */
-       if (shader->SupportsOpcode(shader,
-                                  pass0_make_opcode(inst->Opcode))) {
-               nvsRegister src[3], dest;
-               int i;
-
-               for (i=0; i<_mesa_num_inst_src_regs(inst->Opcode); i++)
-                       pass0_make_src_reg(nvs, &src[i], &inst->SrcReg[i]);
-               pass0_make_dst_reg(nvs, &dest, &inst->DstReg);
-
-               ARITH(pass0_make_opcode(inst->Opcode), dest,
-                               pass0_make_mask(inst->DstReg.WriteMask),
-                               (inst->SaturateMode != SATURATE_OFF),
-                               src[0], src[1], src[2]);
-               nvsinst->tex_unit   = inst->TexSrcUnit;
-               if (pass0_opcode_is_tex(inst->Opcode))
-                       nvsinst->tex_target =
-                               pass0_make_tex_target(inst->TexSrcTarget);
-               else
-                       nvsinst->tex_target = NVS_TEX_TARGET_UNKNOWN;
-
-               ret = GL_TRUE;
-       } else
-               ret = pass0_emulate_instruction(nvs, parent, fpos, inst);
-
-       return ret;
-}
-
-static GLboolean
-pass0_translate_instructions(nouveauShader *nvs, int ipos, int fpos,
-                                                nvsFragmentHeader *parent)
-{
-       struct gl_program *prog = (struct gl_program *)&nvs->mesa.vp;
-
-       while (1) {
-               struct prog_instruction *inst = &prog->Instructions[ipos];
-
-               switch (inst->Opcode) {
-               case OPCODE_END:
-                       return GL_TRUE;
-               case OPCODE_BRA:
-               case OPCODE_CAL:
-               case OPCODE_RET:
-               //case OPCODE_LOOP:
-               //case OPCODE_ENDLOOP:
-               //case OPCODE_IF:
-               //case OPCODE_ELSE:
-               //case OPCODE_ENDIF:
-                       WARN_ONCE("branch ops unimplemented\n");
-                       return GL_FALSE;
-                       break;
-               default:
-                       if (!pass0_translate_arith(nvs, prog,
-                                                  ipos, fpos, parent))
-                               return GL_FALSE;
-                       break;
-               }
-
-               ipos++;
-       }
-
-       return GL_TRUE;
-}
-
-static void
-pass0_build_attrib_map(nouveauShader *nvs, struct gl_vertex_program *vp)
-{
-       GLuint inputs_read = vp->Base.InputsRead;
-       GLuint input_alloc = ~0xFFFF;
-       int i;
-
-       for (i=0; i<NVS_MAX_ATTRIBS; i++)
-               nvs->vp_attrib_map[i] = -1;
-
-       while (inputs_read) {
-               int in = ffs(inputs_read) - 1;
-               int hw;
-               inputs_read &= ~(1<<in);
-
-               if (vp->IsNVProgram) {
-                       /* NVvp: must alias */
-                       if (in >= VERT_ATTRIB_GENERIC0)
-                               hw = in - VERT_ATTRIB_GENERIC0;
-                       else
-                               hw = in;
-               } else {
-                       /* ARBvp: may alias (but we won't)
-                        * GL2.0: must not alias
-                        */
-                       if (in >= VERT_ATTRIB_GENERIC0)
-                               hw = ffs(~input_alloc) - 1;
-                       else 
-                               hw = in;
-                       input_alloc |= (1<<hw);
-               }
-
-               nvs->vp_attrib_map[hw] = in;
-       }
-
-       if (NOUVEAU_DEBUG & DEBUG_SHADERS) {
-               printf("vtxprog attrib map:\n");
-               for (i=0; i<NVS_MAX_ATTRIBS; i++) {
-                       printf(" hw:%d = attrib:%d\n",
-                                       i, nvs->vp_attrib_map[i]);
-               }
-       }
-}
-
-static void
-pass0_vp_insert_ff_clip_planes(GLcontext *ctx, nouveauShader *nvs)
-{
-       struct gl_program *prog = &nvs->mesa.vp.Base;
-       nvsFragmentHeader *parent = nvs->program_tree;
-       nvsInstruction *nvsinst;
-       GLuint fpos = 0;
-       nvsRegister opos, epos, eqn, mv[4];
-       gl_state_index tokens[STATE_LENGTH]
-           = { STATE_MODELVIEW_MATRIX, 0, 0, 0, 0 };
-       GLint id;
-       int i;
-
-       /* modelview transform */
-       pass0_make_reg(nvs, &opos, NVS_FILE_ATTRIB, NVS_FR_POSITION);
-       pass0_make_reg(nvs, &epos, NVS_FILE_TEMP  , -1);
-       for (i=0; i<4; i++) {
-               tokens[2] = tokens[3] = i;
-               id = _mesa_add_state_reference(prog->Parameters, tokens);
-               pass0_make_reg(nvs, &mv[i], NVS_FILE_CONST, id);
-       }
-       ARITHu(NVS_OP_DP4, epos, SMASK_X, 0, opos, mv[0], nvr_unused);
-       ARITHu(NVS_OP_DP4, epos, SMASK_Y, 0, opos, mv[1], nvr_unused);
-       ARITHu(NVS_OP_DP4, epos, SMASK_Z, 0, opos, mv[2], nvr_unused);
-       ARITHu(NVS_OP_DP4, epos, SMASK_W, 0, opos, mv[3], nvr_unused);
-
-       /* Emit code to emulate fixed-function glClipPlane */
-       for (i=0; i<6; i++) {
-               GLuint clipmask = SMASK_X;
-               nvsRegister clip;
-
-               if (!(ctx->Transform.ClipPlanesEnabled & (1<<i)))
-                       continue;
-
-               /* Point a const at a user clipping plane */
-               tokens[0] = STATE_CLIPPLANE;
-               tokens[1] = i;
-               id = _mesa_add_state_reference(prog->Parameters, tokens);
-               pass0_make_reg(nvs, &eqn , NVS_FILE_CONST , id);
-               pass0_make_reg(nvs, &clip, NVS_FILE_RESULT, NVS_FR_CLIP0 + i);
-
-               /*XXX: something else needs to take care of modifying the
-                *     instructions to write to the correct hw clip register.
-                */
-               switch (i) {
-               case 0: case 3: clipmask = SMASK_Y; break;
-               case 1: case 4: clipmask = SMASK_Z; break;
-               case 2: case 5: clipmask = SMASK_W; break;
-               }
-
-               /* Emit transform */
-               ARITHu(NVS_OP_DP4, clip, clipmask, 0, epos, eqn, nvr_unused);
-       }
-}
-
-static void
-pass0_rebase_mesa_consts(nouveauShader *nvs)
-{
-       struct pass0_rec *rec = nvs->pass_rec;
-       struct gl_program *prog = &nvs->mesa.vp.Base;
-       struct prog_instruction *inst = prog->Instructions;
-       int i;
-
-       /*XXX: not a good idea, params->hw_index is malloc'd */
-       memset(nvs->params, 0x00, sizeof(nvs->params));
-
-       /* When doing relative addressing on constants, the hardware needs us
-        * to fill the "const id" field with a positive value.  Determine the
-        * most negative index that is used so that all accesses to a
-        * mesa-provided constant can be rebased to a positive index.
-        */
-       while (inst->Opcode != OPCODE_END) {
-               for (i=0; i<_mesa_num_inst_src_regs(inst->Opcode); i++) {
-                       struct prog_src_register *src = &inst->SrcReg[i];
-
-                       switch (src->File) {
-                       case PROGRAM_STATE_VAR:
-                       case PROGRAM_CONSTANT:
-                       case PROGRAM_NAMED_PARAM:
-                               if (src->RelAddr && src->Index < 0) {
-                                       int base = src->Index * -1;
-                                       if (rec->mesa_const_base < base)
-                                               rec->mesa_const_base = base;
-                               }
-                               break;
-                       default:
-                               break;
-                       }
-               }
-
-               inst++;
-       }
-}
-
-static GLboolean
-pass0_resolve_mesa_consts(nouveauShader *nvs)
-{
-       struct pass0_rec *rec = nvs->pass_rec;
-       struct gl_program *prog = &nvs->mesa.vp.Base;
-       struct gl_program_parameter_list *plist = prog->Parameters;
-       int i;
-
-       /* Init all const tracking/alloc info from the parameter list, rather
-        * than doing it as we translate the program.  Otherwise:
-        *   1) we can't get at the correct constant info when relative
-        *      addressing is being used due to src->Index not pointing
-        *      at the exact const;
-        *   2) as we add extra consts to the program, mesa will call realloc()
-        *      and we get invalid pointers to the const data.
-        */
-       rec->mesa_const_last = plist->NumParameters + rec->mesa_const_base;
-       nvs->param_high = rec->mesa_const_last;
-       for (i=0; i<plist->NumParameters; i++) {
-               int hw = rec->mesa_const_base + i;
-
-               if (hw > NVS_MAX_CONSTS) {
-                       nvsProgramError(nvs, "hw = %d > NVS_MAX_CONSTS!\n", hw);
-                       return GL_FALSE;
-               }
-
-               switch (plist->Parameters[i].Type) {
-               case PROGRAM_NAMED_PARAM:
-               case PROGRAM_STATE_VAR:
-                       nvs->params[hw].in_use     = GL_TRUE;
-                       nvs->params[hw].source_val = plist->ParameterValues[i];
-                       COPY_4V(nvs->params[hw].val, plist->ParameterValues[i]);
-                       break;
-               case PROGRAM_CONSTANT:
-                       nvs->params[hw].in_use     = GL_TRUE;
-                       nvs->params[hw].source_val = NULL;
-                       COPY_4V(nvs->params[hw].val, plist->ParameterValues[i]);
-                       break;
-               default:
-                       nvsProgramError(nvs, "hit bad type=%d on param %d\n",
-                                       plist->Parameters[i].Type, i);
-                       return GL_FALSE;
-               }
-       }
-
-       return GL_TRUE;
-}
-
-GLboolean
-nouveau_shader_pass0(GLcontext *ctx, nouveauShader *nvs)
-{
-       nouveauContextPtr           nmesa = NOUVEAU_CONTEXT(ctx);
-       struct gl_program          *prog  = (struct gl_program*)nvs;
-       struct gl_vertex_program   *vp    = (struct gl_vertex_program *)prog;
-       struct gl_fragment_program *fp    = (struct gl_fragment_program *)prog;
-       struct pass0_rec *rec;
-       int ret = GL_FALSE;
-
-       NVSDBG("start: nvs=%p\n", nvs);
-
-       /* Previously detected an error, and haven't recieved new program
-        * string, so fail immediately.
-        */
-       if (nvs->error) {
-               NVSDBG("failed previous compile attempt, not retrying\n");
-               return GL_FALSE;
-       }
-
-       rec = CALLOC_STRUCT(pass0_rec);
-       if (!rec)
-               return GL_FALSE;
-
-       rec->next_temp = prog->NumTemporaries;
-       nvs->pass_rec  = rec;
-               
-       nvs->program_tree = (nvsFragmentHeader*)
-               pass0_create_subroutine(nvs, "program body");
-       if (!nvs->program_tree) {
-               FREE(rec);
-               return GL_FALSE;
-       }
-
-       switch (prog->Target) {
-       case GL_VERTEX_PROGRAM_ARB:
-               nvs->func = &nmesa->VPfunc;
-
-               if (vp->IsPositionInvariant)
-                       _mesa_insert_mvp_code(ctx, vp);
-               pass0_rebase_mesa_consts(nvs);
-
-               if (!prog->String && ctx->Transform.ClipPlanesEnabled)
-                       pass0_vp_insert_ff_clip_planes(ctx, nvs);
-
-               pass0_build_attrib_map(nvs, vp);
-               break;
-       case GL_FRAGMENT_PROGRAM_ARB:
-               nvs->func = &nmesa->FPfunc;
-
-               if (fp->FogOption != GL_NONE)
-                       _mesa_append_fog_code(ctx, fp);
-               pass0_rebase_mesa_consts(nvs);
-               break;
-       default:
-               fprintf(stderr, "Unknown program type %d", prog->Target);
-               FREE(rec);
-               /* DESTROY TREE!! */
-               return GL_FALSE;
-       }
-       nvs->func->card_priv = &nvs->card_priv;
-
-       ret = pass0_translate_instructions(nvs, 0, 0, nvs->program_tree);
-       if (ret)
-               ret = pass0_resolve_mesa_consts(nvs);   
-       
-       /*XXX: if (!ret) DESTROY TREE!!! */
-
-       FREE(rec);
-       return ret;
-}
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader_1.c b/src/mesa/drivers/dri/nouveau/nouveau_shader_1.c
deleted file mode 100644 (file)
index 78c1401..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#include "glheader.h"
-#include "macros.h"
-#include "enums.h"
-
-#include "nouveau_context.h"
-#include "nouveau_shader.h"
-
-GLboolean
-nouveau_shader_pass1(nvsPtr nvs)
-{
-   NVSDBG("start: nvs=%p\n", nvs);
-
-   return GL_TRUE;
-}
-
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader_2.c b/src/mesa/drivers/dri/nouveau/nouveau_shader_2.c
deleted file mode 100644 (file)
index cd27dac..0000000
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Copyright (C) 2006 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>
- */
-
-#include "glheader.h"
-#include "macros.h"
-#include "enums.h"
-
-#include "shader/prog_parameter.h"
-#include "shader/prog_print.h"
-
-#include "nouveau_context.h"
-#include "nouveau_shader.h"
-#include "nouveau_msg.h"
-
-struct pass2_rec {
-       /* Map nvsRegister temp ID onto hw temp ID */
-       unsigned int temps[NVS_MAX_TEMPS];
-       /* Track free hw registers */
-       unsigned int hw_temps[NVS_MAX_TEMPS];
-};
-
-static int
-pass2_alloc_hw_temp(nvsPtr nvs)
-{
-       struct pass2_rec *rec = nvs->pass_rec;
-       int i;
-
-       for (i=0; i<nvs->func->MaxTemp; i++) {
-               /* This is a *horrible* hack.. R0 is both temp0 and result.color
-                * in NV30/40 fragprogs, we can use R0 as a temp before result
-                * is written however..
-                */
-               if (nvs->mesa.vp.Base.Target == GL_FRAGMENT_PROGRAM_ARB && i==0)
-                       continue;
-               if (rec->hw_temps[i] == 0) {
-                       rec->hw_temps[i] = 1;
-                       return i;
-               }
-       }
-
-       return -1;
-}
-
-static nvsRegister
-pass2_mangle_reg(nvsPtr nvs, nvsInstruction *inst, nvsRegister reg)
-{
-       struct pass2_rec *rec = nvs->pass_rec;
-
-       if (reg.file == NVS_FILE_TEMP) {
-               if (rec->temps[reg.index] == -1)
-                       rec->temps[reg.index] = pass2_alloc_hw_temp(nvs);
-               reg.index = rec->temps[reg.index];
-       }
-
-       return reg;
-}
-
-static void
-pass2_add_instruction(nvsPtr nvs, nvsInstruction *inst, 
-                     struct _op_xlat *op, int slot)
-{
-       nvsSwzComp default_swz[4] = { NVS_SWZ_X, NVS_SWZ_Y,
-                                     NVS_SWZ_Z, NVS_SWZ_W };
-       nvsFunc *shader = nvs->func;
-       nvsRegister reg;
-       int i;
-
-       shader->SetOpcode(shader, op->NV, slot);
-       if (inst->saturate      ) shader->SetSaturate(shader);
-       if (inst->cond_update   ) shader->SetCCUpdate(shader);
-       if (inst->cond_test     ) shader->SetCondition(shader, 1, inst->cond,
-                                                      inst->cond_reg,
-                                                      inst->cond_swizzle);
-       else                      shader->SetCondition(shader, 0, NVS_COND_TR,
-                                                      0,
-                                                      default_swz);
-       switch (inst->op) {
-       case NVS_OP_TEX:
-       case NVS_OP_TXB:
-       case NVS_OP_TXL:
-       case NVS_OP_TXP:
-       case NVS_OP_TXD:
-               shader->SetTexImageUnit(shader, inst->tex_unit);
-               break;
-       default:
-               break;
-       }
-
-       for (i = 0; i < 3; i++) {
-               if (op->srcpos[i] != -1) {
-                       reg = pass2_mangle_reg(nvs, inst, inst->src[i]);
-
-                       shader->SetSource(shader, &reg, op->srcpos[i]);
-
-                       if (reg.file == NVS_FILE_CONST &&
-                                       shader->GetSourceConstVal) {
-                               int idx_slot =
-                                       nvs->params[reg.index].hw_index_cnt++;
-                               nvs->params[reg.index].hw_index = realloc(
-                                               nvs->params[reg.index].hw_index,
-                                               sizeof(int) * idx_slot+1);
-                               nvs->params[reg.index].hw_index[idx_slot] =
-                                       nvs->program_current + 4;
-                       }
-               }
-       }
-
-       reg = pass2_mangle_reg(nvs, inst, inst->dest);
-       shader->SetResult(shader, &reg, inst->mask, slot);
-
-       if (inst->dest_scale != NVS_SCALE_1X) {
-               shader->SetResultScale(shader, inst->dest_scale);
-       }
-}
-
-static int
-pass2_assemble_instruction(nvsPtr nvs, nvsInstruction *inst, int last)
-{
-       nvsFunc *shader = nvs->func;
-       struct _op_xlat *op;
-       unsigned int hw_inst[8];
-       int slot;
-       int instsz;
-       int i;
-
-       shader->inst = hw_inst;
-
-       /* Assemble this instruction */
-       if (!(op = shader->GetOPTXFromSOP(inst->op, &slot)))
-               return 0;
-       shader->InitInstruction(shader);
-       pass2_add_instruction(nvs, inst, op, slot);
-       if (last)
-               shader->SetLastInst(shader);
-
-       instsz = shader->GetOffsetNext(nvs->func);
-       if (nvs->program_size + instsz >= nvs->program_alloc_size) {
-               nvs->program_alloc_size *= 2;
-               nvs->program = realloc(nvs->program,
-                                      nvs->program_alloc_size *
-                                      sizeof(uint32_t));
-       }
-
-       for (i=0; i<instsz; i++)
-               nvs->program[nvs->program_current++] = hw_inst[i];
-       nvs->program_size = nvs->program_current;
-       return 1;
-}
-
-static GLboolean
-pass2_translate(nvsPtr nvs, nvsFragmentHeader *f)
-{
-       nvsFunc *shader = nvs->func;
-       GLboolean last;
-
-       while (f) {
-               last = (f == ((nvsSubroutine*)nvs->program_tree)->insn_tail);
-
-               switch (f->type) {
-               case NVS_INSTRUCTION:
-                       if (!pass2_assemble_instruction(nvs,
-                                                       (nvsInstruction *)f,
-                                                       last))
-                               return GL_FALSE;
-                       break;
-               default:
-                       WARN_ONCE("Unimplemented fragment type\n");
-                       return GL_FALSE;
-               }
-
-               f = f->next;
-       }
-
-       return GL_TRUE;
-}
-
-/* Translate program into hardware format */
-GLboolean
-nouveau_shader_pass2(nvsPtr nvs)
-{
-       struct pass2_rec *rec;
-       int i;
-
-       NVSDBG("start: nvs=%p\n", nvs);
-
-       rec = calloc(1, sizeof(struct pass2_rec));
-       for (i=0; i<NVS_MAX_TEMPS; i++)
-               rec->temps[i] = -1;
-       nvs->pass_rec = rec;
-
-       /* Start off with allocating 4 uint32_t's for each inst, will be grown
-        * if necessary..
-        */
-       nvs->program_alloc_size = nvs->mesa.vp.Base.NumInstructions * 4;
-       nvs->program = calloc(nvs->program_alloc_size, sizeof(uint32_t));
-       nvs->program_size    = 0;
-       nvs->program_current = 0;
-
-       if (!pass2_translate(nvs,
-                            ((nvsSubroutine*)nvs->program_tree)->insn_head)) {
-               free(nvs->program);
-               nvs->program = NULL;
-               return GL_FALSE;
-       }
-
-       /* Shrink allocated memory to only what we need */
-       nvs->program = realloc(nvs->program,
-                              nvs->program_size * sizeof(uint32_t));
-       nvs->program_alloc_size = nvs->program_size;
-
-       nvs->translated  = 1;
-       nvs->on_hardware = 0;
-
-       if (NOUVEAU_DEBUG & DEBUG_SHADERS) {
-               fflush(stdout); fflush(stderr);
-               fprintf(stderr, "-----------MESA PROGRAM target=%s, id=0x%x\n",
-                               _mesa_lookup_enum_by_nr(
-                                       nvs->mesa.vp.Base.Target),
-                               nvs->mesa.vp.Base.Id);
-               fflush(stdout); fflush(stderr);
-               _mesa_print_program(&nvs->mesa.vp.Base);
-               fflush(stdout); fflush(stderr);
-               fprintf(stderr, "^^^^^^^^^^^^^^^^MESA PROGRAM\n");
-               fflush(stdout); fflush(stderr);
-               fprintf(stderr, "----------------NV PROGRAM\n");
-               fflush(stdout); fflush(stderr);
-               nvsDisasmHWShader(nvs);
-               fflush(stdout); fflush(stderr);
-               fprintf(stderr, "^^^^^^^^^^^^^^^^NV PROGRAM\n");
-               fflush(stdout); fflush(stderr);
-       }
-
-       return GL_TRUE;
-}
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_span.c b/src/mesa/drivers/dri/nouveau/nouveau_span.c
deleted file mode 100644 (file)
index 6e3f9fa..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/**************************************************************************
-
-Copyright 2006 Stephane Marchesin
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-
-#include "nouveau_context.h"
-#include "nouveau_span.h"
-#include "nouveau_fifo.h"
-#include "nouveau_lock.h"
-
-#include "swrast/swrast.h"
-
-#define HAVE_HW_DEPTH_SPANS    0
-#define HAVE_HW_DEPTH_PIXELS   0
-#define HAVE_HW_STENCIL_SPANS  0
-#define HAVE_HW_STENCIL_PIXELS 0
-
-static char *fake_span[1280*1024*4];
-
-#define HW_CLIPLOOP()                                                  \
-   do {                                                                        \
-      int _nc = nmesa->numClipRects;                                   \
-      while ( _nc-- ) {                                                        \
-        int minx = nmesa->pClipRects[_nc].x1 - nmesa->drawX;           \
-        int miny = nmesa->pClipRects[_nc].y1 - nmesa->drawY;           \
-        int maxx = nmesa->pClipRects[_nc].x2 - nmesa->drawX;           \
-        int maxy = nmesa->pClipRects[_nc].y2 - nmesa->drawY;
-
-#define LOCAL_VARS                                                     \
-   nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);                     \
-   nouveau_renderbuffer *nrb = (nouveau_renderbuffer *)rb;             \
-   GLuint height = nrb->mesa.Height;                                   \
-   GLubyte *map = (GLubyte *)(nrb->map ? nrb->map : nrb->mem->map) +    \
-        (nmesa->drawY * nrb->pitch) + (nmesa->drawX * nrb->cpp);       \
-   map = fake_span; \
-   GLuint p;                                                           \
-   (void) p;
-
-#define Y_FLIP( _y )            (height - _y - 1)
-
-#define HW_LOCK()
-
-#define HW_UNLOCK()
-
-
-
-/* ================================================================
- * Color buffers
- */
-
-/* RGB565 */ 
-#define SPANTMP_PIXEL_FMT GL_RGB
-#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
-
-#define TAG(x)    nouveau##x##_RGB565
-#define TAG2(x,y) nouveau##x##_RGB565##y
-#define GET_PTR(X,Y) (map + (Y)*nrb->pitch + (X)*nrb->cpp)
-#include "spantmp2.h"
-
-
-/* ARGB8888 */
-#define SPANTMP_PIXEL_FMT GL_BGRA
-#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
-
-#define TAG(x)    nouveau##x##_ARGB8888
-#define TAG2(x,y) nouveau##x##_ARGB8888##y
-#define GET_PTR(X,Y) (map + (Y)*nrb->pitch + (X)*nrb->cpp)
-#include "spantmp2.h"
-
-static void
-nouveauSpanRenderStart( GLcontext *ctx )
-{
-   nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-   FIRE_RING();
-   LOCK_HARDWARE(nmesa);
-   nouveauWaitForIdleLocked( nmesa );
-}
-
-static void
-nouveauSpanRenderFinish( GLcontext *ctx )
-{
-   nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-   _swrast_flush( ctx );
-   nouveauWaitForIdleLocked( nmesa );
-   UNLOCK_HARDWARE( nmesa );
-}
-
-void nouveauSpanInitFunctions( GLcontext *ctx )
-{
-   struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
-   swdd->SpanRenderStart       = nouveauSpanRenderStart;
-   swdd->SpanRenderFinish      = nouveauSpanRenderFinish;
-}
-
-
-/**
- * Plug in the Get/Put routines for the given driRenderbuffer.
- */
-void
-nouveauSpanSetFunctions(nouveau_renderbuffer *nrb, const GLvisual *vis)
-{
-   if (nrb->mesa._ActualFormat == GL_RGBA8)
-      nouveauInitPointers_ARGB8888(&nrb->mesa);
-   else // if (nrb->mesa._ActualFormat == GL_RGB5)
-      nouveauInitPointers_RGB565(&nrb->mesa);
-}
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_span.h b/src/mesa/drivers/dri/nouveau/nouveau_span.h
deleted file mode 100644 (file)
index bc39ecd..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/**************************************************************************
-
-Copyright 2006 Stephane Marchesin
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-
-
-#ifndef __NOUVEAU_SPAN_H__
-#define __NOUVEAU_SPAN_H__
-
-#include "drirenderbuffer.h"
-#include "nouveau_buffers.h"
-
-extern void nouveauSpanInitFunctions( GLcontext *ctx );
-extern void nouveauSpanSetFunctions(nouveau_renderbuffer *nrb, const GLvisual *vis);
-
-#endif /* __NOUVEAU_SPAN_H__ */
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c
deleted file mode 100644 (file)
index f618dcf..0000000
+++ /dev/null
@@ -1,347 +0,0 @@
-/**************************************************************************
-
-Copyright 2006 Jeremy Kolb
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-#include "nouveau_context.h"
-#include "nouveau_state.h"
-#include "nouveau_swtcl.h"
-#include "nouveau_fifo.h"
-
-#include "swrast/swrast.h"
-#include "tnl/tnl.h"
-#include "swrast_setup/swrast_setup.h"
-
-#include "tnl/t_pipeline.h"
-
-#include "mtypes.h"
-#include "colormac.h"
-
-static __inline__ GLuint nouveauPackColor(GLuint format,
-                                      GLubyte r, GLubyte g,
-                                      GLubyte b, GLubyte a)
-{
-   switch (format) {
-   case 2:
-      return PACK_COLOR_565( r, g, b );
-   case 4:
-      return PACK_COLOR_8888( r, g, b, a);
-   default:
-      fprintf(stderr, "unknown format %d\n", (int)format);
-      return 0;
-   }
-}
-
-static void nouveauCalcViewport(GLcontext *ctx)
-{
-    /* Calculate the Viewport Matrix */
-    
-    nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-    const GLfloat *v = ctx->Viewport._WindowMap.m;
-    GLfloat *m = nmesa->viewport.m;
-    GLfloat xoffset = nmesa->drawX, yoffset = nmesa->drawY + nmesa->drawH;
-  
-    nmesa->depth_scale = 1.0 / ctx->DrawBuffer->_DepthMaxF;
-
-    m[MAT_SX] =   v[MAT_SX];
-    m[MAT_TX] =   v[MAT_TX] + xoffset + SUBPIXEL_X;
-    m[MAT_SY] = - v[MAT_SY];
-    m[MAT_TY] = (-v[MAT_TY]) + yoffset + SUBPIXEL_Y;
-    m[MAT_SZ] =   v[MAT_SZ] * nmesa->depth_scale;
-    m[MAT_TZ] =   v[MAT_TZ] * nmesa->depth_scale;
-
-    nmesa->hw_func.WindowMoved(nmesa);
-}
-
-static void nouveauViewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
-{
-    /* 
-     * Need to send (at least on an nv35 the following:
-     * cons = 4 (this may be bytes per pixel)
-     *
-     * The viewport:
-     * 445   0x0000bee0   {size: 0x0   channel: 0x1   cmd: 0x00009ee0} <-- VIEWPORT_SETUP/HEADER ?
-     * 446   0x00000000   {size: 0x0   channel: 0x0   cmd: 0x00000000} <-- x * cons
-     * 447   0x00000c80   {size: 0x0   channel: 0x0   cmd: 0x00000c80} <-- (height + x) * cons
-     * 448   0x00000000   {size: 0x0   channel: 0x0   cmd: 0x00000000} <-- y * cons
-     * 449   0x00000960   {size: 0x0   channel: 0x0   cmd: 0x00000960} <-- (width + y) * cons
-     * 44a   0x00082a00   {size: 0x2   channel: 0x1   cmd: 0x00000a00} <-- VIEWPORT_DIMS
-     * 44b   0x04000000  <-- (Width_from_glViewport << 16) | x
-     * 44c   0x03000000  <-- (Height_from_glViewport << 16) | (win_height - height - y)
-     *
-     */
-    
-    nouveauCalcViewport(ctx);
-}
-
-static void nouveauDepthRange(GLcontext *ctx, GLclampd near, GLclampd far)
-{
-    nouveauCalcViewport(ctx);
-}
-
-static void nouveauDDUpdateHWState(GLcontext *ctx)
-{
-    nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-    int new_state = nmesa->new_state;
-
-    if ( new_state || nmesa->new_render_state & _NEW_TEXTURE )
-    {
-        nmesa->new_state = 0;
-
-        /* Update the various parts of the context's state.
-        */
-        /*
-        if ( new_state & NOUVEAU_NEW_ALPHA )
-            nouveauUpdateAlphaMode( ctx );
-
-        if ( new_state & NOUVEAU_NEW_DEPTH )
-            nouveauUpdateZMode( ctx );
-
-        if ( new_state & NOUVEAU_NEW_FOG )
-            nouveauUpdateFogAttrib( ctx );
-
-        if ( new_state & NOUVEAU_NEW_CLIP )
-            nouveauUpdateClipping( ctx );
-
-        if ( new_state & NOUVEAU_NEW_CULL )
-            nouveauUpdateCull( ctx );
-
-        if ( new_state & NOUVEAU_NEW_MASKS )
-            nouveauUpdateMasks( ctx );
-
-        if ( new_state & NOUVEAU_NEW_WINDOW )
-            nouveauUpdateWindow( ctx );
-
-        if ( nmesa->new_render_state & _NEW_TEXTURE ) {
-            nouveauUpdateTextureState( ctx );
-        }*/
-    }
-}
-
-static void nouveauDDInvalidateState(GLcontext *ctx, GLuint new_state)
-{
-    _swrast_InvalidateState( ctx, new_state );
-    _swsetup_InvalidateState( ctx, new_state );
-    _vbo_InvalidateState( ctx, new_state );
-    _tnl_InvalidateState( ctx, new_state );
-    NOUVEAU_CONTEXT(ctx)->new_render_state |= new_state;
-}
-
-/* Initialize the context's hardware state. */
-void nouveauDDInitState(nouveauContextPtr nmesa)
-{
-    uint32_t type = nmesa->screen->card->type;
-    switch(type)
-    {
-        case NV_03:
-            /* Unimplemented */
-            break;
-        case NV_04:
-        case NV_05:
-            nv04InitStateFuncs(nmesa->glCtx, &nmesa->glCtx->Driver);
-            break;
-        case NV_10:
-        case NV_11:
-        case NV_17:
-            nv10InitStateFuncs(nmesa->glCtx, &nmesa->glCtx->Driver);
-            break;
-        case NV_20:
-            nv20InitStateFuncs(nmesa->glCtx, &nmesa->glCtx->Driver);
-            break;
-        case NV_30:
-        case NV_40:
-        case NV_44:
-            nv30InitStateFuncs(nmesa->glCtx, &nmesa->glCtx->Driver);
-            break;
-        case NV_50:
-            nv50InitStateFuncs(nmesa->glCtx, &nmesa->glCtx->Driver);
-            break;
-        default:
-            break;
-    }
-    nouveau_state_cache_init(nmesa);
-}
-
-/* Initialize the driver's state functions */
-void nouveauDDInitStateFuncs(GLcontext *ctx)
-{
-   ctx->Driver.UpdateState             = nouveauDDInvalidateState;
-
-   ctx->Driver.ClearIndex              = NULL;
-   ctx->Driver.ClearColor              = NULL; //nouveauDDClearColor;
-   ctx->Driver.ClearStencil            = NULL; //nouveauDDClearStencil;
-   ctx->Driver.DrawBuffer              = NULL; //nouveauDDDrawBuffer;
-   ctx->Driver.ReadBuffer              = NULL; //nouveauDDReadBuffer;
-
-   ctx->Driver.IndexMask               = NULL;
-   ctx->Driver.ColorMask               = NULL; //nouveauDDColorMask;
-   ctx->Driver.AlphaFunc               = NULL; //nouveauDDAlphaFunc;
-   ctx->Driver.BlendEquationSeparate   = NULL; //nouveauDDBlendEquationSeparate;
-   ctx->Driver.BlendFuncSeparate       = NULL; //nouveauDDBlendFuncSeparate;
-   ctx->Driver.ClearDepth              = NULL; //nouveauDDClearDepth;
-   ctx->Driver.CullFace                        = NULL; //nouveauDDCullFace;
-   ctx->Driver.FrontFace               = NULL; //nouveauDDFrontFace;
-   ctx->Driver.DepthFunc               = NULL; //nouveauDDDepthFunc;
-   ctx->Driver.DepthMask               = NULL; //nouveauDDDepthMask;
-   ctx->Driver.Enable                  = NULL; //nouveauDDEnable;
-   ctx->Driver.Fogfv                   = NULL; //nouveauDDFogfv;
-   ctx->Driver.Hint                    = NULL;
-   ctx->Driver.Lightfv                 = NULL;
-   ctx->Driver.LightModelfv            = NULL; //nouveauDDLightModelfv;
-   ctx->Driver.LogicOpcode             = NULL; //nouveauDDLogicOpCode;
-   ctx->Driver.PolygonMode             = NULL;
-   ctx->Driver.PolygonStipple          = NULL; //nouveauDDPolygonStipple;
-   ctx->Driver.RenderMode              = NULL; //nouveauDDRenderMode;
-   ctx->Driver.Scissor                 = NULL; //nouveauDDScissor;
-   ctx->Driver.ShadeModel              = NULL; //nouveauDDShadeModel;
-   ctx->Driver.StencilFuncSeparate     = NULL; //nouveauDDStencilFuncSeparate;
-   ctx->Driver.StencilMaskSeparate     = NULL; //nouveauDDStencilMaskSeparate;
-   ctx->Driver.StencilOpSeparate       = NULL; //nouveauDDStencilOpSeparate;
-
-   ctx->Driver.DepthRange               = nouveauDepthRange;
-   ctx->Driver.Viewport                 = nouveauViewport;
-
-   /* 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;
-}
-
-#define STATE_INIT(a) if (ctx->Driver.a) ctx->Driver.a
-
-void nouveauInitState(GLcontext *ctx)
-{
-    /*
-     * Mesa should do this for us:
-     */
-
-    STATE_INIT(AlphaFunc)( ctx, 
-            ctx->Color.AlphaFunc,
-            ctx->Color.AlphaRef);
-
-    STATE_INIT(BlendColor)( ctx,
-            ctx->Color.BlendColor );
-
-    STATE_INIT(BlendEquationSeparate)( ctx, 
-            ctx->Color.BlendEquationRGB,
-            ctx->Color.BlendEquationA);
-
-    STATE_INIT(BlendFuncSeparate)( ctx,
-            ctx->Color.BlendSrcRGB,
-            ctx->Color.BlendDstRGB,
-            ctx->Color.BlendSrcA,
-            ctx->Color.BlendDstA);
-
-    STATE_INIT(ClearColor)( ctx, ctx->Color.ClearColor);
-    STATE_INIT(ClearDepth)( ctx, ctx->Depth.Clear);
-    STATE_INIT(ClearStencil)( ctx, ctx->Stencil.Clear);
-
-    STATE_INIT(ColorMask)( ctx, 
-            ctx->Color.ColorMask[RCOMP],
-            ctx->Color.ColorMask[GCOMP],
-            ctx->Color.ColorMask[BCOMP],
-            ctx->Color.ColorMask[ACOMP]);
-
-    STATE_INIT(CullFace)( ctx, ctx->Polygon.CullFaceMode );
-    STATE_INIT(DepthFunc)( ctx, ctx->Depth.Func );
-    STATE_INIT(DepthMask)( ctx, ctx->Depth.Mask );
-
-    STATE_INIT(Enable)( ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled );
-    STATE_INIT(Enable)( ctx, GL_BLEND, ctx->Color.BlendEnabled );
-    STATE_INIT(Enable)( ctx, GL_COLOR_LOGIC_OP, ctx->Color.ColorLogicOpEnabled );
-    STATE_INIT(Enable)( ctx, GL_COLOR_SUM, ctx->Fog.ColorSumEnabled );
-    STATE_INIT(Enable)( ctx, GL_CULL_FACE, ctx->Polygon.CullFlag );
-    STATE_INIT(Enable)( ctx, GL_DEPTH_TEST, ctx->Depth.Test );
-    STATE_INIT(Enable)( ctx, GL_DITHER, ctx->Color.DitherFlag );
-    STATE_INIT(Enable)( ctx, GL_FOG, ctx->Fog.Enabled );
-    STATE_INIT(Enable)( ctx, GL_LIGHTING, ctx->Light.Enabled );
-    STATE_INIT(Enable)( ctx, GL_LINE_SMOOTH, ctx->Line.SmoothFlag );
-    STATE_INIT(Enable)( ctx, GL_LINE_STIPPLE, ctx->Line.StippleFlag );
-    STATE_INIT(Enable)( ctx, GL_POINT_SMOOTH, ctx->Point.SmoothFlag );
-    STATE_INIT(Enable)( ctx, GL_POLYGON_OFFSET_FILL, ctx->Polygon.OffsetFill);
-    STATE_INIT(Enable)( ctx, GL_POLYGON_OFFSET_LINE, ctx->Polygon.OffsetLine);
-    STATE_INIT(Enable)( ctx, GL_POLYGON_OFFSET_POINT, ctx->Polygon.OffsetPoint);
-    STATE_INIT(Enable)( ctx, GL_POLYGON_SMOOTH, ctx->Polygon.SmoothFlag );
-    STATE_INIT(Enable)( ctx, GL_POLYGON_STIPPLE, ctx->Polygon.StippleFlag );
-    STATE_INIT(Enable)( ctx, GL_SCISSOR_TEST, ctx->Scissor.Enabled );
-    STATE_INIT(Enable)( ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled );
-    STATE_INIT(Enable)( ctx, GL_TEXTURE_1D, GL_FALSE );
-    STATE_INIT(Enable)( ctx, GL_TEXTURE_2D, GL_FALSE );
-    STATE_INIT(Enable)( ctx, GL_TEXTURE_RECTANGLE_NV, GL_FALSE );
-    STATE_INIT(Enable)( ctx, GL_TEXTURE_3D, GL_FALSE );
-    STATE_INIT(Enable)( ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE );
-
-    STATE_INIT(Fogfv)( ctx, GL_FOG_COLOR, ctx->Fog.Color );
-    STATE_INIT(Fogfv)( ctx, GL_FOG_MODE, 0 );
-    STATE_INIT(Fogfv)( ctx, GL_FOG_DENSITY, &ctx->Fog.Density );
-    STATE_INIT(Fogfv)( ctx, GL_FOG_START, &ctx->Fog.Start );
-    STATE_INIT(Fogfv)( ctx, GL_FOG_END, &ctx->Fog.End );
-
-    STATE_INIT(FrontFace)( ctx, ctx->Polygon.FrontFace );
-
-    {
-        GLfloat f = (GLfloat)ctx->Light.Model.ColorControl;
-        STATE_INIT(LightModelfv)( ctx, GL_LIGHT_MODEL_COLOR_CONTROL, &f );
-    }
-
-    STATE_INIT(LineStipple)( ctx, ctx->Line.StippleFactor, ctx->Line.StipplePattern );
-    STATE_INIT(LineWidth)( ctx, ctx->Line.Width );
-    STATE_INIT(LogicOpcode)( ctx, ctx->Color.LogicOp );
-    STATE_INIT(PointSize)( ctx, ctx->Point.Size );
-    STATE_INIT(PolygonMode)( ctx, GL_FRONT, ctx->Polygon.FrontMode );
-    STATE_INIT(PolygonMode)( ctx, GL_BACK, ctx->Polygon.BackMode );
-    STATE_INIT(PolygonOffset)( ctx,
-           ctx->Polygon.OffsetFactor,
-           ctx->Polygon.OffsetUnits );
-    STATE_INIT(PolygonStipple)( ctx, (const GLubyte *)ctx->PolygonStipple );
-    STATE_INIT(ShadeModel)( ctx, ctx->Light.ShadeModel );
-    STATE_INIT(StencilFuncSeparate)( ctx, GL_FRONT,
-            ctx->Stencil.Function[0],
-            ctx->Stencil.Ref[0],
-            ctx->Stencil.ValueMask[0] );
-    STATE_INIT(StencilFuncSeparate)( ctx, GL_BACK,
-            ctx->Stencil.Function[1],
-            ctx->Stencil.Ref[1],
-            ctx->Stencil.ValueMask[1] );
-    STATE_INIT(StencilMaskSeparate)( ctx, GL_FRONT, ctx->Stencil.WriteMask[0] );
-    STATE_INIT(StencilMaskSeparate)( ctx, GL_BACK, ctx->Stencil.WriteMask[1] );
-    STATE_INIT(StencilOpSeparate)( ctx, GL_FRONT,
-            ctx->Stencil.FailFunc[0],
-            ctx->Stencil.ZFailFunc[0],
-            ctx->Stencil.ZPassFunc[0]);
-    STATE_INIT(StencilOpSeparate)( ctx, GL_BACK,
-            ctx->Stencil.FailFunc[1],
-            ctx->Stencil.ZFailFunc[1],
-            ctx->Stencil.ZPassFunc[1]);
-}
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.h b/src/mesa/drivers/dri/nouveau/nouveau_state.h
deleted file mode 100644 (file)
index dbac717..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/**************************************************************************
-
-Copyright 2006 Jeremy Kolb
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-#ifndef __NOUVEAU_STATE_H__
-#define __NOUVEAU_STATE_H__
-
-#include "nouveau_context.h"
-
-extern void nouveauDDInitState(nouveauContextPtr nmesa);
-extern void nouveauDDInitStateFuncs(GLcontext *ctx);
-
-extern void nv04InitStateFuncs(GLcontext *ctx, struct dd_function_table *func);
-extern void nv10InitStateFuncs(GLcontext *ctx, struct dd_function_table *func);
-extern void nv20InitStateFuncs(GLcontext *ctx, struct dd_function_table *func);
-extern void nv30InitStateFuncs(GLcontext *ctx, struct dd_function_table *func);
-extern void nv50InitStateFuncs(GLcontext *ctx, struct dd_function_table *func);
-
-extern void nouveauInitState(GLcontext *ctx);
-
-/*
-extern void nouveauDDUpdateState(GLcontext *ctx);
-extern void nouveauDDUpdateHWState(GLcontext *ctx);
-
-extern void nouveauEmitHwStateLocked(nouveauContextPtr nmesa);
-*/
-#endif
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state_cache.c b/src/mesa/drivers/dri/nouveau/nouveau_state_cache.c
deleted file mode 100644 (file)
index cb4b9d3..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-
-#include "nouveau_state_cache.h"
-#include "nouveau_context.h"
-#include "nouveau_object.h"
-#include "nouveau_fifo.h"
-
-#define BEGIN_RING_NOFLUSH(subchannel,tag,size) do {                                   \
-       if (nmesa->fifo.free <= (size))                                                 \
-               WAIT_RING(nmesa,(size));                                                \
-       OUT_RING( ((size)<<18) | ((subchannel) << 13) | (tag));                         \
-       nmesa->fifo.free -= ((size) + 1);                                               \
-}while(0)
-
-// flush all the dirty state
-void nouveau_state_cache_flush(nouveauContextPtr nmesa)
-{
-       int i=0;
-       int run=0;
-
-       // fast-path no state changes
-       if (!nmesa->state_cache.dirty)
-               return;
-       nmesa->state_cache.dirty=0;
-
-       do
-       {
-               // jump to a dirty state
-               while((nmesa->state_cache.hdirty[i/NOUVEAU_STATE_CACHE_HIER_SIZE]==0)&&(i<NOUVEAU_STATE_CACHE_ENTRIES))
-                       i=(i&~(NOUVEAU_STATE_CACHE_HIER_SIZE-1))+NOUVEAU_STATE_CACHE_HIER_SIZE;
-               while((nmesa->state_cache.atoms[i].dirty==0)&&(i<NOUVEAU_STATE_CACHE_ENTRIES))
-                       i++;
-
-               // figure out a run of dirty values
-               run=0;
-               while((nmesa->state_cache.atoms[i+run].dirty)&&(i+run<NOUVEAU_STATE_CACHE_ENTRIES))
-                       run++;
-
-               // output everything as a single run
-               if (run>0) {
-                       int j;
-
-                       BEGIN_RING_NOFLUSH(NvSub3D, i*4, run);
-                       for(j=0;j<run;j++)
-                       {
-                               OUT_RING(nmesa->state_cache.atoms[i+j].value);
-                               nmesa->state_cache.atoms[i+j].dirty=0;
-                               if ((i+j)%NOUVEAU_STATE_CACHE_HIER_SIZE==0)
-                                       nmesa->state_cache.hdirty[(i+j)/NOUVEAU_STATE_CACHE_HIER_SIZE-1]=0;
-                       }
-                       i+=run;
-               }
-       }
-       while(i<NOUVEAU_STATE_CACHE_ENTRIES);
-       nmesa->state_cache.hdirty[NOUVEAU_STATE_CACHE_HIER_SIZE/NOUVEAU_STATE_CACHE_HIER_SIZE-1]=0;
-}
-
-
-// inits the state cache
-void nouveau_state_cache_init(nouveauContextPtr nmesa)
-{
-       int i;
-       for(i=0;i<NOUVEAU_STATE_CACHE_ENTRIES;i++)
-       {
-               nmesa->state_cache.atoms[i].dirty=0;
-               nmesa->state_cache.atoms[i].value=0xDEADBEEF; // nvidia cards like beef
-       }
-       nmesa->state_cache.dirty=0;
-}
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state_cache.h b/src/mesa/drivers/dri/nouveau/nouveau_state_cache.h
deleted file mode 100644 (file)
index 5f9d426..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-
-#ifndef __NOUVEAU_STATE_CACHE_H__
-#define __NOUVEAU_STATE_CACHE_H__
-
-#include "mtypes.h"
-
-#define NOUVEAU_STATE_CACHE_ENTRIES 2048
-// size of a dirty requests block
-// you can play with that and tune the value to increase/decrease performance
-// but keep it a power of 2 !
-#define NOUVEAU_STATE_CACHE_HIER_SIZE  32
-
-typedef struct nouveau_state_atom_t{
-       uint32_t value;
-       uint32_t dirty;
-}nouveau_state_atom;
-
-typedef struct nouveau_state_cache_t{
-       nouveau_state_atom atoms[NOUVEAU_STATE_CACHE_ENTRIES];
-       uint32_t current_pos;
-       // hierarchical dirty flags
-       uint8_t hdirty[NOUVEAU_STATE_CACHE_ENTRIES/NOUVEAU_STATE_CACHE_HIER_SIZE];
-       // master dirty flag
-       uint8_t dirty;
-}nouveau_state_cache;
-
-
-#endif
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_swtcl.c b/src/mesa/drivers/dri/nouveau/nouveau_swtcl.c
deleted file mode 100644 (file)
index 8a013bd..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/**************************************************************************
-
-Copyright 2006 Stephane Marchesin
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-/* Common software TCL code */
-
-#include "nouveau_context.h"
-#include "nouveau_swtcl.h"
-#include "nv10_swtcl.h"
-#include "nouveau_span.h"
-#include "swrast/swrast.h"
-#include "swrast_setup/swrast_setup.h"
-#include "tnl/tnl.h"
-#include "tnl/t_pipeline.h"
-
-/* Common tri functions */
-
-/* The fallbacks */
-void nouveau_fallback_tri(struct nouveau_context *nmesa,
-               nouveauVertex *v0,
-               nouveauVertex *v1,
-               nouveauVertex *v2)
-{    
-       GLcontext *ctx = nmesa->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]);
-}
-
-
-void nouveau_fallback_line(struct nouveau_context *nmesa,
-               nouveauVertex *v0,
-               nouveauVertex *v1)
-{
-       GLcontext *ctx = nmesa->glCtx;
-       SWvertex v[2];
-       _swsetup_Translate(ctx, v0, &v[0]);
-       _swsetup_Translate(ctx, v1, &v[1]);
-       _swrast_Line(ctx, &v[0], &v[1]);
-}
-
-
-void nouveau_fallback_point(struct nouveau_context *nmesa,
-               nouveauVertex *v0)
-{
-       GLcontext *ctx = nmesa->glCtx;
-       SWvertex v[1];
-       _swsetup_Translate(ctx, v0, &v[0]);
-       _swrast_Point(ctx, &v[0]);
-}
-
-void nouveauFallback(struct nouveau_context *nmesa, GLuint bit, GLboolean mode)
-{
-       GLcontext *ctx = nmesa->glCtx;
-       GLuint oldfallback = nmesa->Fallback;
-
-       if (mode) {
-               nmesa->Fallback |= bit;
-               if (oldfallback == 0) {
-                       if (nmesa->screen->card->type<NV_10) {
-                               //nv04FinishPrimitive(nmesa);
-                       } else {
-                               //nv10FinishPrimitive(nmesa);
-                       }
-
-                       _swsetup_Wakeup(ctx);
-                       nmesa->render_index = ~0;
-               }
-       }
-       else {
-               nmesa->Fallback &= ~bit;
-               if (oldfallback == bit) {
-                       _swrast_flush( ctx );
-
-                       if (nmesa->screen->card->type<NV_10) {
-                               nv04TriInitFunctions(ctx);
-                       } else {
-                               nv10TriInitFunctions(ctx);
-                       }
-
-                       _tnl_invalidate_vertex_state( ctx, ~0 );
-                       _tnl_invalidate_vertices( ctx, ~0 );
-                       _tnl_install_attrs( ctx, 
-                                       nmesa->vertex_attrs, 
-                                       nmesa->vertex_attr_count,
-                                       nmesa->viewport.m, 0 ); 
-               }
-       }    
-}
-
-
-void nouveauRunPipeline( GLcontext *ctx )
-{
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-
-       if (nmesa->new_state) {
-               nmesa->new_render_state |= nmesa->new_state;
-       }
-
-       _tnl_run_pipeline( ctx );
-}
-
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_swtcl.h b/src/mesa/drivers/dri/nouveau/nouveau_swtcl.h
deleted file mode 100644 (file)
index ba4d872..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/**************************************************************************
-
-Copyright 2006 Stephane Marchesin
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-
-
-#ifndef __NOUVEAU_SWTCL_H__
-#define __NOUVEAU_SWTCL_H__
-
-#include "nouveau_context.h"
-
-extern void nouveau_fallback_tri(struct nouveau_context *nmesa,
-               nouveauVertex *v0,
-               nouveauVertex *v1,
-               nouveauVertex *v2);
-
-extern void nouveau_fallback_line(struct nouveau_context *nmesa,
-               nouveauVertex *v0,
-               nouveauVertex *v1);
-
-extern void nouveau_fallback_point(struct nouveau_context *nmesa, 
-               nouveauVertex *v0);
-
-extern void nouveauFallback(struct nouveau_context *nmesa, GLuint bit, GLboolean mode);
-
-extern void nouveauRunPipeline( GLcontext *ctx );
-
-extern void nouveauTriInitFunctions( GLcontext *ctx );
-
-
-#endif /* __NOUVEAU_SWTCL_H__ */
-
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_sync.c b/src/mesa/drivers/dri/nouveau/nouveau_sync.c
deleted file mode 100644 (file)
index 8abc847..0000000
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright (C) 2007 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.
- *
- */
-
-#include "vblank.h" /* for DO_USLEEP */
-
-#include "nouveau_context.h"
-#include "nouveau_buffers.h"
-#include "nouveau_object.h"
-#include "nouveau_fifo.h"
-#include "nouveau_reg.h"
-#include "nouveau_msg.h"
-#include "nouveau_sync.h"
-
-#define NOTIFIER(__v) \
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); \
-       volatile uint32_t *__v = (void*)nmesa->notifier_block + notifier->offset
-
-struct drm_nouveau_notifier_alloc *
-nouveau_notifier_new(GLcontext *ctx, GLuint handle, GLuint count)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       struct drm_nouveau_notifier_alloc *notifier;
-       int ret;
-
-#ifdef NOUVEAU_RING_DEBUG
-       return NULL;
-#endif
-
-       notifier = CALLOC_STRUCT(drm_nouveau_notifier_alloc);
-       if (!notifier)
-               return NULL;
-
-       notifier->channel = nmesa->fifo.channel;
-       notifier->handle  = handle;
-       notifier->count   = count;
-       ret = drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_NOTIFIER_ALLOC,
-                                 notifier, sizeof(*notifier));
-       if (ret) {
-               MESSAGE("Failed to create notifier 0x%08x: %d\n", handle, ret);
-               FREE(notifier);
-               return NULL;
-       }
-
-       return notifier;
-}
-
-void
-nouveau_notifier_destroy(GLcontext *ctx,
-                        struct drm_nouveau_notifier_alloc *notifier)
-{
-       /*XXX: free notifier object.. */
-       FREE(notifier);
-}
-
-void
-nouveau_notifier_reset(GLcontext *ctx,
-                      struct drm_nouveau_notifier_alloc *notifier,
-                      GLuint id)
-{
-       NOTIFIER(n);
-
-#ifdef NOUVEAU_RING_DEBUG
-       return;
-#endif
-
-       n[NV_NOTIFY_TIME_0      /4] = 0x00000000;
-       n[NV_NOTIFY_TIME_1      /4] = 0x00000000;
-       n[NV_NOTIFY_RETURN_VALUE/4] = 0x00000000;
-       n[NV_NOTIFY_STATE       /4] = (NV_NOTIFY_STATE_STATUS_IN_PROCESS <<
-                                      NV_NOTIFY_STATE_STATUS_SHIFT);
-}
-
-GLuint
-nouveau_notifier_status(GLcontext *ctx,
-                       struct drm_nouveau_notifier_alloc *notifier,
-                       GLuint id)
-{
-       NOTIFIER(n);
-
-       return n[NV_NOTIFY_STATE/4] >> NV_NOTIFY_STATE_STATUS_SHIFT;
-}
-
-GLuint
-nouveau_notifier_return_val(GLcontext *ctx,
-                           struct drm_nouveau_notifier_alloc *notifier,
-                           GLuint id)
-{
-       NOTIFIER(n);
-
-       return n[NV_NOTIFY_RETURN_VALUE/4];
-}
-
-GLboolean
-nouveau_notifier_wait_status(GLcontext *ctx,
-                            struct drm_nouveau_notifier_alloc *notifier,
-                            GLuint id, GLuint status, GLuint timeout)
-{
-       NOTIFIER(n);
-       unsigned int time = 0;
-
-#ifdef NOUVEAU_RING_DEBUG
-       return GL_TRUE;
-#endif
-
-       while (time <= timeout) {
-               if (n[NV_NOTIFY_STATE/4] & NV_NOTIFY_STATE_ERROR_CODE_MASK) {
-                       MESSAGE("Notifier returned error: 0x%04x\n",
-                                       n[NV_NOTIFY_STATE/4] &
-                                       NV_NOTIFY_STATE_ERROR_CODE_MASK);
-                       return GL_FALSE;
-               }
-
-               if (((n[NV_NOTIFY_STATE/4] & NV_NOTIFY_STATE_STATUS_MASK) >>
-                               NV_NOTIFY_STATE_STATUS_SHIFT) == status)
-                       return GL_TRUE;
-
-               if (timeout) {
-                       DO_USLEEP(1);
-                       time++;
-               }
-       }
-
-       MESSAGE("Notifier timed out\n");
-       return GL_FALSE;
-}
-
-void
-nouveau_notifier_wait_nop(GLcontext *ctx,
-                         struct drm_nouveau_notifier_alloc *notifier,
-                         GLuint subc)
-{
-       NOTIFIER(n);
-       GLboolean ret;
-
-       nouveau_notifier_reset(ctx, notifier, 0);
-
-       BEGIN_RING_SIZE(subc, NV_NOTIFY, 1);
-       OUT_RING       (NV_NOTIFY_STYLE_WRITE_ONLY);
-       BEGIN_RING_SIZE(subc, NV_NOP, 1);
-       OUT_RING       (0);
-       FIRE_RING();
-
-       ret = nouveau_notifier_wait_status(ctx, notifier, 0,
-                                          NV_NOTIFY_STATE_STATUS_COMPLETED,
-                                          0 /* no timeout */);
-       if (ret == GL_FALSE) MESSAGE("wait on notifier failed\n");
-}
-
-GLboolean nouveauSyncInitFuncs(GLcontext *ctx)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-#ifdef NOUVEAU_RING_DEBUG
-       return GL_TRUE;
-#endif
-
-       nmesa->syncNotifier = nouveau_notifier_new(ctx, NvSyncNotify, 1);
-       if (!nmesa->syncNotifier) {
-               MESSAGE("Failed to create channel sync notifier\n");
-               return GL_FALSE;
-       }
-
-       /* 0x180 is SET_DMA_NOTIFY, should be correct for all supported 3D
-        * object classes
-        */
-       BEGIN_RING_CACHE(NvSub3D, 0x180, 1);
-       OUT_RING_CACHE  (NvSyncNotify);
-#ifdef ALLOW_MULTI_SUBCHANNEL
-       BEGIN_RING_SIZE(NvSubMemFormat,
-                       NV_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 1);
-       OUT_RING       (NvSyncNotify);
-#endif
-
-       return GL_TRUE;
-}
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_sync.h b/src/mesa/drivers/dri/nouveau/nouveau_sync.h
deleted file mode 100644 (file)
index b76af17..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2007 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.
- *
- */
-
-#ifndef __NOUVEAU_SYNC_H__
-#define __NOUVEAU_SYNC_H__
-
-#include "nouveau_buffers.h"
-
-#define NV_NOTIFIER_SIZE                                                      32
-#define NV_NOTIFY_TIME_0                                              0x00000000
-#define NV_NOTIFY_TIME_1                                              0x00000004
-#define NV_NOTIFY_RETURN_VALUE                                        0x00000008
-#define NV_NOTIFY_STATE                                               0x0000000C
-#define NV_NOTIFY_STATE_STATUS_MASK                                   0xFF000000
-#define NV_NOTIFY_STATE_STATUS_SHIFT                                          24
-#define NV_NOTIFY_STATE_STATUS_COMPLETED                                    0x00
-#define NV_NOTIFY_STATE_STATUS_IN_PROCESS                                   0x01
-#define NV_NOTIFY_STATE_ERROR_CODE_MASK                               0x0000FFFF
-#define NV_NOTIFY_STATE_ERROR_CODE_SHIFT                                       0
-
-/* Methods that (hopefully) all objects have */
-#define NV_NOP                                                        0x00000100
-#define NV_NOTIFY                                                     0x00000104
-#define NV_NOTIFY_STYLE_WRITE_ONLY                                             0
-
-extern struct drm_nouveau_notifier_alloc *
-nouveau_notifier_new(GLcontext *, GLuint handle, GLuint count);
-extern void 
-nouveau_notifier_destroy(GLcontext *, struct drm_nouveau_notifier_alloc *);
-extern void
-nouveau_notifier_reset(GLcontext *, struct drm_nouveau_notifier_alloc *,
-                      GLuint id);
-extern GLuint
-nouveau_notifier_status(GLcontext *, struct drm_nouveau_notifier_alloc *,
-                       GLuint id);
-extern GLuint
-nouveau_notifier_return_val(GLcontext *, struct drm_nouveau_notifier_alloc *,
-                           GLuint id);
-extern GLboolean
-nouveau_notifier_wait_status(GLcontext *, struct drm_nouveau_notifier_alloc *,
-                            GLuint id, GLuint status, GLuint timeout);
-extern void
-nouveau_notifier_wait_nop(GLcontext *ctx, struct drm_nouveau_notifier_alloc *,
-                         GLuint subc);
-
-extern GLboolean nouveauSyncInitFuncs(GLcontext *ctx);
-#endif
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_tex.c b/src/mesa/drivers/dri/nouveau/nouveau_tex.c
deleted file mode 100644 (file)
index 0a8d279..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/**************************************************************************
-
-Copyright 2006 Stephane Marchesin
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-
-#include "nouveau_tex.h"
-
-// XXX needs some love
-void nouveauTexInitFunctions( struct dd_function_table *functions )
-{
-/*
-   functions->TexEnv                   = nouveauTexEnv;
-   functions->ChooseTextureFormat      = nouveauChooseTextureFormat;
-   functions->TexImage1D               = nouveauTexImage1D;
-   functions->TexSubImage1D            = nouveauTexSubImage1D;
-   functions->TexImage2D               = nouveauTexImage2D;
-   functions->TexSubImage2D            = nouveauTexSubImage2D;
-   functions->TexParameter             = nouveauTexParameter;
-   functions->BindTexture              = nouveauBindTexture;
-   functions->NewTextureObject         = nouveauNewTextureObject;
-   functions->DeleteTexture            = nouveauDeleteTexture;
-   functions->IsTextureResident                = driIsTextureResident;
-
-   driInitTextureFormats();
-*/
-}
-
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_tex.h b/src/mesa/drivers/dri/nouveau/nouveau_tex.h
deleted file mode 100644 (file)
index 7ac71f8..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/**************************************************************************
-
-Copyright 2006 Stephane Marchesin
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-
-#ifndef __NOUVEAU_TEX_H__
-#define __NOUVEAU_TEX_H__
-
-#include <errno.h>
-#include "mtypes.h"
-#include "macros.h"
-#include "dd.h"
-
-extern void nouveauTexInitFunctions( struct dd_function_table *functions );
-
-#endif /* __NOUVEAU_TEX_H__ */
diff --git a/src/mesa/drivers/dri/nouveau/nv04_state.c b/src/mesa/drivers/dri/nouveau/nv04_state.c
deleted file mode 100644 (file)
index 25df3d2..0000000
+++ /dev/null
@@ -1,540 +0,0 @@
-/**************************************************************************
-
-Copyright 2007 Stephane Marchesin
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-#include "nouveau_context.h"
-#include "nouveau_object.h"
-#include "nouveau_fifo.h"
-#include "nouveau_reg.h"
-#include "nouveau_msg.h"
-
-#include "tnl/t_pipeline.h"
-
-#include "mtypes.h"
-#include "colormac.h"
-
-static uint32_t nv04_compare_func(GLuint f)
-{
-       switch ( f ) {
-               case GL_NEVER:          return 1;
-               case GL_LESS:           return 2;
-               case GL_EQUAL:          return 3;
-               case GL_LEQUAL:         return 4;
-               case GL_GREATER:        return 5;
-               case GL_NOTEQUAL:       return 6;
-               case GL_GEQUAL:         return 7;
-               case GL_ALWAYS:         return 8;
-       }
-       WARN_ONCE("Unable to find the function\n");
-       return 0;
-}
-
-static uint32_t nv04_blend_func(GLuint f)
-{
-       switch ( f ) {
-               case GL_ZERO:                   return 0x1;
-               case GL_ONE:                    return 0x2;
-               case GL_SRC_COLOR:              return 0x3;
-               case GL_ONE_MINUS_SRC_COLOR:    return 0x4;
-               case GL_SRC_ALPHA:              return 0x5;
-               case GL_ONE_MINUS_SRC_ALPHA:    return 0x6;
-               case GL_DST_ALPHA:              return 0x7;
-               case GL_ONE_MINUS_DST_ALPHA:    return 0x8;
-               case GL_DST_COLOR:              return 0x9;
-               case GL_ONE_MINUS_DST_COLOR:    return 0xA;
-               case GL_SRC_ALPHA_SATURATE:     return 0xB;
-       }
-       WARN_ONCE("Unable to find the function 0x%x\n",f);
-       return 0;
-}
-
-static void nv04_emit_control(GLcontext *ctx)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       uint32_t control,cull;
-       GLubyte alpha_ref;
-
-       CLAMPED_FLOAT_TO_UBYTE(alpha_ref, ctx->Color.AlphaRef);
-       control=alpha_ref;
-       control|=(nv04_compare_func(ctx->Color.AlphaFunc)<<8);
-       control|=(ctx->Color.AlphaEnabled<<12);
-       control|=(1<<13);
-       control|=(ctx->Depth.Test<<14);
-       control|=(nv04_compare_func(ctx->Depth.Func)<<16);
-       if ((ctx->Polygon.CullFlag)&&(ctx->Polygon.CullFaceMode!=GL_FRONT_AND_BACK))
-       {
-               if ((ctx->Polygon.FrontFace==GL_CW)&&(ctx->Polygon.CullFaceMode==GL_FRONT))
-                       cull=2;
-               if ((ctx->Polygon.FrontFace==GL_CW)&&(ctx->Polygon.CullFaceMode==GL_BACK))
-                       cull=3;
-               if ((ctx->Polygon.FrontFace==GL_CCW)&&(ctx->Polygon.CullFaceMode==GL_FRONT))
-                       cull=3;
-               if ((ctx->Polygon.FrontFace==GL_CCW)&&(ctx->Polygon.CullFaceMode==GL_BACK))
-                       cull=2;
-       }
-       else
-               if (ctx->Polygon.CullFaceMode==GL_FRONT_AND_BACK)
-                       cull=0;
-               else
-                       cull=1;
-       control|=(cull<<20);
-       control|=(ctx->Color.DitherFlag<<22);
-       if ((ctx->Depth.Test)&&(ctx->Depth.Mask))
-               control|=(1<<24);
-
-       control|=(1<<30); // integer zbuffer format
-
-       BEGIN_RING_CACHE(NvSub3D, NV04_DX5_TEXTURED_TRIANGLE_CONTROL, 1);
-       OUT_RING_CACHE(control);
-}
-
-static void nv04_emit_blend(GLcontext *ctx)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       uint32_t blend;
-
-       blend=0x4; // texture MODULATE_ALPHA
-       blend|=0x20; // alpha is MSB
-       switch(ctx->Light.ShadeModel) {
-               case GL_SMOOTH:blend|=(1<<6);break;
-               case GL_FLAT:  blend|=(2<<6);break;
-               default:break;
-       }
-       if (ctx->Hint.PerspectiveCorrection!=GL_FASTEST)
-               blend|=(1<<8);
-       blend|=(ctx->Fog.Enabled<<16);
-       blend|=(ctx->Color.BlendEnabled<<20);
-       blend|=(nv04_blend_func(ctx->Color.BlendSrcRGB)<<24);
-       blend|=(nv04_blend_func(ctx->Color.BlendDstRGB)<<28);
-
-       BEGIN_RING_CACHE(NvSub3D, NV04_DX5_TEXTURED_TRIANGLE_BLEND, 1);
-       OUT_RING_CACHE(blend);
-}
-
-static void nv04_emit_fog_color(GLcontext *ctx)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte c[4];
-       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] );
-       BEGIN_RING_CACHE(NvSub3D, NV04_DX5_TEXTURED_TRIANGLE_FOG_COLOR, 1);
-       OUT_RING_CACHE(PACK_COLOR_8888_REV(c[0],c[1],c[2],c[3]));
-}
-
-static void nv04AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref)
-{
-       nv04_emit_control(ctx);
-}
-
-static void nv04BlendColor(GLcontext *ctx, const GLfloat color[4])
-{
-       nv04_emit_blend(ctx);
-}
-
-static void nv04BlendEquationSeparate(GLcontext *ctx, GLenum modeRGB, GLenum modeA)
-{
-       nv04_emit_blend(ctx);
-}
-
-
-static void nv04BlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB, GLenum dfactorRGB,
-               GLenum sfactorA, GLenum dfactorA)
-{
-       nv04_emit_blend(ctx);
-}
-
-static void nv04Clear(GLcontext *ctx, GLbitfield mask)
-{
-       /* TODO */
-}
-
-static void nv04ClearColor(GLcontext *ctx, const GLfloat color[4])
-{
-       /* TODO */
-}
-
-static void nv04ClearDepth(GLcontext *ctx, GLclampd d)
-{
-       /* TODO */
-}
-
-static void nv04ClearStencil(GLcontext *ctx, GLint s)
-{
-       /* TODO */
-}
-
-static void nv04ClipPlane(GLcontext *ctx, GLenum plane, const GLfloat *equation)
-{
-       /* TODO */
-}
-
-static void nv04ColorMask(GLcontext *ctx, GLboolean rmask, GLboolean gmask,
-               GLboolean bmask, GLboolean amask )
-{
-       /* TODO */
-}
-
-static void nv04ColorMaterial(GLcontext *ctx, GLenum face, GLenum mode)
-{
-       /* TODO I need love */
-}
-
-static void nv04CullFace(GLcontext *ctx, GLenum mode)
-{
-       nv04_emit_control(ctx);
-}
-
-static void nv04FrontFace(GLcontext *ctx, GLenum mode)
-{
-       /* TODO */
-}
-
-static void nv04DepthFunc(GLcontext *ctx, GLenum func)
-{
-       nv04_emit_control(ctx);
-}
-
-static void nv04DepthMask(GLcontext *ctx, GLboolean flag)
-{
-       /* TODO */
-}
-
-static void nv04DepthRange(GLcontext *ctx, GLclampd nearval, GLclampd farval)
-{
-       /* TODO */
-}
-
-/** 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 );
-
-static void nv04Enable(GLcontext *ctx, GLenum cap, GLboolean state)
-{
-       switch(cap)
-       {
-               case GL_ALPHA_TEST:
-                       nv04_emit_control(ctx);
-                       break;
-//             case GL_AUTO_NORMAL:
-               case GL_BLEND:
-                       nv04_emit_blend(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:
-//             case GL_COLOR_LOGIC_OP:
-//             case GL_COLOR_MATERIAL:
-//             case GL_COLOR_SUM_EXT:
-//             case GL_COLOR_TABLE:
-//             case GL_CONVOLUTION_1D:
-//             case GL_CONVOLUTION_2D:
-               case GL_CULL_FACE:
-                       nv04_emit_control(ctx);
-                       break;
-               case GL_DEPTH_TEST:
-                       nv04_emit_control(ctx);
-                       break;
-               case GL_DITHER:
-                       nv04_emit_control(ctx);
-                       break;
-               case GL_FOG:
-                       nv04_emit_blend(ctx);
-                       nv04_emit_fog_color(ctx);
-                       break;
-//             case GL_HISTOGRAM:
-//             case GL_INDEX_LOGIC_OP:
-//             case GL_LIGHT0:
-//             case GL_LIGHT1:
-//             case GL_LIGHT2:
-//             case GL_LIGHT3:
-//             case GL_LIGHT4:
-//             case GL_LIGHT5:
-//             case GL_LIGHT6:
-//             case GL_LIGHT7:
-//             case GL_LIGHTING:
-//             case GL_LINE_SMOOTH:
-//             case GL_LINE_STIPPLE:
-//             case GL_MAP1_COLOR_4:
-//             case GL_MAP1_INDEX:
-//             case GL_MAP1_NORMAL:
-//             case GL_MAP1_TEXTURE_COORD_1:
-//             case GL_MAP1_TEXTURE_COORD_2:
-//             case GL_MAP1_TEXTURE_COORD_3:
-//             case GL_MAP1_TEXTURE_COORD_4:
-//             case GL_MAP1_VERTEX_3:
-//             case GL_MAP1_VERTEX_4:
-//             case GL_MAP2_COLOR_4:
-//             case GL_MAP2_INDEX:
-//             case GL_MAP2_NORMAL:
-//             case GL_MAP2_TEXTURE_COORD_1:
-//             case GL_MAP2_TEXTURE_COORD_2:
-//             case GL_MAP2_TEXTURE_COORD_3:
-//             case GL_MAP2_TEXTURE_COORD_4:
-//             case GL_MAP2_VERTEX_3:
-//             case GL_MAP2_VERTEX_4:
-//             case GL_MINMAX:
-//             case GL_NORMALIZE:
-//             case GL_POINT_SMOOTH:
-//             case GL_POLYGON_OFFSET_POINT:
-//             case GL_POLYGON_OFFSET_LINE:
-//             case GL_POLYGON_OFFSET_FILL:
-//             case GL_POLYGON_SMOOTH:
-//             case GL_POLYGON_STIPPLE:
-//             case GL_POST_COLOR_MATRIX_COLOR_TABLE:
-//             case GL_POST_CONVOLUTION_COLOR_TABLE:
-//             case GL_RESCALE_NORMAL:
-//             case GL_SCISSOR_TEST:
-//             case GL_SEPARABLE_2D:
-//             case GL_STENCIL_TEST:
-//             case GL_TEXTURE_GEN_Q:
-//             case GL_TEXTURE_GEN_R:
-//             case GL_TEXTURE_GEN_S:
-//             case GL_TEXTURE_GEN_T:
-//             case GL_TEXTURE_1D:
-//             case GL_TEXTURE_2D:
-//             case GL_TEXTURE_3D:
-       }
-}
-
-static void nv04Fogfv(GLcontext *ctx, GLenum pname, const GLfloat *params)
-{
-       nv04_emit_blend(ctx);
-       nv04_emit_fog_color(ctx);
-}
-   
-static void nv04Hint(GLcontext *ctx, GLenum target, GLenum mode)
-{
-       switch(target)
-       {
-               case GL_PERSPECTIVE_CORRECTION_HINT:nv04_emit_blend(ctx);break;
-               default:break;
-       }
-}
-
-static void nv04LineStipple(GLcontext *ctx, GLint factor, GLushort pattern )
-{
-       /* TODO not even in your dreams */
-}
-
-static void nv04LineWidth(GLcontext *ctx, GLfloat width)
-{
-       /* TODO */
-}
-
-static void nv04LogicOpcode(GLcontext *ctx, GLenum opcode)
-{
-       /* TODO */
-}
-
-static void nv04PointParameterfv(GLcontext *ctx, GLenum pname, const GLfloat *params)
-{
-       /* TODO */
-}
-
-static void nv04PointSize(GLcontext *ctx, GLfloat size)
-{
-       /* TODO */
-}
-
-static void nv04PolygonMode(GLcontext *ctx, GLenum face, GLenum mode)
-{
-       /* TODO */
-}
-
-/** Set the scale and units used to calculate depth values */
-static void nv04PolygonOffset(GLcontext *ctx, GLfloat factor, GLfloat units)
-{
-       /* TODO */
-}
-
-/** Set the polygon stippling pattern */
-static void nv04PolygonStipple(GLcontext *ctx, const GLubyte *mask )
-{
-       /* TODO */
-}
-
-/* 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 */
-static void nv04Scissor(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
-{
-       /* TODO */
-}
-
-/** Select flat or smooth shading */
-static void nv04ShadeModel(GLcontext *ctx, GLenum mode)
-{
-       nv04_emit_blend(ctx);
-}
-
-/** OpenGL 2.0 two-sided StencilFunc */
-static void nv04StencilFuncSeparate(GLcontext *ctx, GLenum face, GLenum func,
-               GLint ref, GLuint mask)
-{
-       /* TODO */
-}
-
-/** OpenGL 2.0 two-sided StencilMask */
-static void nv04StencilMaskSeparate(GLcontext *ctx, GLenum face, GLuint mask)
-{
-       /* TODO */
-}
-
-/** OpenGL 2.0 two-sided StencilOp */
-static void nv04StencilOpSeparate(GLcontext *ctx, GLenum face, GLenum fail,
-               GLenum zfail, GLenum zpass)
-{
-       /* TODO */
-}
-
-/** 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);
-
-/* Update anything that depends on the window position/size */
-static void nv04WindowMoved(nouveauContextPtr nmesa)
-{
-}
-
-/* Initialise any card-specific non-GL related state */
-static GLboolean nv04InitCard(nouveauContextPtr nmesa)
-{
-       nouveauObjectOnSubchannel(nmesa, NvSub3D, Nv3D);
-       nouveauObjectOnSubchannel(nmesa, NvSubCtxSurf3D, NvCtxSurf3D);
-
-       BEGIN_RING_SIZE(NvSubCtxSurf3D, NV04_CONTEXT_SURFACES_3D_DMA_NOTIFY, 3);
-       OUT_RING(NvDmaFB);
-       OUT_RING(NvDmaFB);
-       OUT_RING(NvDmaFB);
-       BEGIN_RING_SIZE(NvSub3D, NV04_DX5_TEXTURED_TRIANGLE_SURFACE, 1);
-       OUT_RING(NvCtxSurf3D);
-       return GL_TRUE;
-}
-
-/* Update buffer offset/pitch/format */
-static GLboolean nv04BindBuffers(nouveauContextPtr nmesa, int num_color,
-               nouveau_renderbuffer **color,
-               nouveau_renderbuffer *depth)
-{
-       GLuint x, y, w, h;
-       uint32_t depth_pitch=(depth?depth->pitch:0+15)&~15+16;
-       if (depth_pitch<256) depth_pitch=256;
-
-       w = color[0]->mesa.Width;
-       h = color[0]->mesa.Height;
-       x = nmesa->drawX;
-       y = nmesa->drawY;
-
-       BEGIN_RING_SIZE(NvSubCtxSurf3D, NV04_CONTEXT_SURFACES_3D_FORMAT, 1);
-       if (color[0]->mesa._ActualFormat == GL_RGBA8)
-               OUT_RING(0x108/*A8R8G8B8*/);
-       else
-               OUT_RING(0x103/*R5G6B5*/);
-
-       /* FIXME pitches have to be aligned ! */
-       BEGIN_RING_SIZE(NvSubCtxSurf3D, NV04_CONTEXT_SURFACES_3D_PITCH, 2);
-       OUT_RING(color[0]->pitch|(depth_pitch<<16));
-       OUT_RING(color[0]->offset);
-       if (depth) {
-               BEGIN_RING_SIZE(NvSubCtxSurf3D, NV04_CONTEXT_SURFACES_3D_OFFSET_ZETA, 1);
-               OUT_RING(depth->offset);
-       }
-
-//     BEGIN_RING_SIZE(NvSubCtxSurf3D, NV04_CONTEXT_SURFACES_3D_CLIP_HORIZONTAL, 2);
-//     OUT_RING((w<<16)|x);
-//     OUT_RING((h<<16)|y);
-
-
-       /* FIXME not sure... */
-/*     BEGIN_RING_SIZE(NvSubCtxSurf3D, NV04_CONTEXT_SURFACES_3D_CLIP_SIZE, 1);
-       OUT_RING((h<<16)|w);*/
-
-       return GL_TRUE;
-}
-
-void nv04InitStateFuncs(GLcontext *ctx, struct dd_function_table *func)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       func->AlphaFunc                 = nv04AlphaFunc;
-       func->BlendColor                = nv04BlendColor;
-       func->BlendEquationSeparate     = nv04BlendEquationSeparate;
-       func->BlendFuncSeparate         = nv04BlendFuncSeparate;
-       func->Clear                     = nv04Clear;
-       func->ClearColor                = nv04ClearColor;
-       func->ClearDepth                = nv04ClearDepth;
-       func->ClearStencil              = nv04ClearStencil;
-       func->ClipPlane                 = nv04ClipPlane;
-       func->ColorMask                 = nv04ColorMask;
-       func->ColorMaterial             = nv04ColorMaterial;
-       func->CullFace                  = nv04CullFace;
-       func->FrontFace                 = nv04FrontFace;
-       func->DepthFunc                 = nv04DepthFunc;
-       func->DepthMask                 = nv04DepthMask;
-       func->DepthRange                = nv04DepthRange;
-       func->Enable                    = nv04Enable;
-       func->Fogfv                     = nv04Fogfv;
-       func->Hint                      = nv04Hint;
-/*     func->Lightfv                   = nv04Lightfv;*/
-/*     func->LightModelfv              = nv04LightModelfv; */
-       func->LineStipple               = nv04LineStipple;              /* Not for NV04 */
-       func->LineWidth                 = nv04LineWidth;
-       func->LogicOpcode               = nv04LogicOpcode;
-       func->PointParameterfv          = nv04PointParameterfv;
-       func->PointSize                 = nv04PointSize;
-       func->PolygonMode               = nv04PolygonMode;
-       func->PolygonOffset             = nv04PolygonOffset;
-       func->PolygonStipple            = nv04PolygonStipple;           /* Not for NV04 */
-/*     func->ReadBuffer                = nv04ReadBuffer;*/
-/*     func->RenderMode                = nv04RenderMode;*/
-       func->Scissor                   = nv04Scissor;
-       func->ShadeModel                = nv04ShadeModel;
-       func->StencilFuncSeparate       = nv04StencilFuncSeparate;
-       func->StencilMaskSeparate       = nv04StencilMaskSeparate;
-       func->StencilOpSeparate         = nv04StencilOpSeparate;
-/*     func->TexGen                    = nv04TexGen;*/
-/*     func->TexParameter              = nv04TexParameter;*/
-/*     func->TextureMatrix             = nv04TextureMatrix;*/
-
-       nmesa->hw_func.InitCard         = nv04InitCard;
-       nmesa->hw_func.BindBuffers      = nv04BindBuffers;
-       nmesa->hw_func.WindowMoved      = nv04WindowMoved;
-}
diff --git a/src/mesa/drivers/dri/nouveau/nv04_swtcl.c b/src/mesa/drivers/dri/nouveau/nv04_swtcl.c
deleted file mode 100644 (file)
index cb072e0..0000000
+++ /dev/null
@@ -1,619 +0,0 @@
-/*
- * Copyright 2007 Stephane Marchesin. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and 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.
- */
-
-/* Software TCL for NV04, NV05, NV06 */
-
-#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 "nouveau_swtcl.h"
-#include "nv04_swtcl.h"
-#include "nouveau_context.h"
-#include "nouveau_span.h"
-#include "nouveau_reg.h"
-#include "nouveau_tex.h"
-#include "nouveau_fifo.h"
-#include "nouveau_msg.h"
-#include "nouveau_object.h"
-
-static void nv04RasterPrimitive( GLcontext *ctx, GLenum rprim, GLuint hwprim );
-static void nv04RenderPrimitive( GLcontext *ctx, GLenum prim );
-static void nv04ResetLineStipple( GLcontext *ctx );
-
-
-static inline void nv04_2triangles(struct nouveau_context *nmesa,nouveauVertex* v0,nouveauVertex* v1,nouveauVertex* v2,nouveauVertex* v3,nouveauVertex* v4,nouveauVertex* v5)
-{
-       BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0xA),49);
-       OUT_RINGp(v0,8);
-       OUT_RINGp(v1,8);
-       OUT_RINGp(v2,8);
-       OUT_RINGp(v3,8);
-       OUT_RINGp(v4,8);
-       OUT_RINGp(v5,8);
-       OUT_RING(0xFEDCBA);
-}
-
-static inline void nv04_1triangle(struct nouveau_context *nmesa,nouveauVertex* v0,nouveauVertex* v1,nouveauVertex* v2)
-{
-       BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0xD),25);
-       OUT_RINGp(v0,8);
-       OUT_RINGp(v1,8);
-       OUT_RINGp(v2,8);
-       OUT_RING(0xFED);
-}
-
-static inline void nv04_1quad(struct nouveau_context *nmesa,nouveauVertex* v0,nouveauVertex* v1,nouveauVertex* v2,nouveauVertex* v3)
-{
-       BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0xC),33);
-       OUT_RINGp(v0,8);
-       OUT_RINGp(v1,8);
-       OUT_RINGp(v2,8);
-       OUT_RINGp(v3,8);
-       OUT_RING(0xFECEDC);
-}
-
-static inline void nv04_render_points(GLcontext *ctx,GLuint first,GLuint last)
-{
-       WARN_ONCE("Unimplemented\n");
-}
-
-static inline void nv04_render_line(GLcontext *ctx,GLuint v1,GLuint v2)
-{
-       WARN_ONCE("Unimplemented\n");
-}
-
-static inline void nv04_render_triangle(GLcontext *ctx,GLuint v1,GLuint v2,GLuint v3)
-{
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte *vertptr = (GLubyte *)nmesa->verts;
-       GLuint vertsize = nmesa->vertex_size;
-
-       nv04_1triangle(nmesa,
-                       (nouveauVertex*)(vertptr+v1*vertsize),
-                       (nouveauVertex*)(vertptr+v2*vertsize),
-                       (nouveauVertex*)(vertptr+v3*vertsize)
-                 );
-}
-
-static inline void nv04_render_quad(GLcontext *ctx,GLuint v1,GLuint v2,GLuint v3,GLuint v4)
-{
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte *vertptr = (GLubyte *)nmesa->verts;
-       GLuint vertsize = nmesa->vertex_size;
-
-       nv04_1quad(nmesa,
-                       (nouveauVertex*)(vertptr+v1*vertsize),
-                       (nouveauVertex*)(vertptr+v2*vertsize),
-                       (nouveauVertex*)(vertptr+v3*vertsize),
-                       (nouveauVertex*)(vertptr+v4*vertsize)
-                 );
-}
-
-/**********************************************************************/
-/*               Render unclipped begin/end objects                   */
-/**********************************************************************/
-
-static void nv04_render_points_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       // erm
-}
-
-static void nv04_render_lines_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       // umm
-}
-
-static void nv04_render_line_strip_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       // yeah
-}
-
-static void nv04_render_line_loop_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       // right
-}
-
-static void nv04_render_triangles_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte *vertptr = (GLubyte *)nmesa->verts;
-       GLuint vertsize = nmesa->vertex_size;
-       int i;
-
-       for(i=start;i<count-5;i+=6)
-               nv04_2triangles(nmesa,
-                               (nouveauVertex*)(vertptr+(i+0)*vertsize),
-                               (nouveauVertex*)(vertptr+(i+1)*vertsize),
-                               (nouveauVertex*)(vertptr+(i+2)*vertsize),
-                               (nouveauVertex*)(vertptr+(i+3)*vertsize),
-                               (nouveauVertex*)(vertptr+(i+4)*vertsize),
-                               (nouveauVertex*)(vertptr+(i+5)*vertsize)
-                              );
-       if (i!=count)
-       {
-               nv04_1triangle(nmesa,
-                               (nouveauVertex*)(vertptr+(i+0)*vertsize),
-                               (nouveauVertex*)(vertptr+(i+1)*vertsize),
-                               (nouveauVertex*)(vertptr+(i+2)*vertsize)
-                              );
-               i+=3;
-       }
-       if (i!=count)
-               printf("oops\n");
-}
-
-static void nv04_render_tri_strip_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte *vertptr = (GLubyte *)nmesa->verts;
-       GLuint vertsize = nmesa->vertex_size;
-       uint32_t striptbl[]={0x321210,0x543432,0x765654,0x987876,0xBA9A98,0xDCBCBA,0xFEDEDC};
-       int i,j;
-
-       for(i=start;i<count;i+=14)
-       {
-               int numvert=MIN2(16,count-i);
-               int numtri=numvert-2;
-               if (numvert<3)
-                       break;
-
-               BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0x0),numvert*8);
-               for(j=0;j<numvert;j++)
-                       OUT_RINGp((nouveauVertex*)(vertptr+(i+j)*vertsize),8);
-
-               BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_DRAW|NONINC_METHOD,(numtri+1)/2);
-               for(j=0;j<numtri/2;j++)
-                       OUT_RING(striptbl[j]);
-               if (numtri%2)
-                       OUT_RING(striptbl[numtri/2]&0xFFF);
-       }
-}
-
-static void nv04_render_tri_fan_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte *vertptr = (GLubyte *)nmesa->verts;
-       GLuint vertsize = nmesa->vertex_size;
-       uint32_t fantbl[]={0x320210,0x540430,0x760650,0x980870,0xBA0A90,0xDC0CB0,0xFE0ED0};
-       int i,j;
-
-       BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0x0),8);
-       OUT_RINGp((nouveauVertex*)(vertptr+start*vertsize),8);
-
-       for(i=start+1;i<count;i+=14)
-       {
-               int numvert=MIN2(15,count-i);
-               int numtri=numvert-1;
-               if (numvert<3)
-                       break;
-
-               BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0x1),numvert*8);
-
-               for(j=0;j<numvert;j++)
-                       OUT_RINGp((nouveauVertex*)(vertptr+(i+j)*vertsize),8);
-
-               BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_DRAW|NONINC_METHOD,(numtri+1)/2);
-               for(j=0;j<numtri/2;j++)
-                       OUT_RING(fantbl[j]);
-               if (numtri%2)
-                       OUT_RING(fantbl[numtri/2]&0xFFF);
-       }
-}
-
-static void nv04_render_quads_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte *vertptr = (GLubyte *)nmesa->verts;
-       GLuint vertsize = nmesa->vertex_size;
-       int i;
-
-       for(i=start;i<count;i+=4)
-               nv04_1quad(nmesa,
-                               (nouveauVertex*)(vertptr+(i+0)*vertsize),
-                               (nouveauVertex*)(vertptr+(i+1)*vertsize),
-                               (nouveauVertex*)(vertptr+(i+2)*vertsize),
-                               (nouveauVertex*)(vertptr+(i+3)*vertsize)
-                              );
-}
-
-static void nv04_render_noop_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-}
-
-static void (*nv04_render_tab_verts[GL_POLYGON+2])(GLcontext *,
-                                                          GLuint,
-                                                          GLuint,
-                                                          GLuint) =
-{
-   nv04_render_points_verts,
-   nv04_render_lines_verts,
-   nv04_render_line_loop_verts,
-   nv04_render_line_strip_verts,
-   nv04_render_triangles_verts,
-   nv04_render_tri_strip_verts,
-   nv04_render_tri_fan_verts,
-   nv04_render_quads_verts,
-   nv04_render_tri_strip_verts,  //nv04_render_quad_strip_verts
-   nv04_render_tri_fan_verts,    //nv04_render_poly_verts
-   nv04_render_noop_verts,
-};
-
-
-static void nv04_render_points_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       // erm
-}
-
-static void nv04_render_lines_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       // umm
-}
-
-static void nv04_render_line_strip_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       // yeah
-}
-
-static void nv04_render_line_loop_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       // right
-}
-
-static void nv04_render_triangles_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte *vertptr = (GLubyte *)nmesa->verts;
-       GLuint vertsize = nmesa->vertex_size;
-       const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts;
-       int i;
-
-       for(i=start;i<count-5;i+=6)
-               nv04_2triangles(nmesa,
-                               (nouveauVertex*)(vertptr+elt[i+0]*vertsize),
-                               (nouveauVertex*)(vertptr+elt[i+1]*vertsize),
-                               (nouveauVertex*)(vertptr+elt[i+2]*vertsize),
-                               (nouveauVertex*)(vertptr+elt[i+3]*vertsize),
-                               (nouveauVertex*)(vertptr+elt[i+4]*vertsize),
-                               (nouveauVertex*)(vertptr+elt[i+5]*vertsize)
-                              );
-       if (i!=count)
-       {
-               nv04_1triangle(nmesa,
-                               (nouveauVertex*)(vertptr+elt[i+0]*vertsize),
-                               (nouveauVertex*)(vertptr+elt[i+1]*vertsize),
-                               (nouveauVertex*)(vertptr+elt[i+2]*vertsize)
-                              );
-               i+=3;
-       }
-       if (i!=count)
-               printf("oops\n");
-}
-
-static void nv04_render_tri_strip_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte *vertptr = (GLubyte *)nmesa->verts;
-       GLuint vertsize = nmesa->vertex_size;
-       uint32_t striptbl[]={0x321210,0x543432,0x765654,0x987876,0xBA9A98,0xDCBCBA,0xFEDEDC};
-       const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts;
-       int i,j;
-
-       for(i=start;i<count;i+=14)
-       {
-               int numvert=MIN2(16,count-i);
-               int numtri=numvert-2;
-               if (numvert<3)
-                       break;
-
-               BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0x0),numvert*8);
-               for(j=0;j<numvert;j++)
-                       OUT_RINGp((nouveauVertex*)(vertptr+elt[i+j]*vertsize),8);
-
-               BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_DRAW|NONINC_METHOD,(numtri+1)/2);
-               for(j=0;j<numtri/2;j++)
-                       OUT_RING(striptbl[j]);
-               if (numtri%2)
-                       OUT_RING(striptbl[numtri/2]&0xFFF);
-       }
-}
-
-static void nv04_render_tri_fan_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte *vertptr = (GLubyte *)nmesa->verts;
-       GLuint vertsize = nmesa->vertex_size;
-       uint32_t fantbl[]={0x320210,0x540430,0x760650,0x980870,0xBA0A90,0xDC0CB0,0xFE0ED0};
-       const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts;
-       int i,j;
-
-       BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0x0),8);
-       OUT_RINGp((nouveauVertex*)(vertptr+elt[start]*vertsize),8);
-
-       for(i=start+1;i<count;i+=14)
-       {
-               int numvert=MIN2(15,count-i);
-               int numtri=numvert-2;
-               if (numvert<3)
-                       break;
-
-               BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_TLVERTEX_SX(0x1),numvert*8);
-
-               for(j=0;j<numvert;j++)
-                       OUT_RINGp((nouveauVertex*)(vertptr+elt[i+j]*vertsize),8);
-
-               BEGIN_RING_SIZE(NvSub3D,NV04_DX5_TEXTURED_TRIANGLE_DRAW|NONINC_METHOD,(numtri+1)/2);
-               for(j=0;j<numtri/2;j++)
-                       OUT_RING(fantbl[j]);
-               if (numtri%2)
-                       OUT_RING(fantbl[numtri/2]&0xFFF);
-       }
-}
-
-static void nv04_render_quads_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte *vertptr = (GLubyte *)nmesa->verts;
-       GLuint vertsize = nmesa->vertex_size;
-       const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts;
-       int i;
-
-       for(i=start;i<count;i+=4)
-               nv04_1quad(nmesa,
-                               (nouveauVertex*)(vertptr+elt[i+0]*vertsize),
-                               (nouveauVertex*)(vertptr+elt[i+1]*vertsize),
-                               (nouveauVertex*)(vertptr+elt[i+2]*vertsize),
-                               (nouveauVertex*)(vertptr+elt[i+3]*vertsize)
-                              );
-}
-
-static void nv04_render_noop_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-}
-
-static void (*nv04_render_tab_elts[GL_POLYGON+2])(GLcontext *,
-                                                          GLuint,
-                                                          GLuint,
-                                                          GLuint) =
-{
-   nv04_render_points_elts,
-   nv04_render_lines_elts,
-   nv04_render_line_loop_elts,
-   nv04_render_line_strip_elts,
-   nv04_render_triangles_elts,
-   nv04_render_tri_strip_elts,
-   nv04_render_tri_fan_elts,
-   nv04_render_quads_elts,
-   nv04_render_tri_strip_elts,   // nv04_render_quad_strip_elts,
-   nv04_render_tri_fan_elts,     // nv04_render_poly_elts,
-   nv04_render_noop_elts,
-};
-
-
-/**********************************************************************/
-/*                    Choose render functions                         */
-/**********************************************************************/
-
-
-#define EMIT_ATTR( ATTR, STYLE )                                       \
-do {                                                                   \
-   nmesa->vertex_attrs[nmesa->vertex_attr_count].attrib = (ATTR);      \
-   nmesa->vertex_attrs[nmesa->vertex_attr_count].format = (STYLE);     \
-   nmesa->vertex_attr_count++;                                         \
-} while (0)
-
-#define EMIT_PAD( N )                                                  \
-do {                                                                   \
-   nmesa->vertex_attrs[nmesa->vertex_attr_count].attrib = 0;           \
-   nmesa->vertex_attrs[nmesa->vertex_attr_count].format = EMIT_PAD;    \
-   nmesa->vertex_attrs[nmesa->vertex_attr_count].offset = (N);         \
-   nmesa->vertex_attr_count++;                                         \
-} while (0)
-
-static void nv04_render_clipped_line(GLcontext *ctx,GLuint ii,GLuint jj)
-{
-}
-
-static void nv04_render_clipped_poly(GLcontext *ctx,const GLuint *elts,GLuint n)
-{
-}
-
-static void nv04ChooseRenderState(GLcontext *ctx)
-{
-       TNLcontext *tnl = TNL_CONTEXT(ctx);
-
-       tnl->Driver.Render.PrimTabVerts = nv04_render_tab_verts;
-       tnl->Driver.Render.PrimTabElts = nv04_render_tab_elts;
-       tnl->Driver.Render.ClippedLine = nv04_render_clipped_line;
-       tnl->Driver.Render.ClippedPolygon = nv04_render_clipped_poly;
-       tnl->Driver.Render.Points = nv04_render_points;
-       tnl->Driver.Render.Line = nv04_render_line;
-       tnl->Driver.Render.Triangle = nv04_render_triangle;
-       tnl->Driver.Render.Quad = nv04_render_quad;
-}
-
-
-
-static inline void nv04OutputVertexFormat(struct nouveau_context* nmesa)
-{
-       GLcontext* ctx=nmesa->glCtx;
-       DECLARE_RENDERINPUTS(index);
-
-       /*
-        * Tell t_vertex about the vertex format
-        */
-       nmesa->vertex_attr_count = 0;
-       RENDERINPUTS_COPY(index, nmesa->render_inputs_bitset);
-
-       // SX SY SZ INVW
-       // FIXME : we use W instead of INVW, but since W=1 it doesn't matter
-       if (RENDERINPUTS_TEST(index, _TNL_ATTRIB_POS))
-               EMIT_ATTR(_TNL_ATTRIB_POS,EMIT_4F_VIEWPORT);
-       else
-               EMIT_PAD(4*sizeof(float));
-
-       // COLOR
-       if (RENDERINPUTS_TEST(index, _TNL_ATTRIB_COLOR0))
-               EMIT_ATTR(_TNL_ATTRIB_COLOR0,EMIT_4UB_4F_ABGR);
-       else
-               EMIT_PAD(4);
-
-       // SPECULAR
-       if (RENDERINPUTS_TEST(index, _TNL_ATTRIB_COLOR1))
-               EMIT_ATTR(_TNL_ATTRIB_COLOR1,EMIT_4UB_4F_ABGR);
-       else
-               EMIT_PAD(4);
-
-       // TEXTURE
-       if (RENDERINPUTS_TEST(index, _TNL_ATTRIB_TEX0))
-               EMIT_ATTR(_TNL_ATTRIB_TEX0,EMIT_2F);
-       else
-               EMIT_PAD(2*sizeof(float));
-
-       nmesa->vertex_size=_tnl_install_attrs( ctx,
-                       nmesa->vertex_attrs, 
-                       nmesa->vertex_attr_count,
-                       nmesa->viewport.m, 0 );
-}
-
-
-static void nv04ChooseVertexState( GLcontext *ctx )
-{
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-       TNLcontext *tnl = TNL_CONTEXT(ctx);
-       DECLARE_RENDERINPUTS(index);
-
-       RENDERINPUTS_COPY(index, tnl->render_inputs_bitset);
-       if (!RENDERINPUTS_EQUAL(index, nmesa->render_inputs_bitset))
-       {
-               RENDERINPUTS_COPY(nmesa->render_inputs_bitset, index);
-               nv04OutputVertexFormat(nmesa);
-       }
-}
-
-
-/**********************************************************************/
-/*                 High level hooks for t_vb_render.c                 */
-/**********************************************************************/
-
-
-static void nv04RenderStart(GLcontext *ctx)
-{
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-
-       if (nmesa->new_state) {
-               nmesa->new_render_state |= nmesa->new_state;
-       }
-
-       if (nmesa->new_render_state) {
-               nv04ChooseVertexState(ctx);
-               nv04ChooseRenderState(ctx);
-               nmesa->new_render_state = 0;
-       }
-}
-
-static void nv04RenderFinish(GLcontext *ctx)
-{
-}
-
-
-/* System to flush dma and emit state changes based on the rasterized
- * primitive.
- */
-void nv04RasterPrimitive(GLcontext *ctx,
-               GLenum glprim,
-               GLuint hwprim)
-{
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-
-       assert (!nmesa->new_state);
-
-       if (hwprim != nmesa->current_primitive)
-       {
-               nmesa->current_primitive=hwprim;
-               
-       }
-}
-
-static const GLuint hw_prim[GL_POLYGON+1] = {
-       GL_POINTS+1,
-       GL_LINES+1,
-       GL_LINE_STRIP+1,
-       GL_LINE_LOOP+1,
-       GL_TRIANGLES+1,
-       GL_TRIANGLE_STRIP+1,
-       GL_TRIANGLE_FAN+1,
-       GL_QUADS+1,
-       GL_QUAD_STRIP+1,
-       GL_POLYGON+1
-};
-
-/* Callback for mesa:
- */
-static void nv04RenderPrimitive( GLcontext *ctx, GLuint prim )
-{
-       nv04RasterPrimitive( ctx, prim, hw_prim[prim] );
-}
-
-static void nv04ResetLineStipple( GLcontext *ctx )
-{
-       /* FIXME do something here */
-       WARN_ONCE("Unimplemented nv04ResetLineStipple\n");
-}
-
-
-/**********************************************************************/
-/*                            Initialization.                         */
-/**********************************************************************/
-
-void nv04TriInitFunctions(GLcontext *ctx)
-{
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-       TNLcontext *tnl = TNL_CONTEXT(ctx);
-
-       tnl->Driver.RunPipeline = nouveauRunPipeline;
-       tnl->Driver.Render.Start = nv04RenderStart;
-       tnl->Driver.Render.Finish = nv04RenderFinish;
-       tnl->Driver.Render.PrimitiveNotify = nv04RenderPrimitive;
-       tnl->Driver.Render.ResetLineStipple = nv04ResetLineStipple;
-       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, 32 );
-
-       nmesa->verts = (GLubyte *)tnl->clipspace.vertex_buf;
-}
-
-
diff --git a/src/mesa/drivers/dri/nouveau/nv04_swtcl.h b/src/mesa/drivers/dri/nouveau/nv04_swtcl.h
deleted file mode 100644 (file)
index 42dde53..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef __NV04_SWTCL_H__
-#define __NV04_SWTCL_H__
-
-#include "mtypes.h"
-
-extern void nv04Fallback( GLcontext *ctx, GLuint bit, GLboolean mode );
-extern void nv04FinishPrimitive(struct nouveau_context *nmesa);
-extern void nv04TriInitFunctions(GLcontext *ctx);
-#define FALLBACK( nmesa, bit, mode ) nouveauFallback( nmesa->glCtx, bit, mode )
-
-#endif /* __NV04_SWTCL_H__ */
-
diff --git a/src/mesa/drivers/dri/nouveau/nv10_state.c b/src/mesa/drivers/dri/nouveau/nv10_state.c
deleted file mode 100644 (file)
index 47c4b14..0000000
+++ /dev/null
@@ -1,797 +0,0 @@
-/**************************************************************************
-
-Copyright 2006 Nouveau
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-#include "nouveau_context.h"
-#include "nouveau_object.h"
-#include "nouveau_fifo.h"
-#include "nouveau_reg.h"
-
-#include "tnl/t_pipeline.h"
-
-#include "mtypes.h"
-#include "colormac.h"
-
-static void nv10ViewportScale(nouveauContextPtr nmesa)
-{
-       GLcontext *ctx = nmesa->glCtx;
-       GLuint w = ctx->Viewport.Width;
-       GLuint h = ctx->Viewport.Height;
-
-       GLfloat max_depth = (ctx->Viewport.Near + ctx->Viewport.Far) * 0.5;
-/*     if (ctx->DrawBuffer) {
-               switch (ctx->DrawBuffer->_DepthBuffer->DepthBits) {
-                       case 16:
-                               max_depth *= 32767.0;
-                               break;
-                       case 24:
-                               max_depth *= 16777215.0;
-                               break;
-               }
-       } else {*/
-               /* Default to 24 bits range */  
-               max_depth *= 16777215.0;
-/*     }*/
-
-       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_SCALE_X, 4);
-       OUT_RING_CACHEf ((((GLfloat) w) * 0.5) - 2048.0);
-       OUT_RING_CACHEf ((((GLfloat) h) * 0.5) - 2048.0);
-       OUT_RING_CACHEf (max_depth);
-       OUT_RING_CACHEf (0.0);
-}
-
-static void nv10AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte ubRef;
-       CLAMPED_FLOAT_TO_UBYTE(ubRef, ref);
-
-       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_ALPHA_FUNC_FUNC, 2);
-       OUT_RING_CACHE(func);
-       OUT_RING_CACHE(ubRef);
-}
-
-static void nv10BlendColor(GLcontext *ctx, const GLfloat color[4])
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); 
-       GLubyte cf[4];
-
-       CLAMPED_FLOAT_TO_UBYTE(cf[0], color[0]);
-       CLAMPED_FLOAT_TO_UBYTE(cf[1], color[1]);
-       CLAMPED_FLOAT_TO_UBYTE(cf[2], color[2]);
-       CLAMPED_FLOAT_TO_UBYTE(cf[3], color[3]);
-
-       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_BLEND_COLOR, 1);
-       OUT_RING_CACHE(PACK_COLOR_8888(cf[3], cf[1], cf[2], cf[0]));
-}
-
-static void nv10BlendEquationSeparate(GLcontext *ctx, GLenum modeRGB, GLenum modeA)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       assert( modeRGB == modeA );
-
-       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_BLEND_EQUATION, 1);
-       OUT_RING_CACHE(modeRGB);
-}
-
-
-static void nv10BlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB, GLenum dfactorRGB,
-               GLenum sfactorA, GLenum dfactorA)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       assert( sfactorRGB == sfactorA );
-       assert( dfactorRGB == dfactorA );
-
-       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_BLEND_FUNC_SRC, 2);
-       OUT_RING_CACHE(sfactorRGB);
-       OUT_RING_CACHE(dfactorRGB);
-}
-
-static void nv10Clear(GLcontext *ctx, GLbitfield mask)
-{
-       /* TODO */
-}
-
-static void nv10ClearColor(GLcontext *ctx, const GLfloat color[4])
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte c[4];
-       UNCLAMPED_FLOAT_TO_RGBA_CHAN(c,color);
-       nmesa->clear_color_value = PACK_COLOR_8888(c[3],c[0],c[1],c[2]);
-}
-
-static void nv10ClearDepth(GLcontext *ctx, GLclampd d)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-/*     switch (ctx->DrawBuffer->_DepthBuffer->DepthBits) {
-               case 16:
-                       nmesa->clear_value = (uint32_t)(d*0x7FFF);
-                       break;
-               case 24:*/
-                       nmesa->clear_value = ((nmesa->clear_value&0x000000FF) |
-                               (((uint32_t)(d*0xFFFFFF))<<8));
-/*                     break;
-       }*/
-}
-
-static void nv10ClearStencil(GLcontext *ctx, GLint s)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-/*     if (ctx->DrawBuffer->_DepthBuffer->DepthBits == 24) {*/
-               nmesa->clear_value = ((nmesa->clear_value&0xFFFFFF00)|
-                       (s&0x000000FF));
-/*     }*/
-}
-
-static void nv10ClipPlane(GLcontext *ctx, GLenum plane, const GLfloat *equation)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_CLIP_PLANE_A(plane), 4);
-       OUT_RING_CACHEf(equation[0]);
-       OUT_RING_CACHEf(equation[1]);
-       OUT_RING_CACHEf(equation[2]);
-       OUT_RING_CACHEf(equation[3]);
-}
-
-static void nv10ColorMask(GLcontext *ctx, GLboolean rmask, GLboolean gmask,
-               GLboolean bmask, GLboolean amask )
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_COLOR_MASK, 1);
-       OUT_RING_CACHE(((amask && 0x01) << 24) | ((rmask && 0x01) << 16) | ((gmask && 0x01)<< 8) | ((bmask && 0x01) << 0));
-}
-
-static void nv10ColorMaterial(GLcontext *ctx, GLenum face, GLenum mode)
-{
-       /* TODO I need love */
-}
-
-static void nv10CullFace(GLcontext *ctx, GLenum mode)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_CULL_FACE, 1);
-       OUT_RING_CACHE(mode);
-}
-
-static void nv10FrontFace(GLcontext *ctx, GLenum mode)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_FRONT_FACE, 1);
-       OUT_RING_CACHE(mode);
-}
-
-static void nv10DepthFunc(GLcontext *ctx, GLenum func)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_DEPTH_FUNC, 1);
-       OUT_RING_CACHE(func);
-}
-
-static void nv10DepthMask(GLcontext *ctx, GLboolean flag)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_DEPTH_WRITE_ENABLE, 1);
-       OUT_RING_CACHE(flag);
-}
-
-static void nv10DepthRange(GLcontext *ctx, GLclampd nearval, GLclampd farval)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       GLfloat depth_scale = 16777216.0;
-       if (ctx->DrawBuffer->_DepthBuffer->DepthBits == 16) {
-               depth_scale = 32768.0;
-       }
-
-       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_DEPTH_RANGE_NEAR, 2);
-       OUT_RING_CACHEf(nearval * depth_scale);
-       OUT_RING_CACHEf(farval * depth_scale);
-
-       nv10ViewportScale(nmesa);
-}
-
-/** 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 );
-
-static void nv10Enable(GLcontext *ctx, GLenum cap, GLboolean state)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       switch(cap)
-       {
-               case GL_ALPHA_TEST:
-                       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_ALPHA_FUNC_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_AUTO_NORMAL:
-               case GL_BLEND:
-                       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_BLEND_FUNC_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       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:
-                       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_CLIP_PLANE_ENABLE(cap-GL_CLIP_PLANE0), 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_COLOR_LOGIC_OP:
-                       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_COLOR_LOGIC_OP_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_COLOR_MATERIAL:
-//             case GL_COLOR_SUM_EXT:
-//             case GL_COLOR_TABLE:
-//             case GL_CONVOLUTION_1D:
-//             case GL_CONVOLUTION_2D:
-               case GL_CULL_FACE:
-                       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_CULL_FACE_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_DEPTH_TEST:
-                       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_DEPTH_TEST_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_DITHER:
-                       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_DITHER_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_FOG:
-                       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_FOG_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_HISTOGRAM:
-//             case GL_INDEX_LOGIC_OP:
-               case GL_LIGHT0:
-               case GL_LIGHT1:
-               case GL_LIGHT2:
-               case GL_LIGHT3:
-               case GL_LIGHT4:
-               case GL_LIGHT5:
-               case GL_LIGHT6:
-               case GL_LIGHT7:
-                       {
-                       uint32_t mask=1<<(2*(cap-GL_LIGHT0));
-                       nmesa->enabled_lights=((nmesa->enabled_lights&mask)|(mask*state));
-                       if (nmesa->lighting_enabled)
-                       {
-                               BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_ENABLED_LIGHTS, 1);
-                               OUT_RING_CACHE(nmesa->enabled_lights);
-                       }
-                       break;
-                       }
-               case GL_LIGHTING:
-                       nmesa->lighting_enabled=state;
-                       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_ENABLED_LIGHTS, 1);
-                       if (nmesa->lighting_enabled)
-                               OUT_RING_CACHE(nmesa->enabled_lights);
-                       else
-                               OUT_RING_CACHE(0x0);
-                       break;
-               case GL_LINE_SMOOTH:
-                       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LINE_SMOOTH_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_LINE_STIPPLE:
-//             case GL_MAP1_COLOR_4:
-//             case GL_MAP1_INDEX:
-//             case GL_MAP1_NORMAL:
-//             case GL_MAP1_TEXTURE_COORD_1:
-//             case GL_MAP1_TEXTURE_COORD_2:
-//             case GL_MAP1_TEXTURE_COORD_3:
-//             case GL_MAP1_TEXTURE_COORD_4:
-//             case GL_MAP1_VERTEX_3:
-//             case GL_MAP1_VERTEX_4:
-//             case GL_MAP2_COLOR_4:
-//             case GL_MAP2_INDEX:
-//             case GL_MAP2_NORMAL:
-//             case GL_MAP2_TEXTURE_COORD_1:
-//             case GL_MAP2_TEXTURE_COORD_2:
-//             case GL_MAP2_TEXTURE_COORD_3:
-//             case GL_MAP2_TEXTURE_COORD_4:
-//             case GL_MAP2_VERTEX_3:
-//             case GL_MAP2_VERTEX_4:
-//             case GL_MINMAX:
-               case GL_NORMALIZE:
-                       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_NORMALIZE_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_POINT_SMOOTH:
-               case GL_POLYGON_OFFSET_POINT:
-                       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_POLYGON_OFFSET_POINT_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_POLYGON_OFFSET_LINE:
-                       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_POLYGON_OFFSET_LINE_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_POLYGON_OFFSET_FILL:
-                       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_POLYGON_OFFSET_FILL_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_POLYGON_SMOOTH:
-                       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_POLYGON_SMOOTH_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_POLYGON_STIPPLE:
-//             case GL_POST_COLOR_MATRIX_COLOR_TABLE:
-//             case GL_POST_CONVOLUTION_COLOR_TABLE:
-//             case GL_RESCALE_NORMAL:
-//             case GL_SCISSOR_TEST:
-//             case GL_SEPARABLE_2D:
-               case GL_STENCIL_TEST:
-                       // TODO BACK and FRONT ?
-                       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_STENCIL_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_TEXTURE_GEN_Q:
-//             case GL_TEXTURE_GEN_R:
-//             case GL_TEXTURE_GEN_S:
-//             case GL_TEXTURE_GEN_T:
-//             case GL_TEXTURE_1D:
-//             case GL_TEXTURE_2D:
-//             case GL_TEXTURE_3D:
-       }
-}
-
-static void nv10Fogfv(GLcontext *ctx, GLenum pname, const GLfloat *params)
-{
-    nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-    switch(pname)
-    {
-        case GL_FOG_MODE:
-            //BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_FOG_MODE, 1);
-            //OUT_RING_CACHE (params);
-            break;
-            /* TODO: unsure about the rest.*/
-        default:
-            break;
-    }
-
-}
-   
-static void nv10Hint(GLcontext *ctx, GLenum target, GLenum mode)
-{
-       /* TODO I need love (fog and line_smooth hints) */
-}
-
-// void (*IndexMask)(GLcontext *ctx, GLuint mask);
-
-enum {
-       SPOTLIGHT_NO_UPDATE,
-       SPOTLIGHT_UPDATE_EXPONENT,
-       SPOTLIGHT_UPDATE_DIRECTION,
-       SPOTLIGHT_UPDATE_ALL
-};
-
-static void nv10Lightfv(GLcontext *ctx, GLenum light, GLenum pname, const GLfloat *params )
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       GLint p = light - GL_LIGHT0;
-       struct gl_light *l = &ctx->Light.Light[p];
-       int spotlight_update = SPOTLIGHT_NO_UPDATE;
-
-       switch(pname)
-       {
-               case GL_AMBIENT:
-                       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_AMBIENT_R(p), 3);
-                       OUT_RING_CACHEf(params[0]);
-                       OUT_RING_CACHEf(params[1]);
-                       OUT_RING_CACHEf(params[2]);
-                       break;
-               case GL_DIFFUSE:
-                       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_DIFFUSE_R(p), 3);
-                       OUT_RING_CACHEf(params[0]);
-                       OUT_RING_CACHEf(params[1]);
-                       OUT_RING_CACHEf(params[2]);
-                       break;
-               case GL_SPECULAR:
-                       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_SPECULAR_R(p), 3);
-                       OUT_RING_CACHEf(params[0]);
-                       OUT_RING_CACHEf(params[1]);
-                       OUT_RING_CACHEf(params[2]);
-                       break;
-               case GL_POSITION:
-                       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LIGHT_POSITION_X(p), 3);
-                       OUT_RING_CACHEf(params[0]);
-                       OUT_RING_CACHEf(params[1]);
-                       OUT_RING_CACHEf(params[2]);
-                       break;
-               case GL_SPOT_DIRECTION:
-                       spotlight_update = SPOTLIGHT_UPDATE_DIRECTION;
-                       break;
-               case GL_SPOT_EXPONENT:
-                       spotlight_update = SPOTLIGHT_UPDATE_EXPONENT;
-                       break;
-               case GL_SPOT_CUTOFF:
-                       spotlight_update = SPOTLIGHT_UPDATE_ALL;
-                       break;
-               case GL_CONSTANT_ATTENUATION:
-                       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LIGHT_CONSTANT_ATTENUATION(p), 1);
-                       OUT_RING_CACHEf(*params);
-                       break;
-               case GL_LINEAR_ATTENUATION:
-                       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LIGHT_LINEAR_ATTENUATION(p), 1);
-                       OUT_RING_CACHEf(*params);
-                       break;
-               case GL_QUADRATIC_ATTENUATION:
-                       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LIGHT_QUADRATIC_ATTENUATION(p), 1);
-                       OUT_RING_CACHEf(*params);
-                       break;
-               default:
-                       break;
-       }
-
-       switch(spotlight_update) {
-               case SPOTLIGHT_UPDATE_DIRECTION:
-                       {
-                               GLfloat x,y,z;
-                               GLfloat spot_light_coef_a = 1.0 / (l->_CosCutoff - 1.0);
-                               x = spot_light_coef_a * l->_NormDirection[0];
-                               y = spot_light_coef_a * l->_NormDirection[1];
-                               z = spot_light_coef_a * l->_NormDirection[2];
-                               BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LIGHT_SPOT_DIR_X(p), 3);
-                               OUT_RING_CACHEf(x);
-                               OUT_RING_CACHEf(y);
-                               OUT_RING_CACHEf(z);
-                       }
-                       break;
-               case SPOTLIGHT_UPDATE_EXPONENT:
-                       {
-                               GLfloat cc,lc,qc;
-                               cc = 1.0;       /* FIXME: These need to be correctly computed */
-                               lc = 0.0;
-                               qc = 2.0;
-                               BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LIGHT_SPOT_CUTOFF_A(p), 3);
-                               OUT_RING_CACHEf(cc);
-                               OUT_RING_CACHEf(lc);
-                               OUT_RING_CACHEf(qc);
-                       }
-                       break;
-               case SPOTLIGHT_UPDATE_ALL:
-                       {
-                               GLfloat cc,lc,qc, x,y,z, c;
-                               GLfloat spot_light_coef_a = 1.0 / (l->_CosCutoff - 1.0);
-                               cc = 1.0;       /* FIXME: These need to be correctly computed */
-                               lc = 0.0;
-                               qc = 2.0;
-                               x = spot_light_coef_a * l->_NormDirection[0];
-                               y = spot_light_coef_a * l->_NormDirection[1];
-                               z = spot_light_coef_a * l->_NormDirection[2];
-                               c = spot_light_coef_a + 1.0;
-                               BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LIGHT_SPOT_CUTOFF_A(p), 7);
-                               OUT_RING_CACHEf(cc);
-                               OUT_RING_CACHEf(lc);
-                               OUT_RING_CACHEf(qc);
-                               OUT_RING_CACHEf(x);
-                               OUT_RING_CACHEf(y);
-                               OUT_RING_CACHEf(z);
-                               OUT_RING_CACHEf(c);
-                       }
-                       break;
-               default:
-                       break;
-       }
-}
-
-/** Set the lighting model parameters */
-static void (*LightModelfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
-
-
-static void nv10LineStipple(GLcontext *ctx, GLint factor, GLushort pattern )
-{
-       /* Not for NV10 */
-}
-
-static void nv10LineWidth(GLcontext *ctx, GLfloat width)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_LINE_WIDTH, 1);
-       OUT_RING_CACHE(((int) (width * 8.0)) & -4);
-}
-
-static void nv10LogicOpcode(GLcontext *ctx, GLenum opcode)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_COLOR_LOGIC_OP_OP, 1);
-       OUT_RING_CACHE(opcode);
-}
-
-static void nv10PointParameterfv(GLcontext *ctx, GLenum pname, const GLfloat *params)
-{
-       /*TODO: not sure what goes here. */
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       
-}
-
-static void nv10PointSize(GLcontext *ctx, GLfloat size)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_POINT_SIZE, 1);
-       OUT_RING_CACHE(((int) (size * 8.0)) & -4);
-}
-
-static void nv10PolygonMode(GLcontext *ctx, GLenum face, GLenum mode)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
-               BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_POLYGON_MODE_FRONT, 1);
-               OUT_RING_CACHE(mode);
-       }
-       if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
-               BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_POLYGON_MODE_BACK, 1);
-               OUT_RING_CACHE(mode);
-       }
-}
-
-/** Set the scale and units used to calculate depth values */
-static void nv10PolygonOffset(GLcontext *ctx, GLfloat factor, GLfloat units)
-{
-        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-        BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_POLYGON_OFFSET_FACTOR, 2);
-        OUT_RING_CACHEf(factor);
-        OUT_RING_CACHEf(units);
-}
-
-/** Set the polygon stippling pattern */
-static void nv10PolygonStipple(GLcontext *ctx, const GLubyte *mask )
-{
-       /* Not for NV10 */
-}
-
-/* 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 */
-static void nv10Scissor(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
-{
-}
-
-/** Select flat or smooth shading */
-static void nv10ShadeModel(GLcontext *ctx, GLenum mode)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_SHADE_MODEL, 1);
-       OUT_RING_CACHE(mode);
-}
-
-/** OpenGL 2.0 two-sided StencilFunc */
-static void nv10StencilFuncSeparate(GLcontext *ctx, GLenum face, GLenum func,
-               GLint ref, GLuint mask)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       /* NV10 do not have separate FRONT and BACK stencils */
-       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_STENCIL_FUNC_FUNC, 3);
-       OUT_RING_CACHE(func);
-       OUT_RING_CACHE(ref);
-       OUT_RING_CACHE(mask);
-}
-
-/** OpenGL 2.0 two-sided StencilMask */
-static void nv10StencilMaskSeparate(GLcontext *ctx, GLenum face, GLuint mask)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       /* NV10 do not have separate FRONT and BACK stencils */
-       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_STENCIL_MASK, 1);
-       OUT_RING_CACHE(mask);
-}
-
-/** OpenGL 2.0 two-sided StencilOp */
-static void nv10StencilOpSeparate(GLcontext *ctx, GLenum face, GLenum fail,
-               GLenum zfail, GLenum zpass)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       /* NV10 do not have separate FRONT and BACK stencils */
-       BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_STENCIL_OP_FAIL, 3);
-       OUT_RING_CACHE(fail);
-       OUT_RING_CACHE(zfail);
-       OUT_RING_CACHE(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);
-
-static void nv10TextureMatrix(GLcontext *ctx, GLuint unit, const GLmatrix *mat)
-{
-        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-        BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_TX_MATRIX(unit, 0), 16);
-        /*XXX: This SHOULD work.*/
-        OUT_RING_CACHEp(mat->m, 16);
-}
-
-/* Update anything that depends on the window position/size */
-static void nv10WindowMoved(nouveauContextPtr nmesa)
-{
-       GLcontext *ctx = nmesa->glCtx;
-       GLfloat *v = nmesa->viewport.m;
-       GLuint w = ctx->Viewport.Width;
-       GLuint h = ctx->Viewport.Height;
-       GLuint x = ctx->Viewport.X + nmesa->drawX;
-       GLuint y = ctx->Viewport.Y + nmesa->drawY;
-       int i;
-
-        BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_HORIZ, 2);
-        OUT_RING_CACHE((w << 16) | x);
-        OUT_RING_CACHE((h << 16) | y);
-
-       /* something to do with clears, possibly doesn't belong here */
-       BEGIN_RING_SIZE(NvSub3D, 0x02b4, 1);
-       OUT_RING(0);
-
-       BEGIN_RING_CACHE(NvSub3D,
-             NV10_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(0), 1);
-        OUT_RING_CACHE(((w+x-1) << 16) | x | 0x08000800);
-       BEGIN_RING_CACHE(NvSub3D,
-             NV10_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_VERT(0), 1);
-        OUT_RING_CACHE(((h+y-1) << 16) | y | 0x08000800);
-       for (i=1; i<8; i++) {
-               BEGIN_RING_CACHE(NvSub3D,
-                     NV10_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(i), 1);
-               OUT_RING_CACHE(0);
-               BEGIN_RING_CACHE(NvSub3D,
-                     NV10_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_VERT(i), 1);
-               OUT_RING_CACHE(0);
-       }
-
-       nv10ViewportScale(nmesa);
-}
-
-/* Initialise any card-specific non-GL related state */
-static GLboolean nv10InitCard(nouveauContextPtr nmesa)
-{
-       nouveauObjectOnSubchannel(nmesa, NvSub3D, Nv3D);
-
-       BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_SET_DMA_IN_MEMORY0, 2);
-       OUT_RING(NvDmaFB);      /* 184 dma_in_memory0 */
-       OUT_RING(NvDmaFB);      /* 188 dma_in_memory1 */
-       BEGIN_RING_SIZE(NvSub3D, NV10_TCL_PRIMITIVE_3D_SET_DMA_IN_MEMORY2, 2);
-       OUT_RING(NvDmaFB);      /* 194 dma_in_memory2 */
-       OUT_RING(NvDmaFB);      /* 198 dma_in_memory3 */
-
-       BEGIN_RING_SIZE(NvSub3D, 0x0290, 1);
-       OUT_RING(0x00100001);
-       BEGIN_RING_SIZE(NvSub3D, 0x03f4, 1);
-       OUT_RING(0);
-
-       if (nmesa->screen->card->type >= NV_11) {
-               BEGIN_RING_SIZE(NvSub3D, 0x120, 3);
-               OUT_RING(0);
-               OUT_RING(1);
-               OUT_RING(2);
-       }
-
-       return GL_TRUE;
-}
-
-/* Update buffer offset/pitch/format */
-static GLboolean nv10BindBuffers(nouveauContextPtr nmesa, int num_color,
-                                nouveau_renderbuffer **color,
-                                nouveau_renderbuffer *depth)
-{
-       GLuint x, y, w, h;
-       GLuint pitch, format, depth_pitch;
-
-       w = color[0]->mesa.Width;
-       h = color[0]->mesa.Height;
-       x = nmesa->drawX;
-       y = nmesa->drawY;
-
-       if (num_color != 1)
-               return GL_FALSE;
-
-        BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_HORIZ, 6);
-        OUT_RING_CACHE((w << 16) | x);
-        OUT_RING_CACHE((h << 16) | y);
-       depth_pitch = (depth ? depth->pitch : color[0]->pitch);
-       pitch = (depth_pitch<<16) | color[0]->pitch;
-       format = 0x108;
-       if (color[0]->mesa._ActualFormat != GL_RGBA8) {
-               format = 0x103; /* R5G6B5 color buffer */
-       }
-       OUT_RING_CACHE(format);
-       OUT_RING_CACHE(pitch);
-       OUT_RING_CACHE(color[0]->offset);
-       OUT_RING_CACHE(depth ? depth->offset : color[0]->offset);
-
-       /* Always set to bottom left of buffer */
-       /*BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_X, 4);
-       OUT_RING_CACHEf (0.0);
-       OUT_RING_CACHEf ((GLfloat) h);
-       OUT_RING_CACHEf (0.0);
-       OUT_RING_CACHEf (0.0);*/
-
-       return GL_TRUE;
-}
-
-void nv10InitStateFuncs(GLcontext *ctx, struct dd_function_table *func)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       func->AlphaFunc                 = nv10AlphaFunc;
-       func->BlendColor                = nv10BlendColor;
-       func->BlendEquationSeparate     = nv10BlendEquationSeparate;
-       func->BlendFuncSeparate         = nv10BlendFuncSeparate;
-       func->Clear                     = nv10Clear;
-       func->ClearColor                = nv10ClearColor;
-       func->ClearDepth                = nv10ClearDepth;
-       func->ClearStencil              = nv10ClearStencil;
-       func->ClipPlane                 = nv10ClipPlane;
-       func->ColorMask                 = nv10ColorMask;
-       func->ColorMaterial             = nv10ColorMaterial;
-       func->CullFace                  = nv10CullFace;
-       func->FrontFace                 = nv10FrontFace;
-       func->DepthFunc                 = nv10DepthFunc;
-       func->DepthMask                 = nv10DepthMask;
-       func->DepthRange                = nv10DepthRange;
-       func->Enable                    = nv10Enable;
-       func->Fogfv                     = nv10Fogfv;
-       func->Hint                      = nv10Hint;
-       func->Lightfv                   = nv10Lightfv;
-/*     func->LightModelfv              = nv10LightModelfv; */
-       func->LineStipple               = nv10LineStipple;              /* Not for NV10 */
-       func->LineWidth                 = nv10LineWidth;
-       func->LogicOpcode               = nv10LogicOpcode;
-       func->PointParameterfv          = nv10PointParameterfv;
-       func->PointSize                 = nv10PointSize;
-       func->PolygonMode               = nv10PolygonMode;
-       func->PolygonOffset             = nv10PolygonOffset;
-       func->PolygonStipple            = nv10PolygonStipple;           /* Not for NV10 */
-/*     func->ReadBuffer                = nv10ReadBuffer;*/
-/*     func->RenderMode                = nv10RenderMode;*/
-       func->Scissor                   = nv10Scissor;
-       func->ShadeModel                = nv10ShadeModel;
-       func->StencilFuncSeparate       = nv10StencilFuncSeparate;
-       func->StencilMaskSeparate       = nv10StencilMaskSeparate;
-       func->StencilOpSeparate         = nv10StencilOpSeparate;
-/*     func->TexGen                    = nv10TexGen;*/
-/*     func->TexParameter              = nv10TexParameter;*/
-       func->TextureMatrix             = nv10TextureMatrix;
-
-       nmesa->hw_func.InitCard         = nv10InitCard;
-       nmesa->hw_func.BindBuffers      = nv10BindBuffers;
-       nmesa->hw_func.WindowMoved      = nv10WindowMoved;
-}
diff --git a/src/mesa/drivers/dri/nouveau/nv10_swtcl.c b/src/mesa/drivers/dri/nouveau/nv10_swtcl.c
deleted file mode 100644 (file)
index 611469b..0000000
+++ /dev/null
@@ -1,639 +0,0 @@
-/*
- * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
- * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
- * Copyright 2006 Stephane Marchesin. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and 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.
- */
-
-/* Software TCL for NV10, NV20, NV30, NV40, NV50 */
-
-#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 "nouveau_swtcl.h"
-#include "nv10_swtcl.h"
-#include "nouveau_context.h"
-#include "nouveau_span.h"
-#include "nouveau_reg.h"
-#include "nouveau_tex.h"
-#include "nouveau_fifo.h"
-#include "nouveau_msg.h"
-#include "nouveau_object.h"
-
-static void nv10RasterPrimitive( GLcontext *ctx, GLenum rprim, GLuint hwprim );
-static void nv10RenderPrimitive( GLcontext *ctx, GLenum prim );
-static void nv10ResetLineStipple( GLcontext *ctx );
-
-
-
-static inline void nv10StartPrimitive(struct nouveau_context* nmesa,uint32_t primitive,uint32_t size)
-{
-       if ((nmesa->screen->card->type>=NV_10) && (nmesa->screen->card->type<=NV_17))
-               BEGIN_RING_SIZE(NvSub3D,NV10_TCL_PRIMITIVE_3D_BEGIN_END,1);
-       else if (nmesa->screen->card->type==NV_20)
-               BEGIN_RING_SIZE(NvSub3D,NV20_TCL_PRIMITIVE_3D_BEGIN_END,1);
-       else
-               BEGIN_RING_SIZE(NvSub3D,NV30_TCL_PRIMITIVE_3D_BEGIN_END,1);
-       OUT_RING(primitive);
-
-       if ((nmesa->screen->card->type>=NV_10) && (nmesa->screen->card->type<=NV_17))
-               BEGIN_RING_SIZE(NvSub3D,NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_DATA|NONINC_METHOD,size);
-       else if (nmesa->screen->card->type==NV_20)
-               BEGIN_RING_SIZE(NvSub3D,NV20_TCL_PRIMITIVE_3D_VERTEX_DATA|NONINC_METHOD,size);
-       else
-               BEGIN_RING_SIZE(NvSub3D,NV30_TCL_PRIMITIVE_3D_VERTEX_DATA|NONINC_METHOD,size);
-}
-
-inline void nv10FinishPrimitive(struct nouveau_context *nmesa)
-{
-       if ((nmesa->screen->card->type>=NV_10) && (nmesa->screen->card->type<=NV_17))
-               BEGIN_RING_SIZE(NvSub3D,NV10_TCL_PRIMITIVE_3D_BEGIN_END,1);
-       else if (nmesa->screen->card->type==NV_20)
-               BEGIN_RING_SIZE(NvSub3D,NV20_TCL_PRIMITIVE_3D_BEGIN_END,1);
-       else
-               BEGIN_RING_SIZE(NvSub3D,NV30_TCL_PRIMITIVE_3D_BEGIN_END,1);
-       OUT_RING(0x0);
-       FIRE_RING();
-}
-
-
-static inline void nv10ExtendPrimitive(struct nouveau_context* nmesa, int size)
-{
-       /* make sure there's enough room. if not, wait */
-       if (RING_AVAILABLE()<size)
-       {
-               WAIT_RING(nmesa,size);
-       }
-}
-
-/**********************************************************************/
-/*               Render unclipped begin/end objects                   */
-/**********************************************************************/
-
-static inline void nv10_render_generic_primitive_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags,GLuint prim)
-{
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte *vertptr = (GLubyte *)nmesa->verts;
-       GLuint vertsize = nmesa->vertex_size;
-       GLuint size_dword = vertsize*(count-start)/4;
-
-       nv10ExtendPrimitive(nmesa, size_dword);
-       nv10StartPrimitive(nmesa,prim+1,size_dword);
-       OUT_RINGp((nouveauVertex*)(vertptr+(start*vertsize)),size_dword);
-       nv10FinishPrimitive(nmesa);
-}
-
-static void nv10_render_points_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       nv10_render_generic_primitive_verts(ctx,start,count,flags,GL_POINTS);
-}
-
-static void nv10_render_lines_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       nv10_render_generic_primitive_verts(ctx,start,count,flags,GL_LINES);
-}
-
-static void nv10_render_line_strip_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       nv10_render_generic_primitive_verts(ctx,start,count,flags,GL_LINE_STRIP);
-}
-
-static void nv10_render_line_loop_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       nv10_render_generic_primitive_verts(ctx,start,count,flags,GL_LINE_LOOP);
-}
-
-static void nv10_render_triangles_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       nv10_render_generic_primitive_verts(ctx,start,count,flags,GL_TRIANGLES);
-}
-
-static void nv10_render_tri_strip_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       nv10_render_generic_primitive_verts(ctx,start,count,flags,GL_TRIANGLE_STRIP);
-}
-
-static void nv10_render_tri_fan_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       nv10_render_generic_primitive_verts(ctx,start,count,flags,GL_TRIANGLE_FAN);
-}
-
-static void nv10_render_quads_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       nv10_render_generic_primitive_verts(ctx,start,count,flags,GL_QUADS);
-}
-
-static void nv10_render_quad_strip_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       nv10_render_generic_primitive_verts(ctx,start,count,flags,GL_QUAD_STRIP);
-}
-
-static void nv10_render_poly_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       nv10_render_generic_primitive_verts(ctx,start,count,flags,GL_POLYGON);
-}
-
-static void nv10_render_noop_verts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-}
-
-static void (*nv10_render_tab_verts[GL_POLYGON+2])(GLcontext *,
-                                                          GLuint,
-                                                          GLuint,
-                                                          GLuint) =
-{
-   nv10_render_points_verts,
-   nv10_render_lines_verts,
-   nv10_render_line_loop_verts,
-   nv10_render_line_strip_verts,
-   nv10_render_triangles_verts,
-   nv10_render_tri_strip_verts,
-   nv10_render_tri_fan_verts,
-   nv10_render_quads_verts,
-   nv10_render_quad_strip_verts,
-   nv10_render_poly_verts,
-   nv10_render_noop_verts,
-};
-
-
-static inline void nv10_render_generic_primitive_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags,GLuint prim)
-{
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte *vertptr = (GLubyte *)nmesa->verts;
-       GLuint vertsize = nmesa->vertex_size;
-       GLuint size_dword = vertsize*(count-start)/4;
-       const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts;
-       GLuint j;
-
-       nv10ExtendPrimitive(nmesa, size_dword);
-       nv10StartPrimitive(nmesa,prim+1,size_dword);
-       for (j=start; j<count; j++ ) {
-               OUT_RINGp((nouveauVertex*)(vertptr+(elt[j]*vertsize)),vertsize/4);
-       }
-       nv10FinishPrimitive(nmesa);
-}
-
-static void nv10_render_points_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       nv10_render_generic_primitive_elts(ctx,start,count,flags,GL_POINTS);
-}
-
-static void nv10_render_lines_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       nv10_render_generic_primitive_elts(ctx,start,count,flags,GL_LINES);
-}
-
-static void nv10_render_line_strip_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       nv10_render_generic_primitive_elts(ctx,start,count,flags,GL_LINE_STRIP);
-}
-
-static void nv10_render_line_loop_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       nv10_render_generic_primitive_elts(ctx,start,count,flags,GL_LINE_LOOP);
-}
-
-static void nv10_render_triangles_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       nv10_render_generic_primitive_elts(ctx,start,count,flags,GL_TRIANGLES);
-}
-
-static void nv10_render_tri_strip_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       nv10_render_generic_primitive_elts(ctx,start,count,flags,GL_TRIANGLE_STRIP);
-}
-
-static void nv10_render_tri_fan_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       nv10_render_generic_primitive_elts(ctx,start,count,flags,GL_TRIANGLE_FAN);
-}
-
-static void nv10_render_quads_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       nv10_render_generic_primitive_elts(ctx,start,count,flags,GL_QUADS);
-}
-
-static void nv10_render_quad_strip_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       nv10_render_generic_primitive_elts(ctx,start,count,flags,GL_QUAD_STRIP);
-}
-
-static void nv10_render_poly_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-       nv10_render_generic_primitive_elts(ctx,start,count,flags,GL_POLYGON);
-}
-
-static void nv10_render_noop_elts(GLcontext *ctx,GLuint start,GLuint count,GLuint flags)
-{
-}
-
-static void (*nv10_render_tab_elts[GL_POLYGON+2])(GLcontext *,
-                                                          GLuint,
-                                                          GLuint,
-                                                          GLuint) =
-{
-   nv10_render_points_elts,
-   nv10_render_lines_elts,
-   nv10_render_line_loop_elts,
-   nv10_render_line_strip_elts,
-   nv10_render_triangles_elts,
-   nv10_render_tri_strip_elts,
-   nv10_render_tri_fan_elts,
-   nv10_render_quads_elts,
-   nv10_render_quad_strip_elts,
-   nv10_render_poly_elts,
-   nv10_render_noop_elts,
-};
-
-
-/**********************************************************************/
-/*                    Choose render functions                         */
-/**********************************************************************/
-
-
-#define EMIT_ATTR( ATTR, STYLE )                                       \
-do {                                                                   \
-   nmesa->vertex_attrs[nmesa->vertex_attr_count].attrib = (ATTR);      \
-   nmesa->vertex_attrs[nmesa->vertex_attr_count].format = (STYLE);     \
-   nmesa->vertex_attr_count++;                                         \
-} while (0)
-
-static void nv10_render_clipped_line(GLcontext *ctx,GLuint ii,GLuint jj)
-{
-
-}
-
-static void nv10_render_clipped_poly(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;
-       nv10_render_generic_primitive_elts( ctx, 0, n, PRIM_BEGIN|PRIM_END,GL_POLYGON );
-       VB->Elts = tmp;
-}
-
-static inline void nv10_render_points(GLcontext *ctx,GLuint first,GLuint last)
-{
-       WARN_ONCE("Unimplemented\n");
-}
-
-static inline void nv10_render_line(GLcontext *ctx,GLuint v1,GLuint v2)
-{
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte *vertptr = (GLubyte *)nmesa->verts;
-       GLuint vertsize = nmesa->vertex_size;
-       GLuint size_dword = vertsize*(2)/4;
-
-       /* OUT_RINGp wants size in DWORDS */
-       vertsize >>= 2;
-
-       nv10ExtendPrimitive(nmesa, size_dword);
-       nv10StartPrimitive(nmesa,GL_LINES+1,size_dword);
-       OUT_RINGp((nouveauVertex*)(vertptr+(v1*vertsize)),vertsize);
-       OUT_RINGp((nouveauVertex*)(vertptr+(v2*vertsize)),vertsize);
-       nv10FinishPrimitive(nmesa);
-}
-
-static inline void nv10_render_triangle(GLcontext *ctx,GLuint v1,GLuint v2,GLuint v3)
-{
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte *vertptr = (GLubyte *)nmesa->verts;
-       GLuint vertsize = nmesa->vertex_size;
-       GLuint size_dword = vertsize*(3)/4;
-
-       /* OUT_RINGp wants size in DWORDS */
-       vertsize >>= 2;
-
-       nv10ExtendPrimitive(nmesa, size_dword);
-       nv10StartPrimitive(nmesa,GL_TRIANGLES+1,size_dword);
-       OUT_RINGp((nouveauVertex*)(vertptr+(v1*vertsize)),vertsize);
-       OUT_RINGp((nouveauVertex*)(vertptr+(v2*vertsize)),vertsize);
-       OUT_RINGp((nouveauVertex*)(vertptr+(v3*vertsize)),vertsize);
-       nv10FinishPrimitive(nmesa);
-}
-
-static inline void nv10_render_quad(GLcontext *ctx,GLuint v1,GLuint v2,GLuint v3,GLuint v4)
-{
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte *vertptr = (GLubyte *)nmesa->verts;
-       GLuint vertsize = nmesa->vertex_size;
-       GLuint size_dword = vertsize*(4)/4;
-
-       /* OUT_RINGp wants size in DWORDS */
-       vertsize >>= 2;
-
-       nv10ExtendPrimitive(nmesa, size_dword);
-       nv10StartPrimitive(nmesa,GL_QUADS+1,size_dword);
-       OUT_RINGp((nouveauVertex*)(vertptr+(v1*vertsize)),vertsize);
-       OUT_RINGp((nouveauVertex*)(vertptr+(v2*vertsize)),vertsize);
-       OUT_RINGp((nouveauVertex*)(vertptr+(v3*vertsize)),vertsize);
-       OUT_RINGp((nouveauVertex*)(vertptr+(v4*vertsize)),vertsize);
-       nv10FinishPrimitive(nmesa);
-}
-
-
-
-static void nv10ChooseRenderState(GLcontext *ctx)
-{
-       TNLcontext *tnl = TNL_CONTEXT(ctx);
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-
-       tnl->Driver.Render.PrimTabVerts = nv10_render_tab_verts;
-       tnl->Driver.Render.PrimTabElts = nv10_render_tab_elts;
-       tnl->Driver.Render.ClippedLine = nv10_render_clipped_line;
-       tnl->Driver.Render.ClippedPolygon = nv10_render_clipped_poly;
-       tnl->Driver.Render.Points = nv10_render_points;
-       tnl->Driver.Render.Line = nv10_render_line;
-       tnl->Driver.Render.Triangle = nv10_render_triangle;
-       tnl->Driver.Render.Quad = nv10_render_quad;
-}
-
-
-
-static inline void nv10OutputVertexFormat(struct nouveau_context* nmesa)
-{
-       GLcontext* ctx=nmesa->glCtx;
-       TNLcontext *tnl = TNL_CONTEXT(ctx);
-       DECLARE_RENDERINPUTS(index);
-       struct vertex_buffer *VB = &tnl->vb;
-       int attr_size[16];
-       int default_attr_size[8]={3,3,3,4,3,1,4,4};
-       int i;
-       int slots=0;
-       int total_size=0;
-
-       nmesa->vertex_attr_count = 0;
-       RENDERINPUTS_COPY(index, nmesa->render_inputs_bitset);
-
-       /*
-        * Determine attribute sizes
-        */
-       for(i=0;i<8;i++)
-       {
-               if (RENDERINPUTS_TEST(index, i))
-                       attr_size[i]=default_attr_size[i];
-               else
-                       attr_size[i]=0;
-       }
-       for(i=8;i<16;i++)
-       {
-               if (RENDERINPUTS_TEST(index, i))
-                       attr_size[i]=VB->TexCoordPtr[i-8]->size;
-               else
-                       attr_size[i]=0;
-       }
-
-       /*
-        * Tell t_vertex about the vertex format
-        */
-       for(i=0;i<16;i++)
-       {
-               if (RENDERINPUTS_TEST(index, i))
-               {
-                       slots=i+1;
-                       switch(attr_size[i])
-                       {
-                               case 1:
-                                       EMIT_ATTR(i,EMIT_1F);
-                                       break;
-                               case 2:
-                                       EMIT_ATTR(i,EMIT_2F);
-                                       break;
-                               case 3:
-                                       EMIT_ATTR(i,EMIT_3F);
-                                       break;
-                               case 4:
-                                       EMIT_ATTR(i,EMIT_4F);
-                                       break;
-                       }
-                       if (i==_TNL_ATTRIB_COLOR0)
-                               nmesa->color_offset=total_size;
-                       if (i==_TNL_ATTRIB_COLOR1)
-                               nmesa->specular_offset=total_size;
-                       total_size+=attr_size[i];
-               }
-       }
-
-       nmesa->vertex_size=_tnl_install_attrs( ctx,
-                       nmesa->vertex_attrs, 
-                       nmesa->vertex_attr_count,
-                       NULL, 0 );
-       assert(nmesa->vertex_size==total_size*4);
-
-       /* 
-        * Tell the hardware about the vertex format
-        */
-       if ((nmesa->screen->card->type>=NV_10) && (nmesa->screen->card->type<=NV_17)) {
-               int size;
-
-#define NV_VERTEX_ATTRIBUTE_TYPE_FLOAT 2
-
-#define NV10_SET_VERTEX_ATTRIB(i,j) \
-       do {    \
-               size = attr_size[j] << 4;       \
-               size |= (attr_size[j]*4) << 8;  \
-               size |= NV_VERTEX_ATTRIBUTE_TYPE_FLOAT; \
-               BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VERTEX_ATTR(i),1);      \
-               OUT_RING_CACHE(size);   \
-       } while (0)
-
-               NV10_SET_VERTEX_ATTRIB(0, _TNL_ATTRIB_POS);
-               NV10_SET_VERTEX_ATTRIB(1, _TNL_ATTRIB_COLOR0);
-               NV10_SET_VERTEX_ATTRIB(2, _TNL_ATTRIB_COLOR1);
-               NV10_SET_VERTEX_ATTRIB(3, _TNL_ATTRIB_TEX0);
-               NV10_SET_VERTEX_ATTRIB(4, _TNL_ATTRIB_TEX1);
-               NV10_SET_VERTEX_ATTRIB(5, _TNL_ATTRIB_NORMAL);
-               NV10_SET_VERTEX_ATTRIB(6, _TNL_ATTRIB_WEIGHT);
-               NV10_SET_VERTEX_ATTRIB(7, _TNL_ATTRIB_FOG);
-
-               BEGIN_RING_CACHE(NvSub3D, NV10_TCL_PRIMITIVE_3D_VERTEX_ARRAY_VALIDATE,1);
-               OUT_RING_CACHE(0);
-       } else if (nmesa->screen->card->type==NV_20) {
-               for(i=0;i<16;i++)
-               {
-                       int size=attr_size[i];
-                       BEGIN_RING_CACHE(NvSub3D,NV20_TCL_PRIMITIVE_3D_VERTEX_ATTR(i),1);
-                       OUT_RING_CACHE(NV_VERTEX_ATTRIBUTE_TYPE_FLOAT|(size*0x10));
-               }
-       } else {
-               BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_DO_VERTICES, 1);
-               OUT_RING(0);
-               BEGIN_RING_CACHE(NvSub3D,NV30_TCL_PRIMITIVE_3D_VERTEX_ATTR0_POS,slots);
-               for(i=0;i<slots;i++)
-               {
-                       int size=attr_size[i];
-                       OUT_RING_CACHE(NV_VERTEX_ATTRIBUTE_TYPE_FLOAT|(size*0x10));
-               }
-               // FIXME this is probably not needed
-               BEGIN_RING_SIZE(NvSub3D,NV30_TCL_PRIMITIVE_3D_VERTEX_UNK_0,1);
-               OUT_RING(0);
-               BEGIN_RING_SIZE(NvSub3D,NV30_TCL_PRIMITIVE_3D_VERTEX_UNK_0,1);
-               OUT_RING(0);
-               BEGIN_RING_SIZE(NvSub3D,NV30_TCL_PRIMITIVE_3D_VERTEX_UNK_0,1);
-               OUT_RING(0);
-       }
-}
-
-
-static void nv10ChooseVertexState( GLcontext *ctx )
-{
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-       TNLcontext *tnl = TNL_CONTEXT(ctx);
-       DECLARE_RENDERINPUTS(index);
-       
-       RENDERINPUTS_COPY(index, tnl->render_inputs_bitset);
-       if (!RENDERINPUTS_EQUAL(index, nmesa->render_inputs_bitset))
-       {
-               RENDERINPUTS_COPY(nmesa->render_inputs_bitset, index);
-               nv10OutputVertexFormat(nmesa);
-       }
-
-       if (nmesa->screen->card->type == NV_30) {
-               nouveauShader *fp;
-               
-               if (ctx->FragmentProgram.Enabled) {
-                       fp = (nouveauShader *) ctx->FragmentProgram.Current;
-                       nvsUpdateShader(ctx, fp);
-               } else
-                       nvsUpdateShader(ctx, nmesa->passthrough_fp);
-       }
-
-       if (nmesa->screen->card->type >= NV_40) {
-               /* Ensure passthrough shader is being used, and mvp matrix
-                * is up to date
-                */
-               nvsUpdateShader(ctx, nmesa->passthrough_vp);
-
-               /* Update texenv shader / user fragprog */
-               nvsUpdateShader(ctx, (nouveauShader*)ctx->FragmentProgram._Current);
-       }
-}
-
-
-/**********************************************************************/
-/*                 High level hooks for t_vb_render.c                 */
-/**********************************************************************/
-
-
-static void nv10RenderStart(GLcontext *ctx)
-{
-       TNLcontext *tnl = TNL_CONTEXT(ctx);
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-
-       if (nmesa->new_state) {
-               nmesa->new_render_state |= nmesa->new_state;
-       }
-
-       if (nmesa->new_render_state) {
-               nv10ChooseVertexState(ctx);
-               nv10ChooseRenderState(ctx);
-               nmesa->new_render_state = 0;
-       }
-}
-
-static void nv10RenderFinish(GLcontext *ctx)
-{
-}
-
-
-/* System to flush dma and emit state changes based on the rasterized
- * primitive.
- */
-void nv10RasterPrimitive(GLcontext *ctx,
-               GLenum glprim,
-               GLuint hwprim)
-{
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-
-       assert (!nmesa->new_state);
-
-       if (hwprim != nmesa->current_primitive)
-       {
-               nmesa->current_primitive=hwprim;
-               
-       }
-}
-
-static const GLuint hw_prim[GL_POLYGON+1] = {
-       GL_POINTS+1,
-       GL_LINES+1,
-       GL_LINE_STRIP+1,
-       GL_LINE_LOOP+1,
-       GL_TRIANGLES+1,
-       GL_TRIANGLE_STRIP+1,
-       GL_TRIANGLE_FAN+1,
-       GL_QUADS+1,
-       GL_QUAD_STRIP+1,
-       GL_POLYGON+1
-};
-
-/* Callback for mesa:
- */
-static void nv10RenderPrimitive( GLcontext *ctx, GLuint prim )
-{
-       nv10RasterPrimitive( ctx, prim, hw_prim[prim] );
-}
-
-static void nv10ResetLineStipple( GLcontext *ctx )
-{
-       /* FIXME do something here */
-       WARN_ONCE("Unimplemented nv10ResetLineStipple\n");
-}
-
-
-/**********************************************************************/
-/*                            Initialization.                         */
-/**********************************************************************/
-
-void nv10TriInitFunctions(GLcontext *ctx)
-{
-       struct nouveau_context *nmesa = NOUVEAU_CONTEXT(ctx);
-       TNLcontext *tnl = TNL_CONTEXT(ctx);
-
-       tnl->Driver.RunPipeline = nouveauRunPipeline;
-       tnl->Driver.Render.Start = nv10RenderStart;
-       tnl->Driver.Render.Finish = nv10RenderFinish;
-       tnl->Driver.Render.PrimitiveNotify = nv10RenderPrimitive;
-       tnl->Driver.Render.ResetLineStipple = nv10ResetLineStipple;
-       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, 
-                       64 * sizeof(GLfloat) );
-
-       nmesa->verts = (GLubyte *)tnl->clipspace.vertex_buf;
-}
-
-
diff --git a/src/mesa/drivers/dri/nouveau/nv10_swtcl.h b/src/mesa/drivers/dri/nouveau/nv10_swtcl.h
deleted file mode 100644 (file)
index 7c854ad..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/**************************************************************************
-
-Copyright 2006 Stephane Marchesin
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-
-
-#ifndef __NV10_SWTCL_H__
-#define __NV10_SWTCL_H__
-
-#include "mtypes.h"
-
-extern void nv10Fallback( GLcontext *ctx, GLuint bit, GLboolean mode );
-extern void nv10FinishPrimitive(struct nouveau_context *nmesa);
-extern void nv10TriInitFunctions(GLcontext *ctx);
-#define FALLBACK( nmesa, bit, mode ) nouveauFallback( nmesa->glCtx, bit, mode )
-
-#endif /* __NV10_SWTCL_H__ */
-
diff --git a/src/mesa/drivers/dri/nouveau/nv20_shader.h b/src/mesa/drivers/dri/nouveau/nv20_shader.h
deleted file mode 100644 (file)
index 7d2e29d..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/* NV20_TCL_PRIMITIVE_3D_0x0B00 */
-#define NV20_VP_INST_0B00      0x00000000 /* always 0? */
-#define NV20_VP_INST0_KNOWN    0
-
-/* NV20_TCL_PRIMITIVE_3D_0x0B04 */
-#define NV20_VP_INST_SCA_OPCODE_SHIFT                          25
-#define NV20_VP_INST_SCA_OPCODE_MASK                           (0x0F << 25)
-#define NV20_VP_INST_OPCODE_RCP        0x2
-#define NV20_VP_INST_OPCODE_RCC        0x3
-#define NV20_VP_INST_OPCODE_RSQ        0x4
-#define NV20_VP_INST_OPCODE_EXP        0x5
-#define NV20_VP_INST_OPCODE_LOG        0x6
-#define NV20_VP_INST_OPCODE_LIT        0x7
-#define NV20_VP_INST_VEC_OPCODE_SHIFT                          21
-#define NV20_VP_INST_VEC_OPCODE_MASK                           (0x0F << 21)
-#define NV20_VP_INST_OPCODE_NOP        0x0 /* guess */
-#define NV20_VP_INST_OPCODE_MOV        0x1
-#define NV20_VP_INST_OPCODE_MUL        0x2
-#define NV20_VP_INST_OPCODE_ADD        0x3
-#define NV20_VP_INST_OPCODE_MAD        0x4
-#define NV20_VP_INST_OPCODE_DP3        0x5
-#define NV20_VP_INST_OPCODE_DPH        0x6
-#define NV20_VP_INST_OPCODE_DP4        0x7
-#define NV20_VP_INST_OPCODE_DST        0x8
-#define NV20_VP_INST_OPCODE_MIN        0x9
-#define NV20_VP_INST_OPCODE_MAX        0xA
-#define NV20_VP_INST_OPCODE_SLT        0xB
-#define NV20_VP_INST_OPCODE_SGE        0xC
-#define NV20_VP_INST_OPCODE_ARL        0xD
-#define NV20_VP_INST_CONST_SRC_SHIFT                           13
-#define NV20_VP_INST_CONST_SRC_MASK                            (0xFF << 13)
-#define NV20_VP_INST_INPUT_SRC_SHIFT                           9
-#define NV20_VP_INST_INPUT_SRC_MASK                            (0xF << 9) /* guess */
-#define NV20_VP_INST_INPUT_SRC_POS     0
-#define NV20_VP_INST_INPUT_SRC_COL0    3
-#define NV20_VP_INST_INPUT_SRC_COL1    4
-#define NV20_VP_INST_INPUT_SRC_TC(n)   (9+n)
-#define NV20_VP_INST_SRC0H_SHIFT                               0
-#define NV20_VP_INST_SRC0H_MASK                                        (0x1FF << 0)
-#define NV20_VP_INST1_KNOWN    ( \
-       NV20_VP_INST_OPCODE_MASK | \
-       NV20_VP_INST_CONST_SRC_MASK | \
-       NV20_VP_INST_INPUT_SRC_MASK | \
-       NV20_VP_INST_SRC0H_MASK \
-       )
-
-/* NV20_TCL_PRIMITIVE_3D_0x0B08 */
-#define NV20_VP_INST_SRC0L_SHIFT                               26
-#define NV20_VP_INST_SRC0L_MASK                                        (0x3F  <<26)
-#define NV20_VP_INST_SRC1_SHIFT                                        11
-#define NV20_VP_INST_SRC1_MASK                                 (0x7FFF<<11)
-#define NV20_VP_INST_SRC2H_SHIFT                               0
-#define NV20_VP_INST_SRC2H_MASK                                        (0x7FF << 0)
-
-/* NV20_TCL_PRIMITIVE_3D_0x0B0C */
-#define NV20_VP_INST_SRC2L_SHIFT                               28
-#define NV20_VP_INST_SRC2L_MASK                                        (0x0F  <<28)
-#define NV20_VP_INST_VTEMP_WRITEMASK_SHIFT                     24
-#define NV20_VP_INST_VTEMP_WRITEMASK_MASK                      (0x0F  <<24)
-#    define NV20_VP_INST_TEMP_WRITEMASK_X      (1<<27)
-#    define NV20_VP_INST_TEMP_WRITEMASK_Y      (1<<26)
-#    define NV20_VP_INST_TEMP_WRITEMASK_Z      (1<<25)
-#    define NV20_VP_INST_TEMP_WRITEMASK_W      (1<<24)
-#define NV20_VP_INST_DEST_TEMP_ID_SHIFT                                20
-#define NV20_VP_INST_DEST_TEMP_ID_MASK                         (0x0F  <<20)
-#define NV20_VP_INST_STEMP_WRITEMASK_SHIFT                     16
-#define NV20_VP_INST_STEMP_WRITEMASK_MASK                      (0x0F  <<16)
-#    define NV20_VP_INST_STEMP_WRITEMASK_X     (1<<19)
-#    define NV20_VP_INST_STEMP_WRITEMASK_Y     (1<<18)
-#    define NV20_VP_INST_STEMP_WRITEMASK_Z     (1<<17)
-#    define NV20_VP_INST_STEMP_WRITEMASK_W     (1<<16)
-#define NV20_VP_INST_DEST_WRITEMASK_SHIFT                      12
-#define NV20_VP_INST_DEST_WRITEMASK_MASK                       (0x0F  <<12)
-#    define NV20_VP_INST_DEST_WRITEMASK_X      (1<<15)
-#    define NV20_VP_INST_DEST_WRITEMASK_Y      (1<<14)
-#    define NV20_VP_INST_DEST_WRITEMASK_Z      (1<<13)
-#    define NV20_VP_INST_DEST_WRITEMASK_W      (1<<12)
-#define NV20_VP_INST_DEST_SHIFT                                        3
-#define NV20_VP_INST_DEST_MASK                                 (0xF << 3) /* guess */
-#define NV20_VP_INST_DEST_POS  0
-#define NV20_VP_INST_DEST_COL0 3
-#define NV20_VP_INST_DEST_COL1 4
-#define NV20_VP_INST_DEST_TC(n)        (9+n)
-#define NV20_VP_INST_INDEX_CONST                               (1<<1)
-#define NV20_VP_INST3_KNOWN ( \
-       NV20_VP_INST_SRC2L_MASK | \
-       NV20_VP_INST_TEMP_WRITEMASK_MASK | \
-       NV20_VP_INST_DEST_TEMP_ID_MASK | \
-       NV20_VP_INST_STEMP_WRITEMASK_MASK | \
-       NV20_VP_INST_DEST_WRITEMASK_MASK | \
-       NV20_VP_INST_DEST_MASK | \
-       NV20_VP_INST_INDEX_CONST \
-       )
-
-/* Useful to split the source selection regs into their pieces */
-#define NV20_VP_SRC0_HIGH_SHIFT 6
-#define NV20_VP_SRC0_HIGH_MASK  0x00007FC0
-#define NV20_VP_SRC0_LOW_MASK   0x0000003F
-#define NV20_VP_SRC2_HIGH_SHIFT 4
-#define NV20_VP_SRC2_HIGH_MASK  0x00007FF0
-#define NV20_VP_SRC2_LOW_MASK   0x0000000F
-
-#define NV20_VP_SRC_REG_NEGATE                                 (1<<14)
-#define NV20_VP_SRC_REG_SWZ_X_SHIFT                            12
-#define NV20_VP_SRC_REG_SWZ_X_MASK                             (0x03  <<12)
-#define NV20_VP_SRC_REG_SWZ_Y_SHIFT                            10
-#define NV20_VP_SRC_REG_SWZ_Y_MASK                             (0x03  <<10)
-#define NV20_VP_SRC_REG_SWZ_Z_SHIFT                            8
-#define NV20_VP_SRC_REG_SWZ_Z_MASK                             (0x03  << 8)
-#define NV20_VP_SRC_REG_SWZ_W_SHIFT                            6
-#define NV20_VP_SRC_REG_SWZ_W_MASK                             (0x03  << 6)
-#define NV20_VP_SRC_REG_SWZ_ALL_SHIFT                          6
-#define NV20_VP_SRC_REG_SWZ_ALL_MASK                           (0xFF  << 6)
-#define NV20_VP_SRC_REG_TEMP_ID_SHIFT                          2
-#define NV20_VP_SRC_REG_TEMP_ID_MASK                           (0x0F  << 0)
-#define NV20_VP_SRC_REG_TYPE_SHIFT                             0
-#define NV20_VP_SRC_REG_TYPE_MASK                              (0x03  << 0)
-#define NV20_VP_SRC_REG_TYPE_TEMP      1
-#define NV20_VP_SRC_REG_TYPE_INPUT     2
-#define NV20_VP_SRC_REG_TYPE_CONST     3       /* guess */
-
diff --git a/src/mesa/drivers/dri/nouveau/nv20_state.c b/src/mesa/drivers/dri/nouveau/nv20_state.c
deleted file mode 100644 (file)
index ccf2f61..0000000
+++ /dev/null
@@ -1,824 +0,0 @@
-/**************************************************************************
-
-Copyright 2006 Nouveau
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-#include "nouveau_context.h"
-#include "nouveau_object.h"
-#include "nouveau_fifo.h"
-#include "nouveau_reg.h"
-
-#include "tnl/t_pipeline.h"
-
-#include "mtypes.h"
-#include "colormac.h"
-
-static void nv20AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte ubRef;
-       CLAMPED_FLOAT_TO_UBYTE(ubRef, ref);
-
-       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_ALPHA_FUNC_FUNC, 2);
-       OUT_RING_CACHE(func);
-       OUT_RING_CACHE(ubRef);
-}
-
-static void nv20BlendColor(GLcontext *ctx, const GLfloat color[4])
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); 
-       GLubyte cf[4];
-
-       CLAMPED_FLOAT_TO_UBYTE(cf[0], color[0]);
-       CLAMPED_FLOAT_TO_UBYTE(cf[1], color[1]);
-       CLAMPED_FLOAT_TO_UBYTE(cf[2], color[2]);
-       CLAMPED_FLOAT_TO_UBYTE(cf[3], color[3]);
-
-       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_BLEND_COLOR, 1);
-       OUT_RING_CACHE(PACK_COLOR_8888(cf[3], cf[1], cf[2], cf[0]));
-}
-
-static void nv20BlendEquationSeparate(GLcontext *ctx, GLenum modeRGB, GLenum modeA)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_BLEND_EQUATION, 1);
-       OUT_RING_CACHE((modeA<<16) | modeRGB);
-}
-
-
-static void nv20BlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB, GLenum dfactorRGB,
-               GLenum sfactorA, GLenum dfactorA)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_BLEND_FUNC_SRC, 2);
-       OUT_RING_CACHE((sfactorA<<16) | sfactorRGB);
-       OUT_RING_CACHE((dfactorA<<16) | dfactorRGB);
-}
-
-static void nv20Clear(GLcontext *ctx, GLbitfield mask)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       GLuint hw_bufs = 0;
-
-       if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT))
-               hw_bufs |= 0xf0;
-       if (mask & (BUFFER_BIT_DEPTH))
-               hw_bufs |= 0x03;
-
-       if (hw_bufs) {
-               BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_CLEAR_WHICH_BUFFERS, 1);
-               OUT_RING_CACHE(hw_bufs);
-       }
-}
-
-static void nv20ClearColor(GLcontext *ctx, const GLfloat color[4])
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte c[4];
-       UNCLAMPED_FLOAT_TO_RGBA_CHAN(c,color);
-       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_CLEAR_VALUE_ARGB, 1);
-       OUT_RING_CACHE(PACK_COLOR_8888(c[3],c[0],c[1],c[2]));
-}
-
-static void nv20ClearDepth(GLcontext *ctx, GLclampd d)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       nmesa->clear_value=((nmesa->clear_value&0x000000FF)|(((uint32_t)(d*0xFFFFFF))<<8));
-       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_CLEAR_VALUE_DEPTH, 1);
-       OUT_RING_CACHE(nmesa->clear_value);
-}
-
-/* we're don't support indexed buffers
-   void (*ClearIndex)(GLcontext *ctx, GLuint index)
- */
-
-static void nv20ClearStencil(GLcontext *ctx, GLint s)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       nmesa->clear_value=((nmesa->clear_value&0xFFFFFF00)|(s&0x000000FF));
-       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_CLEAR_VALUE_DEPTH, 1);
-       OUT_RING_CACHE(nmesa->clear_value);
-}
-
-static void nv20ClipPlane(GLcontext *ctx, GLenum plane, const GLfloat *equation)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_CLIP_PLANE_A(plane), 4);
-       OUT_RING_CACHEf(equation[0]);
-       OUT_RING_CACHEf(equation[1]);
-       OUT_RING_CACHEf(equation[2]);
-       OUT_RING_CACHEf(equation[3]);
-}
-
-static void nv20ColorMask(GLcontext *ctx, GLboolean rmask, GLboolean gmask,
-               GLboolean bmask, GLboolean amask )
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_COLOR_MASK, 1);
-       OUT_RING_CACHE(((amask && 0x01) << 24) | ((rmask && 0x01) << 16) | ((gmask && 0x01)<< 8) | ((bmask && 0x01) << 0));
-}
-
-static void nv20ColorMaterial(GLcontext *ctx, GLenum face, GLenum mode)
-{
-       // TODO I need love
-}
-
-static void nv20CullFace(GLcontext *ctx, GLenum mode)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_CULL_FACE, 1);
-       OUT_RING_CACHE(mode);
-}
-
-static void nv20FrontFace(GLcontext *ctx, GLenum mode)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_FRONT_FACE, 1);
-       OUT_RING_CACHE(mode);
-}
-
-static void nv20DepthFunc(GLcontext *ctx, GLenum func)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_DEPTH_FUNC, 1);
-       OUT_RING_CACHE(func);
-}
-
-static void nv20DepthMask(GLcontext *ctx, GLboolean flag)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_DEPTH_WRITE_ENABLE, 1);
-       OUT_RING_CACHE(flag);
-}
-
-static void nv20DepthRange(GLcontext *ctx, GLclampd nearval, GLclampd farval)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_DEPTH_RANGE_NEAR, 2);
-       OUT_RING_CACHEf(nearval);
-       OUT_RING_CACHEf(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 );
-
-static void nv20Enable(GLcontext *ctx, GLenum cap, GLboolean state)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       switch(cap)
-       {
-               case GL_ALPHA_TEST:
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_ALPHA_FUNC_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_AUTO_NORMAL:
-               case GL_BLEND:
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_BLEND_FUNC_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       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:
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_CLIP_PLANE_ENABLE(cap-GL_CLIP_PLANE0), 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_COLOR_LOGIC_OP:
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_COLOR_LOGIC_OP_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_COLOR_MATERIAL:
-//             case GL_COLOR_SUM_EXT:
-//             case GL_COLOR_TABLE:
-//             case GL_CONVOLUTION_1D:
-//             case GL_CONVOLUTION_2D:
-               case GL_CULL_FACE:
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_CULL_FACE_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_DEPTH_TEST:
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_DEPTH_TEST_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_DITHER:
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_DITHER_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_FOG:
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_FOG_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_HISTOGRAM:
-//             case GL_INDEX_LOGIC_OP:
-               case GL_LIGHT0:
-               case GL_LIGHT1:
-               case GL_LIGHT2:
-               case GL_LIGHT3:
-               case GL_LIGHT4:
-               case GL_LIGHT5:
-               case GL_LIGHT6:
-               case GL_LIGHT7:
-                       {
-                       uint32_t mask=0x11<<(2*(cap-GL_LIGHT0));
-                       nmesa->enabled_lights=((nmesa->enabled_lights&mask)|(mask*state));
-                       if (nmesa->lighting_enabled)
-                       {
-                               BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_ENABLED_LIGHTS, 1);
-                               OUT_RING_CACHE(nmesa->enabled_lights);
-                       }
-                       break;
-                       }
-               case GL_LIGHTING:
-                       nmesa->lighting_enabled=state;
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_ENABLED_LIGHTS, 1);
-                       if (nmesa->lighting_enabled)
-                               OUT_RING_CACHE(nmesa->enabled_lights);
-                       else
-                               OUT_RING_CACHE(0x0);
-                       break;
-               case GL_LINE_SMOOTH:
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_LINE_SMOOTH_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_LINE_STIPPLE:
-//             case GL_MAP1_COLOR_4:
-//             case GL_MAP1_INDEX:
-//             case GL_MAP1_NORMAL:
-//             case GL_MAP1_TEXTURE_COORD_1:
-//             case GL_MAP1_TEXTURE_COORD_2:
-//             case GL_MAP1_TEXTURE_COORD_3:
-//             case GL_MAP1_TEXTURE_COORD_4:
-//             case GL_MAP1_VERTEX_3:
-//             case GL_MAP1_VERTEX_4:
-//             case GL_MAP2_COLOR_4:
-//             case GL_MAP2_INDEX:
-//             case GL_MAP2_NORMAL:
-//             case GL_MAP2_TEXTURE_COORD_1:
-//             case GL_MAP2_TEXTURE_COORD_2:
-//             case GL_MAP2_TEXTURE_COORD_3:
-//             case GL_MAP2_TEXTURE_COORD_4:
-//             case GL_MAP2_VERTEX_3:
-//             case GL_MAP2_VERTEX_4:
-//             case GL_MINMAX:
-               case GL_NORMALIZE:
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_NORMALIZE_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_POINT_SMOOTH:
-               case GL_POLYGON_OFFSET_POINT:
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_POLYGON_OFFSET_POINT_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_POLYGON_OFFSET_LINE:
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_POLYGON_OFFSET_LINE_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_POLYGON_OFFSET_FILL:
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_POLYGON_OFFSET_FILL_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_POLYGON_SMOOTH:
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_POLYGON_SMOOTH_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_POLYGON_STIPPLE:
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_POLYGON_STIPPLE_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_POST_COLOR_MATRIX_COLOR_TABLE:
-//             case GL_POST_CONVOLUTION_COLOR_TABLE:
-//             case GL_RESCALE_NORMAL:
-               case GL_SCISSOR_TEST:
-                       /* No enable bit, nv20Scissor will adjust to max range */
-                       ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
-                                                ctx->Scissor.Width, ctx->Scissor.Height);
-                       break;
-//             case GL_SEPARABLE_2D:
-               case GL_STENCIL_TEST:
-                       // TODO BACK and FRONT ?
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_STENCIL_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_TEXTURE_GEN_Q:
-//             case GL_TEXTURE_GEN_R:
-//             case GL_TEXTURE_GEN_S:
-//             case GL_TEXTURE_GEN_T:
-//             case GL_TEXTURE_1D:
-//             case GL_TEXTURE_2D:
-//             case GL_TEXTURE_3D:
-       }
-}
-
-static void nv20Fogfv(GLcontext *ctx, GLenum pname, const GLfloat *params)
-{
-    nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-    switch(pname)
-    {
-        case GL_FOG_MODE:
-            BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_FOG_MODE, 1);
-            //OUT_RING_CACHE (params);
-            break;
-            /* TODO: unsure about the rest.*/
-        default:
-            break;
-    }
-
-}
-   
-static void nv20Hint(GLcontext *ctx, GLenum target, GLenum mode)
-{
-       // TODO I need love (fog and line_smooth hints)
-}
-
-// void (*IndexMask)(GLcontext *ctx, GLuint mask);
-
-enum {
-       SPOTLIGHT_NO_UPDATE,
-       SPOTLIGHT_UPDATE_EXPONENT,
-       SPOTLIGHT_UPDATE_DIRECTION,
-       SPOTLIGHT_UPDATE_ALL
-};
-
-static void nv20Lightfv(GLcontext *ctx, GLenum light, GLenum pname, const GLfloat *params )
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       GLint p = light - GL_LIGHT0;
-       struct gl_light *l = &ctx->Light.Light[p];
-       int spotlight_update = SPOTLIGHT_NO_UPDATE;
-
-       /* not sure where the fourth param value goes...*/
-       switch(pname)
-       {
-               case GL_AMBIENT:
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_AMBIENT_R(p), 3);
-                       OUT_RING_CACHEf(params[0]);
-                       OUT_RING_CACHEf(params[1]);
-                       OUT_RING_CACHEf(params[2]);
-                       break;
-               case GL_DIFFUSE:
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_DIFFUSE_R(p), 3);
-                       OUT_RING_CACHEf(params[0]);
-                       OUT_RING_CACHEf(params[1]);
-                       OUT_RING_CACHEf(params[2]);
-                       break;
-               case GL_SPECULAR:
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_SPECULAR_R(p), 3);
-                       OUT_RING_CACHEf(params[0]);
-                       OUT_RING_CACHEf(params[1]);
-                       OUT_RING_CACHEf(params[2]);
-                       break;
-               case GL_POSITION:
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_LIGHT_POSITION_X(p), 3);
-                       OUT_RING_CACHEf(params[0]);
-                       OUT_RING_CACHEf(params[1]);
-                       OUT_RING_CACHEf(params[2]);
-                       break;
-               case GL_SPOT_DIRECTION:
-                       spotlight_update = SPOTLIGHT_UPDATE_DIRECTION;
-                       break;
-               case GL_SPOT_EXPONENT:
-                       spotlight_update = SPOTLIGHT_UPDATE_EXPONENT;
-                       break;
-               case GL_SPOT_CUTOFF:
-                       spotlight_update = SPOTLIGHT_UPDATE_ALL;
-                       break;
-               case GL_CONSTANT_ATTENUATION:
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_LIGHT_CONSTANT_ATTENUATION(p), 1);
-                       OUT_RING_CACHEf(*params);
-                       break;
-               case GL_LINEAR_ATTENUATION:
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_LIGHT_LINEAR_ATTENUATION(p), 1);
-                       OUT_RING_CACHEf(*params);
-                       break;
-               case GL_QUADRATIC_ATTENUATION:
-                       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_LIGHT_QUADRATIC_ATTENUATION(p), 1);
-                       OUT_RING_CACHEf(*params);
-                       break;
-               default:
-                       break;
-       }
-
-       switch(spotlight_update) {
-               case SPOTLIGHT_UPDATE_DIRECTION:
-                       {
-                               GLfloat x,y,z;
-                               GLfloat spot_light_coef_a = 1.0 / (l->_CosCutoff - 1.0);
-                               x = spot_light_coef_a * l->_NormDirection[0];
-                               y = spot_light_coef_a * l->_NormDirection[1];
-                               z = spot_light_coef_a * l->_NormDirection[2];
-                               BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_LIGHT_SPOT_DIR_X(p), 3);
-                               OUT_RING_CACHEf(x);
-                               OUT_RING_CACHEf(y);
-                               OUT_RING_CACHEf(z);
-                       }
-                       break;
-               case SPOTLIGHT_UPDATE_EXPONENT:
-                       {
-                               GLfloat cc,lc,qc;
-                               cc = 1.0;       /* FIXME: These need to be correctly computed */
-                               lc = 0.0;
-                               qc = 2.0;
-                               BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_LIGHT_SPOT_CUTOFF_A(p), 3);
-                               OUT_RING_CACHEf(cc);
-                               OUT_RING_CACHEf(lc);
-                               OUT_RING_CACHEf(qc);
-                       }
-                       break;
-               case SPOTLIGHT_UPDATE_ALL:
-                       {
-                               GLfloat cc,lc,qc, x,y,z, c;
-                               GLfloat spot_light_coef_a = 1.0 / (l->_CosCutoff - 1.0);
-                               cc = 1.0;       /* FIXME: These need to be correctly computed */
-                               lc = 0.0;
-                               qc = 2.0;
-                               x = spot_light_coef_a * l->_NormDirection[0];
-                               y = spot_light_coef_a * l->_NormDirection[1];
-                               z = spot_light_coef_a * l->_NormDirection[2];
-                               c = spot_light_coef_a + 1.0;
-                               BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_LIGHT_SPOT_CUTOFF_A(p), 7);
-                               OUT_RING_CACHEf(cc);
-                               OUT_RING_CACHEf(lc);
-                               OUT_RING_CACHEf(qc);
-                               OUT_RING_CACHEf(x);
-                               OUT_RING_CACHEf(y);
-                               OUT_RING_CACHEf(z);
-                               OUT_RING_CACHEf(c);
-                       }
-                       break;
-               default:
-                       break;
-       }
-}
-
-/** Set the lighting model parameters */
-static void (*LightModelfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
-
-
-static void nv20LineStipple(GLcontext *ctx, GLint factor, GLushort pattern )
-{
-/*     nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_LINE_STIPPLE_PATTERN, 1);
-       OUT_RING_CACHE((pattern << 16) | factor);*/
-}
-
-static void nv20LineWidth(GLcontext *ctx, GLfloat width)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_LINE_WIDTH, 1);
-       OUT_RING_CACHEf(width);
-}
-
-static void nv20LogicOpcode(GLcontext *ctx, GLenum opcode)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_COLOR_LOGIC_OP_OP, 1);
-       OUT_RING_CACHE(opcode);
-}
-
-static void nv20PointParameterfv(GLcontext *ctx, GLenum pname, const GLfloat *params)
-{
-       /*TODO: not sure what goes here. */
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       
-}
-
-/** Specify the diameter of rasterized points */
-static void nv20PointSize(GLcontext *ctx, GLfloat size)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_POINT_SIZE, 1);
-       OUT_RING_CACHEf(size);
-}
-
-/** Select a polygon rasterization mode */
-static void nv20PolygonMode(GLcontext *ctx, GLenum face, GLenum mode)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
-               BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_POLYGON_MODE_FRONT, 1);
-               OUT_RING_CACHE(mode);
-       }
-       if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
-               BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_POLYGON_MODE_BACK, 1);
-               OUT_RING_CACHE(mode);
-       }
-}
-
-/** Set the scale and units used to calculate depth values */
-static void nv20PolygonOffset(GLcontext *ctx, GLfloat factor, GLfloat units)
-{
-        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-        BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_POLYGON_OFFSET_FACTOR, 2);
-        OUT_RING_CACHEf(factor);
-        OUT_RING_CACHEf(units);
-}
-
-/** Set the polygon stippling pattern */
-static void nv20PolygonStipple(GLcontext *ctx, const GLubyte *mask )
-{
-        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-        BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_POLYGON_STIPPLE_PATTERN(0), 32);
-        OUT_RING_CACHEp(mask, 32);
-}
-
-/* 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 */
-static void nv20Scissor(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
-{
-        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       /* There's no scissor enable bit, so adjust the scissor to cover the
-        * maximum draw buffer bounds
-        */
-       if (!ctx->Scissor.Enabled) {
-          x = y = 0;
-          w = h = 4095;
-       } else {
-          x += nmesa->drawX;
-          y += nmesa->drawY;
-       }
-
-        /*BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_SCISSOR_X2_X1, 1);
-        OUT_RING_CACHE((w << 16) | x );
-        BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_SCISSOR_Y2_Y1, 1);
-        OUT_RING_CACHE((h << 16) | y );*/
-
-}
-
-/** Select flat or smooth shading */
-static void nv20ShadeModel(GLcontext *ctx, GLenum mode)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_SHADE_MODEL, 1);
-       OUT_RING_CACHE(mode);
-}
-
-/** OpenGL 2.0 two-sided StencilFunc */
-static void nv20StencilFuncSeparate(GLcontext *ctx, GLenum face, GLenum func,
-               GLint ref, GLuint mask)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_STENCIL_FUNC_FUNC, 3);
-       OUT_RING_CACHE(func);
-       OUT_RING_CACHE(ref);
-       OUT_RING_CACHE(mask);
-}
-
-/** OpenGL 2.0 two-sided StencilMask */
-static void nv20StencilMaskSeparate(GLcontext *ctx, GLenum face, GLuint mask)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_STENCIL_MASK, 1);
-       OUT_RING_CACHE(mask);
-}
-
-/** OpenGL 2.0 two-sided StencilOp */
-static void nv20StencilOpSeparate(GLcontext *ctx, GLenum face, GLenum fail,
-               GLenum zfail, GLenum zpass)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_STENCIL_OP_FAIL, 1);
-       OUT_RING_CACHE(fail);
-       OUT_RING_CACHE(zfail);
-       OUT_RING_CACHE(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);
-
-static void nv20TextureMatrix(GLcontext *ctx, GLuint unit, const GLmatrix *mat)
-{
-        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-        BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_TX_MATRIX(unit, 0), 16);
-        /*XXX: This SHOULD work.*/
-        OUT_RING_CACHEp(mat->m, 16);
-}
-
-/* Update anything that depends on the window position/size */
-static void nv20WindowMoved(nouveauContextPtr nmesa)
-{
-       GLcontext *ctx = nmesa->glCtx;
-       GLfloat *v = nmesa->viewport.m;
-       GLuint w = ctx->Viewport.Width;
-       GLuint h = ctx->Viewport.Height;
-       GLuint x = ctx->Viewport.X + nmesa->drawX;
-       GLuint y = ctx->Viewport.Y + nmesa->drawY;
-       int i;
-
-        BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_VIEWPORT_HORIZ, 2);
-        OUT_RING_CACHE((w << 16) | x);
-        OUT_RING_CACHE((h << 16) | y);
-
-       BEGIN_RING_SIZE(NvSub3D, 0x02b4, 1);
-       OUT_RING(0);
-
-       BEGIN_RING_CACHE(NvSub3D,
-             NV20_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(0), 1);
-        OUT_RING_CACHE((4095 << 16) | 0);
-       BEGIN_RING_CACHE(NvSub3D,
-             NV20_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_VERT(0), 1);
-        OUT_RING_CACHE((4095 << 16) | 0);
-       for (i=1; i<8; i++) {
-               BEGIN_RING_CACHE(NvSub3D,
-                     NV20_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(i), 1);
-               OUT_RING_CACHE(0);
-               BEGIN_RING_CACHE(NvSub3D,
-                     NV20_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_VERT(i), 1);
-               OUT_RING_CACHE(0);
-       }
-
-       ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
-                           ctx->Scissor.Width, ctx->Scissor.Height);
-
-       /* TODO: recalc viewport scale coefs */
-}
-
-/* Initialise any card-specific non-GL related state */
-static GLboolean nv20InitCard(nouveauContextPtr nmesa)
-{
-       nouveauObjectOnSubchannel(nmesa, NvSub3D, Nv3D);
-
-       BEGIN_RING_SIZE(NvSub3D, NV20_TCL_PRIMITIVE_3D_SET_OBJECT1, 2);
-       OUT_RING(NvDmaFB);      /* 184 dma_object1 */
-       OUT_RING(NvDmaFB);      /* 188 dma_object2 */
-       BEGIN_RING_SIZE(NvSub3D, NV20_TCL_PRIMITIVE_3D_SET_OBJECT3, 2);
-       OUT_RING(NvDmaFB);      /* 194 dma_object3 */
-       OUT_RING(NvDmaFB);      /* 198 dma_object4 */
-       BEGIN_RING_SIZE(NvSub3D, NV20_TCL_PRIMITIVE_3D_SET_OBJECT8, 1);
-       OUT_RING(NvDmaFB);      /* 1a8 dma_object8 */
-
-       BEGIN_RING_SIZE(NvSub3D, 0x17e0, 3);
-       OUT_RINGf(0.0);
-       OUT_RINGf(0.0);
-       OUT_RINGf(1.0);
-
-       BEGIN_RING_SIZE(NvSub3D, 0x1e6c, 1);
-       OUT_RING(0x0db6);
-       BEGIN_RING_SIZE(NvSub3D, 0x0290, 1);
-       OUT_RING(0x00100001);
-       BEGIN_RING_SIZE(NvSub3D, 0x09fc, 1);
-       OUT_RING(0);
-       BEGIN_RING_SIZE(NvSub3D, 0x1d80, 1);
-       OUT_RING(1);
-       BEGIN_RING_SIZE(NvSub3D, 0x09f8, 1);
-       OUT_RING(4);
-
-       BEGIN_RING_SIZE(NvSub3D, 0x17ec, 3);
-       OUT_RINGf(0.0);
-       OUT_RINGf(1.0);
-       OUT_RINGf(0.0);
-
-       BEGIN_RING_SIZE(NvSub3D, 0x1d88, 1);
-       OUT_RING(3);
-
-       /* FIXME: More dma objects to setup ? */
-
-       BEGIN_RING_SIZE(NvSub3D, 0x1e98, 1);
-       OUT_RING(0);
-
-       BEGIN_RING_SIZE(NvSub3D, 0x120, 3);
-       OUT_RING(0);
-       OUT_RING(1);
-       OUT_RING(2);
-
-       return GL_TRUE;
-}
-
-/* Update buffer offset/pitch/format */
-static GLboolean nv20BindBuffers(nouveauContextPtr nmesa, int num_color,
-                                nouveau_renderbuffer **color,
-                                nouveau_renderbuffer *depth)
-{
-       GLuint x, y, w, h;
-       GLuint pitch, format, depth_pitch;
-
-       w = color[0]->mesa.Width;
-       h = color[0]->mesa.Height;
-       x = nmesa->drawX;
-       y = nmesa->drawY;
-
-       if (num_color != 1)
-               return GL_FALSE;
-
-        BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_VIEWPORT_HORIZ, 6);
-        OUT_RING_CACHE((w << 16) | x);
-        OUT_RING_CACHE((h << 16) | y);
-       depth_pitch = (depth ? depth->pitch : color[0]->pitch);
-       pitch = (depth_pitch<<16) | color[0]->pitch;
-       format = 0x128;
-       if (color[0]->mesa._ActualFormat != GL_RGBA8) {
-               format = 0x123; /* R5G6B5 color buffer */
-       }
-       OUT_RING_CACHE(format);
-       OUT_RING_CACHE(pitch);
-       OUT_RING_CACHE(color[0]->offset);
-       OUT_RING_CACHE(depth ? depth->offset : color[0]->offset);
-
-       if (depth) {
-               BEGIN_RING_SIZE(NvSub3D, NV20_TCL_PRIMITIVE_3D_LMA_DEPTH_BUFFER_PITCH, 2);
-               /* TODO: use a different buffer */
-               OUT_RING(depth->pitch);
-               OUT_RING(depth->offset);
-       }
-
-       /* Always set to bottom left of buffer */
-       /*BEGIN_RING_CACHE(NvSub3D, NV20_TCL_PRIMITIVE_3D_VIEWPORT_ORIGIN_X, 4);
-       OUT_RING_CACHEf (0.0);
-       OUT_RING_CACHEf ((GLfloat) h);
-       OUT_RING_CACHEf (0.0);
-       OUT_RING_CACHEf (0.0);*/
-
-       return GL_TRUE;
-}
-
-void nv20InitStateFuncs(GLcontext *ctx, struct dd_function_table *func)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       func->AlphaFunc                 = nv20AlphaFunc;
-       func->BlendColor                = nv20BlendColor;
-       func->BlendEquationSeparate     = nv20BlendEquationSeparate;
-       func->BlendFuncSeparate         = nv20BlendFuncSeparate;
-       func->Clear                     = nv20Clear;
-       func->ClearColor                = nv20ClearColor;
-       func->ClearDepth                = nv20ClearDepth;
-       func->ClearStencil              = nv20ClearStencil;
-       func->ClipPlane                 = nv20ClipPlane;
-       func->ColorMask                 = nv20ColorMask;
-       func->ColorMaterial             = nv20ColorMaterial;
-       func->CullFace                  = nv20CullFace;
-       func->FrontFace                 = nv20FrontFace;
-       func->DepthFunc                 = nv20DepthFunc;
-       func->DepthMask                 = nv20DepthMask;
-       func->DepthRange                = nv20DepthRange;
-       func->Enable                    = nv20Enable;
-       func->Fogfv                     = nv20Fogfv;
-       func->Hint                      = nv20Hint;
-       func->Lightfv                   = nv20Lightfv;
-/*     func->LightModelfv              = nv20LightModelfv; */
-       func->LineStipple               = nv20LineStipple;
-       func->LineWidth                 = nv20LineWidth;
-       func->LogicOpcode               = nv20LogicOpcode;
-       func->PointParameterfv          = nv20PointParameterfv;
-       func->PointSize                 = nv20PointSize;
-       func->PolygonMode               = nv20PolygonMode;
-       func->PolygonOffset             = nv20PolygonOffset;
-       func->PolygonStipple            = nv20PolygonStipple;
-/*     func->ReadBuffer                = nv20ReadBuffer;*/
-/*     func->RenderMode                = nv20RenderMode;*/
-       func->Scissor                   = nv20Scissor;
-       func->ShadeModel                = nv20ShadeModel;
-       func->StencilFuncSeparate       = nv20StencilFuncSeparate;
-       func->StencilMaskSeparate       = nv20StencilMaskSeparate;
-       func->StencilOpSeparate         = nv20StencilOpSeparate;
-/*     func->TexGen                    = nv20TexGen;*/
-/*     func->TexParameter              = nv20TexParameter;*/
-       func->TextureMatrix             = nv20TextureMatrix;
-
-       nmesa->hw_func.InitCard         = nv20InitCard;
-       nmesa->hw_func.BindBuffers      = nv20BindBuffers;
-       nmesa->hw_func.WindowMoved      = nv20WindowMoved;
-}
-
diff --git a/src/mesa/drivers/dri/nouveau/nv20_vertprog.c b/src/mesa/drivers/dri/nouveau/nv20_vertprog.c
deleted file mode 100644 (file)
index 60cfcd7..0000000
+++ /dev/null
@@ -1,447 +0,0 @@
-#include "nouveau_context.h"
-#include "nouveau_object.h"
-#include "nouveau_fifo.h"
-#include "nouveau_reg.h"
-
-#include "nouveau_shader.h"
-#include "nv20_shader.h"
-
-unsigned int NVVP_TX_VOP_COUNT = 16;
-unsigned int NVVP_TX_NVS_OP_COUNT = 16;
-struct _op_xlat NVVP_TX_VOP[32];
-struct _op_xlat NVVP_TX_SOP[32];
-
-nvsSwzComp NV20VP_TX_SWIZZLE[4] = { NVS_SWZ_X, NVS_SWZ_Y, NVS_SWZ_Z, NVS_SWZ_W };
-
-/*****************************************************************************
- * Support routines
- */
-static void
-NV20VPUploadToHW(GLcontext *ctx, nouveauShader *nvs)
-{
-   nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-   int i;
-
-   /* XXX: missing a way to say what insn we're uploading from, and possible
-    *      the program start position (if NV20 has one) */
-   for (i=0; i<nvs->program_size; i+=4) {
-      BEGIN_RING_SIZE(NvSub3D, NV20_TCL_PRIMITIVE_3D_VP_UPLOAD_INST0, 4);
-      OUT_RING(nvs->program[i + 0]);
-      OUT_RING(nvs->program[i + 1]);
-      OUT_RING(nvs->program[i + 2]);
-      OUT_RING(nvs->program[i + 3]);
-   }
-}
-
-static void
-NV20VPUpdateConst(GLcontext *ctx, nouveauShader *nvs, int id)
-{
-   nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-   /* Worth checking if the value *actually* changed? Mesa doesn't tell us this
-    * as far as I know..
-    */
-   BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_ID, 1);
-   OUT_RING (id);
-   BEGIN_RING_SIZE(NvSub3D, NV20_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_X, 4);
-   OUT_RINGf(nvs->params[id].source_val[0]);
-   OUT_RINGf(nvs->params[id].source_val[1]);
-   OUT_RINGf(nvs->params[id].source_val[2]);
-   OUT_RINGf(nvs->params[id].source_val[3]);
-}
-
-/*****************************************************************************
- * Assembly routines
- */
-
-/*****************************************************************************
- * Disassembly routines
- */
-void
-NV20VPTXSwizzle(int hwswz, nvsSwzComp *swz)
-{
-   swz[NVS_SWZ_X] = NV20VP_TX_SWIZZLE[(hwswz & 0xC0) >> 6];
-   swz[NVS_SWZ_Y] = NV20VP_TX_SWIZZLE[(hwswz & 0x30) >> 4];
-   swz[NVS_SWZ_Z] = NV20VP_TX_SWIZZLE[(hwswz & 0x0C) >> 2];
-   swz[NVS_SWZ_W] = NV20VP_TX_SWIZZLE[(hwswz & 0x03) >> 0];
-}
-
-static int
-NV20VPHasMergedInst(nvsFunc * shader)
-{
-   if (shader->GetOpcodeHW(shader, 0) != NV20_VP_INST_OPCODE_NOP &&
-       shader->GetOpcodeHW(shader, 1) != NV20_VP_INST_OPCODE_NOP)
-      printf
-        ("\n\n*****both opcode fields have values - PLEASE REPORT*****\n");
-   return 0;
-}
-
-static int
-NV20VPIsLastInst(nvsFunc * shader)
-{
-   return ((shader->inst[3] & (1 << 0)) ? 1 : 0);
-}
-
-static int
-NV20VPGetOffsetNext(nvsFunc * shader)
-{
-   return 4;
-}
-
-static struct _op_xlat *
-NV20VPGetOPTXRec(nvsFunc * shader, int merged)
-{
-   struct _op_xlat *opr;
-   int op;
-
-   if (shader->GetOpcodeSlot(shader, merged)) {
-      opr = NVVP_TX_SOP;
-      op = shader->GetOpcodeHW(shader, 1);
-      if (op >= NVVP_TX_NVS_OP_COUNT)
-        return NULL;
-   }
-   else {
-      opr = NVVP_TX_VOP;
-      op = shader->GetOpcodeHW(shader, 0);
-      if (op >= NVVP_TX_VOP_COUNT)
-        return NULL;
-   }
-
-   if (opr[op].SOP == NVS_OP_UNKNOWN)
-      return NULL;
-   return &opr[op];
-}
-
-static struct _op_xlat *
-NV20VPGetOPTXFromSOP(nvsOpcode sop, int *id)
-{
-   int i;
-
-   for (i=0;i<NVVP_TX_VOP_COUNT;i++) {
-      if (NVVP_TX_VOP[i].SOP == sop) {
-        if (id) *id = 0;
-        return &NVVP_TX_VOP[i];
-      }
-   }
-
-   for (i=0;i<NVVP_TX_NVS_OP_COUNT;i++) {
-      if (NVVP_TX_SOP[i].SOP == sop) {
-        if (id) *id = 1;
-        return &NVVP_TX_SOP[i];
-      }
-   }
-
-   return NULL;
-}
-
-static int
-NV20VPGetOpcodeSlot(nvsFunc * shader, int merged)
-{
-   if (shader->HasMergedInst(shader))
-      return merged;
-   if (shader->GetOpcodeHW(shader, 0) == NV20_VP_INST_OPCODE_NOP)
-      return 1;
-   return 0;
-}
-
-static nvsOpcode
-NV20VPGetOpcode(nvsFunc * shader, int merged)
-{
-   struct _op_xlat *opr;
-
-   opr = shader->GetOPTXRec(shader, merged);
-   if (!opr)
-      return NVS_OP_UNKNOWN;
-
-   return opr->SOP;
-}
-
-static nvsOpcode
-NV20VPGetOpcodeHW(nvsFunc * shader, int slot)
-{
-   if (slot)
-      return (shader->inst[1] & NV20_VP_INST_SCA_OPCODE_MASK)
-        >> NV20_VP_INST_SCA_OPCODE_SHIFT;
-   return (shader->inst[1] & NV20_VP_INST_VEC_OPCODE_MASK)
-      >> NV20_VP_INST_VEC_OPCODE_SHIFT;
-}
-
-static nvsRegFile
-NV20VPGetDestFile(nvsFunc * shader, int merged)
-{
-   switch (shader->GetOpcode(shader, merged)) {
-   case NVS_OP_ARL:
-      return NVS_FILE_ADDRESS;
-   default:
-      /*FIXME: This probably isn't correct.. */
-      if ((shader->inst[3] & NV20_VP_INST_DEST_WRITEMASK_MASK) == 0)
-        return NVS_FILE_TEMP;
-      return NVS_FILE_RESULT;
-   }
-}
-
-static unsigned int
-NV20VPGetDestID(nvsFunc * shader, int merged)
-{
-   int id;
-
-   switch (shader->GetDestFile(shader, merged)) {
-   case NVS_FILE_RESULT:
-      id = ((shader->inst[3] & NV20_VP_INST_DEST_MASK)
-           >> NV20_VP_INST_DEST_SHIFT);
-      switch (id) {
-      case NV20_VP_INST_DEST_POS  : return NVS_FR_POSITION;
-      case NV20_VP_INST_DEST_COL0 : return NVS_FR_COL0;
-      case NV20_VP_INST_DEST_COL1 : return NVS_FR_COL1;
-      case NV20_VP_INST_DEST_TC(0): return NVS_FR_TEXCOORD0;
-      case NV20_VP_INST_DEST_TC(1): return NVS_FR_TEXCOORD1;
-      case NV20_VP_INST_DEST_TC(2): return NVS_FR_TEXCOORD2;
-      case NV20_VP_INST_DEST_TC(3): return NVS_FR_TEXCOORD3;
-      default:
-        return -1;
-      }
-   case NVS_FILE_ADDRESS:
-      return 0;
-   case NVS_FILE_TEMP:
-      id = ((shader->inst[3] & NV20_VP_INST_DEST_TEMP_ID_MASK)
-           >> NV20_VP_INST_DEST_TEMP_ID_SHIFT);
-      return id;
-   default:
-      return -1;
-   }
-}
-
-static unsigned int
-NV20VPGetDestMask(nvsFunc * shader, int merged)
-{
-   int hwmask, mask = 0;
-
-   /* Special handling for ARL - hardware only supports a
-    * 1-component address reg
-    */
-   if (shader->GetOpcode(shader, merged) == NVS_OP_ARL)
-      return SMASK_X;
-
-   if (shader->GetDestFile(shader, merged) == NVS_FILE_RESULT)
-      hwmask = (shader->inst[3] & NV20_VP_INST_DEST_WRITEMASK_MASK)
-        >> NV20_VP_INST_DEST_WRITEMASK_SHIFT;
-   else if (shader->GetOpcodeSlot(shader, merged))
-      hwmask = (shader->inst[3] & NV20_VP_INST_STEMP_WRITEMASK_MASK)
-        >> NV20_VP_INST_STEMP_WRITEMASK_SHIFT;
-   else
-      hwmask = (shader->inst[3] & NV20_VP_INST_VTEMP_WRITEMASK_MASK)
-        >> NV20_VP_INST_VTEMP_WRITEMASK_SHIFT;
-
-   if (hwmask & (1 << 3)) mask |= SMASK_X;
-   if (hwmask & (1 << 2)) mask |= SMASK_Y;
-   if (hwmask & (1 << 1)) mask |= SMASK_Z;
-   if (hwmask & (1 << 0)) mask |= SMASK_W;
-
-   return mask;
-}
-
-static unsigned int
-NV20VPGetSourceHW(nvsFunc * shader, int merged, int pos)
-{
-   struct _op_xlat *opr;
-   unsigned int src;
-
-   opr = shader->GetOPTXRec(shader, merged);
-   if (!opr)
-      return -1;
-
-   switch (opr->srcpos[pos]) {
-   case 0:
-      src = ((shader->inst[1] & NV20_VP_INST_SRC0H_MASK)
-            >> NV20_VP_INST_SRC0H_SHIFT)
-        << NV20_VP_SRC0_HIGH_SHIFT;
-      src |= ((shader->inst[2] & NV20_VP_INST_SRC0L_MASK)
-             >> NV20_VP_INST_SRC0L_SHIFT);
-      break;
-   case 1:
-      src = ((shader->inst[2] & NV20_VP_INST_SRC1_MASK)
-            >> NV20_VP_INST_SRC1_SHIFT);
-      break;
-   case 2:
-      src = ((shader->inst[2] & NV20_VP_INST_SRC2H_MASK)
-            >> NV20_VP_INST_SRC2H_SHIFT)
-        << NV20_VP_SRC2_HIGH_SHIFT;
-      src |= ((shader->inst[3] & NV20_VP_INST_SRC2L_MASK)
-             >> NV20_VP_INST_SRC2L_SHIFT);
-      break;
-   default:
-      src = -1;
-   }
-
-   return src;
-}
-
-static nvsRegFile
-NV20VPGetSourceFile(nvsFunc * shader, int merged, int pos)
-{
-   unsigned int src;
-   struct _op_xlat *opr;
-   int file;
-
-   opr = shader->GetOPTXRec(shader, merged);
-   if (!opr || opr->srcpos[pos] == -1)
-      return -1;
-
-   switch (opr->srcpos[pos]) {
-   case SPOS_ADDRESS:
-      return NVS_FILE_ADDRESS;
-   default:
-      src = NV20VPGetSourceHW(shader, merged, pos);
-      file = (src & NV20_VP_SRC_REG_TYPE_MASK) >> NV20_VP_SRC_REG_TYPE_SHIFT;
-
-      switch (file) {
-      case NV20_VP_SRC_REG_TYPE_TEMP : return NVS_FILE_TEMP;
-      case NV20_VP_SRC_REG_TYPE_INPUT: return NVS_FILE_ATTRIB;
-      case NV20_VP_SRC_REG_TYPE_CONST: return NVS_FILE_CONST;
-      default:
-        return NVS_FILE_UNKNOWN;
-      }
-   }
-}
-
-static int
-NV20VPGetSourceID(nvsFunc * shader, int merged, int pos)
-{
-   unsigned int src;
-
-   switch (shader->GetSourceFile(shader, merged, pos)) {
-   case NVS_FILE_TEMP:
-      src = shader->GetSourceHW(shader, merged, pos);
-      return ((src & NV20_VP_SRC_REG_TEMP_ID_MASK) >>
-             NV20_VP_SRC_REG_TEMP_ID_SHIFT);
-   case NVS_FILE_CONST:
-      return ((shader->inst[1] & NV20_VP_INST_CONST_SRC_MASK)
-             >> NV20_VP_INST_CONST_SRC_SHIFT);
-   case NVS_FILE_ATTRIB:
-      src = ((shader->inst[1] & NV20_VP_INST_INPUT_SRC_MASK)
-            >> NV20_VP_INST_INPUT_SRC_SHIFT);
-      switch (src) {
-      case NV20_VP_INST_INPUT_SRC_POS  : return NVS_FR_POSITION;
-      case NV20_VP_INST_INPUT_SRC_COL0 : return NVS_FR_COL0;
-      case NV20_VP_INST_INPUT_SRC_COL1 : return NVS_FR_COL1;
-      case NV20_VP_INST_INPUT_SRC_TC(0): return NVS_FR_TEXCOORD0;
-      case NV20_VP_INST_INPUT_SRC_TC(1): return NVS_FR_TEXCOORD1;
-      case NV20_VP_INST_INPUT_SRC_TC(2): return NVS_FR_TEXCOORD2;
-      case NV20_VP_INST_INPUT_SRC_TC(3): return NVS_FR_TEXCOORD3;
-      default:
-        return NVS_FR_UNKNOWN;
-      }
-   default:
-      return -1;
-   }
-}
-
-static int
-NV20VPGetSourceNegate(nvsFunc * shader, int merged, int pos)
-{
-   unsigned int src;
-
-   src = shader->GetSourceHW(shader, merged, pos);
-
-   return ((src & NV20_VP_SRC_REG_NEGATE) ? 1 : 0);
-}
-
-static int
-NV20VPGetSourceAbs(nvsFunc * shader, int merged, int pos)
-{
-   /* NV20 can't do ABS on sources?  Appears to be emulated with
-    *      MAX reg, reg, -reg
-    */
-   return 0;
-}
-
-static void
-NV20VPGetSourceSwizzle(nvsFunc * shader, int merged, int pos, nvsSwzComp *swz)
-{
-   unsigned int src;
-   int swzbits;
-
-   src = shader->GetSourceHW(shader, merged, pos);
-   swzbits  =
-      (src & NV20_VP_SRC_REG_SWZ_ALL_MASK) >> NV20_VP_SRC_REG_SWZ_ALL_SHIFT;
-   return NV20VPTXSwizzle(swzbits, swz);
-}
-
-static int
-NV20VPGetSourceIndexed(nvsFunc * shader, int merged, int pos)
-{
-   /* I don't think NV20 can index into attribs, at least no GL
-    * extension is exposed that will allow it.
-    */
-   if (shader->GetSourceFile(shader, merged, pos) != NVS_FILE_CONST)
-      return 0;
-   if (shader->inst[3] & NV20_VP_INST_INDEX_CONST)
-      return 1;
-   return 0;
-}
-
-static int
-NV20VPGetAddressRegID(nvsFunc * shader)
-{
-   /* Only 1 address reg */
-   return 0;
-}
-
-static nvsSwzComp
-NV20VPGetAddressRegSwizzle(nvsFunc * shader)
-{
-   /* Only A0.x available */
-   return NVS_SWZ_X;
-}
-
-void
-NV20VPInitShaderFuncs(nvsFunc * shader)
-{
-   MOD_OPCODE(NVVP_TX_VOP, NV20_VP_INST_OPCODE_NOP, NVS_OP_NOP, -1, -1, -1);
-   MOD_OPCODE(NVVP_TX_VOP, NV20_VP_INST_OPCODE_MOV, NVS_OP_MOV,  0, -1, -1);
-   MOD_OPCODE(NVVP_TX_VOP, NV20_VP_INST_OPCODE_MUL, NVS_OP_MUL,  0,  1, -1);
-   MOD_OPCODE(NVVP_TX_VOP, NV20_VP_INST_OPCODE_ADD, NVS_OP_ADD,  0,  2, -1);
-   MOD_OPCODE(NVVP_TX_VOP, NV20_VP_INST_OPCODE_MAD, NVS_OP_MAD,  0,  1,  2);
-   MOD_OPCODE(NVVP_TX_VOP, NV20_VP_INST_OPCODE_DP3, NVS_OP_DP3,  0,  1, -1);
-   MOD_OPCODE(NVVP_TX_VOP, NV20_VP_INST_OPCODE_DPH, NVS_OP_DPH,  0,  1, -1);
-   MOD_OPCODE(NVVP_TX_VOP, NV20_VP_INST_OPCODE_DP4, NVS_OP_DP4,  0,  1, -1);
-   MOD_OPCODE(NVVP_TX_VOP, NV20_VP_INST_OPCODE_DST, NVS_OP_DST,  0,  1, -1);
-   MOD_OPCODE(NVVP_TX_VOP, NV20_VP_INST_OPCODE_MIN, NVS_OP_MIN,  0,  1, -1);
-   MOD_OPCODE(NVVP_TX_VOP, NV20_VP_INST_OPCODE_MAX, NVS_OP_MAX,  0,  1, -1);
-   MOD_OPCODE(NVVP_TX_VOP, NV20_VP_INST_OPCODE_SLT, NVS_OP_SLT,  0,  1, -1);
-   MOD_OPCODE(NVVP_TX_VOP, NV20_VP_INST_OPCODE_SGE, NVS_OP_SGE,  0,  1, -1);
-   MOD_OPCODE(NVVP_TX_VOP, NV20_VP_INST_OPCODE_ARL, NVS_OP_ARL,  0, -1, -1);
-
-   MOD_OPCODE(NVVP_TX_SOP, NV20_VP_INST_OPCODE_NOP, NVS_OP_NOP, -1, -1, -1);
-   MOD_OPCODE(NVVP_TX_SOP, NV20_VP_INST_OPCODE_RCP, NVS_OP_RCP,  2, -1, -1);
-   MOD_OPCODE(NVVP_TX_SOP, NV20_VP_INST_OPCODE_RCC, NVS_OP_RCC,  2, -1, -1);
-   MOD_OPCODE(NVVP_TX_SOP, NV20_VP_INST_OPCODE_RSQ, NVS_OP_RSQ,  2, -1, -1);
-   MOD_OPCODE(NVVP_TX_SOP, NV20_VP_INST_OPCODE_EXP, NVS_OP_EXP,  2, -1, -1);
-   MOD_OPCODE(NVVP_TX_SOP, NV20_VP_INST_OPCODE_LOG, NVS_OP_LOG,  2, -1, -1);
-   MOD_OPCODE(NVVP_TX_SOP, NV20_VP_INST_OPCODE_LIT, NVS_OP_LIT,  2, -1, -1);
-
-   shader->UploadToHW          = NV20VPUploadToHW;
-   shader->UpdateConst         = NV20VPUpdateConst;
-
-   shader->GetOPTXRec          = NV20VPGetOPTXRec;
-   shader->GetOPTXFromSOP      = NV20VPGetOPTXFromSOP;
-
-   shader->HasMergedInst       = NV20VPHasMergedInst;
-   shader->IsLastInst          = NV20VPIsLastInst;
-   shader->GetOffsetNext       = NV20VPGetOffsetNext;
-   shader->GetOpcodeSlot       = NV20VPGetOpcodeSlot;
-   shader->GetOpcode           = NV20VPGetOpcode;
-   shader->GetOpcodeHW         = NV20VPGetOpcodeHW;
-   shader->GetDestFile         = NV20VPGetDestFile;
-   shader->GetDestID           = NV20VPGetDestID;
-   shader->GetDestMask         = NV20VPGetDestMask;
-   shader->GetSourceHW         = NV20VPGetSourceHW;
-   shader->GetSourceFile       = NV20VPGetSourceFile;
-   shader->GetSourceID         = NV20VPGetSourceID;
-   shader->GetSourceNegate     = NV20VPGetSourceNegate;
-   shader->GetSourceAbs                = NV20VPGetSourceAbs;
-   shader->GetSourceSwizzle    = NV20VPGetSourceSwizzle;
-   shader->GetSourceIndexed    = NV20VPGetSourceIndexed;
-   shader->GetRelAddressRegID  = NV20VPGetAddressRegID;
-   shader->GetRelAddressSwizzle        = NV20VPGetAddressRegSwizzle;
-}
diff --git a/src/mesa/drivers/dri/nouveau/nv30_fragprog.c b/src/mesa/drivers/dri/nouveau/nv30_fragprog.c
deleted file mode 100644 (file)
index e324523..0000000
+++ /dev/null
@@ -1,742 +0,0 @@
-#include <stdint.h>
-
-#include "glheader.h"
-#include "macros.h"
-
-#include "nouveau_context.h"
-#include "nouveau_fifo.h"
-#include "nouveau_reg.h"
-#include "nouveau_drm.h"
-#include "nouveau_shader.h"
-#include "nouveau_object.h"
-#include "nouveau_msg.h"
-#include "nouveau_bufferobj.h"
-#include "nv30_shader.h"
-
-unsigned int NVFP_TX_AOP_COUNT = 64;
-struct _op_xlat NVFP_TX_AOP[64];
-
-/*******************************************************************************
- * Support routines
- */
-
-static void
-NV30FPUploadToHW(GLcontext *ctx, nouveauShader *nvs)
-{
-   nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-   nvsCardPriv *priv = &nvs->card_priv;
-   uint32_t offset;
-
-   if (!nvs->program_buffer)
-      nvs->program_buffer = ctx->Driver.NewBufferObject(ctx, 0,
-                                                       GL_ARRAY_BUFFER_ARB);
-
-   /* Should use STATIC_DRAW_ARB if shader doesn't use changable params */
-   nouveau_bo_init_storage(ctx, NOUVEAU_BO_VRAM_OK,
-                         nvs->program_size * sizeof(uint32_t),
-                         (const GLvoid *)nvs->program,
-                         GL_DYNAMIC_DRAW_ARB,
-                         nvs->program_buffer);
-
-   offset = nouveau_bo_gpu_ref(ctx, nvs->program_buffer);
-
-   /* Not using state cache here, updated programs at the same address don't
-    * seem to take effect unless the ACTIVE_PROGRAM method is called again.
-    * HW caches the program somewhere?
-    */
-   BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_FP_ACTIVE_PROGRAM, 1);
-   OUT_RING       (offset | 1);
-   if (nmesa->screen->card->type == NV_30) {  
-          BEGIN_RING_SIZE(NvSub3D,
-                          0x1d60 /*NV30_TCL_PRIMITIVE_3D_FP_CONTROL*/, 1);
-          OUT_RING       ((priv->NV30FP.uses_kil << 7));
-          BEGIN_RING_SIZE(NvSub3D, 0x1450, 1);
-          OUT_RING       (priv->NV30FP.num_regs << 16);
-   } else {
-          BEGIN_RING_SIZE(NvSub3D,
-                          0x1d60 /*NV30_TCL_PRIMITIVE_3D_FP_CONTROL*/, 1);
-          OUT_RING       ((priv->NV30FP.uses_kil <<  7) |
-                          (priv->NV30FP.num_regs << 24));
-   }
-}
-
-static void
-NV30FPUpdateConst(GLcontext *ctx, nouveauShader *nvs, int id)
-{
-   uint32_t *new     = nvs->params[id].source_val ?
-      (uint32_t*)nvs->params[id].source_val : (uint32_t*)nvs->params[id].val;
-   uint32_t *current;
-   int i;
-
-   for (i=0; i<nvs->params[id].hw_index_cnt; i++) {
-      current = nvs->program + nvs->params[id].hw_index[i];
-      COPY_4V(current, new);
-   }
-   nvs->on_hardware = 0;
-}
-
-/*******************************************************************************
- * Assembly helpers
- */
-static struct _op_xlat *
-NV30FPGetOPTXFromSOP(nvsOpcode op, int *id)
-{
-   int i;
-
-   for (i=0; i<NVFP_TX_AOP_COUNT; i++) {
-      if (NVFP_TX_AOP[i].SOP == op) {
-        if (id) *id = 0;
-        return &NVFP_TX_AOP[i];
-      }
-   }
-
-   return NULL;
-}
-
-static int
-NV30FPSupportsOpcode(nvsFunc *shader, nvsOpcode op)
-{
-   if (shader->GetOPTXFromSOP(op, NULL))
-      return 1;
-   return 0;
-}
-
-static void
-NV30FPSetOpcode(nvsFunc *shader, unsigned int opcode, int slot)
-{
-   if (opcode == NV30_FP_OP_OPCODE_KIL)
-      shader->card_priv->NV30FP.uses_kil = GL_TRUE;
-   shader->inst[0] &= ~NV30_FP_OP_OPCODE_MASK;
-   shader->inst[0] |= (opcode << NV30_FP_OP_OPCODE_SHIFT);
-}
-
-static void
-NV30FPSetCCUpdate(nvsFunc *shader)
-{
-   shader->inst[0] |= NV30_FP_OP_COND_WRITE_ENABLE;
-}
-
-static void
-NV30FPSetCondition(nvsFunc *shader, int on, nvsCond cond, int reg,
-                 nvsSwzComp *swz)
-{
-   nvsSwzComp default_swz[4] = { NVS_SWZ_X, NVS_SWZ_Y, NVS_SWZ_Z, NVS_SWZ_W };
-   unsigned int hwcond;
-
-   /* cond masking is always enabled */
-   if (!on) {
-      cond = NVS_COND_TR;
-      reg  = 0;
-      swz  = default_swz;
-   }
-
-   switch (cond) {
-   case NVS_COND_TR: hwcond = NV30_FP_OP_COND_TR; break;
-   case NVS_COND_FL: hwcond = NV30_FP_OP_COND_FL; break;
-   case NVS_COND_LT: hwcond = NV30_FP_OP_COND_LT; break;
-   case NVS_COND_GT: hwcond = NV30_FP_OP_COND_GT; break;
-   case NVS_COND_LE: hwcond = NV30_FP_OP_COND_LE; break;
-   case NVS_COND_GE: hwcond = NV30_FP_OP_COND_GE; break;
-   case NVS_COND_EQ: hwcond = NV30_FP_OP_COND_EQ; break;
-   case NVS_COND_NE: hwcond = NV30_FP_OP_COND_NE; break;
-   default:
-       WARN_ONCE("unknown fp condmask=%d\n", cond);
-       hwcond = NV30_FP_OP_COND_TR;
-       break;
-   }
-
-   shader->inst[1] &= ~NV30_FP_OP_COND_MASK;
-   shader->inst[1] |= (hwcond << NV30_FP_OP_COND_SHIFT);
-
-   shader->inst[1] &= ~NV30_FP_OP_COND_SWZ_ALL_MASK;
-   shader->inst[1] |= (swz[NVS_SWZ_X] << NV30_FP_OP_COND_SWZ_X_SHIFT);
-   shader->inst[1] |= (swz[NVS_SWZ_Y] << NV30_FP_OP_COND_SWZ_Y_SHIFT);
-   shader->inst[1] |= (swz[NVS_SWZ_Z] << NV30_FP_OP_COND_SWZ_Z_SHIFT);
-   shader->inst[1] |= (swz[NVS_SWZ_W] << NV30_FP_OP_COND_SWZ_W_SHIFT);
-}
-
-static void
-NV30FPSetHighReg(nvsFunc *shader, int id)
-{
-   if (shader->card_priv->NV30FP.num_regs < (id+1)) {
-      if (id == 0)
-        id = 1; /* necessary? */
-      shader->card_priv->NV30FP.num_regs = (id+1);
-   }
-}
-
-static void
-NV30FPSetResult(nvsFunc *shader, nvsRegister *reg, unsigned int mask, int slot)
-{
-   unsigned int hwreg;
-
-   if (mask & SMASK_X) shader->inst[0] |= NV30_FP_OP_OUT_X;
-   if (mask & SMASK_Y) shader->inst[0] |= NV30_FP_OP_OUT_Y;
-   if (mask & SMASK_Z) shader->inst[0] |= NV30_FP_OP_OUT_Z;
-   if (mask & SMASK_W) shader->inst[0] |= NV30_FP_OP_OUT_W;
-
-   if (reg->file == NVS_FILE_RESULT) {
-      hwreg = 0; /* FIXME: this is only fragment.color */
-      /* This is *not* correct, I have no idea what it is either */
-      shader->inst[0] |= NV30_FP_OP_UNK0_7;
-   } else {
-      shader->inst[0] &= ~NV30_FP_OP_UNK0_7;
-      hwreg = reg->index;
-   }
-   NV30FPSetHighReg(shader, hwreg);
-   shader->inst[0] &= ~NV30_FP_OP_OUT_REG_SHIFT;
-   shader->inst[0] |= (hwreg  << NV30_FP_OP_OUT_REG_SHIFT);
-}
-
-static void
-NV30FPSetSource(nvsFunc *shader, nvsRegister *reg, int pos)
-{
-   unsigned int hwsrc = 0;
-
-   switch (reg->file) {
-   case NVS_FILE_TEMP:
-      hwsrc |= (NV30_FP_REG_TYPE_TEMP << NV30_FP_REG_TYPE_SHIFT);
-      hwsrc |= (reg->index << NV30_FP_REG_SRC_SHIFT);
-      NV30FPSetHighReg(shader, reg->index);
-      break;
-   case NVS_FILE_ATTRIB:
-      {
-        unsigned int hwin;
-
-        switch (reg->index) {
-        case NVS_FR_POSITION : hwin = NV30_FP_OP_INPUT_SRC_POSITION; break;
-        case NVS_FR_COL0     : hwin = NV30_FP_OP_INPUT_SRC_COL0; break;
-        case NVS_FR_COL1     : hwin = NV30_FP_OP_INPUT_SRC_COL1; break;
-        case NVS_FR_FOGCOORD : hwin = NV30_FP_OP_INPUT_SRC_FOGC; break;
-        case NVS_FR_TEXCOORD0: hwin = NV30_FP_OP_INPUT_SRC_TC(0); break;
-        case NVS_FR_TEXCOORD1: hwin = NV30_FP_OP_INPUT_SRC_TC(1); break;
-        case NVS_FR_TEXCOORD2: hwin = NV30_FP_OP_INPUT_SRC_TC(2); break;
-        case NVS_FR_TEXCOORD3: hwin = NV30_FP_OP_INPUT_SRC_TC(3); break;
-        case NVS_FR_TEXCOORD4: hwin = NV30_FP_OP_INPUT_SRC_TC(4); break;
-        case NVS_FR_TEXCOORD5: hwin = NV30_FP_OP_INPUT_SRC_TC(5); break;
-        case NVS_FR_TEXCOORD6: hwin = NV30_FP_OP_INPUT_SRC_TC(6); break;
-        case NVS_FR_TEXCOORD7: hwin = NV30_FP_OP_INPUT_SRC_TC(7); break;
-        default:
-               WARN_ONCE("unknown fp input %d\n", reg->index);
-               hwin = NV30_FP_OP_INPUT_SRC_COL0;
-               break;
-        }
-        shader->inst[0] &= ~NV30_FP_OP_INPUT_SRC_MASK;
-        shader->inst[0] |= (hwin << NV30_FP_OP_INPUT_SRC_SHIFT);
-        hwsrc |= (hwin << NV30_FP_REG_SRC_SHIFT);
-      }
-      hwsrc |= (NV30_FP_REG_TYPE_INPUT << NV30_FP_REG_TYPE_SHIFT);
-      break;
-   case NVS_FILE_CONST:
-      /* consts are inlined after the inst */
-      hwsrc |= (NV30_FP_REG_TYPE_CONST << NV30_FP_REG_TYPE_SHIFT);
-      break;
-   default:
-      assert(0);
-      break;
-   }
-
-   if (reg->negate)
-      hwsrc |= NV30_FP_REG_NEGATE;
-   if (reg->abs)
-      shader->inst[1] |= (1 << (29+pos));
-   hwsrc |= (reg->swizzle[NVS_SWZ_X] << NV30_FP_REG_SWZ_X_SHIFT);
-   hwsrc |= (reg->swizzle[NVS_SWZ_Y] << NV30_FP_REG_SWZ_Y_SHIFT);
-   hwsrc |= (reg->swizzle[NVS_SWZ_Z] << NV30_FP_REG_SWZ_Z_SHIFT);
-   hwsrc |= (reg->swizzle[NVS_SWZ_W] << NV30_FP_REG_SWZ_W_SHIFT);
-
-   shader->inst[pos+1] &= ~NV30_FP_REG_ALL_MASK;
-   shader->inst[pos+1] |= hwsrc;
-}
-
-static void
-NV30FPSetTexImageUnit(nvsFunc *shader, int unit)
-{
-   shader->inst[0] &= ~NV30_FP_OP_TEX_UNIT_SHIFT;
-   shader->inst[0] |= (unit << NV30_FP_OP_TEX_UNIT_SHIFT);
-}
-
-static void
-NV30FPSetSaturate(nvsFunc *shader)
-{
-   shader->inst[0] |= NV30_FP_OP_OUT_SAT;
-}
-
-static void
-NV30FPInitInstruction(nvsFunc *shader)
-{
-   unsigned int hwsrc;
-
-   shader->inst[0] = 0;
-
-   hwsrc = (NV30_FP_REG_TYPE_INPUT << NV30_FP_REG_TYPE_SHIFT) |
-          (NVS_SWZ_X << NV30_FP_REG_SWZ_X_SHIFT) |
-          (NVS_SWZ_Y << NV30_FP_REG_SWZ_Y_SHIFT) |
-          (NVS_SWZ_Z << NV30_FP_REG_SWZ_Z_SHIFT) |
-          (NVS_SWZ_W << NV30_FP_REG_SWZ_W_SHIFT);
-   shader->inst[1] = hwsrc;
-   shader->inst[2] = hwsrc;
-   shader->inst[3] = hwsrc;
-}
-
-static void
-NV30FPSetLastInst(nvsFunc *shader)
-{
-   shader->inst[0] |= 1; 
-}
-
-/*******************************************************************************
- * Disassembly helpers
- */
-static struct _op_xlat *
-NV30FPGetOPTXRec(nvsFunc * shader, int merged)
-{
-   int op;
-
-   op = shader->GetOpcodeHW(shader, 0);
-   if (op > NVFP_TX_AOP_COUNT)
-      return NULL;
-   if (NVFP_TX_AOP[op].SOP == NVS_OP_UNKNOWN)
-      return NULL;
-   return &NVFP_TX_AOP[op];
-}
-
-static int
-NV30FPHasMergedInst(nvsFunc * shader)
-{
-   return 0;
-}
-
-static int
-NV30FPIsLastInst(nvsFunc * shader)
-{
-   return ((shader->inst[0] & NV30_FP_OP_PROGRAM_END) ? 1 : 0);
-}
-
-static int
-NV30FPGetOffsetNext(nvsFunc * shader)
-{
-   int i;
-
-   for (i = 0; i < 3; i++)
-      if (shader->GetSourceFile(shader, 0, i) == NVS_FILE_CONST)
-        return 8;
-   return 4;
-}
-
-static nvsOpcode
-NV30FPGetOpcode(nvsFunc * shader, int merged)
-{
-   struct _op_xlat *opr;
-
-   opr = shader->GetOPTXRec(shader, merged);
-   if (!opr)
-      return NVS_OP_UNKNOWN;
-
-   return opr->SOP;
-}
-
-static unsigned int
-NV30FPGetOpcodeHW(nvsFunc * shader, int slot)
-{
-   int op;
-
-   op = (shader->inst[0] & NV30_FP_OP_OPCODE_MASK) >> NV30_FP_OP_OPCODE_SHIFT;
-
-   return op;
-}
-
-static nvsRegFile
-NV30FPGetDestFile(nvsFunc * shader, int merged)
-{
-   /* Result regs overlap temporary regs */
-   return NVS_FILE_TEMP;
-}
-
-static unsigned int
-NV30FPGetDestID(nvsFunc * shader, int merged)
-{
-   int id;
-
-   switch (shader->GetDestFile(shader, merged)) {
-   case NVS_FILE_TEMP:
-      id = ((shader->inst[0] & NV30_FP_OP_OUT_REG_MASK)
-           >> NV30_FP_OP_OUT_REG_SHIFT);
-      return id;
-   default:
-      return -1;
-   }
-}
-
-static unsigned int
-NV30FPGetDestMask(nvsFunc * shader, int merged)
-{
-   unsigned int mask = 0;
-
-   if (shader->inst[0] & NV30_FP_OP_OUT_X) mask |= SMASK_X;
-   if (shader->inst[0] & NV30_FP_OP_OUT_Y) mask |= SMASK_Y;
-   if (shader->inst[0] & NV30_FP_OP_OUT_Z) mask |= SMASK_Z;
-   if (shader->inst[0] & NV30_FP_OP_OUT_W) mask |= SMASK_W;
-
-   return mask;
-}
-
-static unsigned int
-NV30FPGetSourceHW(nvsFunc * shader, int merged, int pos)
-{
-   struct _op_xlat *opr;
-
-   opr = shader->GetOPTXRec(shader, merged);
-   if (!opr || opr->srcpos[pos] == -1)
-      return -1;
-
-   return shader->inst[opr->srcpos[pos] + 1];
-}
-
-static nvsRegFile
-NV30FPGetSourceFile(nvsFunc * shader, int merged, int pos)
-{
-   unsigned int src;
-   struct _op_xlat *opr;
-   int file;
-
-   opr = shader->GetOPTXRec(shader, merged);
-   if (!opr || opr->srcpos[pos] == -1)
-      return NVS_FILE_UNKNOWN;
-
-   switch (opr->srcpos[pos]) {
-   case SPOS_ADDRESS: return NVS_FILE_ADDRESS;
-   default:
-      src = shader->GetSourceHW(shader, merged, pos);
-      file = (src & NV30_FP_REG_TYPE_MASK) >> NV30_FP_REG_TYPE_SHIFT;
-
-      switch (file) {
-      case NV30_FP_REG_TYPE_TEMP : return NVS_FILE_TEMP;
-      case NV30_FP_REG_TYPE_INPUT: return NVS_FILE_ATTRIB;
-      case NV30_FP_REG_TYPE_CONST: return NVS_FILE_CONST;
-      default:
-        return NVS_FILE_UNKNOWN;
-      }
-   }
-}
-
-static int
-NV30FPGetSourceID(nvsFunc * shader, int merged, int pos)
-{
-   switch (shader->GetSourceFile(shader, merged, pos)) {
-   case NVS_FILE_ATTRIB:
-      switch ((shader->inst[0] & NV30_FP_OP_INPUT_SRC_MASK)
-             >> NV30_FP_OP_INPUT_SRC_SHIFT) {
-      case NV30_FP_OP_INPUT_SRC_POSITION: return NVS_FR_POSITION;
-      case NV30_FP_OP_INPUT_SRC_COL0    : return NVS_FR_COL0;
-      case NV30_FP_OP_INPUT_SRC_COL1    : return NVS_FR_COL1;
-      case NV30_FP_OP_INPUT_SRC_FOGC    : return NVS_FR_FOGCOORD;
-      case NV30_FP_OP_INPUT_SRC_TC(0)   : return NVS_FR_TEXCOORD0;
-      case NV30_FP_OP_INPUT_SRC_TC(1)   : return NVS_FR_TEXCOORD1;
-      case NV30_FP_OP_INPUT_SRC_TC(2)   : return NVS_FR_TEXCOORD2;
-      case NV30_FP_OP_INPUT_SRC_TC(3)   : return NVS_FR_TEXCOORD3;
-      case NV30_FP_OP_INPUT_SRC_TC(4)   : return NVS_FR_TEXCOORD4;
-      case NV30_FP_OP_INPUT_SRC_TC(5)   : return NVS_FR_TEXCOORD5;
-      case NV30_FP_OP_INPUT_SRC_TC(6)   : return NVS_FR_TEXCOORD6;
-      case NV30_FP_OP_INPUT_SRC_TC(7)   : return NVS_FR_TEXCOORD7;
-      default:
-        return -1;
-      }
-      break;
-   case NVS_FILE_TEMP:
-      {
-        unsigned int src;
-
-        src = shader->GetSourceHW(shader, merged, pos);
-        return ((src & NV30_FP_REG_SRC_MASK) >> NV30_FP_REG_SRC_SHIFT);
-      }
-   case NVS_FILE_CONST:                /* inlined into fragprog */
-   default:
-      return -1;
-   }
-}
-
-static int
-NV30FPGetTexImageUnit(nvsFunc *shader)
-{
-      return ((shader->inst[0] & NV30_FP_OP_TEX_UNIT_MASK)
-             >> NV30_FP_OP_TEX_UNIT_SHIFT);
-}
-
-static int
-NV30FPGetSourceNegate(nvsFunc * shader, int merged, int pos)
-{
-   unsigned int src;
-
-   src = shader->GetSourceHW(shader, merged, pos);
-
-   if (src == -1)
-      return -1;
-   return ((src & NV30_FP_REG_NEGATE) ? 1 : 0);
-}
-
-static int
-NV30FPGetSourceAbs(nvsFunc * shader, int merged, int pos)
-{
-   struct _op_xlat *opr;
-   static unsigned int abspos[3] = {
-      NV30_FP_OP_OUT_ABS,
-      (1 << 30),               /* guess */
-      (1 << 31)                        /* guess */
-   };
-
-   opr = shader->GetOPTXRec(shader, merged);
-   if (!opr || opr->srcpos[pos] == -1)
-      return -1;
-
-   return ((shader->inst[1] & abspos[opr->srcpos[pos]]) ? 1 : 0);
-}
-
-nvsSwzComp NV30FP_TX_SWIZZLE[4] = {NVS_SWZ_X, NVS_SWZ_Y, NVS_SWZ_Z, NVS_SWZ_W };
-
-static void
-NV30FPTXSwizzle(int hwswz, nvsSwzComp *swz)
-{
-   swz[NVS_SWZ_W] = NV30FP_TX_SWIZZLE[(hwswz & 0xC0) >> 6];
-   swz[NVS_SWZ_Z] = NV30FP_TX_SWIZZLE[(hwswz & 0x30) >> 4];
-   swz[NVS_SWZ_Y] = NV30FP_TX_SWIZZLE[(hwswz & 0x0C) >> 2];
-   swz[NVS_SWZ_X] = NV30FP_TX_SWIZZLE[(hwswz & 0x03) >> 0];
-}
-
-static void
-NV30FPGetSourceSwizzle(nvsFunc * shader, int merged, int pos, nvsSwzComp *swz)
-{
-   unsigned int src;
-   int swzbits;
-
-   src = shader->GetSourceHW(shader, merged, pos);
-   swzbits = (src & NV30_FP_REG_SWZ_ALL_MASK) >> NV30_FP_REG_SWZ_ALL_SHIFT;
-   NV30FPTXSwizzle(swzbits, swz);
-}
-
-static int
-NV30FPGetSourceIndexed(nvsFunc * shader, int merged, int pos)
-{
-   switch (shader->GetSourceFile(shader, merged, pos)) {
-   case NVS_FILE_ATTRIB:
-      return ((shader->inst[3] & NV30_FP_OP_INDEX_INPUT) ? 1 : 0);
-   default:
-      return 0;
-   }
-}
-
-static void
-NV30FPGetSourceConstVal(nvsFunc * shader, int merged, int pos, float *val)
-{
-   val[0] = *(float *) &(shader->inst[4]);
-   val[1] = *(float *) &(shader->inst[5]);
-   val[2] = *(float *) &(shader->inst[6]);
-   val[3] = *(float *) &(shader->inst[7]);
-}
-
-static int
-NV30FPGetSourceScale(nvsFunc * shader, int merged, int pos)
-{
-/*FIXME: is this per-source, only for a specific source, or all sources??*/
-   return (1 << ((shader->inst[2] & NV30_FP_OP_SRC_SCALE_MASK)
-                >> NV30_FP_OP_SRC_SCALE_SHIFT));
-}
-
-static int
-NV30FPGetAddressRegID(nvsFunc * shader)
-{
-   return 0;
-}
-
-static nvsSwzComp
-NV30FPGetAddressRegSwizzle(nvsFunc * shader)
-{
-   return NVS_SWZ_X;
-}
-
-static int
-NV30FPSupportsConditional(nvsFunc * shader)
-{
-   /*FIXME: Is this true of all ops? */
-   return 1;
-}
-
-static int
-NV30FPGetConditionUpdate(nvsFunc * shader)
-{
-   return ((shader->inst[0] & NV30_FP_OP_COND_WRITE_ENABLE) ? 1 : 0);
-}
-
-static int
-NV30FPGetConditionTest(nvsFunc * shader)
-{
-   /*FIXME: always? */
-   return 1;
-}
-
-static nvsCond
-NV30FPGetCondition(nvsFunc * shader)
-{
-   int cond;
-
-   cond = ((shader->inst[1] & NV30_FP_OP_COND_MASK)
-          >> NV30_FP_OP_COND_SHIFT);
-
-   switch (cond) {
-   case NV30_FP_OP_COND_FL: return NVS_COND_FL;
-   case NV30_FP_OP_COND_LT: return NVS_COND_LT;
-   case NV30_FP_OP_COND_EQ: return NVS_COND_EQ;
-   case NV30_FP_OP_COND_LE: return NVS_COND_LE;
-   case NV30_FP_OP_COND_GT: return NVS_COND_GT;
-   case NV30_FP_OP_COND_NE: return NVS_COND_NE;
-   case NV30_FP_OP_COND_GE: return NVS_COND_GE;
-   case NV30_FP_OP_COND_TR: return NVS_COND_TR;
-   default:
-      return NVS_COND_UNKNOWN;
-   }
-}
-
-static void
-NV30FPGetCondRegSwizzle(nvsFunc * shader, nvsSwzComp *swz)
-{
-   int swzbits;
-
-   swzbits = (shader->inst[1] & NV30_FP_OP_COND_SWZ_ALL_MASK)
-      >> NV30_FP_OP_COND_SWZ_ALL_SHIFT;
-   NV30FPTXSwizzle(swzbits, swz);
-}
-
-static int
-NV30FPGetCondRegID(nvsFunc * shader)
-{
-   return 0;
-}
-
-static nvsPrecision
-NV30FPGetPrecision(nvsFunc * shader)
-{
-   int p;
-
-   p = (shader->inst[0] & NV30_FP_OP_PRECISION_MASK)
-      >> NV30_FP_OP_PRECISION_SHIFT;
-
-   switch (p) {
-   case NV30_FP_PRECISION_FP32: return NVS_PREC_FLOAT32;
-   case NV30_FP_PRECISION_FP16: return NVS_PREC_FLOAT16;
-   case NV30_FP_PRECISION_FX12: return NVS_PREC_FIXED12;
-   default:
-      return NVS_PREC_UNKNOWN;
-   }
-}
-
-static int
-NV30FPGetSaturate(nvsFunc * shader)
-{
-   return ((shader->inst[0] & NV30_FP_OP_OUT_SAT) ? 1 : 0);
-}
-
-/*******************************************************************************
- * Init
- */
-void
-NV30FPInitShaderFuncs(nvsFunc * shader)
-{
-   /* These are probably bogus, I made them up... */
-   shader->MaxInst     = 1024;
-   shader->MaxAttrib   = 16;
-   shader->MaxTemp     = 32;
-   shader->MaxAddress  = 1;
-   shader->MaxConst    = 256;
-   shader->caps                = SCAP_SRC_ABS;
-
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_MOV, NVS_OP_MOV, 0, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_MUL, NVS_OP_MUL, 0, 1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_ADD, NVS_OP_ADD, 0, 1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_MAD, NVS_OP_MAD, 0, 1, 2);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_DP3, NVS_OP_DP3, 0, 1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_DP4, NVS_OP_DP4, 0, 1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_DST, NVS_OP_DST, 0, 1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_MIN, NVS_OP_MIN, 0, 1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_MAX, NVS_OP_MAX, 0, 1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_SLT, NVS_OP_SLT, 0, 1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_SGE, NVS_OP_SGE, 0, 1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_FRC, NVS_OP_FRC, 0, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_FLR, NVS_OP_FLR, 0, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_TEX, NVS_OP_TEX, 0, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_TXD, NVS_OP_TXD, 0, 1, 2);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_TXP, NVS_OP_TXP, 0, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_TXB, NVS_OP_TXB, 0, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_SEQ, NVS_OP_SEQ, 0, 1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_SGT, NVS_OP_SGT, 0, 1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_SLE, NVS_OP_SLE, 0, 1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_SNE, NVS_OP_SNE, 0, 1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_RCP, NVS_OP_RCP, 0, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_LG2, NVS_OP_LG2, 0, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_EX2, NVS_OP_EX2, 0, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_COS, NVS_OP_COS, 0, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_SIN, NVS_OP_SIN, 0, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_NOP, NVS_OP_NOP, -1, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_DDX, NVS_OP_DDX, 0, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_DDY, NVS_OP_DDY, 0, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_KIL, NVS_OP_KIL, -1, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_PK4B, NVS_OP_PK4B, 0, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_UP4B, NVS_OP_UP4B, 0, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_PK2H, NVS_OP_PK2H, 0, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_UP2H, NVS_OP_UP2H, 0, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_PK4UB, NVS_OP_PK4UB, 0, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_UP4UB, NVS_OP_UP4UB, 0, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_PK2US, NVS_OP_PK2US, 0, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_UP2US, NVS_OP_UP2US, 0, -1, -1);
-   /*FIXME: Haven't confirmed the source positions for the below opcodes */
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_LIT, NVS_OP_LIT, 0, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_LRP, NVS_OP_LRP, 0, 1, 2);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_POW, NVS_OP_POW, 0, 1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_RSQ, NVS_OP_RSQ, 0, -1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV30_FP_OP_OPCODE_RFL, NVS_OP_RFL, 0, 1, -1);
-
-   shader->GetOPTXRec          = NV30FPGetOPTXRec;
-   shader->GetOPTXFromSOP      = NV30FPGetOPTXFromSOP;
-
-   shader->UploadToHW          = NV30FPUploadToHW;
-   shader->UpdateConst         = NV30FPUpdateConst;
-
-   shader->InitInstruction     = NV30FPInitInstruction;
-   shader->SupportsOpcode      = NV30FPSupportsOpcode;
-   shader->SetOpcode           = NV30FPSetOpcode;
-   shader->SetCCUpdate         = NV30FPSetCCUpdate;
-   shader->SetCondition                = NV30FPSetCondition;
-   shader->SetResult           = NV30FPSetResult;
-   shader->SetSource           = NV30FPSetSource;
-   shader->SetTexImageUnit     = NV30FPSetTexImageUnit;
-   shader->SetSaturate         = NV30FPSetSaturate;
-   shader->SetLastInst         = NV30FPSetLastInst;
-
-   shader->HasMergedInst       = NV30FPHasMergedInst;
-   shader->IsLastInst          = NV30FPIsLastInst;
-   shader->GetOffsetNext       = NV30FPGetOffsetNext;
-   shader->GetOpcode           = NV30FPGetOpcode;
-   shader->GetOpcodeHW         = NV30FPGetOpcodeHW;
-   shader->GetDestFile         = NV30FPGetDestFile;
-   shader->GetDestID           = NV30FPGetDestID;
-   shader->GetDestMask         = NV30FPGetDestMask;
-   shader->GetSourceHW         = NV30FPGetSourceHW;
-   shader->GetSourceFile       = NV30FPGetSourceFile;
-   shader->GetSourceID         = NV30FPGetSourceID;
-   shader->GetTexImageUnit     = NV30FPGetTexImageUnit;
-   shader->GetSourceNegate     = NV30FPGetSourceNegate;
-   shader->GetSourceAbs                = NV30FPGetSourceAbs;
-   shader->GetSourceSwizzle    = NV30FPGetSourceSwizzle;
-   shader->GetSourceIndexed    = NV30FPGetSourceIndexed;
-   shader->GetSourceConstVal   = NV30FPGetSourceConstVal;
-   shader->GetSourceScale      = NV30FPGetSourceScale;
-   shader->GetRelAddressRegID  = NV30FPGetAddressRegID;
-   shader->GetRelAddressSwizzle = NV30FPGetAddressRegSwizzle;
-   shader->GetPrecision                = NV30FPGetPrecision;
-   shader->GetSaturate         = NV30FPGetSaturate;
-   shader->SupportsConditional = NV30FPSupportsConditional;
-   shader->GetConditionUpdate  = NV30FPGetConditionUpdate;
-   shader->GetConditionTest    = NV30FPGetConditionTest;
-   shader->GetCondition                = NV30FPGetCondition;
-   shader->GetCondRegSwizzle   = NV30FPGetCondRegSwizzle;
-   shader->GetCondRegID                = NV30FPGetCondRegID;
-}
diff --git a/src/mesa/drivers/dri/nouveau/nv30_shader.h b/src/mesa/drivers/dri/nouveau/nv30_shader.h
deleted file mode 100644 (file)
index 7a027dd..0000000
+++ /dev/null
@@ -1,379 +0,0 @@
-#ifndef __NV30_SHADER_H__
-#define __NV30_SHADER_H__
-
-/* Vertex programs instruction set
- *
- * 128bit opcodes, split into 4 32-bit ones for ease of use.
- *
- * Non-native instructions
- *      ABS - MOV + NV40_VP_INST0_DEST_ABS
- *      POW - EX2 + MUL + LG2
- *      SUB - ADD, second source negated
- *      SWZ - MOV
- *      XPD -  
- *
- * Register access
- *      - Only one INPUT can be accessed per-instruction (move extras into TEMPs)
- *      - Only one CONST can be accessed per-instruction (move extras into TEMPs)
- *
- * Relative Addressing
- *      According to the value returned for MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB
- *      there are only two address registers available.  The destination in the ARL
- *      instruction is set to TEMP <n> (The temp isn't actually written).
- *
- *      When using vanilla ARB_v_p, the proprietary driver will squish both the available
- *      ADDRESS regs into the first hardware reg in the X and Y components.
- *
- *      To use an address reg as an index into consts, the CONST_SRC is set to
- *      (const_base + offset) and INDEX_CONST is set.
- *
- *      To access the second address reg use ADDR_REG_SELECT_1. A particular component
- *      of the address regs is selected with ADDR_SWZ.
- *
- *      Only one address register can be accessed per instruction.
- *
- * Conditional execution (see NV_vertex_program{2,3} for details)
- *      Conditional execution of an instruction is enabled by setting COND_TEST_ENABLE, and
- *      selecting the condition which will allow the test to pass with COND_{FL,LT,...}.
- *      It is possible to swizzle the values in the condition register, which allows for
- *      testing against an individual component.
- *
- * Branching
- *      The BRA/CAL instructions seem to follow a slightly different opcode layout.  The
- *      destination instruction ID (IADDR) overlaps a source field.  Instruction ID's seem to
- *      be numbered based on the UPLOAD_FROM_ID FIFO command, and is incremented automatically
- *      on each UPLOAD_INST FIFO command.
- *
- *      Conditional branching is achieved by using the condition tests described above.
- *      There doesn't appear to be dedicated looping instructions, but this can be done
- *      using a temp reg + conditional branching.
- *
- *      Subroutines may be uploaded before the main program itself, but the first executed
- *      instruction is determined by the PROGRAM_START_ID FIFO command.
- *
- */
-
-/* DWORD 0 */
-#define NV30_VP_INST_ADDR_REG_SELECT_1                         (1 << 24)
-#define NV30_VP_INST_SRC2_ABS                                  (1 << 23) /* guess */
-#define NV30_VP_INST_SRC1_ABS                                  (1 << 22) /* guess */
-#define NV30_VP_INST_SRC0_ABS                                  (1 << 21) /* guess */
-#define NV30_VP_INST_OUT_RESULT                                        (1 << 20)
-#define NV30_VP_INST_DEST_TEMP_ID_SHIFT                                16
-#define NV30_VP_INST_DEST_TEMP_ID_MASK                         (0x0F << 16)
-#define NV30_VP_INST_COND_UPDATE_ENABLE                                (1<<15)
-#define NV30_VP_INST_COND_TEST_ENABLE                          (1<<14)
-#define NV30_VP_INST_COND_SHIFT                                        11
-#define NV30_VP_INST_COND_MASK                                 (0x07 << 11)
-#      define NV30_VP_INST_COND_FL     0 /* guess */   
-#      define NV30_VP_INST_COND_LT     1       
-#      define NV30_VP_INST_COND_EQ     2
-#      define NV30_VP_INST_COND_LE     3
-#      define NV30_VP_INST_COND_GT     4
-#      define NV30_VP_INST_COND_NE     5
-#      define NV30_VP_INST_COND_GE     6
-#      define NV30_VP_INST_COND_TR     7 /* guess */
-#define NV30_VP_INST_COND_SWZ_X_SHIFT                          9
-#define NV30_VP_INST_COND_SWZ_X_MASK                           (0x03 <<  9)
-#define NV30_VP_INST_COND_SWZ_Y_SHIFT                          7
-#define NV30_VP_INST_COND_SWZ_Y_MASK                           (0x03 <<  7)
-#define NV30_VP_INST_COND_SWZ_Z_SHIFT                          5
-#define NV30_VP_INST_COND_SWZ_Z_MASK                           (0x03 <<  5)
-#define NV30_VP_INST_COND_SWZ_W_SHIFT                          3
-#define NV30_VP_INST_COND_SWZ_W_MASK                           (0x03 <<  3)
-#define NV30_VP_INST_COND_SWZ_ALL_SHIFT                                3
-#define NV30_VP_INST_COND_SWZ_ALL_MASK                         (0xFF <<  3)
-#define NV30_VP_INST_ADDR_SWZ_SHIFT                            1
-#define NV30_VP_INST_ADDR_SWZ_MASK                             (0x03 <<  1)
-#define NV30_VP_INST_SCA_OPCODEH_SHIFT                         0
-#define NV30_VP_INST_SCA_OPCODEH_MASK                          (0x01 <<  0)
-
-/* DWORD 1 */
-#define NV30_VP_INST_SCA_OPCODEL_SHIFT                         28
-#define NV30_VP_INST_SCA_OPCODEL_MASK                          (0x0F << 28)
-#      define NV30_VP_INST_OP_NOP      0x00
-#      define NV30_VP_INST_OP_RCP      0x02
-#      define NV30_VP_INST_OP_RCC      0x03
-#      define NV30_VP_INST_OP_RSQ      0x04
-#      define NV30_VP_INST_OP_EXP      0x05
-#      define NV30_VP_INST_OP_LOG      0x06
-#      define NV30_VP_INST_OP_LIT      0x07
-#      define NV30_VP_INST_OP_BRA      0x09
-#      define NV30_VP_INST_OP_CAL      0x0B
-#      define NV30_VP_INST_OP_RET      0x0C
-#      define NV30_VP_INST_OP_LG2      0x0D
-#      define NV30_VP_INST_OP_EX2      0x0E
-#      define NV30_VP_INST_OP_SIN      0x0F
-#      define NV30_VP_INST_OP_COS      0x10
-#define NV30_VP_INST_VEC_OPCODE_SHIFT                          23
-#define NV30_VP_INST_VEC_OPCODE_MASK                           (0x1F << 23)
-#      define NV30_VP_INST_OP_NOPV     0x00
-#      define NV30_VP_INST_OP_MOV      0x01
-#      define NV30_VP_INST_OP_MUL      0x02
-#      define NV30_VP_INST_OP_ADD      0x03
-#      define NV30_VP_INST_OP_MAD      0x04
-#      define NV30_VP_INST_OP_DP3      0x05
-#      define NV30_VP_INST_OP_DP4      0x07
-#      define NV30_VP_INST_OP_DPH      0x06
-#      define NV30_VP_INST_OP_DST      0x08
-#      define NV30_VP_INST_OP_MIN      0x09
-#      define NV30_VP_INST_OP_MAX      0x0A
-#      define NV30_VP_INST_OP_SLT      0x0B
-#      define NV30_VP_INST_OP_SGE      0x0C
-#      define NV30_VP_INST_OP_ARL      0x0D
-#      define NV30_VP_INST_OP_FRC      0x0E
-#      define NV30_VP_INST_OP_FLR      0x0F
-#      define NV30_VP_INST_OP_SEQ      0x10
-#      define NV30_VP_INST_OP_SFL      0x11
-#      define NV30_VP_INST_OP_SGT      0x12
-#      define NV30_VP_INST_OP_SLE      0x13
-#      define NV30_VP_INST_OP_SNE      0x14
-#      define NV30_VP_INST_OP_STR      0x15
-#      define NV30_VP_INST_OP_SSG      0x16
-#      define NV30_VP_INST_OP_ARR      0x17
-#      define NV30_VP_INST_OP_ARA      0x18
-#define NV30_VP_INST_CONST_SRC_SHIFT                           14
-#define NV30_VP_INST_CONST_SRC_MASK                            (0xFF << 14)
-#define NV30_VP_INST_INPUT_SRC_SHIFT                           9               /*NV20*/
-#define NV30_VP_INST_INPUT_SRC_MASK                            (0x0F <<  9)    /*NV20*/
-#      define NV30_VP_INST_IN_POS      0         /* These seem to match the bindings specified in */
-#      define NV30_VP_INST_IN_WEIGHT   1         /* the ARB_v_p spec (2.14.3.1) */
-#      define NV30_VP_INST_IN_NORMAL   2         
-#      define NV30_VP_INST_IN_COL0     3         /* Should probably confirm them all though */
-#      define NV30_VP_INST_IN_COL1     4
-#      define NV30_VP_INST_IN_FOGC     5
-#      define NV30_VP_INST_IN_TC0      8
-#      define NV30_VP_INST_IN_TC(n)    (8+n)
-#define NV30_VP_INST_SRC0H_SHIFT                               0               /*NV20*/
-#define NV30_VP_INST_SRC0H_MASK                                        (0x1FF << 0)    /*NV20*/
-
-/* DWORD 2 */
-#define NV30_VP_INST_SRC0L_SHIFT                               26              /*NV20*/
-#define NV30_VP_INST_SRC0L_MASK                                        (0x3F  <<26)    /*NV20*/
-#define NV30_VP_INST_SRC1_SHIFT                                        11              /*NV20*/
-#define NV30_VP_INST_SRC1_MASK                                 (0x7FFF<<11)    /*NV20*/
-#define NV30_VP_INST_SRC2H_SHIFT                               0               /*NV20*/
-#define NV30_VP_INST_SRC2H_MASK                                        (0x7FF << 0)    /*NV20*/
-#define NV30_VP_INST_IADDR_SHIFT                               2
-#define NV30_VP_INST_IADDR_MASK                                        (0xFF <<  2)    /* guess */
-
-/* DWORD 3 */
-#define NV30_VP_INST_SRC2L_SHIFT                               28              /*NV20*/
-#define NV30_VP_INST_SRC2L_MASK                                        (0x0F  <<28)    /*NV20*/
-#define NV30_VP_INST_STEMP_WRITEMASK_SHIFT                     24
-#define NV30_VP_INST_STEMP_WRITEMASK_MASK                      (0x0F << 24)
-#define NV30_VP_INST_VTEMP_WRITEMASK_SHIFT                     20
-#define NV30_VP_INST_VTEMP_WRITEMASK_MASK                      (0x0F << 20)
-#define NV30_VP_INST_SDEST_WRITEMASK_SHIFT                     16
-#define NV30_VP_INST_SDEST_WRITEMASK_MASK                      (0x0F << 16)
-#define NV30_VP_INST_VDEST_WRITEMASK_SHIFT                     12              /*NV20*/
-#define NV30_VP_INST_VDEST_WRITEMASK_MASK                      (0x0F << 12)    /*NV20*/
-#define NV30_VP_INST_DEST_ID_SHIFT                             2
-#define NV30_VP_INST_DEST_ID_MASK                              (0x0F <<  2)
-#      define NV30_VP_INST_DEST_POS    0
-#      define NV30_VP_INST_DEST_COL0   3
-#      define NV30_VP_INST_DEST_COL1   4
-#      define NV30_VP_INST_DEST_TC(n)  (8+n)
-
-/* Source-register definition - matches NV20 exactly */
-#define NV30_VP_SRC_REG_NEGATE                                 (1<<14)
-#define NV30_VP_SRC_REG_SWZ_X_SHIFT                            12
-#define NV30_VP_SRC_REG_SWZ_X_MASK                             (0x03  <<12)
-#define NV30_VP_SRC_REG_SWZ_Y_SHIFT                            10
-#define NV30_VP_SRC_REG_SWZ_Y_MASK                             (0x03  <<10)
-#define NV30_VP_SRC_REG_SWZ_Z_SHIFT                            8
-#define NV30_VP_SRC_REG_SWZ_Z_MASK                             (0x03  << 8)
-#define NV30_VP_SRC_REG_SWZ_W_SHIFT                            6
-#define NV30_VP_SRC_REG_SWZ_W_MASK                             (0x03  << 6)
-#define NV30_VP_SRC_REG_SWZ_ALL_SHIFT                          6
-#define NV30_VP_SRC_REG_SWZ_ALL_MASK                           (0xFF  << 6)
-#define NV30_VP_SRC_REG_TEMP_ID_SHIFT                          2
-#define NV30_VP_SRC_REG_TEMP_ID_MASK                           (0x0F  << 0)
-#define NV30_VP_SRC_REG_TYPE_SHIFT                             0
-#define NV30_VP_SRC_REG_TYPE_MASK                              (0x03  << 0)
-#define NV30_VP_SRC_REG_TYPE_TEMP      1
-#define NV30_VP_SRC_REG_TYPE_INPUT     2
-#define NV30_VP_SRC_REG_TYPE_CONST     3 /* guess */
-
-/*
- * Each fragment program opcode appears to be comprised of 4 32-bit values.
- *
- *      0 - Opcode, output reg/mask, ATTRIB source
- *      1 - Source 0
- *      2 - Source 1
- *      3 - Source 2
- *
- * There appears to be no special difference between result regs and temp regs.
- *             result.color == R0.xyzw
- *             result.depth == R1.z
- * When the fragprog contains instructions to write depth, NV30_TCL_PRIMITIVE_3D_UNK1D78=0
- * otherwise it is set to 1.
- *
- * Constants are inserted directly after the instruction that uses them.
- * 
- * It appears that it's not possible to use two input registers in one
- * instruction as the input sourcing is done in the instruction dword
- * and not the source selection dwords.  As such instructions such as:
- * 
- *              ADD result.color, fragment.color, fragment.texcoord[0];
- *
- * must be split into two MOV's and then an ADD (nvidia does this) but
- * I'm not sure why it's not just one MOV and then source the second input
- * in the ADD instruction..
- *
- * Negation of the full source is done with NV30_FP_REG_NEGATE, arbitrary
- * negation requires multiplication with a const.
- *
- * Arbitrary swizzling is supported with the exception of SWIZZLE_ZERO/SWIZZLE_ONE
- * The temp/result regs appear to be initialised to (0.0, 0.0, 0.0, 0.0) as SWIZZLE_ZERO
- * is implemented simply by not writing to the relevant components of the destination.
- *
- * Conditional execution
- *   TODO
- * 
- * Non-native instructions:
- *      LIT
- *      LRP - MAD+MAD
- *      SUB - ADD, negate second source
- *      RSQ - LG2 + EX2
- *      POW - LG2 + MUL + EX2
- *      SCS - COS + SIN
- *      XPD
- */
-
-//== Opcode / Destination selection ==
-#define NV30_FP_OP_PROGRAM_END                                 (1 << 0)
-#define NV30_FP_OP_OUT_REG_SHIFT                               1
-#define NV30_FP_OP_OUT_REG_MASK                                        (31 << 1)       /* uncertain */
-/* Needs to be set when writing outputs to get expected result.. */
-#define NV30_FP_OP_UNK0_7                                      (1 << 7)
-#define NV30_FP_OP_COND_WRITE_ENABLE                           (1 << 8)
-#define NV30_FP_OP_OUTMASK_SHIFT                               9
-#define NV30_FP_OP_OUTMASK_MASK                                        (0xF << 9)
-#      define NV30_FP_OP_OUT_X (1<<9)
-#      define NV30_FP_OP_OUT_Y (1<<10)
-#      define NV30_FP_OP_OUT_Z (1<<11)
-#      define NV30_FP_OP_OUT_W (1<<12)
-/* Uncertain about these, especially the input_src values.. it's possible that
- * they can be dynamically changed.
- */
-#define NV30_FP_OP_INPUT_SRC_SHIFT                             13
-#define NV30_FP_OP_INPUT_SRC_MASK                              (15 << 13)
-#      define NV30_FP_OP_INPUT_SRC_POSITION    0x0
-#      define NV30_FP_OP_INPUT_SRC_COL0        0x1
-#      define NV30_FP_OP_INPUT_SRC_COL1        0x2
-#      define NV30_FP_OP_INPUT_SRC_FOGC        0x3
-#      define NV30_FP_OP_INPUT_SRC_TC0         0x4
-#      define NV30_FP_OP_INPUT_SRC_TC(n)       (0x4 + n)
-#define NV30_FP_OP_TEX_UNIT_SHIFT                              17
-#define NV30_FP_OP_TEX_UNIT_MASK                               (0xF << 17) /* guess */
-#define NV30_FP_OP_PRECISION_SHIFT                             22
-#define NV30_FP_OP_PRECISION_MASK                              (3 << 22)
-#   define NV30_FP_PRECISION_FP32      0
-#   define NV30_FP_PRECISION_FP16      1
-#   define NV30_FP_PRECISION_FX12      2
-#define NV30_FP_OP_OPCODE_SHIFT                                        24
-#define NV30_FP_OP_OPCODE_MASK                                 (0x3F << 24)
-#      define NV30_FP_OP_OPCODE_NOP    0x00
-#      define NV30_FP_OP_OPCODE_MOV    0x01
-#      define NV30_FP_OP_OPCODE_MUL    0x02
-#      define NV30_FP_OP_OPCODE_ADD    0x03
-#      define NV30_FP_OP_OPCODE_MAD    0x04
-#      define NV30_FP_OP_OPCODE_DP3    0x05
-#      define NV30_FP_OP_OPCODE_DP4    0x06
-#      define NV30_FP_OP_OPCODE_DST    0x07
-#      define NV30_FP_OP_OPCODE_MIN    0x08
-#      define NV30_FP_OP_OPCODE_MAX    0x09
-#      define NV30_FP_OP_OPCODE_SLT    0x0A
-#      define NV30_FP_OP_OPCODE_SGE    0x0B
-#      define NV30_FP_OP_OPCODE_SLE    0x0C
-#      define NV30_FP_OP_OPCODE_SGT    0x0D
-#      define NV30_FP_OP_OPCODE_SNE    0x0E
-#      define NV30_FP_OP_OPCODE_SEQ    0x0F
-#      define NV30_FP_OP_OPCODE_FRC    0x10
-#      define NV30_FP_OP_OPCODE_FLR    0x11
-#      define NV30_FP_OP_OPCODE_KIL    0x12
-#      define NV30_FP_OP_OPCODE_PK4B   0x13
-#      define NV30_FP_OP_OPCODE_UP4B   0x14
-#      define NV30_FP_OP_OPCODE_DDX    0x15 /* can only write XY */
-#      define NV30_FP_OP_OPCODE_DDY    0x16 /* can only write XY */
-#      define NV30_FP_OP_OPCODE_TEX    0x17
-#      define NV30_FP_OP_OPCODE_TXP    0x18
-#      define NV30_FP_OP_OPCODE_TXD    0x19
-#      define NV30_FP_OP_OPCODE_RCP    0x1A
-#      define NV30_FP_OP_OPCODE_RSQ    0x1B
-#      define NV30_FP_OP_OPCODE_EX2    0x1C
-#      define NV30_FP_OP_OPCODE_LG2    0x1D
-#      define NV30_FP_OP_OPCODE_LIT    0x1E
-#      define NV30_FP_OP_OPCODE_LRP    0x1F
-#      define NV30_FP_OP_OPCODE_COS    0x22
-#      define NV30_FP_OP_OPCODE_SIN    0x23
-#      define NV30_FP_OP_OPCODE_PK2H   0x24
-#      define NV30_FP_OP_OPCODE_UP2H   0x25
-#      define NV30_FP_OP_OPCODE_POW    0x26
-#      define NV30_FP_OP_OPCODE_PK4UB  0x27
-#      define NV30_FP_OP_OPCODE_UP4UB  0x28
-#      define NV30_FP_OP_OPCODE_PK2US  0x29
-#      define NV30_FP_OP_OPCODE_UP2US  0x2A
-#      define NV30_FP_OP_OPCODE_DP2A   0x2E
-#      define NV30_FP_OP_OPCODE_TXB    0x31
-#      define NV30_FP_OP_OPCODE_RFL    0x36
-#define NV30_FP_OP_OUT_SAT                                     (1 << 31)
-
-/* high order bits of SRC0 */
-#define NV30_FP_OP_OUT_ABS                                     (1 << 29)
-#define NV30_FP_OP_COND_SWZ_W_SHIFT                            27
-#define NV30_FP_OP_COND_SWZ_W_MASK                             (3 << 27)
-#define NV30_FP_OP_COND_SWZ_Z_SHIFT                            25
-#define NV30_FP_OP_COND_SWZ_Z_MASK                             (3 << 25)
-#define NV30_FP_OP_COND_SWZ_Y_SHIFT                            23
-#define NV30_FP_OP_COND_SWZ_Y_MASK                             (3 << 23)
-#define NV30_FP_OP_COND_SWZ_X_SHIFT                            21
-#define NV30_FP_OP_COND_SWZ_X_MASK                             (3 << 21)
-#define NV30_FP_OP_COND_SWZ_ALL_SHIFT                          21
-#define NV30_FP_OP_COND_SWZ_ALL_MASK                           (0xFF << 21)
-#define NV30_FP_OP_COND_SHIFT                                  18
-#define NV30_FP_OP_COND_MASK                                   (0x07 << 18)
-#      define NV30_FP_OP_COND_FL       0
-#      define NV30_FP_OP_COND_LT       1
-#      define NV30_FP_OP_COND_EQ       2
-#      define NV30_FP_OP_COND_LE       3
-#      define NV30_FP_OP_COND_GT       4
-#      define NV30_FP_OP_COND_NE       5
-#      define NV30_FP_OP_COND_GE       6
-#      define NV30_FP_OP_COND_TR       7
-
-/* high order bits of SRC1 */
-#define NV30_FP_OP_SRC_SCALE_SHIFT                             28
-#define NV30_FP_OP_SRC_SCALE_MASK                              (3 << 28)
-
-/* high order bits of SRC2 */
-#define NV30_FP_OP_INDEX_INPUT                                 (1 << 30)
-
-//== Register selection ==
-#define NV30_FP_REG_ALL_MASK                                   (0x1FFFF<<0)
-#define NV30_FP_REG_TYPE_SHIFT                                 0
-#define NV30_FP_REG_TYPE_MASK                                  (3 << 0)
-#      define NV30_FP_REG_TYPE_TEMP    0
-#      define NV30_FP_REG_TYPE_INPUT   1
-#      define NV30_FP_REG_TYPE_CONST   2
-#define NV30_FP_REG_SRC_SHIFT                                  2 /* uncertain */
-#define NV30_FP_REG_SRC_MASK                                   (31 << 2)
-#define NV30_FP_REG_UNK_0                                      (1 << 8)
-#define NV30_FP_REG_SWZ_ALL_SHIFT                              9
-#define NV30_FP_REG_SWZ_ALL_MASK                               (255 << 9)
-#define NV30_FP_REG_SWZ_X_SHIFT                                        9
-#define NV30_FP_REG_SWZ_X_MASK                                 (3 << 9)
-#define NV30_FP_REG_SWZ_Y_SHIFT                                        11
-#define NV30_FP_REG_SWZ_Y_MASK                                 (3 << 11)
-#define NV30_FP_REG_SWZ_Z_SHIFT                                        13
-#define NV30_FP_REG_SWZ_Z_MASK                                 (3 << 13)
-#define NV30_FP_REG_SWZ_W_SHIFT                                        15
-#define NV30_FP_REG_SWZ_W_MASK                                 (3 << 15)
-#      define NV30_FP_SWIZZLE_X        0
-#      define NV30_FP_SWIZZLE_Y        1
-#      define NV30_FP_SWIZZLE_Z        2
-#      define NV30_FP_SWIZZLE_W        3
-#define NV30_FP_REG_NEGATE                                     (1 << 17)
-
-#endif
diff --git a/src/mesa/drivers/dri/nouveau/nv30_state.c b/src/mesa/drivers/dri/nouveau/nv30_state.c
deleted file mode 100644 (file)
index 9b01095..0000000
+++ /dev/null
@@ -1,1002 +0,0 @@
-/**************************************************************************
-
-Copyright 2006 Nouveau
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-#include "nouveau_context.h"
-#include "nouveau_object.h"
-#include "nouveau_fifo.h"
-#include "nouveau_reg.h"
-#include "nouveau_state.h"
-
-#include "tnl/t_pipeline.h"
-
-#include "mtypes.h"
-#include "colormac.h"
-
-#define NOUVEAU_CARD_USING_SHADERS (nmesa->screen->card->type >= NV_40)
-
-static void nv30AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte ubRef;
-       CLAMPED_FLOAT_TO_UBYTE(ubRef, ref);
-
-       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_ALPHA_FUNC_FUNC, 2);
-       OUT_RING_CACHE(func);     /* NV30_TCL_PRIMITIVE_3D_ALPHA_FUNC_FUNC */
-       OUT_RING_CACHE(ubRef);    /* NV30_TCL_PRIMITIVE_3D_ALPHA_FUNC_REF  */
-}
-
-static void nv30BlendColor(GLcontext *ctx, const GLfloat color[4])
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); 
-       GLubyte cf[4];
-
-       CLAMPED_FLOAT_TO_UBYTE(cf[0], color[0]);
-       CLAMPED_FLOAT_TO_UBYTE(cf[1], color[1]);
-       CLAMPED_FLOAT_TO_UBYTE(cf[2], color[2]);
-       CLAMPED_FLOAT_TO_UBYTE(cf[3], color[3]);
-
-       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_BLEND_COLOR, 1);
-       OUT_RING_CACHE(PACK_COLOR_8888(cf[3], cf[1], cf[2], cf[0]));
-}
-
-static void nv30BlendEquationSeparate(GLcontext *ctx, GLenum modeRGB, GLenum modeA)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_BLEND_EQUATION, 1);
-       OUT_RING_CACHE((modeA<<16) | modeRGB);
-}
-
-
-static void nv30BlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB, GLenum dfactorRGB,
-               GLenum sfactorA, GLenum dfactorA)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_BLEND_FUNC_SRC, 2);
-       OUT_RING_CACHE((sfactorA<<16) | sfactorRGB);
-       OUT_RING_CACHE((dfactorA<<16) | dfactorRGB);
-}
-
-static void nv30Clear(GLcontext *ctx, GLbitfield mask)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       GLuint hw_bufs = 0;
-
-       if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT))
-               hw_bufs |= 0xf0;
-       if (mask & (BUFFER_BIT_DEPTH))
-               hw_bufs |= 0x03;
-
-       if (hw_bufs) {
-               BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_CLEAR_WHICH_BUFFERS, 1);
-               OUT_RING(hw_bufs);
-       }
-}
-
-static void nv30ClearColor(GLcontext *ctx, const GLfloat color[4])
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte c[4];
-       UNCLAMPED_FLOAT_TO_RGBA_CHAN(c,color);
-       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_CLEAR_VALUE_ARGB, 1);
-       OUT_RING_CACHE(PACK_COLOR_8888(c[3],c[0],c[1],c[2]));
-}
-
-static void nv30ClearDepth(GLcontext *ctx, GLclampd d)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       nmesa->clear_value=((nmesa->clear_value&0x000000FF)|(((uint32_t)(d*0xFFFFFF))<<8));
-       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_CLEAR_VALUE_DEPTH, 1);
-       OUT_RING_CACHE(nmesa->clear_value);
-}
-
-/* we're don't support indexed buffers
-   void (*ClearIndex)(GLcontext *ctx, GLuint index)
- */
-
-static void nv30ClearStencil(GLcontext *ctx, GLint s)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       nmesa->clear_value=((nmesa->clear_value&0xFFFFFF00)|(s&0x000000FF));
-       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_CLEAR_VALUE_DEPTH, 1);
-       OUT_RING_CACHE(nmesa->clear_value);
-}
-
-static void nv30ClipPlane(GLcontext *ctx, GLenum plane, const GLfloat *equation)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       if (NOUVEAU_CARD_USING_SHADERS)
-               return;
-
-       plane -= GL_CLIP_PLANE0;
-       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_CLIP_PLANE_A(plane), 4);
-       OUT_RING_CACHEf(equation[0]);
-       OUT_RING_CACHEf(equation[1]);
-       OUT_RING_CACHEf(equation[2]);
-       OUT_RING_CACHEf(equation[3]);
-}
-
-static void nv30ColorMask(GLcontext *ctx, GLboolean rmask, GLboolean gmask,
-               GLboolean bmask, GLboolean amask )
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_COLOR_MASK, 1);
-       OUT_RING_CACHE(((amask && 0x01) << 24) | ((rmask && 0x01) << 16) | ((gmask && 0x01)<< 8) | ((bmask && 0x01) << 0));
-}
-
-static void nv30ColorMaterial(GLcontext *ctx, GLenum face, GLenum mode)
-{
-       // TODO I need love
-}
-
-static void nv30CullFace(GLcontext *ctx, GLenum mode)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_CULL_FACE, 1);
-       OUT_RING_CACHE(mode);
-}
-
-static void nv30FrontFace(GLcontext *ctx, GLenum mode)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_FRONT_FACE, 1);
-       OUT_RING_CACHE(mode);
-}
-
-static void nv30DepthFunc(GLcontext *ctx, GLenum func)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_DEPTH_FUNC, 1);
-       OUT_RING_CACHE(func);
-}
-
-static void nv30DepthMask(GLcontext *ctx, GLboolean flag)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_DEPTH_WRITE_ENABLE, 1);
-       OUT_RING_CACHE(flag);
-}
-
-static void nv30DepthRange(GLcontext *ctx, GLclampd nearval, GLclampd farval)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_DEPTH_RANGE_NEAR, 2);
-       OUT_RING_CACHEf(nearval);
-       OUT_RING_CACHEf(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 );
-
-static void nv30Enable(GLcontext *ctx, GLenum cap, GLboolean state)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       switch(cap)
-       {
-               case GL_ALPHA_TEST:
-                       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_ALPHA_FUNC_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_AUTO_NORMAL:
-               case GL_BLEND:
-                       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_BLEND_FUNC_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       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:
-                       if (NOUVEAU_CARD_USING_SHADERS) {
-                               nouveauShader *nvs = (nouveauShader *)ctx->VertexProgram._Current;
-                               if (nvs)
-                                       nvs->translated = GL_FALSE;
-                       } else {
-                               BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_CLIP_PLANE_ENABLE(cap-GL_CLIP_PLANE0), 1);
-                               OUT_RING_CACHE(state);
-                       }
-                       break;
-               case GL_COLOR_LOGIC_OP:
-                       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_COLOR_LOGIC_OP_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_COLOR_MATERIAL:
-//             case GL_COLOR_SUM_EXT:
-//             case GL_COLOR_TABLE:
-//             case GL_CONVOLUTION_1D:
-//             case GL_CONVOLUTION_2D:
-               case GL_CULL_FACE:
-                       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_CULL_FACE_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_DEPTH_TEST:
-                       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_DEPTH_TEST_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_DITHER:
-                       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_DITHER_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_FOG:
-                       if (NOUVEAU_CARD_USING_SHADERS)
-                               break;
-                       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_FOG_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_HISTOGRAM:
-//             case GL_INDEX_LOGIC_OP:
-               case GL_LIGHT0:
-               case GL_LIGHT1:
-               case GL_LIGHT2:
-               case GL_LIGHT3:
-               case GL_LIGHT4:
-               case GL_LIGHT5:
-               case GL_LIGHT6:
-               case GL_LIGHT7:
-                       {
-                       uint32_t mask=0x11<<(2*(cap-GL_LIGHT0));
-
-                       if (NOUVEAU_CARD_USING_SHADERS)
-                               break;
-
-                       nmesa->enabled_lights=((nmesa->enabled_lights&mask)|(mask*state));
-                       if (nmesa->lighting_enabled)
-                       {
-                               BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_ENABLED_LIGHTS, 1);
-                               OUT_RING_CACHE(nmesa->enabled_lights);
-                       }
-                       break;
-                       }
-               case GL_LIGHTING:
-                       if (NOUVEAU_CARD_USING_SHADERS)
-                               break;
-
-                       nmesa->lighting_enabled=state;
-                       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_ENABLED_LIGHTS, 1);
-                       if (nmesa->lighting_enabled)
-                               OUT_RING_CACHE(nmesa->enabled_lights);
-                       else
-                               OUT_RING_CACHE(0x0);
-                       break;
-//             case GL_LINE_SMOOTH:
-//             case GL_LINE_STIPPLE:
-//             case GL_MAP1_COLOR_4:
-//             case GL_MAP1_INDEX:
-//             case GL_MAP1_NORMAL:
-//             case GL_MAP1_TEXTURE_COORD_1:
-//             case GL_MAP1_TEXTURE_COORD_2:
-//             case GL_MAP1_TEXTURE_COORD_3:
-//             case GL_MAP1_TEXTURE_COORD_4:
-//             case GL_MAP1_VERTEX_3:
-//             case GL_MAP1_VERTEX_4:
-//             case GL_MAP2_COLOR_4:
-//             case GL_MAP2_INDEX:
-//             case GL_MAP2_NORMAL:
-//             case GL_MAP2_TEXTURE_COORD_1:
-//             case GL_MAP2_TEXTURE_COORD_2:
-//             case GL_MAP2_TEXTURE_COORD_3:
-//             case GL_MAP2_TEXTURE_COORD_4:
-//             case GL_MAP2_VERTEX_3:
-//             case GL_MAP2_VERTEX_4:
-//             case GL_MINMAX:
-               case GL_NORMALIZE:
-                       if (nmesa->screen->card->type != NV_44) {
-                               BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_NORMALIZE_ENABLE, 1);
-                               OUT_RING_CACHE(state);
-                       }
-                       break;
-//             case GL_POINT_SMOOTH:
-               case GL_POLYGON_OFFSET_POINT:
-                       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_POLYGON_OFFSET_POINT_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_POLYGON_OFFSET_LINE:
-                       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_POLYGON_OFFSET_LINE_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_POLYGON_OFFSET_FILL:
-                       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_POLYGON_OFFSET_FILL_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_POLYGON_SMOOTH:
-                       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_POLYGON_SMOOTH_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_POLYGON_STIPPLE:
-                       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_POLYGON_STIPPLE_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_POST_COLOR_MATRIX_COLOR_TABLE:
-//             case GL_POST_CONVOLUTION_COLOR_TABLE:
-//             case GL_RESCALE_NORMAL:
-               case GL_SCISSOR_TEST:
-                       /* No enable bit, nv30Scissor will adjust to max range */
-                       ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
-                                                ctx->Scissor.Width, ctx->Scissor.Height);
-                       break;
-//             case GL_SEPARABLE_2D:
-               case GL_STENCIL_TEST:
-                       // TODO BACK and FRONT ?
-                       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_STENCIL_FRONT_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_STENCIL_BACK_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_TEXTURE_GEN_Q:
-//             case GL_TEXTURE_GEN_R:
-//             case GL_TEXTURE_GEN_S:
-//             case GL_TEXTURE_GEN_T:
-//             case GL_TEXTURE_1D:
-//             case GL_TEXTURE_2D:
-//             case GL_TEXTURE_3D:
-       }
-}
-
-static void nv30Fogfv(GLcontext *ctx, GLenum pname, const GLfloat *params)
-{
-    nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-    if (NOUVEAU_CARD_USING_SHADERS)
-        return;
-
-    switch(pname)
-    {
-    case GL_FOG_MODE:
-    {
-        int mode = 0;
-        /* The modes are different in GL and the card.  */
-        switch(ctx->Fog.Mode)
-        {
-        case GL_LINEAR:
-            mode = 0x804;
-            break;
-        case GL_EXP:
-            mode = 0x802;
-            break;
-        case GL_EXP2:
-            mode = 0x803;
-            break;
-        }
-       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_FOG_MODE, 1);
-       OUT_RING_CACHE (mode);
-       break;
-    }
-    case GL_FOG_COLOR:
-    {
-       GLubyte c[4];
-       UNCLAMPED_FLOAT_TO_RGBA_CHAN(c,params);
-        BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_FOG_COLOR, 1);
-        /* nvidia ignores the alpha channel */
-       OUT_RING_CACHE(PACK_COLOR_8888_REV(c[0],c[1],c[2],c[3]));
-        break;
-    }
-    case GL_FOG_DENSITY:
-    case GL_FOG_START:
-    case GL_FOG_END:
-    {
-        GLfloat f=0., c=0.;
-        switch(ctx->Fog.Mode)
-        {
-        case GL_LINEAR:
-            f = -1.0/(ctx->Fog.End - ctx->Fog.Start);
-            c = ctx->Fog.Start/(ctx->Fog.End - ctx->Fog.Start) + 2.001953;
-            break;
-        case GL_EXP:
-            f = -0.090168*ctx->Fog.Density;
-            c = 1.5;
-        case GL_EXP2:
-            f = -0.212330*ctx->Fog.Density;
-            c = 1.5;
-        }
-        BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_FOG_EQUATION_LINEAR, 1);
-        OUT_RING_CACHE(f);
-        BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_FOG_EQUATION_CONSTANT, 1);
-        OUT_RING_CACHE(c);
-        BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_FOG_EQUATION_QUADRATIC, 1);
-        OUT_RING_CACHE(0); /* Is this always the same? */
-        break;
-    }
-//    case GL_FOG_COORD_SRC:
-    default:
-        break;
-    }
-}
-   
-static void nv30Hint(GLcontext *ctx, GLenum target, GLenum mode)
-{
-       // TODO I need love (fog and line_smooth hints)
-}
-
-// void (*IndexMask)(GLcontext *ctx, GLuint mask);
-
-enum {
-       SPOTLIGHT_NO_UPDATE,
-       SPOTLIGHT_UPDATE_EXPONENT,
-       SPOTLIGHT_UPDATE_DIRECTION,
-       SPOTLIGHT_UPDATE_ALL
-};
-
-static void nv30Lightfv(GLcontext *ctx, GLenum light, GLenum pname, const GLfloat *params )
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       GLint p = light - GL_LIGHT0;
-       struct gl_light *l = &ctx->Light.Light[p];
-       int spotlight_update = SPOTLIGHT_NO_UPDATE;
-
-       if (NOUVEAU_CARD_USING_SHADERS)
-          return;
-
-       /* not sure where the fourth param value goes...*/
-       switch(pname)
-       {
-               case GL_AMBIENT:
-                       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_AMBIENT_R(p), 3);
-                       OUT_RING_CACHEf(params[0]);
-                       OUT_RING_CACHEf(params[1]);
-                       OUT_RING_CACHEf(params[2]);
-                       break;
-               case GL_DIFFUSE:
-                       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_DIFFUSE_R(p), 3);
-                       OUT_RING_CACHEf(params[0]);
-                       OUT_RING_CACHEf(params[1]);
-                       OUT_RING_CACHEf(params[2]);
-                       break;
-               case GL_SPECULAR:
-                       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_LIGHT_FRONT_SIDE_PRODUCT_SPECULAR_R(p), 3);
-                       OUT_RING_CACHEf(params[0]);
-                       OUT_RING_CACHEf(params[1]);
-                       OUT_RING_CACHEf(params[2]);
-                       break;
-               case GL_POSITION:
-                       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_LIGHT_POSITION_X(p), 3);
-                       OUT_RING_CACHEf(params[0]);
-                       OUT_RING_CACHEf(params[1]);
-                       OUT_RING_CACHEf(params[2]);
-                       break;
-               case GL_SPOT_DIRECTION:
-                       spotlight_update = SPOTLIGHT_UPDATE_DIRECTION;
-                       break;
-               case GL_SPOT_EXPONENT:
-                       spotlight_update = SPOTLIGHT_UPDATE_EXPONENT;
-                       break;
-               case GL_SPOT_CUTOFF:
-                       spotlight_update = SPOTLIGHT_UPDATE_ALL;
-                       break;
-               case GL_CONSTANT_ATTENUATION:
-                       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_LIGHT_CONSTANT_ATTENUATION(p), 1);
-                       OUT_RING_CACHEf(*params);
-                       break;
-               case GL_LINEAR_ATTENUATION:
-                       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_LIGHT_LINEAR_ATTENUATION(p), 1);
-                       OUT_RING_CACHEf(*params);
-                       break;
-               case GL_QUADRATIC_ATTENUATION:
-                       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_LIGHT_QUADRATIC_ATTENUATION(p), 1);
-                       OUT_RING_CACHEf(*params);
-                       break;
-               default:
-                       break;
-       }
-
-       switch(spotlight_update) {
-               case SPOTLIGHT_UPDATE_DIRECTION:
-                       {
-                               GLfloat x,y,z;
-                               GLfloat spot_light_coef_a = 1.0 / (l->_CosCutoff - 1.0);
-                               x = spot_light_coef_a * l->_NormDirection[0];
-                               y = spot_light_coef_a * l->_NormDirection[1];
-                               z = spot_light_coef_a * l->_NormDirection[2];
-                               BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_LIGHT_SPOT_DIR_X(p), 3);
-                               OUT_RING_CACHEf(x);
-                               OUT_RING_CACHEf(y);
-                               OUT_RING_CACHEf(z);
-                       }
-                       break;
-               case SPOTLIGHT_UPDATE_EXPONENT:
-                       {
-                               GLfloat cc,lc,qc;
-                               cc = 1.0;       /* FIXME: These need to be correctly computed */
-                               lc = 0.0;
-                               qc = 2.0;
-                               BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_LIGHT_SPOT_CUTOFF_A(p), 3);
-                               OUT_RING_CACHEf(cc);
-                               OUT_RING_CACHEf(lc);
-                               OUT_RING_CACHEf(qc);
-                       }
-                       break;
-               case SPOTLIGHT_UPDATE_ALL:
-                       {
-                               GLfloat cc,lc,qc, x,y,z, c;
-                               GLfloat spot_light_coef_a = 1.0 / (l->_CosCutoff - 1.0);
-                               cc = 1.0;       /* FIXME: These need to be correctly computed */
-                               lc = 0.0;
-                               qc = 2.0;
-                               x = spot_light_coef_a * l->_NormDirection[0];
-                               y = spot_light_coef_a * l->_NormDirection[1];
-                               z = spot_light_coef_a * l->_NormDirection[2];
-                               c = spot_light_coef_a + 1.0;
-                               BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_LIGHT_SPOT_CUTOFF_A(p), 7);
-                               OUT_RING_CACHEf(cc);
-                               OUT_RING_CACHEf(lc);
-                               OUT_RING_CACHEf(qc);
-                               OUT_RING_CACHEf(x);
-                               OUT_RING_CACHEf(y);
-                               OUT_RING_CACHEf(z);
-                               OUT_RING_CACHEf(c);
-                       }
-                       break;
-               default:
-                       break;
-       }
-}
-
-/** Set the lighting model parameters */
-void (*LightModelfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
-
-
-static void nv30LineStipple(GLcontext *ctx, GLint factor, GLushort pattern )
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_LINE_STIPPLE_PATTERN, 1);
-       OUT_RING_CACHE((pattern << 16) | factor);
-}
-
-static void nv30LineWidth(GLcontext *ctx, GLfloat width)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte ubWidth;
-
-       ubWidth = (GLubyte)(width * 8.0) & 0xFF;
-
-       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_LINE_WIDTH_SMOOTH, 1);
-       OUT_RING_CACHE(ubWidth);
-}
-
-static void nv30LogicOpcode(GLcontext *ctx, GLenum opcode)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_COLOR_LOGIC_OP_OP, 1);
-       OUT_RING_CACHE(opcode);
-}
-
-static void nv30PointParameterfv(GLcontext *ctx, GLenum pname, const GLfloat *params)
-{
-       /*TODO: not sure what goes here. */
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       
-}
-
-/** Specify the diameter of rasterized points */
-static void nv30PointSize(GLcontext *ctx, GLfloat size)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_POINT_SIZE, 1);
-       OUT_RING_CACHEf(size);
-}
-
-/** Select a polygon rasterization mode */
-static void nv30PolygonMode(GLcontext *ctx, GLenum face, GLenum mode)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
-               BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_POLYGON_MODE_FRONT, 1);
-               OUT_RING_CACHE(mode);
-       }
-       if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
-               BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_POLYGON_MODE_BACK, 1);
-               OUT_RING_CACHE(mode);
-       }
-}
-
-/** Set the scale and units used to calculate depth values */
-static void nv30PolygonOffset(GLcontext *ctx, GLfloat factor, GLfloat units)
-{
-        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-        BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_POLYGON_OFFSET_FACTOR, 2);
-        OUT_RING_CACHEf(factor);
-
-        /* Looks like we always multiply units by 2.0... according to the dumps.*/
-        OUT_RING_CACHEf(units * 2.0);
-}
-
-/** Set the polygon stippling pattern */
-static void nv30PolygonStipple(GLcontext *ctx, const GLubyte *mask )
-{
-        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-        BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_POLYGON_STIPPLE_PATTERN(0), 32);
-        OUT_RING_CACHEp(mask, 32);
-}
-
-/* Specifies the current buffer for reading */
-void (*ReadBuffer)( GLcontext *ctx, GLenum buffer );
-/** Set rasterization mode */
-void (*RenderMode)(GLcontext *ctx, GLenum mode );
-
-/* Translate GL coords to window coords, clamping w/h to the
- * dimensions of the window.
- */
-static void nv30WindowCoords(nouveauContextPtr nmesa,
-                            GLuint x, GLuint y, GLuint w, GLuint h,
-                            GLuint *wX, GLuint *wY, GLuint *wW, GLuint *wH)
-{
-       if ((x+w) > nmesa->drawW)
-               w = nmesa->drawW - x;
-       (*wX) = x + nmesa->drawX;
-       (*wW) = w;
-
-       if ((y+h) > nmesa->drawH)
-               h = nmesa->drawH - y;
-       (*wY) = (nmesa->drawH - y) - h + nmesa->drawY;
-       (*wH) = h;
-}
-
-/** Define the scissor box */
-static void nv30Scissor(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
-{
-        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       GLuint wX, wY, wW, wH;
-
-       /* There's no scissor enable bit, so adjust the scissor to cover the
-        * maximum draw buffer bounds
-        */
-       if (!ctx->Scissor.Enabled) {
-          wX = nmesa->drawX;
-          wY = nmesa->drawY;
-          wW = nmesa->drawW;
-          wH = nmesa->drawH;
-       } else {
-          nv30WindowCoords(nmesa, x, y, w, h, &wX, &wY, &wW, &wH);
-       }
-
-        BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_SCISSOR_WIDTH_XPOS, 2);
-        OUT_RING_CACHE  ((wW << 16) | wX);
-        OUT_RING_CACHE  ((wH << 16) | wY);
-}
-
-/** Select flat or smooth shading */
-static void nv30ShadeModel(GLcontext *ctx, GLenum mode)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_SHADE_MODEL, 1);
-       OUT_RING_CACHE(mode);
-}
-
-/** OpenGL 2.0 two-sided StencilFunc */
-static void nv30StencilFuncSeparate(GLcontext *ctx, GLenum face, GLenum func,
-               GLint ref, GLuint mask)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
-               BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_STENCIL_FRONT_FUNC_FUNC, 3);
-               OUT_RING_CACHE(func);
-               OUT_RING_CACHE(ref);
-               OUT_RING_CACHE(mask);
-       }
-       if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
-               BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_STENCIL_BACK_FUNC_FUNC, 3);
-               OUT_RING_CACHE(func);
-               OUT_RING_CACHE(ref);
-               OUT_RING_CACHE(mask);
-       }
-}
-
-/** OpenGL 2.0 two-sided StencilMask */
-static void nv30StencilMaskSeparate(GLcontext *ctx, GLenum face, GLuint mask)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
-               BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_STENCIL_FRONT_MASK, 1);
-               OUT_RING_CACHE(mask);
-       }
-       if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
-               BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_STENCIL_BACK_MASK, 1);
-               OUT_RING_CACHE(mask);
-       }
-}
-
-/** OpenGL 2.0 two-sided StencilOp */
-static void nv30StencilOpSeparate(GLcontext *ctx, GLenum face, GLenum fail,
-               GLenum zfail, GLenum zpass)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
-               BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_STENCIL_FRONT_OP_FAIL, 3);
-               OUT_RING_CACHE(fail);
-               OUT_RING_CACHE(zfail);
-               OUT_RING_CACHE(zpass);
-       }
-       if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
-               BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_STENCIL_BACK_OP_FAIL, 3);
-               OUT_RING_CACHE(fail);
-               OUT_RING_CACHE(zfail);
-               OUT_RING_CACHE(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);
-
-static void nv30TextureMatrix(GLcontext *ctx, GLuint unit, const GLmatrix *mat)
-{
-        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       if (!NOUVEAU_CARD_USING_SHADERS) {
-               BEGIN_RING_CACHE(NvSub3D,
-                                NV30_TCL_PRIMITIVE_3D_TX_MATRIX(unit, 0), 16);
-               /*XXX: This SHOULD work.*/
-               OUT_RING_CACHEp(mat->m, 16);
-       }
-}
-
-static void nv30WindowMoved(nouveauContextPtr nmesa)
-{
-       GLcontext *ctx = nmesa->glCtx;
-       GLfloat *v = nmesa->viewport.m;
-       GLuint wX, wY, wW, wH;
-
-       nv30WindowCoords(nmesa, ctx->Viewport.X, ctx->Viewport.Y, 
-                               ctx->Viewport.Width, ctx->Viewport.Height,
-                               &wX, &wY, &wW, &wH);
-        BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_VIEWPORT_DIMS_0, 2);
-        OUT_RING_CACHE  ((wW << 16) | wX);
-        OUT_RING_CACHE  ((wH << 16) | wY);
-
-       /* something to do with clears, possibly doesn't belong here */
-       BEGIN_RING_CACHE(NvSub3D,
-             NV30_TCL_PRIMITIVE_3D_VIEWPORT_COLOR_BUFFER_OFS0, 2);
-        OUT_RING_CACHE(((nmesa->drawX + nmesa->drawW) << 16) | nmesa->drawX);
-        OUT_RING_CACHE(((nmesa->drawY + nmesa->drawH) << 16) | nmesa->drawY);
-
-       /* viewport transform */
-       BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_VIEWPORT_XFRM_OX, 8);
-       OUT_RING_CACHEf (v[MAT_TX]);
-       OUT_RING_CACHEf (v[MAT_TY]);
-       OUT_RING_CACHEf (v[MAT_TZ]);
-       OUT_RING_CACHEf (0.0);
-       OUT_RING_CACHEf (v[MAT_SX]);
-       OUT_RING_CACHEf (v[MAT_SY]);
-       OUT_RING_CACHEf (v[MAT_SZ]);
-       OUT_RING_CACHEf (0.0);
-
-       ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
-                           ctx->Scissor.Width, ctx->Scissor.Height);
-}
-
-static GLboolean nv30InitCard(nouveauContextPtr nmesa)
-{
-       int i;
-       nouveauObjectOnSubchannel(nmesa, NvSub3D, Nv3D);
-
-       BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_SET_OBJECT1, 3);
-       OUT_RING(NvDmaFB);
-       OUT_RING(NvDmaTT);
-        OUT_RING(NvDmaFB);
-       BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_SET_OBJECT8, 1);
-       OUT_RING(NvDmaFB);
-       BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_SET_OBJECT4, 2);
-       OUT_RING(NvDmaFB);
-       OUT_RING(NvDmaFB);
-        BEGIN_RING_SIZE(NvSub3D, 0x1b0, 1); /* SET_OBJECT8B*/
-        OUT_RING(NvDmaFB);
-
-        for(i = 0x2c8; i <= 0x2fc; i += 4)
-        {
-            BEGIN_RING_SIZE(NvSub3D, i, 1);
-            OUT_RING(0x0);
-        }
-
-       BEGIN_RING_SIZE(NvSub3D, 0x0220, 1);
-       OUT_RING(1);
-
-       BEGIN_RING_SIZE(NvSub3D, 0x03b0, 1);
-       OUT_RING(0x00100000);
-       BEGIN_RING_SIZE(NvSub3D, 0x1454, 1);
-       OUT_RING(0);
-       BEGIN_RING_SIZE(NvSub3D, 0x1d80, 1);
-       OUT_RING(3);
-       
-       /* NEW */
-               BEGIN_RING_SIZE(NvSub3D, 0x1e98, 1);
-        OUT_RING(0);
-        BEGIN_RING_SIZE(NvSub3D, 0x17e0, 3);
-        OUT_RING(0);
-        OUT_RING(0);
-        OUT_RING(0x3f800000);
-        BEGIN_RING_SIZE(NvSub3D, 0x1f80, 16);
-        OUT_RING(0); OUT_RING(0); OUT_RING(0); OUT_RING(0); 
-        OUT_RING(0); OUT_RING(0); OUT_RING(0); OUT_RING(0); 
-        OUT_RING(0x0000ffff);
-        OUT_RING(0); OUT_RING(0); OUT_RING(0); OUT_RING(0); 
-        OUT_RING(0); OUT_RING(0); OUT_RING(0); 
-/*
-        BEGIN_RING_SIZE(NvSub3D, 0x100, 2);
-        OUT_RING(0);
-        OUT_RING(0);
-*/
-        BEGIN_RING_SIZE(NvSub3D, 0x120, 3);
-        OUT_RING(0);
-        OUT_RING(1);
-        OUT_RING(2);
-
-        BEGIN_RING_SIZE(NvSub3D, 0x1d88, 1);
-        OUT_RING(0x00001200);
-
-       BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_RC_ENABLE, 1);
-       OUT_RING       (0);
-
-       return GL_TRUE;
-}
-
-static GLboolean nv40InitCard(nouveauContextPtr nmesa)
-{
-       nouveauObjectOnSubchannel(nmesa, NvSub3D, Nv3D);
-
-       BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_SET_OBJECT1, 2);
-       OUT_RING(NvDmaFB);
-       OUT_RING(NvDmaFB);
-       BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_SET_OBJECT8, 1);
-       OUT_RING(NvDmaFB);
-       BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_SET_OBJECT4, 2);
-       OUT_RING(NvDmaFB);
-       OUT_RING(NvDmaFB);
-       BEGIN_RING_SIZE(NvSub3D, 0x0220, 1);
-       OUT_RING(1);
-
-       BEGIN_RING_SIZE(NvSub3D, 0x1ea4, 3);
-       OUT_RING(0x00000010);
-       OUT_RING(0x01000100);
-       OUT_RING(0xff800006);
-       BEGIN_RING_SIZE(NvSub3D, 0x1fc4, 1);
-       OUT_RING(0x06144321);
-       BEGIN_RING_SIZE(NvSub3D, 0x1fc8, 2);
-       OUT_RING(0xedcba987);
-       OUT_RING(0x00000021);
-       BEGIN_RING_SIZE(NvSub3D, 0x1fd0, 1);
-       OUT_RING(0x00171615);
-       BEGIN_RING_SIZE(NvSub3D, 0x1fd4, 1);
-       OUT_RING(0x001b1a19);
-
-       BEGIN_RING_SIZE(NvSub3D, 0x1ef8, 1);
-       OUT_RING(0x0020ffff);
-       BEGIN_RING_SIZE(NvSub3D, 0x1d64, 1);
-       OUT_RING(0x00d30000);
-       BEGIN_RING_SIZE(NvSub3D, 0x1e94, 1);
-       OUT_RING(0x00000001);
-
-       return GL_TRUE;
-}
-
-static GLboolean nv30BindBuffers(nouveauContextPtr nmesa, int num_color,
-               nouveau_renderbuffer **color,
-               nouveau_renderbuffer *depth)
-{
-       GLuint x, y, w, h;
-
-       w = color[0]->mesa.Width;
-       h = color[0]->mesa.Height;
-       x = nmesa->drawX;
-       y = nmesa->drawY;
-
-       if (num_color != 1)
-               return GL_FALSE;
-       BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_VIEWPORT_COLOR_BUFFER_DIM0, 5);
-       OUT_RING        (((w+x)<<16)|x);
-       OUT_RING        (((h+y)<<16)|y);
-       if (color[0]->mesa._ActualFormat == GL_RGBA8)
-               OUT_RING        (0x148);
-       else
-               OUT_RING        (0x143);
-       if (nmesa->screen->card->type >= NV_40)
-               OUT_RING        (color[0]->pitch);
-       else
-               OUT_RING        (color[0]->pitch | (depth ? (depth->pitch << 16): 0));
-       OUT_RING        (color[0]->offset);
-
-       if (depth) {
-               BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_DEPTH_OFFSET, 1);
-               OUT_RING        (depth->offset);
-               if (nmesa->screen->card->type >= NV_40) {
-                       BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_LMA_DEPTH_BUFFER_PITCH, 1);
-                       OUT_RING        (depth->pitch);
-               }
-       }
-
-       return GL_TRUE;
-}
-
-void nv30InitStateFuncs(GLcontext *ctx, struct dd_function_table *func)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       func->AlphaFunc                 = nv30AlphaFunc;
-       func->BlendColor                = nv30BlendColor;
-       func->BlendEquationSeparate     = nv30BlendEquationSeparate;
-       func->BlendFuncSeparate         = nv30BlendFuncSeparate;
-       func->Clear                     = nv30Clear;
-       func->ClearColor                = nv30ClearColor;
-       func->ClearDepth                = nv30ClearDepth;
-       func->ClearStencil              = nv30ClearStencil;
-       func->ClipPlane                 = nv30ClipPlane;
-       func->ColorMask                 = nv30ColorMask;
-       func->ColorMaterial             = nv30ColorMaterial;
-       func->CullFace                  = nv30CullFace;
-       func->FrontFace                 = nv30FrontFace;
-       func->DepthFunc                 = nv30DepthFunc;
-       func->DepthMask                 = nv30DepthMask;
-       func->DepthRange                = nv30DepthRange;
-       func->Enable                    = nv30Enable;
-       func->Fogfv                     = nv30Fogfv;
-       func->Hint                      = nv30Hint;
-       func->Lightfv                   = nv30Lightfv;
-/*     func->LightModelfv              = nv30LightModelfv; */
-       func->LineStipple               = nv30LineStipple;
-       func->LineWidth                 = nv30LineWidth;
-       func->LogicOpcode               = nv30LogicOpcode;
-       func->PointParameterfv          = nv30PointParameterfv;
-       func->PointSize                 = nv30PointSize;
-       func->PolygonMode               = nv30PolygonMode;
-       func->PolygonOffset             = nv30PolygonOffset;
-       func->PolygonStipple            = nv30PolygonStipple;
-#if 0
-       func->ReadBuffer                = nv30ReadBuffer;
-       func->RenderMode                = nv30RenderMode;
-#endif
-       func->Scissor                   = nv30Scissor;
-       func->ShadeModel                = nv30ShadeModel;
-       func->StencilFuncSeparate       = nv30StencilFuncSeparate;
-       func->StencilMaskSeparate       = nv30StencilMaskSeparate;
-       func->StencilOpSeparate         = nv30StencilOpSeparate;
-#if 0
-       func->TexGen                    = nv30TexGen;
-       func->TexParameter              = nv30TexParameter;
-#endif
-       func->TextureMatrix             = nv30TextureMatrix;
-
-
-       if (nmesa->screen->card->type >= NV_40)
-          nmesa->hw_func.InitCard      = nv40InitCard;
-       else 
-          nmesa->hw_func.InitCard      = nv30InitCard;
-       nmesa->hw_func.BindBuffers      = nv30BindBuffers;
-       nmesa->hw_func.WindowMoved      = nv30WindowMoved;
-}
-
diff --git a/src/mesa/drivers/dri/nouveau/nv30_vertprog.c b/src/mesa/drivers/dri/nouveau/nv30_vertprog.c
deleted file mode 100644 (file)
index d023e84..0000000
+++ /dev/null
@@ -1,367 +0,0 @@
-#include "nouveau_context.h"
-#include "nouveau_object.h"
-#include "nouveau_fifo.h"
-#include "nouveau_reg.h"
-
-#include "nouveau_shader.h"
-#include "nv30_shader.h"
-
-/*****************************************************************************
- * Support routines
- */
-static void
-NV30VPUploadToHW(GLcontext *ctx, nouveauShader *nvs)
-{
-   nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-   int i;
-
-   /* We can do better here and keep more than one VP on the hardware, and
-    * switch between them with PROGRAM_START_ID..
-    */
-   BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_FROM_ID, 1);
-   OUT_RING(0);
-   for (i=0; i<nvs->program_size; i+=4) {
-      BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_INST0, 4);
-      OUT_RING(nvs->program[i + 0]);
-      OUT_RING(nvs->program[i + 1]);
-      OUT_RING(nvs->program[i + 2]);
-      OUT_RING(nvs->program[i + 3]);
-   }
-   BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_VP_PROGRAM_START_ID, 1);
-   OUT_RING(0);
-
-   BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_VP_IN_REG, 2);
-   OUT_RING(nvs->card_priv.NV30VP.vp_in_reg);
-   OUT_RING(nvs->card_priv.NV30VP.vp_out_reg);
-
-   BEGIN_RING_CACHE(NvSub3D, NV30_TCL_PRIMITIVE_3D_SET_CLIPPING_PLANES, 1);
-   OUT_RING_CACHE  (nvs->card_priv.NV30VP.clip_enables);
-}
-
-static void
-NV30VPUpdateConst(GLcontext *ctx, nouveauShader *nvs, int id)
-{
-   nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-   GLfloat *val;
-
-   val = nvs->params[id].source_val ?
-      nvs->params[id].source_val : nvs->params[id].val;
-
-   BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_VP_UPLOAD_CONST_ID, 5);
-   OUT_RING (id);
-   OUT_RINGp(val, 4);
-}
-
-/*****************************************************************************
- * Assembly routines
- */
-static void
-NV30VPSetBranchTarget(nvsFunc *shader, int addr)
-{
-       shader->inst[2] &= ~NV30_VP_INST_IADDR_MASK;
-       shader->inst[2] |= (addr << NV30_VP_INST_IADDR_SHIFT);
-}
-
-/*****************************************************************************
- * Disassembly routines
- */
-static unsigned int
-NV30VPGetOpcodeHW(nvsFunc * shader, int slot)
-{
-   int op;
-
-   if (slot) {
-      op = (shader->inst[1] & NV30_VP_INST_SCA_OPCODEL_MASK)
-        >> NV30_VP_INST_SCA_OPCODEL_SHIFT;
-      op |= ((shader->inst[0] & NV30_VP_INST_SCA_OPCODEH_MASK)
-            >> NV30_VP_INST_SCA_OPCODEH_SHIFT) << 4;
-   }
-   else {
-      op = (shader->inst[1] & NV30_VP_INST_VEC_OPCODE_MASK)
-        >> NV30_VP_INST_VEC_OPCODE_SHIFT;
-   }
-
-   return op;
-}
-
-static nvsRegFile
-NV30VPGetDestFile(nvsFunc * shader, int merged)
-{
-   switch (shader->GetOpcode(shader, merged)) {
-   case NVS_OP_ARL:
-   case NVS_OP_ARR:
-   case NVS_OP_ARA:
-      return NVS_FILE_ADDRESS;
-   default:
-      /*FIXME: This probably isn't correct.. */
-      if ((shader->inst[3] & NV30_VP_INST_VDEST_WRITEMASK_MASK) != 0)
-        return NVS_FILE_RESULT;
-      if ((shader->inst[3] & NV30_VP_INST_SDEST_WRITEMASK_MASK) != 0)
-        return NVS_FILE_RESULT;
-      return NVS_FILE_TEMP;
-   }
-}
-
-static unsigned int
-NV30VPGetDestID(nvsFunc * shader, int merged)
-{
-   int id;
-
-   switch (shader->GetDestFile(shader, merged)) {
-   case NVS_FILE_RESULT:
-      id = ((shader->inst[3] & NV30_VP_INST_DEST_ID_MASK)
-           >> NV30_VP_INST_DEST_ID_SHIFT);
-      switch (id) {
-      case NV30_VP_INST_DEST_POS  : return NVS_FR_POSITION;
-      case NV30_VP_INST_DEST_COL0 : return NVS_FR_COL0;
-      case NV30_VP_INST_DEST_COL1 : return NVS_FR_COL1;
-      case NV30_VP_INST_DEST_TC(0): return NVS_FR_TEXCOORD0;
-      case NV30_VP_INST_DEST_TC(1): return NVS_FR_TEXCOORD1;
-      case NV30_VP_INST_DEST_TC(2): return NVS_FR_TEXCOORD2;
-      case NV30_VP_INST_DEST_TC(3): return NVS_FR_TEXCOORD3;
-      case NV30_VP_INST_DEST_TC(4): return NVS_FR_TEXCOORD4;
-      case NV30_VP_INST_DEST_TC(5): return NVS_FR_TEXCOORD5;
-      case NV30_VP_INST_DEST_TC(6): return NVS_FR_TEXCOORD6;
-      case NV30_VP_INST_DEST_TC(7): return NVS_FR_TEXCOORD7;
-      default:
-        return -1;
-      }
-   case NVS_FILE_ADDRESS:
-   case NVS_FILE_TEMP:
-      return (shader->inst[0] & NV30_VP_INST_DEST_TEMP_ID_MASK)
-        >> NV30_VP_INST_DEST_TEMP_ID_SHIFT;
-   default:
-      return -1;
-   }
-}
-
-static unsigned int
-NV30VPGetDestMask(nvsFunc * shader, int merged)
-{
-   int hwmask, mask = 0;
-
-   if (shader->GetDestFile(shader, merged) == NVS_FILE_RESULT)
-      if (shader->GetOpcodeSlot(shader, merged))
-        hwmask = (shader->inst[3] & NV30_VP_INST_SDEST_WRITEMASK_MASK)
-           >> NV30_VP_INST_SDEST_WRITEMASK_SHIFT;
-      else
-        hwmask = (shader->inst[3] & NV30_VP_INST_VDEST_WRITEMASK_MASK)
-           >> NV30_VP_INST_VDEST_WRITEMASK_SHIFT;
-   else if (shader->GetOpcodeSlot(shader, merged))
-      hwmask = (shader->inst[3] & NV30_VP_INST_STEMP_WRITEMASK_MASK)
-        >> NV30_VP_INST_STEMP_WRITEMASK_SHIFT;
-   else
-      hwmask = (shader->inst[3] & NV30_VP_INST_VTEMP_WRITEMASK_MASK)
-        >> NV30_VP_INST_VTEMP_WRITEMASK_SHIFT;
-
-   if (hwmask & (1 << 3)) mask |= SMASK_X;
-   if (hwmask & (1 << 2)) mask |= SMASK_Y;
-   if (hwmask & (1 << 1)) mask |= SMASK_Z;
-   if (hwmask & (1 << 0)) mask |= SMASK_W;
-
-   return mask;
-}
-
-static int
-NV30VPGetSourceID(nvsFunc * shader, int merged, int pos)
-{
-   unsigned int src;
-
-   switch (shader->GetSourceFile(shader, merged, pos)) {
-   case NVS_FILE_TEMP:
-      src = shader->GetSourceHW(shader, merged, pos);
-      return ((src & NV30_VP_SRC_REG_TEMP_ID_MASK) >>
-             NV30_VP_SRC_REG_TEMP_ID_SHIFT);
-   case NVS_FILE_CONST:
-      return ((shader->inst[1] & NV30_VP_INST_CONST_SRC_MASK)
-             >> NV30_VP_INST_CONST_SRC_SHIFT);
-   case NVS_FILE_ATTRIB:
-      src = ((shader->inst[1] & NV30_VP_INST_INPUT_SRC_MASK)
-            >> NV30_VP_INST_INPUT_SRC_SHIFT);
-      switch (src) {
-      case NV30_VP_INST_IN_POS  : return NVS_FR_POSITION;
-      case NV30_VP_INST_IN_COL0 : return NVS_FR_COL0;
-      case NV30_VP_INST_IN_COL1 : return NVS_FR_COL1;
-      case NV30_VP_INST_IN_TC(0): return NVS_FR_TEXCOORD0;
-      case NV30_VP_INST_IN_TC(1): return NVS_FR_TEXCOORD1;
-      case NV30_VP_INST_IN_TC(2): return NVS_FR_TEXCOORD2;
-      case NV30_VP_INST_IN_TC(3): return NVS_FR_TEXCOORD3;
-      case NV30_VP_INST_IN_TC(4): return NVS_FR_TEXCOORD4;
-      case NV30_VP_INST_IN_TC(5): return NVS_FR_TEXCOORD5;
-      case NV30_VP_INST_IN_TC(6): return NVS_FR_TEXCOORD6;
-      case NV30_VP_INST_IN_TC(7): return NVS_FR_TEXCOORD7;
-      default:
-        return NVS_FR_UNKNOWN;
-      }
-   default:
-      return -1;
-   }
-}
-
-static int
-NV30VPGetSourceAbs(nvsFunc * shader, int merged, int pos)
-{
-   struct _op_xlat *opr;
-   static unsigned int abspos[3] = {
-      NV30_VP_INST_SRC0_ABS,
-      NV30_VP_INST_SRC1_ABS,
-      NV30_VP_INST_SRC2_ABS,
-   };
-
-   opr = shader->GetOPTXRec(shader, merged);
-   if (!opr || opr->srcpos[pos] == -1 || opr->srcpos[pos] > 2)
-      return 0;
-
-   return ((shader->inst[0] & abspos[opr->srcpos[pos]]) ? 1 : 0);
-}
-
-static int
-NV30VPGetRelAddressRegID(nvsFunc * shader)
-{
-   return ((shader->inst[0] & NV30_VP_INST_ADDR_REG_SELECT_1) ? 1 : 0);
-}
-
-static nvsSwzComp
-NV30VPGetRelAddressSwizzle(nvsFunc * shader)
-{
-   nvsSwzComp swz;
-
-   swz = NV20VP_TX_SWIZZLE[(shader->inst[0] & NV30_VP_INST_ADDR_SWZ_MASK)
-                          >> NV30_VP_INST_ADDR_SWZ_SHIFT];
-   return swz;
-}
-
-static int
-NV30VPSupportsConditional(nvsFunc * shader)
-{
-   /*FIXME: Is this true of all ops? */
-   return 1;
-}
-
-static int
-NV30VPGetConditionUpdate(nvsFunc * shader)
-{
-   return ((shader->inst[0] & NV30_VP_INST_COND_UPDATE_ENABLE) ? 1 : 0);
-}
-
-static int
-NV30VPGetConditionTest(nvsFunc * shader)
-{
-   int op;
-
-   /* The condition test is unconditionally enabled on some
-    * instructions. ie: the condition test bit does *NOT* have
-    * to be set.
-    *
-    * FIXME: check other relevant ops for this situation.
-    */
-   op = shader->GetOpcodeHW(shader, 1);
-   switch (op) {
-   case NV30_VP_INST_OP_BRA:
-      return 1;
-   default:
-      return ((shader->inst[0] & NV30_VP_INST_COND_TEST_ENABLE) ? 1 : 0);
-   }
-}
-
-static nvsCond
-NV30VPGetCondition(nvsFunc * shader)
-{
-   int cond;
-
-   cond = ((shader->inst[0] & NV30_VP_INST_COND_MASK)
-          >> NV30_VP_INST_COND_SHIFT);
-
-   switch (cond) {
-   case NV30_VP_INST_COND_FL: return NVS_COND_FL;
-   case NV30_VP_INST_COND_LT: return NVS_COND_LT;
-   case NV30_VP_INST_COND_EQ: return NVS_COND_EQ;
-   case NV30_VP_INST_COND_LE: return NVS_COND_LE;
-   case NV30_VP_INST_COND_GT: return NVS_COND_GT;
-   case NV30_VP_INST_COND_NE: return NVS_COND_NE;
-   case NV30_VP_INST_COND_GE: return NVS_COND_GE;
-   case NV30_VP_INST_COND_TR: return NVS_COND_TR;
-   default:
-      return NVS_COND_UNKNOWN;
-   }
-}
-
-static void
-NV30VPGetCondRegSwizzle(nvsFunc * shader, nvsSwzComp *swz)
-{
-   int swzbits;
-
-   swzbits = (shader->inst[0] & NV30_VP_INST_COND_SWZ_ALL_MASK)
-      >> NV30_VP_INST_COND_SWZ_ALL_SHIFT;
-   NV20VPTXSwizzle(swzbits, swz);
-}
-
-static int
-NV30VPGetCondRegID(nvsFunc * shader)
-{
-   return 0;
-}
-
-
-static int
-NV30VPGetBranch(nvsFunc * shader)
-{
-   return ((shader->inst[2] & NV30_VP_INST_IADDR_MASK)
-          >> NV30_VP_INST_IADDR_SHIFT);
-}
-
-void
-NV30VPInitShaderFuncs(nvsFunc * shader)
-{
-   /* Inherit NV20 code, a lot of it is the same */
-   NV20VPInitShaderFuncs(shader);
-
-   /* Increase max valid opcode ID, and add new instructions */
-   NVVP_TX_VOP_COUNT = NVVP_TX_NVS_OP_COUNT = 32;
-
-   MOD_OPCODE(NVVP_TX_VOP, NV30_VP_INST_OP_FRC, NVS_OP_FRC,  0, -1, -1);
-   MOD_OPCODE(NVVP_TX_VOP, NV30_VP_INST_OP_FLR, NVS_OP_FLR,  0, -1, -1);
-   MOD_OPCODE(NVVP_TX_VOP, NV30_VP_INST_OP_SEQ, NVS_OP_SEQ,  0,  1, -1);
-   MOD_OPCODE(NVVP_TX_VOP, NV30_VP_INST_OP_SFL, NVS_OP_SFL,  0,  1, -1);
-   MOD_OPCODE(NVVP_TX_VOP, NV30_VP_INST_OP_SGT, NVS_OP_SGT,  0,  1, -1);
-   MOD_OPCODE(NVVP_TX_VOP, NV30_VP_INST_OP_SLE, NVS_OP_SLE,  0,  1, -1);
-   MOD_OPCODE(NVVP_TX_VOP, NV30_VP_INST_OP_SNE, NVS_OP_SNE,  0,  1, -1);
-   MOD_OPCODE(NVVP_TX_VOP, NV30_VP_INST_OP_STR, NVS_OP_STR,  0,  1, -1);
-   MOD_OPCODE(NVVP_TX_VOP, NV30_VP_INST_OP_SSG, NVS_OP_SSG,  0, -1, -1);
-   MOD_OPCODE(NVVP_TX_VOP, NV30_VP_INST_OP_ARR, NVS_OP_ARR,  0, -1, -1);
-   MOD_OPCODE(NVVP_TX_VOP, NV30_VP_INST_OP_ARA, NVS_OP_ARA,  3, -1, -1);
-
-   MOD_OPCODE(NVVP_TX_SOP, NV30_VP_INST_OP_BRA, NVS_OP_BRA, -1, -1, -1);
-   MOD_OPCODE(NVVP_TX_SOP, NV30_VP_INST_OP_CAL, NVS_OP_CAL, -1, -1, -1);
-   MOD_OPCODE(NVVP_TX_SOP, NV30_VP_INST_OP_RET, NVS_OP_RET, -1, -1, -1);
-   MOD_OPCODE(NVVP_TX_SOP, NV30_VP_INST_OP_LG2, NVS_OP_LG2,  2, -1, -1);
-   MOD_OPCODE(NVVP_TX_SOP, NV30_VP_INST_OP_EX2, NVS_OP_EX2,  2, -1, -1);
-   MOD_OPCODE(NVVP_TX_SOP, NV30_VP_INST_OP_SIN, NVS_OP_SIN,  2, -1, -1);
-   MOD_OPCODE(NVVP_TX_SOP, NV30_VP_INST_OP_COS, NVS_OP_COS,  2, -1, -1);
-
-   shader->UploadToHW          = NV30VPUploadToHW;
-   shader->UpdateConst         = NV30VPUpdateConst;
-
-   shader->GetOpcodeHW         = NV30VPGetOpcodeHW;
-
-   shader->GetDestFile         = NV30VPGetDestFile;
-   shader->GetDestID           = NV30VPGetDestID;
-   shader->GetDestMask         = NV30VPGetDestMask;
-
-   shader->GetSourceID         = NV30VPGetSourceID;
-   shader->GetSourceAbs                = NV30VPGetSourceAbs;
-
-   shader->GetRelAddressRegID  = NV30VPGetRelAddressRegID;
-   shader->GetRelAddressSwizzle        = NV30VPGetRelAddressSwizzle;
-
-   shader->SupportsConditional = NV30VPSupportsConditional;
-   shader->GetConditionUpdate  = NV30VPGetConditionUpdate;
-   shader->GetConditionTest    = NV30VPGetConditionTest;
-   shader->GetCondition                = NV30VPGetCondition;
-   shader->GetCondRegSwizzle   = NV30VPGetCondRegSwizzle;
-   shader->GetCondRegID                = NV30VPGetCondRegID;
-
-   shader->GetBranch           = NV30VPGetBranch;
-   shader->SetBranchTarget     = NV30VPSetBranchTarget;
-}
-
diff --git a/src/mesa/drivers/dri/nouveau/nv40_fragprog.c b/src/mesa/drivers/dri/nouveau/nv40_fragprog.c
deleted file mode 100644 (file)
index 3e4ae04..0000000
+++ /dev/null
@@ -1,224 +0,0 @@
-#include "nouveau_shader.h"
-#include "nv40_shader.h"
-
-/* branching ops */
-unsigned int NVFP_TX_BOP_COUNT = 5;
-struct _op_xlat NVFP_TX_BOP[64];
-
-
-/*****************************************************************************
- * Assembly routines
- *     - These extend the NV30 routines, which are almost identical.  NV40
- *       just has branching hacked into the instruction set.
- */
-static int
-NV40FPSupportsResultScale(nvsFunc *shader, nvsScale scale)
-{
-       switch (scale) {
-       case NVS_SCALE_1X:
-       case NVS_SCALE_2X:
-       case NVS_SCALE_4X:
-       case NVS_SCALE_8X:
-       case NVS_SCALE_INV_2X:
-       case NVS_SCALE_INV_4X:
-       case NVS_SCALE_INV_8X:
-               return 1;
-       default:
-               return 0;
-       }
-}
-
-static void
-NV40FPSetResultScale(nvsFunc *shader, nvsScale scale)
-{
-       shader->inst[2] &= ~NV40_FP_OP_DST_SCALE_MASK;
-       shader->inst[2] |= ((unsigned int)scale << NV40_FP_OP_DST_SCALE_SHIFT);
-}
-
-static void
-NV40FPSetBranchTarget(nvsFunc *shader, int addr)
-{
-       shader->inst[2] &= ~NV40_FP_OP_IADDR_MASK;
-       shader->inst[2] |= (addr << NV40_FP_OP_IADDR_SHIFT);
-}
-
-static void
-NV40FPSetBranchElse(nvsFunc *shader, int addr)
-{
-       shader->inst[2] &= ~NV40_FP_OP_ELSE_ID_MASK;
-       shader->inst[2] |= (addr << NV40_FP_OP_ELSE_ID_SHIFT);
-}
-
-static void
-NV40FPSetBranchEnd(nvsFunc *shader, int addr)
-{
-       shader->inst[3] &= ~NV40_FP_OP_END_ID_MASK;
-       shader->inst[3] |= (addr << NV40_FP_OP_END_ID_SHIFT);
-}
-
-static void
-NV40FPSetLoopParams(nvsFunc *shader, int count, int initial, int increment)
-{
-       shader->inst[2] &= ~(NV40_FP_OP_LOOP_COUNT_MASK |
-                            NV40_FP_OP_LOOP_INDEX_MASK |
-                            NV40_FP_OP_LOOP_INCR_MASK);
-       shader->inst[2] |= ((count     << NV40_FP_OP_LOOP_COUNT_SHIFT) |
-                           (initial   << NV40_FP_OP_LOOP_INDEX_SHIFT) |
-                           (increment << NV40_FP_OP_LOOP_INCR_SHIFT));
-}
-
-/*****************************************************************************
- * Disassembly routines
- */
-static struct _op_xlat *
-NV40FPGetOPTXRec(nvsFunc * shader, int merged)
-{
-   struct _op_xlat *opr;
-   int op;
-
-   op = shader->GetOpcodeHW(shader, 0);
-   if (shader->inst[2] & NV40_FP_OP_OPCODE_IS_BRANCH) {
-      opr = NVFP_TX_BOP;
-      op &= ~NV40_FP_OP_OPCODE_IS_BRANCH;
-      if (op > NVFP_TX_BOP_COUNT)
-        return NULL;
-   }
-   else {
-      opr = NVFP_TX_AOP;
-      if (op > NVFP_TX_AOP_COUNT)
-        return NULL;
-   }
-
-   if (opr[op].SOP == NVS_OP_UNKNOWN)
-      return NULL;
-   return &opr[op];
-}
-
-static int
-NV40FPGetSourceID(nvsFunc * shader, int merged, int pos)
-{
-   switch (shader->GetSourceFile(shader, merged, pos)) {
-   case NVS_FILE_ATTRIB:
-      switch ((shader->inst[0] & NV40_FP_OP_INPUT_SRC_MASK)
-             >> NV40_FP_OP_INPUT_SRC_SHIFT) {
-      case NV40_FP_OP_INPUT_SRC_POSITION: return NVS_FR_POSITION;
-      case NV40_FP_OP_INPUT_SRC_COL0    : return NVS_FR_COL0;
-      case NV40_FP_OP_INPUT_SRC_COL1    : return NVS_FR_COL1;
-      case NV40_FP_OP_INPUT_SRC_FOGC    : return NVS_FR_FOGCOORD;
-      case NV40_FP_OP_INPUT_SRC_TC(0)   : return NVS_FR_TEXCOORD0;
-      case NV40_FP_OP_INPUT_SRC_TC(1)   : return NVS_FR_TEXCOORD1;
-      case NV40_FP_OP_INPUT_SRC_TC(2)   : return NVS_FR_TEXCOORD2;
-      case NV40_FP_OP_INPUT_SRC_TC(3)   : return NVS_FR_TEXCOORD3;
-      case NV40_FP_OP_INPUT_SRC_TC(4)   : return NVS_FR_TEXCOORD4;
-      case NV40_FP_OP_INPUT_SRC_TC(5)   : return NVS_FR_TEXCOORD5;
-      case NV40_FP_OP_INPUT_SRC_TC(6)   : return NVS_FR_TEXCOORD6;
-      case NV40_FP_OP_INPUT_SRC_TC(7)   : return NVS_FR_TEXCOORD7;
-      case NV40_FP_OP_INPUT_SRC_FACING  : return NVS_FR_FACING;
-      default:
-        return -1;
-      }
-      break;
-   case NVS_FILE_TEMP:
-      {
-        unsigned int src;
-
-        src = shader->GetSourceHW(shader, merged, pos);
-        return ((src & NV40_FP_REG_SRC_MASK) >> NV40_FP_REG_SRC_SHIFT);
-      }
-   case NVS_FILE_CONST:                /* inlined into fragprog */
-   default:
-      return -1;
-   }
-}
-
-static int
-NV40FPGetBranch(nvsFunc * shader)
-{
-   return ((shader->inst[2] & NV40_FP_OP_IADDR_MASK)
-          >> NV40_FP_OP_IADDR_SHIFT);;
-}
-
-static int
-NV40FPGetBranchElse(nvsFunc * shader)
-{
-   return ((shader->inst[2] & NV40_FP_OP_ELSE_ID_MASK)
-          >> NV40_FP_OP_ELSE_ID_SHIFT);
-}
-
-static int
-NV40FPGetBranchEnd(nvsFunc * shader)
-{
-   return ((shader->inst[3] & NV40_FP_OP_END_ID_MASK)
-          >> NV40_FP_OP_END_ID_SHIFT);
-}
-
-static int
-NV40FPGetLoopCount(nvsFunc * shader)
-{
-   return ((shader->inst[2] & NV40_FP_OP_LOOP_COUNT_MASK)
-          >> NV40_FP_OP_LOOP_COUNT_SHIFT);
-}
-
-static int
-NV40FPGetLoopInitial(nvsFunc * shader)
-{
-   return ((shader->inst[2] & NV40_FP_OP_LOOP_INDEX_MASK)
-          >> NV40_FP_OP_LOOP_INDEX_SHIFT);
-}
-
-static int
-NV40FPGetLoopIncrement(nvsFunc * shader)
-{
-   return ((shader->inst[2] & NV40_FP_OP_LOOP_INCR_MASK)
-          >> NV40_FP_OP_LOOP_INCR_SHIFT);
-}
-
-void
-NV40FPInitShaderFuncs(nvsFunc * shader)
-{
-   /* Inherit NV30 FP code, it's mostly the same */
-   NV30FPInitShaderFuncs(shader);
-
-   /* Kill off opcodes seen on NV30, but not seen on NV40 - need to find
-    * out if these actually work or not.
-    *
-    * update: either LIT/RSQ don't work on nv40, or I generate bad code for
-    *         them.  haven't tested the others yet
-    */
-   MOD_OPCODE(NVFP_TX_AOP, 0x1B, NVS_OP_UNKNOWN, -1, -1, -1);  /* NV30 RSQ */
-   MOD_OPCODE(NVFP_TX_AOP, 0x1E, NVS_OP_UNKNOWN, -1, -1, -1);  /* NV30 LIT */
-   MOD_OPCODE(NVFP_TX_AOP, 0x1F, NVS_OP_UNKNOWN, -1, -1, -1);  /* NV30 LRP */
-   MOD_OPCODE(NVFP_TX_AOP, 0x26, NVS_OP_UNKNOWN, -1, -1, -1);  /* NV30 POW */
-   MOD_OPCODE(NVFP_TX_AOP, 0x36, NVS_OP_UNKNOWN, -1, -1, -1);  /* NV30 RFL */
-
-   /* Extra opcodes supported on NV40 */
-   MOD_OPCODE(NVFP_TX_AOP, NV40_FP_OP_OPCODE_DIV     , NVS_OP_DIV ,  0,  1, -1);
-   MOD_OPCODE(NVFP_TX_AOP, NV40_FP_OP_OPCODE_DP2A    , NVS_OP_DP2A,  0,  1,  2);
-   MOD_OPCODE(NVFP_TX_AOP, NV40_FP_OP_OPCODE_TXL     , NVS_OP_TXL ,  0, -1, -1);
-
-   MOD_OPCODE(NVFP_TX_BOP, NV40_FP_OP_BRA_OPCODE_BRK , NVS_OP_BRK , -1, -1, -1);
-   MOD_OPCODE(NVFP_TX_BOP, NV40_FP_OP_BRA_OPCODE_CAL , NVS_OP_CAL , -1, -1, -1);
-   MOD_OPCODE(NVFP_TX_BOP, NV40_FP_OP_BRA_OPCODE_IF  , NVS_OP_IF  , -1, -1, -1);
-   MOD_OPCODE(NVFP_TX_BOP, NV40_FP_OP_BRA_OPCODE_LOOP, NVS_OP_LOOP, -1, -1, -1);
-   MOD_OPCODE(NVFP_TX_BOP, NV40_FP_OP_BRA_OPCODE_REP , NVS_OP_REP , -1, -1, -1);
-   MOD_OPCODE(NVFP_TX_BOP, NV40_FP_OP_BRA_OPCODE_RET , NVS_OP_RET , -1, -1, -1);
-
-   shader->SupportsResultScale = NV40FPSupportsResultScale;
-   shader->SetResultScale      = NV40FPSetResultScale;
-
-   /* fragment.facing */
-   shader->GetSourceID         = NV40FPGetSourceID;
-
-   /* branching */
-   shader->GetOPTXRec          = NV40FPGetOPTXRec;
-   shader->GetBranch           = NV40FPGetBranch;
-   shader->GetBranchElse       = NV40FPGetBranchElse;
-   shader->GetBranchEnd                = NV40FPGetBranchEnd;
-   shader->GetLoopCount                = NV40FPGetLoopCount;
-   shader->GetLoopInitial      = NV40FPGetLoopInitial;
-   shader->GetLoopIncrement    = NV40FPGetLoopIncrement;
-   shader->SetBranchTarget     = NV40FPSetBranchTarget;
-   shader->SetBranchElse       = NV40FPSetBranchElse;
-   shader->SetBranchEnd                = NV40FPSetBranchEnd;
-   shader->SetLoopParams       = NV40FPSetLoopParams;
-}
diff --git a/src/mesa/drivers/dri/nouveau/nv40_shader.h b/src/mesa/drivers/dri/nouveau/nv40_shader.h
deleted file mode 100644 (file)
index 584f4c2..0000000
+++ /dev/null
@@ -1,467 +0,0 @@
-#ifndef __NV40_SHADER_H__
-#define __NV40_SHADER_H__
-
-/* Vertex programs instruction set
- *
- * The NV40 instruction set is very similar to NV30.  Most fields are in
- * a slightly different position in the instruction however.
- *
- * Merged instructions
- *     In some cases it is possible to put two instructions into one opcode
- *     slot.  The rules for when this is OK is not entirely clear to me yet.
- *
- *     There are separate writemasks and dest temp register fields for each
- *     grouping of instructions.  There is however only one field with the
- *     ID of a result register.  Writing to temp/result regs is selected by
- *     setting VEC_RESULT/SCA_RESULT.
- *
- * Temporary registers
- *     The source/dest temp register fields have been extended by 1 bit, to
- *     give a total of 32 temporary registers.
- *
- * Relative Addressing
- *     NV40 can use an address register to index into vertex attribute regs.
- *     This is done by putting the offset value into INPUT_SRC and setting
- *     the INDEX_INPUT flag.
- *
- * Conditional execution (see NV_vertex_program{2,3} for details)
- *     There is a second condition code register on NV40, it's use is enabled
- *     by setting the COND_REG_SELECT_1 flag.
- *
- * Texture lookup
- *     TODO
- */
-
-/* ---- OPCODE BITS 127:96 / data DWORD 0 --- */
-#define NV40_VP_INST_VEC_RESULT                                        (1 << 30)
-/* uncertain.. */
-#define NV40_VP_INST_COND_UPDATE_ENABLE                        ((1 << 14)|1<<29)
-/* use address reg as index into attribs */
-#define NV40_VP_INST_INDEX_INPUT                                       (1 << 27)
-#define NV40_VP_INST_COND_REG_SELECT_1                                 (1 << 25)
-#define NV40_VP_INST_ADDR_REG_SELECT_1                                 (1 << 24)
-#define NV40_VP_INST_SRC2_ABS                                          (1 << 23)
-#define NV40_VP_INST_SRC1_ABS                                          (1 << 22)
-#define NV40_VP_INST_SRC0_ABS                                          (1 << 21)
-#define NV40_VP_INST_VEC_DEST_TEMP_SHIFT                                      15
-#define NV40_VP_INST_VEC_DEST_TEMP_MASK                             (0x1F << 15)
-#define NV40_VP_INST_COND_TEST_ENABLE                                  (1 << 13)
-#define NV40_VP_INST_COND_SHIFT                                               10
-#define NV40_VP_INST_COND_MASK                                       (0x7 << 10)
-#    define NV40_VP_INST_COND_FL                                               0
-#    define NV40_VP_INST_COND_LT                                               1
-#    define NV40_VP_INST_COND_EQ                                               2
-#    define NV40_VP_INST_COND_LE                                               3
-#    define NV40_VP_INST_COND_GT                                               4
-#    define NV40_VP_INST_COND_NE                                               5
-#    define NV40_VP_INST_COND_GE                                               6
-#    define NV40_VP_INST_COND_TR                                               7
-#define NV40_VP_INST_COND_SWZ_X_SHIFT                                          8
-#define NV40_VP_INST_COND_SWZ_X_MASK                                    (3 << 8)
-#define NV40_VP_INST_COND_SWZ_Y_SHIFT                                          6
-#define NV40_VP_INST_COND_SWZ_Y_MASK                                    (3 << 6)
-#define NV40_VP_INST_COND_SWZ_Z_SHIFT                                          4
-#define NV40_VP_INST_COND_SWZ_Z_MASK                                    (3 << 4)
-#define NV40_VP_INST_COND_SWZ_W_SHIFT                                          2
-#define NV40_VP_INST_COND_SWZ_W_MASK                                    (3 << 2)
-#define NV40_VP_INST_COND_SWZ_ALL_SHIFT                                        2
-#define NV40_VP_INST_COND_SWZ_ALL_MASK                               (0xFF << 2)
-#define NV40_VP_INST_ADDR_SWZ_SHIFT                                            0
-#define NV40_VP_INST_ADDR_SWZ_MASK                                   (0x03 << 0)
-#define NV40_VP_INST0_KNOWN ( \
-                NV40_VP_INST_INDEX_INPUT | \
-                NV40_VP_INST_COND_REG_SELECT_1 | \
-                NV40_VP_INST_ADDR_REG_SELECT_1 | \
-                NV40_VP_INST_SRC2_ABS | \
-                NV40_VP_INST_SRC1_ABS | \
-                NV40_VP_INST_SRC0_ABS | \
-                NV40_VP_INST_VEC_DEST_TEMP_MASK | \
-                NV40_VP_INST_COND_TEST_ENABLE | \
-                NV40_VP_INST_COND_MASK | \
-                NV40_VP_INST_COND_SWZ_ALL_MASK | \
-                NV40_VP_INST_ADDR_SWZ_MASK)
-
-/* ---- OPCODE BITS 95:64 / data DWORD 1 --- */
-#define NV40_VP_INST_VEC_OPCODE_SHIFT                                         22
-#define NV40_VP_INST_VEC_OPCODE_MASK                                (0x1F << 22)
-#    define NV40_VP_INST_OP_NOP                                             0x00
-#    define NV40_VP_INST_OP_MOV                                             0x01
-#    define NV40_VP_INST_OP_MUL                                             0x02
-#    define NV40_VP_INST_OP_ADD                                             0x03
-#    define NV40_VP_INST_OP_MAD                                             0x04
-#    define NV40_VP_INST_OP_DP3                                             0x05
-#    define NV40_VP_INST_OP_DP4                                             0x07
-#    define NV40_VP_INST_OP_DPH                                             0x06
-#    define NV40_VP_INST_OP_DST                                             0x08
-#    define NV40_VP_INST_OP_MIN                                             0x09
-#    define NV40_VP_INST_OP_MAX                                             0x0A
-#    define NV40_VP_INST_OP_SLT                                             0x0B
-#    define NV40_VP_INST_OP_SGE                                             0x0C
-#    define NV40_VP_INST_OP_ARL                                             0x0D
-#    define NV40_VP_INST_OP_FRC                                             0x0E
-#    define NV40_VP_INST_OP_FLR                                             0x0F
-#    define NV40_VP_INST_OP_SEQ                                             0x10
-#    define NV40_VP_INST_OP_SFL                                             0x11
-#    define NV40_VP_INST_OP_SGT                                             0x12
-#    define NV40_VP_INST_OP_SLE                                             0x13
-#    define NV40_VP_INST_OP_SNE                                             0x14
-#    define NV40_VP_INST_OP_STR                                             0x15
-#    define NV40_VP_INST_OP_SSG                                             0x16
-#    define NV40_VP_INST_OP_ARR                                             0x17
-#    define NV40_VP_INST_OP_ARA                                             0x18
-#    define NV40_VP_INST_OP_TXWHAT                                          0x19
-#define NV40_VP_INST_SCA_OPCODE_SHIFT                                         27
-#define NV40_VP_INST_SCA_OPCODE_MASK                                (0x1F << 27)
-#    define NV40_VP_INST_OP_RCP                                             0x02
-#    define NV40_VP_INST_OP_RCC                                             0x03
-#    define NV40_VP_INST_OP_RSQ                                             0x04
-#    define NV40_VP_INST_OP_EXP                                             0x05
-#    define NV40_VP_INST_OP_LOG                                             0x06
-#    define NV40_VP_INST_OP_LIT                                             0x07
-#    define NV40_VP_INST_OP_BRA                                             0x09
-#    define NV40_VP_INST_OP_CAL                                             0x0B
-#    define NV40_VP_INST_OP_RET                                             0x0C
-#    define NV40_VP_INST_OP_LG2                                             0x0D
-#    define NV40_VP_INST_OP_EX2                                             0x0E
-#    define NV40_VP_INST_OP_SIN                                             0x0F
-#    define NV40_VP_INST_OP_COS                                             0x10
-#    define NV40_VP_INST_OP_PUSHA                                           0x13
-#    define NV40_VP_INST_OP_POPA                                            0x14
-#define NV40_VP_INST_CONST_SRC_SHIFT                                          12
-#define NV40_VP_INST_CONST_SRC_MASK                                 (0xFF << 12)
-#define NV40_VP_INST_INPUT_SRC_SHIFT                                           8
-#define NV40_VP_INST_INPUT_SRC_MASK                                  (0x0F << 8)
-#    define NV40_VP_INST_IN_POS                                                0
-#    define NV40_VP_INST_IN_WEIGHT                                             1
-#    define NV40_VP_INST_IN_NORMAL                                             2
-#    define NV40_VP_INST_IN_COL0                                               3
-#    define NV40_VP_INST_IN_COL1                                               4
-#    define NV40_VP_INST_IN_FOGC                                               5
-#    define NV40_VP_INST_IN_TC0                                                8
-#    define NV40_VP_INST_IN_TC(n)                                          (8+n)
-#define NV40_VP_INST_SRC0H_SHIFT                                               0
-#define NV40_VP_INST_SRC0H_MASK                                      (0xFF << 0)
-#define NV40_VP_INST1_KNOWN ( \
-                NV40_VP_INST_VEC_OPCODE_MASK | \
-                NV40_VP_INST_SCA_OPCODE_MASK | \
-                NV40_VP_INST_CONST_SRC_MASK  | \
-                NV40_VP_INST_INPUT_SRC_MASK  | \
-                NV40_VP_INST_SRC0H_MASK \
-                )
-
-/* ---- OPCODE BITS 63:32 / data DWORD 2 --- */
-#define NV40_VP_INST_SRC0L_SHIFT                                              23
-#define NV40_VP_INST_SRC0L_MASK                                    (0x1FF << 23)
-#define NV40_VP_INST_SRC1_SHIFT                                                6
-#define NV40_VP_INST_SRC1_MASK                                    (0x1FFFF << 6)
-#define NV40_VP_INST_SRC2H_SHIFT                                               0
-#define NV40_VP_INST_SRC2H_MASK                                      (0x3F << 0)
-#define NV40_VP_INST_IADDRH_SHIFT                                              0
-#define NV40_VP_INST_IADDRH_MASK                                     (0x1F << 0)
-
-/* ---- OPCODE BITS 31:0 / data DWORD 3 --- */
-#define NV40_VP_INST_IADDRL_SHIFT                                             29
-#define NV40_VP_INST_IADDRL_MASK                                       (7 << 29)
-#define NV40_VP_INST_SRC2L_SHIFT                                              21
-#define NV40_VP_INST_SRC2L_MASK                                    (0x7FF << 21)
-#define NV40_VP_INST_SCA_WRITEMASK_SHIFT                                      17
-#define NV40_VP_INST_SCA_WRITEMASK_MASK                              (0xF << 17)
-#    define NV40_VP_INST_SCA_WRITEMASK_X                               (1 << 20)
-#    define NV40_VP_INST_SCA_WRITEMASK_Y                               (1 << 19)
-#    define NV40_VP_INST_SCA_WRITEMASK_Z                               (1 << 18)
-#    define NV40_VP_INST_SCA_WRITEMASK_W                               (1 << 17)
-#define NV40_VP_INST_VEC_WRITEMASK_SHIFT                                      13
-#define NV40_VP_INST_VEC_WRITEMASK_MASK                              (0xF << 13)
-#    define NV40_VP_INST_VEC_WRITEMASK_X                               (1 << 16)
-#    define NV40_VP_INST_VEC_WRITEMASK_Y                               (1 << 15)
-#    define NV40_VP_INST_VEC_WRITEMASK_Z                               (1 << 14)
-#    define NV40_VP_INST_VEC_WRITEMASK_W                               (1 << 13)
-#define NV40_VP_INST_SCA_RESULT                                        (1 << 12)
-#define NV40_VP_INST_SCA_DEST_TEMP_SHIFT                                       7
-#define NV40_VP_INST_SCA_DEST_TEMP_MASK                              (0x1F << 7)
-#define NV40_VP_INST_DEST_SHIFT                                                2
-#define NV40_VP_INST_DEST_MASK                                         (31 << 2)
-#    define NV40_VP_INST_DEST_POS                                              0
-#    define NV40_VP_INST_DEST_COL0                                             1
-#    define NV40_VP_INST_DEST_COL1                                             2
-#    define NV40_VP_INST_DEST_BFC0                                             3
-#    define NV40_VP_INST_DEST_BFC1                                             4
-#    define NV40_VP_INST_DEST_FOGC                                             5
-#    define NV40_VP_INST_DEST_PSZ                                              6
-#    define NV40_VP_INST_DEST_TC0                                              7
-#    define NV40_VP_INST_DEST_TC(n)                                        (7+n)
-#    define NV40_VP_INST_DEST_TEMP                                          0x1F
-#define NV40_VP_INST_INDEX_CONST                                        (1 << 1)
-#define NV40_VP_INST_LAST                                               (1 << 0)
-#define NV40_VP_INST3_KNOWN ( \
-                NV40_VP_INST_SRC2L_MASK |\
-                NV40_VP_INST_SCA_WRITEMASK_MASK |\
-                NV40_VP_INST_VEC_WRITEMASK_MASK |\
-                NV40_VP_INST_SCA_DEST_TEMP_MASK |\
-                NV40_VP_INST_DEST_MASK |\
-                NV40_VP_INST_INDEX_CONST)
-
-/* Useful to split the source selection regs into their pieces */
-#define NV40_VP_SRC0_HIGH_SHIFT                                                9
-#define NV40_VP_SRC0_HIGH_MASK                                        0x0001FE00
-#define NV40_VP_SRC0_LOW_MASK                                         0x000001FF
-#define NV40_VP_SRC2_HIGH_SHIFT                                               11
-#define NV40_VP_SRC2_HIGH_MASK                                        0x0001F800
-#define NV40_VP_SRC2_LOW_MASK                                         0x000007FF
-
-/* Source selection - these are the bits you fill NV40_VP_INST_SRCn with */
-#define NV40_VP_SRC_NEGATE                                             (1 << 16)
-#define NV40_VP_SRC_SWZ_X_SHIFT                                               14
-#define NV40_VP_SRC_SWZ_X_MASK                                         (3 << 14)
-#define NV40_VP_SRC_SWZ_Y_SHIFT                                               12
-#define NV40_VP_SRC_SWZ_Y_MASK                                         (3 << 12)
-#define NV40_VP_SRC_SWZ_Z_SHIFT                                               10
-#define NV40_VP_SRC_SWZ_Z_MASK                                         (3 << 10)
-#define NV40_VP_SRC_SWZ_W_SHIFT                                                8
-#define NV40_VP_SRC_SWZ_W_MASK                                          (3 << 8)
-#define NV40_VP_SRC_SWZ_ALL_SHIFT                                              8
-#define NV40_VP_SRC_SWZ_ALL_MASK                                     (0xFF << 8)
-#define NV40_VP_SRC_TEMP_SRC_SHIFT                                             2
-#define NV40_VP_SRC_TEMP_SRC_MASK                                    (0x1F << 2)
-#define NV40_VP_SRC_REG_TYPE_SHIFT                                             0
-#define NV40_VP_SRC_REG_TYPE_MASK                                       (3 << 0)
-#    define NV40_VP_SRC_REG_TYPE_UNK0                                          0
-#    define NV40_VP_SRC_REG_TYPE_TEMP                                          1
-#    define NV40_VP_SRC_REG_TYPE_INPUT                                         2
-#    define NV40_VP_SRC_REG_TYPE_CONST                                         3
-
-
-/*
- * Each fragment program opcode appears to be comprised of 4 32-bit values.
- *
- *         0 - Opcode, output reg/mask, ATTRIB source
- *         1 - Source 0
- *         2 - Source 1
- *         3 - Source 2
- *
- * There appears to be no special difference between result regs and temp regs.
- *                 result.color == R0.xyzw
- *                 result.depth == R1.z
- * When the fragprog contains instructions to write depth,
- * NV30_TCL_PRIMITIVE_3D_UNK1D78=0 otherwise it is set to 1.
- *
- * Constants are inserted directly after the instruction that uses them.
- * 
- * It appears that it's not possible to use two input registers in one
- * instruction as the input sourcing is done in the instruction dword
- * and not the source selection dwords.  As such instructions such as:
- * 
- *                 ADD result.color, fragment.color, fragment.texcoord[0];
- *
- * must be split into two MOV's and then an ADD (nvidia does this) but
- * I'm not sure why it's not just one MOV and then source the second input
- * in the ADD instruction..
- *
- * Negation of the full source is done with NV30_FP_REG_NEGATE, arbitrary
- * negation requires multiplication with a const.
- *
- * Arbitrary swizzling is supported with the exception of SWIZZLE_ZERO and
- * SWIZZLE_ONE.
- *
- * The temp/result regs appear to be initialised to (0.0, 0.0, 0.0, 0.0) as
- * SWIZZLE_ZERO is implemented simply by not writing to the relevant components
- * of the destination.
- *
- * Looping
- *   Loops appear to be fairly expensive on NV40 at least, the proprietary
- *   driver goes to a lot of effort to avoid using the native looping
- *   instructions.  If the total number of *executed* instructions between
- *   REP/ENDREP or LOOP/ENDLOOP is <=500, the driver will unroll the loop.
- *   The maximum loop count is 255.
- *
- * Conditional execution
- *   TODO
- * 
- * Non-native instructions:
- *         LIT
- *         LRP - MAD+MAD
- *         SUB - ADD, negate second source
- *         RSQ - LG2 + EX2
- *         POW - LG2 + MUL + EX2
- *         SCS - COS + SIN
- *         XPD
- *         DP2 - MUL + ADD
- *         NRM
- */
-
-//== Opcode / Destination selection ==
-#define NV40_FP_OP_PROGRAM_END                                          (1 << 0)
-#define NV40_FP_OP_OUT_REG_SHIFT                                               1
-#define NV40_FP_OP_OUT_REG_MASK                                        (31 << 1)
-/* Needs to be set when writing outputs to get expected result.. */
-#define NV40_FP_OP_UNK0_7                                               (1 << 7)
-#define NV40_FP_OP_COND_WRITE_ENABLE                                    (1 << 8)
-#define NV40_FP_OP_OUTMASK_SHIFT                                               9
-#define NV40_FP_OP_OUTMASK_MASK                                       (0xF << 9)
-#    define NV40_FP_OP_OUT_X                                            (1 << 9)
-#    define NV40_FP_OP_OUT_Y                                            (1 <<10)
-#    define NV40_FP_OP_OUT_Z                                            (1 <<11)
-#    define NV40_FP_OP_OUT_W                                            (1 <<12)
-/* Uncertain about these, especially the input_src values.. it's possible that
- * they can be dynamically changed.
- */
-#define NV40_FP_OP_INPUT_SRC_SHIFT                                            13
-#define NV40_FP_OP_INPUT_SRC_MASK                                     (15 << 13)
-#    define NV40_FP_OP_INPUT_SRC_POSITION                                    0x0
-#    define NV40_FP_OP_INPUT_SRC_COL0                                        0x1
-#    define NV40_FP_OP_INPUT_SRC_COL1                                        0x2
-#    define NV40_FP_OP_INPUT_SRC_FOGC                                        0x3
-#    define NV40_FP_OP_INPUT_SRC_TC0                                         0x4
-#    define NV40_FP_OP_INPUT_SRC_TC(n)                                 (0x4 + n)
-#    define NV40_FP_OP_INPUT_SRC_FACING                                      0xE
-#define NV40_FP_OP_TEX_UNIT_SHIFT                                             17
-#define NV40_FP_OP_TEX_UNIT_MASK                                     (0xF << 17)
-#define NV40_FP_OP_PRECISION_SHIFT                                            22
-#define NV40_FP_OP_PRECISION_MASK                                      (3 << 22)
-#   define NV40_FP_PRECISION_FP32                                              0
-#   define NV40_FP_PRECISION_FP16                                              1
-#   define NV40_FP_PRECISION_FX12                                              2
-#define NV40_FP_OP_OPCODE_SHIFT                                               24
-#define NV40_FP_OP_OPCODE_MASK                                      (0x3F << 24)
-#        define NV40_FP_OP_OPCODE_NOP                                       0x00
-#        define NV40_FP_OP_OPCODE_MOV                                       0x01
-#        define NV40_FP_OP_OPCODE_MUL                                       0x02
-#        define NV40_FP_OP_OPCODE_ADD                                       0x03
-#        define NV40_FP_OP_OPCODE_MAD                                       0x04
-#        define NV40_FP_OP_OPCODE_DP3                                       0x05
-#        define NV40_FP_OP_OPCODE_DP4                                       0x06
-#        define NV40_FP_OP_OPCODE_DST                                       0x07
-#        define NV40_FP_OP_OPCODE_MIN                                       0x08
-#        define NV40_FP_OP_OPCODE_MAX                                       0x09
-#        define NV40_FP_OP_OPCODE_SLT                                       0x0A
-#        define NV40_FP_OP_OPCODE_SGE                                       0x0B
-#        define NV40_FP_OP_OPCODE_SLE                                       0x0C
-#        define NV40_FP_OP_OPCODE_SGT                                       0x0D
-#        define NV40_FP_OP_OPCODE_SNE                                       0x0E
-#        define NV40_FP_OP_OPCODE_SEQ                                       0x0F
-#        define NV40_FP_OP_OPCODE_FRC                                       0x10
-#        define NV40_FP_OP_OPCODE_FLR                                       0x11
-#        define NV40_FP_OP_OPCODE_KIL                                       0x12
-#        define NV40_FP_OP_OPCODE_PK4B                                      0x13
-#        define NV40_FP_OP_OPCODE_UP4B                                      0x14
-/* DDX/DDY can only write to XY */
-#        define NV40_FP_OP_OPCODE_DDX                                       0x15
-#        define NV40_FP_OP_OPCODE_DDY                                       0x16
-#        define NV40_FP_OP_OPCODE_TEX                                       0x17
-#        define NV40_FP_OP_OPCODE_TXP                                       0x18
-#        define NV40_FP_OP_OPCODE_TXD                                       0x19
-#        define NV40_FP_OP_OPCODE_RCP                                       0x1A
-#        define NV40_FP_OP_OPCODE_EX2                                       0x1C
-#        define NV40_FP_OP_OPCODE_LG2                                       0x1D
-#        define NV40_FP_OP_OPCODE_COS                                       0x22
-#        define NV40_FP_OP_OPCODE_SIN                                       0x23
-#        define NV40_FP_OP_OPCODE_PK2H                                      0x24
-#        define NV40_FP_OP_OPCODE_UP2H                                      0x25
-#        define NV40_FP_OP_OPCODE_PK4UB                                     0x27
-#        define NV40_FP_OP_OPCODE_UP4UB                                     0x28
-#        define NV40_FP_OP_OPCODE_PK2US                                     0x29
-#        define NV40_FP_OP_OPCODE_UP2US                                     0x2A
-#        define NV40_FP_OP_OPCODE_DP2A                                      0x2E
-#        define NV40_FP_OP_OPCODE_TXL                                       0x2F
-#        define NV40_FP_OP_OPCODE_TXB                                       0x31
-#        define NV40_FP_OP_OPCODE_DIV                                       0x3A
-/* The use of these instructions appears to be indicated by bit 31 of DWORD 2.*/
-#        define NV40_FP_OP_BRA_OPCODE_BRK                                    0x0
-#        define NV40_FP_OP_BRA_OPCODE_CAL                                    0x1
-#        define NV40_FP_OP_BRA_OPCODE_IF                                     0x2
-#        define NV40_FP_OP_BRA_OPCODE_LOOP                                   0x3
-#        define NV40_FP_OP_BRA_OPCODE_REP                                    0x4
-#        define NV40_FP_OP_BRA_OPCODE_RET                                    0x5
-#define NV40_FP_OP_OUT_SAT                                             (1 << 31)
-
-/* high order bits of SRC0 */
-#define NV40_FP_OP_OUT_ABS                                             (1 << 29)
-#define NV40_FP_OP_COND_SWZ_W_SHIFT                                           27
-#define NV40_FP_OP_COND_SWZ_W_MASK                                     (3 << 27)
-#define NV40_FP_OP_COND_SWZ_Z_SHIFT                                           25
-#define NV40_FP_OP_COND_SWZ_Z_MASK                                     (3 << 25)
-#define NV40_FP_OP_COND_SWZ_Y_SHIFT                                           23
-#define NV40_FP_OP_COND_SWZ_Y_MASK                                     (3 << 23)
-#define NV40_FP_OP_COND_SWZ_X_SHIFT                                           21
-#define NV40_FP_OP_COND_SWZ_X_MASK                                     (3 << 21)
-#define NV40_FP_OP_COND_SWZ_ALL_SHIFT                                         21
-#define NV40_FP_OP_COND_SWZ_ALL_MASK                                (0xFF << 21)
-#define NV40_FP_OP_COND_SHIFT                                                 18
-#define NV40_FP_OP_COND_MASK                                        (0x07 << 18)
-#        define NV40_FP_OP_COND_FL                                             0
-#        define NV40_FP_OP_COND_LT                                             1
-#        define NV40_FP_OP_COND_EQ                                             2
-#        define NV40_FP_OP_COND_LE                                             3
-#        define NV40_FP_OP_COND_GT                                             4
-#        define NV40_FP_OP_COND_NE                                             5
-#        define NV40_FP_OP_COND_GE                                             6
-#        define NV40_FP_OP_COND_TR                                             7
-
-/* high order bits of SRC1 */
-#define NV40_FP_OP_OPCODE_IS_BRANCH                                      (1<<31)
-#define NV40_FP_OP_DST_SCALE_SHIFT                                            28
-#define NV40_FP_OP_DST_SCALE_MASK                                      (3 << 28)
-
-/* SRC1 LOOP */
-#define NV40_FP_OP_LOOP_INCR_SHIFT                                            19
-#define NV40_FP_OP_LOOP_INCR_MASK                                   (0xFF << 19)
-#define NV40_FP_OP_LOOP_INDEX_SHIFT                                           10
-#define NV40_FP_OP_LOOP_INDEX_MASK                                  (0xFF << 10)
-#define NV40_FP_OP_LOOP_COUNT_SHIFT                                            2
-#define NV40_FP_OP_LOOP_COUNT_MASK                                   (0xFF << 2)
-
-/* SRC1 IF */
-#define NV40_FP_OP_ELSE_ID_SHIFT                                               2
-#define NV40_FP_OP_ELSE_ID_MASK                                      (0xFF << 2)
-
-/* SRC1 CAL */
-#define NV40_FP_OP_IADDR_SHIFT                                                 2
-#define NV40_FP_OP_IADDR_MASK                                        (0xFF << 2)
-
-/* SRC1 REP
- *   I have no idea why there are 3 count values here..  but they
- *   have always been filled with the same value in my tests so
- *   far..
- */
-#define NV40_FP_OP_REP_COUNT1_SHIFT                                            2
-#define NV40_FP_OP_REP_COUNT1_MASK                                   (0xFF << 2)
-#define NV40_FP_OP_REP_COUNT2_SHIFT                                           10
-#define NV40_FP_OP_REP_COUNT2_MASK                                  (0xFF << 10)
-#define NV40_FP_OP_REP_COUNT3_SHIFT                                           19
-#define NV40_FP_OP_REP_COUNT3_MASK                                  (0xFF << 19)
-
-/* SRC2 REP/IF */
-#define NV40_FP_OP_END_ID_SHIFT                                                2
-#define NV40_FP_OP_END_ID_MASK                                       (0xFF << 2)
-
-// SRC2 high-order
-#define NV40_FP_OP_INDEX_INPUT                                         (1 << 30)
-#define NV40_FP_OP_ADDR_INDEX_SHIFT                                           19
-#define NV40_FP_OP_ADDR_INDEX_MASK                                   (0xF << 19)
-
-//== Register selection ==
-#define NV40_FP_REG_TYPE_SHIFT                                                 0
-#define NV40_FP_REG_TYPE_MASK                                           (3 << 0)
-#        define NV40_FP_REG_TYPE_TEMP                                          0
-#        define NV40_FP_REG_TYPE_INPUT                                         1
-#        define NV40_FP_REG_TYPE_CONST                                         2
-#define NV40_FP_REG_SRC_SHIFT                                                  2
-#define NV40_FP_REG_SRC_MASK                                           (31 << 2)
-#define NV40_FP_REG_UNK_0                                               (1 << 8)
-#define NV40_FP_REG_SWZ_ALL_SHIFT                                              9
-#define NV40_FP_REG_SWZ_ALL_MASK                                      (255 << 9)
-#define NV40_FP_REG_SWZ_X_SHIFT                                                9
-#define NV40_FP_REG_SWZ_X_MASK                                          (3 << 9)
-#define NV40_FP_REG_SWZ_Y_SHIFT                                               11
-#define NV40_FP_REG_SWZ_Y_MASK                                         (3 << 11)
-#define NV40_FP_REG_SWZ_Z_SHIFT                                               13
-#define NV40_FP_REG_SWZ_Z_MASK                                         (3 << 13)
-#define NV40_FP_REG_SWZ_W_SHIFT                                               15
-#define NV40_FP_REG_SWZ_W_MASK                                         (3 << 15)
-#        define NV40_FP_SWIZZLE_X                                              0
-#        define NV40_FP_SWIZZLE_Y                                              1
-#        define NV40_FP_SWIZZLE_Z                                              2
-#        define NV40_FP_SWIZZLE_W                                              3
-#define NV40_FP_REG_NEGATE                                             (1 << 17)
-
-#endif
diff --git a/src/mesa/drivers/dri/nouveau/nv40_vertprog.c b/src/mesa/drivers/dri/nouveau/nv40_vertprog.c
deleted file mode 100644 (file)
index d054140..0000000
+++ /dev/null
@@ -1,778 +0,0 @@
-#include "nouveau_shader.h"
-#include "nouveau_msg.h"
-#include "nv40_shader.h"
-
-/*****************************************************************************
- * Assembly routines
- */
-static int
-NV40VPSupportsOpcode(nvsFunc * shader, nvsOpcode op)
-{
-   if (shader->GetOPTXFromSOP(op, NULL))
-      return 1;
-   return 0;
-}
-
-static void
-NV40VPSetOpcode(nvsFunc *shader, unsigned int opcode, int slot)
-{
-   if (slot) {
-      shader->inst[1] &= ~NV40_VP_INST_SCA_OPCODE_MASK;
-      shader->inst[1] |= (opcode << NV40_VP_INST_SCA_OPCODE_SHIFT);
-   } else {
-      shader->inst[1] &= ~NV40_VP_INST_VEC_OPCODE_MASK;
-      shader->inst[1] |= (opcode << NV40_VP_INST_VEC_OPCODE_SHIFT);
-   }
-}
-
-static void
-NV40VPSetCCUpdate(nvsFunc *shader)
-{
-   shader->inst[0] |= NV40_VP_INST_COND_UPDATE_ENABLE;
-}
-
-static void
-NV40VPSetCondition(nvsFunc *shader, int on, nvsCond cond, int reg,
-                  nvsSwzComp *swizzle)
-{
-   unsigned int hwcond;
-
-   if (on ) shader->inst[0] |= NV40_VP_INST_COND_TEST_ENABLE;
-   else     shader->inst[0] &= ~NV40_VP_INST_COND_TEST_ENABLE;
-   if (reg) shader->inst[0] |= NV40_VP_INST_COND_REG_SELECT_1;
-   else     shader->inst[0] &= ~NV40_VP_INST_COND_REG_SELECT_1;
-
-   switch (cond) {
-   case NVS_COND_TR: hwcond = NV40_VP_INST_COND_TR; break;
-   case NVS_COND_FL: hwcond = NV40_VP_INST_COND_FL; break;
-   case NVS_COND_LT: hwcond = NV40_VP_INST_COND_LT; break;
-   case NVS_COND_GT: hwcond = NV40_VP_INST_COND_GT; break;
-   case NVS_COND_NE: hwcond = NV40_VP_INST_COND_NE; break;
-   case NVS_COND_EQ: hwcond = NV40_VP_INST_COND_EQ; break;
-   case NVS_COND_GE: hwcond = NV40_VP_INST_COND_GE; break;
-   case NVS_COND_LE: hwcond = NV40_VP_INST_COND_LE; break;
-   default:
-       WARN_ONCE("unknown vp cond %d\n", cond);
-       hwcond = NV40_VP_INST_COND_TR;
-       break;
-   }
-   shader->inst[0] &= ~NV40_VP_INST_COND_MASK;
-   shader->inst[0] |= (hwcond << NV40_VP_INST_COND_SHIFT);
-
-   shader->inst[0] &= ~NV40_VP_INST_COND_SWZ_ALL_MASK;
-   shader->inst[0] |= (swizzle[NVS_SWZ_X] << NV40_VP_INST_COND_SWZ_X_SHIFT);
-   shader->inst[0] |= (swizzle[NVS_SWZ_Y] << NV40_VP_INST_COND_SWZ_Y_SHIFT);
-   shader->inst[0] |= (swizzle[NVS_SWZ_Z] << NV40_VP_INST_COND_SWZ_Z_SHIFT);
-   shader->inst[0] |= (swizzle[NVS_SWZ_W] << NV40_VP_INST_COND_SWZ_W_SHIFT);
-}
-
-/* these just exist here until nouveau_reg.h has them. */
-#define NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_COL0  (1<<0)
-#define NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_COL1  (1<<1)
-#define NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_BFC0  (1<<2)
-#define NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_BFC1  (1<<3)
-#define NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_FOGC  (1<<4)
-#define NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_PSZ   (1<<5)
-#define NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_CLP0  (1<<6)
-#define NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_CLP1  (1<<7)
-#define NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_CLP2  (1<<8)
-#define NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_CLP3  (1<<9)
-#define NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_CLP4  (1<<10)
-#define NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_CLP5  (1<<11)
-#define NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_TEX0   (1<<14)
-
-static unsigned int
-NV40VPTranslateResultReg(nvsFunc *shader, nvsFixedReg result,
-                                         unsigned int *mask_ret)
-{
-       unsigned int *out_reg = &shader->card_priv->NV30VP.vp_out_reg;
-       unsigned int *clip_en = &shader->card_priv->NV30VP.clip_enables;
-
-       *mask_ret = 0xf;
-
-       switch (result) {
-       case NVS_FR_POSITION:
-               /* out_reg POS implied */
-               return NV40_VP_INST_DEST_POS;
-       case NVS_FR_COL0:
-               (*out_reg) |= NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_COL0;
-               return NV40_VP_INST_DEST_COL0;
-       case NVS_FR_COL1:
-               (*out_reg) |= NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_COL1;
-               return NV40_VP_INST_DEST_COL1;
-       case NVS_FR_BFC0:
-               (*out_reg) |= NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_BFC0;
-               return NV40_VP_INST_DEST_BFC0;
-       case NVS_FR_BFC1:
-               (*out_reg) |= NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_BFC1;
-               return NV40_VP_INST_DEST_BFC1;
-       case NVS_FR_FOGCOORD:
-               (*out_reg) |= NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_FOGC;
-               *mask_ret = 0x8;
-               return NV40_VP_INST_DEST_FOGC;
-       case NVS_FR_CLIP0:
-               (*out_reg) |= NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_CLP0;
-               (*clip_en) |= 0x00000002;
-               *mask_ret = 0x4;
-               return NV40_VP_INST_DEST_FOGC;
-       case NVS_FR_CLIP1:
-               (*out_reg) |= NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_CLP1;
-               (*clip_en) |= 0x00000020;
-               *mask_ret = 0x2;
-               return NV40_VP_INST_DEST_FOGC;
-       case NVS_FR_CLIP2:
-               (*out_reg) |= NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_CLP2;
-               (*clip_en) |= 0x00000200;
-               *mask_ret = 0x1;
-               return NV40_VP_INST_DEST_FOGC;
-       case NVS_FR_POINTSZ:
-               (*out_reg) |= NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_PSZ;
-               *mask_ret = 0x8;
-               return NV40_VP_INST_DEST_PSZ;
-       case NVS_FR_CLIP3:
-               (*out_reg) |= NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_CLP3;
-               (*clip_en) |= 0x00002000;
-               *mask_ret = 0x4;
-               return NV40_VP_INST_DEST_PSZ;
-       case NVS_FR_CLIP4:
-               (*clip_en) |= 0x00020000;
-               (*out_reg) |= NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_CLP4;
-               *mask_ret = 0x2;
-               return NV40_VP_INST_DEST_PSZ;
-       case NVS_FR_CLIP5:
-               (*clip_en) |= 0x00200000;
-               (*out_reg) |= NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_CLP5;
-               *mask_ret = 0x1;
-               return NV40_VP_INST_DEST_PSZ;
-       case NVS_FR_TEXCOORD0:
-       case NVS_FR_TEXCOORD1:
-       case NVS_FR_TEXCOORD2:
-       case NVS_FR_TEXCOORD3:
-       case NVS_FR_TEXCOORD4:
-       case NVS_FR_TEXCOORD5:
-       case NVS_FR_TEXCOORD6:
-       case NVS_FR_TEXCOORD7:
-       {
-               int unit = result - NVS_FR_TEXCOORD0;
-               (*out_reg) |= (NV30_TCL_PRIMITIVE_3D_VP_OUT_REG_TEX0 << unit);
-               return NV40_VP_INST_DEST_TC(unit);
-       }
-       default:
-               WARN_ONCE("unknown vp output %d\n", result);
-               return NV40_VP_INST_DEST_POS;
-       }
-}
-
-static void
-NV40VPSetResult(nvsFunc *shader, nvsRegister * dest, unsigned int mask,
-               int slot)
-{
-   unsigned int hwmask = 0;
-
-   if (mask & SMASK_X) hwmask |= (1 << 3);
-   if (mask & SMASK_Y) hwmask |= (1 << 2);
-   if (mask & SMASK_Z) hwmask |= (1 << 1);
-   if (mask & SMASK_W) hwmask |= (1 << 0);
-
-   if (dest->file == NVS_FILE_RESULT) {
-      unsigned int valid_mask;
-      int hwidx;
-
-      hwidx = NV40VPTranslateResultReg(shader, dest->index, &valid_mask);
-      if (hwmask & ~valid_mask)
-             WARN_ONCE("writing invalid components of result reg\n");
-      hwmask &= valid_mask;
-
-      shader->inst[3] &= ~NV40_VP_INST_DEST_MASK;
-      shader->inst[3] |= (hwidx << NV40_VP_INST_DEST_SHIFT);
-
-      if (slot) shader->inst[3] |= NV40_VP_INST_SCA_RESULT;
-      else      shader->inst[0] |= NV40_VP_INST_VEC_RESULT;
-   } else {
-      /* NVS_FILE_TEMP || NVS_FILE_ADDRESS */
-      if (slot) {
-        shader->inst[3] &= ~NV40_VP_INST_SCA_RESULT;
-        shader->inst[3] &= ~NV40_VP_INST_SCA_DEST_TEMP_MASK;
-        shader->inst[3] |= (dest->index << NV40_VP_INST_SCA_DEST_TEMP_SHIFT);
-      } else {
-        shader->inst[0] &= ~NV40_VP_INST_VEC_RESULT;
-        shader->inst[0] &= ~(NV40_VP_INST_VEC_DEST_TEMP_MASK | (1<<20));
-        shader->inst[0] |= (dest->index << NV40_VP_INST_VEC_DEST_TEMP_SHIFT);
-      }
-   }
-
-   if (slot) {
-      shader->inst[3] &= ~NV40_VP_INST_SCA_WRITEMASK_MASK;
-      shader->inst[3] |= (hwmask << NV40_VP_INST_SCA_WRITEMASK_SHIFT);
-   } else {
-      shader->inst[3] &= ~NV40_VP_INST_VEC_WRITEMASK_MASK;
-      shader->inst[3] |= (hwmask << NV40_VP_INST_VEC_WRITEMASK_SHIFT);
-   }
-}
-
-static void
-NV40VPInsertSource(nvsFunc *shader, unsigned int hw, int pos)
-{
-   switch (pos) {
-   case 0:
-      shader->inst[1] &= ~NV40_VP_INST_SRC0H_MASK;
-      shader->inst[2] &= ~NV40_VP_INST_SRC0L_MASK;
-      shader->inst[1] |= ((hw & NV40_VP_SRC0_HIGH_MASK) >>
-           NV40_VP_SRC0_HIGH_SHIFT)
-        << NV40_VP_INST_SRC0H_SHIFT;
-      shader->inst[2] |= (hw & NV40_VP_SRC0_LOW_MASK)
-        << NV40_VP_INST_SRC0L_SHIFT;
-      break;
-   case 1:
-      shader->inst[2] &= ~NV40_VP_INST_SRC1_MASK;
-      shader->inst[2] |= hw
-        << NV40_VP_INST_SRC1_SHIFT;
-      break;
-   case 2:
-      shader->inst[2] &= ~NV40_VP_INST_SRC2H_MASK;
-      shader->inst[3] &= ~NV40_VP_INST_SRC2L_MASK;
-      shader->inst[2] |= ((hw & NV40_VP_SRC2_HIGH_MASK) >>
-           NV40_VP_SRC2_HIGH_SHIFT)
-        << NV40_VP_INST_SRC2H_SHIFT;
-      shader->inst[3] |= (hw & NV40_VP_SRC2_LOW_MASK)
-        << NV40_VP_INST_SRC2L_SHIFT;
-      break;
-   default:
-      assert(0);
-      break;
-   }
-}
-
-static void
-NV40VPSetSource(nvsFunc *shader, nvsRegister * src, int pos)
-{
-   unsigned int hw = 0;
-
-   switch (src->file) {
-   case NVS_FILE_ADDRESS:
-      break;
-   case NVS_FILE_ATTRIB:
-      hw |= (NV40_VP_SRC_REG_TYPE_INPUT << NV40_VP_SRC_REG_TYPE_SHIFT);
-
-      shader->inst[1] &= ~NV40_VP_INST_INPUT_SRC_MASK;
-      shader->inst[1] |= (src->index << NV40_VP_INST_INPUT_SRC_SHIFT);
-      shader->card_priv->NV30VP.vp_in_reg |= (1 << src->index);
-      if (src->indexed) {
-        shader->inst[0] |= NV40_VP_INST_INDEX_INPUT;
-        if (src->addr_reg)
-           shader->inst[0] |= NV40_VP_INST_ADDR_REG_SELECT_1;
-        else
-           shader->inst[0] &= ~NV40_VP_INST_ADDR_REG_SELECT_1;
-        shader->inst[0] &= ~NV40_VP_INST_ADDR_SWZ_SHIFT;
-        shader->inst[0] |= (src->addr_comp << NV40_VP_INST_ADDR_SWZ_SHIFT);
-      } else
-        shader->inst[0] &= ~NV40_VP_INST_INDEX_INPUT;
-      break;
-   case NVS_FILE_CONST:
-      hw |= (NV40_VP_SRC_REG_TYPE_CONST << NV40_VP_SRC_REG_TYPE_SHIFT);
-
-      shader->inst[1] &= ~NV40_VP_INST_CONST_SRC_MASK;
-      shader->inst[1] |= (src->index << NV40_VP_INST_CONST_SRC_SHIFT);
-      if (src->indexed) {
-        shader->inst[3] |= NV40_VP_INST_INDEX_CONST;
-        if (src->addr_reg)
-           shader->inst[0] |= NV40_VP_INST_ADDR_REG_SELECT_1;
-        else
-           shader->inst[0] &= ~NV40_VP_INST_ADDR_REG_SELECT_1;
-        shader->inst[0] &= ~NV40_VP_INST_ADDR_SWZ_MASK;
-        shader->inst[0] |= (src->addr_comp << NV40_VP_INST_ADDR_SWZ_SHIFT);
-      } else
-        shader->inst[3] &= ~NV40_VP_INST_INDEX_CONST;
-      break;
-   case NVS_FILE_TEMP:
-      hw |= (NV40_VP_SRC_REG_TYPE_TEMP << NV40_VP_SRC_REG_TYPE_SHIFT);
-      hw |= (src->index << NV40_VP_SRC_TEMP_SRC_SHIFT);
-      break;
-   default:
-      fprintf(stderr, "unknown source file %d\n", src->file);
-      assert(0);
-      break;
-   }
-
-   if (src->file != NVS_FILE_ADDRESS) {
-      if (src->negate)
-        hw |= NV40_VP_SRC_NEGATE;
-      if (src->abs)
-        shader->inst[0] |= (1 << (21 + pos));
-      else
-        shader->inst[0] &= ~(1 << (21 + pos));
-      hw |= (src->swizzle[0] << NV40_VP_SRC_SWZ_X_SHIFT);
-      hw |= (src->swizzle[1] << NV40_VP_SRC_SWZ_Y_SHIFT);
-      hw |= (src->swizzle[2] << NV40_VP_SRC_SWZ_Z_SHIFT);
-      hw |= (src->swizzle[3] << NV40_VP_SRC_SWZ_W_SHIFT);
-
-      NV40VPInsertSource(shader, hw, pos);
-   }
-}
-
-static void
-NV40VPSetBranchTarget(nvsFunc *shader, int addr)
-{
-       shader->inst[2] &= ~NV40_VP_INST_IADDRH_MASK;
-       shader->inst[2] |= ((addr & 0xf8) >> 3) << NV40_VP_INST_IADDRH_SHIFT;
-       shader->inst[3] &= ~NV40_VP_INST_IADDRL_MASK;
-       shader->inst[3] |= ((addr & 0x07) << NV40_VP_INST_IADDRL_SHIFT);
-}
-
-static void
-NV40VPInitInstruction(nvsFunc *shader)
-{
-   unsigned int hwsrc = 0;
-
-   shader->inst[0] = /*NV40_VP_INST_VEC_RESULT | */
-                    NV40_VP_INST_VEC_DEST_TEMP_MASK | (1<<20);
-   shader->inst[1] = 0;
-   shader->inst[2] = 0;
-   shader->inst[3] = NV40_VP_INST_SCA_RESULT |
-                    NV40_VP_INST_SCA_DEST_TEMP_MASK |
-                    NV40_VP_INST_DEST_MASK;
-   
-   hwsrc = (NV40_VP_SRC_REG_TYPE_INPUT << NV40_VP_SRC_REG_TYPE_SHIFT) |
-          (NVS_SWZ_X << NV40_VP_SRC_SWZ_X_SHIFT) |
-          (NVS_SWZ_Y << NV40_VP_SRC_SWZ_Y_SHIFT) |
-          (NVS_SWZ_Z << NV40_VP_SRC_SWZ_Z_SHIFT) |
-          (NVS_SWZ_W << NV40_VP_SRC_SWZ_W_SHIFT);
-   NV40VPInsertSource(shader, hwsrc, 0);
-   NV40VPInsertSource(shader, hwsrc, 1);
-   NV40VPInsertSource(shader, hwsrc, 2);
-}
-
-static void
-NV40VPSetLastInst(nvsFunc *shader)
-{
-   shader->inst[3] |= 1;
-}
-
-/*****************************************************************************
- * Disassembly routines
- */
-static int
-NV40VPHasMergedInst(nvsFunc * shader)
-{
-   if (shader->GetOpcodeHW(shader, 0) != NV40_VP_INST_OP_NOP &&
-       shader->GetOpcodeHW(shader, 1) != NV40_VP_INST_OP_NOP)
-      return 1;
-   return 0;
-}
-
-static unsigned int
-NV40VPGetOpcodeHW(nvsFunc * shader, int slot)
-{
-   int op;
-
-   if (slot)
-      op = (shader->inst[1] & NV40_VP_INST_SCA_OPCODE_MASK)
-        >> NV40_VP_INST_SCA_OPCODE_SHIFT;
-   else
-      op = (shader->inst[1] & NV40_VP_INST_VEC_OPCODE_MASK)
-        >> NV40_VP_INST_VEC_OPCODE_SHIFT;
-
-   return op;
-}
-
-static nvsRegFile
-NV40VPGetDestFile(nvsFunc * shader, int merged)
-{
-   nvsOpcode op;
-
-   op = shader->GetOpcode(shader, merged);
-   switch (op) {
-   case NVS_OP_ARL:
-   case NVS_OP_ARR:
-   case NVS_OP_ARA:
-   case NVS_OP_POPA:
-      return NVS_FILE_ADDRESS;
-   default:
-      if (shader->GetOpcodeSlot(shader, merged)) {
-        if (shader->inst[3] & NV40_VP_INST_SCA_RESULT)
-           return NVS_FILE_RESULT;
-      }
-      else {
-        if (shader->inst[0] & NV40_VP_INST_VEC_RESULT)
-           return NVS_FILE_RESULT;
-      }
-      return NVS_FILE_TEMP;
-   }
-
-}
-
-static unsigned int
-NV40VPGetDestID(nvsFunc * shader, int merged)
-{
-   int id;
-
-   switch (shader->GetDestFile(shader, merged)) {
-   case NVS_FILE_RESULT:
-      id = ((shader->inst[3] & NV40_VP_INST_DEST_MASK)
-           >> NV40_VP_INST_DEST_SHIFT);
-      switch (id) {
-      case NV40_VP_INST_DEST_POS : return NVS_FR_POSITION;
-      case NV40_VP_INST_DEST_COL0: return NVS_FR_COL0;
-      case NV40_VP_INST_DEST_COL1: return NVS_FR_COL1;
-      case NV40_VP_INST_DEST_BFC0: return NVS_FR_BFC0;
-      case NV40_VP_INST_DEST_BFC1: return NVS_FR_BFC1;
-      case NV40_VP_INST_DEST_FOGC: {
-           int mask = shader->GetDestMask(shader, merged);
-           switch (mask) {
-           case SMASK_X: return NVS_FR_FOGCOORD;
-           case SMASK_Y: return NVS_FR_CLIP0;
-           case SMASK_Z: return NVS_FR_CLIP1;
-           case SMASK_W: return NVS_FR_CLIP2;
-           default:
-              printf("more than 1 mask component set in FOGC writemask!\n");
-              return NVS_FR_UNKNOWN;
-           }
-        }
-      case NV40_VP_INST_DEST_PSZ:
-        {
-           int mask = shader->GetDestMask(shader, merged);
-           switch (mask) {
-           case SMASK_X: return NVS_FR_POINTSZ;
-           case SMASK_Y: return NVS_FR_CLIP3;
-           case SMASK_Z: return NVS_FR_CLIP4;
-           case SMASK_W: return NVS_FR_CLIP5;
-           default:
-              printf("more than 1 mask component set in PSZ writemask!\n");
-              return NVS_FR_UNKNOWN;
-           }
-        }
-      case NV40_VP_INST_DEST_TC(0): return NVS_FR_TEXCOORD0;
-      case NV40_VP_INST_DEST_TC(1): return NVS_FR_TEXCOORD1;
-      case NV40_VP_INST_DEST_TC(2): return NVS_FR_TEXCOORD2;
-      case NV40_VP_INST_DEST_TC(3): return NVS_FR_TEXCOORD3;
-      case NV40_VP_INST_DEST_TC(4): return NVS_FR_TEXCOORD4;
-      case NV40_VP_INST_DEST_TC(5): return NVS_FR_TEXCOORD5;
-      case NV40_VP_INST_DEST_TC(6): return NVS_FR_TEXCOORD6;
-      case NV40_VP_INST_DEST_TC(7): return NVS_FR_TEXCOORD7;
-      default:
-        return -1;
-      }
-   case NVS_FILE_ADDRESS:
-      /* Instructions that write address regs are encoded as if
-       * they would write temps.
-       */
-   case NVS_FILE_TEMP:
-      if (shader->GetOpcodeSlot(shader, merged))
-        id = ((shader->inst[3] & NV40_VP_INST_SCA_DEST_TEMP_MASK)
-              >> NV40_VP_INST_SCA_DEST_TEMP_SHIFT);
-      else
-        id = ((shader->inst[0] & NV40_VP_INST_VEC_DEST_TEMP_MASK)
-              >> NV40_VP_INST_VEC_DEST_TEMP_SHIFT);
-      return id;
-   default:
-      return -1;
-   }
-}
-
-static unsigned int
-NV40VPGetDestMask(nvsFunc * shader, int merged)
-{
-   unsigned int mask = 0;
-
-   if (shader->GetOpcodeSlot(shader, merged)) {
-      if (shader->inst[3] & NV40_VP_INST_SCA_WRITEMASK_X) mask |= SMASK_X;
-      if (shader->inst[3] & NV40_VP_INST_SCA_WRITEMASK_Y) mask |= SMASK_Y;
-      if (shader->inst[3] & NV40_VP_INST_SCA_WRITEMASK_Z) mask |= SMASK_Z;
-      if (shader->inst[3] & NV40_VP_INST_SCA_WRITEMASK_W) mask |= SMASK_W;
-   } else {
-      if (shader->inst[3] & NV40_VP_INST_VEC_WRITEMASK_X) mask |= SMASK_X;
-      if (shader->inst[3] & NV40_VP_INST_VEC_WRITEMASK_Y) mask |= SMASK_Y;
-      if (shader->inst[3] & NV40_VP_INST_VEC_WRITEMASK_Z) mask |= SMASK_Z;
-      if (shader->inst[3] & NV40_VP_INST_VEC_WRITEMASK_W) mask |= SMASK_W;
-   }
-
-   return mask;
-}
-
-static unsigned int
-NV40VPGetSourceHW(nvsFunc * shader, int merged, int pos)
-{
-   struct _op_xlat *opr;
-   unsigned int src;
-
-   opr = shader->GetOPTXRec(shader, merged);
-   if (!opr)
-      return -1;
-
-   switch (opr->srcpos[pos]) {
-   case 0:
-      src = ((shader->inst[1] & NV40_VP_INST_SRC0H_MASK)
-            >> NV40_VP_INST_SRC0H_SHIFT)
-        << NV40_VP_SRC0_HIGH_SHIFT;
-      src |= ((shader->inst[2] & NV40_VP_INST_SRC0L_MASK)
-             >> NV40_VP_INST_SRC0L_SHIFT);
-      break;
-   case 1:
-      src = ((shader->inst[2] & NV40_VP_INST_SRC1_MASK)
-            >> NV40_VP_INST_SRC1_SHIFT);
-      break;
-   case 2:
-      src = ((shader->inst[2] & NV40_VP_INST_SRC2H_MASK)
-            >> NV40_VP_INST_SRC2H_SHIFT)
-        << NV40_VP_SRC2_HIGH_SHIFT;
-      src |= ((shader->inst[3] & NV40_VP_INST_SRC2L_MASK)
-             >> NV40_VP_INST_SRC2L_SHIFT);
-      break;
-   default:
-      src = -1;
-   }
-
-   return src;
-}
-
-static nvsRegFile
-NV40VPGetSourceFile(nvsFunc * shader, int merged, int pos)
-{
-   unsigned int src;
-   struct _op_xlat *opr;
-   int file;
-
-   opr = shader->GetOPTXRec(shader, merged);
-   if (!opr || opr->srcpos[pos] == -1)
-      return -1;
-
-   switch (opr->srcpos[pos]) {
-   case SPOS_ADDRESS: return NVS_FILE_ADDRESS;
-   default:
-      src = shader->GetSourceHW(shader, merged, pos);
-      file = (src & NV40_VP_SRC_REG_TYPE_MASK) >> NV40_VP_SRC_REG_TYPE_SHIFT;
-
-      switch (file) {
-      case NV40_VP_SRC_REG_TYPE_TEMP : return NVS_FILE_TEMP;
-      case NV40_VP_SRC_REG_TYPE_INPUT: return NVS_FILE_ATTRIB;
-      case NV40_VP_SRC_REG_TYPE_CONST: return NVS_FILE_CONST;
-      default:
-        return NVS_FILE_UNKNOWN;
-      }
-   }
-}
-
-static int
-NV40VPGetSourceID(nvsFunc * shader, int merged, int pos)
-{
-   switch (shader->GetSourceFile(shader, merged, pos)) {
-   case NVS_FILE_ATTRIB:
-      switch ((shader->inst[1] & NV40_VP_INST_INPUT_SRC_MASK)
-             >> NV40_VP_INST_INPUT_SRC_SHIFT) {
-      case NV40_VP_INST_IN_POS:                return NVS_FR_POSITION;
-      case NV40_VP_INST_IN_WEIGHT:     return NVS_FR_WEIGHT;
-      case NV40_VP_INST_IN_NORMAL:     return NVS_FR_NORMAL;
-      case NV40_VP_INST_IN_COL0:       return NVS_FR_COL0;
-      case NV40_VP_INST_IN_COL1:       return NVS_FR_COL1;
-      case NV40_VP_INST_IN_FOGC:       return NVS_FR_FOGCOORD;
-      case NV40_VP_INST_IN_TC(0):      return NVS_FR_TEXCOORD0;
-      case NV40_VP_INST_IN_TC(1):      return NVS_FR_TEXCOORD1;
-      case NV40_VP_INST_IN_TC(2):      return NVS_FR_TEXCOORD2;
-      case NV40_VP_INST_IN_TC(3):      return NVS_FR_TEXCOORD3;
-      case NV40_VP_INST_IN_TC(4):      return NVS_FR_TEXCOORD4;
-      case NV40_VP_INST_IN_TC(5):      return NVS_FR_TEXCOORD5;
-      case NV40_VP_INST_IN_TC(6):      return NVS_FR_TEXCOORD6;
-      case NV40_VP_INST_IN_TC(7):      return NVS_FR_TEXCOORD7;
-      default:
-        return -1;
-      }
-      break;
-   case NVS_FILE_CONST:
-      return ((shader->inst[1] & NV40_VP_INST_CONST_SRC_MASK)
-             >> NV40_VP_INST_CONST_SRC_SHIFT);
-   case NVS_FILE_TEMP:
-      {
-        unsigned int src;
-
-        src = shader->GetSourceHW(shader, merged, pos);
-        return ((src & NV40_VP_SRC_TEMP_SRC_MASK) >>
-                NV40_VP_SRC_TEMP_SRC_SHIFT);
-      }
-   default:
-      return -1;
-   }
-}
-
-static int
-NV40VPGetSourceNegate(nvsFunc * shader, int merged, int pos)
-{
-   unsigned int src;
-
-   src = shader->GetSourceHW(shader, merged, pos);
-
-   if (src == -1)
-      return -1;
-   return ((src & NV40_VP_SRC_NEGATE) ? 1 : 0);
-}
-
-static void
-NV40VPGetSourceSwizzle(nvsFunc * shader, int merged, int pos, nvsSwzComp *swz)
-{
-   unsigned int src;
-   int swzbits;
-
-   src = shader->GetSourceHW(shader, merged, pos);
-   swzbits = (src & NV40_VP_SRC_SWZ_ALL_MASK) >> NV40_VP_SRC_SWZ_ALL_SHIFT;
-   NV20VPTXSwizzle(swzbits, swz);
-}
-
-static int
-NV40VPGetSourceIndexed(nvsFunc * shader, int merged, int pos)
-{
-   switch (shader->GetSourceFile(shader, merged, pos)) {
-   case NVS_FILE_ATTRIB:
-      return ((shader->inst[0] & NV40_VP_INST_INDEX_INPUT) ? 1 : 0);
-   case NVS_FILE_CONST:
-      return ((shader->inst[3] & NV40_VP_INST_INDEX_CONST) ? 1 : 0);
-   default:
-      return 0;
-   }
-}
-
-static nvsSwzComp
-NV40VPGetAddressRegSwizzle(nvsFunc * shader)
-{
-   nvsSwzComp swz;
-
-   swz = NV20VP_TX_SWIZZLE[(shader->inst[0] & NV40_VP_INST_ADDR_SWZ_MASK)
-                          >> NV40_VP_INST_ADDR_SWZ_SHIFT];
-   return swz;
-}
-
-static int
-NV40VPSupportsConditional(nvsFunc * shader)
-{
-   /*FIXME: Is this true of all ops? */
-   return 1;
-}
-
-static int
-NV40VPGetConditionUpdate(nvsFunc * shader)
-{
-   return ((shader->inst[0] & NV40_VP_INST_COND_UPDATE_ENABLE) ? 1 : 0);
-}
-
-static int
-NV40VPGetConditionTest(nvsFunc * shader)
-{
-   int op;
-
-   /* The condition test is unconditionally enabled on some
-    * instructions. ie: the condition test bit does *NOT* have
-    * to be set.
-    *
-    * FIXME: check other relevant ops for this situation.
-    */
-   op = shader->GetOpcodeHW(shader, 1);
-   switch (op) {
-   case NV40_VP_INST_OP_BRA:
-      return 1;
-   default:
-      return ((shader->inst[0] & NV40_VP_INST_COND_TEST_ENABLE) ? 1 : 0);
-   }
-}
-
-static nvsCond
-NV40VPGetCondition(nvsFunc * shader)
-{
-   int cond;
-
-   cond = ((shader->inst[0] & NV40_VP_INST_COND_MASK)
-          >> NV40_VP_INST_COND_SHIFT);
-
-   switch (cond) {
-   case NV40_VP_INST_COND_FL: return NVS_COND_FL;
-   case NV40_VP_INST_COND_LT: return NVS_COND_LT;
-   case NV40_VP_INST_COND_EQ: return NVS_COND_EQ;
-   case NV40_VP_INST_COND_LE: return NVS_COND_LE;
-   case NV40_VP_INST_COND_GT: return NVS_COND_GT;
-   case NV40_VP_INST_COND_NE: return NVS_COND_NE;
-   case NV40_VP_INST_COND_GE: return NVS_COND_GE;
-   case NV40_VP_INST_COND_TR: return NVS_COND_TR;
-   default:
-      return NVS_COND_UNKNOWN;
-   }
-}
-
-static void
-NV40VPGetCondRegSwizzle(nvsFunc * shader, nvsSwzComp *swz)
-{
-   int swzbits;
-
-   swzbits = (shader->inst[0] & NV40_VP_INST_COND_SWZ_ALL_MASK)
-      >> NV40_VP_INST_COND_SWZ_ALL_SHIFT;
-   NV20VPTXSwizzle(swzbits, swz);
-}
-
-static int
-NV40VPGetCondRegID(nvsFunc * shader)
-{
-   return ((shader->inst[0] & NV40_VP_INST_COND_REG_SELECT_1) ? 1 : 0);
-}
-
-static int
-NV40VPGetBranch(nvsFunc * shader)
-{
-   int addr;
-
-   addr = ((shader->inst[2] & NV40_VP_INST_IADDRH_MASK)
-          >> NV40_VP_INST_IADDRH_SHIFT) << 3;
-   addr |= ((shader->inst[3] & NV40_VP_INST_IADDRL_MASK)
-           >> NV40_VP_INST_IADDRL_SHIFT);
-   return addr;
-}
-
-void
-NV40VPInitShaderFuncs(nvsFunc * shader)
-{
-   /* Inherit NV30 VP code, we share some of it */
-   NV30VPInitShaderFuncs(shader);
-
-   /* Limits */
-   shader->MaxInst     = 4096;
-   shader->MaxAttrib   = 16;
-   shader->MaxTemp     = 32;
-   shader->MaxAddress  = 2;
-   shader->MaxConst    = 256;
-   shader->caps                = SCAP_SRC_ABS;
-
-   /* Add extra opcodes for NV40+ */
-//      MOD_OPCODE(NVVP_TX_VOP, NV40_VP_INST_OP_TXWHAT, NVS_OP_TEX  ,  0,  4, -1);
-   MOD_OPCODE(NVVP_TX_SOP, NV40_VP_INST_OP_PUSHA, NVS_OP_PUSHA,  3, -1, -1);
-   MOD_OPCODE(NVVP_TX_SOP, NV40_VP_INST_OP_POPA , NVS_OP_POPA , -1, -1, -1);
-
-   shader->InitInstruction     = NV40VPInitInstruction;
-   shader->SupportsOpcode      = NV40VPSupportsOpcode;
-   shader->SetOpcode           = NV40VPSetOpcode;
-   shader->SetCCUpdate         = NV40VPSetCCUpdate;
-   shader->SetCondition                = NV40VPSetCondition;
-   shader->SetResult           = NV40VPSetResult;
-   shader->SetSource           = NV40VPSetSource;
-   shader->SetLastInst         = NV40VPSetLastInst;
-   shader->SetBranchTarget     = NV40VPSetBranchTarget;
-
-   shader->HasMergedInst       = NV40VPHasMergedInst;
-   shader->GetOpcodeHW         = NV40VPGetOpcodeHW;
-
-   shader->GetDestFile         = NV40VPGetDestFile;
-   shader->GetDestID           = NV40VPGetDestID;
-   shader->GetDestMask         = NV40VPGetDestMask;
-
-   shader->GetSourceHW         = NV40VPGetSourceHW;
-   shader->GetSourceFile       = NV40VPGetSourceFile;
-   shader->GetSourceID         = NV40VPGetSourceID;
-   shader->GetSourceNegate     = NV40VPGetSourceNegate;
-   shader->GetSourceSwizzle    = NV40VPGetSourceSwizzle;
-   shader->GetSourceIndexed    = NV40VPGetSourceIndexed;
-
-   shader->GetRelAddressSwizzle        = NV40VPGetAddressRegSwizzle;
-
-   shader->SupportsConditional = NV40VPSupportsConditional;
-   shader->GetConditionUpdate  = NV40VPGetConditionUpdate;
-   shader->GetConditionTest    = NV40VPGetConditionTest;
-   shader->GetCondition                = NV40VPGetCondition;
-   shader->GetCondRegSwizzle   = NV40VPGetCondRegSwizzle;
-   shader->GetCondRegID                = NV40VPGetCondRegID;
-
-   shader->GetBranch           = NV40VPGetBranch;
-}
diff --git a/src/mesa/drivers/dri/nouveau/nv50_state.c b/src/mesa/drivers/dri/nouveau/nv50_state.c
deleted file mode 100644 (file)
index 818e268..0000000
+++ /dev/null
@@ -1,641 +0,0 @@
-/**************************************************************************
-
-Copyright 2006 Nouveau
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-#include "nouveau_context.h"
-#include "nouveau_object.h"
-#include "nouveau_fifo.h"
-#include "nouveau_reg.h"
-#include "nouveau_state.h"
-
-#include "tnl/t_pipeline.h"
-
-#include "mtypes.h"
-#include "colormac.h"
-
-static void nv50AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       GLubyte ubRef;
-       CLAMPED_FLOAT_TO_UBYTE(ubRef, ref);
-
-       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_ALPHA_FUNC_REF, 2);
-       OUT_RING_CACHE(ubRef);
-       OUT_RING_CACHE(func);
-}
-
-static void nv50BlendColor(GLcontext *ctx, const GLfloat color[4])
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); 
-
-       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_BLEND_COLOR_R, 4);
-       OUT_RING_CACHEf(color[0]);
-       OUT_RING_CACHEf(color[1]);
-       OUT_RING_CACHEf(color[2]);
-       OUT_RING_CACHEf(color[3]);
-}
-
-static void nv50BlendEquationSeparate(GLcontext *ctx, GLenum modeRGB, GLenum modeA)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_BLEND_EQUATION_RGB, 1);
-       OUT_RING_CACHE(modeRGB);
-       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_BLEND_EQUATION_ALPHA, 1);
-       OUT_RING_CACHE(modeA);
-}
-
-
-static void nv50BlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB, GLenum dfactorRGB,
-               GLenum sfactorA, GLenum dfactorA)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_BLEND_FUNC_SRC_RGB, 2);
-       OUT_RING_CACHE(sfactorRGB);     /* FIXME, sometimes has |0x4000 */
-       OUT_RING_CACHE(dfactorRGB);     /* FIXME, sometimes has |0x4000 */
-       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_BLEND_FUNC_SRC_ALPHA, 2);
-       OUT_RING_CACHE(sfactorA);       /* FIXME, sometimes has |0x4000 */
-       OUT_RING_CACHE(dfactorA);       /* FIXME, sometimes has |0x4000 */
-}
-
-static void nv50Clear(GLcontext *ctx, GLbitfield mask)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       GLuint hw_bufs = 0;
-
-       if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT))
-               hw_bufs |= 0x3c;
-       if (mask & (BUFFER_BIT_STENCIL))
-               hw_bufs |= 0x02;
-       if (mask & (BUFFER_BIT_DEPTH))
-               hw_bufs |= 0x01;
-
-       if (hw_bufs) {
-               BEGIN_RING_SIZE(NvSub3D, NV50_TCL_PRIMITIVE_3D_CLEAR_BUFFERS, 1);
-               OUT_RING(hw_bufs);
-       }
-}
-
-static void nv50ClearColor(GLcontext *ctx, const GLfloat color[4])
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_CLEAR_COLOR_R, 4);
-       OUT_RING_CACHEf(color[0]);
-       OUT_RING_CACHEf(color[1]);
-       OUT_RING_CACHEf(color[2]);
-       OUT_RING_CACHEf(color[3]);
-}
-
-static void nv50ClearDepth(GLcontext *ctx, GLclampd d)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_CLEAR_DEPTH, 1);
-       OUT_RING_CACHEf(d);
-}
-
-/* we're don't support indexed buffers
-   void (*ClearIndex)(GLcontext *ctx, GLuint index)
- */
-
-static void nv50ClearStencil(GLcontext *ctx, GLint s)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_CLEAR_STENCIL, 1);
-       OUT_RING_CACHE(s);
-}
-
-static void nv50ClipPlane(GLcontext *ctx, GLenum plane, const GLfloat *equation)
-{
-       /* Only using shaders */
-}
-
-static void nv50ColorMask(GLcontext *ctx, GLboolean rmask, GLboolean gmask,
-               GLboolean bmask, GLboolean amask )
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       int i;
-
-       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_COLOR_MASK(0), 8);
-       for (i=0; i<8; i++) {
-               OUT_RING_CACHE(((amask && 0x01) << 12) | ((bmask && 0x01) << 8) | ((gmask && 0x01)<< 4) | ((rmask && 0x01) << 0));
-       }
-}
-
-static void nv50ColorMaterial(GLcontext *ctx, GLenum face, GLenum mode)
-{
-       // TODO I need love
-}
-
-static void nv50CullFace(GLcontext *ctx, GLenum mode)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_CULL_FACE, 1);
-       OUT_RING_CACHE(mode);
-}
-
-static void nv50FrontFace(GLcontext *ctx, GLenum mode)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_FRONT_FACE, 1);
-       OUT_RING_CACHE(mode);
-}
-
-static void nv50DepthFunc(GLcontext *ctx, GLenum func)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_DEPTH_FUNC, 1);
-       OUT_RING_CACHE(func);
-}
-
-static void nv50DepthMask(GLcontext *ctx, GLboolean flag)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_DEPTH_WRITE_ENABLE, 1);
-       OUT_RING_CACHE(flag);
-}
-
-static void nv50DepthRange(GLcontext *ctx, GLclampd nearval, GLclampd farval)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_DEPTH_RANGE_NEAR, 2);
-       OUT_RING_CACHEf(nearval);
-       OUT_RING_CACHEf(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 );
-
-static void nv50Enable(GLcontext *ctx, GLenum cap, GLboolean state)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       switch(cap)
-       {
-               case GL_ALPHA_TEST:
-                       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_ALPHA_FUNC_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_AUTO_NORMAL:
-//             case GL_BLEND:
-//             case GL_CLIP_PLANE0:
-//             case GL_CLIP_PLANE1:
-//             case GL_CLIP_PLANE2:
-//             case GL_CLIP_PLANE3:
-//             case GL_CLIP_PLANE4:
-//             case GL_CLIP_PLANE5:
-               case GL_COLOR_LOGIC_OP:
-                       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_LOGIC_OP_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_COLOR_MATERIAL:
-//             case GL_COLOR_SUM_EXT:
-//             case GL_COLOR_TABLE:
-//             case GL_CONVOLUTION_1D:
-//             case GL_CONVOLUTION_2D:
-               case GL_CULL_FACE:
-                       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_CULL_FACE_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_DEPTH_TEST:
-                       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_DEPTH_TEST_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_DITHER:
-//             case GL_FOG:
-//             case GL_HISTOGRAM:
-//             case GL_INDEX_LOGIC_OP:
-//             case GL_LIGHT0:
-//             case GL_LIGHT1:
-//             case GL_LIGHT2:
-//             case GL_LIGHT3:
-//             case GL_LIGHT4:
-//             case GL_LIGHT5:
-//             case GL_LIGHT6:
-//             case GL_LIGHT7:
-//             case GL_LIGHTING:
-               case GL_LINE_SMOOTH:
-                       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_LINE_SMOOTH_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_LINE_STIPPLE:
-                       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_LINE_STIPPLE_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_MAP1_COLOR_4:
-//             case GL_MAP1_INDEX:
-//             case GL_MAP1_NORMAL:
-//             case GL_MAP1_TEXTURE_COORD_1:
-//             case GL_MAP1_TEXTURE_COORD_2:
-//             case GL_MAP1_TEXTURE_COORD_3:
-//             case GL_MAP1_TEXTURE_COORD_4:
-//             case GL_MAP1_VERTEX_3:
-//             case GL_MAP1_VERTEX_4:
-//             case GL_MAP2_COLOR_4:
-//             case GL_MAP2_INDEX:
-//             case GL_MAP2_NORMAL:
-//             case GL_MAP2_TEXTURE_COORD_1:
-//             case GL_MAP2_TEXTURE_COORD_2:
-//             case GL_MAP2_TEXTURE_COORD_3:
-//             case GL_MAP2_TEXTURE_COORD_4:
-//             case GL_MAP2_VERTEX_3:
-//             case GL_MAP2_VERTEX_4:
-//             case GL_MINMAX:
-//             case GL_NORMALIZE:
-//             case GL_POINT_SMOOTH:
-               case GL_POLYGON_OFFSET_POINT:
-                       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_POLYGON_OFFSET_POINT_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_POLYGON_OFFSET_LINE:
-                       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_POLYGON_OFFSET_LINE_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_POLYGON_OFFSET_FILL:
-                       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_POLYGON_OFFSET_FILL_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_POLYGON_SMOOTH:
-                       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_POLYGON_SMOOTH_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-               case GL_POLYGON_STIPPLE:
-                       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_POLYGON_STIPPLE_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_POST_COLOR_MATRIX_COLOR_TABLE:
-//             case GL_POST_CONVOLUTION_COLOR_TABLE:
-//             case GL_RESCALE_NORMAL:
-               case GL_SCISSOR_TEST:
-                       /* No enable bit, nv50Scissor will adjust to max range */
-                       ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
-                                                ctx->Scissor.Width, ctx->Scissor.Height);
-                       break;
-//             case GL_SEPARABLE_2D:
-               case GL_STENCIL_TEST:
-                       // TODO BACK and FRONT ?
-                       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_STENCIL_FRONT_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_STENCIL_BACK_ENABLE, 1);
-                       OUT_RING_CACHE(state);
-                       break;
-//             case GL_TEXTURE_GEN_Q:
-//             case GL_TEXTURE_GEN_R:
-//             case GL_TEXTURE_GEN_S:
-//             case GL_TEXTURE_GEN_T:
-//             case GL_TEXTURE_1D:
-//             case GL_TEXTURE_2D:
-//             case GL_TEXTURE_3D:
-       }
-}
-
-static void nv50Fogfv(GLcontext *ctx, GLenum pname, const GLfloat *params)
-{
-       /* Only using shaders */
-}
-   
-static void nv50Hint(GLcontext *ctx, GLenum target, GLenum mode)
-{
-       // TODO I need love (fog and line_smooth hints)
-}
-
-// void (*IndexMask)(GLcontext *ctx, GLuint mask);
-
-static void nv50Lightfv(GLcontext *ctx, GLenum light, GLenum pname, const GLfloat *params )
-{
-       /* Only with shaders */
-}
-
-/** Set the lighting model parameters */
-void (*LightModelfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
-
-
-static void nv50LineStipple(GLcontext *ctx, GLint factor, GLushort pattern )
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_LINE_STIPPLE_PATTERN, 1);
-       OUT_RING_CACHE((pattern << 8) | factor);
-}
-
-static void nv50LineWidth(GLcontext *ctx, GLfloat width)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_LINE_WIDTH, 1);
-       OUT_RING_CACHEf(width);
-}
-
-static void nv50LogicOpcode(GLcontext *ctx, GLenum opcode)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_LOGIC_OP_OP, 1);
-       OUT_RING_CACHE(opcode);
-}
-
-static void nv50PointParameterfv(GLcontext *ctx, GLenum pname, const GLfloat *params)
-{
-       /*TODO: not sure what goes here. */
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-       
-}
-
-/** Specify the diameter of rasterized points */
-static void nv50PointSize(GLcontext *ctx, GLfloat size)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_POINT_SIZE, 1);
-       OUT_RING_CACHEf(size);
-}
-
-/** Select a polygon rasterization mode */
-static void nv50PolygonMode(GLcontext *ctx, GLenum face, GLenum mode)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
-               BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_POLYGON_MODE_FRONT, 1);
-               OUT_RING_CACHE(mode);
-       }
-       if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
-               BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_POLYGON_MODE_BACK, 1);
-               OUT_RING_CACHE(mode);
-       }
-}
-
-/** Set the scale and units used to calculate depth values */
-static void nv50PolygonOffset(GLcontext *ctx, GLfloat factor, GLfloat units)
-{
-        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-        BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_POLYGON_OFFSET_FACTOR, 1);
-        OUT_RING_CACHEf(factor);
-        BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_POLYGON_OFFSET_UNITS, 1);
-        OUT_RING_CACHEf(units);
-}
-
-/** Set the polygon stippling pattern */
-static void nv50PolygonStipple(GLcontext *ctx, const GLubyte *mask )
-{
-        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-        BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_POLYGON_STIPPLE_PATTERN(0), 32);
-        OUT_RING_CACHEp(mask, 32);
-}
-
-/* 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 */
-static void nv50Scissor(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
-{
-        nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       /* There's no scissor enable bit, so adjust the scissor to cover the
-        * maximum draw buffer bounds
-        */
-       if (!ctx->Scissor.Enabled) {
-          x = y = 0;
-          w = h = 8191;
-       } else {
-          x += nmesa->drawX;
-          y += nmesa->drawY;
-       }
-
-        BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_SCISSOR_WIDTH_XPOS, 2);
-        OUT_RING_CACHE(((w) << 16) | x);
-        OUT_RING_CACHE(((h) << 16) | y);
-}
-
-/** Select flat or smooth shading */
-static void nv50ShadeModel(GLcontext *ctx, GLenum mode)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_SHADE_MODEL, 1);
-       OUT_RING_CACHE(mode);
-}
-
-/** OpenGL 2.0 two-sided StencilFunc */
-static void nv50StencilFuncSeparate(GLcontext *ctx, GLenum face, GLenum func,
-               GLint ref, GLuint mask)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
-               BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_STENCIL_FRONT_FUNC_FUNC, 1);
-               OUT_RING_CACHE(func);
-               BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_STENCIL_FRONT_FUNC_REF, 1);
-               OUT_RING_CACHE(ref);
-               BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_STENCIL_FRONT_FUNC_MASK, 1);
-               OUT_RING_CACHE(mask);
-       }
-       if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
-               BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_STENCIL_BACK_FUNC_FUNC, 2);
-               OUT_RING_CACHE(func);
-               OUT_RING_CACHE(ref);
-               BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_STENCIL_BACK_FUNC_MASK, 1);
-               OUT_RING_CACHE(mask);
-       }
-}
-
-/** OpenGL 2.0 two-sided StencilMask */
-static void nv50StencilMaskSeparate(GLcontext *ctx, GLenum face, GLuint mask)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
-               BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_STENCIL_FRONT_MASK, 1);
-               OUT_RING_CACHE(mask);
-       }
-       if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
-               BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_STENCIL_BACK_MASK, 1);
-               OUT_RING_CACHE(mask);
-       }
-}
-
-/** OpenGL 2.0 two-sided StencilOp */
-static void nv50StencilOpSeparate(GLcontext *ctx, GLenum face, GLenum fail,
-               GLenum zfail, GLenum zpass)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
-               BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_STENCIL_FRONT_OP_FAIL, 3);
-               OUT_RING_CACHE(fail);
-               OUT_RING_CACHE(zfail);
-               OUT_RING_CACHE(zpass);
-       }
-       if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
-               BEGIN_RING_CACHE(NvSub3D, NV50_TCL_PRIMITIVE_3D_STENCIL_BACK_OP_FAIL, 3);
-               OUT_RING_CACHE(fail);
-               OUT_RING_CACHE(zfail);
-               OUT_RING_CACHE(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);
-
-static void nv50TextureMatrix(GLcontext *ctx, GLuint unit, const GLmatrix *mat)
-{
-       /* Only with shaders */
-}
-
-static void nv50WindowMoved(nouveauContextPtr nmesa)
-{
-       GLcontext *ctx = nmesa->glCtx;
-       GLfloat *v = nmesa->viewport.m;
-       GLuint w = ctx->Viewport.Width;
-       GLuint h = ctx->Viewport.Height;
-       GLuint x = ctx->Viewport.X + nmesa->drawX;
-       GLuint y = ctx->Viewport.Y + nmesa->drawY;
-       int i;
-
-       BEGIN_RING_CACHE(NvSub3D,
-             NV50_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(0), 2);
-        OUT_RING_CACHE((8191 << 16) | 0);
-        OUT_RING_CACHE((8191 << 16) | 0);
-       for (i=1; i<8; i++) {
-               BEGIN_RING_CACHE(NvSub3D,
-                     NV50_TCL_PRIMITIVE_3D_VIEWPORT_CLIP_HORIZ(i), 2);
-               OUT_RING_CACHE(0);
-               OUT_RING_CACHE(0);
-       }
-
-       ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
-                           ctx->Scissor.Width, ctx->Scissor.Height);
-}
-
-static GLboolean nv50InitCard(nouveauContextPtr nmesa)
-{
-       int i,j;
-
-       nouveauObjectOnSubchannel(nmesa, NvSub3D, Nv3D);
-
-       BEGIN_RING_SIZE(NvSub3D, 0x1558, 1);
-       OUT_RING(1);
-
-       BEGIN_RING_SIZE(NvSub3D, NV50_TCL_PRIMITIVE_3D_SET_OBJECT_1(0), 8);
-       for (i=0; i<8; i++) {
-               OUT_RING(NvDmaFB);
-       }
-
-       BEGIN_RING_SIZE(NvSub3D, NV50_TCL_PRIMITIVE_3D_SET_OBJECT_0(0), 12);
-       for (i=0; i<12; i++) {
-               OUT_RING(NvDmaFB);
-       }
-
-       BEGIN_RING_SIZE(NvSub3D, 0x121c, 1);
-       OUT_RING(1);
-
-       for (i=0; i<8; i++) {
-               BEGIN_RING_SIZE(NvSub3D, 0x0200 + (i*0x20), 5);
-               for (j=0; j<5; j++) {
-                       OUT_RING(0);
-               }
-       }
-
-       BEGIN_RING_SIZE(NvSub3D, 0x0fe0, 5);
-       OUT_RING(0);
-       OUT_RING(0);
-       OUT_RING(0x16);
-       OUT_RING(0);
-       OUT_RING(0);
-
-       return GL_FALSE;
-}
-
-static GLboolean nv50BindBuffers(nouveauContextPtr nmesa, int num_color,
-                                nouveau_renderbuffer **color,
-                                nouveau_renderbuffer *depth)
-{
-       return GL_FALSE;
-}
-
-void nv50InitStateFuncs(GLcontext *ctx, struct dd_function_table *func)
-{
-       nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
-
-       func->AlphaFunc                 = nv50AlphaFunc;
-       func->BlendColor                = nv50BlendColor;
-       func->BlendEquationSeparate     = nv50BlendEquationSeparate;
-       func->BlendFuncSeparate         = nv50BlendFuncSeparate;
-       func->Clear                     = nv50Clear;
-       func->ClearColor                = nv50ClearColor;
-       func->ClearDepth                = nv50ClearDepth;
-       func->ClearStencil              = nv50ClearStencil;
-       func->ClipPlane                 = nv50ClipPlane;
-       func->ColorMask                 = nv50ColorMask;
-       func->ColorMaterial             = nv50ColorMaterial;
-       func->CullFace                  = nv50CullFace;
-       func->FrontFace                 = nv50FrontFace;
-       func->DepthFunc                 = nv50DepthFunc;
-       func->DepthMask                 = nv50DepthMask;
-       func->DepthRange                = nv50DepthRange;
-       func->Enable                    = nv50Enable;
-       func->Fogfv                     = nv50Fogfv;
-       func->Hint                      = nv50Hint;
-       func->Lightfv                   = nv50Lightfv;
-/*     func->LightModelfv              = nv50LightModelfv;      */
-       func->LineStipple               = nv50LineStipple;
-       func->LineWidth                 = nv50LineWidth;
-       func->LogicOpcode               = nv50LogicOpcode;
-       func->PointParameterfv          = nv50PointParameterfv;
-       func->PointSize                 = nv50PointSize;
-       func->PolygonMode               = nv50PolygonMode;
-       func->PolygonOffset             = nv50PolygonOffset;
-       func->PolygonStipple            = nv50PolygonStipple;
-/*     func->ReadBuffer                = nv50ReadBuffer;       */
-/*     func->RenderMode                = nv50RenderMode;       */
-       func->Scissor                   = nv50Scissor;
-       func->ShadeModel                = nv50ShadeModel;
-       func->StencilFuncSeparate       = nv50StencilFuncSeparate;
-       func->StencilMaskSeparate       = nv50StencilMaskSeparate;
-       func->StencilOpSeparate         = nv50StencilOpSeparate;
-/*     func->TexGen                    = nv50TexGen;           */
-/*     func->TexParameter              = nv50TexParameter;     */
-       func->TextureMatrix             = nv50TextureMatrix;
-
-       nmesa->hw_func.InitCard         = nv50InitCard;
-       nmesa->hw_func.BindBuffers      = nv50BindBuffers;
-       nmesa->hw_func.WindowMoved      = nv50WindowMoved;
-}
index dfc89a2da7624d807053ff96f9e3c51126d02ce8..5e7cadc331503f35edf580a819606a828d01284a 100644 (file)
@@ -253,7 +253,7 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual,
    _tnl_allow_vertex_fog( ctx, GL_TRUE );
 
    driInitExtensions( ctx, card_extensions, GL_TRUE );
-   if (sPriv->drmMinor >= 4)
+   if (sPriv->drm_version.minor >= 4)
       _mesa_enable_extension( ctx, "GL_MESA_ycbcr_texture" );
 
    r128InitTriFuncs( ctx );
@@ -261,9 +261,6 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual,
    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
@@ -346,8 +343,13 @@ r128MakeCurrent( __DRIcontextPrivate *driContextPriv,
         newR128Ctx->dirty = R128_UPLOAD_ALL;
       }
 
-      driDrawableInitVBlank( driDrawPriv, newR128Ctx->vblank_flags,
-                            &newR128Ctx->vbl_seq );
+      if (driDrawPriv->swap_interval == (unsigned)-1) {
+        driDrawPriv->vblFlags = (newR128Ctx->r128Screen->irq != 0)
+           ? driGetDefaultVBlankFlags(&newR128Ctx->optionCache)
+           : VBLANK_FLAG_NO_IRQ;
+
+        driDrawableInitVBlank( driDrawPriv );
+      }
       newR128Ctx->driDrawable = driDrawPriv;
 
       _mesa_make_current( newR128Ctx->glCtx,
index 1d10cb0b4fe94c48282fbfc60e56ec9c3b4dd9f4..7bf853da39ca798c1af039a21697e232c71b8fbc 100644 (file)
@@ -209,11 +209,6 @@ struct r128_context {
    GLuint c_textureBytes;
    GLuint c_vertexBuffers;
 
-   /* VBI
-    */
-   GLuint vbl_seq;
-   GLuint vblank_flags;
-
    /* Configuration cache
     */
    driOptionCache optionCache;
index dcb5d10459ed2fd47f940bb52ccb151e7bf0ac73..a3d4b2ba0c4fefd06785a108197d0624f2cf05b9 100644 (file)
@@ -248,7 +248,7 @@ static int r128WaitForFrameCompletion( r128ContextPtr rmesa )
 
 /* Copy the back color buffer to the front color buffer.
  */
-void r128CopyBuffer( const __DRIdrawablePrivate *dPriv )
+void r128CopyBuffer( __DRIdrawablePrivate *dPriv )
 {
    r128ContextPtr rmesa;
    GLint nbox, i, ret;
@@ -281,7 +281,7 @@ void r128CopyBuffer( const __DRIdrawablePrivate *dPriv )
    }
 
    UNLOCK_HARDWARE( rmesa );
-   driWaitForVBlank( dPriv, &rmesa->vbl_seq, rmesa->vblank_flags, &missed_target );
+   driWaitForVBlank( dPriv, &missed_target );
    LOCK_HARDWARE( rmesa );
 
    nbox = dPriv->numClipRects; /* must be in locked region */
@@ -327,7 +327,7 @@ void r128CopyBuffer( const __DRIdrawablePrivate *dPriv )
 #endif
 }
 
-void r128PageFlip( const __DRIdrawablePrivate *dPriv )
+void r128PageFlip( __DRIdrawablePrivate *dPriv )
 {
    r128ContextPtr rmesa;
    GLint ret;
@@ -358,7 +358,7 @@ void r128PageFlip( const __DRIdrawablePrivate *dPriv )
    }
 
    UNLOCK_HARDWARE( rmesa );
-   driWaitForVBlank( dPriv, &rmesa->vbl_seq, rmesa->vblank_flags, &missed_target );
+   driWaitForVBlank( dPriv, &missed_target );
    LOCK_HARDWARE( rmesa );
 
    /* The kernel will have been initialized to perform page flipping
index 52ae3a293f831020a2d8027853ef1a811efa7613..4b0c9cdc7febde7e64cdfb031c562e8471552cf9 100644 (file)
@@ -44,7 +44,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 extern drmBufPtr r128GetBufferLocked( r128ContextPtr rmesa );
 extern void r128FlushVerticesLocked( r128ContextPtr rmesa );
 
-static __inline void *r128AllocDmaLow( r128ContextPtr rmesa, int count,
+static INLINE void *r128AllocDmaLow( r128ContextPtr rmesa, int count,
                                       int vert_size )
 {
    uint32_t *head;
@@ -85,8 +85,8 @@ extern void r128ReadDepthSpanLocked( r128ContextPtr rmesa,
 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 );
+extern void r128CopyBuffer( __DRIdrawablePrivate *dPriv );
+extern void r128PageFlip( __DRIdrawablePrivate *dPriv );
 void r128WaitForVBlank( r128ContextPtr rmesa );
 
 extern void r128WaitForIdleLocked( r128ContextPtr rmesa );
index 1e9616272f0407699b200e124f19fb9992e30768..448c8573805cd17028cd7619d94c3d28326f3dd7 100644 (file)
@@ -97,9 +97,7 @@ 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;
+   int i;
 
    if (sPriv->devPrivSize != sizeof(R128DRIRec)) {
       fprintf(stderr,"\nERROR!  sizeof(R128DRIRec) does not match passed size from device driver\n");
@@ -120,7 +118,7 @@ r128CreateScreen( __DRIscreenPrivate *sPriv )
    r128Screen->IsPCI = r128DRIPriv->IsPCI;
    r128Screen->sarea_priv_offset = r128DRIPriv->sarea_priv_offset;
    
-   if (sPriv->drmMinor >= 3) {
+   if (sPriv->drm_version.minor >= 3) {
       drm_r128_getparam_t gp;
       int ret;
 
@@ -225,15 +223,14 @@ r128CreateScreen( __DRIscreenPrivate *sPriv )
 
    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" );
+   i = 0;
+   r128Screen->extensions[i++] = &driFrameTrackingExtension.base;
+   if ( r128Screen->irq != 0 ) {
+       r128Screen->extensions[i++] = &driSwapControlExtension.base;
+       r128Screen->extensions[i++] = &driMediaStreamCounterExtension.base;
    }
+   r128Screen->extensions[i++] = NULL;
+   sPriv->extensions = r128Screen->extensions;
 
    return r128Screen;
 }
@@ -401,37 +398,18 @@ r128InitDriver( __DRIscreenPrivate *sPriv )
    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,
+static const __DRIconfig **
+r128FillInModes( __DRIscreenPrivate *psp,
+                unsigned pixel_bits, unsigned depth_bits,
                 unsigned stencil_bits, GLboolean have_back_buffer )
 {
-    __GLcontextModes * modes;
+    __DRIconfig **configs;
     __GLcontextModes * m;
-    unsigned num_modes;
     unsigned depth_buffer_factor;
     unsigned back_buffer_factor;
     GLenum fb_format;
     GLenum fb_type;
+    int 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
@@ -459,8 +437,6 @@ r128FillInModes( unsigned pixel_bits, unsigned depth_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;
@@ -470,97 +446,85 @@ r128FillInModes( unsigned pixel_bits, unsigned depth_bits,
         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;
-    }
+   configs = driCreateConfigs(fb_format, fb_type,
+                             depth_bits_array, stencil_bits_array,
+                             depth_buffer_factor, back_buffer_modes,
+                             back_buffer_factor);
+   if (configs == NULL) {
+    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;
-       }
-    }
+   /* Mark the visual as slow if there are "fake" stencil bits.
+    */
+   for (i = 0; configs[i]; i++) {
+      m = &configs[i]->modes;
+      if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
+         m->visualRating = GLX_SLOW_CONFIG;
+      }
+   }
 
-    return modes;
+   return (const __DRIconfig **) configs;
 }
 
 
 /**
- * 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.
+ * This is the driver specific part of the createNewScreen entry point.
  * 
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on 
- *         failure.
+ * \todo maybe fold this into intelInitDriver
+ *
+ * \return the __GLcontextModes supported by this driver
  */
-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 )
-                            
+static const __DRIconfig **
+r128InitScreen(__DRIscreenPrivate *psp)
 {
-   __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;
+   R128DRIPtr dri_priv = (R128DRIPtr) psp->pDevPriv;
 
    if ( ! driCheckDriDdxDrmVersions2( "Rage128",
-                                     dri_version, & dri_expected,
-                                     ddx_version, & ddx_expected,
-                                     drm_version, & drm_expected ) ) {
+                                     &psp->dri_version, & dri_expected,
+                                     &psp->ddx_version, & ddx_expected,
+                                     &psp->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;
+   /* 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 );
+
+   if (!r128InitDriver(psp))
+       return NULL;
+
+   return r128FillInModes( psp,
+                          dri_priv->bpp,
+                          (dri_priv->bpp == 16) ? 16 : 24,
+                          (dri_priv->bpp == 16) ? 0  : 8,
+                          (dri_priv->backOffset != dri_priv->depthOffset) );
 }
+
+const struct __DriverAPIRec driDriverAPI = {
+   .InitScreen      = r128InitScreen,
+   .DestroyScreen   = r128DestroyScreen,
+   .CreateContext   = r128CreateContext,
+   .DestroyContext  = r128DestroyContext,
+   .CreateBuffer    = r128CreateBuffer,
+   .DestroyBuffer   = r128DestroyBuffer,
+   .SwapBuffers     = r128SwapBuffers,
+   .MakeCurrent     = r128MakeCurrent,
+   .UnbindContext   = r128UnbindContext,
+   .GetSwapInfo     = NULL,
+   .GetDrawableMSC  = driDrawableGetMSC32,
+   .WaitForMSC      = driWaitForMSC32,
+   .WaitForSBC      = NULL,
+   .SwapBuffersMSC  = NULL
+};
index b31e87661b51b0342613b6922f8ff405f6735588..e2fa1677c9fa5064bf47cd1baa787173c973dbd6 100644 (file)
@@ -77,6 +77,8 @@ typedef struct {
    /* Configuration cache with default values for all contexts */
    driOptionCache optionCache;
 
+   const __DRIextension *extensions[4];
+
 } r128ScreenRec, *r128ScreenPtr;
 
 
index c5b6480db9e3885d1a953164cdf3352480850a87..dd177e0def5cceef049858cb7d5f454a02079393 100644 (file)
@@ -130,6 +130,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 /* 16-bit depth buffer functions
  */
+#define VALUE_TYPE GLushort
 
 #define WRITE_DEPTH_SPAN()                                             \
 do {                                                                   \
@@ -206,6 +207,8 @@ do {                                                                        \
 
 /* 24-bit depth, 8-bit stencil buffer functions
  */
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH_SPAN()                                             \
 do {                                                                   \
    GLuint buf[n];                                                      \
index 58c3a27ee83d5a50977abc5201d93ccb729efaba..52a4d2e3f11ac70023e3d8a8c675cc56b0f08af9 100644 (file)
@@ -812,7 +812,7 @@ static void r128UpdateWindow( GLcontext *ctx )
    r128ContextPtr rmesa = R128_CONTEXT(ctx);
    int x = rmesa->driDrawable->x;
    int y = rmesa->driDrawable->y;
-   struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+   struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];
    driRenderbuffer *drb = (driRenderbuffer *) rb;
 
    rmesa->setup.window_xy_offset = (((y & 0xFFF) << R128_WINDOW_Y_SHIFT) |
@@ -896,18 +896,22 @@ static void r128DDDrawBuffer( GLcontext *ctx, GLenum mode )
 
    FLUSH_BATCH( rmesa );
 
-   /*
-    * _ColorDrawBufferMask is easier to cope with than <mode>.
-    */
-   switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
-   case BUFFER_BIT_FRONT_LEFT:
-   case BUFFER_BIT_BACK_LEFT:
-      FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_FALSE );
-      break;
-   default:
+   if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) {
       /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
       FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_TRUE );
-      break;
+      return;
+   }
+   else {
+      switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) {
+      case BUFFER_FRONT_LEFT:
+      case BUFFER_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;
+      }
    }
 
    rmesa->new_state |= R128_NEW_WINDOW;
index e863436f4b29a8bd886e724a48b16e3f98c37759..77f0201a55e6c16738f7deea004fae55a7beb8a6 100644 (file)
@@ -67,9 +67,9 @@ extern void r128InitTextureFuncs( struct dd_function_table *functions );
 #define R128PACKCOLOR4444( r, g, b, a )                                        \
    ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
 
-static __inline__ uint32_t r128PackColor( GLuint cpp,
-                                       GLubyte r, GLubyte g,
-                                       GLubyte b, GLubyte a )
+static INLINE uint32_t r128PackColor( GLuint cpp,
+                                      GLubyte r, GLubyte g,
+                                      GLubyte b, GLubyte a )
 {
     switch ( cpp ) {
     case 2:
index 5a178442bdb7bb2a494a1d3a9e3876a7c624c4ee..c567349335cdf396e93ef8b46fdb40dd5f82d69d 100644 (file)
@@ -69,6 +69,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define need_GL_ATI_fragment_shader
 #define need_GL_EXT_blend_minmax
 #define need_GL_EXT_fog_coord
+#define need_GL_EXT_multi_draw_arrays
 #define need_GL_EXT_secondary_color
 #define need_GL_EXT_blend_equation_separate
 #define need_GL_EXT_blend_func_separate
@@ -132,6 +133,7 @@ const struct dri_extension card_extensions[] =
     { "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_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 },
@@ -277,14 +279,14 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
                                                  "def_max_anisotropy");
 
    if ( driQueryOptionb( &rmesa->optionCache, "hyperz" ) ) {
-      if ( sPriv->drmMinor < 13 )
+      if ( sPriv->drm_version.minor < 13 )
         fprintf( stderr, "DRM version 1.%d too old to support HyperZ, "
-                         "disabling.\n",sPriv->drmMinor );
+                         "disabling.\n", sPriv->drm_version.minor );
       else
         rmesa->using_hyperz = GL_TRUE;
    }
  
-   if ( sPriv->drmMinor >= 15 )
+   if ( sPriv->drm_version.minor >= 15 )
       rmesa->texmicrotile = GL_TRUE;
 
    /* Init default driver functions then plug in our R200-specific functions
@@ -317,7 +319,7 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
    rmesa->dri.hwContext = driContextPriv->hHWContext;
    rmesa->dri.hwLock = &sPriv->pSAREA->lock;
    rmesa->dri.fd = sPriv->fd;
-   rmesa->dri.drmMinor = sPriv->drmMinor;
+   rmesa->dri.drmMinor = sPriv->drm_version.minor;
 
    rmesa->r200Screen = screen;
    rmesa->sarea = (drm_radeon_sarea_t *)((GLubyte *)sPriv->pSAREA +
@@ -499,13 +501,10 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
              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 );
+   (*sPriv->systemTime->getUST)( & rmesa->swap_ust );
 
 
 #if DO_DEBUG
@@ -666,15 +665,18 @@ r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
       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->vbl_seq );
-      }
-
       newCtx->dri.readable = driReadPriv;
 
       if ( newCtx->dri.drawable != driDrawPriv ||
            newCtx->lastStamp != driDrawPriv->lastStamp ) {
+        if (driDrawPriv->swap_interval == (unsigned)-1) {
+           driDrawPriv->vblFlags = (newCtx->r200Screen->irq != 0)
+              ? driGetDefaultVBlankFlags(&newCtx->optionCache)
+              : VBLANK_FLAG_NO_IRQ;
+
+           driDrawableInitVBlank( driDrawPriv );
+        }
+
         newCtx->dri.drawable = driDrawPriv;
 
         r200SetCliprects(newCtx);
index bec09e8ef6ab81fd2287bda5574fbd415bca8916..ee478e7d3c06f17d890935a651e7e68bfa38cb44 100644 (file)
@@ -179,6 +179,7 @@ struct r200_tex_obj {
 
    drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS];
                                        /* Six, for the cube faces */
+   GLboolean image_override;           /* Image overridden by GLX_EXT_tfp */
 
    GLuint pp_txfilter;                 /* hardware register values */
    GLuint pp_txformat;
@@ -892,11 +893,8 @@ struct r200_context {
    GLuint TexGenCompSel;
    GLmatrix tmpmat;
 
-   /* VBI / buffer swap
+   /* buffer swap
     */
-   GLuint vbl_seq;
-   GLuint vblank_flags;
-
    int64_t swap_ust;
    int64_t swap_missed_ust;
 
@@ -929,7 +927,7 @@ struct r200_context {
 #define R200_CONTEXT(ctx)              ((r200ContextPtr)(ctx->DriverCtx))
 
 
-static __inline GLuint r200PackColor( GLuint cpp,
+static INLINE GLuint r200PackColor( GLuint cpp,
                                        GLubyte r, GLubyte g,
                                        GLubyte b, GLubyte a )
 {
index 5dd3adaef69540890ceb428283ee43bd190d0c11..d514b28219ade521136ef3478e97f0178090dbd1 100644 (file)
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  **************************************************************************/
-#include "glheader.h"
-#include "macros.h"
-#include "enums.h"
 
+#include "main/glheader.h"
+#include "main/macros.h"
+#include "main/enums.h"
 #include "tnl/t_context.h"
-#include "atifragshader.h"
-#include "program.h"
+#include "shader/atifragshader.h"
+#include "shader/program.h"
 #include "r200_context.h"
 #include "r200_ioctl.h"
 #include "r200_tex.h"
index ed57defb4981486d6cc229e0ed54aa0a3258c3c0..90c695fec9d4f897fe661af730960042fc437320 100644 (file)
@@ -419,13 +419,14 @@ static void r200WaitForFrameCompletion( r200ContextPtr rmesa )
 
 /* Copy the back color buffer to the front color buffer.
  */
-void r200CopyBuffer( const __DRIdrawablePrivate *dPriv,
+void r200CopyBuffer( __DRIdrawablePrivate *dPriv,
                      const drm_clip_rect_t      *rect)
 {
    r200ContextPtr rmesa;
    GLint nbox, i, ret;
    GLboolean   missed_target;
    int64_t ust;
+   __DRIscreenPrivate *psp = dPriv->driScreenPriv;
 
    assert(dPriv);
    assert(dPriv->driContextPriv);
@@ -449,7 +450,7 @@ void r200CopyBuffer( const __DRIdrawablePrivate *dPriv,
    if (!rect)
    {
        UNLOCK_HARDWARE( rmesa );
-       driWaitForVBlank( dPriv, & rmesa->vbl_seq, rmesa->vblank_flags, & missed_target );
+       driWaitForVBlank( dPriv, & missed_target );
        LOCK_HARDWARE( rmesa );
    }
 
@@ -476,16 +477,18 @@ void r200CopyBuffer( const __DRIdrawablePrivate *dPriv,
             if (rect->y2 < b->y2)
                 b->y2 = rect->y2;
 
-            if (b->x1 < b->x2 && b->y1 < b->y2)
-                b++;
+            if (b->x1 >= b->x2 || b->y1 >= b->y2)
+                continue;
          }
-         else
-             b++;
 
+         b++;
          n++;
       }
       rmesa->sarea->nbox = n;
 
+      if (!n)
+        continue;
+
       ret = drmCommandNone( rmesa->dri.fd, DRM_RADEON_SWAP );
 
       if ( ret ) {
@@ -501,7 +504,7 @@ void r200CopyBuffer( const __DRIdrawablePrivate *dPriv,
        rmesa->hw.all_dirty = GL_TRUE;
 
        rmesa->swap_count++;
-       (*dri_interface->getUST)( & ust );
+       (*psp->systemTime->getUST)( & ust );
        if ( missed_target ) {
           rmesa->swap_missed_count++;
           rmesa->swap_missed_ust = ust - rmesa->swap_ust;
@@ -513,11 +516,12 @@ void r200CopyBuffer( const __DRIdrawablePrivate *dPriv,
    }
 }
 
-void r200PageFlip( const __DRIdrawablePrivate *dPriv )
+void r200PageFlip( __DRIdrawablePrivate *dPriv )
 {
    r200ContextPtr rmesa;
    GLint ret;
    GLboolean   missed_target;
+   __DRIscreenPrivate *psp = dPriv->driScreenPriv;
 
    assert(dPriv);
    assert(dPriv->driContextPriv);
@@ -553,10 +557,10 @@ void r200PageFlip( const __DRIdrawablePrivate *dPriv )
     */
    r200WaitForFrameCompletion( rmesa );
    UNLOCK_HARDWARE( rmesa );
-   driWaitForVBlank( dPriv, & rmesa->vbl_seq, rmesa->vblank_flags, & missed_target );
+   driWaitForVBlank( dPriv, & missed_target );
    if ( missed_target ) {
       rmesa->swap_missed_count++;
-      (void) (*dri_interface->getUST)( & rmesa->swap_missed_ust );
+      (void) (*psp->systemTime->getUST)( & rmesa->swap_missed_ust );
    }
    LOCK_HARDWARE( rmesa );
 
@@ -570,7 +574,7 @@ void r200PageFlip( const __DRIdrawablePrivate *dPriv )
    }
 
    rmesa->swap_count++;
-   (void) (*dri_interface->getUST)( & rmesa->swap_ust );
+   (void) (*psp->systemTime->getUST)( & rmesa->swap_ust );
 
 #if 000
    if ( rmesa->sarea->pfCurrentPage == 1 ) {
@@ -857,7 +861,7 @@ void r200Finish( GLcontext *ctx )
  * the kernel data structures, and the current context to get the
  * device fd.
  */
-void *r200AllocateMemoryMESA(__DRInativeDisplay *dpy, int scrn, GLsizei size,
+void *r200AllocateMemoryMESA(__DRIscreen *screen, GLsizei size,
                             GLfloat readfreq, GLfloat writefreq, 
                             GLfloat priority)
 {
@@ -899,7 +903,7 @@ void *r200AllocateMemoryMESA(__DRInativeDisplay *dpy, int scrn, GLsizei size,
 
 
 /* Called via glXFreeMemoryMESA() */
-void r200FreeMemoryMESA(__DRInativeDisplay *dpy, int scrn, GLvoid *pointer)
+void r200FreeMemoryMESA(__DRIscreen *screen, GLvoid *pointer)
 {
    GET_CURRENT_CONTEXT(ctx);
    r200ContextPtr rmesa;
@@ -936,7 +940,7 @@ void r200FreeMemoryMESA(__DRInativeDisplay *dpy, int scrn, GLvoid *pointer)
 }
 
 /* Called via glXGetMemoryOffsetMESA() */
-GLuint r200GetMemoryOffsetMESA(__DRInativeDisplay *dpy, int scrn, const GLvoid *pointer)
+GLuint r200GetMemoryOffsetMESA(__DRIscreen *screen, const GLvoid *pointer)
 {
    GET_CURRENT_CONTEXT(ctx);
    r200ContextPtr rmesa;
index 5ed1555f6a324a11378216ec974a66b75929ff43..31431b7b03dd81ff62d8983d6bced592c421ee5e 100644 (file)
@@ -89,19 +89,19 @@ extern void r200ReleaseDmaRegion( r200ContextPtr rmesa,
                                    struct r200_dma_region *region,
                                    const char *caller );
 
-extern void r200CopyBuffer( const __DRIdrawablePrivate *drawable,
+extern void r200CopyBuffer( __DRIdrawablePrivate *drawable,
                            const drm_clip_rect_t      *rect);
-extern void r200PageFlip( const __DRIdrawablePrivate *drawable );
+extern void r200PageFlip( __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,
+extern void *r200AllocateMemoryMESA( __DRIscreen *screen, 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 void r200FreeMemoryMESA( __DRIscreen *screen, GLvoid *pointer );
+extern GLuint r200GetMemoryOffsetMESA( __DRIscreen *screen, const GLvoid *pointer );
 
 extern GLboolean r200IsGartMemory( r200ContextPtr rmesa, const GLvoid *pointer,
                                   GLint size );
@@ -137,7 +137,7 @@ do {                                                                \
    memcpy( rmesa->hw.ATOM.lastcmd, rmesa->hw.ATOM.cmd, \
           rmesa->hw.ATOM.cmd_size * 4)
 
-static __inline int R200_DB_STATECHANGE( 
+static INLINE int R200_DB_STATECHANGE( 
    r200ContextPtr rmesa,
    struct r200_state_atom *atom )
 {
@@ -183,7 +183,7 @@ do {                                                        \
  * 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 )
+static INLINE void r200EnsureCmdBufSpace( r200ContextPtr rmesa, int bytes )
 {
    if (rmesa->store.cmd_used + bytes > R200_CMD_BUF_SZ)
       r200FlushCmdBuf( rmesa, __FUNCTION__ );
@@ -192,7 +192,7 @@ static __inline void r200EnsureCmdBufSpace( r200ContextPtr rmesa, int bytes )
 
 /* Alloc space in the command buffer
  */
-static __inline char *r200AllocCmdBuf( r200ContextPtr rmesa,
+static INLINE char *r200AllocCmdBuf( r200ContextPtr rmesa,
                                         int bytes, const char *where )
 {
    char * head;
index 2f5aab0744b2be72a1c829240eae19ead412984c..46d230767a117355d60671d0c7ff3e9d418a3607 100644 (file)
@@ -294,7 +294,7 @@ static void do_draw_pix( GLcontext *ctx,
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
    __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
    drm_clip_rect_t *box = dPriv->pClipRects;
-   struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorDrawBuffers[0][0];
+   struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorDrawBuffers[0];
    driRenderbuffer *drb = (driRenderbuffer *) rb;
    int nbox = dPriv->numClipRects;
    int i;
@@ -382,13 +382,13 @@ r200TryDrawPixels( GLcontext *ctx,
    GLint pitch = unpack->RowLength ? unpack->RowLength : width;
    GLuint planemask;
    GLuint cpp = rmesa->r200Screen->cpp;
-   GLint size = width * pitch * cpp;
+   GLint size = height * pitch * cpp;
 
    if (R200_DEBUG & DEBUG_PIXEL)
       fprintf(stderr, "%s\n", __FUNCTION__);
 
    /* check that we're drawing to exactly one color buffer */
-   if (ctx->DrawBuffer->_NumColorDrawBuffers[0] != 1)
+   if (ctx->DrawBuffer->_NumColorDrawBuffers != 1)
      return GL_FALSE;
 
    switch (format) {
index fe427bdcdecb383365bc4cecb0712bde5f5f5b57..3d7a0002180c94c9766b5bb6de8812111ab7b2c3 100644 (file)
@@ -172,6 +172,7 @@ r200_mba_z16( driRenderbuffer *drb, GLint x, GLint y )
 
 /* 16-bit depth buffer functions
  */
+#define VALUE_TYPE GLushort
 
 #define WRITE_DEPTH( _x, _y, d )                                       \
    *(GLushort *)(buf + r200_mba_z16( drb, _x + xo, _y + yo )) = d;
@@ -185,6 +186,7 @@ r200_mba_z16( driRenderbuffer *drb, GLint x, GLint y )
 
 /* 24 bit depth, 8 bit stencil depthbuffer functions
  */
+#define VALUE_TYPE GLuint
 
 #define WRITE_DEPTH( _x, _y, d )                                       \
 do {                                                                   \
@@ -255,7 +257,7 @@ static void r200SpanRenderStart( GLcontext *ctx )
    {
       int p;
       driRenderbuffer *drb =
-        (driRenderbuffer *) ctx->WinSysDrawBuffer->_ColorDrawBuffers[0][0];
+        (driRenderbuffer *) ctx->WinSysDrawBuffer->_ColorDrawBuffers[0];
       volatile int *buf =
         (volatile int *)(rmesa->dri.screen->pFB + drb->offset);
       p = *buf;
index e9d2d9a3cd189df5aca23ca92c1f2bcb22c18950..ade26c2d2166fd446798118a7b1883ba3c22656f 100644 (file)
@@ -1859,8 +1859,7 @@ void r200SetCliprects( r200ContextPtr rmesa )
    GLframebuffer *const draw_fb = (GLframebuffer*) drawable->driverPrivate;
    GLframebuffer *const read_fb = (GLframebuffer*) readable->driverPrivate;
 
-   if (draw_fb->_ColorDrawBufferMask[0]
-       == BUFFER_BIT_BACK_LEFT) {
+   if (draw_fb->_ColorDrawBufferIndexes[0] == BUFFER_BIT_BACK_LEFT) {
       /* Can't ignore 2d windows if we are page flipping.
        */
       if ( drawable->numBackClipRects == 0 || rmesa->doPageFlip ) {
@@ -1910,17 +1909,18 @@ static void r200DrawBuffer( GLcontext *ctx, GLenum mode )
 
    R200_FIREVERTICES(rmesa);   /* don't pipeline cliprect changes */
 
-   /*
-    * _ColorDrawBufferMask is easier to cope with than <mode>.
-    * Check for software fallback, update cliprects.
-    */
-   switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
-   case BUFFER_BIT_FRONT_LEFT:
-   case BUFFER_BIT_BACK_LEFT:
+   if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) {
+      /* 0 (GL_NONE) buffers or multiple color drawing buffers */
+      FALLBACK( rmesa, R200_FALLBACK_DRAW_BUFFER, GL_TRUE );
+      return;
+   }
+
+   switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) {
+   case BUFFER_FRONT_LEFT:
+   case BUFFER_BACK_LEFT:
       FALLBACK( rmesa, R200_FALLBACK_DRAW_BUFFER, GL_FALSE );
       break;
    default:
-      /* 0 (GL_NONE) buffers or multiple color drawing buffers */
       FALLBACK( rmesa, R200_FALLBACK_DRAW_BUFFER, GL_TRUE );
       return;
    }
@@ -2445,11 +2445,11 @@ r200UpdateDrawBuffer(GLcontext *ctx)
    struct gl_framebuffer *fb = ctx->DrawBuffer;
    driRenderbuffer *drb;
 
-   if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT) {
+   if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) {
       /* draw to front */
       drb = (driRenderbuffer *) fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
    }
-   else if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT) {
+   else if (fb->_ColorDrawBufferIndexes[0] == BUFFER_BACK_LEFT) {
       /* draw to back */
       drb = (driRenderbuffer *) fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer;
    }
index 2ad35d4390647ca8ea62e978bc88bc7080c81a5a..78347d3cc28d0aa0b1dfb4e864c13abdc6be1d34 100644 (file)
@@ -488,7 +488,7 @@ static GLboolean r200_run_tcl_render( GLcontext *ctx,
 
    for (i = 0 ; i < VB->PrimitiveCount ; i++)
    {
-      GLuint prim = VB->Primitive[i].mode;
+      GLuint prim = _tnl_translate_prim(&VB->Primitive[i]);
       GLuint start = VB->Primitive[i].start;
       GLuint length = VB->Primitive[i].count;
 
index e7a37dd4c99d4d682b24397b30f306b65996aa4a..24b9b3b696fe0ccdb1ce6c90a5e52cb70a9e2fc6 100644 (file)
@@ -102,37 +102,39 @@ static void r200SetTexWrap( r200TexObjPtr t, GLenum swrap, GLenum twrap, GLenum
       _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;
-      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__);
+   if (t->base.tObj->Target != GL_TEXTURE_1D) {
+      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;
+         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;
index e6c0e00eb073fb0c9148ef8186af6775afe3968d..10ff8e8a6604d9b03c01d6316e80ca9227d6fd05 100644 (file)
@@ -35,6 +35,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #ifndef __R200_TEX_H__
 #define __R200_TEX_H__
 
+extern void r200SetTexOffset(__DRIcontext *pDRICtx, GLint texname,
+                            unsigned long long offset, GLint depth,
+                            GLuint pitch);
+
 extern void r200UpdateTextureState( GLcontext *ctx );
 
 extern int r200UploadTexImages( r200ContextPtr rmesa, r200TexObjPtr t, GLuint face );
index d926313d576c164d80ecf6290660a4415663dd19..183c4ca424be982bd51f8685dd723a7145efe868 100644 (file)
@@ -181,7 +181,8 @@ static void r200UploadRectSubImage( r200ContextPtr rmesa,
       /* In this case, could also use GART texturing.  This is
        * currently disabled, but has been tested & works.
        */
-      t->pp_txoffset = r200GartOffsetFromVirtual( rmesa, texImage->Data );
+      if ( !t->image_override )
+         t->pp_txoffset = r200GartOffsetFromVirtual( rmesa, texImage->Data );
       t->pp_txpitch = texImage->RowStride * texFormat->TexelBytes - 32;
 
       if (R200_DEBUG & DEBUG_TEXTURE)
@@ -467,7 +468,7 @@ int r200UploadTexImages( r200ContextPtr rmesa, r200TexObjPtr t, GLuint face )
               t->base.firstLevel, t->base.lastLevel );
    }
 
-   if ( !t || t->base.totalSize == 0 )
+   if ( !t || t->base.totalSize == 0 || t->image_override )
       return 0;
 
    if (R200_DEBUG & DEBUG_SYNC) {
index ae02ec4b6383ba957300871aff6f0b868ada8d56..4edf3044388b6ae99fe19a7faa9872e764248678 100644 (file)
@@ -37,6 +37,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "context.h"
 #include "macros.h"
 #include "texformat.h"
+#include "texobj.h"
 #include "enums.h"
 
 #include "r200_context.h"
@@ -70,12 +71,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define _INVALID(f) \
     [ MESA_FORMAT_ ## f ] = { 0xffffffff, 0 }
 #define VALID_FORMAT(f) ( ((f) <= MESA_FORMAT_RGBA_DXT5) \
-                            && (tx_table_le[f].format != 0xffffffff) )
+                            && (tx_table_be[f].format != 0xffffffff) )
 
-static const struct {
+struct tx_table {
    GLuint format, filter;
-}
-tx_table_be[] =
+};
+
+static const struct tx_table tx_table_be[] =
 {
    [ MESA_FORMAT_RGBA8888 ] = { R200_TXFORMAT_ABGR8888 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
    _ALPHA_REV(RGBA8888),
@@ -104,16 +106,13 @@ tx_table_be[] =
    _ALPHA(RGBA_DXT5),
 };
 
-static const struct {
-   GLuint format, filter;
-}
-tx_table_le[] =
+static const struct tx_table tx_table_le[] =
 {
    _ALPHA(RGBA8888),
    [ MESA_FORMAT_RGBA8888_REV ] = { R200_TXFORMAT_ABGR8888 | R200_TXFORMAT_ALPHA_IN_MAP, 0 },
    _ALPHA(ARGB8888),
    _ALPHA_REV(ARGB8888),
-   _INVALID(RGB888),
+   [ MESA_FORMAT_RGB888 ] = { R200_TXFORMAT_ARGB8888, 0 },
    _COLOR(RGB565),
    _COLOR_REV(RGB565),
    _ALPHA(ARGB4444),
@@ -160,30 +159,26 @@ static void r200SetTexImages( r200ContextPtr rmesa,
    GLint i, texelBytes;
    GLint numLevels;
    GLint log2Width, log2Height, log2Depth;
-   const GLuint ui = 1;
-   const GLubyte littleEndian = *((const GLubyte *) &ui);
 
    /* Set the hardware texture format
     */
+   if ( !t->image_override ) {
+      if ( VALID_FORMAT( baseImage->TexFormat->MesaFormat ) ) {
+        const struct tx_table *table = _mesa_little_endian() ? tx_table_le :
+                                                               tx_table_be;
 
-   t->pp_txformat &= ~(R200_TXFORMAT_FORMAT_MASK |
-                      R200_TXFORMAT_ALPHA_IN_MAP);
-   t->pp_txfilter &= ~R200_YUV_TO_RGB;
+         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 ) ) {
-      if (littleEndian) {
-        t->pp_txformat |= tx_table_le[ baseImage->TexFormat->MesaFormat ].format;
-        t->pp_txfilter |= tx_table_le[ baseImage->TexFormat->MesaFormat ].filter;
+        t->pp_txformat |= table[ baseImage->TexFormat->MesaFormat ].format;
+        t->pp_txfilter |= table[ baseImage->TexFormat->MesaFormat ].filter;
       }
       else {
-        t->pp_txformat |= tx_table_be[ baseImage->TexFormat->MesaFormat ].format;
-        t->pp_txfilter |= tx_table_be[ baseImage->TexFormat->MesaFormat ].filter;
+         _mesa_problem(NULL, "unexpected texture format in %s", __FUNCTION__);
+         return;
       }
    }
-   else {
-      _mesa_problem(NULL, "unexpected texture format in %s", __FUNCTION__);
-      return;
-   }
 
    texelBytes = baseImage->TexFormat->TexelBytes;
 
@@ -380,11 +375,13 @@ static void r200SetTexImages( r200ContextPtr rmesa,
     * 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;
+   if ( !t->image_override ) {
+      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;
 
@@ -979,6 +976,44 @@ static GLboolean r200UpdateTextureEnv( GLcontext *ctx, int unit, int slot, GLuin
    return GL_TRUE;
 }
 
+void r200SetTexOffset(__DRIcontext * pDRICtx, GLint texname,
+                     unsigned long long offset, GLint depth, GLuint pitch)
+{
+       r200ContextPtr rmesa = pDRICtx->driverPrivate;
+       struct gl_texture_object *tObj =
+           _mesa_lookup_texture(rmesa->glCtx, texname);
+       r200TexObjPtr t;
+
+       if (!tObj)
+               return;
+
+       t = (r200TexObjPtr) tObj->DriverData;
+
+       t->image_override = GL_TRUE;
+
+       if (!offset)
+               return;
+
+       t->pp_txoffset = offset;
+       t->pp_txpitch = pitch - 32;
+
+       switch (depth) {
+       case 32:
+               t->pp_txformat = tx_table_le[MESA_FORMAT_ARGB8888].format;
+               t->pp_txfilter |= tx_table_le[MESA_FORMAT_ARGB8888].filter;
+               break;
+       case 24:
+       default:
+               t->pp_txformat = tx_table_le[MESA_FORMAT_RGB888].format;
+               t->pp_txfilter |= tx_table_le[MESA_FORMAT_RGB888].filter;
+               break;
+       case 16:
+               t->pp_txformat = tx_table_le[MESA_FORMAT_RGB565].format;
+               t->pp_txfilter |= tx_table_le[MESA_FORMAT_RGB565].filter;
+               break;
+       }
+}
+
 #define REF_COLOR 1
 #define REF_ALPHA 2
 
@@ -1560,7 +1595,7 @@ static GLboolean enable_tex_2d( GLcontext *ctx, int unit )
       R200_FIREVERTICES( rmesa );
       r200SetTexImages( rmesa, tObj );
       r200UploadTexImages( rmesa, (r200TexObjPtr) tObj->DriverData, 0 );
-      if ( !t->base.memBlock ) 
+      if ( !t->base.memBlock && !t->image_override 
         return GL_FALSE;
    }
 
@@ -1668,7 +1703,9 @@ static GLboolean enable_tex_rect( GLcontext *ctx, int unit )
       R200_FIREVERTICES( rmesa );
       r200SetTexImages( rmesa, tObj );
       r200UploadTexImages( rmesa, (r200TexObjPtr) tObj->DriverData, 0 );
-      if ( !t->base.memBlock && !rmesa->prefer_gart_client_texturing ) 
+      if ( !t->base.memBlock &&
+           !t->image_override &&
+           !rmesa->prefer_gart_client_texturing ) 
         return GL_FALSE;
    }
 
@@ -1778,6 +1815,12 @@ void r200UpdateTextureState( GLcontext *ctx )
    GLboolean ok;
    GLuint dbg;
 
+   /* NOTE: must not manipulate rmesa->state.texture.unit[].unitneeded or
+      rmesa->state.envneeded before a R200_STATECHANGE (or R200_NEWPRIM) since
+      we use these to determine if we want to emit the corresponding state
+      atoms. */
+   R200_NEWPRIM( rmesa );
+
    if (ctx->ATIFragmentShader._Enabled) {
       GLuint i;
       for (i = 0; i < R200_MAX_TEXTURE_UNITS; i++) {
index 6089d617c6b68cca15fa91487d740962a670a7d4..562992fbb5c4688344e351f0c22e8675b582a66b 100644 (file)
@@ -30,10 +30,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  *   Aapo Tahkola <aet@rasterburn.org>
  *   Roland Scheidegger <rscheidegger_lists@hispeed.ch>
  */
-#include "glheader.h"
-#include "macros.h"
-#include "enums.h"
-#include "program.h"
+#include "main/glheader.h"
+#include "main/macros.h"
+#include "main/enums.h"
+#include "shader/program.h"
 #include "shader/prog_instruction.h"
 #include "shader/prog_parameter.h"
 #include "shader/prog_statevars.h"
@@ -154,7 +154,7 @@ static GLboolean r200VertexProgUpdateParams(GLcontext *ctx, struct r200_vertex_p
    return GL_TRUE;
 }
 
-static __inline unsigned long t_dst_mask(GLuint mask)
+static INLINE unsigned long t_dst_mask(GLuint mask)
 {
    /* WRITEMASK_* is equivalent to VSF_FLAG_* */
    return mask & VSF_FLAG_ALL;
@@ -215,6 +215,7 @@ static unsigned long t_src_class(enum register_file file)
    case PROGRAM_LOCAL_PARAM:
    case PROGRAM_ENV_PARAM:
    case PROGRAM_NAMED_PARAM:
+   case PROGRAM_CONSTANT:
    case PROGRAM_STATE_VAR:
       return VSF_IN_CLASS_PARAM;
    /*
@@ -228,7 +229,7 @@ static unsigned long t_src_class(enum register_file file)
    }
 }
 
-static __inline unsigned long t_swizzle(GLubyte swizzle)
+static INLINE unsigned long t_swizzle(GLubyte swizzle)
 {
 /* this is in fact a NOP as the Mesa SWIZZLE_* are all identical to VSF_IN_COMPONENT_* */
    return swizzle;
@@ -408,6 +409,7 @@ static GLboolean r200_translate_vertex_program(GLcontext *ctx, struct r200_verte
    int fog_temp_i = 0;
    int free_inputs;
    int array_count = 0;
+   int u_temp_used;
 
    vp->native = GL_FALSE;
    vp->translated = GL_TRUE;
@@ -744,9 +746,16 @@ static GLboolean r200_translate_vertex_program(GLcontext *ctx, struct r200_verte
         goto next;
 
       case OPCODE_MAD:
+        /* only 2 read ports into temp memory thus may need the macro op MAD_2
+           instead (requiring 2 clocks) if all inputs are in temp memory
+           (and, only if they actually reference 3 distinct temps) */
         hw_op=(src[0].File == PROGRAM_TEMPORARY &&
            src[1].File == PROGRAM_TEMPORARY &&
-           src[2].File == PROGRAM_TEMPORARY) ? R200_VPI_OUT_OP_MAD_2 : R200_VPI_OUT_OP_MAD;
+           src[2].File == PROGRAM_TEMPORARY &&
+           (((src[0].RelAddr << 8) | src[0].Index) != ((src[1].RelAddr << 8) | src[1].Index)) &&
+           (((src[0].RelAddr << 8) | src[0].Index) != ((src[2].RelAddr << 8) | src[2].Index)) &&
+           (((src[1].RelAddr << 8) | src[1].Index) != ((src[2].RelAddr << 8) | src[2].Index))) ?
+           R200_VPI_OUT_OP_MAD_2 : R200_VPI_OUT_OP_MAD;
 
         o_inst->op = MAKE_VSF_OP(hw_op, t_dst(&dst),
            t_dst_mask(dst.WriteMask));
@@ -874,8 +883,11 @@ else {
       case OPCODE_XPD:
         /* mul r0, r1.yzxw, r2.zxyw
            mad r0, -r2.yzxw, r1.zxyw, r0
-           NOTE: might need MAD_2
          */
+        hw_op=(src[0].File == PROGRAM_TEMPORARY &&
+           src[1].File == PROGRAM_TEMPORARY &&
+           (((src[0].RelAddr << 8) | src[0].Index) != ((src[1].RelAddr << 8) | src[1].Index))) ?
+           R200_VPI_OUT_OP_MAD_2 : R200_VPI_OUT_OP_MAD;
 
         o_inst->op = MAKE_VSF_OP(R200_VPI_OUT_OP_MUL,
            (u_temp_i << R200_VPI_OUT_REG_INDEX_SHIFT) | R200_VSF_OUT_CLASS_TMP,
@@ -901,7 +913,7 @@ else {
         o_inst++;
         u_temp_i--;
 
-        o_inst->op = MAKE_VSF_OP(R200_VPI_OUT_OP_MAD, t_dst(&dst),
+        o_inst->op = MAKE_VSF_OP(hw_op, t_dst(&dst),
                t_dst_mask(dst.WriteMask));
 
         o_inst->src0 = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
@@ -1051,14 +1063,15 @@ else {
          dofogfix = 0;
       }
 
+      u_temp_used = (R200_VSF_MAX_TEMPS - 1) - u_temp_i;
       if (mesa_vp->Base.NumNativeTemporaries <
-        (mesa_vp->Base.NumTemporaries + (R200_VSF_MAX_TEMPS - 1 - u_temp_i))) {
+        (mesa_vp->Base.NumTemporaries + u_temp_used)) {
         mesa_vp->Base.NumNativeTemporaries =
-           mesa_vp->Base.NumTemporaries + (R200_VSF_MAX_TEMPS - 1 - u_temp_i);
+           mesa_vp->Base.NumTemporaries + u_temp_used;
       }
-      if (u_temp_i < mesa_vp->Base.NumTemporaries) {
+      if ((mesa_vp->Base.NumTemporaries + u_temp_used) > R200_VSF_MAX_TEMPS) {
         if (R200_DEBUG & DEBUG_FALLBACKS) {
-           fprintf(stderr, "Ran out of temps, num temps %d, us %d\n", mesa_vp->Base.NumTemporaries, u_temp_i);
+           fprintf(stderr, "Ran out of temps, num temps %d, us %d\n", mesa_vp->Base.NumTemporaries, u_temp_used);
         }
         return GL_FALSE;
       }
index 44248964fdb7d889b1f3528c1b7aad8c046b97f1..6ca934204f38c6d7f4ec53b19328b145d9f558e2 100644 (file)
@@ -28,7 +28,6 @@ DRIVER_SOURCES = \
                 radeon_span.c \
                 radeon_state.c \
                 r300_mem.c \
-                \
                 r300_context.c \
                 r300_ioctl.c \
                 r300_cmdbuf.c \
@@ -37,8 +36,16 @@ DRIVER_SOURCES = \
                 r300_texmem.c \
                 r300_tex.c \
                 r300_texstate.c \
+                radeon_program.c \
+                radeon_program_alu.c \
+                radeon_program_pair.c \
+                radeon_nqssadce.c \
                 r300_vertprog.c \
                 r300_fragprog.c \
+                r300_fragprog_swizzle.c \
+                r300_fragprog_emit.c \
+                r500_fragprog.c \
+                r500_fragprog_emit.c \
                 r300_shader.c \
                 r300_emit.c \
                 r300_swtcl.c \
index 9eca41fa38cdf686e91ccb770267c9d7e94882e5..c069660eeafb257c83f7f909f8025fca83618535 100644 (file)
@@ -150,7 +150,7 @@ static void r300PrintStateAtom(r300ContextPtr r300, struct r300_state_atom *stat
  * The caller must have ensured that there is enough space in the command
  * buffer.
  */
-static inline void r300EmitAtoms(r300ContextPtr r300, GLboolean dirty)
+static INLINE void r300EmitAtoms(r300ContextPtr r300, GLboolean dirty)
 {
        struct r300_state_atom *atom;
        uint32_t *dest;
@@ -164,7 +164,7 @@ static inline void r300EmitAtoms(r300ContextPtr r300, GLboolean dirty)
        r300->cmdbuf.count_used++;
 
        /* Emit cache flush */
-       *dest = cmdpacket0(R300_TX_CNTL, 1);
+       *dest = cmdpacket0(R300_TX_INVALTAGS, 1);
        dest++;
        r300->cmdbuf.count_used++;
 
@@ -242,6 +242,7 @@ void r300EmitState(r300ContextPtr r300)
 
 #define packet0_count(ptr) (((drm_r300_cmd_header_t*)(ptr))->packet0.count)
 #define vpu_count(ptr) (((drm_r300_cmd_header_t*)(ptr))->vpu.count)
+#define r500fp_count(ptr) (((drm_r300_cmd_header_t*)(ptr))->r500fp.count)
 
 static int check_always(r300ContextPtr r300, struct r300_state_atom *atom)
 {
@@ -262,6 +263,20 @@ static int check_vpu(r300ContextPtr r300, struct r300_state_atom *atom)
        return cnt ? (cnt * 4) + 1 : 0;
 }
 
+static int check_r500fp(r300ContextPtr r300, struct r300_state_atom *atom)
+{
+       int cnt;
+       cnt = r500fp_count(atom->cmd);
+       return cnt ? (cnt * 6) + 1 : 0;
+}
+
+static int check_r500fp_const(r300ContextPtr r300, struct r300_state_atom *atom)
+{
+       int cnt;
+       cnt = r500fp_count(atom->cmd);
+       return cnt ? (cnt * 4) + 1 : 0;
+}
+
 #define ALLOC_STATE( ATOM, CHK, SZ, IDX )                              \
    do {                                                                        \
       r300->hw.ATOM.cmd_size = (SZ);                                   \
@@ -281,10 +296,15 @@ void r300InitCmdBuf(r300ContextPtr r300)
 {
        int size, mtu;
        int has_tcl = 1;
+       int is_r500 = 0;
+       int i;
 
        if (!(r300->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL))
                has_tcl = 0;
 
+       if (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515)
+               is_r500 = 1;
+
        r300->hw.max_state_size = 2 + 2;        /* reserve extra space for WAIT_IDLE and tex cache flush */
 
        mtu = r300->radeon.glCtx->Const.MaxTextureUnits;
@@ -299,32 +319,39 @@ void r300InitCmdBuf(r300ContextPtr r300)
        /* Initialize state atoms */
        ALLOC_STATE(vpt, always, R300_VPT_CMDSIZE, 0);
        r300->hw.vpt.cmd[R300_VPT_CMD_0] = cmdpacket0(R300_SE_VPORT_XSCALE, 6);
-       ALLOC_STATE(vap_cntl, always, 2, 0);
-       r300->hw.vap_cntl.cmd[0] = cmdpacket0(R300_VAP_CNTL, 1);
+       ALLOC_STATE(vap_cntl, always, R300_VAP_CNTL_SIZE, 0);
+       r300->hw.vap_cntl.cmd[R300_VAP_CNTL_FLUSH] = cmdpacket0(R300_VAP_PVS_STATE_FLUSH_REG, 1);
+       r300->hw.vap_cntl.cmd[R300_VAP_CNTL_FLUSH_1] = 0;
+       r300->hw.vap_cntl.cmd[R300_VAP_CNTL_CMD] = cmdpacket0(R300_VAP_CNTL, 1);
+       if (is_r500) {
+           ALLOC_STATE(vap_index_offset, always, 2, 0);
+           r300->hw.vap_index_offset.cmd[0] = cmdpacket0(R500_VAP_INDEX_OFFSET, 1);
+           r300->hw.vap_index_offset.cmd[1] = 0;
+       }
        ALLOC_STATE(vte, always, 3, 0);
        r300->hw.vte.cmd[0] = cmdpacket0(R300_SE_VTE_CNTL, 2);
-       ALLOC_STATE(unk2134, always, 3, 0);
-       r300->hw.unk2134.cmd[0] = cmdpacket0(0x2134, 2);
+       ALLOC_STATE(vap_vf_max_vtx_indx, always, 3, 0);
+       r300->hw.vap_vf_max_vtx_indx.cmd[0] = cmdpacket0(R300_VAP_VF_MAX_VTX_INDX, 2);
        ALLOC_STATE(vap_cntl_status, always, 2, 0);
        r300->hw.vap_cntl_status.cmd[0] = cmdpacket0(R300_VAP_CNTL_STATUS, 1);
        ALLOC_STATE(vir[0], variable, R300_VIR_CMDSIZE, 0);
        r300->hw.vir[0].cmd[R300_VIR_CMD_0] =
-           cmdpacket0(R300_VAP_INPUT_ROUTE_0_0, 1);
+           cmdpacket0(R300_VAP_PROG_STREAM_CNTL_0, 1);
        ALLOC_STATE(vir[1], variable, R300_VIR_CMDSIZE, 1);
        r300->hw.vir[1].cmd[R300_VIR_CMD_0] =
-           cmdpacket0(R300_VAP_INPUT_ROUTE_1_0, 1);
+           cmdpacket0(R300_VAP_PROG_STREAM_CNTL_EXT_0, 1);
        ALLOC_STATE(vic, always, R300_VIC_CMDSIZE, 0);
-       r300->hw.vic.cmd[R300_VIC_CMD_0] = cmdpacket0(R300_VAP_INPUT_CNTL_0, 2);
-       ALLOC_STATE(unk21DC, always, 2, 0);
-       r300->hw.unk21DC.cmd[0] = cmdpacket0(0x21DC, 1);
-       ALLOC_STATE(unk221C, always, 2, 0);
-       r300->hw.unk221C.cmd[0] = cmdpacket0(R300_VAP_UNKNOWN_221C, 1);
-       ALLOC_STATE(vap_clip, always, 5, 0);
-       r300->hw.vap_clip.cmd[0] = cmdpacket0(R300_VAP_CLIP_X_0, 4);
+       r300->hw.vic.cmd[R300_VIC_CMD_0] = cmdpacket0(R300_VAP_VTX_STATE_CNTL, 2);
+       ALLOC_STATE(vap_psc_sgn_norm_cntl, always, 2, 0);
+       r300->hw.vap_psc_sgn_norm_cntl.cmd[0] = cmdpacket0(R300_VAP_PSC_SGN_NORM_CNTL, SGN_NORM_ZERO_CLAMP_MINUS_ONE);
 
        if (has_tcl) {
-               ALLOC_STATE(unk2288, always, 2, 0);
-               r300->hw.unk2288.cmd[0] = cmdpacket0(R300_VAP_UNKNOWN_2288, 1);
+               ALLOC_STATE(vap_clip_cntl, always, 2, 0);
+               r300->hw.vap_clip_cntl.cmd[0] = cmdpacket0(R300_VAP_CLIP_CNTL, 1);
+               ALLOC_STATE(vap_clip, always, 5, 0);
+               r300->hw.vap_clip.cmd[0] = cmdpacket0(R300_VAP_GB_VERT_CLIP_ADJ, 4);
+               ALLOC_STATE(vap_pvs_vtx_timeout_reg, always, 2, 0);
+               r300->hw.vap_pvs_vtx_timeout_reg.cmd[0] = cmdpacket0(VAP_PVS_VTX_TIMEOUT_REG, 1);
        }
 
        ALLOC_STATE(vof, always, R300_VOF_CMDSIZE, 0);
@@ -334,7 +361,7 @@ void r300InitCmdBuf(r300ContextPtr r300)
        if (has_tcl) {
                ALLOC_STATE(pvs, always, R300_PVS_CMDSIZE, 0);
                r300->hw.pvs.cmd[R300_PVS_CMD_0] =
-                   cmdpacket0(R300_VAP_PVS_CNTL_1, 3);
+                   cmdpacket0(R300_VAP_PVS_CODE_CNTL_0, 3);
        }
 
        ALLOC_STATE(gb_enable, always, 2, 0);
@@ -343,121 +370,183 @@ void r300InitCmdBuf(r300ContextPtr r300)
        r300->hw.gb_misc.cmd[0] = cmdpacket0(R300_GB_MSPOS0, 5);
        ALLOC_STATE(txe, always, R300_TXE_CMDSIZE, 0);
        r300->hw.txe.cmd[R300_TXE_CMD_0] = cmdpacket0(R300_TX_ENABLE, 1);
-       ALLOC_STATE(unk4200, always, 5, 0);
-       r300->hw.unk4200.cmd[0] = cmdpacket0(0x4200, 4);
-       ALLOC_STATE(unk4214, always, 2, 0);
-       r300->hw.unk4214.cmd[0] = cmdpacket0(0x4214, 1);
+       ALLOC_STATE(ga_point_s0, always, 5, 0);
+       r300->hw.ga_point_s0.cmd[0] = cmdpacket0(R300_GA_POINT_S0, 4);
+       ALLOC_STATE(ga_triangle_stipple, always, 2, 0);
+       r300->hw.ga_triangle_stipple.cmd[0] = cmdpacket0(R300_GA_TRIANGLE_STIPPLE, 1);
        ALLOC_STATE(ps, always, R300_PS_CMDSIZE, 0);
-       r300->hw.ps.cmd[0] = cmdpacket0(R300_RE_POINTSIZE, 1);
-       ALLOC_STATE(unk4230, always, 4, 0);
-       r300->hw.unk4230.cmd[0] = cmdpacket0(0x4230, 3);
+       r300->hw.ps.cmd[0] = cmdpacket0(R300_GA_POINT_SIZE, 1);
+       ALLOC_STATE(ga_point_minmax, always, 4, 0);
+       r300->hw.ga_point_minmax.cmd[0] = cmdpacket0(R300_GA_POINT_MINMAX, 3);
        ALLOC_STATE(lcntl, always, 2, 0);
-       r300->hw.lcntl.cmd[0] = cmdpacket0(R300_RE_LINE_CNT, 1);
-       ALLOC_STATE(unk4260, always, 4, 0);
-       r300->hw.unk4260.cmd[0] = cmdpacket0(0x4260, 3);
+       r300->hw.lcntl.cmd[0] = cmdpacket0(R300_GA_LINE_CNTL, 1);
+       ALLOC_STATE(ga_line_stipple, always, 4, 0);
+       r300->hw.ga_line_stipple.cmd[0] = cmdpacket0(R300_GA_LINE_STIPPLE_VALUE, 3);
        ALLOC_STATE(shade, always, 5, 0);
-       r300->hw.shade.cmd[0] = cmdpacket0(R300_RE_SHADE, 4);
+       r300->hw.shade.cmd[0] = cmdpacket0(R300_GA_ENHANCE, 4);
        ALLOC_STATE(polygon_mode, always, 4, 0);
-       r300->hw.polygon_mode.cmd[0] = cmdpacket0(R300_RE_POLYGON_MODE, 3);
+       r300->hw.polygon_mode.cmd[0] = cmdpacket0(R300_GA_POLY_MODE, 3);
        ALLOC_STATE(fogp, always, 3, 0);
-       r300->hw.fogp.cmd[0] = cmdpacket0(R300_RE_FOG_SCALE, 2);
+       r300->hw.fogp.cmd[0] = cmdpacket0(R300_GA_FOG_SCALE, 2);
        ALLOC_STATE(zbias_cntl, always, 2, 0);
-       r300->hw.zbias_cntl.cmd[0] = cmdpacket0(R300_RE_ZBIAS_CNTL, 1);
+       r300->hw.zbias_cntl.cmd[0] = cmdpacket0(R300_SU_TEX_WRAP, 1);
        ALLOC_STATE(zbs, always, R300_ZBS_CMDSIZE, 0);
        r300->hw.zbs.cmd[R300_ZBS_CMD_0] =
-           cmdpacket0(R300_RE_ZBIAS_T_FACTOR, 4);
+           cmdpacket0(R300_SU_POLY_OFFSET_FRONT_SCALE, 4);
        ALLOC_STATE(occlusion_cntl, always, 2, 0);
-       r300->hw.occlusion_cntl.cmd[0] = cmdpacket0(R300_RE_OCCLUSION_CNTL, 1);
+       r300->hw.occlusion_cntl.cmd[0] = cmdpacket0(R300_SU_POLY_OFFSET_ENABLE, 1);
        ALLOC_STATE(cul, always, R300_CUL_CMDSIZE, 0);
-       r300->hw.cul.cmd[R300_CUL_CMD_0] = cmdpacket0(R300_RE_CULL_CNTL, 1);
-       ALLOC_STATE(unk42C0, always, 3, 0);
-       r300->hw.unk42C0.cmd[0] = cmdpacket0(0x42C0, 2);
+       r300->hw.cul.cmd[R300_CUL_CMD_0] = cmdpacket0(R300_SU_CULL_MODE, 1);
+       ALLOC_STATE(su_depth_scale, always, 3, 0);
+       r300->hw.su_depth_scale.cmd[0] = cmdpacket0(R300_SU_DEPTH_SCALE, 2);
        ALLOC_STATE(rc, always, R300_RC_CMDSIZE, 0);
-       r300->hw.rc.cmd[R300_RC_CMD_0] = cmdpacket0(R300_RS_CNTL_0, 2);
-       ALLOC_STATE(ri, always, R300_RI_CMDSIZE, 0);
-       r300->hw.ri.cmd[R300_RI_CMD_0] = cmdpacket0(R300_RS_INTERP_0, 8);
-       ALLOC_STATE(rr, variable, R300_RR_CMDSIZE, 0);
-       r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(R300_RS_ROUTE_0, 1);
-       ALLOC_STATE(unk43A4, always, 3, 0);
-       r300->hw.unk43A4.cmd[0] = cmdpacket0(0x43A4, 2);
-       ALLOC_STATE(unk43E8, always, 2, 0);
-       r300->hw.unk43E8.cmd[0] = cmdpacket0(0x43E8, 1);
-       ALLOC_STATE(fp, always, R300_FP_CMDSIZE, 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, 0);
-       r300->hw.fpt.cmd[R300_FPT_CMD_0] = cmdpacket0(R300_PFS_TEXI_0, 0);
-       ALLOC_STATE(unk46A4, always, 6, 0);
-       r300->hw.unk46A4.cmd[0] = cmdpacket0(0x46A4, 5);
-       ALLOC_STATE(fpi[0], variable, R300_FPI_CMDSIZE, 0);
-       r300->hw.fpi[0].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR0_0, 1);
-       ALLOC_STATE(fpi[1], variable, R300_FPI_CMDSIZE, 1);
-       r300->hw.fpi[1].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR1_0, 1);
-       ALLOC_STATE(fpi[2], variable, R300_FPI_CMDSIZE, 2);
-       r300->hw.fpi[2].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR2_0, 1);
-       ALLOC_STATE(fpi[3], variable, R300_FPI_CMDSIZE, 3);
-       r300->hw.fpi[3].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR3_0, 1);
+       r300->hw.rc.cmd[R300_RC_CMD_0] = cmdpacket0(R300_RS_COUNT, 2);
+       if (is_r500) {
+               ALLOC_STATE(ri, always, R500_RI_CMDSIZE, 0);
+               r300->hw.ri.cmd[R300_RI_CMD_0] = cmdpacket0(R500_RS_IP_0, 16);
+               for (i = 0; i < 8; i++) {
+                       r300->hw.ri.cmd[R300_RI_CMD_0 + i +1] =
+                         (R500_RS_IP_PTR_K0 << R500_RS_IP_TEX_PTR_S_SHIFT) |
+                          (R500_RS_IP_PTR_K0 << R500_RS_IP_TEX_PTR_T_SHIFT) |
+                          (R500_RS_IP_PTR_K0 << R500_RS_IP_TEX_PTR_R_SHIFT) |
+                          (R500_RS_IP_PTR_K1 << R500_RS_IP_TEX_PTR_Q_SHIFT);
+               }
+               ALLOC_STATE(rr, variable, R300_RR_CMDSIZE, 0);
+               r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(R500_RS_INST_0, 1);
+       } else {
+               ALLOC_STATE(ri, always, R300_RI_CMDSIZE, 0);
+               r300->hw.ri.cmd[R300_RI_CMD_0] = cmdpacket0(R300_RS_IP_0, 8);
+               ALLOC_STATE(rr, variable, R300_RR_CMDSIZE, 0);
+               r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(R300_RS_INST_0, 1);
+       }
+       ALLOC_STATE(sc_hyperz, always, 3, 0);
+       r300->hw.sc_hyperz.cmd[0] = cmdpacket0(R300_SC_HYPERZ, 2);
+       ALLOC_STATE(sc_screendoor, always, 2, 0);
+       r300->hw.sc_screendoor.cmd[0] = cmdpacket0(R300_SC_SCREENDOOR, 1);
+       ALLOC_STATE(us_out_fmt, always, 6, 0);
+       r300->hw.us_out_fmt.cmd[0] = cmdpacket0(R300_US_OUT_FMT, 5);
+
+       if (is_r500) {
+               ALLOC_STATE(fp, always, R500_FP_CMDSIZE, 0);
+               r300->hw.fp.cmd[R500_FP_CMD_0] = cmdpacket0(R500_US_CONFIG, 2);
+               r300->hw.fp.cmd[R500_FP_CNTL] = R500_ZERO_TIMES_ANYTHING_EQUALS_ZERO;
+               r300->hw.fp.cmd[R500_FP_CMD_1] = cmdpacket0(R500_US_CODE_ADDR, 3);
+               r300->hw.fp.cmd[R500_FP_CMD_2] = cmdpacket0(R500_US_FC_CTRL, 1);
+               r300->hw.fp.cmd[R500_FP_FC_CNTL] = 0; /* FIXME when we add flow control */
+
+               ALLOC_STATE(r500fp, r500fp, R500_FPI_CMDSIZE, 0);
+               r300->hw.r500fp.cmd[R300_FPI_CMD_0] = cmdr500fp(0, 0, 0, 0);
+               ALLOC_STATE(r500fp_const, r500fp_const, R500_FPP_CMDSIZE, 0);
+               r300->hw.r500fp_const.cmd[R300_FPI_CMD_0] = cmdr500fp(0, 0, 1, 0);
+       } else {
+               ALLOC_STATE(fp, always, R300_FP_CMDSIZE, 0);
+               r300->hw.fp.cmd[R300_FP_CMD_0] = cmdpacket0(R300_US_CONFIG, 3);
+               r300->hw.fp.cmd[R300_FP_CMD_1] = cmdpacket0(R300_US_CODE_ADDR_0, 4);
+               ALLOC_STATE(fpt, variable, R300_FPT_CMDSIZE, 0);
+               r300->hw.fpt.cmd[R300_FPT_CMD_0] = cmdpacket0(R300_US_TEX_INST_0, 0);
+
+               ALLOC_STATE(fpi[0], variable, R300_FPI_CMDSIZE, 0);
+               r300->hw.fpi[0].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_US_ALU_RGB_INST_0, 1);
+               ALLOC_STATE(fpi[1], variable, R300_FPI_CMDSIZE, 1);
+               r300->hw.fpi[1].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_US_ALU_RGB_ADDR_0, 1);
+               ALLOC_STATE(fpi[2], variable, R300_FPI_CMDSIZE, 2);
+               r300->hw.fpi[2].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_US_ALU_ALPHA_INST_0, 1);
+               ALLOC_STATE(fpi[3], variable, R300_FPI_CMDSIZE, 3);
+               r300->hw.fpi[3].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_US_ALU_ALPHA_ADDR_0, 1);
+               ALLOC_STATE(fpp, variable, R300_FPP_CMDSIZE, 0);
+               r300->hw.fpp.cmd[R300_FPP_CMD_0] = cmdpacket0(R300_PFS_PARAM_0_X, 0);
+       }
        ALLOC_STATE(fogs, always, R300_FOGS_CMDSIZE, 0);
-       r300->hw.fogs.cmd[R300_FOGS_CMD_0] = cmdpacket0(R300_RE_FOG_STATE, 1);
+       r300->hw.fogs.cmd[R300_FOGS_CMD_0] = cmdpacket0(R300_FG_FOG_BLEND, 1);
        ALLOC_STATE(fogc, always, R300_FOGC_CMDSIZE, 0);
-       r300->hw.fogc.cmd[R300_FOGC_CMD_0] = cmdpacket0(R300_FOG_COLOR_R, 3);
+       r300->hw.fogc.cmd[R300_FOGC_CMD_0] = cmdpacket0(R300_FG_FOG_COLOR_R, 3);
        ALLOC_STATE(at, always, R300_AT_CMDSIZE, 0);
-       r300->hw.at.cmd[R300_AT_CMD_0] = cmdpacket0(R300_PP_ALPHA_TEST, 2);
-       ALLOC_STATE(unk4BD8, always, 2, 0);
-       r300->hw.unk4BD8.cmd[0] = cmdpacket0(0x4BD8, 1);
-       ALLOC_STATE(fpp, variable, R300_FPP_CMDSIZE, 0);
-       r300->hw.fpp.cmd[R300_FPP_CMD_0] = cmdpacket0(R300_PFS_PARAM_0_X, 0);
-       ALLOC_STATE(unk4E00, always, 2, 0);
-       r300->hw.unk4E00.cmd[0] = cmdpacket0(0x4E00, 1);
+       r300->hw.at.cmd[R300_AT_CMD_0] = cmdpacket0(R300_FG_ALPHA_FUNC, 2);
+       ALLOC_STATE(fg_depth_src, always, 2, 0);
+       r300->hw.fg_depth_src.cmd[0] = cmdpacket0(R300_FG_DEPTH_SRC, 1);
+       ALLOC_STATE(rb3d_cctl, always, 2, 0);
+       r300->hw.rb3d_cctl.cmd[0] = cmdpacket0(R300_RB3D_CCTL, 1);
        ALLOC_STATE(bld, always, R300_BLD_CMDSIZE, 0);
        r300->hw.bld.cmd[R300_BLD_CMD_0] = cmdpacket0(R300_RB3D_CBLEND, 2);
        ALLOC_STATE(cmk, always, R300_CMK_CMDSIZE, 0);
-       r300->hw.cmk.cmd[R300_CMK_CMD_0] = cmdpacket0(R300_RB3D_COLORMASK, 1);
-       ALLOC_STATE(blend_color, always, 4, 0);
-       r300->hw.blend_color.cmd[0] = cmdpacket0(R300_RB3D_BLEND_COLOR, 3);
+       r300->hw.cmk.cmd[R300_CMK_CMD_0] = cmdpacket0(RB3D_COLOR_CHANNEL_MASK, 1);
+       if (is_r500) {
+               ALLOC_STATE(blend_color, always, 3, 0);
+               r300->hw.blend_color.cmd[0] = cmdpacket0(R500_RB3D_CONSTANT_COLOR_AR, 2);
+       } else {
+               ALLOC_STATE(blend_color, always, 2, 0);
+               r300->hw.blend_color.cmd[0] = cmdpacket0(R300_RB3D_BLEND_COLOR, 1);
+       }
+       ALLOC_STATE(rop, always, 2, 0);
+       r300->hw.rop.cmd[0] = cmdpacket0(R300_RB3D_ROPCNTL, 1);
        ALLOC_STATE(cb, always, R300_CB_CMDSIZE, 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, 0);
-       r300->hw.unk4E50.cmd[0] = cmdpacket0(0x4E50, 9);
-       ALLOC_STATE(unk4E88, always, 2, 0);
-       r300->hw.unk4E88.cmd[0] = cmdpacket0(0x4E88, 1);
-       ALLOC_STATE(unk4EA0, always, 3, 0);
-       r300->hw.unk4EA0.cmd[0] = cmdpacket0(0x4EA0, 2);
+       ALLOC_STATE(rb3d_dither_ctl, always, 10, 0);
+       r300->hw.rb3d_dither_ctl.cmd[0] = cmdpacket0(R300_RB3D_DITHER_CTL, 9);
+       ALLOC_STATE(rb3d_aaresolve_ctl, always, 2, 0);
+       r300->hw.rb3d_aaresolve_ctl.cmd[0] = cmdpacket0(R300_RB3D_AARESOLVE_CTL, 1);
+       ALLOC_STATE(rb3d_discard_src_pixel_lte_threshold, always, 3, 0);
+       r300->hw.rb3d_discard_src_pixel_lte_threshold.cmd[0] = cmdpacket0(R500_RB3D_DISCARD_SRC_PIXEL_LTE_THRESHOLD, 2);
        ALLOC_STATE(zs, always, R300_ZS_CMDSIZE, 0);
        r300->hw.zs.cmd[R300_ZS_CMD_0] =
-           cmdpacket0(R300_RB3D_ZSTENCIL_CNTL_0, 3);
+           cmdpacket0(R300_ZB_CNTL, 3);
        ALLOC_STATE(zstencil_format, always, 5, 0);
        r300->hw.zstencil_format.cmd[0] =
-           cmdpacket0(R300_RB3D_ZSTENCIL_FORMAT, 4);
+           cmdpacket0(R300_ZB_FORMAT, 4);
        ALLOC_STATE(zb, always, R300_ZB_CMDSIZE, 0);
-       r300->hw.zb.cmd[R300_ZB_CMD_0] = cmdpacket0(R300_RB3D_DEPTHOFFSET, 2);
-       ALLOC_STATE(unk4F28, always, 2, 0);
-       r300->hw.unk4F28.cmd[0] = cmdpacket0(0x4F28, 1);
+       r300->hw.zb.cmd[R300_ZB_CMD_0] = cmdpacket0(R300_ZB_DEPTHOFFSET, 2);
+       ALLOC_STATE(zb_depthclearvalue, always, 2, 0);
+       r300->hw.zb_depthclearvalue.cmd[0] = cmdpacket0(R300_ZB_DEPTHCLEARVALUE, 1);
        ALLOC_STATE(unk4F30, always, 3, 0);
        r300->hw.unk4F30.cmd[0] = cmdpacket0(0x4F30, 2);
-       ALLOC_STATE(unk4F44, always, 2, 0);
-       r300->hw.unk4F44.cmd[0] = cmdpacket0(0x4F44, 1);
-       ALLOC_STATE(unk4F54, always, 2, 0);
-       r300->hw.unk4F54.cmd[0] = cmdpacket0(0x4F54, 1);
+       ALLOC_STATE(zb_hiz_offset, always, 2, 0);
+       r300->hw.zb_hiz_offset.cmd[0] = cmdpacket0(R300_ZB_HIZ_OFFSET, 1);
+       ALLOC_STATE(zb_hiz_pitch, always, 2, 0);
+       r300->hw.zb_hiz_pitch.cmd[0] = cmdpacket0(R300_ZB_HIZ_PITCH, 1);
 
        /* VPU only on TCL */
        if (has_tcl) {
+               int i;
                ALLOC_STATE(vpi, vpu, R300_VPI_CMDSIZE, 0);
                r300->hw.vpi.cmd[R300_VPI_CMD_0] =
-                   cmdvpu(R300_PVS_UPLOAD_PROGRAM, 0);
-               ALLOC_STATE(vpp, vpu, R300_VPP_CMDSIZE, 0);
-               r300->hw.vpp.cmd[R300_VPP_CMD_0] =
-                   cmdvpu(R300_PVS_UPLOAD_PARAMETERS, 0);
-               ALLOC_STATE(vps, vpu, R300_VPS_CMDSIZE, 0);
-               r300->hw.vps.cmd[R300_VPS_CMD_0] =
-                   cmdvpu(R300_PVS_UPLOAD_POINTSIZE, 1);
+                   cmdvpu(R300_PVS_CODE_START, 0);
+
+               if (is_r500) {
+                   ALLOC_STATE(vpp, vpu, R300_VPP_CMDSIZE, 0);
+                   r300->hw.vpp.cmd[R300_VPP_CMD_0] =
+                       cmdvpu(R500_PVS_CONST_START, 0);
+
+                   ALLOC_STATE(vps, vpu, R300_VPS_CMDSIZE, 0);
+                   r300->hw.vps.cmd[R300_VPS_CMD_0] =
+                       cmdvpu(R500_POINT_VPORT_SCALE_OFFSET, 1);
+
+                       for (i = 0; i < 6; i++) {
+                               ALLOC_STATE(vpucp[i], vpu, R300_VPUCP_CMDSIZE, 0);
+                               r300->hw.vpucp[i].cmd[R300_VPUCP_CMD_0] =
+                                       cmdvpu(R500_PVS_UCP_START + i, 1);
+                       }
+               } else {
+                   ALLOC_STATE(vpp, vpu, R300_VPP_CMDSIZE, 0);
+                   r300->hw.vpp.cmd[R300_VPP_CMD_0] =
+                       cmdvpu(R300_PVS_CONST_START, 0);
+
+                   ALLOC_STATE(vps, vpu, R300_VPS_CMDSIZE, 0);
+                   r300->hw.vps.cmd[R300_VPS_CMD_0] =
+                       cmdvpu(R300_POINT_VPORT_SCALE_OFFSET, 1);
+
+                       for (i = 0; i < 6; i++) {
+                               ALLOC_STATE(vpucp[i], vpu, R300_VPUCP_CMDSIZE, 0);
+                               r300->hw.vpucp[i].cmd[R300_VPUCP_CMD_0] =
+                                       cmdvpu(R300_PVS_UCP_START + i, 1);
+                       }
+               }
        }
 
        /* Textures */
        ALLOC_STATE(tex.filter, variable, mtu + 1, 0);
        r300->hw.tex.filter.cmd[R300_TEX_CMD_0] =
-           cmdpacket0(R300_TX_FILTER_0, 0);
+           cmdpacket0(R300_TX_FILTER0_0, 0);
 
        ALLOC_STATE(tex.filter_1, variable, mtu + 1, 0);
        r300->hw.tex.filter_1.cmd[R300_TEX_CMD_0] =
@@ -471,7 +560,7 @@ void r300InitCmdBuf(r300ContextPtr r300)
            cmdpacket0(R300_TX_FORMAT_0, 0);
 
        ALLOC_STATE(tex.pitch, variable, mtu + 1, 0);
-       r300->hw.tex.pitch.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_PITCH_0, 0);
+       r300->hw.tex.pitch.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_FORMAT2_0, 0);
 
        ALLOC_STATE(tex.offset, variable, mtu + 1, 0);
        r300->hw.tex.offset.cmd[R300_TEX_CMD_0] =
index acb6e38c6dfcdbbb8b9f4546c1a96803ebfcedd9..a8eaa580bd92191f9ec07d86461a9f53a28803b8 100644 (file)
@@ -52,7 +52,7 @@ extern void r300DestroyCmdBuf(r300ContextPtr r300);
  *
  * \param dwords The number of dwords we need to be free on the command buffer
  */
-static inline void r300EnsureCmdBufSpace(r300ContextPtr r300,
+static INLINE void r300EnsureCmdBufSpace(r300ContextPtr r300,
                                             int dwords, const char *caller)
 {
        assert(dwords < r300->cmdbuf.size);
@@ -68,7 +68,7 @@ static inline void r300EnsureCmdBufSpace(r300ContextPtr r300,
  * causes state reemission after a flush. This is necessary to ensure
  * correct hardware state after an unlock.
  */
-static inline uint32_t *r300RawAllocCmdBuf(r300ContextPtr r300,
+static INLINE uint32_t *r300RawAllocCmdBuf(r300ContextPtr r300,
                                               int dwords, const char *caller)
 {
        uint32_t *ptr;
@@ -80,7 +80,7 @@ static inline uint32_t *r300RawAllocCmdBuf(r300ContextPtr r300,
        return ptr;
 }
 
-static inline uint32_t *r300AllocCmdBuf(r300ContextPtr r300,
+static INLINE uint32_t *r300AllocCmdBuf(r300ContextPtr r300,
                                            int dwords, const char *caller)
 {
        uint32_t *ptr;
index 14e0f052fd57aec1b6f7b038c5cb5bcffc7896f0..fcf571d20603aa856628241680a5c203ef576585 100644 (file)
@@ -79,11 +79,13 @@ int hw_tcl_on = 1;
 
 #define need_GL_EXT_stencil_two_side
 #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_minmax
 //#define need_GL_EXT_fog_coord
+#define need_GL_EXT_multi_draw_arrays
 #define need_GL_EXT_secondary_color
 #define need_GL_EXT_blend_equation_separate
 #define need_GL_EXT_blend_func_separate
@@ -93,8 +95,13 @@ int hw_tcl_on = 1;
 
 const struct dri_extension card_extensions[] = {
   /* *INDENT-OFF* */
+  {"GL_ARB_depth_texture",             NULL},
+  {"GL_ARB_fragment_program",          NULL},
   {"GL_ARB_multisample",               GL_ARB_multisample_functions},
   {"GL_ARB_multitexture",              NULL},
+  {"GL_ARB_point_parameters",          GL_ARB_point_parameters_functions},
+  {"GL_ARB_shadow",                    NULL},
+  {"GL_ARB_shadow_ambient",            NULL},
   {"GL_ARB_texture_border_clamp",      NULL},
   {"GL_ARB_texture_compression",       GL_ARB_texture_compression_functions},
   {"GL_ARB_texture_cube_map",          NULL},
@@ -105,14 +112,15 @@ const struct dri_extension card_extensions[] = {
   {"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},
-  {"GL_ARB_fragment_program",          NULL},
   {"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_multi_draw_arrays",         GL_EXT_multi_draw_arrays_functions},
   {"GL_EXT_gpu_program_parameters",     GL_EXT_gpu_program_parameters_functions},
   {"GL_EXT_secondary_color",           GL_EXT_secondary_color_functions},
+  {"GL_EXT_shadow_funcs",              NULL},
   {"GL_EXT_stencil_two_side",          GL_EXT_stencil_two_side_functions},
   {"GL_EXT_stencil_wrap",              NULL},
   {"GL_EXT_texture_edge_clamp",                NULL},
@@ -130,6 +138,7 @@ const struct dri_extension card_extensions[] = {
   {"GL_NV_blend_square",               NULL},
   {"GL_NV_vertex_program",             GL_NV_vertex_program_functions},
   {"GL_SGIS_generate_mipmap",          NULL},
+  {"GL_SGIX_depth_texture",            NULL},
   {NULL,                               NULL}
   /* *INDENT-ON* */
 };
@@ -273,6 +282,12 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
            MIN2(ctx->Const.MaxTextureImageUnits,
                 ctx->Const.MaxTextureCoordUnits);
        ctx->Const.MaxTextureMaxAnisotropy = 16.0;
+       ctx->Const.MaxTextureLodBias = 16.0;
+
+       if (screen->chip_family >= CHIP_FAMILY_RV515) {
+           ctx->Const.MaxTextureLevels = 13;
+           ctx->Const.MaxTextureRectSize = 4096;
+       }
 
        ctx->Const.MinPointSize = 1.0;
        ctx->Const.MinPointSizeAA = 1.0;
index be6909724a380081b28e4351ff6ae4bcb91566c7..d2017f8afeb9d0a6259cb87648a6e145ae556202 100644 (file)
@@ -73,12 +73,12 @@ typedef struct r300_context *r300ContextPtr;
        }
 
 #include "r300_vertprog.h"
-#include "r300_fragprog.h"
+#include "r500_fragprog.h"
 
 /**
  * This function takes a float and packs it into a uint32_t
  */
-static inline uint32_t r300PackFloat32(float fl)
+static INLINE uint32_t r300PackFloat32(float fl)
 {
        union {
                float fl;
@@ -95,7 +95,7 @@ static inline uint32_t r300PackFloat32(float fl)
  * But it works for most things.  I'll fix it later if someone
  * else with a better clue doesn't
  */
-static inline uint32_t r300PackFloat24(float f)
+static INLINE uint32_t r300PackFloat24(float f)
 {
        float mantissa;
        int exponent;
@@ -178,13 +178,6 @@ struct r300_tex_obj {
        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 */
 
@@ -330,15 +323,17 @@ struct r300_state_atom {
 #define R300_RI_INTERP_7       8
 #define R300_RI_CMDSIZE                9
 
+#define R500_RI_CMDSIZE               17
+
 #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_INST_0         1
+#define R300_RR_INST_1         2
+#define R300_RR_INST_2         3
+#define R300_RR_INST_3         4
+#define R300_RR_INST_4         5
+#define R300_RR_INST_5         6
+#define R300_RR_INST_6         7
+#define R300_RR_INST_7         8
 #define R300_RR_CMDSIZE                9
 
 #define R300_FP_CMD_0          0
@@ -352,6 +347,17 @@ struct r300_state_atom {
 #define R300_FP_NODE3          8
 #define R300_FP_CMDSIZE                9
 
+#define R500_FP_CMD_0           0
+#define R500_FP_CNTL            1
+#define R500_FP_PIXSIZE         2
+#define R500_FP_CMD_1           3
+#define R500_FP_CODE_ADDR       4
+#define R500_FP_CODE_RANGE      5
+#define R500_FP_CODE_OFFSET     6
+#define R500_FP_CMD_2           7
+#define R500_FP_FC_CNTL         8
+#define R500_FP_CMDSIZE         9
+
 #define R300_FPT_CMD_0         0
 #define R300_FPT_INSTR_0       1
 #define R300_FPT_CMDSIZE       65
@@ -359,10 +365,14 @@ struct r300_state_atom {
 #define R300_FPI_CMD_0         0
 #define R300_FPI_INSTR_0       1
 #define R300_FPI_CMDSIZE       65
+/* R500 has space for 512 instructions - 6 dwords per instruction */
+#define R500_FPI_CMDSIZE       (512*6+1)
 
 #define R300_FPP_CMD_0         0
 #define R300_FPP_PARAM_0       1
 #define R300_FPP_CMDSIZE       (32*4+1)
+/* R500 has spcae for 256 constants - 4 dwords per constant */
+#define R500_FPP_CMDSIZE       (256*4+1)
 
 #define R300_FOGS_CMD_0                0
 #define R300_FOGS_STATE                1
@@ -410,6 +420,12 @@ struct r300_state_atom {
 #define R300_ZB_PITCH          2
 #define R300_ZB_CMDSIZE                3
 
+#define R300_VAP_CNTL_FLUSH     0
+#define R300_VAP_CNTL_FLUSH_1   1
+#define R300_VAP_CNTL_CMD       2
+#define R300_VAP_CNTL_INSTR     3
+#define R300_VAP_CNTL_SIZE      4
+
 #define R300_VPI_CMD_0         0
 #define R300_VPI_INSTR_0       1
 #define R300_VPI_CMDSIZE       1025    /* 256 16 byte instructions */
@@ -418,6 +434,13 @@ struct r300_state_atom {
 #define R300_VPP_PARAM_0       1
 #define R300_VPP_CMDSIZE       1025    /* 256 4-component parameters */
 
+#define R300_VPUCP_CMD_0               0
+#define R300_VPUCP_X            1
+#define R300_VPUCP_Y            2
+#define R300_VPUCP_Z            3
+#define R300_VPUCP_W            4
+#define R300_VPUCP_CMDSIZE     5       /* 256 4-component parameters */
+
 #define R300_VPS_CMD_0         0
 #define R300_VPS_ZERO_0                1
 #define R300_VPS_ZERO_1                2
@@ -444,67 +467,72 @@ struct r300_hw_state {
 
        struct r300_state_atom vpt;     /* viewport (1D98) */
        struct r300_state_atom vap_cntl;
+        struct r300_state_atom vap_index_offset; /* 0x208c r5xx only */
        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 vap_vf_max_vtx_indx;     /* Maximum Vertex Indx Clamp (2134) */
        struct r300_state_atom vap_cntl_status;
        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 vap_psc_sgn_norm_cntl; /* Programmable Stream Control Signed Normalize Control (21DC) */
+       struct r300_state_atom vap_clip_cntl;
        struct r300_state_atom vap_clip;
-       struct r300_state_atom unk2288; /* (2288) */
+       struct r300_state_atom vap_pvs_vtx_timeout_reg; /* Vertex timeout register (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 ga_point_s0;     /* S Texture Coordinate of Vertex 0 for Point texture stuffing (LLC) (4200) */
+       struct r300_state_atom ga_triangle_stipple;     /* (4214) */
        struct r300_state_atom ps;      /* pointsize (421C) */
-       struct r300_state_atom unk4230; /* (4230) */
+       struct r300_state_atom ga_point_minmax; /* (4230) */
        struct r300_state_atom lcntl;   /* line control */
-       struct r300_state_atom unk4260; /* (4260) */
+       struct r300_state_atom ga_line_stipple; /* (4260) */
        struct r300_state_atom shade;
        struct r300_state_atom polygon_mode;
        struct r300_state_atom fogp;    /* fog parameters (4294) */
-       struct r300_state_atom unk429C; /* (429C) */
+       struct r300_state_atom ga_soft_reset;   /* (429C) */
        struct r300_state_atom zbias_cntl;
        struct r300_state_atom zbs;     /* zbias (42A4) */
        struct r300_state_atom occlusion_cntl;
        struct r300_state_atom cul;     /* cull cntl (42B8) */
-       struct r300_state_atom unk42C0; /* (42C0) */
+       struct r300_state_atom su_depth_scale;  /* (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 sc_hyperz;       /* (43A4) */
+       struct r300_state_atom sc_screendoor;   /* (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 us_out_fmt;      /* (46A4) */
+       struct r300_state_atom r500fp;  /* r500 fp instructions */
+       struct r300_state_atom r500fp_const;    /* r500 fp constants */
        struct r300_state_atom fpi[4];  /* fp instructions (46C0/47C0/48C0/49C0) */
        struct r300_state_atom fogs;    /* fog state (4BC0) */
        struct r300_state_atom fogc;    /* fog color (4BC8) */
        struct r300_state_atom at;      /* alpha test (4BD4) */
-       struct r300_state_atom unk4BD8; /* (4BD8) */
+       struct r300_state_atom fg_depth_src;    /* (4BD8) */
        struct r300_state_atom fpp;     /* 0x4C00 and following */
-       struct r300_state_atom unk4E00; /* (4E00) */
+       struct r300_state_atom rb3d_cctl;       /* (4E00) */
        struct r300_state_atom bld;     /* blending (4E04) */
        struct r300_state_atom cmk;     /* colormask (4E0C) */
        struct r300_state_atom blend_color;     /* constant blend color */
+       struct r300_state_atom rop;     /* ropcntl */
        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 rb3d_dither_ctl; /* (4E50) */
+       struct r300_state_atom rb3d_aaresolve_ctl;      /* (4E88) */
+       struct r300_state_atom rb3d_discard_src_pixel_lte_threshold;    /* (4E88) I saw it only written on RV350 hardware..  */
        struct r300_state_atom zs;      /* zstencil control (4F00) */
        struct r300_state_atom zstencil_format;
        struct r300_state_atom zb;      /* z buffer (4F20) */
-       struct r300_state_atom unk4F28; /* (4F28) */
+       struct r300_state_atom zb_depthclearvalue;      /* (4F28) */
        struct r300_state_atom unk4F30; /* (4F30) */
-       struct r300_state_atom unk4F44; /* (4F44) */
-       struct r300_state_atom unk4F54; /* (4F54) */
+       struct r300_state_atom zb_hiz_offset;   /* (4F44) */
+       struct r300_state_atom zb_hiz_pitch;    /* (4F54) */
 
        struct r300_state_atom vpi;     /* vp instructions */
        struct r300_state_atom vpp;     /* vp parameters */
        struct r300_state_atom vps;     /* vertex point size (?) */
+       struct r300_state_atom vpucp[6];        /* vp user clip plane - 6 */
        /* 8 texture units */
        /* the state is grouped by function and not by
           texture unit. This makes single unit updates
@@ -546,9 +574,7 @@ struct r300_depthbuffer_state {
 };
 
 struct r300_stencilbuffer_state {
-       GLuint clear;
        GLboolean hw_stencil;
-
 };
 
 /* Vertex shader state */
@@ -596,6 +622,7 @@ extern int hw_tcl_on;
 struct r300_vertex_program_key {
        GLuint InputsRead;
        GLuint OutputsWritten;
+       GLuint OutputsAdded;
 };
 
 struct r300_vertex_program {
@@ -627,82 +654,75 @@ struct r300_vertex_program_cont {
 #define PFS_NUM_TEMP_REGS      32
 #define PFS_NUM_CONST_REGS     16
 
-/* Mapping Mesa registers to R300 temporaries */
-struct reg_acc {
-       int reg;                /* Assigned hw temp */
-       unsigned int refcount;  /* Number of uses by mesa program */
-};
+struct r300_pfs_compile_state;
+
 
 /**
- * Describe the current lifetime information for an R300 temporary
+ * Stores state that influences the compilation of a fragment program.
  */
-struct reg_lifetime {
-       /* Index of the first slot where this register is free in the sense
-          that it can be used as a new destination register.
-          This is -1 if the register has been assigned to a Mesa register
-          and the last access to the register has not yet been emitted */
-       int free;
-
-       /* Index of the first slot where this register is currently reserved.
-          This is used to stop e.g. a scalar operation from being moved
-          before the allocation time of a register that was first allocated
-          for a vector operation. */
-       int reserved;
-
-       /* Index of the first slot in which the register can be used as a
-          source without losing the value that is written by the last
-          emitted instruction that writes to the register */
-       int vector_valid;
-       int scalar_valid;
-
-       /* Index to the slot where the register was last read.
-          This is also the first slot in which the register may be written again */
-       int vector_lastread;
-       int scalar_lastread;
+struct r300_fragment_program_external_state {
+       struct {
+               /**
+                * If the sampler is used as a shadow sampler,
+                * this field is:
+                *  0 - GL_LUMINANCE
+                *  1 - GL_INTENSITY
+                *  2 - GL_ALPHA
+                * depending on the depth texture mode.
+                */
+               GLuint depth_texture_mode : 2;
+
+               /**
+                * If the sampler is used as a shadow sampler,
+                * this field is (texture_compare_func - GL_NEVER).
+                * [e.g. if compare function is GL_LEQUAL, this field is 3]
+                *
+                * Otherwise, this field is 0.
+                */
+               GLuint texture_compare_func : 3;
+       } unit[16];
 };
 
-/**
- * Store usage information about an ALU instruction slot during the
- * compilation of a fragment program.
- */
-#define SLOT_SRC_VECTOR  (1<<0)
-#define SLOT_SRC_SCALAR  (1<<3)
-#define SLOT_SRC_BOTH    (SLOT_SRC_VECTOR | SLOT_SRC_SCALAR)
-#define SLOT_OP_VECTOR   (1<<16)
-#define SLOT_OP_SCALAR   (1<<17)
-#define SLOT_OP_BOTH     (SLOT_OP_VECTOR | SLOT_OP_SCALAR)
-
-struct r300_pfs_compile_slot {
-       /* Bitmask indicating which parts of the slot are used, using SLOT_ constants
-          defined above */
-       unsigned int used;
-
-       /* Selected sources */
-       int vsrc[3];
-       int ssrc[3];
+
+struct r300_fragment_program_node {
+       int tex_offset; /**< first tex instruction */
+       int tex_end; /**< last tex instruction, relative to tex_offset */
+       int alu_offset; /**< first ALU instruction */
+       int alu_end; /**< last ALU instruction, relative to alu_offset */
+       int flags;
 };
 
 /**
- * Store information during compilation of fragment programs.
+ * Stores an R300 fragment program in its compiled-to-hardware form.
  */
-struct r300_pfs_compile_state {
-       int nrslots;            /* number of ALU slots used so far */
+struct r300_fragment_program_code {
+       struct {
+               int length; /**< total # of texture instructions used */
+               GLuint inst[PFS_MAX_TEX_INST];
+       } tex;
 
-       /* Track which (parts of) slots are already filled with instructions */
-       struct r300_pfs_compile_slot slot[PFS_MAX_ALU_INST];
+       struct {
+               int length; /**< total # of ALU instructions used */
+               struct {
+                       GLuint inst0;
+                       GLuint inst1;
+                       GLuint inst2;
+                       GLuint inst3;
+               } inst[PFS_MAX_ALU_INST];
+       } alu;
 
-       /* Track the validity of R300 temporaries */
-       struct reg_lifetime hwtemps[PFS_NUM_TEMP_REGS];
+       struct r300_fragment_program_node node[4];
+       int cur_node;
+       int first_node_has_tex;
 
-       /* Used to map Mesa's inputs/temps onto hardware temps */
-       int temp_in_use;
-       struct reg_acc temps[PFS_NUM_TEMP_REGS];
-       struct reg_acc inputs[32];      /* don't actually need 32... */
+       /**
+        * Remember which program register a given hardware constant
+        * belongs to.
+        */
+       struct prog_src_register constant[PFS_NUM_CONST_REGS];
+       int const_nr;
 
-       /* Track usage of hardware temps, for register allocation,
-        * indirection detection, etc. */
-       GLuint used_in_node;
-       GLuint dest_in_node;
+       int max_temp_idx;
 };
 
 /**
@@ -712,51 +732,75 @@ struct r300_pfs_compile_state {
 struct r300_fragment_program {
        struct gl_fragment_program mesa_program;
 
-       GLcontext *ctx;
        GLboolean translated;
        GLboolean error;
-       struct r300_pfs_compile_state *cs;
 
-       struct {
-               int length;
-               GLuint inst[PFS_MAX_TEX_INST];
-       } tex;
+       struct r300_fragment_program_external_state state;
+       struct r300_fragment_program_code code;
 
-       struct {
-               struct {
-                       GLuint inst0;
-                       GLuint inst1;
-                       GLuint inst2;
-                       GLuint inst3;
-               } inst[PFS_MAX_ALU_INST];
-       } alu;
+       GLboolean WritesDepth;
+       GLuint optimization;
+};
+
+struct r500_pfs_compile_state;
 
+struct r500_fragment_program_external_state {
        struct {
-               int tex_offset;
-               int tex_end;
-               int alu_offset;
-               int alu_end;
-               int flags;
-       } node[4];
-       int cur_node;
-       int first_node_has_tex;
+               /**
+                * If the sampler is used as a shadow sampler,
+                * this field is:
+                *  0 - GL_LUMINANCE
+                *  1 - GL_INTENSITY
+                *  2 - GL_ALPHA
+                * depending on the depth texture mode.
+                */
+               GLuint depth_texture_mode : 2;
+
+               /**
+                * If the sampler is used as a shadow sampler,
+                * this field is (texture_compare_func - GL_NEVER).
+                * [e.g. if compare function is GL_LEQUAL, this field is 3]
+                *
+                * Otherwise, this field is 0.
+                */
+               GLuint texture_compare_func : 3;
+       } unit[16];
+};
 
-       int alu_offset;
-       int alu_end;
-       int tex_offset;
-       int tex_end;
-
-       /* Hardware constants.
-        * Contains a pointer to the value. The destination of the pointer
-        * is supposed to be updated when GL state changes.
-        * Typically, this is either a pointer into
-        * gl_program_parameter_list::ParameterValues, or a pointer to a
-        * global constant (e.g. for sin/cos-approximation)
+struct r500_fragment_program_code {
+       struct {
+               GLuint inst0;
+               GLuint inst1;
+               GLuint inst2;
+               GLuint inst3;
+               GLuint inst4;
+               GLuint inst5;
+       } inst[512];
+
+       int inst_offset;
+       int inst_end;
+
+       /**
+        * Remember which program register a given hardware constant
+        * belongs to.
         */
-       const GLfloat *constant[PFS_NUM_CONST_REGS];
+       struct prog_src_register constant[PFS_NUM_CONST_REGS];
        int const_nr;
 
        int max_temp_idx;
+};
+
+struct r500_fragment_program {
+       struct gl_fragment_program mesa_program;
+
+       GLcontext *ctx;
+       GLboolean translated;
+       GLboolean error;
+
+       struct r500_fragment_program_external_state state;
+       struct r500_fragment_program_code code;
+
+       GLboolean writes_depth;
 
        GLuint optimization;
 };
@@ -772,7 +816,6 @@ struct r300_state {
        struct r300_texture_state texture;
        int sw_tcl_inputs[VERT_ATTRIB_MAX];
        struct r300_vertex_shader_state vertex_shader;
-       struct r300_pfs_compile_state pfs_compile;
        struct r300_dma_region aos[R300_MAX_AOS_ARRAYS];
        int aos_count;
 
@@ -795,7 +838,7 @@ struct r300_state {
  */
 struct r300_swtcl_info {
    GLuint RenderIndex;
-   
+
    /**
     * Size of a hardware vertex.  This is calculated when \c ::vertex_attrs is
     * installed in the Mesa state vector.
index 424bf44e595159dbe48d59d733bc2f1ca087cc93..2ea17ad0a7c725f19ef0549e9b1be831207c9240 100644 (file)
@@ -207,49 +207,57 @@ static void r300EmitVec(GLcontext * ctx, struct r300_dma_region *rvb,
        }
 }
 
-static GLuint r300VAPInputRoute0(uint32_t * dst, GLvector4f ** attribptr,
+#define DW_SIZE(x) ((inputs[tab[(x)]] << R300_DST_VEC_LOC_SHIFT) |     \
+                   (attribptr[tab[(x)]]->size - 1) << R300_DATA_TYPE_0_SHIFT)
+
+GLuint r300VAPInputRoute0(uint32_t * dst, GLvector4f ** attribptr,
                                 int *inputs, GLint * tab, GLuint nr)
 {
        GLuint i, dw;
 
        /* type, inputs, stop bit, size */
-       for (i = 0; i + 1 < nr; i += 2) {
-               dw = R300_INPUT_ROUTE_FLOAT | (inputs[tab[i]] << 8) | (attribptr[tab[i]]->size - 1);
-               dw |= (R300_INPUT_ROUTE_FLOAT | (inputs[tab[i + 1]] << 8) | (attribptr[tab[i + 1]]->size - 1)) << 16;
-               if (i + 2 == nr) {
-                       dw |= (R300_VAP_INPUT_ROUTE_END << 16);
+       for (i = 0; i < nr; i += 2) {
+               /* make sure input is valid, would lockup the gpu */
+               assert(inputs[tab[i]] != -1);
+               dw = (R300_SIGNED | DW_SIZE(i));
+               if (i + 1 == nr) {
+                       dw |= R300_LAST_VEC << R300_DATA_TYPE_0_SHIFT;
+               } else {
+                       assert(inputs[tab[i + 1]] != -1);
+                       dw |= (R300_SIGNED |
+                              DW_SIZE(i + 1)) << R300_DATA_TYPE_1_SHIFT;
+                       if (i + 2 == nr) {
+                               dw |= R300_LAST_VEC << R300_DATA_TYPE_1_SHIFT;
+                       }
                }
                dst[i >> 1] = dw;
        }
 
-       if (nr & 1) {
-               dw = R300_INPUT_ROUTE_FLOAT | (inputs[tab[nr - 1]] << 8) | (attribptr[tab[nr - 1]]->size - 1);
-               dw |= R300_VAP_INPUT_ROUTE_END;
-               dst[nr >> 1] = dw;
-       }
-
        return (nr + 1) >> 1;
 }
 
 static GLuint r300VAPInputRoute1Swizzle(int swizzle[4])
 {
-       return (swizzle[0] << R300_INPUT_ROUTE_X_SHIFT) |
-           (swizzle[1] << R300_INPUT_ROUTE_Y_SHIFT) |
-           (swizzle[2] << R300_INPUT_ROUTE_Z_SHIFT) |
-           (swizzle[3] << R300_INPUT_ROUTE_W_SHIFT);
+       return (swizzle[0] << R300_SWIZZLE_SELECT_X_SHIFT) |
+           (swizzle[1] << R300_SWIZZLE_SELECT_Y_SHIFT) |
+           (swizzle[2] << R300_SWIZZLE_SELECT_Z_SHIFT) |
+           (swizzle[3] << R300_SWIZZLE_SELECT_W_SHIFT);
 }
 
 GLuint r300VAPInputRoute1(uint32_t * dst, int swizzle[][4], GLuint nr)
 {
-       GLuint i;
-
-       for (i = 0; i + 1 < nr; i += 2) {
-               dst[i >> 1] = r300VAPInputRoute1Swizzle(swizzle[i]) | R300_INPUT_ROUTE_ENABLE;
-               dst[i >> 1] |= (r300VAPInputRoute1Swizzle(swizzle[i + 1]) | R300_INPUT_ROUTE_ENABLE) << 16;
-       }
+       GLuint i, dw;
 
-       if (nr & 1) {
-               dst[nr >> 1] = r300VAPInputRoute1Swizzle(swizzle[nr - 1]) | R300_INPUT_ROUTE_ENABLE;
+       for (i = 0; i < nr; i += 2) {
+               dw = (r300VAPInputRoute1Swizzle(swizzle[i]) |
+                     ((R300_WRITE_ENA_X | R300_WRITE_ENA_Y |
+                       R300_WRITE_ENA_Z | R300_WRITE_ENA_W) << R300_WRITE_ENA_SHIFT)) << R300_SWIZZLE0_SHIFT;
+               if (i + 1 < nr) {
+                       dw |= (r300VAPInputRoute1Swizzle(swizzle[i + 1]) |
+                              ((R300_WRITE_ENA_X | R300_WRITE_ENA_Y |
+                                R300_WRITE_ENA_Z | R300_WRITE_ENA_W) << R300_WRITE_ENA_SHIFT)) << R300_SWIZZLE1_SHIFT;
+               }
+               dst[i >> 1] = dw;
        }
 
        return (nr + 1) >> 1;
@@ -294,7 +302,7 @@ GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten)
                ret |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT;
 
        if (OutputsWritten & (1 << VERT_RESULT_COL0))
-               ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT;
+               ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT;
 
        if (OutputsWritten & (1 << VERT_RESULT_COL1))
                ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT;
@@ -536,16 +544,16 @@ void r300ReleaseArrays(GLcontext * ctx)
 
 void r300EmitCacheFlush(r300ContextPtr rmesa)
 {
-        int cmd_reserved = 0;
+       int cmd_reserved = 0;
        int cmd_written = 0;
 
        drm_radeon_cmd_header_t *cmd = NULL;
 
        reg_start(R300_RB3D_DSTCACHE_CTLSTAT, 0);
-       e32(R300_RB3D_DSTCACHE_UNKNOWN_0A);
-
-       reg_start(R300_RB3D_ZCACHE_CTLSTAT, 0);
-       e32(R300_RB3D_ZCACHE_UNKNOWN_03);
-
+       e32(R300_RB3D_DSTCACHE_CTLSTAT_DC_FREE_FREE_3D_TAGS |
+           R300_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_FLUSH_DIRTY_3D);
 
+       reg_start(R300_ZB_ZCACHE_CTLSTAT, 0);
+       e32(R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE |
+           R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE);
 }
index a6d69ec5ff861a85f91c6707b6f994864b447a8d..5950539cba46eadab27f8f55f402b9f6046ff672 100644 (file)
@@ -50,7 +50,7 @@
 #define CP_PACKET3( pkt, n )                                           \
        (RADEON_CP_PACKET3 | (pkt) | ((n) << 16))
 
-static inline uint32_t cmdpacket0(int reg, int count)
+static INLINE uint32_t cmdpacket0(int reg, int count)
 {
        drm_r300_cmd_header_t cmd;
 
@@ -62,7 +62,7 @@ static inline uint32_t cmdpacket0(int reg, int count)
        return cmd.u;
 }
 
-static inline uint32_t cmdvpu(int addr, int count)
+static INLINE uint32_t cmdvpu(int addr, int count)
 {
        drm_r300_cmd_header_t cmd;
 
@@ -74,7 +74,21 @@ static inline uint32_t cmdvpu(int addr, int count)
        return cmd.u;
 }
 
-static inline uint32_t cmdpacket3(int packet)
+static INLINE uint32_t cmdr500fp(int addr, int count, int type, int clamp)
+{
+       drm_r300_cmd_header_t cmd;
+
+       cmd.r500fp.cmd_type = R300_CMD_R500FP;
+       cmd.r500fp.count = count;
+       cmd.r500fp.adrhi_flags = ((unsigned int)addr & 0x100) >> 8;
+       cmd.r500fp.adrhi_flags |= type ? R500FP_CONSTANT_TYPE : 0;
+       cmd.r500fp.adrhi_flags |= clamp ? R500FP_CONSTANT_CLAMP : 0;
+       cmd.r500fp.adrlo = ((unsigned int)addr & 0x00FF);
+
+       return cmd.u;
+}
+
+static INLINE uint32_t cmdpacket3(int packet)
 {
        drm_r300_cmd_header_t cmd;
 
@@ -84,7 +98,7 @@ static inline uint32_t cmdpacket3(int packet)
        return cmd.u;
 }
 
-static inline uint32_t cmdcpdelay(unsigned short count)
+static INLINE uint32_t cmdcpdelay(unsigned short count)
 {
        drm_r300_cmd_header_t cmd;
 
@@ -94,7 +108,7 @@ static inline uint32_t cmdcpdelay(unsigned short count)
        return cmd.u;
 }
 
-static inline uint32_t cmdwait(unsigned char flags)
+static INLINE uint32_t cmdwait(unsigned char flags)
 {
        drm_r300_cmd_header_t cmd;
 
@@ -104,7 +118,7 @@ static inline uint32_t cmdwait(unsigned char flags)
        return cmd.u;
 }
 
-static inline uint32_t cmdpacify(void)
+static INLINE uint32_t cmdpacify(void)
 {
        drm_r300_cmd_header_t cmd;
 
@@ -166,6 +180,19 @@ static inline uint32_t cmdpacify(void)
                cmd[0].i = cmdvpu((dest), _n/4);                        \
        } while (0);
 
+#define r500fp_start_fragment(dest, length)                            \
+       do {                                                            \
+               int _n;                                                 \
+               _n = (length);                                          \
+               cmd = (drm_radeon_cmd_header_t*)                        \
+                       r300AllocCmdBuf(rmesa,                          \
+                                       (_n+1),                         \
+                                       __FUNCTION__);                  \
+               cmd_reserved = _n+1;                                    \
+               cmd_written =1;                                         \
+               cmd[0].i = cmdr500fp((dest), _n/6, 0, 0);               \
+       } while (0);
+
 #define start_packet3(packet, count)                                   \
        {                                                               \
                int _n;                                                 \
@@ -191,7 +218,7 @@ static inline uint32_t cmdpacify(void)
 /**
  * Must be sent to switch to 2d commands
  */
-void static inline end_3d(r300ContextPtr rmesa)
+void static INLINE end_3d(r300ContextPtr rmesa)
 {
        drm_radeon_cmd_header_t *cmd = NULL;
 
@@ -200,7 +227,7 @@ void static inline end_3d(r300ContextPtr rmesa)
        cmd[0].header.cmd_type = R300_CMD_END3D;
 }
 
-void static inline cp_delay(r300ContextPtr rmesa, unsigned short count)
+void static INLINE cp_delay(r300ContextPtr rmesa, unsigned short count)
 {
        drm_radeon_cmd_header_t *cmd = NULL;
 
@@ -209,7 +236,7 @@ void static inline cp_delay(r300ContextPtr rmesa, unsigned short count)
        cmd[0].i = cmdcpdelay(count);
 }
 
-void static inline cp_wait(r300ContextPtr rmesa, unsigned char flags)
+void static INLINE cp_wait(r300ContextPtr rmesa, unsigned char flags)
 {
        drm_radeon_cmd_header_t *cmd = NULL;
 
@@ -230,6 +257,8 @@ extern int r300NumVerts(r300ContextPtr rmesa, int num_verts, int prim);
 
 extern void r300EmitCacheFlush(r300ContextPtr rmesa);
 
+extern GLuint r300VAPInputRoute0(uint32_t * dst, GLvector4f ** attribptr,
+                                int *inputs, GLint * tab, GLuint nr);
 extern GLuint r300VAPInputRoute1(uint32_t * dst, int swizzle[][4], GLuint nr);
 extern GLuint r300VAPInputCntl0(GLcontext * ctx, GLuint InputsRead);
 extern GLuint r300VAPInputCntl1(GLcontext * ctx, GLuint InputsRead);
index cce8e685865f0b64c1fca00093df5ebab1fcbc01..453dda74312b6e47d4eac43c616d9be8987d3523 100644 (file)
 /**
  * \file
  *
- * \author Ben Skeggs <darktama@iinet.net.au>
+ * Fragment program compiler. Perform transformations on the intermediate
+ * representation until the program is in a form where we can translate
+ * it more or less directly into machine-readable form.
  *
+ * \author Ben Skeggs <darktama@iinet.net.au>
  * \author Jerome Glisse <j.glisse@gmail.com>
- *
- * \todo Depth write, WPOS/FOGC inputs
- *
- * \todo FogOption
- *
- * \todo Verify results of opcodes for accuracy, I've only checked them in
- * specific cases.
  */
 
 #include "glheader.h"
 
 #include "r300_context.h"
 #include "r300_fragprog.h"
-#include "r300_reg.h"
+#include "r300_fragprog_swizzle.h"
 #include "r300_state.h"
 
-/*
- * Usefull macros and values
- */
-#define ERROR(fmt, args...) do {                       \
-               fprintf(stderr, "%s::%s(): " fmt "\n",  \
-                       __FILE__, __FUNCTION__, ##args);        \
-               fp->error = GL_TRUE;                    \
-       } while(0)
-
-#define PFS_INVAL 0xFFFFFFFF
-#define COMPILE_STATE struct r300_pfs_compile_state *cs = fp->cs
-
-#define SWIZZLE_XYZ            0
-#define SWIZZLE_XXX            1
-#define SWIZZLE_YYY            2
-#define SWIZZLE_ZZZ            3
-#define SWIZZLE_WWW            4
-#define SWIZZLE_YZX            5
-#define SWIZZLE_ZXY            6
-#define SWIZZLE_WZY            7
-#define SWIZZLE_111            8
-#define SWIZZLE_000            9
-#define SWIZZLE_HHH            10
-
-#define swizzle(r, x, y, z, w) do_swizzle(fp, r,               \
-                                         ((SWIZZLE_##x<<0)|    \
-                                          (SWIZZLE_##y<<3)|    \
-                                          (SWIZZLE_##z<<6)|    \
-                                          (SWIZZLE_##w<<9)),   \
-                                         0)
-
-#define REG_TYPE_INPUT         0
-#define REG_TYPE_OUTPUT                1
-#define REG_TYPE_TEMP          2
-#define REG_TYPE_CONST         3
-
-#define REG_TYPE_SHIFT         0
-#define REG_INDEX_SHIFT                2
-#define REG_VSWZ_SHIFT         8
-#define REG_SSWZ_SHIFT         13
-#define REG_NEGV_SHIFT         18
-#define REG_NEGS_SHIFT         19
-#define REG_ABS_SHIFT          20
-#define REG_NO_USE_SHIFT       21      // Hack for refcounting
-#define REG_VALID_SHIFT                22      // Does the register contain a defined value?
-#define REG_BUILTIN_SHIFT   23 // Is it a builtin (like all zero/all one)?
-
-#define REG_TYPE_MASK          (0x03 << REG_TYPE_SHIFT)
-#define REG_INDEX_MASK         (0x3F << REG_INDEX_SHIFT)
-#define REG_VSWZ_MASK          (0x1F << REG_VSWZ_SHIFT)
-#define REG_SSWZ_MASK          (0x1F << REG_SSWZ_SHIFT)
-#define REG_NEGV_MASK          (0x01 << REG_NEGV_SHIFT)
-#define REG_NEGS_MASK          (0x01 << REG_NEGS_SHIFT)
-#define REG_ABS_MASK           (0x01 << REG_ABS_SHIFT)
-#define REG_NO_USE_MASK                (0x01 << REG_NO_USE_SHIFT)
-#define REG_VALID_MASK         (0x01 << REG_VALID_SHIFT)
-#define REG_BUILTIN_MASK       (0x01 << REG_BUILTIN_SHIFT)
-
-#define REG(type, index, vswz, sswz, nouse, valid, builtin)    \
-       (((type << REG_TYPE_SHIFT) & REG_TYPE_MASK) |                   \
-        ((index << REG_INDEX_SHIFT) & REG_INDEX_MASK) |                \
-        ((nouse << REG_NO_USE_SHIFT) & REG_NO_USE_MASK) |              \
-        ((valid << REG_VALID_SHIFT) & REG_VALID_MASK) |                \
-        ((builtin << REG_BUILTIN_SHIFT) & REG_BUILTIN_MASK) |  \
-        ((vswz << REG_VSWZ_SHIFT) & REG_VSWZ_MASK) |                   \
-        ((sswz << REG_SSWZ_SHIFT) & REG_SSWZ_MASK))
-#define REG_GET_TYPE(reg)                                              \
-       ((reg & REG_TYPE_MASK) >> REG_TYPE_SHIFT)
-#define REG_GET_INDEX(reg)                                             \
-       ((reg & REG_INDEX_MASK) >> REG_INDEX_SHIFT)
-#define REG_GET_VSWZ(reg)                                              \
-       ((reg & REG_VSWZ_MASK) >> REG_VSWZ_SHIFT)
-#define REG_GET_SSWZ(reg)                                              \
-       ((reg & REG_SSWZ_MASK) >> REG_SSWZ_SHIFT)
-#define REG_GET_NO_USE(reg)                                            \
-       ((reg & REG_NO_USE_MASK) >> REG_NO_USE_SHIFT)
-#define REG_GET_VALID(reg)                                             \
-       ((reg & REG_VALID_MASK) >> REG_VALID_SHIFT)
-#define REG_GET_BUILTIN(reg)                                           \
-       ((reg & REG_BUILTIN_MASK) >> REG_BUILTIN_SHIFT)
-#define REG_SET_TYPE(reg, type)                                                \
-       reg = ((reg & ~REG_TYPE_MASK) |                                 \
-              ((type << REG_TYPE_SHIFT) & REG_TYPE_MASK))
-#define REG_SET_INDEX(reg, index)                                      \
-       reg = ((reg & ~REG_INDEX_MASK) |                                \
-              ((index << REG_INDEX_SHIFT) & REG_INDEX_MASK))
-#define REG_SET_VSWZ(reg, vswz)                                                \
-       reg = ((reg & ~REG_VSWZ_MASK) |                                 \
-              ((vswz << REG_VSWZ_SHIFT) & REG_VSWZ_MASK))
-#define REG_SET_SSWZ(reg, sswz)                                                \
-       reg = ((reg & ~REG_SSWZ_MASK) |                                 \
-              ((sswz << REG_SSWZ_SHIFT) & REG_SSWZ_MASK))
-#define REG_SET_NO_USE(reg, nouse)                                     \
-       reg = ((reg & ~REG_NO_USE_MASK) |                               \
-              ((nouse << REG_NO_USE_SHIFT) & REG_NO_USE_MASK))
-#define REG_SET_VALID(reg, valid)                                      \
-       reg = ((reg & ~REG_VALID_MASK) |                                \
-              ((valid << REG_VALID_SHIFT) & REG_VALID_MASK))
-#define REG_SET_BUILTIN(reg, builtin)                                  \
-       reg = ((reg & ~REG_BUILTIN_MASK) |                              \
-              ((builtin << REG_BUILTIN_SHIFT) & REG_BUILTIN_MASK))
-#define REG_ABS(reg)                                                   \
-       reg = (reg | REG_ABS_MASK)
-#define REG_NEGV(reg)                                                  \
-       reg = (reg | REG_NEGV_MASK)
-#define REG_NEGS(reg)                                                  \
-       reg = (reg | REG_NEGS_MASK)
-
-/*
- * Datas structures for fragment program generation
- */
-
-/* description of r300 native hw instructions */
-static const struct {
-       const char *name;
-       int argc;
-       int v_op;
-       int s_op;
-} r300_fpop[] = {
-       /* *INDENT-OFF* */
-       {"MAD", 3, R300_FPI0_OUTC_MAD, R300_FPI2_OUTA_MAD},
-       {"DP3", 2, R300_FPI0_OUTC_DP3, R300_FPI2_OUTA_DP4},
-       {"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},
-       {"CMPH", 3, R300_FPI0_OUTC_CMPH, PFS_INVAL},
-       /* *INDENT-ON* */
-};
-
-/* vector swizzles r300 can support natively, with a couple of
- * cases we handle specially
- *
- * REG_VSWZ/REG_SSWZ is an index into this table
- */
-
-/* mapping from SWIZZLE_* to r300 native values for scalar insns */
-#define SWIZZLE_HALF 6
-
-#define MAKE_SWZ3(x, y, z) (MAKE_SWIZZLE4(SWIZZLE_##x, \
-                                         SWIZZLE_##y, \
-                                         SWIZZLE_##z, \
-                                         SWIZZLE_ZERO))
-/* native swizzles */
-static const struct r300_pfs_swizzle {
-       GLuint hash;            /* swizzle value this matches */
-       GLuint base;            /* base value for hw swizzle */
-       GLuint stride;          /* difference in base between arg0/1/2 */
-       GLuint flags;
-} v_swiz[] = {
-       /* *INDENT-OFF* */
-       {MAKE_SWZ3(X, Y, Z), R300_FPI0_ARGC_SRC0C_XYZ, 4, SLOT_SRC_VECTOR},
-       {MAKE_SWZ3(X, X, X), R300_FPI0_ARGC_SRC0C_XXX, 4, SLOT_SRC_VECTOR},
-       {MAKE_SWZ3(Y, Y, Y), R300_FPI0_ARGC_SRC0C_YYY, 4, SLOT_SRC_VECTOR},
-       {MAKE_SWZ3(Z, Z, Z), R300_FPI0_ARGC_SRC0C_ZZZ, 4, SLOT_SRC_VECTOR},
-       {MAKE_SWZ3(W, W, W), R300_FPI0_ARGC_SRC0A, 1, SLOT_SRC_SCALAR},
-       {MAKE_SWZ3(Y, Z, X), R300_FPI0_ARGC_SRC0C_YZX, 1, SLOT_SRC_VECTOR},
-       {MAKE_SWZ3(Z, X, Y), R300_FPI0_ARGC_SRC0C_ZXY, 1, SLOT_SRC_VECTOR},
-       {MAKE_SWZ3(W, Z, Y), R300_FPI0_ARGC_SRC0CA_WZY, 1, SLOT_SRC_BOTH},
-       {MAKE_SWZ3(ONE, ONE, ONE), R300_FPI0_ARGC_ONE, 0, 0},
-       {MAKE_SWZ3(ZERO, ZERO, ZERO), R300_FPI0_ARGC_ZERO, 0, 0},
-       {MAKE_SWZ3(HALF, HALF, HALF), R300_FPI0_ARGC_HALF, 0, 0},
-       {PFS_INVAL, 0, 0, 0},
-       /* *INDENT-ON* */
-};
-
-/* used during matching of non-native swizzles */
-#define SWZ_X_MASK (7 << 0)
-#define SWZ_Y_MASK (7 << 3)
-#define SWZ_Z_MASK (7 << 6)
-#define SWZ_W_MASK (7 << 9)
-static const struct {
-       GLuint hash;            /* used to mask matching swizzle components */
-       int mask;               /* actual outmask */
-       int count;              /* count of components matched */
-} s_mask[] = {
-       /* *INDENT-OFF* */
-       {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}
-       /* *INDENT-ON* */
-};
-
-static const struct {
-       int base;               /* hw value of swizzle */
-       int stride;             /* difference between SRC0/1/2 */
-       GLuint flags;
-} s_swiz[] = {
-       /* *INDENT-OFF* */
-       {R300_FPI2_ARGA_SRC0C_X, 3, SLOT_SRC_VECTOR},
-       {R300_FPI2_ARGA_SRC0C_Y, 3, SLOT_SRC_VECTOR},
-       {R300_FPI2_ARGA_SRC0C_Z, 3, SLOT_SRC_VECTOR},
-       {R300_FPI2_ARGA_SRC0A, 1, SLOT_SRC_SCALAR},
-       {R300_FPI2_ARGA_ZERO, 0, 0},
-       {R300_FPI2_ARGA_ONE, 0, 0},
-       {R300_FPI2_ARGA_HALF, 0, 0}
-       /* *INDENT-ON* */
-};
-
-/* boiler-plate reg, for convenience */
-static const GLuint undef = REG(REG_TYPE_TEMP,
-                               0,
-                               SWIZZLE_XYZ,
-                               SWIZZLE_W,
-                               GL_FALSE,
-                               GL_FALSE,
-                               GL_FALSE);
-
-/* constant one source */
-static const GLuint pfs_one = REG(REG_TYPE_CONST,
-                                 0,
-                                 SWIZZLE_111,
-                                 SWIZZLE_ONE,
-                                 GL_FALSE,
-                                 GL_TRUE,
-                                 GL_TRUE);
-
-/* constant half source */
-static const GLuint pfs_half = REG(REG_TYPE_CONST,
-                                  0,
-                                  SWIZZLE_HHH,
-                                  SWIZZLE_HALF,
-                                  GL_FALSE,
-                                  GL_TRUE,
-                                  GL_TRUE);
-
-/* constant zero source */
-static const GLuint pfs_zero = REG(REG_TYPE_CONST,
-                                  0,
-                                  SWIZZLE_000,
-                                  SWIZZLE_ZERO,
-                                  GL_FALSE,
-                                  GL_TRUE,
-                                  GL_TRUE);
+#include "radeon_nqssadce.h"
+#include "radeon_program_alu.h"
 
-/*
- * Common functions prototypes
- */
-static void dump_program(struct r300_fragment_program *fp);
-static void emit_arith(struct r300_fragment_program *fp, int op,
-                      GLuint dest, int mask,
-                      GLuint src0, GLuint src1, GLuint src2, int flags);
 
-/**
- * Get an R300 temporary that can be written to in the given slot.
- */
-static int get_hw_temp(struct r300_fragment_program *fp, int slot)
+static void reset_srcreg(struct prog_src_register* reg)
 {
-       COMPILE_STATE;
-       int r;
-
-       for (r = 0; r < PFS_NUM_TEMP_REGS; ++r) {
-               if (cs->hwtemps[r].free >= 0 && cs->hwtemps[r].free <= slot)
-                       break;
-       }
-
-       if (r >= PFS_NUM_TEMP_REGS) {
-               ERROR("Out of hardware temps\n");
-               return 0;
-       }
-       // Reserved is used to avoid the following scenario:
-       //  R300 temporary X is first assigned to Mesa temporary Y during vector ops
-       //  R300 temporary X is then assigned to Mesa temporary Z for further vector ops
-       //  Then scalar ops on Mesa temporary Z are emitted and move back in time
-       //  to overwrite the value of temporary Y.
-       // End scenario.
-       cs->hwtemps[r].reserved = cs->hwtemps[r].free;
-       cs->hwtemps[r].free = -1;
-
-       // Reset to some value that won't mess things up when the user
-       // tries to read from a temporary that hasn't been assigned a value yet.
-       // In the normal case, vector_valid and scalar_valid should be set to
-       // a sane value by the first emit that writes to this temporary.
-       cs->hwtemps[r].vector_valid = 0;
-       cs->hwtemps[r].scalar_valid = 0;
-
-       if (r > fp->max_temp_idx)
-               fp->max_temp_idx = r;
-
-       return r;
+       _mesa_bzero(reg, sizeof(*reg));
+       reg->Swizzle = SWIZZLE_NOOP;
 }
 
-/**
- * Get an R300 temporary that will act as a TEX destination register.
- */
-static int get_hw_temp_tex(struct r300_fragment_program *fp)
+static struct prog_src_register shadow_ambient(struct gl_program *program, int tmu)
 {
-       COMPILE_STATE;
-       int r;
-
-       for (r = 0; r < PFS_NUM_TEMP_REGS; ++r) {
-               if (cs->used_in_node & (1 << r))
-                       continue;
-
-               // Note: Be very careful here
-               if (cs->hwtemps[r].free >= 0 && cs->hwtemps[r].free <= 0)
-                       break;
-       }
-
-       if (r >= PFS_NUM_TEMP_REGS)
-               return get_hw_temp(fp, 0);      /* Will cause an indirection */
-
-       cs->hwtemps[r].reserved = cs->hwtemps[r].free;
-       cs->hwtemps[r].free = -1;
-
-       // Reset to some value that won't mess things up when the user
-       // tries to read from a temporary that hasn't been assigned a value yet.
-       // In the normal case, vector_valid and scalar_valid should be set to
-       // a sane value by the first emit that writes to this temporary.
-       cs->hwtemps[r].vector_valid = cs->nrslots;
-       cs->hwtemps[r].scalar_valid = cs->nrslots;
-
-       if (r > fp->max_temp_idx)
-               fp->max_temp_idx = r;
-
-       return r;
-}
-
-/**
- * Mark the given hardware register as free.
- */
-static void free_hw_temp(struct r300_fragment_program *fp, int idx)
-{
-       COMPILE_STATE;
-
-       // Be very careful here. Consider sequences like
-       //  MAD r0, r1,r2,r3
-       //  TEX r4, ...
-       // The TEX instruction may be moved in front of the MAD instruction
-       // due to the way nodes work. We don't want to alias r1 and r4 in
-       // this case.
-       // I'm certain the register allocation could be further sanitized,
-       // but it's tricky because of stuff that can happen inside emit_tex
-       // and emit_arith.
-       cs->hwtemps[idx].free = cs->nrslots + 1;
-}
-
-/**
- * Create a new Mesa temporary register.
- */
-static GLuint get_temp_reg(struct r300_fragment_program *fp)
-{
-       COMPILE_STATE;
-       GLuint r = undef;
-       GLuint index;
-
-       index = ffs(~cs->temp_in_use);
-       if (!index) {
-               ERROR("Out of program temps\n");
-               return r;
-       }
-
-       cs->temp_in_use |= (1 << --index);
-       cs->temps[index].refcount = 0xFFFFFFFF;
-       cs->temps[index].reg = -1;
-
-       REG_SET_TYPE(r, REG_TYPE_TEMP);
-       REG_SET_INDEX(r, index);
-       REG_SET_VALID(r, GL_TRUE);
-       return r;
-}
-
-/**
- * Create a new Mesa temporary register that will act as the destination
- * register for a texture read.
- */
-static GLuint get_temp_reg_tex(struct r300_fragment_program *fp)
-{
-       COMPILE_STATE;
-       GLuint r = undef;
-       GLuint index;
-
-       index = ffs(~cs->temp_in_use);
-       if (!index) {
-               ERROR("Out of program temps\n");
-               return r;
-       }
-
-       cs->temp_in_use |= (1 << --index);
-       cs->temps[index].refcount = 0xFFFFFFFF;
-       cs->temps[index].reg = get_hw_temp_tex(fp);
-
-       REG_SET_TYPE(r, REG_TYPE_TEMP);
-       REG_SET_INDEX(r, index);
-       REG_SET_VALID(r, GL_TRUE);
-       return r;
-}
-
-/**
- * Free a Mesa temporary and the associated R300 temporary.
- */
-static void free_temp(struct r300_fragment_program *fp, GLuint r)
-{
-       COMPILE_STATE;
-       GLuint index = REG_GET_INDEX(r);
-
-       if (!(cs->temp_in_use & (1 << index)))
-               return;
+       gl_state_index fail_value_tokens[STATE_LENGTH] = {
+               STATE_INTERNAL, STATE_SHADOW_AMBIENT, 0, 0, 0
+       };
+       struct prog_src_register reg = { 0, };
 
-       if (REG_GET_TYPE(r) == REG_TYPE_TEMP) {
-               free_hw_temp(fp, cs->temps[index].reg);
-               cs->temps[index].reg = -1;
-               cs->temp_in_use &= ~(1 << index);
-       } else if (REG_GET_TYPE(r) == REG_TYPE_INPUT) {
-               free_hw_temp(fp, cs->inputs[index].reg);
-               cs->inputs[index].reg = -1;
-       }
+       fail_value_tokens[2] = tmu;
+       reg.File = PROGRAM_STATE_VAR;
+       reg.Index = _mesa_add_state_reference(program->Parameters, fail_value_tokens);
+       reg.Swizzle = SWIZZLE_WWWW;
+       return reg;
 }
 
 /**
- * Emit a hardware constant/parameter.
+ * Transform TEX, TXP, TXB, and KIL instructions in the following way:
+ *  - premultiply texture coordinates for RECT
+ *  - extract operand swizzles
+ *  - introduce a temporary register when write masks are needed
  *
- * \p cp Stable pointer to an array of 4 floats.
- *  The pointer must be stable in the sense that it remains to be valid
- *  and hold the contents of the constant/parameter throughout the lifetime
- *  of the fragment program (actually, up until the next time the fragment
- *  program is translated).
- */
-static GLuint emit_const4fv(struct r300_fragment_program *fp,
-                           const GLfloat * cp)
-{
-       GLuint reg = undef;
-       int index;
-
-       for (index = 0; index < fp->const_nr; ++index) {
-               if (fp->constant[index] == cp)
-                       break;
-       }
-
-       if (index >= fp->const_nr) {
-               if (index >= PFS_NUM_CONST_REGS) {
-                       ERROR("Out of hw constants!\n");
-                       return reg;
-               }
-
-               fp->const_nr++;
-               fp->constant[index] = cp;
-       }
-
-       REG_SET_TYPE(reg, REG_TYPE_CONST);
-       REG_SET_INDEX(reg, index);
-       REG_SET_VALID(reg, GL_TRUE);
-       return reg;
-}
-
-static inline GLuint negate(GLuint r)
-{
-       REG_NEGS(r);
-       REG_NEGV(r);
-       return r;
-}
-
-/* Hack, to prevent clobbering sources used multiple times when
- * emulating non-native instructions
+ * \todo If/when r5xx uses the radeon_program architecture, this can probably
+ * be reused.
  */
-static inline GLuint keep(GLuint r)
-{
-       REG_SET_NO_USE(r, GL_TRUE);
-       return r;
-}
-
-static inline GLuint absolute(GLuint r)
+static GLboolean transform_TEX(
+       struct radeon_transform_context *t,
+       struct prog_instruction* orig_inst, void* data)
 {
-       REG_ABS(r);
-       return r;
-}
-
-static int swz_native(struct r300_fragment_program *fp,
-                     GLuint src, GLuint * r, GLuint arbneg)
-{
-       /* Native swizzle, handle negation */
-       src = (src & ~REG_NEGS_MASK) | (((arbneg >> 3) & 1) << REG_NEGS_SHIFT);
-
-       if ((arbneg & 0x7) == 0x0) {
-               src = src & ~REG_NEGV_MASK;
-               *r = src;
-       } else if ((arbneg & 0x7) == 0x7) {
-               src |= REG_NEGV_MASK;
-               *r = src;
-       } else {
-               if (!REG_GET_VALID(*r))
-                       *r = get_temp_reg(fp);
-               src |= REG_NEGV_MASK;
-               emit_arith(fp,
-                          PFS_OP_MAD,
-                          *r, arbneg & 0x7, keep(src), pfs_one, pfs_zero, 0);
-               src = src & ~REG_NEGV_MASK;
-               emit_arith(fp,
-                          PFS_OP_MAD,
-                          *r,
-                          (arbneg ^ 0x7) | WRITEMASK_W,
-                          src, pfs_one, pfs_zero, 0);
-       }
-
-       return 3;
-}
-
-static int swz_emit_partial(struct r300_fragment_program *fp,
-                           GLuint src,
-                           GLuint * r, int mask, int mc, GLuint arbneg)
-{
-       GLuint tmp;
-       GLuint wmask = 0;
-
-       if (!REG_GET_VALID(*r))
-               *r = get_temp_reg(fp);
-
-       /* A partial match, VSWZ/mask define what parts of the
-        * desired swizzle we match
-        */
-       if (mc + s_mask[mask].count == 3) {
-               wmask = WRITEMASK_W;
-               src |= ((arbneg >> 3) & 1) << REG_NEGS_SHIFT;
-       }
-
-       tmp = arbneg & s_mask[mask].mask;
-       if (tmp) {
-               tmp = tmp ^ s_mask[mask].mask;
-               if (tmp) {
-                       emit_arith(fp,
-                                  PFS_OP_MAD,
-                                  *r,
-                                  arbneg & s_mask[mask].mask,
-                                  keep(src) | REG_NEGV_MASK,
-                                  pfs_one, pfs_zero, 0);
-                       if (!wmask) {
-                               REG_SET_NO_USE(src, GL_TRUE);
-                       } else {
-                               REG_SET_NO_USE(src, GL_FALSE);
-                       }
-                       emit_arith(fp,
-                                  PFS_OP_MAD,
-                                  *r, tmp | wmask, src, pfs_one, pfs_zero, 0);
-               } else {
-                       if (!wmask) {
-                               REG_SET_NO_USE(src, GL_TRUE);
-                       } else {
-                               REG_SET_NO_USE(src, GL_FALSE);
-                       }
-                       emit_arith(fp,
-                                  PFS_OP_MAD,
-                                  *r,
-                                  (arbneg & s_mask[mask].mask) | wmask,
-                                  src | REG_NEGV_MASK, pfs_one, pfs_zero, 0);
-               }
-       } else {
-               if (!wmask) {
-                       REG_SET_NO_USE(src, GL_TRUE);
-               } else {
-                       REG_SET_NO_USE(src, GL_FALSE);
-               }
-               emit_arith(fp, PFS_OP_MAD,
-                          *r,
-                          s_mask[mask].mask | wmask,
-                          src, pfs_one, pfs_zero, 0);
-       }
-
-       return s_mask[mask].count;
-}
-
-static GLuint do_swizzle(struct r300_fragment_program *fp,
-                        GLuint src, GLuint arbswz, GLuint arbneg)
-{
-       GLuint r = undef;
-       GLuint vswz;
-       int c_mask = 0;
-       int v_match = 0;
-
-       /* If swizzling from something without an XYZW native swizzle,
-        * emit result to a temp, and do new swizzle from the temp.
-        */
-#if 0
-       if (REG_GET_VSWZ(src) != SWIZZLE_XYZ || REG_GET_SSWZ(src) != SWIZZLE_W) {
-               GLuint temp = get_temp_reg(fp);
-               emit_arith(fp,
-                          PFS_OP_MAD,
-                          temp, WRITEMASK_XYZW, src, pfs_one, pfs_zero, 0);
-               src = temp;
-       }
-#endif
-
-       if (REG_GET_VSWZ(src) != SWIZZLE_XYZ || REG_GET_SSWZ(src) != SWIZZLE_W) {
-               GLuint vsrcswz =
-                   (v_swiz[REG_GET_VSWZ(src)].
-                    hash & (SWZ_X_MASK | SWZ_Y_MASK | SWZ_Z_MASK)) |
-                   REG_GET_SSWZ(src) << 9;
-               GLint i;
-
-               GLuint newswz = 0;
-               GLuint offset;
-               for (i = 0; i < 4; ++i) {
-                       offset = GET_SWZ(arbswz, i);
-
-                       newswz |=
-                           (offset <= 3) ? GET_SWZ(vsrcswz,
-                                                   offset) << i *
-                           3 : offset << i * 3;
-               }
-
-               arbswz = newswz & (SWZ_X_MASK | SWZ_Y_MASK | SWZ_Z_MASK);
-               REG_SET_SSWZ(src, GET_SWZ(newswz, 3));
-       } else {
-               /* set scalar swizzling */
-               REG_SET_SSWZ(src, GET_SWZ(arbswz, 3));
-
-       }
-       do {
-               vswz = REG_GET_VSWZ(src);
-               do {
-                       int chash;
-
-                       REG_SET_VSWZ(src, vswz);
-                       chash = v_swiz[REG_GET_VSWZ(src)].hash &
-                           s_mask[c_mask].hash;
-
-                       if (chash == (arbswz & s_mask[c_mask].hash)) {
-                               if (s_mask[c_mask].count == 3) {
-                                       v_match += swz_native(fp,
-                                                             src, &r, arbneg);
-                               } else {
-                                       v_match += swz_emit_partial(fp,
-                                                                   src,
-                                                                   &r,
-                                                                   c_mask,
-                                                                   v_match,
-                                                                   arbneg);
-                               }
-
-                               if (v_match == 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[++vswz].hash != PFS_INVAL);
-               REG_SET_VSWZ(src, SWIZZLE_XYZ);
-       } while (s_mask[++c_mask].hash != PFS_INVAL);
-
-       ERROR("should NEVER get here\n");
-       return r;
-}
-
-static GLuint t_src(struct r300_fragment_program *fp,
-                   struct prog_src_register fpsrc)
-{
-       GLuint r = undef;
-
-       switch (fpsrc.File) {
-       case PROGRAM_TEMPORARY:
-               REG_SET_INDEX(r, fpsrc.Index);
-               REG_SET_VALID(r, GL_TRUE);
-               REG_SET_TYPE(r, REG_TYPE_TEMP);
-               break;
-       case PROGRAM_INPUT:
-               REG_SET_INDEX(r, fpsrc.Index);
-               REG_SET_VALID(r, GL_TRUE);
-               REG_SET_TYPE(r, REG_TYPE_INPUT);
-               break;
-       case PROGRAM_LOCAL_PARAM:
-               r = emit_const4fv(fp,
-                                 fp->mesa_program.Base.LocalParams[fpsrc.
-                                                                   Index]);
-               break;
-       case PROGRAM_ENV_PARAM:
-               r = emit_const4fv(fp,
-                                 fp->ctx->FragmentProgram.Parameters[fpsrc.
-                                                                     Index]);
-               break;
-       case PROGRAM_STATE_VAR:
-       case PROGRAM_NAMED_PARAM:
-               r = emit_const4fv(fp,
-                                 fp->mesa_program.Base.Parameters->
-                                 ParameterValues[fpsrc.Index]);
-               break;
-       default:
-               ERROR("unknown SrcReg->File %x\n", fpsrc.File);
-               return r;
-       }
-
-       /* no point swizzling ONE/ZERO/HALF constants... */
-       if (REG_GET_VSWZ(r) < SWIZZLE_111 || REG_GET_SSWZ(r) < SWIZZLE_ZERO)
-               r = do_swizzle(fp, r, fpsrc.Swizzle, fpsrc.NegateBase);
-       return r;
-}
-
-static GLuint t_scalar_src(struct r300_fragment_program *fp,
-                          struct prog_src_register fpsrc)
-{
-       struct prog_src_register src = fpsrc;
-       int sc = GET_SWZ(fpsrc.Swizzle, 0);     /* X */
-
-       src.Swizzle = ((sc << 0) | (sc << 3) | (sc << 6) | (sc << 9));
-
-       return t_src(fp, src);
-}
-
-static GLuint t_dst(struct r300_fragment_program *fp,
-                   struct prog_dst_register dest)
-{
-       GLuint r = undef;
-
-       switch (dest.File) {
-       case PROGRAM_TEMPORARY:
-               REG_SET_INDEX(r, dest.Index);
-               REG_SET_VALID(r, GL_TRUE);
-               REG_SET_TYPE(r, REG_TYPE_TEMP);
-               return r;
-       case PROGRAM_OUTPUT:
-               REG_SET_TYPE(r, REG_TYPE_OUTPUT);
-               switch (dest.Index) {
-               case FRAG_RESULT_COLR:
-               case FRAG_RESULT_DEPR:
-                       REG_SET_INDEX(r, dest.Index);
-                       REG_SET_VALID(r, GL_TRUE);
-                       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 int t_hw_src(struct r300_fragment_program *fp, GLuint src, GLboolean tex)
-{
-       COMPILE_STATE;
-       int idx;
-       int index = REG_GET_INDEX(src);
-
-       switch (REG_GET_TYPE(src)) {
-       case REG_TYPE_TEMP:
-               /* NOTE: if reg==-1 here, a source is being read that
-                *       hasn't been written to. Undefined results.
-                */
-               if (cs->temps[index].reg == -1)
-                       cs->temps[index].reg = get_hw_temp(fp, cs->nrslots);
-
-               idx = cs->temps[index].reg;
-
-               if (!REG_GET_NO_USE(src) && (--cs->temps[index].refcount == 0))
-                       free_temp(fp, src);
-               break;
-       case REG_TYPE_INPUT:
-               idx = cs->inputs[index].reg;
-
-               if (!REG_GET_NO_USE(src) && (--cs->inputs[index].refcount == 0))
-                       free_hw_temp(fp, cs->inputs[index].reg);
-               break;
-       case REG_TYPE_CONST:
-               return (index | SRC_CONST);
-       default:
-               ERROR("Invalid type for source reg\n");
-               return (0 | SRC_CONST);
-       }
+       struct r300_fragment_program_compiler *compiler =
+               (struct r300_fragment_program_compiler*)data;
+       struct prog_instruction inst = *orig_inst;
+       struct prog_instruction* tgt;
+       GLboolean destredirect = GL_FALSE;
+
+       if (inst.Opcode != OPCODE_TEX &&
+           inst.Opcode != OPCODE_TXB &&
+           inst.Opcode != OPCODE_TXP &&
+           inst.Opcode != OPCODE_KIL)
+               return GL_FALSE;
 
-       if (!tex)
-               cs->used_in_node |= (1 << idx);
+       if (inst.Opcode != OPCODE_KIL &&
+           t->Program->ShadowSamplers & (1 << inst.TexSrcUnit)) {
+               GLuint comparefunc = GL_NEVER + compiler->fp->state.unit[inst.TexSrcUnit].texture_compare_func;
 
-       return idx;
-}
+               if (comparefunc == GL_NEVER || comparefunc == GL_ALWAYS) {
+                       tgt = radeonAppendInstructions(t->Program, 1);
 
-static int t_hw_dst(struct r300_fragment_program *fp,
-                   GLuint dest, GLboolean tex, int slot)
-{
-       COMPILE_STATE;
-       int idx;
-       GLuint index = REG_GET_INDEX(dest);
-       assert(REG_GET_VALID(dest));
-
-       switch (REG_GET_TYPE(dest)) {
-       case REG_TYPE_TEMP:
-               if (cs->temps[REG_GET_INDEX(dest)].reg == -1) {
-                       if (!tex) {
-                               cs->temps[index].reg = get_hw_temp(fp, slot);
+                       tgt->Opcode = OPCODE_MOV;
+                       tgt->DstReg = inst.DstReg;
+                       if (comparefunc == GL_ALWAYS) {
+                               tgt->SrcReg[0].File = PROGRAM_BUILTIN;
+                               tgt->SrcReg[0].Swizzle = SWIZZLE_1111;
                        } else {
-                               cs->temps[index].reg = get_hw_temp_tex(fp);
+                               tgt->SrcReg[0] = shadow_ambient(t->Program, inst.TexSrcUnit);
                        }
+                       return GL_TRUE;
                }
-               idx = cs->temps[index].reg;
-
-               if (!REG_GET_NO_USE(dest) && (--cs->temps[index].refcount == 0))
-                       free_temp(fp, dest);
-
-               cs->dest_in_node |= (1 << idx);
-               cs->used_in_node |= (1 << idx);
-               break;
-       case REG_TYPE_OUTPUT:
-               switch (index) {
-               case FRAG_RESULT_COLR:
-                       fp->node[fp->cur_node].flags |=
-                           R300_PFS_NODE_OUTPUT_COLOR;
-                       break;
-               case FRAG_RESULT_DEPR:
-                       fp->node[fp->cur_node].flags |=
-                           R300_PFS_NODE_OUTPUT_DEPTH;
-                       break;
-               }
-               return index;
-               break;
-       default:
-               ERROR("invalid dest reg type %d\n", REG_GET_TYPE(dest));
-               return 0;
-       }
 
-       return idx;
-}
-
-static void emit_nop(struct r300_fragment_program *fp)
-{
-       COMPILE_STATE;
-
-       if (cs->nrslots >= PFS_MAX_ALU_INST) {
-               ERROR("Out of ALU instruction slots\n");
-               return;
+               inst.DstReg.File = PROGRAM_TEMPORARY;
+               inst.DstReg.Index = radeonFindFreeTemporary(t);
+               inst.DstReg.WriteMask = WRITEMASK_XYZW;
        }
 
-       fp->alu.inst[cs->nrslots].inst0 = NOP_INST0;
-       fp->alu.inst[cs->nrslots].inst1 = NOP_INST1;
-       fp->alu.inst[cs->nrslots].inst2 = NOP_INST2;
-       fp->alu.inst[cs->nrslots].inst3 = NOP_INST3;
-       cs->nrslots++;
-}
-
-static void emit_tex(struct r300_fragment_program *fp,
-                    struct prog_instruction *fpi, int opcode)
-{
-       COMPILE_STATE;
-       GLuint coord = t_src(fp, fpi->SrcReg[0]);
-       GLuint dest = undef, rdest = undef;
-       GLuint din, uin;
-       int unit = fpi->TexSrcUnit;
-       int hwsrc, hwdest;
-       GLuint tempreg = 0;
-
-       uin = cs->used_in_node;
-       din = cs->dest_in_node;
-
-       /* Resolve source/dest to hardware registers */
-       if (opcode != R300_FPITX_OP_KIL) {
-               if (fpi->TexSrcTarget == TEXTURE_RECT_INDEX) {
-                       /**
-                        * Hardware uses [0..1]x[0..1] range for rectangle textures
-                        * instead of [0..Width]x[0..Height].
-                        * Add a scaling instruction.
-                        *
-                        * \todo Refactor this once we have proper rewriting/optimization
-                        * support for programs.
-                        */
-                       gl_state_index tokens[STATE_LENGTH] = {
-                               STATE_INTERNAL, STATE_R300_TEXRECT_FACTOR, 0, 0,
-                               0
-                       };
-                       int factor_index;
-                       GLuint factorreg;
-
-                       tokens[2] = unit;
-                       factor_index =
-                           _mesa_add_state_reference(fp->mesa_program.Base.
-                                                     Parameters, tokens);
-                       factorreg =
-                           emit_const4fv(fp,
-                                         fp->mesa_program.Base.Parameters->
-                                         ParameterValues[factor_index]);
-                       tempreg = keep(get_temp_reg(fp));
-
-                       emit_arith(fp, PFS_OP_MAD, tempreg, WRITEMASK_XYZW,
-                                  coord, factorreg, pfs_zero, 0);
-
-                       /* Ensure correct node indirection */
-                       uin = cs->used_in_node;
-                       din = cs->dest_in_node;
-
-                       hwsrc = t_hw_src(fp, tempreg, GL_TRUE);
-               } else {
-                       hwsrc = t_hw_src(fp, coord, GL_TRUE);
-               }
-
-               dest = t_dst(fp, fpi->DstReg);
 
-               /* r300 doesn't seem to be able to do TEX->output reg */
-               if (REG_GET_TYPE(dest) == REG_TYPE_OUTPUT) {
-                       rdest = dest;
-                       dest = get_temp_reg_tex(fp);
-               }
-               hwdest =
-                   t_hw_dst(fp, dest, GL_TRUE,
-                            fp->node[fp->cur_node].alu_offset);
-
-               /* Use a temp that hasn't been used in this node, rather
-                * than causing an indirection
-                */
-               if (uin & (1 << hwdest)) {
-                       free_hw_temp(fp, hwdest);
-                       hwdest = get_hw_temp_tex(fp);
-                       cs->temps[REG_GET_INDEX(dest)].reg = hwdest;
-               }
-       } else {
-               hwdest = 0;
-               unit = 0;
-               hwsrc = t_hw_src(fp, coord, GL_TRUE);
-       }
-
-       /* Indirection if source has been written in this node, or if the
-        * dest has been read/written in this node
+       /* Hardware uses [0..1]x[0..1] range for rectangle textures
+        * instead of [0..Width]x[0..Height].
+        * Add a scaling instruction.
         */
-       if ((REG_GET_TYPE(coord) != REG_TYPE_CONST &&
-            (din & (1 << hwsrc))) || (uin & (1 << hwdest))) {
-
-               /* Finish off current node */
-               if (fp->node[fp->cur_node].alu_offset == cs->nrslots)
-                       emit_nop(fp);
-
-               fp->node[fp->cur_node].alu_end =
-                   cs->nrslots - fp->node[fp->cur_node].alu_offset - 1;
-               assert(fp->node[fp->cur_node].alu_end >= 0);
-
-               if (++fp->cur_node >= PFS_MAX_TEX_INDIRECT) {
-                       ERROR("too many levels of texture indirection\n");
-                       return;
-               }
-
-               /* Start new node */
-               fp->node[fp->cur_node].tex_offset = fp->tex.length;
-               fp->node[fp->cur_node].alu_offset = cs->nrslots;
-               fp->node[fp->cur_node].tex_end = -1;
-               fp->node[fp->cur_node].alu_end = -1;
-               fp->node[fp->cur_node].flags = 0;
-               cs->used_in_node = 0;
-               cs->dest_in_node = 0;
-       }
+       if (inst.Opcode != OPCODE_KIL && inst.TexSrcTarget == TEXTURE_RECT_INDEX) {
+               gl_state_index tokens[STATE_LENGTH] = {
+                       STATE_INTERNAL, STATE_R300_TEXRECT_FACTOR, 0, 0,
+                       0
+               };
 
-       if (fp->cur_node == 0)
-               fp->first_node_has_tex = 1;
+               int tempreg = radeonFindFreeTemporary(t);
+               int factor_index;
 
-       fp->tex.inst[fp->tex.length++] = 0 | (hwsrc << R300_FPITX_SRC_SHIFT)
-           | (hwdest << R300_FPITX_DST_SHIFT)
-           | (unit << R300_FPITX_IMAGE_SHIFT)
-           /* not entirely sure about this */
-           | (opcode << R300_FPITX_OPCODE_SHIFT);
+               tokens[2] = inst.TexSrcUnit;
+               factor_index = _mesa_add_state_reference(t->Program->Parameters, tokens);
 
-       cs->dest_in_node |= (1 << hwdest);
-       if (REG_GET_TYPE(coord) != REG_TYPE_CONST)
-               cs->used_in_node |= (1 << hwsrc);
+               tgt = radeonAppendInstructions(t->Program, 1);
 
-       fp->node[fp->cur_node].tex_end++;
+               tgt->Opcode = OPCODE_MUL;
+               tgt->DstReg.File = PROGRAM_TEMPORARY;
+               tgt->DstReg.Index = tempreg;
+               tgt->SrcReg[0] = inst.SrcReg[0];
+               tgt->SrcReg[1].File = PROGRAM_STATE_VAR;
+               tgt->SrcReg[1].Index = factor_index;
 
-       /* Copy from temp to output if needed */
-       if (REG_GET_VALID(rdest)) {
-               emit_arith(fp, PFS_OP_MAD, rdest, WRITEMASK_XYZW, dest,
-                          pfs_one, pfs_zero, 0);
-               free_temp(fp, dest);
+               reset_srcreg(&inst.SrcReg[0]);
+               inst.SrcReg[0].File = PROGRAM_TEMPORARY;
+               inst.SrcReg[0].Index = tempreg;
        }
 
-       /* Free temp register */
-       if (tempreg != 0)
-               free_temp(fp, tempreg);
-}
-
-/**
- * Returns the first slot where we could possibly allow writing to dest,
- * according to register allocation.
- */
-static int get_earliest_allowed_write(struct r300_fragment_program *fp,
-                                     GLuint dest, int mask)
-{
-       COMPILE_STATE;
-       int idx;
-       int pos;
-       GLuint index = REG_GET_INDEX(dest);
-       assert(REG_GET_VALID(dest));
-
-       switch (REG_GET_TYPE(dest)) {
-       case REG_TYPE_TEMP:
-               if (cs->temps[index].reg == -1)
-                       return 0;
-
-               idx = cs->temps[index].reg;
-               break;
-       case REG_TYPE_OUTPUT:
-               return 0;
-       default:
-               ERROR("invalid dest reg type %d\n", REG_GET_TYPE(dest));
-               return 0;
-       }
-
-       pos = cs->hwtemps[idx].reserved;
-       if (mask & WRITEMASK_XYZ) {
-               if (pos < cs->hwtemps[idx].vector_lastread)
-                       pos = cs->hwtemps[idx].vector_lastread;
-       }
-       if (mask & WRITEMASK_W) {
-               if (pos < cs->hwtemps[idx].scalar_lastread)
-                       pos = cs->hwtemps[idx].scalar_lastread;
-       }
-
-       return pos;
-}
+       if (inst.Opcode != OPCODE_KIL) {
+               if (inst.DstReg.File != PROGRAM_TEMPORARY ||
+                   inst.DstReg.WriteMask != WRITEMASK_XYZW) {
+                       int tempreg = radeonFindFreeTemporary(t);
 
-/**
- * Allocates a slot for an ALU instruction that can consist of
- * a vertex part or a scalar part or both.
- *
- * Sources from src (src[0] to src[argc-1]) are added to the slot in the
- * appropriate position (vector and/or scalar), and their positions are
- * recorded in the srcpos array.
- *
- * This function emits instruction code for the source fetch and the
- * argument selection. It does not emit instruction code for the
- * opcode or the destination selection.
- *
- * @return the index of the slot
- */
-static int find_and_prepare_slot(struct r300_fragment_program *fp,
-                                GLboolean emit_vop,
-                                GLboolean emit_sop,
-                                int argc, GLuint * src, GLuint dest, int mask)
-{
-       COMPILE_STATE;
-       int hwsrc[3];
-       int srcpos[3];
-       unsigned int used;
-       int tempused;
-       int tempvsrc[3];
-       int tempssrc[3];
-       int pos;
-       int regnr;
-       int i, j;
-
-       // Determine instruction slots, whether sources are required on
-       // vector or scalar side, and the smallest slot number where
-       // all source registers are available
-       used = 0;
-       if (emit_vop)
-               used |= SLOT_OP_VECTOR;
-       if (emit_sop)
-               used |= SLOT_OP_SCALAR;
-
-       pos = get_earliest_allowed_write(fp, dest, mask);
-
-       if (fp->node[fp->cur_node].alu_offset > pos)
-               pos = fp->node[fp->cur_node].alu_offset;
-       for (i = 0; i < argc; ++i) {
-               if (!REG_GET_BUILTIN(src[i])) {
-                       if (emit_vop)
-                               used |= v_swiz[REG_GET_VSWZ(src[i])].flags << i;
-                       if (emit_sop)
-                               used |= s_swiz[REG_GET_SSWZ(src[i])].flags << i;
-               }
-
-               hwsrc[i] = t_hw_src(fp, src[i], GL_FALSE);      /* Note: sideeffects wrt refcounting! */
-               regnr = hwsrc[i] & 31;
-
-               if (REG_GET_TYPE(src[i]) == REG_TYPE_TEMP) {
-                       if (used & (SLOT_SRC_VECTOR << i)) {
-                               if (cs->hwtemps[regnr].vector_valid > pos)
-                                       pos = cs->hwtemps[regnr].vector_valid;
-                       }
-                       if (used & (SLOT_SRC_SCALAR << i)) {
-                               if (cs->hwtemps[regnr].scalar_valid > pos)
-                                       pos = cs->hwtemps[regnr].scalar_valid;
-                       }
+                       inst.DstReg.File = PROGRAM_TEMPORARY;
+                       inst.DstReg.Index = tempreg;
+                       inst.DstReg.WriteMask = WRITEMASK_XYZW;
+                       destredirect = GL_TRUE;
                }
        }
 
-       // Find a slot that fits
-       for (;; ++pos) {
-               if (cs->slot[pos].used & used & SLOT_OP_BOTH)
-                       continue;
-
-               if (pos >= cs->nrslots) {
-                       if (cs->nrslots >= PFS_MAX_ALU_INST) {
-                               ERROR("Out of ALU instruction slots\n");
-                               return -1;
-                       }
-
-                       fp->alu.inst[pos].inst0 = NOP_INST0;
-                       fp->alu.inst[pos].inst1 = NOP_INST1;
-                       fp->alu.inst[pos].inst2 = NOP_INST2;
-                       fp->alu.inst[pos].inst3 = NOP_INST3;
-
-                       cs->nrslots++;
-               }
-               // Note: When we need both parts (vector and scalar) of a source,
-               // we always try to put them into the same position. This makes the
-               // code easier to read, and it is optimal (i.e. one doesn't gain
-               // anything by splitting the parts).
-               // It also avoids headaches with swizzles that access both parts (i.e WXY)
-               tempused = cs->slot[pos].used;
-               for (i = 0; i < 3; ++i) {
-                       tempvsrc[i] = cs->slot[pos].vsrc[i];
-                       tempssrc[i] = cs->slot[pos].ssrc[i];
-               }
-
-               for (i = 0; i < argc; ++i) {
-                       int flags = (used >> i) & SLOT_SRC_BOTH;
-
-                       if (!flags) {
-                               srcpos[i] = 0;
-                               continue;
-                       }
-
-                       for (j = 0; j < 3; ++j) {
-                               if ((tempused >> j) & flags & SLOT_SRC_VECTOR) {
-                                       if (tempvsrc[j] != hwsrc[i])
-                                               continue;
-                               }
-
-                               if ((tempused >> j) & flags & SLOT_SRC_SCALAR) {
-                                       if (tempssrc[j] != hwsrc[i])
-                                               continue;
-                               }
-
-                               break;
-                       }
-
-                       if (j == 3)
-                               break;
-
-                       srcpos[i] = j;
-                       tempused |= flags << j;
-                       if (flags & SLOT_SRC_VECTOR)
-                               tempvsrc[j] = hwsrc[i];
-                       if (flags & SLOT_SRC_SCALAR)
-                               tempssrc[j] = hwsrc[i];
-               }
-
-               if (i == argc)
-                       break;
-       }
-
-       // Found a slot, reserve it
-       cs->slot[pos].used = tempused | (used & SLOT_OP_BOTH);
-       for (i = 0; i < 3; ++i) {
-               cs->slot[pos].vsrc[i] = tempvsrc[i];
-               cs->slot[pos].ssrc[i] = tempssrc[i];
-       }
-
-       for (i = 0; i < argc; ++i) {
-               if (REG_GET_TYPE(src[i]) == REG_TYPE_TEMP) {
-                       int regnr = hwsrc[i] & 31;
-
-                       if (used & (SLOT_SRC_VECTOR << i)) {
-                               if (cs->hwtemps[regnr].vector_lastread < pos)
-                                       cs->hwtemps[regnr].vector_lastread =
-                                           pos;
-                       }
-                       if (used & (SLOT_SRC_SCALAR << i)) {
-                               if (cs->hwtemps[regnr].scalar_lastread < pos)
-                                       cs->hwtemps[regnr].scalar_lastread =
-                                           pos;
-                       }
-               }
-       }
-
-       // Emit the source fetch code
-       fp->alu.inst[pos].inst1 &= ~R300_FPI1_SRC_MASK;
-       fp->alu.inst[pos].inst1 |=
-           ((cs->slot[pos].vsrc[0] << R300_FPI1_SRC0C_SHIFT) |
-            (cs->slot[pos].vsrc[1] << R300_FPI1_SRC1C_SHIFT) |
-            (cs->slot[pos].vsrc[2] << R300_FPI1_SRC2C_SHIFT));
-
-       fp->alu.inst[pos].inst3 &= ~R300_FPI3_SRC_MASK;
-       fp->alu.inst[pos].inst3 |=
-           ((cs->slot[pos].ssrc[0] << R300_FPI3_SRC0A_SHIFT) |
-            (cs->slot[pos].ssrc[1] << R300_FPI3_SRC1A_SHIFT) |
-            (cs->slot[pos].ssrc[2] << R300_FPI3_SRC2A_SHIFT));
-
-       // Emit the argument selection code
-       if (emit_vop) {
-               int swz[3];
-
-               for (i = 0; i < 3; ++i) {
-                       if (i < argc) {
-                               swz[i] = (v_swiz[REG_GET_VSWZ(src[i])].base +
-                                         (srcpos[i] *
-                                          v_swiz[REG_GET_VSWZ(src[i])].
-                                          stride)) | ((src[i] & REG_NEGV_MASK)
-                                                      ? ARG_NEG : 0) | ((src[i]
-                                                                         &
-                                                                         REG_ABS_MASK)
-                                                                        ?
-                                                                        ARG_ABS
-                                                                        : 0);
-                       } else {
-                               swz[i] = R300_FPI0_ARGC_ZERO;
-                       }
-               }
-
-               fp->alu.inst[pos].inst0 &=
-                   ~(R300_FPI0_ARG0C_MASK | R300_FPI0_ARG1C_MASK |
-                     R300_FPI0_ARG2C_MASK);
-               fp->alu.inst[pos].inst0 |=
-                   (swz[0] << R300_FPI0_ARG0C_SHIFT) | (swz[1] <<
-                                                        R300_FPI0_ARG1C_SHIFT)
-                   | (swz[2] << R300_FPI0_ARG2C_SHIFT);
-       }
-
-       if (emit_sop) {
-               int swz[3];
-
-               for (i = 0; i < 3; ++i) {
-                       if (i < argc) {
-                               swz[i] = (s_swiz[REG_GET_SSWZ(src[i])].base +
-                                         (srcpos[i] *
-                                          s_swiz[REG_GET_SSWZ(src[i])].
-                                          stride)) | ((src[i] & REG_NEGV_MASK)
-                                                      ? ARG_NEG : 0) | ((src[i]
-                                                                         &
-                                                                         REG_ABS_MASK)
-                                                                        ?
-                                                                        ARG_ABS
-                                                                        : 0);
-                       } else {
-                               swz[i] = R300_FPI2_ARGA_ZERO;
-                       }
-               }
-
-               fp->alu.inst[pos].inst2 &=
-                   ~(R300_FPI2_ARG0A_MASK | R300_FPI2_ARG1A_MASK |
-                     R300_FPI2_ARG2A_MASK);
-               fp->alu.inst[pos].inst2 |=
-                   (swz[0] << R300_FPI2_ARG0A_SHIFT) | (swz[1] <<
-                                                        R300_FPI2_ARG1A_SHIFT)
-                   | (swz[2] << R300_FPI2_ARG2A_SHIFT);
-       }
-
-       return pos;
-}
-
-/**
- * Append an ALU instruction to the instruction list.
- */
-static void emit_arith(struct r300_fragment_program *fp,
-                      int op,
-                      GLuint dest,
-                      int mask,
-                      GLuint src0, GLuint src1, GLuint src2, int flags)
-{
-       COMPILE_STATE;
-       GLuint src[3] = { src0, src1, src2 };
-       int hwdest;
-       GLboolean emit_vop, emit_sop;
-       int vop, sop, argc;
-       int pos;
-
-       vop = r300_fpop[op].v_op;
-       sop = r300_fpop[op].s_op;
-       argc = r300_fpop[op].argc;
-
-       if (REG_GET_TYPE(dest) == REG_TYPE_OUTPUT &&
-           REG_GET_INDEX(dest) == FRAG_RESULT_DEPR) {
-               if (mask & WRITEMASK_Z) {
-                       mask = WRITEMASK_W;
-               } else {
-                       return;
-               }
-       }
-
-       emit_vop = GL_FALSE;
-       emit_sop = GL_FALSE;
-       if ((mask & WRITEMASK_XYZ) || vop == R300_FPI0_OUTC_DP3)
-               emit_vop = GL_TRUE;
-       if ((mask & WRITEMASK_W) || vop == R300_FPI0_OUTC_REPL_ALPHA)
-               emit_sop = GL_TRUE;
-
-       pos =
-           find_and_prepare_slot(fp, emit_vop, emit_sop, argc, src, dest,
-                                 mask);
-       if (pos < 0)
-               return;
-
-       hwdest = t_hw_dst(fp, dest, GL_FALSE, pos);     /* Note: Side effects wrt register allocation */
-
-       if (flags & PFS_FLAG_SAT) {
-               vop |= R300_FPI0_OUTC_SAT;
-               sop |= R300_FPI2_OUTA_SAT;
-       }
-
-       /* Throw the pieces together and get FPI0/1 */
-       if (emit_vop) {
-               fp->alu.inst[pos].inst0 |= vop;
+       tgt = radeonAppendInstructions(t->Program, 1);
+       _mesa_copy_instructions(tgt, &inst, 1);
+
+       if (inst.Opcode != OPCODE_KIL &&
+           t->Program->ShadowSamplers & (1 << inst.TexSrcUnit)) {
+               GLuint comparefunc = GL_NEVER + compiler->fp->state.unit[inst.TexSrcUnit].texture_compare_func;
+               GLuint depthmode = compiler->fp->state.unit[inst.TexSrcUnit].depth_texture_mode;
+               int rcptemp = radeonFindFreeTemporary(t);
+               int pass, fail;
+
+               tgt = radeonAppendInstructions(t->Program, 3);
+
+               tgt[0].Opcode = OPCODE_RCP;
+               tgt[0].DstReg.File = PROGRAM_TEMPORARY;
+               tgt[0].DstReg.Index = rcptemp;
+               tgt[0].DstReg.WriteMask = WRITEMASK_W;
+               tgt[0].SrcReg[0] = inst.SrcReg[0];
+               tgt[0].SrcReg[0].Swizzle = SWIZZLE_WWWW;
+
+               tgt[1].Opcode = OPCODE_MAD;
+               tgt[1].DstReg = inst.DstReg;
+               tgt[1].DstReg.WriteMask = orig_inst->DstReg.WriteMask;
+               tgt[1].SrcReg[0] = inst.SrcReg[0];
+               tgt[1].SrcReg[0].Swizzle = SWIZZLE_ZZZZ;
+               tgt[1].SrcReg[1].File = PROGRAM_TEMPORARY;
+               tgt[1].SrcReg[1].Index = rcptemp;
+               tgt[1].SrcReg[1].Swizzle = SWIZZLE_WWWW;
+               tgt[1].SrcReg[2].File = PROGRAM_TEMPORARY;
+               tgt[1].SrcReg[2].Index = inst.DstReg.Index;
+               if (depthmode == 0) /* GL_LUMINANCE */
+                       tgt[1].SrcReg[2].Swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z);
+               else if (depthmode == 2) /* GL_ALPHA */
+                       tgt[1].SrcReg[2].Swizzle = SWIZZLE_WWWW;
+
+               /* Recall that SrcReg[0] is tex, SrcReg[2] is r and:
+                *   r  < tex  <=>      -tex+r < 0
+                *   r >= tex  <=> not (-tex+r < 0 */
+               if (comparefunc == GL_LESS || comparefunc == GL_GEQUAL)
+                       tgt[1].SrcReg[2].NegateBase = tgt[0].SrcReg[2].NegateBase ^ NEGATE_XYZW;
+               else
+                       tgt[1].SrcReg[0].NegateBase = tgt[0].SrcReg[0].NegateBase ^ NEGATE_XYZW;
 
-               fp->alu.inst[pos].inst1 |= hwdest << R300_FPI1_DSTC_SHIFT;
+               tgt[2].Opcode = OPCODE_CMP;
+               tgt[2].DstReg = orig_inst->DstReg;
+               tgt[2].SrcReg[0].File = PROGRAM_TEMPORARY;
+               tgt[2].SrcReg[0].Index = tgt[1].DstReg.Index;
 
-               if (REG_GET_TYPE(dest) == REG_TYPE_OUTPUT) {
-                       if (REG_GET_INDEX(dest) == FRAG_RESULT_COLR) {
-                               fp->alu.inst[pos].inst1 |=
-                                   (mask & WRITEMASK_XYZ) <<
-                                   R300_FPI1_DSTC_OUTPUT_MASK_SHIFT;
-                       } else
-                               assert(0);
+               if (comparefunc == GL_LESS || comparefunc == GL_GREATER) {
+                       pass = 1;
+                       fail = 2;
                } else {
-                       fp->alu.inst[pos].inst1 |=
-                           (mask & WRITEMASK_XYZ) <<
-                           R300_FPI1_DSTC_REG_MASK_SHIFT;
-
-                       cs->hwtemps[hwdest].vector_valid = pos + 1;
+                       pass = 2;
+                       fail = 1;
                }
-       }
 
-       /* And now FPI2/3 */
-       if (emit_sop) {
-               fp->alu.inst[pos].inst2 |= sop;
-
-               if (mask & WRITEMASK_W) {
-                       if (REG_GET_TYPE(dest) == REG_TYPE_OUTPUT) {
-                               if (REG_GET_INDEX(dest) == FRAG_RESULT_COLR) {
-                                       fp->alu.inst[pos].inst3 |=
-                                           (hwdest << R300_FPI3_DSTA_SHIFT) |
-                                           R300_FPI3_DSTA_OUTPUT;
-                               } else if (REG_GET_INDEX(dest) ==
-                                          FRAG_RESULT_DEPR) {
-                                       fp->alu.inst[pos].inst3 |=
-                                           R300_FPI3_DSTA_DEPTH;
-                               } else
-                                       assert(0);
-                       } else {
-                               fp->alu.inst[pos].inst3 |=
-                                   (hwdest << R300_FPI3_DSTA_SHIFT) |
-                                   R300_FPI3_DSTA_REG;
+               tgt[2].SrcReg[pass].File = PROGRAM_BUILTIN;
+               tgt[2].SrcReg[pass].Swizzle = SWIZZLE_1111;
+               tgt[2].SrcReg[fail] = shadow_ambient(t->Program, inst.TexSrcUnit);
+       } else if (destredirect) {
+               tgt = radeonAppendInstructions(t->Program, 1);
 
-                               cs->hwtemps[hwdest].scalar_valid = pos + 1;
-                       }
-               }
+               tgt->Opcode = OPCODE_MOV;
+               tgt->DstReg = orig_inst->DstReg;
+               tgt->SrcReg[0].File = PROGRAM_TEMPORARY;
+               tgt->SrcReg[0].Index = inst.DstReg.Index;
        }
 
-       return;
+       return GL_TRUE;
 }
 
-#if 0
-static GLuint get_attrib(struct r300_fragment_program *fp, GLuint attr)
+
+static void update_params(r300ContextPtr r300, struct r300_fragment_program *fp)
 {
        struct gl_fragment_program *mp = &fp->mesa_program;
-       GLuint r = undef;
-
-       if (!(mp->Base.InputsRead & (1 << attr))) {
-               ERROR("Attribute %d was not provided!\n", attr);
-               return undef;
-       }
 
-       REG_SET_TYPE(r, REG_TYPE_INPUT);
-       REG_SET_INDEX(r, attr);
-       REG_SET_VALID(r, GL_TRUE);
-       return r;
+       /* Ask Mesa nicely to fill in ParameterValues for us */
+       if (mp->Base.Parameters)
+               _mesa_load_state_parameters(r300->radeon.glCtx, mp->Base.Parameters);
 }
-#endif
-
-static GLfloat SinCosConsts[2][4] = {
-       {
-        1.273239545,           // 4/PI
-        -0.405284735,          // -4/(PI*PI)
-        3.141592654,           // PI
-        0.2225                 // weight
-        },
-       {
-        0.75,
-        0.0,
-        0.159154943,           // 1/(2*PI)
-        6.283185307            // 2*PI
-        }
-};
+
 
 /**
- * Emit a LIT instruction.
- * \p flags may be PFS_FLAG_SAT
+ * Transform the program to support fragment.position.
  *
- * Definition of LIT (from ARB_fragment_program):
- * tmp = VectorLoad(op0);
- * if (tmp.x < 0) tmp.x = 0;
- * if (tmp.y < 0) tmp.y = 0;
- * if (tmp.w < -(128.0-epsilon)) tmp.w = -(128.0-epsilon);
- * else if (tmp.w > 128-epsilon) tmp.w = 128-epsilon;
- * result.x = 1.0;
- * result.y = tmp.x;
- * result.z = (tmp.x > 0) ? RoughApproxPower(tmp.y, tmp.w) : 0.0;
- * result.w = 1.0;
+ * Introduce a small fragment at the start of the program that will be
+ * the only code that directly reads the FRAG_ATTRIB_WPOS input.
+ * All other code pieces that reference that input will be rewritten
+ * to read from a newly allocated temporary.
  *
- * The longest path of computation is the one leading to result.z,
- * consisting of 5 operations. This implementation of LIT takes
- * 5 slots. So unless there's some special undocumented opcode,
- * this implementation is potentially optimal. Unfortunately,
- * emit_arith is a bit too conservative because it doesn't understand
- * partial writes to the vector component.
+ * \todo if/when r5xx supports the radeon_program architecture, this is a
+ * likely candidate for code sharing.
  */
-static const GLfloat LitConst[4] =
-    { 127.999999, 127.999999, 127.999999, -127.999999 };
-
-static void emit_lit(struct r300_fragment_program *fp,
-                    GLuint dest, int mask, GLuint src, int flags)
+static void insert_WPOS_trailer(struct r300_fragment_program_compiler *compiler)
 {
-       COMPILE_STATE;
-       GLuint cnst;
-       int needTemporary;
-       GLuint temp;
-
-       cnst = emit_const4fv(fp, LitConst);
-
-       needTemporary = 0;
-       if ((mask & WRITEMASK_XYZW) != WRITEMASK_XYZW) {
-               needTemporary = 1;
-       } else if (REG_GET_TYPE(dest) == REG_TYPE_OUTPUT) {
-               // LIT is typically followed by DP3/DP4, so there's no point
-               // in creating special code for this case
-               needTemporary = 1;
-       }
-
-       if (needTemporary) {
-               temp = keep(get_temp_reg(fp));
-       } else {
-               temp = keep(dest);
-       }
-
-       // Note: The order of emit_arith inside the slots is relevant,
-       // because emit_arith only looks at scalar vs. vector when resolving
-       // dependencies, and it does not consider individual vector components,
-       // so swizzling between the two parts can create fake dependencies.
-
-       // First slot
-       emit_arith(fp, PFS_OP_MAX, temp, WRITEMASK_XY,
-                  keep(src), pfs_zero, undef, 0);
-       emit_arith(fp, PFS_OP_MAX, temp, WRITEMASK_W, src, cnst, undef, 0);
-
-       // Second slot
-       emit_arith(fp, PFS_OP_MIN, temp, WRITEMASK_Z,
-                  swizzle(temp, W, W, W, W), cnst, undef, 0);
-       emit_arith(fp, PFS_OP_LG2, temp, WRITEMASK_W,
-                  swizzle(temp, Y, Y, Y, Y), undef, undef, 0);
-
-       // Third slot
-       // If desired, we saturate the y result here.
-       // This does not affect the use as a condition variable in the CMP later
-       emit_arith(fp, PFS_OP_MAD, temp, WRITEMASK_W,
-                  temp, swizzle(temp, Z, Z, Z, Z), pfs_zero, 0);
-       emit_arith(fp, PFS_OP_MAD, temp, WRITEMASK_Y,
-                  swizzle(temp, X, X, X, X), pfs_one, pfs_zero, flags);
-
-       // Fourth slot
-       emit_arith(fp, PFS_OP_MAD, temp, WRITEMASK_X,
-                  pfs_one, pfs_one, pfs_zero, 0);
-       emit_arith(fp, PFS_OP_EX2, temp, WRITEMASK_W, temp, undef, undef, 0);
-
-       // Fifth slot
-       emit_arith(fp, PFS_OP_CMP, temp, WRITEMASK_Z,
-                  pfs_zero, swizzle(temp, W, W, W, W),
-                  negate(swizzle(temp, Y, Y, Y, Y)), flags);
-       emit_arith(fp, PFS_OP_MAD, temp, WRITEMASK_W, pfs_one, pfs_one,
-                  pfs_zero, 0);
-
-       if (needTemporary) {
-               emit_arith(fp, PFS_OP_MAD, dest, mask,
-                          temp, pfs_one, pfs_zero, flags);
-               free_temp(fp, temp);
-       } else {
-               // Decrease refcount of the destination
-               t_hw_dst(fp, dest, GL_FALSE, cs->nrslots);
-       }
-}
-
-static GLboolean parse_program(struct r300_fragment_program *fp)
-{
-       struct gl_fragment_program *mp = &fp->mesa_program;
-       const struct prog_instruction *inst = mp->Base.Instructions;
-       struct prog_instruction *fpi;
-       GLuint src[3], dest, temp[2];
-       int flags, mask = 0;
-       int const_sin[2];
-
-       if (!inst || inst[0].Opcode == OPCODE_END) {
-               ERROR("empty program?\n");
-               return GL_FALSE;
-       }
+       GLuint InputsRead = compiler->fp->mesa_program.Base.InputsRead;
 
-       for (fpi = mp->Base.Instructions; fpi->Opcode != OPCODE_END; fpi++) {
-               if (fpi->SaturateMode == SATURATE_ZERO_ONE)
-                       flags = PFS_FLAG_SAT;
-               else
-                       flags = 0;
-
-               if (fpi->Opcode != OPCODE_KIL) {
-                       dest = t_dst(fp, fpi->DstReg);
-                       mask = fpi->DstReg.WriteMask;
-               }
-
-               switch (fpi->Opcode) {
-               case OPCODE_ABS:
-                       src[0] = t_src(fp, fpi->SrcReg[0]);
-                       emit_arith(fp, PFS_OP_MAD, dest, mask,
-                                  absolute(src[0]), pfs_one, pfs_zero, flags);
-                       break;
-               case OPCODE_ADD:
-                       src[0] = t_src(fp, fpi->SrcReg[0]);
-                       src[1] = t_src(fp, fpi->SrcReg[1]);
-                       emit_arith(fp, PFS_OP_MAD, dest, mask,
-                                  src[0], pfs_one, src[1], flags);
-                       break;
-               case OPCODE_CMP:
-                       src[0] = t_src(fp, fpi->SrcReg[0]);
-                       src[1] = t_src(fp, fpi->SrcReg[1]);
-                       src[2] = t_src(fp, fpi->SrcReg[2]);
-                       /* ARB_f_p - if src0.c < 0.0 ? src1.c : src2.c
-                        *    r300 - if src2.c < 0.0 ? src1.c : src0.c
-                        */
-                       emit_arith(fp, PFS_OP_CMP, dest, mask,
-                                  src[2], src[1], src[0], flags);
-                       break;
-               case OPCODE_COS:
-                       /*
-                        * cos using a parabola (see SIN):
-                        * cos(x):
-                        *   x = (x/(2*PI))+0.75
-                        *   x = frac(x)
-                        *   x = (x*2*PI)-PI
-                        *   result = sin(x)
-                        */
-                       temp[0] = get_temp_reg(fp);
-                       const_sin[0] = emit_const4fv(fp, SinCosConsts[0]);
-                       const_sin[1] = emit_const4fv(fp, SinCosConsts[1]);
-                       src[0] = t_scalar_src(fp, fpi->SrcReg[0]);
-
-                       /* add 0.5*PI and do range reduction */
-
-                       emit_arith(fp, PFS_OP_MAD, temp[0], WRITEMASK_X,
-                                  swizzle(src[0], X, X, X, X),
-                                  swizzle(const_sin[1], Z, Z, Z, Z),
-                                  swizzle(const_sin[1], X, X, X, X), 0);
-
-                       emit_arith(fp, PFS_OP_FRC, temp[0], WRITEMASK_X,
-                                  swizzle(temp[0], X, X, X, X),
-                                  undef, undef, 0);
-
-                       emit_arith(fp, PFS_OP_MAD, temp[0], WRITEMASK_Z, swizzle(temp[0], X, X, X, X), swizzle(const_sin[1], W, W, W, W),       //2*PI
-                                  negate(swizzle(const_sin[0], Z, Z, Z, Z)),   //-PI
-                                  0);
-
-                       /* SIN */
-
-                       emit_arith(fp, PFS_OP_MAD, temp[0],
-                                  WRITEMASK_X | WRITEMASK_Y, swizzle(temp[0],
-                                                                     Z, Z, Z,
-                                                                     Z),
-                                  const_sin[0], pfs_zero, 0);
-
-                       emit_arith(fp, PFS_OP_MAD, temp[0], WRITEMASK_X,
-                                  swizzle(temp[0], Y, Y, Y, Y),
-                                  absolute(swizzle(temp[0], Z, Z, Z, Z)),
-                                  swizzle(temp[0], X, X, X, X), 0);
-
-                       emit_arith(fp, PFS_OP_MAD, temp[0], WRITEMASK_Y,
-                                  swizzle(temp[0], X, X, X, X),
-                                  absolute(swizzle(temp[0], X, X, X, X)),
-                                  negate(swizzle(temp[0], X, X, X, X)), 0);
-
-                       emit_arith(fp, PFS_OP_MAD, dest, mask,
-                                  swizzle(temp[0], Y, Y, Y, Y),
-                                  swizzle(const_sin[0], W, W, W, W),
-                                  swizzle(temp[0], X, X, X, X), flags);
-
-                       free_temp(fp, temp[0]);
-                       break;
-               case OPCODE_DP3:
-                       src[0] = t_src(fp, fpi->SrcReg[0]);
-                       src[1] = t_src(fp, fpi->SrcReg[1]);
-                       emit_arith(fp, PFS_OP_DP3, dest, mask,
-                                  src[0], src[1], undef, flags);
-                       break;
-               case OPCODE_DP4:
-                       src[0] = t_src(fp, fpi->SrcReg[0]);
-                       src[1] = t_src(fp, fpi->SrcReg[1]);
-                       emit_arith(fp, PFS_OP_DP4, dest, mask,
-                                  src[0], src[1], undef, flags);
-                       break;
-               case OPCODE_DPH:
-                       src[0] = t_src(fp, fpi->SrcReg[0]);
-                       src[1] = t_src(fp, fpi->SrcReg[1]);
-                       /* src0.xyz1 -> temp
-                        * DP4 dest, temp, src1
-                        */
-#if 0
-                       temp[0] = get_temp_reg(fp);
-                       src[0].s_swz = SWIZZLE_ONE;
-                       emit_arith(fp, PFS_OP_MAD, temp[0], mask,
-                                  src[0], pfs_one, pfs_zero, 0);
-                       emit_arith(fp, PFS_OP_DP4, dest, mask,
-                                  temp[0], src[1], undef, flags);
-                       free_temp(fp, temp[0]);
-#else
-                       emit_arith(fp, PFS_OP_DP4, dest, mask,
-                                  swizzle(src[0], X, Y, Z, ONE), src[1],
-                                  undef, flags);
-#endif
-                       break;
-               case OPCODE_DST:
-                       src[0] = t_src(fp, fpi->SrcReg[0]);
-                       src[1] = t_src(fp, fpi->SrcReg[1]);
-                       /* dest.y = src0.y * src1.y */
-                       if (mask & WRITEMASK_Y)
-                               emit_arith(fp, PFS_OP_MAD, dest, WRITEMASK_Y,
-                                          keep(src[0]), keep(src[1]),
-                                          pfs_zero, flags);
-                       /* dest.z = src0.z */
-                       if (mask & WRITEMASK_Z)
-                               emit_arith(fp, PFS_OP_MAD, dest, WRITEMASK_Z,
-                                          src[0], pfs_one, pfs_zero, flags);
-                       /* result.x = 1.0
-                        * result.w = src1.w */
-                       if (mask & WRITEMASK_XW) {
-                               REG_SET_VSWZ(src[1], SWIZZLE_111);      /*Cheat */
-                               emit_arith(fp, PFS_OP_MAD, dest,
-                                          mask & WRITEMASK_XW,
-                                          src[1], pfs_one, pfs_zero, flags);
-                       }
-                       break;
-               case OPCODE_EX2:
-                       src[0] = t_scalar_src(fp, fpi->SrcReg[0]);
-                       emit_arith(fp, PFS_OP_EX2, dest, mask,
-                                  src[0], undef, undef, flags);
-                       break;
-               case OPCODE_FLR:
-                       src[0] = t_src(fp, fpi->SrcReg[0]);
-                       temp[0] = get_temp_reg(fp);
-                       /* FRC temp, src0
-                        * MAD dest, src0, 1.0, -temp
-                        */
-                       emit_arith(fp, PFS_OP_FRC, temp[0], mask,
-                                  keep(src[0]), undef, undef, 0);
-                       emit_arith(fp, PFS_OP_MAD, dest, mask,
-                                  src[0], pfs_one, negate(temp[0]), flags);
-                       free_temp(fp, temp[0]);
-                       break;
-               case OPCODE_FRC:
-                       src[0] = t_src(fp, fpi->SrcReg[0]);
-                       emit_arith(fp, PFS_OP_FRC, dest, mask,
-                                  src[0], undef, undef, flags);
-                       break;
-               case OPCODE_KIL:
-                       emit_tex(fp, fpi, R300_FPITX_OP_KIL);
-                       break;
-               case OPCODE_LG2:
-                       src[0] = t_scalar_src(fp, fpi->SrcReg[0]);
-                       emit_arith(fp, PFS_OP_LG2, dest, mask,
-                                  src[0], undef, undef, flags);
-                       break;
-               case OPCODE_LIT:
-                       src[0] = t_src(fp, fpi->SrcReg[0]);
-                       emit_lit(fp, dest, mask, src[0], flags);
-                       break;
-               case OPCODE_LRP:
-                       src[0] = t_src(fp, fpi->SrcReg[0]);
-                       src[1] = t_src(fp, fpi->SrcReg[1]);
-                       src[2] = t_src(fp, fpi->SrcReg[2]);
-                       /* result = tmp0tmp1 + (1 - tmp0)tmp2
-                        *        = tmp0tmp1 + tmp2 + (-tmp0)tmp2
-                        *     MAD temp, -tmp0, tmp2, tmp2
-                        *     MAD result, tmp0, tmp1, temp
-                        */
-                       temp[0] = get_temp_reg(fp);
-                       emit_arith(fp, PFS_OP_MAD, temp[0], mask,
-                                  negate(keep(src[0])), keep(src[2]), src[2],
-                                  0);
-                       emit_arith(fp, PFS_OP_MAD, dest, mask,
-                                  src[0], src[1], temp[0], flags);
-                       free_temp(fp, temp[0]);
-                       break;
-               case OPCODE_MAD:
-                       src[0] = t_src(fp, fpi->SrcReg[0]);
-                       src[1] = t_src(fp, fpi->SrcReg[1]);
-                       src[2] = t_src(fp, fpi->SrcReg[2]);
-                       emit_arith(fp, PFS_OP_MAD, dest, mask,
-                                  src[0], src[1], src[2], flags);
-                       break;
-               case OPCODE_MAX:
-                       src[0] = t_src(fp, fpi->SrcReg[0]);
-                       src[1] = t_src(fp, fpi->SrcReg[1]);
-                       emit_arith(fp, PFS_OP_MAX, dest, mask,
-                                  src[0], src[1], undef, flags);
-                       break;
-               case OPCODE_MIN:
-                       src[0] = t_src(fp, fpi->SrcReg[0]);
-                       src[1] = t_src(fp, fpi->SrcReg[1]);
-                       emit_arith(fp, PFS_OP_MIN, dest, mask,
-                                  src[0], src[1], undef, flags);
-                       break;
-               case OPCODE_MOV:
-               case OPCODE_SWZ:
-                       src[0] = t_src(fp, fpi->SrcReg[0]);
-                       emit_arith(fp, PFS_OP_MAD, dest, mask,
-                                  src[0], pfs_one, pfs_zero, flags);
-                       break;
-               case OPCODE_MUL:
-                       src[0] = t_src(fp, fpi->SrcReg[0]);
-                       src[1] = t_src(fp, fpi->SrcReg[1]);
-                       emit_arith(fp, PFS_OP_MAD, dest, mask,
-                                  src[0], src[1], pfs_zero, flags);
-                       break;
-               case OPCODE_POW:
-                       src[0] = t_scalar_src(fp, fpi->SrcReg[0]);
-                       src[1] = t_scalar_src(fp, fpi->SrcReg[1]);
-                       temp[0] = get_temp_reg(fp);
-                       emit_arith(fp, PFS_OP_LG2, temp[0], WRITEMASK_W,
-                                  src[0], undef, undef, 0);
-                       emit_arith(fp, PFS_OP_MAD, temp[0], WRITEMASK_W,
-                                  temp[0], src[1], pfs_zero, 0);
-                       emit_arith(fp, PFS_OP_EX2, dest, fpi->DstReg.WriteMask,
-                                  temp[0], undef, undef, 0);
-                       free_temp(fp, temp[0]);
-                       break;
-               case OPCODE_RCP:
-                       src[0] = t_scalar_src(fp, fpi->SrcReg[0]);
-                       emit_arith(fp, PFS_OP_RCP, dest, mask,
-                                  src[0], undef, undef, flags);
-                       break;
-               case OPCODE_RSQ:
-                       src[0] = t_scalar_src(fp, fpi->SrcReg[0]);
-                       emit_arith(fp, PFS_OP_RSQ, dest, mask,
-                                  absolute(src[0]), pfs_zero, pfs_zero, flags);
-                       break;
-               case OPCODE_SCS:
-                       /*
-                        * scs using a parabola :
-                        * scs(x):
-                        *   result.x = sin(-abs(x)+0.5*PI)  (cos)
-                        *   result.y = sin(x)               (sin)
-                        *
-                        */
-                       temp[0] = get_temp_reg(fp);
-                       temp[1] = get_temp_reg(fp);
-                       const_sin[0] = emit_const4fv(fp, SinCosConsts[0]);
-                       const_sin[1] = emit_const4fv(fp, SinCosConsts[1]);
-                       src[0] = t_scalar_src(fp, fpi->SrcReg[0]);
-
-                       /* x = -abs(x)+0.5*PI */
-                       emit_arith(fp, PFS_OP_MAD, temp[0], WRITEMASK_Z, swizzle(const_sin[0], Z, Z, Z, Z),     //PI
-                                  pfs_half,
-                                  negate(abs
-                                         (swizzle(keep(src[0]), X, X, X, X))),
-                                  0);
-
-                       /* C*x (sin) */
-                       emit_arith(fp, PFS_OP_MAD, temp[0], WRITEMASK_W,
-                                  swizzle(const_sin[0], Y, Y, Y, Y),
-                                  swizzle(keep(src[0]), X, X, X, X),
-                                  pfs_zero, 0);
-
-                       /* B*x, C*x (cos) */
-                       emit_arith(fp, PFS_OP_MAD, temp[0],
-                                  WRITEMASK_X | WRITEMASK_Y, swizzle(temp[0],
-                                                                     Z, Z, Z,
-                                                                     Z),
-                                  const_sin[0], pfs_zero, 0);
-
-                       /* B*x (sin) */
-                       emit_arith(fp, PFS_OP_MAD, temp[1], WRITEMASK_W,
-                                  swizzle(const_sin[0], X, X, X, X),
-                                  keep(src[0]), pfs_zero, 0);
-
-                       /* y = B*x + C*x*abs(x) (sin) */
-                       emit_arith(fp, PFS_OP_MAD, temp[1], WRITEMASK_Z,
-                                  absolute(src[0]),
-                                  swizzle(temp[0], W, W, W, W),
-                                  swizzle(temp[1], W, W, W, W), 0);
-
-                       /* y = B*x + C*x*abs(x) (cos) */
-                       emit_arith(fp, PFS_OP_MAD, temp[1], WRITEMASK_W,
-                                  swizzle(temp[0], Y, Y, Y, Y),
-                                  absolute(swizzle(temp[0], Z, Z, Z, Z)),
-                                  swizzle(temp[0], X, X, X, X), 0);
-
-                       /* y*abs(y) - y (cos), y*abs(y) - y (sin) */
-                       emit_arith(fp, PFS_OP_MAD, temp[0],
-                                  WRITEMASK_X | WRITEMASK_Y, swizzle(temp[1],
-                                                                     W, Z, Y,
-                                                                     X),
-                                  absolute(swizzle(temp[1], W, Z, Y, X)),
-                                  negate(swizzle(temp[1], W, Z, Y, X)), 0);
-
-                       /* dest.xy = mad(temp.xy, P, temp2.wz) */
-                       emit_arith(fp, PFS_OP_MAD, dest,
-                                  mask & (WRITEMASK_X | WRITEMASK_Y), temp[0],
-                                  swizzle(const_sin[0], W, W, W, W),
-                                  swizzle(temp[1], W, Z, Y, X), flags);
-
-                       free_temp(fp, temp[0]);
-                       free_temp(fp, temp[1]);
-                       break;
-               case OPCODE_SGE:
-                       src[0] = t_src(fp, fpi->SrcReg[0]);
-                       src[1] = t_src(fp, fpi->SrcReg[1]);
-                       temp[0] = get_temp_reg(fp);
-                       /* temp = src0 - src1
-                        * dest.c = (temp.c < 0.0) ? 0 : 1
-                        */
-                       emit_arith(fp, PFS_OP_MAD, temp[0], mask,
-                                  src[0], pfs_one, negate(src[1]), 0);
-                       emit_arith(fp, PFS_OP_CMP, dest, mask,
-                                  pfs_one, pfs_zero, temp[0], 0);
-                       free_temp(fp, temp[0]);
-                       break;
-               case OPCODE_SIN:
-                       /*
-                        *  using a parabola:
-                        * sin(x) = 4/pi * x + -4/(pi*pi) * x * abs(x)
-                        * extra precision is obtained by weighting against
-                        * itself squared.
-                        */
-
-                       temp[0] = get_temp_reg(fp);
-                       const_sin[0] = emit_const4fv(fp, SinCosConsts[0]);
-                       const_sin[1] = emit_const4fv(fp, SinCosConsts[1]);
-                       src[0] = t_scalar_src(fp, fpi->SrcReg[0]);
-
-                       /* do range reduction */
-
-                       emit_arith(fp, PFS_OP_MAD, temp[0], WRITEMASK_X,
-                                  swizzle(keep(src[0]), X, X, X, X),
-                                  swizzle(const_sin[1], Z, Z, Z, Z),
-                                  pfs_half, 0);
-
-                       emit_arith(fp, PFS_OP_FRC, temp[0], WRITEMASK_X,
-                                  swizzle(temp[0], X, X, X, X),
-                                  undef, undef, 0);
-
-                       emit_arith(fp, PFS_OP_MAD, temp[0], WRITEMASK_Z, swizzle(temp[0], X, X, X, X), swizzle(const_sin[1], W, W, W, W),       //2*PI
-                                  negate(swizzle(const_sin[0], Z, Z, Z, Z)),   //PI
-                                  0);
-
-                       /* SIN */
-
-                       emit_arith(fp, PFS_OP_MAD, temp[0],
-                                  WRITEMASK_X | WRITEMASK_Y, swizzle(temp[0],
-                                                                     Z, Z, Z,
-                                                                     Z),
-                                  const_sin[0], pfs_zero, 0);
-
-                       emit_arith(fp, PFS_OP_MAD, temp[0], WRITEMASK_X,
-                                  swizzle(temp[0], Y, Y, Y, Y),
-                                  absolute(swizzle(temp[0], Z, Z, Z, Z)),
-                                  swizzle(temp[0], X, X, X, X), 0);
-
-                       emit_arith(fp, PFS_OP_MAD, temp[0], WRITEMASK_Y,
-                                  swizzle(temp[0], X, X, X, X),
-                                  absolute(swizzle(temp[0], X, X, X, X)),
-                                  negate(swizzle(temp[0], X, X, X, X)), 0);
-
-                       emit_arith(fp, PFS_OP_MAD, dest, mask,
-                                  swizzle(temp[0], Y, Y, Y, Y),
-                                  swizzle(const_sin[0], W, W, W, W),
-                                  swizzle(temp[0], X, X, X, X), flags);
-
-                       free_temp(fp, temp[0]);
-                       break;
-               case OPCODE_SLT:
-                       src[0] = t_src(fp, fpi->SrcReg[0]);
-                       src[1] = t_src(fp, fpi->SrcReg[1]);
-                       temp[0] = get_temp_reg(fp);
-                       /* temp = src0 - src1
-                        * dest.c = (temp.c < 0.0) ? 1 : 0
-                        */
-                       emit_arith(fp, PFS_OP_MAD, temp[0], mask,
-                                  src[0], pfs_one, negate(src[1]), 0);
-                       emit_arith(fp, PFS_OP_CMP, dest, mask,
-                                  pfs_zero, pfs_one, temp[0], 0);
-                       free_temp(fp, temp[0]);
-                       break;
-               case OPCODE_SUB:
-                       src[0] = t_src(fp, fpi->SrcReg[0]);
-                       src[1] = t_src(fp, fpi->SrcReg[1]);
-                       emit_arith(fp, PFS_OP_MAD, dest, mask,
-                                  src[0], pfs_one, negate(src[1]), flags);
-                       break;
-               case OPCODE_TEX:
-                       emit_tex(fp, fpi, R300_FPITX_OP_TEX);
-                       break;
-               case OPCODE_TXB:
-                       emit_tex(fp, fpi, R300_FPITX_OP_TXB);
-                       break;
-               case OPCODE_TXP:
-                       emit_tex(fp, fpi, R300_FPITX_OP_TXP);
-                       break;
-               case OPCODE_XPD:{
-                               src[0] = t_src(fp, fpi->SrcReg[0]);
-                               src[1] = t_src(fp, fpi->SrcReg[1]);
-                               temp[0] = get_temp_reg(fp);
-                               /* temp = src0.zxy * src1.yzx */
-                               emit_arith(fp, PFS_OP_MAD, temp[0],
-                                          WRITEMASK_XYZ, swizzle(keep(src[0]),
-                                                                 Z, X, Y, W),
-                                          swizzle(keep(src[1]), Y, Z, X, W),
-                                          pfs_zero, 0);
-                               /* dest.xyz = src0.yzx * src1.zxy - temp
-                                * dest.w       = undefined
-                                * */
-                               emit_arith(fp, PFS_OP_MAD, dest,
-                                          mask & WRITEMASK_XYZ, swizzle(src[0],
-                                                                        Y, Z,
-                                                                        X, W),
-                                          swizzle(src[1], Z, X, Y, W),
-                                          negate(temp[0]), flags);
-                               /* cleanup */
-                               free_temp(fp, temp[0]);
-                               break;
-                       }
-               default:
-                       ERROR("unknown fpi->Opcode %d\n", fpi->Opcode);
-                       break;
-               }
-
-               if (fp->error)
-                       return GL_FALSE;
-
-       }
-
-       return GL_TRUE;
-}
+       if (!(InputsRead & FRAG_BIT_WPOS))
+               return;
 
-static void insert_wpos(struct gl_program *prog)
-{
        static gl_state_index tokens[STATE_LENGTH] = {
                STATE_INTERNAL, STATE_R300_WINDOW_DIMENSION, 0, 0, 0
        };
        struct prog_instruction *fpi;
        GLuint window_index;
        int i = 0;
-       GLuint tempregi = prog->NumTemporaries;
-       /* should do something else if no temps left... */
-       prog->NumTemporaries++;
+       GLuint tempregi = _mesa_find_free_register(compiler->program, PROGRAM_TEMPORARY);
 
-       fpi = _mesa_alloc_instructions(prog->NumInstructions + 3);
-       _mesa_init_instructions(fpi, prog->NumInstructions + 3);
+       _mesa_insert_instructions(compiler->program, 0, 3);
+       fpi = compiler->program->Instructions;
 
        /* perspective divide */
        fpi[i].Opcode = OPCODE_RCP;
@@ -2027,7 +303,7 @@ static void insert_wpos(struct gl_program *prog)
        i++;
 
        /* viewport transformation */
-       window_index = _mesa_add_state_reference(prog->Parameters, tokens);
+       window_index = _mesa_add_state_reference(compiler->program->Parameters, tokens);
 
        fpi[i].Opcode = OPCODE_MAD;
 
@@ -2052,242 +328,182 @@ static void insert_wpos(struct gl_program *prog)
            MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_ZERO);
        i++;
 
-       _mesa_copy_instructions(&fpi[i], prog->Instructions,
-                               prog->NumInstructions);
-
-       free(prog->Instructions);
-
-       prog->Instructions = fpi;
-
-       prog->NumInstructions += i;
-       fpi = &prog->Instructions[prog->NumInstructions - 1];
-
-       assert(fpi->Opcode == OPCODE_END);
-
-       for (fpi = &prog->Instructions[3]; fpi->Opcode != OPCODE_END; fpi++) {
-               for (i = 0; i < 3; i++)
-                       if (fpi->SrcReg[i].File == PROGRAM_INPUT &&
-                           fpi->SrcReg[i].Index == FRAG_ATTRIB_WPOS) {
-                               fpi->SrcReg[i].File = PROGRAM_TEMPORARY;
-                               fpi->SrcReg[i].Index = tempregi;
+       for (; i < compiler->program->NumInstructions; ++i) {
+               int reg;
+               for (reg = 0; reg < 3; reg++) {
+                       if (fpi[i].SrcReg[reg].File == PROGRAM_INPUT &&
+                           fpi[i].SrcReg[reg].Index == FRAG_ATTRIB_WPOS) {
+                               fpi[i].SrcReg[reg].File = PROGRAM_TEMPORARY;
+                               fpi[i].SrcReg[reg].Index = tempregi;
                        }
+               }
        }
 }
 
-/* - Init structures
- * - Determine what hwregs each input corresponds to
- */
-static void init_program(r300ContextPtr r300, struct r300_fragment_program *fp)
+
+static void nqssadce_init(struct nqssadce_state* s)
 {
-       struct r300_pfs_compile_state *cs = NULL;
-       struct gl_fragment_program *mp = &fp->mesa_program;
-       struct prog_instruction *fpi;
-       GLuint InputsRead = mp->Base.InputsRead;
-       GLuint temps_used = 0;  /* for fp->temps[] */
-       int i, j;
-
-       /* New compile, reset tracking data */
-       fp->optimization =
-           driQueryOptioni(&r300->radeon.optionCache, "fp_optimization");
-       fp->translated = GL_FALSE;
-       fp->error = GL_FALSE;
-       fp->cs = cs = &(R300_CONTEXT(fp->ctx)->state.pfs_compile);
-       fp->tex.length = 0;
-       fp->cur_node = 0;
-       fp->first_node_has_tex = 0;
-       fp->const_nr = 0;
-       fp->max_temp_idx = 0;
-       fp->node[0].alu_end = -1;
-       fp->node[0].tex_end = -1;
-
-       _mesa_memset(cs, 0, sizeof(*fp->cs));
-       for (i = 0; i < PFS_MAX_ALU_INST; i++) {
-               for (j = 0; j < 3; j++) {
-                       cs->slot[i].vsrc[j] = SRC_CONST;
-                       cs->slot[i].ssrc[j] = SRC_CONST;
-               }
-       }
+       s->Outputs[FRAG_RESULT_COLR].Sourced = WRITEMASK_XYZW;
+       s->Outputs[FRAG_RESULT_DEPR].Sourced = WRITEMASK_W;
+}
 
-       /* 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
-        *
-        * NOTE: this depends on get_hw_temp() allocating registers in order,
-        * starting from register 0.
-        */
 
-       /* Texcoords come first */
-       for (i = 0; i < fp->ctx->Const.MaxTextureUnits; i++) {
-               if (InputsRead & (FRAG_BIT_TEX0 << i)) {
-                       cs->inputs[FRAG_ATTRIB_TEX0 + i].refcount = 0;
-                       cs->inputs[FRAG_ATTRIB_TEX0 + i].reg =
-                           get_hw_temp(fp, 0);
-               }
+static GLuint build_dtm(GLuint depthmode)
+{
+       switch(depthmode) {
+       default:
+       case GL_LUMINANCE: return 0;
+       case GL_INTENSITY: return 1;
+       case GL_ALPHA: return 2;
        }
-       InputsRead &= ~FRAG_BITS_TEX_ANY;
+}
 
-       /* fragment position treated as a texcoord */
-       if (InputsRead & FRAG_BIT_WPOS) {
-               cs->inputs[FRAG_ATTRIB_WPOS].refcount = 0;
-               cs->inputs[FRAG_ATTRIB_WPOS].reg = get_hw_temp(fp, 0);
-               insert_wpos(&mp->Base);
-       }
-       InputsRead &= ~FRAG_BIT_WPOS;
+static GLuint build_func(GLuint comparefunc)
+{
+       return comparefunc - GL_NEVER;
+}
 
-       /* Then primary colour */
-       if (InputsRead & FRAG_BIT_COL0) {
-               cs->inputs[FRAG_ATTRIB_COL0].refcount = 0;
-               cs->inputs[FRAG_ATTRIB_COL0].reg = get_hw_temp(fp, 0);
-       }
-       InputsRead &= ~FRAG_BIT_COL0;
 
-       /* Secondary color */
-       if (InputsRead & FRAG_BIT_COL1) {
-               cs->inputs[FRAG_ATTRIB_COL1].refcount = 0;
-               cs->inputs[FRAG_ATTRIB_COL1].reg = get_hw_temp(fp, 0);
-       }
-       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))
-                               cs->inputs[i].reg = 0;
-       }
+/**
+ * Collect all external state that is relevant for compiling the given
+ * fragment program.
+ */
+static void build_state(
+       r300ContextPtr r300,
+       struct r300_fragment_program *fp,
+       struct r300_fragment_program_external_state *state)
+{
+       int unit;
 
-       /* Pre-parse the mesa program, grabbing refcounts on input/temp regs.
-        * That way, we can free up the reg when it's no longer needed
-        */
-       if (!mp->Base.Instructions) {
-               ERROR("No instructions found in program\n");
-               return;
-       }
+       _mesa_bzero(state, sizeof(*state));
 
-       for (fpi = mp->Base.Instructions; fpi->Opcode != OPCODE_END; fpi++) {
-               int idx;
-
-               for (i = 0; i < 3; i++) {
-                       idx = fpi->SrcReg[i].Index;
-                       switch (fpi->SrcReg[i].File) {
-                       case PROGRAM_TEMPORARY:
-                               if (!(temps_used & (1 << idx))) {
-                                       cs->temps[idx].reg = -1;
-                                       cs->temps[idx].refcount = 1;
-                                       temps_used |= (1 << idx);
-                               } else
-                                       cs->temps[idx].refcount++;
-                               break;
-                       case PROGRAM_INPUT:
-                               cs->inputs[idx].refcount++;
-                               break;
-                       default:
-                               break;
-                       }
-               }
+       for(unit = 0; unit < 16; ++unit) {
+               if (fp->mesa_program.Base.ShadowSamplers & (1 << unit)) {
+                       struct gl_texture_object* tex = r300->radeon.glCtx->Texture.Unit[unit]._Current;
 
-               idx = fpi->DstReg.Index;
-               if (fpi->DstReg.File == PROGRAM_TEMPORARY) {
-                       if (!(temps_used & (1 << idx))) {
-                               cs->temps[idx].reg = -1;
-                               cs->temps[idx].refcount = 1;
-                               temps_used |= (1 << idx);
-                       } else
-                               cs->temps[idx].refcount++;
+                       state->unit[unit].depth_texture_mode = build_dtm(tex->DepthMode);
+                       state->unit[unit].texture_compare_func = build_func(tex->CompareFunc);
                }
        }
-       cs->temp_in_use = temps_used;
 }
 
-static void update_params(struct r300_fragment_program *fp)
-{
-       struct gl_fragment_program *mp = &fp->mesa_program;
-
-       /* Ask Mesa nicely to fill in ParameterValues for us */
-       if (mp->Base.Parameters)
-               _mesa_load_state_parameters(fp->ctx, mp->Base.Parameters);
-}
 
 void r300TranslateFragmentShader(r300ContextPtr r300,
                                 struct r300_fragment_program *fp)
 {
-       struct r300_pfs_compile_state *cs = NULL;
+       struct r300_fragment_program_external_state state;
+
+       build_state(r300, fp, &state);
+       if (_mesa_memcmp(&fp->state, &state, sizeof(state))) {
+               /* TODO: cache compiled programs */
+               fp->translated = GL_FALSE;
+               _mesa_memcpy(&fp->state, &state, sizeof(state));
+       }
 
        if (!fp->translated) {
+               struct r300_fragment_program_compiler compiler;
+
+               compiler.r300 = r300;
+               compiler.fp = fp;
+               compiler.code = &fp->code;
+               compiler.program = _mesa_clone_program(r300->radeon.glCtx, &fp->mesa_program.Base);
+
+               if (RADEON_DEBUG & DEBUG_PIXEL) {
+                       _mesa_printf("Fragment Program: Initial program:\n");
+                       _mesa_print_program(compiler.program);
+               }
 
-               init_program(r300, fp);
-               cs = fp->cs;
+               insert_WPOS_trailer(&compiler);
+
+               struct radeon_program_transformation transformations[] = {
+                       { &transform_TEX, &compiler },
+                       { &radeonTransformALU, 0 },
+                       { &radeonTransformTrigSimple, 0 }
+               };
+               radeonLocalTransform(
+                       r300->radeon.glCtx,
+                       compiler.program,
+                       3, transformations);
+
+               if (RADEON_DEBUG & DEBUG_PIXEL) {
+                       _mesa_printf("Fragment Program: After native rewrite:\n");
+                       _mesa_print_program(compiler.program);
+               }
 
-               if (parse_program(fp) == GL_FALSE) {
-                       dump_program(fp);
-                       return;
+               struct radeon_nqssadce_descr nqssadce = {
+                       .Init = &nqssadce_init,
+                       .IsNativeSwizzle = &r300FPIsNativeSwizzle,
+                       .BuildSwizzle = &r300FPBuildSwizzle,
+                       .RewriteDepthOut = GL_TRUE
+               };
+               radeonNqssaDce(r300->radeon.glCtx, compiler.program, &nqssadce);
+
+               if (RADEON_DEBUG & DEBUG_PIXEL) {
+                       _mesa_printf("Compiler: after NqSSA-DCE:\n");
+                       _mesa_print_program(compiler.program);
                }
 
-               /* Finish off */
-               fp->node[fp->cur_node].alu_end =
-                   cs->nrslots - fp->node[fp->cur_node].alu_offset - 1;
-               if (fp->node[fp->cur_node].tex_end < 0)
-                       fp->node[fp->cur_node].tex_end = 0;
-               fp->alu_offset = 0;
-               fp->alu_end = cs->nrslots - 1;
-               fp->tex_offset = 0;
-               fp->tex_end = fp->tex.length ? fp->tex.length - 1 : 0;
-               assert(fp->node[fp->cur_node].alu_end >= 0);
-               assert(fp->alu_end >= 0);
-
-               fp->translated = GL_TRUE;
-               if (RADEON_DEBUG & DEBUG_PIXEL)
-                       dump_program(fp);
-               r300UpdateStateParameters(fp->ctx, _NEW_PROGRAM);
+               if (!r300FragmentProgramEmit(&compiler))
+                       fp->error = GL_TRUE;
+
+               /* Subtle: Rescue any parameters that have been added during transformations */
+               _mesa_free_parameter_list(fp->mesa_program.Base.Parameters);
+               fp->mesa_program.Base.Parameters = compiler.program->Parameters;
+               compiler.program->Parameters = 0;
+
+               _mesa_reference_program(r300->radeon.glCtx, &compiler.program, NULL);
+
+               if (!fp->error)
+                       fp->translated = GL_TRUE;
+               if (fp->error || (RADEON_DEBUG & DEBUG_PIXEL))
+                       r300FragmentProgramDump(fp, &fp->code);
+               r300UpdateStateParameters(r300->radeon.glCtx, _NEW_PROGRAM);
        }
 
-       update_params(fp);
+       update_params(r300, fp);
 }
 
 /* just some random things... */
-static void dump_program(struct r300_fragment_program *fp)
+void r300FragmentProgramDump(
+       struct r300_fragment_program *fp,
+       struct r300_fragment_program_code *code)
 {
        int n, i, j;
        static int pc = 0;
 
        fprintf(stderr, "pc=%d*************************************\n", pc++);
 
-       fprintf(stderr, "Mesa program:\n");
-       fprintf(stderr, "-------------\n");
-       _mesa_print_program(&fp->mesa_program.Base);
-       fflush(stdout);
-
        fprintf(stderr, "Hardware program\n");
        fprintf(stderr, "----------------\n");
 
-       for (n = 0; n < (fp->cur_node + 1); n++) {
+       for (n = 0; n < (code->cur_node + 1); n++) {
                fprintf(stderr, "NODE %d: alu_offset: %d, tex_offset: %d, "
-                       "alu_end: %d, tex_end: %d\n", n,
-                       fp->node[n].alu_offset,
-                       fp->node[n].tex_offset,
-                       fp->node[n].alu_end, fp->node[n].tex_end);
+                       "alu_end: %d, tex_end: %d, flags: %08x\n", n,
+                       code->node[n].alu_offset,
+                       code->node[n].tex_offset,
+                       code->node[n].alu_end, code->node[n].tex_end,
+                       code->node[n].flags);
 
-               if (fp->tex.length) {
+               if (n > 0 || code->first_node_has_tex) {
                        fprintf(stderr, "  TEX:\n");
-                       for (i = fp->node[n].tex_offset;
-                            i <= fp->node[n].tex_offset + fp->node[n].tex_end;
+                       for (i = code->node[n].tex_offset;
+                            i <= code->node[n].tex_offset + code->node[n].tex_end;
                             ++i) {
                                const char *instr;
 
-                               switch ((fp->tex.
-                                        inst[i] >> R300_FPITX_OPCODE_SHIFT) &
+                               switch ((code->tex.
+                                        inst[i] >> R300_TEX_INST_SHIFT) &
                                        15) {
-                               case R300_FPITX_OP_TEX:
+                               case R300_TEX_OP_LD:
                                        instr = "TEX";
                                        break;
-                               case R300_FPITX_OP_KIL:
+                               case R300_TEX_OP_KIL:
                                        instr = "KIL";
                                        break;
-                               case R300_FPITX_OP_TXP:
+                               case R300_TEX_OP_TXP:
                                        instr = "TXP";
                                        break;
-                               case R300_FPITX_OP_TXB:
+                               case R300_TEX_OP_TXB:
                                        instr = "TXB";
                                        break;
                                default:
@@ -2297,22 +513,20 @@ static void dump_program(struct r300_fragment_program *fp)
                                fprintf(stderr,
                                        "    %s t%i, %c%i, texture[%i]   (%08x)\n",
                                        instr,
-                                       (fp->tex.
-                                        inst[i] >> R300_FPITX_DST_SHIFT) & 31,
-                                       (fp->tex.
-                                        inst[i] & R300_FPITX_SRC_CONST) ? 'c' :
+                                       (code->tex.
+                                        inst[i] >> R300_DST_ADDR_SHIFT) & 31,
                                        't',
-                                       (fp->tex.
-                                        inst[i] >> R300_FPITX_SRC_SHIFT) & 31,
-                                       (fp->tex.
-                                        inst[i] & R300_FPITX_IMAGE_MASK) >>
-                                       R300_FPITX_IMAGE_SHIFT,
-                                       fp->tex.inst[i]);
+                                       (code->tex.
+                                        inst[i] >> R300_SRC_ADDR_SHIFT) & 31,
+                                       (code->tex.
+                                        inst[i] & R300_TEX_ID_MASK) >>
+                                       R300_TEX_ID_SHIFT,
+                                       code->tex.inst[i]);
                        }
                }
 
-               for (i = fp->node[n].alu_offset;
-                    i <= fp->node[n].alu_offset + fp->node[n].alu_end; ++i) {
+               for (i = code->node[n].alu_offset;
+                    i <= code->node[n].alu_offset + code->node[n].alu_end; ++i) {
                        char srcc[3][10], dstc[20];
                        char srca[3][10], dsta[20];
                        char argc[3][20];
@@ -2320,8 +534,8 @@ static void dump_program(struct r300_fragment_program *fp)
                        char flags[5], tmp[10];
 
                        for (j = 0; j < 3; ++j) {
-                               int regc = fp->alu.inst[i].inst1 >> (j * 6);
-                               int rega = fp->alu.inst[i].inst3 >> (j * 6);
+                               int regc = code->alu.inst[i].inst1 >> (j * 6);
+                               int rega = code->alu.inst[i].inst3 >> (j * 6);
 
                                sprintf(srcc[j], "%c%i",
                                        (regc & 32) ? 'c' : 't', regc & 31);
@@ -2331,46 +545,46 @@ static void dump_program(struct r300_fragment_program *fp)
 
                        dstc[0] = 0;
                        sprintf(flags, "%s%s%s",
-                               (fp->alu.inst[i].
-                                inst1 & R300_FPI1_DSTC_REG_X) ? "x" : "",
-                               (fp->alu.inst[i].
-                                inst1 & R300_FPI1_DSTC_REG_Y) ? "y" : "",
-                               (fp->alu.inst[i].
-                                inst1 & R300_FPI1_DSTC_REG_Z) ? "z" : "");
+                               (code->alu.inst[i].
+                                inst1 & R300_ALU_DSTC_REG_X) ? "x" : "",
+                               (code->alu.inst[i].
+                                inst1 & R300_ALU_DSTC_REG_Y) ? "y" : "",
+                               (code->alu.inst[i].
+                                inst1 & R300_ALU_DSTC_REG_Z) ? "z" : "");
                        if (flags[0] != 0) {
                                sprintf(dstc, "t%i.%s ",
-                                       (fp->alu.inst[i].
-                                        inst1 >> R300_FPI1_DSTC_SHIFT) & 31,
+                                       (code->alu.inst[i].
+                                        inst1 >> R300_ALU_DSTC_SHIFT) & 31,
                                        flags);
                        }
                        sprintf(flags, "%s%s%s",
-                               (fp->alu.inst[i].
-                                inst1 & R300_FPI1_DSTC_OUTPUT_X) ? "x" : "",
-                               (fp->alu.inst[i].
-                                inst1 & R300_FPI1_DSTC_OUTPUT_Y) ? "y" : "",
-                               (fp->alu.inst[i].
-                                inst1 & R300_FPI1_DSTC_OUTPUT_Z) ? "z" : "");
+                               (code->alu.inst[i].
+                                inst1 & R300_ALU_DSTC_OUTPUT_X) ? "x" : "",
+                               (code->alu.inst[i].
+                                inst1 & R300_ALU_DSTC_OUTPUT_Y) ? "y" : "",
+                               (code->alu.inst[i].
+                                inst1 & R300_ALU_DSTC_OUTPUT_Z) ? "z" : "");
                        if (flags[0] != 0) {
                                sprintf(tmp, "o%i.%s",
-                                       (fp->alu.inst[i].
-                                        inst1 >> R300_FPI1_DSTC_SHIFT) & 31,
+                                       (code->alu.inst[i].
+                                        inst1 >> R300_ALU_DSTC_SHIFT) & 31,
                                        flags);
                                strcat(dstc, tmp);
                        }
 
                        dsta[0] = 0;
-                       if (fp->alu.inst[i].inst3 & R300_FPI3_DSTA_REG) {
+                       if (code->alu.inst[i].inst3 & R300_ALU_DSTA_REG) {
                                sprintf(dsta, "t%i.w ",
-                                       (fp->alu.inst[i].
-                                        inst3 >> R300_FPI3_DSTA_SHIFT) & 31);
+                                       (code->alu.inst[i].
+                                        inst3 >> R300_ALU_DSTA_SHIFT) & 31);
                        }
-                       if (fp->alu.inst[i].inst3 & R300_FPI3_DSTA_OUTPUT) {
+                       if (code->alu.inst[i].inst3 & R300_ALU_DSTA_OUTPUT) {
                                sprintf(tmp, "o%i.w ",
-                                       (fp->alu.inst[i].
-                                        inst3 >> R300_FPI3_DSTA_SHIFT) & 31);
+                                       (code->alu.inst[i].
+                                        inst3 >> R300_ALU_DSTA_SHIFT) & 31);
                                strcat(dsta, tmp);
                        }
-                       if (fp->alu.inst[i].inst3 & R300_FPI3_DSTA_DEPTH) {
+                       if (code->alu.inst[i].inst3 & R300_ALU_DSTA_DEPTH) {
                                strcat(dsta, "Z");
                        }
 
@@ -2378,31 +592,31 @@ static void dump_program(struct r300_fragment_program *fp)
                                "%3i: xyz: %3s %3s %3s -> %-20s (%08x)\n"
                                "       w: %3s %3s %3s -> %-20s (%08x)\n", i,
                                srcc[0], srcc[1], srcc[2], dstc,
-                               fp->alu.inst[i].inst1, srca[0], srca[1],
-                               srca[2], dsta, fp->alu.inst[i].inst3);
+                               code->alu.inst[i].inst1, srca[0], srca[1],
+                               srca[2], dsta, code->alu.inst[i].inst3);
 
                        for (j = 0; j < 3; ++j) {
-                               int regc = fp->alu.inst[i].inst0 >> (j * 7);
-                               int rega = fp->alu.inst[i].inst2 >> (j * 7);
+                               int regc = code->alu.inst[i].inst0 >> (j * 7);
+                               int rega = code->alu.inst[i].inst2 >> (j * 7);
                                int d;
                                char buf[20];
 
                                d = regc & 31;
                                if (d < 12) {
                                        switch (d % 4) {
-                                       case R300_FPI0_ARGC_SRC0C_XYZ:
+                                       case R300_ALU_ARGC_SRC0C_XYZ:
                                                sprintf(buf, "%s.xyz",
                                                        srcc[d / 4]);
                                                break;
-                                       case R300_FPI0_ARGC_SRC0C_XXX:
+                                       case R300_ALU_ARGC_SRC0C_XXX:
                                                sprintf(buf, "%s.xxx",
                                                        srcc[d / 4]);
                                                break;
-                                       case R300_FPI0_ARGC_SRC0C_YYY:
+                                       case R300_ALU_ARGC_SRC0C_YYY:
                                                sprintf(buf, "%s.yyy",
                                                        srcc[d / 4]);
                                                break;
-                                       case R300_FPI0_ARGC_SRC0C_ZZZ:
+                                       case R300_ALU_ARGC_SRC0C_ZZZ:
                                                sprintf(buf, "%s.zzz",
                                                        srcc[d / 4]);
                                                break;
@@ -2465,8 +679,8 @@ static void dump_program(struct r300_fragment_program *fp)
                        fprintf(stderr, "     xyz: %8s %8s %8s    op: %08x\n"
                                "       w: %8s %8s %8s    op: %08x\n",
                                argc[0], argc[1], argc[2],
-                               fp->alu.inst[i].inst0, arga[0], arga[1],
-                               arga[2], fp->alu.inst[i].inst2);
+                               code->alu.inst[i].inst0, arga[0], arga[1],
+                               arga[2], code->alu.inst[i].inst2);
                }
        }
 }
index 72fca778455b13400f493838edd032bfd9721397..b3a3cd2e04cf56b3ce658e8902321a76afd4faa4 100644 (file)
 #include "shader/prog_instruction.h"
 
 #include "r300_context.h"
-
-typedef struct r300_fragment_program_swizzle {
-       GLuint length;
-       GLuint src[4];
-       GLuint inst[8];
-} r300_fragment_program_swizzle_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 PFS_OP_CMPH 12
-#define MAX_PFS_OP 12
-
-#define PFS_FLAG_SAT   (1 << 0)
-#define PFS_FLAG_ABS   (1 << 1)
-
-#define ARG_NEG                        (1 << 5)
-#define ARG_ABS                        (1 << 6)
-#define ARG_MASK               (127 << 0)
-#define ARG_STRIDE             7
-#define SRC_CONST              (1 << 5)
-#define SRC_MASK               (63 << 0)
-#define SRC_STRIDE             6
-
-#define NOP_INST0 (                                             \
-               (R300_FPI0_OUTC_MAD) |                           \
-               (R300_FPI0_ARGC_ZERO << R300_FPI0_ARG0C_SHIFT) | \
-               (R300_FPI0_ARGC_ZERO << R300_FPI0_ARG1C_SHIFT) | \
-               (R300_FPI0_ARGC_ZERO << R300_FPI0_ARG2C_SHIFT))
-#define NOP_INST1 (                                         \
-               ((0 | SRC_CONST) << R300_FPI1_SRC0C_SHIFT) | \
-               ((0 | SRC_CONST) << R300_FPI1_SRC1C_SHIFT) | \
-               ((0 | SRC_CONST) << R300_FPI1_SRC2C_SHIFT))
-#define NOP_INST2 ( \
-               (R300_FPI2_OUTA_MAD) |                           \
-               (R300_FPI2_ARGA_ZERO << R300_FPI2_ARG0A_SHIFT) | \
-               (R300_FPI2_ARGA_ZERO << R300_FPI2_ARG1A_SHIFT) | \
-               (R300_FPI2_ARGA_ZERO << R300_FPI2_ARG2A_SHIFT))
-#define NOP_INST3 (                                         \
-               ((0 | SRC_CONST) << R300_FPI3_SRC0A_SHIFT) | \
-               ((0 | SRC_CONST) << R300_FPI3_SRC1A_SHIFT) | \
-               ((0 | SRC_CONST) << R300_FPI3_SRC2A_SHIFT))
+#include "radeon_program.h"
 
 #define DRI_CONF_FP_OPTIMIZATION_SPEED   0
 #define DRI_CONF_FP_OPTIMIZATION_QUALITY 1
 
+#if 1
+
+/**
+ * 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_ALU_DSTC_SHIFT) |           \
+        (FP_SELC_MASK_##regmask << 23) |               \
+        (FP_SELC_MASK_##outmask << 26) |               \
+        ((src0) << R300_ALU_SRC0C_SHIFT) |             \
+        ((src1) << R300_ALU_SRC1C_SHIFT) |             \
+        ((src2) << R300_ALU_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_ALU_DSTA_SHIFT) |           \
+        (FP_SELA_MASK_##regmask << 23) |               \
+        (FP_SELA_MASK_##outmask << 24) |               \
+        ((src0) << R300_ALU_SRC0A_SHIFT) |             \
+        ((src1) << R300_ALU_SRC1A_SHIFT) |             \
+        ((src2) << R300_ALU_SRC2A_SHIFT))
+
+/* Produce unshifted argument selectors */
+#define FP_ARGC(source)        R300_ALU_ARGC_##source
+#define FP_ARGA(source) R300_ALU_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_ALU_OUTC_##opcode |               \
+       ((arg0) << R300_ALU_ARG0C_SHIFT) |      \
+       ((arg1) << R300_ALU_ARG1C_SHIFT) |      \
+       ((arg2) << R300_ALU_ARG2C_SHIFT))
+
+#define FP_INSTRA(opcode,arg0,arg1,arg2) \
+       (R300_ALU_OUTA_##opcode |               \
+       ((arg0) << R300_ALU_ARG0A_SHIFT) |      \
+       ((arg1) << R300_ALU_ARG1A_SHIFT) |      \
+       ((arg2) << R300_ALU_ARG2A_SHIFT))
+
+#endif
+
 struct r300_fragment_program;
 
 extern void r300TranslateFragmentShader(r300ContextPtr r300,
                                        struct r300_fragment_program *fp);
 
+
+/**
+ * Used internally by the r300 fragment program code to store compile-time
+ * only data.
+ */
+struct r300_fragment_program_compiler {
+       r300ContextPtr r300;
+       struct r300_fragment_program *fp;
+       struct r300_fragment_program_code *code;
+       struct gl_program *program;
+};
+
+extern GLboolean r300FragmentProgramEmit(struct r300_fragment_program_compiler *compiler);
+
+
+extern void r300FragmentProgramDump(
+       struct r300_fragment_program *fp,
+       struct r300_fragment_program_code *code);
+
 #endif
diff --git a/src/mesa/drivers/dri/r300/r300_fragprog_emit.c b/src/mesa/drivers/dri/r300/r300_fragprog_emit.c
new file mode 100644 (file)
index 0000000..9f0b7e3
--- /dev/null
@@ -0,0 +1,344 @@
+/*
+ * 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.
+ *
+ */
+
+/**
+ * \file
+ *
+ * Emit the r300_fragment_program_code that can be understood by the hardware.
+ * Input is a pre-transformed radeon_program.
+ *
+ * \author Ben Skeggs <darktama@iinet.net.au>
+ *
+ * \author Jerome Glisse <j.glisse@gmail.com>
+ *
+ * \todo FogOption
+ */
+
+#include "r300_fragprog.h"
+
+#include "radeon_program_pair.h"
+#include "r300_fragprog_swizzle.h"
+#include "r300_reg.h"
+
+
+#define PROG_CODE \
+       struct r300_fragment_program_compiler *c = (struct r300_fragment_program_compiler*)data; \
+       struct r300_fragment_program_code *code = c->code
+
+#define error(fmt, args...) do {                       \
+               fprintf(stderr, "%s::%s(): " fmt "\n",  \
+                       __FILE__, __FUNCTION__, ##args);        \
+       } while(0)
+
+
+static GLboolean emit_const(void* data, GLuint file, GLuint index, GLuint *hwindex)
+{
+       PROG_CODE;
+
+       for (*hwindex = 0; *hwindex < code->const_nr; ++*hwindex) {
+               if (code->constant[*hwindex].File == file &&
+                   code->constant[*hwindex].Index == index)
+                       break;
+       }
+
+       if (*hwindex >= code->const_nr) {
+               if (*hwindex >= PFS_NUM_CONST_REGS) {
+                       error("Out of hw constants!\n");
+                       return GL_FALSE;
+               }
+
+               code->const_nr++;
+               code->constant[*hwindex].File = file;
+               code->constant[*hwindex].Index = index;
+       }
+
+       return GL_TRUE;
+}
+
+
+/**
+ * Mark a temporary register as used.
+ */
+static void use_temporary(struct r300_fragment_program_code *code, GLuint index)
+{
+       if (index > code->max_temp_idx)
+               code->max_temp_idx = index;
+}
+
+
+static GLuint translate_rgb_opcode(GLuint opcode)
+{
+       switch(opcode) {
+       case OPCODE_CMP: return R300_ALU_OUTC_CMP;
+       case OPCODE_DP3: return R300_ALU_OUTC_DP3;
+       case OPCODE_DP4: return R300_ALU_OUTC_DP4;
+       case OPCODE_FRC: return R300_ALU_OUTC_FRC;
+       default:
+               error("translate_rgb_opcode(%i): Unknown opcode", opcode);
+               /* fall through */
+       case OPCODE_NOP:
+               /* fall through */
+       case OPCODE_MAD: return R300_ALU_OUTC_MAD;
+       case OPCODE_MAX: return R300_ALU_OUTC_MAX;
+       case OPCODE_MIN: return R300_ALU_OUTC_MIN;
+       case OPCODE_REPL_ALPHA: return R300_ALU_OUTC_REPL_ALPHA;
+       }
+}
+
+static GLuint translate_alpha_opcode(GLuint opcode)
+{
+       switch(opcode) {
+       case OPCODE_CMP: return R300_ALU_OUTA_CMP;
+       case OPCODE_DP3: return R300_ALU_OUTA_DP4;
+       case OPCODE_DP4: return R300_ALU_OUTA_DP4;
+       case OPCODE_EX2: return R300_ALU_OUTA_EX2;
+       case OPCODE_FRC: return R300_ALU_OUTA_FRC;
+       case OPCODE_LG2: return R300_ALU_OUTA_LG2;
+       default:
+               error("translate_rgb_opcode(%i): Unknown opcode", opcode);
+               /* fall through */
+       case OPCODE_NOP:
+               /* fall through */
+       case OPCODE_MAD: return R300_ALU_OUTA_MAD;
+       case OPCODE_MAX: return R300_ALU_OUTA_MAX;
+       case OPCODE_MIN: return R300_ALU_OUTA_MIN;
+       case OPCODE_RCP: return R300_ALU_OUTA_RCP;
+       case OPCODE_RSQ: return R300_ALU_OUTA_RSQ;
+       }
+}
+
+/**
+ * Emit one paired ALU instruction.
+ */
+static GLboolean emit_alu(void* data, struct radeon_pair_instruction* inst)
+{
+       PROG_CODE;
+
+       if (code->alu.length >= PFS_MAX_ALU_INST) {
+               error("Too many ALU instructions");
+               return GL_FALSE;
+       }
+
+       int ip = code->alu.length++;
+       int j;
+       code->node[code->cur_node].alu_end++;
+
+       code->alu.inst[ip].inst0 = translate_rgb_opcode(inst->RGB.Opcode);
+       code->alu.inst[ip].inst2 = translate_alpha_opcode(inst->Alpha.Opcode);
+
+       for(j = 0; j < 3; ++j) {
+               GLuint src = inst->RGB.Src[j].Index | (inst->RGB.Src[j].Constant << 5);
+               if (!inst->RGB.Src[j].Constant)
+                       use_temporary(code, inst->RGB.Src[j].Index);
+               code->alu.inst[ip].inst1 |= src << (6*j);
+
+               src = inst->Alpha.Src[j].Index | (inst->Alpha.Src[j].Constant << 5);
+               if (!inst->Alpha.Src[j].Constant)
+                       use_temporary(code, inst->Alpha.Src[j].Index);
+               code->alu.inst[ip].inst3 |= src << (6*j);
+
+               GLuint arg = r300FPTranslateRGBSwizzle(inst->RGB.Arg[j].Source, inst->RGB.Arg[j].Swizzle);
+               arg |= inst->RGB.Arg[j].Abs << 6;
+               arg |= inst->RGB.Arg[j].Negate << 5;
+               code->alu.inst[ip].inst0 |= arg << (7*j);
+
+               arg = r300FPTranslateAlphaSwizzle(inst->Alpha.Arg[j].Source, inst->Alpha.Arg[j].Swizzle);
+               arg |= inst->Alpha.Arg[j].Abs << 6;
+               arg |= inst->Alpha.Arg[j].Negate << 5;
+               code->alu.inst[ip].inst2 |= arg << (7*j);
+       }
+
+       if (inst->RGB.Saturate)
+               code->alu.inst[ip].inst0 |= R300_ALU_OUTC_CLAMP;
+       if (inst->Alpha.Saturate)
+               code->alu.inst[ip].inst2 |= R300_ALU_OUTA_CLAMP;
+
+       if (inst->RGB.WriteMask) {
+               use_temporary(code, inst->RGB.DestIndex);
+               code->alu.inst[ip].inst1 |=
+                       (inst->RGB.DestIndex << R300_ALU_DSTC_SHIFT) |
+                       (inst->RGB.WriteMask << R300_ALU_DSTC_REG_MASK_SHIFT);
+       }
+       if (inst->RGB.OutputWriteMask) {
+               code->alu.inst[ip].inst1 |= (inst->RGB.OutputWriteMask << R300_ALU_DSTC_OUTPUT_MASK_SHIFT);
+               code->node[code->cur_node].flags |= R300_RGBA_OUT;
+       }
+
+       if (inst->Alpha.WriteMask) {
+               use_temporary(code, inst->Alpha.DestIndex);
+               code->alu.inst[ip].inst3 |=
+                       (inst->Alpha.DestIndex << R300_ALU_DSTA_SHIFT) |
+                       R300_ALU_DSTA_REG;
+       }
+       if (inst->Alpha.OutputWriteMask) {
+               code->alu.inst[ip].inst3 |= R300_ALU_DSTA_OUTPUT;
+               code->node[code->cur_node].flags |= R300_RGBA_OUT;
+       }
+       if (inst->Alpha.DepthWriteMask) {
+               code->alu.inst[ip].inst3 |= R300_ALU_DSTA_DEPTH;
+               code->node[code->cur_node].flags |= R300_W_OUT;
+               c->fp->WritesDepth = GL_TRUE;
+       }
+
+       return GL_TRUE;
+}
+
+
+/**
+ * Finish the current node without advancing to the next one.
+ */
+static GLboolean finish_node(struct r300_fragment_program_compiler *c)
+{
+       struct r300_fragment_program_code *code = c->code;
+       struct r300_fragment_program_node *node = &code->node[code->cur_node];
+
+       if (node->alu_end < 0) {
+               /* Generate a single NOP for this node */
+               struct radeon_pair_instruction inst;
+               _mesa_bzero(&inst, sizeof(inst));
+               if (!emit_alu(c, &inst))
+                       return GL_FALSE;
+       }
+
+       if (node->tex_end < 0) {
+               if (code->cur_node == 0) {
+                       node->tex_end = 0;
+               } else {
+                       error("Node %i has no TEX instructions", code->cur_node);
+                       return GL_FALSE;
+               }
+       } else {
+               if (code->cur_node == 0)
+                       code->first_node_has_tex = 1;
+       }
+
+       return GL_TRUE;
+}
+
+
+/**
+ * Begin a block of texture instructions.
+ * Create the necessary indirection.
+ */
+static GLboolean begin_tex(void* data)
+{
+       PROG_CODE;
+
+       if (code->cur_node == 0) {
+               if (code->node[0].alu_end < 0 &&
+                   code->node[0].tex_end < 0)
+                       return GL_TRUE;
+       }
+
+       if (code->cur_node == 3) {
+               error("Too many texture indirections");
+               return GL_FALSE;
+       }
+
+       if (!finish_node(c))
+               return GL_FALSE;
+
+       struct r300_fragment_program_node *node = &code->node[++code->cur_node];
+       node->alu_offset = code->alu.length;
+       node->alu_end = -1;
+       node->tex_offset = code->tex.length;
+       node->tex_end = -1;
+       return GL_TRUE;
+}
+
+
+static GLboolean emit_tex(void* data, struct prog_instruction* inst)
+{
+       PROG_CODE;
+
+       if (code->tex.length >= PFS_MAX_TEX_INST) {
+               error("Too many TEX instructions");
+               return GL_FALSE;
+       }
+
+       GLuint unit = inst->TexSrcUnit;
+       GLuint dest = inst->DstReg.Index;
+       GLuint opcode;
+
+       switch(inst->Opcode) {
+       case OPCODE_KIL: opcode = R300_TEX_OP_KIL; break;
+       case OPCODE_TEX: opcode = R300_TEX_OP_LD; break;
+       case OPCODE_TXB: opcode = R300_TEX_OP_TXB; break;
+       case OPCODE_TXP: opcode = R300_TEX_OP_TXP; break;
+       default:
+               error("Unknown texture opcode %i", inst->Opcode);
+               return GL_FALSE;
+       }
+
+       if (inst->Opcode == OPCODE_KIL) {
+               unit = 0;
+               dest = 0;
+       } else {
+               use_temporary(code, dest);
+       }
+
+       use_temporary(code, inst->SrcReg[0].Index);
+
+       code->node[code->cur_node].tex_end++;
+       code->tex.inst[code->tex.length++] =
+               (inst->SrcReg[0].Index << R300_SRC_ADDR_SHIFT) |
+               (dest << R300_DST_ADDR_SHIFT) |
+               (unit << R300_TEX_ID_SHIFT) |
+               (opcode << R300_TEX_INST_SHIFT);
+       return GL_TRUE;
+}
+
+
+static const struct radeon_pair_handler pair_handler = {
+       .EmitConst = &emit_const,
+       .EmitPaired = &emit_alu,
+       .EmitTex = &emit_tex,
+       .BeginTexBlock = &begin_tex,
+       .MaxHwTemps = PFS_NUM_TEMP_REGS
+};
+
+/**
+ * Final compilation step: Turn the intermediate radeon_program into
+ * machine-readable instructions.
+ */
+GLboolean r300FragmentProgramEmit(struct r300_fragment_program_compiler *compiler)
+{
+       struct r300_fragment_program_code *code = compiler->code;
+
+       _mesa_bzero(code, sizeof(struct r300_fragment_program_code));
+       code->node[0].alu_end = -1;
+       code->node[0].tex_end = -1;
+
+       if (!radeonPairProgram(compiler->r300->radeon.glCtx, compiler->program, &pair_handler, compiler))
+               return GL_FALSE;
+
+       if (!finish_node(compiler))
+               return GL_FALSE;
+
+       return GL_TRUE;
+}
+
diff --git a/src/mesa/drivers/dri/r300/r300_fragprog_swizzle.c b/src/mesa/drivers/dri/r300/r300_fragprog_swizzle.c
new file mode 100644 (file)
index 0000000..a86d2bd
--- /dev/null
@@ -0,0 +1,227 @@
+/*
+ * Copyright (C) 2008 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.
+ *
+ */
+
+/**
+ * @file
+ * Utilities to deal with the somewhat odd restriction on R300 fragment
+ * program swizzles.
+ */
+
+#include "r300_fragprog_swizzle.h"
+
+#include "r300_reg.h"
+#include "radeon_nqssadce.h"
+
+#define MAKE_SWZ3(x, y, z) (MAKE_SWIZZLE4(SWIZZLE_##x, SWIZZLE_##y, SWIZZLE_##z, SWIZZLE_ZERO))
+
+struct swizzle_data {
+       GLuint hash; /**< swizzle value this matches */
+       GLuint base; /**< base value for hw swizzle */
+       GLuint stride; /**< difference in base between arg0/1/2 */
+};
+
+static const struct swizzle_data native_swizzles[] = {
+       {MAKE_SWZ3(X, Y, Z), R300_ALU_ARGC_SRC0C_XYZ, 4},
+       {MAKE_SWZ3(X, X, X), R300_ALU_ARGC_SRC0C_XXX, 4},
+       {MAKE_SWZ3(Y, Y, Y), R300_ALU_ARGC_SRC0C_YYY, 4},
+       {MAKE_SWZ3(Z, Z, Z), R300_ALU_ARGC_SRC0C_ZZZ, 4},
+       {MAKE_SWZ3(W, W, W), R300_ALU_ARGC_SRC0A, 1},
+       {MAKE_SWZ3(Y, Z, X), R300_ALU_ARGC_SRC0C_YZX, 1},
+       {MAKE_SWZ3(Z, X, Y), R300_ALU_ARGC_SRC0C_ZXY, 1},
+       {MAKE_SWZ3(W, Z, Y), R300_ALU_ARGC_SRC0CA_WZY, 1},
+       {MAKE_SWZ3(ONE, ONE, ONE), R300_ALU_ARGC_ONE, 0},
+       {MAKE_SWZ3(ZERO, ZERO, ZERO), R300_ALU_ARGC_ZERO, 0}
+};
+
+static const int num_native_swizzles = sizeof(native_swizzles)/sizeof(native_swizzles[0]);
+
+
+/**
+ * Find a native RGB swizzle that matches the given swizzle.
+ * Returns 0 if none found.
+ */
+static const struct swizzle_data* lookup_native_swizzle(GLuint swizzle)
+{
+       int i, comp;
+
+       for(i = 0; i < num_native_swizzles; ++i) {
+               const struct swizzle_data* sd = &native_swizzles[i];
+               for(comp = 0; comp < 3; ++comp) {
+                       GLuint swz = GET_SWZ(swizzle, comp);
+                       if (swz == SWIZZLE_NIL)
+                               continue;
+                       if (swz != GET_SWZ(sd->hash, comp))
+                               break;
+               }
+               if (comp == 3)
+                       return sd;
+       }
+
+       return 0;
+}
+
+
+/**
+ * Check whether the given instruction supports the swizzle and negate
+ * combinations in the given source register.
+ */
+GLboolean r300FPIsNativeSwizzle(GLuint opcode, struct prog_src_register reg)
+{
+       if (reg.Abs)
+               reg.NegateBase = 0;
+
+       if (opcode == OPCODE_KIL ||
+           opcode == OPCODE_TEX ||
+           opcode == OPCODE_TXB ||
+           opcode == OPCODE_TXP) {
+               int j;
+
+               if (reg.Abs || reg.NegateBase != (15*reg.NegateAbs))
+                       return GL_FALSE;
+
+               for(j = 0; j < 4; ++j) {
+                       GLuint swz = GET_SWZ(reg.Swizzle, j);
+                       if (swz == SWIZZLE_NIL)
+                               continue;
+                       if (swz != j)
+                               return GL_FALSE;
+               }
+
+               return GL_TRUE;
+       }
+
+       GLuint relevant = 0;
+       int j;
+
+       for(j = 0; j < 3; ++j)
+               if (GET_SWZ(reg.Swizzle, j) != SWIZZLE_NIL)
+                       relevant |= 1 << j;
+
+       if ((reg.NegateBase & relevant) && (reg.NegateBase & relevant) != relevant)
+               return GL_FALSE;
+
+       if (!lookup_native_swizzle(reg.Swizzle))
+               return GL_FALSE;
+
+       return GL_TRUE;
+}
+
+
+/**
+ * Generate MOV dst, src using only native swizzles.
+ */
+void r300FPBuildSwizzle(struct nqssadce_state *s, struct prog_dst_register dst, struct prog_src_register src)
+{
+       if (src.Abs)
+               src.NegateBase = 0;
+
+       while(dst.WriteMask) {
+               const struct swizzle_data *best_swizzle = 0;
+               GLuint best_matchcount = 0;
+               GLuint best_matchmask = 0;
+               GLboolean rgbnegate;
+               int i, comp;
+
+               for(i = 0; i < num_native_swizzles; ++i) {
+                       const struct swizzle_data *sd = &native_swizzles[i];
+                       GLuint matchcount = 0;
+                       GLuint matchmask = 0;
+                       for(comp = 0; comp < 3; ++comp) {
+                               if (!GET_BIT(dst.WriteMask, comp))
+                                       continue;
+                               GLuint swz = GET_SWZ(src.Swizzle, comp);
+                               if (swz == SWIZZLE_NIL)
+                                       continue;
+                               if (swz == GET_SWZ(sd->hash, comp)) {
+                                       matchcount++;
+                                       matchmask |= 1 << comp;
+                               }
+                       }
+                       if (matchcount > best_matchcount) {
+                               best_swizzle = sd;
+                               best_matchcount = matchcount;
+                               best_matchmask = matchmask;
+                               if (matchmask == (dst.WriteMask & WRITEMASK_XYZ))
+                                       break;
+                       }
+               }
+
+               if ((src.NegateBase & best_matchmask) != 0) {
+                       best_matchmask &= src.NegateBase;
+                       rgbnegate = !src.NegateAbs;
+               } else {
+                       rgbnegate = src.NegateAbs;
+               }
+
+               struct prog_instruction *inst;
+
+               _mesa_insert_instructions(s->Program, s->IP, 1);
+               inst = s->Program->Instructions + s->IP++;
+               inst->Opcode = OPCODE_MOV;
+               inst->DstReg = dst;
+               inst->DstReg.WriteMask &= (best_matchmask | WRITEMASK_W);
+               inst->SrcReg[0] = src;
+               /* Note: We rely on NqSSA/DCE to set unused swizzle components to NIL */
+
+               dst.WriteMask &= ~inst->DstReg.WriteMask;
+       }
+}
+
+
+/**
+ * Translate an RGB (XYZ) swizzle into the hardware code for the given
+ * instruction source.
+ */
+GLuint r300FPTranslateRGBSwizzle(GLuint src, GLuint swizzle)
+{
+       const struct swizzle_data* sd = lookup_native_swizzle(swizzle);
+
+       if (!sd) {
+               _mesa_printf("Not a native swizzle: %08x\n", swizzle);
+               return 0;
+       }
+
+       return sd->base + src*sd->stride;
+}
+
+
+/**
+ * Translate an Alpha (W) swizzle into the hardware code for the given
+ * instruction source.
+ */
+GLuint r300FPTranslateAlphaSwizzle(GLuint src, GLuint swizzle)
+{
+       if (swizzle < 3)
+               return swizzle + 3*src;
+
+       switch(swizzle) {
+       case SWIZZLE_W: return R300_ALU_ARGA_SRC0A + src;
+       case SWIZZLE_ONE: return R300_ALU_ARGA_ONE;
+       case SWIZZLE_ZERO: return R300_ALU_ARGA_ZERO;
+       default: return R300_ALU_ARGA_ONE;
+       }
+}
diff --git a/src/mesa/drivers/dri/r300/r300_fragprog_swizzle.h b/src/mesa/drivers/dri/r300/r300_fragprog_swizzle.h
new file mode 100644 (file)
index 0000000..3da99a9
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2008 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.
+ *
+ */
+
+#ifndef __R300_FRAGPROG_SWIZZLE_H_
+#define __R300_FRAGPROG_SWIZZLE_H_
+
+#include "glheader.h"
+#include "shader/prog_instruction.h"
+
+struct nqssadce_state;
+
+GLboolean r300FPIsNativeSwizzle(GLuint opcode, struct prog_src_register reg);
+void r300FPBuildSwizzle(struct nqssadce_state*, struct prog_dst_register dst, struct prog_src_register src);
+
+GLuint r300FPTranslateRGBSwizzle(GLuint src, GLuint swizzle);
+GLuint r300FPTranslateAlphaSwizzle(GLuint src, GLuint swizzle);
+
+#endif /* __R300_FRAGPROG_SWIZZLE_H_ */
index 90f5027c9ad77a5488e5ab3969faeb57640a5fa2..bd7f060435f3239022ada0206e46e10475cbad41 100644 (file)
@@ -51,9 +51,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r300_ioctl.h"
 #include "r300_cmdbuf.h"
 #include "r300_state.h"
-#include "r300_program.h"
+#include "r300_vertprog.h"
 #include "radeon_reg.h"
 #include "r300_emit.h"
+#include "r300_fragprog.h"
 
 #include "vblank.h"
 
@@ -106,19 +107,19 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
        e32(cbpitch);
 
        R300_STATECHANGE(r300, cmk);
-       reg_start(R300_RB3D_COLORMASK, 0);
+       reg_start(RB3D_COLOR_CHANNEL_MASK, 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));
+               e32((ctx->Color.ColorMask[BCOMP] ? RB3D_COLOR_CHANNEL_MASK_BLUE_MASK0 : 0) |
+                   (ctx->Color.ColorMask[GCOMP] ? RB3D_COLOR_CHANNEL_MASK_GREEN_MASK0 : 0) |
+                   (ctx->Color.ColorMask[RCOMP] ? RB3D_COLOR_CHANNEL_MASK_RED_MASK0 : 0) |
+                   (ctx->Color.ColorMask[ACOMP] ? RB3D_COLOR_CHANNEL_MASK_ALPHA_MASK0 : 0));
        } else {
                e32(0x0);
        }
 
        R300_STATECHANGE(r300, zs);
-       reg_start(R300_RB3D_ZSTENCIL_CNTL_0, 2);
+       reg_start(R300_ZB_CNTL, 2);
 
        {
                uint32_t t1, t2;
@@ -127,37 +128,28 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
                t2 = 0x0;
 
                if (flags & CLEARBUFFER_DEPTH) {
-                       t1 |= R300_RB3D_Z_WRITE_ONLY;
+                       t1 |= R300_Z_ENABLE | R300_Z_WRITE_ENABLE;
                        t2 |=
-                           (R300_ZS_ALWAYS << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT);
-               } else {
-                       t1 |= R300_RB3D_Z_DISABLED_1;   // disable
+                           (R300_ZS_ALWAYS << R300_Z_FUNC_SHIFT);
                }
 
                if (flags & CLEARBUFFER_STENCIL) {
-                       t1 |= R300_RB3D_STENCIL_ENABLE;
+                       t1 |= R300_STENCIL_ENABLE;
                        t2 |=
                            (R300_ZS_ALWAYS <<
-                            R300_RB3D_ZS1_FRONT_FUNC_SHIFT) |
+                            R300_S_FRONT_FUNC_SHIFT) |
                            (R300_ZS_REPLACE <<
-                            R300_RB3D_ZS1_FRONT_FAIL_OP_SHIFT) |
+                            R300_S_FRONT_SFAIL_OP_SHIFT) |
                            (R300_ZS_REPLACE <<
-                            R300_RB3D_ZS1_FRONT_ZPASS_OP_SHIFT) |
+                            R300_S_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_S_FRONT_ZFAIL_OP_SHIFT);
                }
 
                e32(t1);
                e32(t2);
-               e32(r300->state.stencil.clear);
+               e32(((ctx->Stencil.WriteMask[0] & R300_STENCILREF_MASK) << R300_STENCILWRITEMASK_SHIFT) |
+                   (ctx->Stencil.Clear & R300_STENCILREF_MASK));
        }
 
        cmd2 = (drm_r300_cmd_header_t *) r300AllocCmdBuf(r300, 9, __FUNCTION__);
@@ -186,10 +178,16 @@ static void r300EmitClearState(GLcontext * ctx)
        int cmd_written = 0;
        drm_radeon_cmd_header_t *cmd = NULL;
        int has_tcl = 1;
+       int is_r500 = 0;
+       GLuint vap_cntl;
 
        if (!(r300->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL))
                has_tcl = 0;
 
+        if (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515)
+                is_r500 = 1;
+
+
        /* FIXME: the values written to R300_VAP_INPUT_ROUTE_0_0 and
         * R300_VAP_INPUT_ROUTE_0_1 are in fact known, however, the values are
         * quite complex; see the functions in r300_emit.c.
@@ -199,25 +197,38 @@ static void r300EmitClearState(GLcontext * ctx)
         * these registers, as well as the actual values used for rendering.
         */
        R300_STATECHANGE(r300, vir[0]);
-       reg_start(R300_VAP_INPUT_ROUTE_0_0, 0);
+       reg_start(R300_VAP_PROG_STREAM_CNTL_0, 0);
        if (!has_tcl)
-               e32(0x22030003);
+           e32(((((0 << R300_DST_VEC_LOC_SHIFT) | R300_DATA_TYPE_FLOAT_4) << R300_DATA_TYPE_0_SHIFT) |
+                ((R300_LAST_VEC | (2 << R300_DST_VEC_LOC_SHIFT) | R300_DATA_TYPE_FLOAT_4) << R300_DATA_TYPE_1_SHIFT)));
        else
-               e32(0x21030003);
+           e32(((((0 << R300_DST_VEC_LOC_SHIFT) | R300_DATA_TYPE_FLOAT_4) << R300_DATA_TYPE_0_SHIFT) |
+                ((R300_LAST_VEC | (1 << R300_DST_VEC_LOC_SHIFT) | R300_DATA_TYPE_FLOAT_4) << R300_DATA_TYPE_1_SHIFT)));
 
        /* disable fog */
        R300_STATECHANGE(r300, fogs);
-       reg_start(R300_RE_FOG_STATE, 0);
+       reg_start(R300_FG_FOG_BLEND, 0);
        e32(0x0);
 
        R300_STATECHANGE(r300, vir[1]);
-       reg_start(R300_VAP_INPUT_ROUTE_1_0, 0);
-       e32(0xF688F688);
+       reg_start(R300_VAP_PROG_STREAM_CNTL_EXT_0, 0);
+       e32(((((R300_SWIZZLE_SELECT_X << R300_SWIZZLE_SELECT_X_SHIFT) |
+              (R300_SWIZZLE_SELECT_Y << R300_SWIZZLE_SELECT_Y_SHIFT) |
+              (R300_SWIZZLE_SELECT_Z << R300_SWIZZLE_SELECT_Z_SHIFT) |
+              (R300_SWIZZLE_SELECT_W << R300_SWIZZLE_SELECT_W_SHIFT) |
+              ((R300_WRITE_ENA_X | R300_WRITE_ENA_Y | R300_WRITE_ENA_Z | R300_WRITE_ENA_W) << R300_WRITE_ENA_SHIFT))
+             << R300_SWIZZLE0_SHIFT) |
+            (((R300_SWIZZLE_SELECT_X << R300_SWIZZLE_SELECT_X_SHIFT) |
+              (R300_SWIZZLE_SELECT_Y << R300_SWIZZLE_SELECT_Y_SHIFT) |
+              (R300_SWIZZLE_SELECT_Z << R300_SWIZZLE_SELECT_Z_SHIFT) |
+              (R300_SWIZZLE_SELECT_W << R300_SWIZZLE_SELECT_W_SHIFT) |
+              ((R300_WRITE_ENA_X | R300_WRITE_ENA_Y | R300_WRITE_ENA_Z | R300_WRITE_ENA_W) << R300_WRITE_ENA_SHIFT))
+             << R300_SWIZZLE1_SHIFT)));
 
        /* R300_VAP_INPUT_CNTL_0, R300_VAP_INPUT_CNTL_1 */
        R300_STATECHANGE(r300, vic);
-       reg_start(R300_VAP_INPUT_CNTL_0, 1);
-       e32(R300_INPUT_CNTL_0_COLOR);
+       reg_start(R300_VAP_VTX_STATE_CNTL, 1);
+       e32((R300_SEL_USER_COLOR_0 << R300_COLOR_0_ASSEMBLY_SHIFT));
        e32(R300_INPUT_CNTL_POS | R300_INPUT_CNTL_COLOR | R300_INPUT_CNTL_TC0);
 
        R300_STATECHANGE(r300, vte);
@@ -229,13 +240,13 @@ static void r300EmitClearState(GLcontext * ctx)
            R300_VPORT_Z_OFFSET_ENA);
        e32(0x8);
 
-       reg_start(0x21dc, 0);
+       reg_start(R300_VAP_PSC_SGN_NORM_CNTL, 0);
        e32(0xaaaaaaaa);
 
        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);
+           R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT);
        e32(0x0);               /* no textures */
 
        R300_STATECHANGE(r300, txe);
@@ -252,7 +263,7 @@ static void r300EmitClearState(GLcontext * ctx)
        efloat(0.0);
 
        R300_STATECHANGE(r300, at);
-       reg_start(R300_PP_ALPHA_TEST, 0);
+       reg_start(R300_FG_ALPHA_FUNC, 0);
        e32(0x0);
 
        R300_STATECHANGE(r300, bld);
@@ -260,78 +271,192 @@ static void r300EmitClearState(GLcontext * ctx)
        e32(0x0);
        e32(0x0);
 
-       R300_STATECHANGE(r300, unk221C);
-       reg_start(R300_VAP_UNKNOWN_221C, 0);
-       e32(R300_221C_CLEAR);
+       if (has_tcl) {
+           R300_STATECHANGE(r300, vap_clip_cntl);
+           reg_start(R300_VAP_CLIP_CNTL, 0);
+           e32(R300_PS_UCP_MODE_CLIP_AS_TRIFAN | R300_CLIP_DISABLE);
+        }
 
        R300_STATECHANGE(r300, ps);
-       reg_start(R300_RE_POINTSIZE, 0);
+       reg_start(R300_GA_POINT_SIZE, 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);
+       if (!is_r500) {
+               R300_STATECHANGE(r300, ri);
+               reg_start(R300_RS_IP_0, 7);
+               for (i = 0; i < 8; ++i) {
+                       e32(R300_RS_SEL_T(1) | R300_RS_SEL_R(2) | R300_RS_SEL_Q(3));
+               }
+
+               R300_STATECHANGE(r300, rc);
+               /* The second constant is needed to get glxgears display anything .. */
+               reg_start(R300_RS_COUNT, 1);
+               e32((1 << R300_IC_COUNT_SHIFT) | R300_HIRES_EN);
+               e32(0x0);
+
+               R300_STATECHANGE(r300, rr);
+               reg_start(R300_RS_INST_0, 0);
+               e32(R300_RS_INST_COL_CN_WRITE);
+       } else {
+               R300_STATECHANGE(r300, ri);
+               reg_start(R500_RS_IP_0, 7);
+               for (i = 0; i < 8; ++i) {
+                       e32((R500_RS_IP_PTR_K0 << R500_RS_IP_TEX_PTR_S_SHIFT) |
+                           (R500_RS_IP_PTR_K0 << R500_RS_IP_TEX_PTR_T_SHIFT) |
+                           (R500_RS_IP_PTR_K0 << R500_RS_IP_TEX_PTR_R_SHIFT) |
+                           (R500_RS_IP_PTR_K1 << R500_RS_IP_TEX_PTR_Q_SHIFT));
+               }
+
+               R300_STATECHANGE(r300, rc);
+               /* The second constant is needed to get glxgears display anything .. */
+               reg_start(R300_RS_COUNT, 1);
+               e32((1 << R300_IC_COUNT_SHIFT) | R300_HIRES_EN);
+               e32(0x0);
+
+               R300_STATECHANGE(r300, rr);
+               reg_start(R500_RS_INST_0, 0);
+               e32(R500_RS_INST_COL_CN_WRITE);
+
        }
 
-       R300_STATECHANGE(r300, rc);
-       /* The second constant is needed to get glxgears display anything .. */
-       reg_start(R300_RS_CNTL_0, 1);
-       e32((1 << R300_RS_CNTL_CI_CNT_SHIFT) | R300_RS_CNTL_0_UNKNOWN_18);
-       e32(0x0);
+       if (!is_r500) {
+               R300_STATECHANGE(r300, fp);
+               reg_start(R300_US_CONFIG, 2);
+               e32(0x0);
+               e32(0x0);
+               e32(0x0);
+               reg_start(R300_US_CODE_ADDR_0, 3);
+               e32(0x0);
+               e32(0x0);
+               e32(0x0);
+               e32(R300_RGBA_OUT);
 
-       R300_STATECHANGE(r300, rr);
-       reg_start(R300_RS_ROUTE_0, 0);
-       e32(R300_RS_ROUTE_0_COLOR);
+               R300_STATECHANGE(r300, fpi[0]);
+               R300_STATECHANGE(r300, fpi[1]);
+               R300_STATECHANGE(r300, fpi[2]);
+               R300_STATECHANGE(r300, fpi[3]);
 
-       R300_STATECHANGE(r300, fp);
-       reg_start(R300_PFS_CNTL_0, 2);
-       e32(0x0);
-       e32(0x0);
-       e32(0x0);
-       reg_start(R300_PFS_NODE_0, 3);
-       e32(0x0);
-       e32(0x0);
-       e32(0x0);
-       e32(R300_PFS_NODE_OUTPUT_COLOR);
+               reg_start(R300_US_ALU_RGB_INST_0, 0);
+               e32(FP_INSTRC(MAD, FP_ARGC(SRC0C_XYZ), FP_ARGC(ONE), FP_ARGC(ZERO)));
 
-       R300_STATECHANGE(r300, fpi[0]);
-       R300_STATECHANGE(r300, fpi[1]);
-       R300_STATECHANGE(r300, fpi[2]);
-       R300_STATECHANGE(r300, fpi[3]);
+               reg_start(R300_US_ALU_RGB_ADDR_0, 0);
+               e32(FP_SELC(0, NO, XYZ, FP_TMP(0), 0, 0));
 
-       reg_start(R300_PFS_INSTR0_0, 0);
-       e32(FP_INSTRC(MAD, FP_ARGC(SRC0C_XYZ), FP_ARGC(ONE), FP_ARGC(ZERO)));
+               reg_start(R300_US_ALU_ALPHA_INST_0, 0);
+               e32(FP_INSTRA(MAD, FP_ARGA(SRC0A), FP_ARGA(ONE), FP_ARGA(ZERO)));
 
-       reg_start(R300_PFS_INSTR1_0, 0);
-       e32(FP_SELC(0, NO, XYZ, FP_TMP(0), 0, 0));
+               reg_start(R300_US_ALU_ALPHA_ADDR_0, 0);
+               e32(FP_SELA(0, NO, W, FP_TMP(0), 0, 0));
+       } else {
+               R300_STATECHANGE(r300, fp);
+               reg_start(R500_US_CONFIG, 1);
+               e32(R500_ZERO_TIMES_ANYTHING_EQUALS_ZERO);
+               e32(0x0);
+               reg_start(R500_US_CODE_ADDR, 2);
+               e32(R500_US_CODE_START_ADDR(0) | R500_US_CODE_END_ADDR(1));
+               e32(R500_US_CODE_RANGE_ADDR(0) | R500_US_CODE_RANGE_SIZE(1));
+               e32(R500_US_CODE_OFFSET_ADDR(0));
+
+               R300_STATECHANGE(r300, r500fp);
+               r500fp_start_fragment(0, 6);
+
+               e32(R500_INST_TYPE_OUT |
+                   R500_INST_TEX_SEM_WAIT |
+                   R500_INST_LAST |
+                   R500_INST_RGB_OMASK_R |
+                   R500_INST_RGB_OMASK_G |
+                   R500_INST_RGB_OMASK_B |
+                   R500_INST_ALPHA_OMASK |
+                   R500_INST_RGB_CLAMP |
+                   R500_INST_ALPHA_CLAMP);
+
+               e32(R500_RGB_ADDR0(0) |
+                   R500_RGB_ADDR1(0) |
+                   R500_RGB_ADDR1_CONST |
+                   R500_RGB_ADDR2(0) |
+                   R500_RGB_ADDR2_CONST);
+
+               e32(R500_ALPHA_ADDR0(0) |
+                   R500_ALPHA_ADDR1(0) |
+                   R500_ALPHA_ADDR1_CONST |
+                   R500_ALPHA_ADDR2(0) |
+                   R500_ALPHA_ADDR2_CONST);
+
+               e32(R500_ALU_RGB_SEL_A_SRC0 |
+                   R500_ALU_RGB_R_SWIZ_A_R |
+                   R500_ALU_RGB_G_SWIZ_A_G |
+                   R500_ALU_RGB_B_SWIZ_A_B |
+                   R500_ALU_RGB_SEL_B_SRC0 |
+                   R500_ALU_RGB_R_SWIZ_B_R |
+                   R500_ALU_RGB_B_SWIZ_B_G |
+                   R500_ALU_RGB_G_SWIZ_B_B);
+
+               e32(R500_ALPHA_OP_CMP |
+                   R500_ALPHA_SWIZ_A_A |
+                   R500_ALPHA_SWIZ_B_A);
+
+               e32(R500_ALU_RGBA_OP_CMP |
+                   R500_ALU_RGBA_R_SWIZ_0 |
+                   R500_ALU_RGBA_G_SWIZ_0 |
+                   R500_ALU_RGBA_B_SWIZ_0 |
+                   R500_ALU_RGBA_A_SWIZ_0);
+       }
 
-       reg_start(R300_PFS_INSTR2_0, 0);
-       e32(FP_INSTRA(MAD, FP_ARGA(SRC0A), FP_ARGA(ONE), FP_ARGA(ZERO)));
+       reg_start(R300_VAP_PVS_STATE_FLUSH_REG, 0);
+       e32(0x00000000);
+       if (has_tcl) {
+           vap_cntl = ((10 << R300_PVS_NUM_SLOTS_SHIFT) |
+                       (5 << R300_PVS_NUM_CNTLRS_SHIFT) |
+                       (12 << R300_VF_MAX_VTX_NUM_SHIFT));
+           if (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515)
+               vap_cntl |= R500_TCL_STATE_OPTIMIZATION;
+       } else
+           vap_cntl = ((10 << R300_PVS_NUM_SLOTS_SHIFT) |
+                       (5 << R300_PVS_NUM_CNTLRS_SHIFT) |
+                       (5 << R300_VF_MAX_VTX_NUM_SHIFT));
+
+       if (r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV515)
+           vap_cntl |= (2 << R300_PVS_NUM_FPUS_SHIFT);
+       else if ((r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV530) ||
+                (r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV560) ||
+                (r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV570))
+           vap_cntl |= (5 << R300_PVS_NUM_FPUS_SHIFT);
+       else if ((r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV410) ||
+                (r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_R420))
+           vap_cntl |= (6 << R300_PVS_NUM_FPUS_SHIFT);
+       else if ((r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_R520) ||
+                (r300->radeon.radeonScreen->chip_family == CHIP_FAMILY_R580))
+           vap_cntl |= (8 << R300_PVS_NUM_FPUS_SHIFT);
+       else
+           vap_cntl |= (4 << R300_PVS_NUM_FPUS_SHIFT);
 
-       reg_start(R300_PFS_INSTR3_0, 0);
-       e32(FP_SELA(0, NO, W, FP_TMP(0), 0, 0));
+       R300_STATECHANGE(rmesa, vap_cntl);
+       reg_start(R300_VAP_CNTL, 0);
+       e32(vap_cntl);
 
        if (has_tcl) {
                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(0x0);
-               e32(1 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT);
+               reg_start(R300_VAP_PVS_CODE_CNTL_0, 2);
+
+               e32((0 << R300_PVS_FIRST_INST_SHIFT) |
+                   (0 << R300_PVS_XYZW_VALID_INST_SHIFT) |
+                   (1 << R300_PVS_LAST_INST_SHIFT));
+               e32((0 << R300_PVS_CONST_BASE_OFFSET_SHIFT) |
+                   (0 << R300_PVS_MAX_CONST_ADDR_SHIFT));
+               e32(1 << R300_PVS_LAST_VTX_SRC_INST_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(PVS_OP_DST_OPERAND(VE_ADD, GL_FALSE, GL_FALSE, 0, 0xf, PVS_DST_REG_OUT));
+               e32(PVS_SRC_OPERAND(0, PVS_SRC_SELECT_X, PVS_SRC_SELECT_Y, PVS_SRC_SELECT_Z, PVS_SRC_SELECT_W, PVS_SRC_REG_INPUT, VSF_FLAG_NONE));
+               e32(PVS_SRC_OPERAND(0, PVS_SRC_SELECT_FORCE_0, PVS_SRC_SELECT_FORCE_0, PVS_SRC_SELECT_FORCE_0, PVS_SRC_SELECT_FORCE_0, PVS_SRC_REG_INPUT, VSF_FLAG_NONE));
                e32(0x0);
 
-               e32(VP_OUT(ADD, OUT, 1, XYZW));
-               e32(VP_IN(IN, 1));
-               e32(VP_ZERO());
+               e32(PVS_OP_DST_OPERAND(VE_ADD, GL_FALSE, GL_FALSE, 1, 0xf, PVS_DST_REG_OUT));
+               e32(PVS_SRC_OPERAND(1, PVS_SRC_SELECT_X, PVS_SRC_SELECT_Y, PVS_SRC_SELECT_Z, PVS_SRC_SELECT_W, PVS_SRC_REG_INPUT, VSF_FLAG_NONE));
+               e32(PVS_SRC_OPERAND(1, PVS_SRC_SELECT_FORCE_0, PVS_SRC_SELECT_FORCE_0, PVS_SRC_SELECT_FORCE_0, PVS_SRC_SELECT_FORCE_0, PVS_SRC_REG_INPUT, VSF_FLAG_NONE));
                e32(0x0);
        }
 }
diff --git a/src/mesa/drivers/dri/r300/r300_program.h b/src/mesa/drivers/dri/r300/r300_program.h
deleted file mode 100644 (file)
index eddd783..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
-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 gl_vertex_program *vp);
-
-#endif                         /* __R300_PROGRAM_H__ */
index 1baa74c5269e6d929d2381aa03db653cdc8c1533..778db96cc1fd184f6afd1653018f5a6cce23b5fd 100644 (file)
@@ -67,9 +67,15 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 /*
  * Vertex Array Processing (VAP) Control
- * Stolen from r200 code from Christoph Brill (It's a guess!)
  */
 #define R300_VAP_CNTL  0x2080
+#       define R300_PVS_NUM_SLOTS_SHIFT                 0
+#       define R300_PVS_NUM_CNTLRS_SHIFT                4
+#       define R300_PVS_NUM_FPUS_SHIFT                  8
+#       define R300_VF_MAX_VTX_NUM_SHIFT                18
+#       define R300_GL_CLIP_SPACE_DEF                   (0 << 22)
+#       define R300_DX_CLIP_SPACE_DEF                   (1 << 22)
+#       define R500_TCL_STATE_OPTIMIZATION              (1 << 23)
 
 /* This register is written directly and also starts data section
  * in many 3d CP_PACKET3's
@@ -106,14 +112,15 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
        /* number of vertices */
 #      define  R300_VAP_VF_CNTL__NUM_VERTICES__SHIFT           16
 
-/* BEGIN: Wild guesses */
+#define R500_VAP_INDEX_OFFSET              0x208c
+
 #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_0__COLOR_0_PRESENT (1<<1)
+#       define R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT (1<<2)
+#       define R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT (1<<3)
+#       define R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT (1<<4)
+#       define R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT (1<<16)
 
 #define R300_VAP_OUTPUT_VTX_FMT_1           0x2094
        /* each of the following is 3 bits wide, specifies number
@@ -126,30 +133,64 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #       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: Wild guesses */
+#      define R300_VAP_OUTPUT_VTX_FMT_1__NOT_PRESENT  0
+#      define R300_VAP_OUTPUT_VTX_FMT_1__1_COMPONENT  1
+#      define R300_VAP_OUTPUT_VTX_FMT_1__2_COMPONENTS 2
+#      define R300_VAP_OUTPUT_VTX_FMT_1__3_COMPONENTS 3
+#      define R300_VAP_OUTPUT_VTX_FMT_1__4_COMPONENTS 4
 
 #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
+#      define     R300_VPORT_X_SCALE_ENA                (1 << 0)
+#      define     R300_VPORT_X_OFFSET_ENA               (1 << 1)
+#      define     R300_VPORT_Y_SCALE_ENA                (1 << 2)
+#      define     R300_VPORT_Y_OFFSET_ENA               (1 << 3)
+#      define     R300_VPORT_Z_SCALE_ENA                (1 << 4)
+#      define     R300_VPORT_Z_OFFSET_ENA               (1 << 5)
+#      define     R300_VTX_XY_FMT                       (1 << 8)
+#      define     R300_VTX_Z_FMT                        (1 << 9)
+#      define     R300_VTX_W0_FMT                       (1 << 10)
+#      define     R300_SERIAL_PROC_ENA                  (1 << 11)
 
 /* BEGIN: Vertex data assembly - lots of uncertainties */
 
 /* gap */
 
+/* Maximum Vertex Indx Clamp */
+#define R300_VAP_VF_MAX_VTX_INDX         0x2134
+/* Minimum Vertex Indx Clamp */
+#define R300_VAP_VF_MIN_VTX_INDX         0x2138
+
+/** Vertex assembler/processor control status */
 #define R300_VAP_CNTL_STATUS              0x2140
+/* No swap at all (default) */
 #      define R300_VC_NO_SWAP                  (0 << 0)
+/* 16-bit swap: 0xAABBCCDD becomes 0xBBAADDCC */
 #      define R300_VC_16BIT_SWAP               (1 << 0)
+/* 32-bit swap: 0xAABBCCDD becomes 0xDDCCBBAA */
 #      define R300_VC_32BIT_SWAP               (2 << 0)
+/* Half-dword swap: 0xAABBCCDD becomes 0xCCDDAABB */
+#      define R300_VC_HALF_DWORD_SWAP          (3 << 0)
+/* The TCL engine will not be used (as it is logically or even physically removed) */
 #      define R300_VAP_TCL_BYPASS              (1 << 8)
+/* Read only flag if TCL engine is busy. */
+#      define R300_VAP_PVS_BUSY                (1 << 11)
+/* TODO: gap for MAX_MPS */
+/* Read only flag if the vertex store is busy. */
+#      define R300_VAP_VS_BUSY                 (1 << 24)
+/* Read only flag if the reciprocal engine is busy. */
+#      define R300_VAP_RCP_BUSY                (1 << 25)
+/* Read only flag if the viewport transform engine is busy. */
+#      define R300_VAP_VTE_BUSY                (1 << 26)
+/* Read only flag if the memory interface unit is busy. */
+#      define R300_VAP_MUI_BUSY                (1 << 27)
+/* Read only flag if the vertex cache is busy. */
+#      define R300_VAP_VC_BUSY                 (1 << 28)
+/* Read only flag if the vertex fetcher is busy. */
+#      define R300_VAP_VF_BUSY                 (1 << 29)
+/* Read only flag if the register pipeline is busy. */
+#      define R300_VAP_REGPIPE_BUSY            (1 << 30)
+/* Read only flag if the VAP engine is busy. */
+#      define R300_VAP_VAP_BUSY                (1 << 31)
 
 /* gap */
 
@@ -177,27 +218,31 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  * 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
-
+#define R300_VAP_PROG_STREAM_CNTL_0                     0x2150
+#       define R300_DATA_TYPE_0_SHIFT                   0
+#       define R300_DATA_TYPE_FLOAT_1                   0
+#       define R300_DATA_TYPE_FLOAT_2                   1
+#       define R300_DATA_TYPE_FLOAT_3                   2
+#       define R300_DATA_TYPE_FLOAT_4                   3
+#       define R300_DATA_TYPE_BYTE                      4
+#       define R300_DATA_TYPE_D3DCOLOR                  5
+#       define R300_DATA_TYPE_SHORT_2                   6
+#       define R300_DATA_TYPE_SHORT_4                   7
+#       define R300_DATA_TYPE_VECTOR_3_TTT              8
+#       define R300_DATA_TYPE_VECTOR_3_EET              9
+#       define R300_SKIP_DWORDS_SHIFT                   4
+#       define R300_DST_VEC_LOC_SHIFT                   8
+#       define R300_LAST_VEC                            (1 << 13)
+#       define R300_SIGNED                              (1 << 14)
+#       define R300_NORMALIZE                           (1 << 15)
+#       define R300_DATA_TYPE_1_SHIFT                   16
+#define R300_VAP_PROG_STREAM_CNTL_1                     0x2154
+#define R300_VAP_PROG_STREAM_CNTL_2                     0x2158
+#define R300_VAP_PROG_STREAM_CNTL_3                     0x215C
+#define R300_VAP_PROG_STREAM_CNTL_4                     0x2160
+#define R300_VAP_PROG_STREAM_CNTL_5                     0x2164
+#define R300_VAP_PROG_STREAM_CNTL_6                     0x2168
+#define R300_VAP_PROG_STREAM_CNTL_7                     0x216C
 /* gap */
 
 /* Notes:
@@ -205,9 +250,26 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  *    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_VAP_VTX_STATE_CNTL               0x2180
+#       define R300_COLOR_0_ASSEMBLY_SHIFT    0
+#       define R300_SEL_COLOR                 0
+#       define R300_SEL_USER_COLOR_0          1
+#       define R300_SEL_USER_COLOR_1          2
+#       define R300_COLOR_1_ASSEMBLY_SHIFT    2
+#       define R300_COLOR_2_ASSEMBLY_SHIFT    4
+#       define R300_COLOR_3_ASSEMBLY_SHIFT    6
+#       define R300_COLOR_4_ASSEMBLY_SHIFT    8
+#       define R300_COLOR_5_ASSEMBLY_SHIFT    10
+#       define R300_COLOR_6_ASSEMBLY_SHIFT    12
+#       define R300_COLOR_7_ASSEMBLY_SHIFT    14
+#       define R300_UPDATE_USER_COLOR_0_ENA   (1 << 16)
+
+/*
+ * Each bit in this field applies to the corresponding vector in the VSM
+ * memory (i.e. Bit 0 applies to VECTOR_0 (POSITION), etc.). If the bit
+ * is set, then the corresponding 4-Dword Vector is output into the Vertex Stream.
+ */
+#define R300_VAP_VSM_VTX_ASSM               0x2184
 #       define R300_INPUT_CNTL_POS               0x00000001
 #       define R300_INPUT_CNTL_NORMAL            0x00000002
 #       define R300_INPUT_CNTL_COLOR             0x00000004
@@ -220,6 +282,12 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #       define R300_INPUT_CNTL_TC6               0x00010000 /* GUESS */
 #       define R300_INPUT_CNTL_TC7               0x00020000 /* GUESS */
 
+/* Programmable Stream Control Signed Normalize Control */
+#define R300_VAP_PSC_SGN_NORM_CNTL         0x21dc
+#      define SGN_NORM_ZERO                 0
+#      define SGN_NORM_ZERO_CLAMP_MINUS_ONE 1
+#      define SGN_NORM_NO_ZERO              2
+
 /* gap */
 
 /* Words parallel to INPUT_ROUTE_0; All words that are active in INPUT_ROUTE_0
@@ -229,26 +297,40 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  * 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_VAP_PROG_STREAM_CNTL_EXT_0                 0x21e0
+#       define R300_SWIZZLE0_SHIFT                      0
+#       define R300_SWIZZLE_SELECT_X_SHIFT              0
+#       define R300_SWIZZLE_SELECT_Y_SHIFT              3
+#       define R300_SWIZZLE_SELECT_Z_SHIFT              6
+#       define R300_SWIZZLE_SELECT_W_SHIFT              9
+
+#       define R300_SWIZZLE_SELECT_X                    0
+#       define R300_SWIZZLE_SELECT_Y                    1
+#       define R300_SWIZZLE_SELECT_Z                    2
+#       define R300_SWIZZLE_SELECT_W                    3
+#       define R300_SWIZZLE_SELECT_FP_ZERO              4
+#       define R300_SWIZZLE_SELECT_FP_ONE               5
+/* alternate forms for r300_emit.c */
 #       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
+
+#       define R300_WRITE_ENA_SHIFT                     12
+#       define R300_WRITE_ENA_X                         1
+#       define R300_WRITE_ENA_Y                         2
+#       define R300_WRITE_ENA_Z                         4
+#       define R300_WRITE_ENA_W                         8
+#       define R300_SWIZZLE1_SHIFT                      16
+#define R300_VAP_PROG_STREAM_CNTL_EXT_1                 0x21e4
+#define R300_VAP_PROG_STREAM_CNTL_EXT_2                 0x21e8
+#define R300_VAP_PROG_STREAM_CNTL_EXT_3                 0x21ec
+#define R300_VAP_PROG_STREAM_CNTL_EXT_4                 0x21f0
+#define R300_VAP_PROG_STREAM_CNTL_EXT_5                 0x21f4
+#define R300_VAP_PROG_STREAM_CNTL_EXT_6                 0x21f8
+#define R300_VAP_PROG_STREAM_CNTL_EXT_7                 0x21fc
 
 /* END: Vertex data assembly */
 
@@ -280,18 +362,20 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  * 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
-/* gap */
-#       define R300_PVS_UPLOAD_PARAMETERS        0x00000200
-/* gap */
-#       define R300_PVS_UPLOAD_CLIP_PLANE0       0x00000400
-#       define R300_PVS_UPLOAD_CLIP_PLANE1       0x00000401
-#       define R300_PVS_UPLOAD_CLIP_PLANE2       0x00000402
-#       define R300_PVS_UPLOAD_CLIP_PLANE3       0x00000403
-#       define R300_PVS_UPLOAD_CLIP_PLANE4       0x00000404
-#       define R300_PVS_UPLOAD_CLIP_PLANE5       0x00000405
-#       define R300_PVS_UPLOAD_POINTSIZE         0x00000406
+#define R300_VAP_PVS_VECTOR_INDX_REG         0x2200
+#       define R300_PVS_CODE_START           0
+#       define R300_MAX_PVS_CODE_LINES       256
+#       define R500_MAX_PVS_CODE_LINES       1024
+#       define R300_PVS_CONST_START          512
+#       define R500_PVS_CONST_START          1024
+#       define R300_MAX_PVS_CONST_VECS       256
+#       define R500_MAX_PVS_CONST_VECS       1024
+#       define R300_PVS_UCP_START            1024
+#       define R500_PVS_UCP_START            1536
+#       define R300_POINT_VPORT_SCALE_OFFSET 1030
+#       define R500_POINT_VPORT_SCALE_OFFSET 1542
+#       define R300_POINT_GEN_TEX_OFFSET     1031
+#       define R500_POINT_GEN_TEX_OFFSET     1543
 
 /*
  * These are obsolete defines form r300_context.h, but they might give some
@@ -319,10 +403,28 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 /* 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.
+ *
+ * 2007-11-05: This register is the user clip plane control register, but there
+ * also seems to be a rendering mode control; the NORMAL/CLEAR defines.
+ *
+ * See bug #9871. http://bugs.freedesktop.org/attachment.cgi?id=10672&action=view
  */
-#define R300_VAP_UNKNOWN_221C               0x221C
-#       define R300_221C_NORMAL                  0x00000000
-#       define R300_221C_CLEAR                   0x0001C000
+#define R300_VAP_CLIP_CNTL                       0x221C
+#       define R300_VAP_UCP_ENABLE_0             (1 << 0)
+#       define R300_VAP_UCP_ENABLE_1             (1 << 1)
+#       define R300_VAP_UCP_ENABLE_2             (1 << 2)
+#       define R300_VAP_UCP_ENABLE_3             (1 << 3)
+#       define R300_VAP_UCP_ENABLE_4             (1 << 4)
+#       define R300_VAP_UCP_ENABLE_5             (1 << 5)
+#       define R300_PS_UCP_MODE_DIST_COP         (0 << 14)
+#       define R300_PS_UCP_MODE_RADIUS_COP       (1 << 14)
+#       define R300_PS_UCP_MODE_RADIUS_COP_CLIP  (2 << 14)
+#       define R300_PS_UCP_MODE_CLIP_AS_TRIFAN   (3 << 14)
+#       define R300_CLIP_DISABLE                 (1 << 16)
+#       define R300_UCP_CULL_ONLY_ENABLE         (1 << 17)
+#       define R300_BOUNDARY_EDGE_FLAG_ENABLE    (1 << 18)
+#       define R500_COLOR2_IS_TEXTURE            (1 << 20)
+#       define R500_COLOR3_IS_TEXTURE            (1 << 21)
 
 /* These seem to be per-pixel and per-vertex X and Y clipping planes. The first
  * plane is per-pixel and the second plane is per-vertex.
@@ -331,10 +433,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  * These registers are called X_QUAD0_1_FL to X_QUAD0_4_FL by glxtest.
  */
-#define R300_VAP_CLIP_X_0                   0x2220
-#define R300_VAP_CLIP_X_1                   0x2224
-#define R300_VAP_CLIP_Y_0                   0x2228
-#define R300_VAP_CLIP_Y_1                   0x2230
+#define R300_VAP_GB_VERT_CLIP_ADJ                   0x2220
+#define R300_VAP_GB_VERT_DISC_ADJ                   0x2224
+#define R300_VAP_GB_HORZ_CLIP_ADJ                   0x2228
+#define R300_VAP_GB_HORZ_DISC_ADJ                   0x222c
 
 /* gap */
 
@@ -343,10 +445,14 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  * 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 */
+#define R300_VAP_PVS_STATE_FLUSH_REG        0x2284
 
-/* Absolutely no clue what this register is about. */
-#define R300_VAP_UNKNOWN_2288               0x2288
+/* This register is used to define the number of core clocks to wait for a
+ * vertex to be received by the VAP input controller (while the primitive
+ * path is backed up) before forcing any accumulated vertices to be submitted
+ * to the vertex processing path.
+ */
+#define VAP_PVS_VTX_TIMEOUT_REG             0x2288
 #       define R300_2288_R300                    0x00750000 /* -- nh */
 #       define R300_2288_RV350                   0x0000FFFF /* -- Vladimir */
 
@@ -369,17 +475,17 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  * 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
+#define R300_VAP_PVS_CODE_CNTL_0            0x22D0
+#       define R300_PVS_FIRST_INST_SHIFT         0
+#       define R300_PVS_XYZW_VALID_INST_SHIFT    10
+#       define R300_PVS_LAST_INST_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
+#define R300_VAP_PVS_CONST_CNTL             0x22D4
+#       define R300_PVS_CONST_BASE_OFFSET_SHIFT  0
+#       define R300_PVS_MAX_CONST_ADDR_SHIFT     16
+#define R300_VAP_PVS_CODE_CNTL_1           0x22D8
+#       define R300_PVS_LAST_VTX_SRC_INST_SHIFT  0
+#define R300_VAP_PVS_FLOW_CNTL_OPC          0x22DC
 
 /* The entire range from 0x2300 to 0x2AC inclusive seems to be used for
  * immediate vertices
@@ -427,17 +533,23 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  * (or something closely related to that).
  * This bit is rather fatal at the time being due to lackings at pixel
  * shader side
+ * Specifies top of Raster pipe specific enable controls.
  */
 #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_UNK31                    (1<<31)
+#      define R300_GB_POINT_STUFF_DISABLE     (0 << 0)
+#      define R300_GB_POINT_STUFF_ENABLE      (1 << 0) /* Specifies if points will have stuffed texture coordinates. */
+#      define R300_GB_LINE_STUFF_DISABLE      (0 << 1)
+#      define R300_GB_LINE_STUFF_ENABLE       (1 << 1) /* Specifies if lines will have stuffed texture coordinates. */
+#      define R300_GB_TRIANGLE_STUFF_DISABLE  (0 << 2)
+#      define R300_GB_TRIANGLE_STUFF_ENABLE   (1 << 2) /* Specifies if triangles will have stuffed texture coordinates. */
+#      define R300_GB_STENCIL_AUTO_DISABLE    (0 << 4)
+#      define R300_GB_STENCIL_AUTO_ENABLE     (1 << 4) /* Enable stencil auto inc/dec based on triangle cw/ccw, force into dzy low bit. */
+#      define R300_GB_STENCIL_AUTO_FORCE      (2 << 4) /* Force 0 into dzy low bit. */
+
        /* 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_TEX_REPLICATE  0 /* Replicate VAP source texture coordinates (S,T,[R,Q]). */
+#define R300_GB_TEX_ST         1 /* Stuff with source texture coordinates (S,T). */
+#define R300_GB_TEX_STR                2 /* Stuff with source texture coordinates (S,T,R). */
 #      define R300_GB_TEX0_SOURCE_SHIFT        16
 #      define R300_GB_TEX1_SOURCE_SHIFT        18
 #      define R300_GB_TEX2_SOURCE_SHIFT        20
@@ -448,7 +560,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #      define R300_GB_TEX7_SOURCE_SHIFT        30
 
 /* MSPOS - positions for multisample antialiasing (?) */
-#define R300_GB_MSPOS0 0x4010
+#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
@@ -459,7 +571,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #      define R300_GB_MSPOS0__MSBD0_Y          24
 #      define R300_GB_MSPOS0__MSBD0_X          28
 
-#define R300_GB_MSPOS1 0x4014
+#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
@@ -468,31 +580,47 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #      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_PIPE_COUNT_RV410    (3<<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)
+/* Specifies the graphics pipeline configuration for rasterization. */
+#define R300_GB_TILE_CONFIG                      0x4018
+#      define R300_GB_TILE_DISABLE             (0 << 0)
+#      define R300_GB_TILE_ENABLE              (1 << 0)
+#      define R300_GB_TILE_PIPE_COUNT_RV300    (0 << 1) /* RV350 (1 pipe, 1 ctx) */
+#      define R300_GB_TILE_PIPE_COUNT_R300     (3 << 1) /* R300 (2 pipes, 1 ctx) */
+#      define R300_GB_TILE_PIPE_COUNT_R420_3P  (6 << 1) /* R420-3P (3 pipes, 1 ctx) */
+#      define R300_GB_TILE_PIPE_COUNT_R420     (7 << 1) /* R420 (4 pipes, 1 ctx) */
+#      define R300_GB_TILE_SIZE_8              (0 << 4)
+#      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_SUPER_TILE_A             (0 << 15)
+#      define R300_GB_SUPER_TILE_B             (1 << 15)
+#      define R300_GB_SUBPIXEL_1_12            (0 << 16)
+#      define R300_GB_SUBPIXEL_1_16            (1 << 16)
+#      define GB_TILE_CONFIG_QUADS_PER_RAS_4   (0 << 17)
+#      define GB_TILE_CONFIG_QUADS_PER_RAS_8   (1 << 17)
+#      define GB_TILE_CONFIG_QUADS_PER_RAS_16  (2 << 17)
+#      define GB_TILE_CONFIG_QUADS_PER_RAS_32  (3 << 17)
+#      define GB_TILE_CONFIG_BB_SCAN_INTERCEPT (0 << 19)
+#      define GB_TILE_CONFIG_BB_SCAN_BOUND_BOX (1 << 19)
+#      define GB_TILE_CONFIG_ALT_SCAN_EN_LR    (0 << 20)
+#      define GB_TILE_CONFIG_ALT_SCAN_EN_LRL   (1 << 20)
+#      define GB_TILE_CONFIG_ALT_OFFSET        (0 << 21)
+#      define GB_TILE_CONFIG_SUBPRECISION      (0 << 22)
+#      define GB_TILE_CONFIG_ALT_TILING_DEF    (0 << 23)
+#      define GB_TILE_CONFIG_ALT_TILING_3_2    (1 << 23)
+#      define GB_TILE_CONFIG_Z_EXTENDED_24_1   (0 << 24)
+#      define GB_TILE_CONFIG_Z_EXTENDED_S25_1  (1 << 24)
+
+/* Specifies the sizes of the various FIFO`s in the sc/rs/us. This register must be the first one written */
 #define R300_GB_FIFO_SIZE      0x4024
        /* each of the following is 2 bits wide */
 #define R300_GB_FIFO_SIZE_32   0
@@ -516,30 +644,102 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #      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_DISABLE                  0x00
-#      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)
+#define GB_Z_PEQ_CONFIG                          0x4028
+#      define GB_Z_PEQ_CONFIG_Z_PEQ_SIZE_4_4    (0 << 0)
+#      define GB_Z_PEQ_CONFIG_Z_PEQ_SIZE_8_8    (1 << 0)
+
+/* Specifies various polygon specific selects (fog, depth, perspective). */
+#define R300_GB_SELECT                           0x401c
+#      define R300_GB_FOG_SELECT_C0A           (0 << 0)
+#      define R300_GB_FOG_SELECT_C1A           (1 << 0)
+#      define R300_GB_FOG_SELECT_C2A           (2 << 0)
+#      define R300_GB_FOG_SELECT_C3A           (3 << 0)
+#      define R300_GB_FOG_SELECT_1_1_W         (4 << 0)
+#      define R300_GB_FOG_SELECT_Z             (5 << 0)
+#      define R300_GB_DEPTH_SELECT_Z           (0 << 3
+#      define R300_GB_DEPTH_SELECT_1_1_W       (1 << 3)
+#      define R300_GB_W_SELECT_1_W             (0 << 4)
+#      define R300_GB_W_SELECT_1               (1 << 4)
+#      define R300_GB_FOG_STUFF_DISABLE        (0 << 5)
+#      define R300_GB_FOG_STUFF_ENABLE         (1 << 5)
+#      define R300_GB_FOG_STUFF_TEX_SHIFT      6
+#      define R300_GB_FOG_STUFF_TEX_MASK       0x000003c0
+#      define R300_GB_FOG_STUFF_COMP_SHIFT     10
+#      define R300_GB_FOG_STUFF_COMP_MASK      0x00000c00
+
+/* Specifies the graphics pipeline configuration for antialiasing. */
+#define GB_AA_CONFIG                                    0x4020
+#      define GB_AA_CONFIG_AA_DISABLE           (0 << 0)
+#      define GB_AA_CONFIG_AA_ENABLE            (1 << 0)
+#      define GB_AA_CONFIG_NUM_AA_SUBSAMPLES_2  (0 << 1)
+#      define GB_AA_CONFIG_NUM_AA_SUBSAMPLES_3  (1 << 1)
+#      define GB_AA_CONFIG_NUM_AA_SUBSAMPLES_4  (2 << 1)
+#      define GB_AA_CONFIG_NUM_AA_SUBSAMPLES_6  (3 << 1)
+
+/* Selects which of 4 pipes are active. */
+#define GB_PIPE_SELECT                           0x402c
+#      define GB_PIPE_SELECT_PIPE0_ID_SHIFT  0
+#      define GB_PIPE_SELECT_PIPE1_ID_SHIFT  2
+#      define GB_PIPE_SELECT_PIPE2_ID_SHIFT  4
+#      define GB_PIPE_SELECT_PIPE3_ID_SHIFT  6
+#      define GB_PIPE_SELECT_PIPE_MASK_SHIFT 8
+#      define GB_PIPE_SELECT_MAX_PIPE        12
+#      define GB_PIPE_SELECT_BAD_PIPES       14
+#      define GB_PIPE_SELECT_CONFIG_PIPES    18
+
+
+/* Specifies the sizes of the various FIFO`s in the sc/rs. */
+#define GB_FIFO_SIZE1                            0x4070
+/* High water mark for SC input fifo */
+#      define GB_FIFO_SIZE1_SC_HIGHWATER_IFIFO_SHIFT 0
+#      define GB_FIFO_SIZE1_SC_HIGHWATER_IFIFO_MASK  0x0000003f
+/* High water mark for SC input fifo (B) */
+#      define GB_FIFO_SIZE1_SC_HIGHWATER_BFIFO_SHIFT 6
+#      define GB_FIFO_SIZE1_SC_HIGHWATER_BFIFO_MASK  0x00000fc0
+/* High water mark for RS colors' fifo */
+#      define GB_FIFO_SIZE1_SC_HIGHWATER_COL_SHIFT   12
+#      define GB_FIFO_SIZE1_SC_HIGHWATER_COL_MASK    0x0003f000
+/* High water mark for RS textures' fifo */
+#      define GB_FIFO_SIZE1_SC_HIGHWATER_TEX_SHIFT   18
+#      define GB_FIFO_SIZE1_SC_HIGHWATER_TEX_MASK    0x00fc0000
+
+/* This table specifies the source location and format for up to 16 texture
+ * addresses (i[0]:i[15]) and four colors (c[0]:c[3])
+ */
+#define R500_RS_IP_0                                   0x4074
+#define R500_RS_IP_1                                   0x4078
+#define R500_RS_IP_2                                   0x407C
+#define R500_RS_IP_3                                   0x4080
+#define R500_RS_IP_4                                   0x4084
+#define R500_RS_IP_5                                   0x4088
+#define R500_RS_IP_6                                   0x408C
+#define R500_RS_IP_7                                   0x4090
+#define R500_RS_IP_8                                   0x4094
+#define R500_RS_IP_9                                   0x4098
+#define R500_RS_IP_10                                  0x409C
+#define R500_RS_IP_11                                  0x40A0
+#define R500_RS_IP_12                                  0x40A4
+#define R500_RS_IP_13                                  0x40A8
+#define R500_RS_IP_14                                  0x40AC
+#define R500_RS_IP_15                                  0x40B0
+#define R500_RS_IP_PTR_K0                               62
+#define R500_RS_IP_PTR_K1                               63
+#define R500_RS_IP_TEX_PTR_S_SHIFT                     0
+#define R500_RS_IP_TEX_PTR_T_SHIFT                     6
+#define R500_RS_IP_TEX_PTR_R_SHIFT                     12
+#define R500_RS_IP_TEX_PTR_Q_SHIFT                     18
+#define R500_RS_IP_COL_PTR_SHIFT                       24
+#define R500_RS_IP_COL_FMT_SHIFT                       27
+#      define R500_RS_COL_PTR(x)                       (x << 24)
+#       define R500_RS_COL_FMT(x)                       (x << 27)
+/* gap */
+#define R500_RS_IP_OFFSET_DIS                          (0 << 31)
+#define R500_RS_IP_OFFSET_EN                           (1 << 31)
 
 /* gap */
 
 /* Zero to flush caches. */
-#define R300_TX_CNTL                        0x4100
+#define R300_TX_INVALTAGS                   0x4100
 #define R300_TX_FLUSH                       0x0
 
 /* The upper enable bits are guessed, based on fglrx reported limits. */
@@ -561,53 +761,335 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #       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 R500_TX_FILTER_4                   0x4110
+#      define R500_TX_WEIGHT_1_SHIFT            (0)
+#      define R500_TX_WEIGHT_0_SHIFT            (11)
+#      define R500_TX_WEIGHT_PAIR               (1<<22)
+#      define R500_TX_PHASE_SHIFT               (23)
+#      define R500_TX_DIRECTION_HORIZONTAL      (0<<27)
+#      define R500_TX_DIRECTION_VERITCAL        (1<<27)
+
+/* S Texture Coordinate of Vertex 0 for Point texture stuffing (LLC) */
+#define R300_GA_POINT_S0                              0x4200
+
+/* T Texture Coordinate of Vertex 0 for Point texture stuffing (LLC) */
+#define R300_GA_POINT_T0                              0x4204
+
+/* S Texture Coordinate of Vertex 2 for Point texture stuffing (URC) */
+#define R300_GA_POINT_S1                              0x4208
+
+/* T Texture Coordinate of Vertex 2 for Point texture stuffing (URC) */
+#define R300_GA_POINT_T1                              0x420c
+
+/* Specifies amount to shift integer position of vertex (screen space) before
+ * converting to float for triangle stipple.
+ */
+#define R300_GA_TRIANGLE_STIPPLE            0x4214
+#      define R300_GA_TRIANGLE_STIPPLE_X_SHIFT_SHIFT 0
+#      define R300_GA_TRIANGLE_STIPPLE_X_SHIFT_MASK  0x0000000f
+#      define R300_GA_TRIANGLE_STIPPLE_Y_SHIFT_SHIFT 16
+#      define R300_GA_TRIANGLE_STIPPLE_Y_SHIFT_MASK  0x000f0000
+
+/* The pointsize is given in multiples of 6. The pointsize can be enormous:
+ * Clear() renders a single point that fills the entire framebuffer.
+ * 1/2 Height of point; fixed (16.0), subpixel format (1/12 or 1/16, even if in
+ * 8b precision).
  */
-#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_GA_POINT_SIZE                   0x421C
+#       define R300_POINTSIZE_Y_SHIFT         0
+#       define R300_POINTSIZE_Y_MASK          0x0000ffff
+#       define R300_POINTSIZE_X_SHIFT         16
+#       define R300_POINTSIZE_X_MASK          0xffff0000
 #       define R300_POINTSIZE_MAX             (R300_POINTSIZE_Y_MASK / 6)
 
-/* The line width is given in multiples of 6.
+/* Blue fill color */
+#define R500_GA_FILL_R                                0x4220
+
+/* Blue fill color */
+#define R500_GA_FILL_G                                0x4224
+
+/* Blue fill color */
+#define R500_GA_FILL_B                                0x4228
+
+/* Alpha fill color */
+#define R500_GA_FILL_A                                0x422c
+
+
+/* Specifies maximum and minimum point & sprite sizes for per vertex size
+ * specification. The lower part (15:0) is MIN and (31:16) is max.
+ */
+#define R300_GA_POINT_MINMAX                0x4230
+#       define R300_GA_POINT_MINMAX_MIN_SHIFT          0
+#       define R300_GA_POINT_MINMAX_MIN_MASK           (0xFFFF << 0)
+#       define R300_GA_POINT_MINMAX_MAX_SHIFT          16
+#       define R300_GA_POINT_MINMAX_MAX_MASK           (0xFFFF << 16)
+
+/* 1/2 width of line, in subpixels (1/12 or 1/16 only, even in 8b
+ * subprecision); (16.0) fixed format.
+ *
+ * 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_GA_LINE_CNTL                             0x4234
+#       define R300_GA_LINE_CNTL_WIDTH_SHIFT       0
+#       define R300_GA_LINE_CNTL_WIDTH_MASK        0x0000ffff
+#      define R300_GA_LINE_CNTL_END_TYPE_HOR      (0 << 16)
+#      define R300_GA_LINE_CNTL_END_TYPE_VER      (1 << 16)
+#      define R300_GA_LINE_CNTL_END_TYPE_SQR      (2 << 16) /* horizontal or vertical depending upon slope */
+#      define R300_GA_LINE_CNTL_END_TYPE_COMP     (3 << 16) /* Computed (perpendicular to slope) */
+#      define R500_GA_LINE_CNTL_SORT_NO           (0 << 18)
+#      define R500_GA_LINE_CNTL_SORT_MINX_MINY    (1 << 18)
+/** TODO: looks wrong */
+#       define R300_LINESIZE_MAX              (R300_GA_LINE_CNTL_WIDTH_MASK / 6)
+/** TODO: looks wrong */
 #       define R300_LINE_CNT_HO               (1 << 16)
+/** TODO: looks wrong */
 #       define R300_LINE_CNT_VE               (1 << 17)
 
-/* Some sort of scale or clamp value for texcoordless textures. */
-#define R300_RE_UNK4238                       0x4238
-
-/* Something shade related */
-#define R300_RE_SHADE                         0x4274
-
-#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)
-
-/* Fog parameters */
-#define R300_RE_FOG_SCALE                     0x4294
-#define R300_RE_FOG_START                     0x4298
+/* Line Stipple configuration information. */
+#define R300_GA_LINE_STIPPLE_CONFIG                   0x4238
+#      define R300_GA_LINE_STIPPLE_CONFIG_LINE_RESET_NO     (0 << 0)
+#      define R300_GA_LINE_STIPPLE_CONFIG_LINE_RESET_LINE   (1 << 0)
+#      define R300_GA_LINE_STIPPLE_CONFIG_LINE_RESET_PACKET (2 << 0)
+#      define R300_GA_LINE_STIPPLE_CONFIG_STIPPLE_SCALE_SHIFT 2
+#      define R300_GA_LINE_STIPPLE_CONFIG_STIPPLE_SCALE_MASK  0xfffffffc
+
+/* Used to load US instructions and constants */
+#define R500_GA_US_VECTOR_INDEX               0x4250
+#      define R500_GA_US_VECTOR_INDEX_SHIFT       0
+#      define R500_GA_US_VECTOR_INDEX_MASK        0x000000ff
+#      define R500_GA_US_VECTOR_INDEX_TYPE_INSTR  (0 << 16)
+#      define R500_GA_US_VECTOR_INDEX_TYPE_CONST  (1 << 16)
+#      define R500_GA_US_VECTOR_INDEX_CLAMP_NO    (0 << 17)
+#      define R500_GA_US_VECTOR_INDEX_CLAMP_CONST (1 << 17)
+
+/* Data register for loading US instructions and constants */
+#define R500_GA_US_VECTOR_DATA                0x4254
+
+/* Specifies color properties and mappings of textures. */
+#define R500_GA_COLOR_CONTROL_PS3                     0x4258
+#      define R500_TEX0_SHADING_PS3_SOLID       (0 << 0)
+#      define R500_TEX0_SHADING_PS3_FLAT        (1 << 0)
+#      define R500_TEX0_SHADING_PS3_GOURAUD     (2 << 0)
+#      define R500_TEX1_SHADING_PS3_SOLID       (0 << 2)
+#      define R500_TEX1_SHADING_PS3_FLAT        (1 << 2)
+#      define R500_TEX1_SHADING_PS3_GOURAUD     (2 << 2)
+#      define R500_TEX2_SHADING_PS3_SOLID       (0 << 4)
+#      define R500_TEX2_SHADING_PS3_FLAT        (1 << 4)
+#      define R500_TEX2_SHADING_PS3_GOURAUD     (2 << 4)
+#      define R500_TEX3_SHADING_PS3_SOLID       (0 << 6)
+#      define R500_TEX3_SHADING_PS3_FLAT        (1 << 6)
+#      define R500_TEX3_SHADING_PS3_GOURAUD     (2 << 6)
+#      define R500_TEX4_SHADING_PS3_SOLID       (0 << 8)
+#      define R500_TEX4_SHADING_PS3_FLAT        (1 << 8)
+#      define R500_TEX4_SHADING_PS3_GOURAUD     (2 << 8)
+#      define R500_TEX5_SHADING_PS3_SOLID       (0 << 10)
+#      define R500_TEX5_SHADING_PS3_FLAT        (1 << 10)
+#      define R500_TEX5_SHADING_PS3_GOURAUD     (2 << 10)
+#      define R500_TEX6_SHADING_PS3_SOLID       (0 << 12)
+#      define R500_TEX6_SHADING_PS3_FLAT        (1 << 12)
+#      define R500_TEX6_SHADING_PS3_GOURAUD     (2 << 12)
+#      define R500_TEX7_SHADING_PS3_SOLID       (0 << 14)
+#      define R500_TEX7_SHADING_PS3_FLAT        (1 << 14)
+#      define R500_TEX7_SHADING_PS3_GOURAUD     (2 << 14)
+#      define R500_TEX8_SHADING_PS3_SOLID       (0 << 16)
+#      define R500_TEX8_SHADING_PS3_FLAT        (1 << 16)
+#      define R500_TEX8_SHADING_PS3_GOURAUD     (2 << 16)
+#      define R500_TEX9_SHADING_PS3_SOLID       (0 << 18)
+#      define R500_TEX9_SHADING_PS3_FLAT        (1 << 18)
+#      define R500_TEX9_SHADING_PS3_GOURAUD     (2 << 18)
+#      define R500_TEX10_SHADING_PS3_SOLID      (0 << 20)
+#      define R500_TEX10_SHADING_PS3_FLAT       (1 << 20)
+#      define R500_TEX10_SHADING_PS3_GOURAUD    (2 << 20)
+#      define R500_COLOR0_TEX_OVERRIDE_NO       (0 << 22)
+#      define R500_COLOR0_TEX_OVERRIDE_TEX_0    (1 << 22)
+#      define R500_COLOR0_TEX_OVERRIDE_TEX_1    (2 << 22)
+#      define R500_COLOR0_TEX_OVERRIDE_TEX_2    (3 << 22)
+#      define R500_COLOR0_TEX_OVERRIDE_TEX_3    (4 << 22)
+#      define R500_COLOR0_TEX_OVERRIDE_TEX_4    (5 << 22)
+#      define R500_COLOR0_TEX_OVERRIDE_TEX_5    (6 << 22)
+#      define R500_COLOR0_TEX_OVERRIDE_TEX_6    (7 << 22)
+#      define R500_COLOR0_TEX_OVERRIDE_TEX_7    (8 << 22)
+#      define R500_COLOR0_TEX_OVERRIDE_TEX_8_C2 (9 << 22)
+#      define R500_COLOR0_TEX_OVERRIDE_TEX_9_C3 (10 << 22)
+#      define R500_COLOR1_TEX_OVERRIDE_NO       (0 << 26)
+#      define R500_COLOR1_TEX_OVERRIDE_TEX_0    (1 << 26)
+#      define R500_COLOR1_TEX_OVERRIDE_TEX_1    (2 << 26)
+#      define R500_COLOR1_TEX_OVERRIDE_TEX_2    (3 << 26)
+#      define R500_COLOR1_TEX_OVERRIDE_TEX_3    (4 << 26)
+#      define R500_COLOR1_TEX_OVERRIDE_TEX_4    (5 << 26)
+#      define R500_COLOR1_TEX_OVERRIDE_TEX_5    (6 << 26)
+#      define R500_COLOR1_TEX_OVERRIDE_TEX_6    (7 << 26)
+#      define R500_COLOR1_TEX_OVERRIDE_TEX_7    (8 << 26)
+#      define R500_COLOR1_TEX_OVERRIDE_TEX_8_C2 (9 << 26)
+#      define R500_COLOR1_TEX_OVERRIDE_TEX_9_C3 (10 << 26)
+
+/* Returns idle status of various G3D block, captured when GA_IDLE written or
+ * when hard or soft reset asserted.
+ */
+#define R500_GA_IDLE                                  0x425c
+#      define R500_GA_IDLE_PIPE3_Z_IDLE  (0 << 0)
+#      define R500_GA_IDLE_PIPE2_Z_IDLE  (0 << 1)
+#      define R500_GA_IDLE_PIPE3_CD_IDLE (0 << 2)
+#      define R500_GA_IDLE_PIPE2_CD_IDLE (0 << 3)
+#      define R500_GA_IDLE_PIPE3_FG_IDLE (0 << 4)
+#      define R500_GA_IDLE_PIPE2_FG_IDLE (0 << 5)
+#      define R500_GA_IDLE_PIPE3_US_IDLE (0 << 6)
+#      define R500_GA_IDLE_PIPE2_US_IDLE (0 << 7)
+#      define R500_GA_IDLE_PIPE3_SC_IDLE (0 << 8)
+#      define R500_GA_IDLE_PIPE2_SC_IDLE (0 << 9)
+#      define R500_GA_IDLE_PIPE3_RS_IDLE (0 << 10)
+#      define R500_GA_IDLE_PIPE2_RS_IDLE (0 << 11)
+#      define R500_GA_IDLE_PIPE1_Z_IDLE  (0 << 12)
+#      define R500_GA_IDLE_PIPE0_Z_IDLE  (0 << 13)
+#      define R500_GA_IDLE_PIPE1_CD_IDLE (0 << 14)
+#      define R500_GA_IDLE_PIPE0_CD_IDLE (0 << 15)
+#      define R500_GA_IDLE_PIPE1_FG_IDLE (0 << 16)
+#      define R500_GA_IDLE_PIPE0_FG_IDLE (0 << 17)
+#      define R500_GA_IDLE_PIPE1_US_IDLE (0 << 18)
+#      define R500_GA_IDLE_PIPE0_US_IDLE (0 << 19)
+#      define R500_GA_IDLE_PIPE1_SC_IDLE (0 << 20)
+#      define R500_GA_IDLE_PIPE0_SC_IDLE (0 << 21)
+#      define R500_GA_IDLE_PIPE1_RS_IDLE (0 << 22)
+#      define R500_GA_IDLE_PIPE0_RS_IDLE (0 << 23)
+#      define R500_GA_IDLE_SU_IDLE       (0 << 24)
+#      define R500_GA_IDLE_GA_IDLE       (0 << 25)
+#      define R500_GA_IDLE_GA_UNIT2_IDLE (0 << 26)
+
+/* Current value of stipple accumulator. */
+#define R300_GA_LINE_STIPPLE_VALUE            0x4260
+
+/* S Texture Coordinate Value for Vertex 0 of Line (stuff textures -- i.e. AA) */
+#define R300_GA_LINE_S0                               0x4264
+/* S Texture Coordinate Value for Vertex 1 of Lines (V2 of parallelogram -- stuff textures -- i.e. AA) */
+#define R300_GA_LINE_S1                               0x4268
+
+/* GA Input fifo high water marks */
+#define R500_GA_FIFO_CNTL                             0x4270
+#      define R500_GA_FIFO_CNTL_VERTEX_FIFO_MASK   0x00000007
+#      define R500_GA_FIFO_CNTL_VERTEX_FIFO_SHIFT  0
+#      define R500_GA_FIFO_CNTL_VERTEX_INDEX_MASK  0x00000038
+#      define R500_GA_FIFO_CNTL_VERTEX_INDEX_SHIFT 3
+#      define R500_GA_FIFO_CNTL_VERTEX_REG_MASK    0x00003fc0
+#      define R500_GA_FIFO_CNTL_VERTEX_REG_SHIFT   6
+
+/* GA enhance/tweaks */
+#define R300_GA_ENHANCE                               0x4274
+#      define R300_GA_ENHANCE_DEADLOCK_CNTL_NO_EFFECT   (0 << 0)
+#      define R300_GA_ENHANCE_DEADLOCK_CNTL_PREVENT_TCL (1 << 0) /* Prevents TCL interface from deadlocking on GA side. */
+#      define R300_GA_ENHANCE_FASTSYNC_CNTL_NO_EFFECT   (0 << 1)
+#      define R300_GA_ENHANCE_FASTSYNC_CNTL_ENABLE      (1 << 1) /* Enables high-performance register/primitive switching. */
+#      define R500_GA_ENHANCE_REG_READWRITE_NO_EFFECT   (0 << 2) /* R520+ only */
+#      define R500_GA_ENHANCE_REG_READWRITE_ENABLE      (1 << 2) /* R520+ only, Enables GA support of simultaneous register reads and writes. */
+#      define R500_GA_ENHANCE_REG_NOSTALL_NO_EFFECT     (0 << 3)
+#      define R500_GA_ENHANCE_REG_NOSTALL_ENABLE        (1 << 3) /* Enables GA support of no-stall reads for register read back. */
+
+#define R300_GA_COLOR_CONTROL                   0x4278
+#      define R300_GA_COLOR_CONTROL_RGB0_SHADING_SOLID      (0 << 0)
+#      define R300_GA_COLOR_CONTROL_RGB0_SHADING_FLAT       (1 << 0)
+#      define R300_GA_COLOR_CONTROL_RGB0_SHADING_GOURAUD    (2 << 0)
+#      define R300_GA_COLOR_CONTROL_ALPHA0_SHADING_SOLID    (0 << 2)
+#      define R300_GA_COLOR_CONTROL_ALPHA0_SHADING_FLAT     (1 << 2)
+#      define R300_GA_COLOR_CONTROL_ALPHA0_SHADING_GOURAUD  (2 << 2)
+#      define R300_GA_COLOR_CONTROL_RGB1_SHADING_SOLID      (0 << 4)
+#      define R300_GA_COLOR_CONTROL_RGB1_SHADING_FLAT       (1 << 4)
+#      define R300_GA_COLOR_CONTROL_RGB1_SHADING_GOURAUD    (2 << 4)
+#      define R300_GA_COLOR_CONTROL_ALPHA1_SHADING_SOLID    (0 << 6)
+#      define R300_GA_COLOR_CONTROL_ALPHA1_SHADING_FLAT     (1 << 6)
+#      define R300_GA_COLOR_CONTROL_ALPHA1_SHADING_GOURAUD  (2 << 6)
+#      define R300_GA_COLOR_CONTROL_RGB2_SHADING_SOLID      (0 << 8)
+#      define R300_GA_COLOR_CONTROL_RGB2_SHADING_FLAT       (1 << 8)
+#      define R300_GA_COLOR_CONTROL_RGB2_SHADING_GOURAUD    (2 << 8)
+#      define R300_GA_COLOR_CONTROL_ALPHA2_SHADING_SOLID    (0 << 10)
+#      define R300_GA_COLOR_CONTROL_ALPHA2_SHADING_FLAT     (1 << 10)
+#      define R300_GA_COLOR_CONTROL_ALPHA2_SHADING_GOURAUD  (2 << 10)
+#      define R300_GA_COLOR_CONTROL_RGB3_SHADING_SOLID      (0 << 12)
+#      define R300_GA_COLOR_CONTROL_RGB3_SHADING_FLAT       (1 << 12)
+#      define R300_GA_COLOR_CONTROL_RGB3_SHADING_GOURAUD    (2 << 12)
+#      define R300_GA_COLOR_CONTROL_ALPHA3_SHADING_SOLID    (0 << 14)
+#      define R300_GA_COLOR_CONTROL_ALPHA3_SHADING_FLAT     (1 << 14)
+#      define R300_GA_COLOR_CONTROL_ALPHA3_SHADING_GOURAUD  (2 << 14)
+#      define R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_FIRST  (0 << 16)
+#      define R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_SECOND (1 << 16)
+#      define R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_THIRD  (2 << 16)
+#      define R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST   (3 << 16)
+
+/** TODO: might be candidate for removal */
+#      define R300_RE_SHADE_MODEL_SMOOTH     ( \
+       R300_GA_COLOR_CONTROL_RGB0_SHADING_GOURAUD | R300_GA_COLOR_CONTROL_ALPHA0_SHADING_GOURAUD | \
+       R300_GA_COLOR_CONTROL_RGB1_SHADING_GOURAUD | R300_GA_COLOR_CONTROL_ALPHA1_SHADING_GOURAUD | \
+       R300_GA_COLOR_CONTROL_RGB2_SHADING_GOURAUD | R300_GA_COLOR_CONTROL_ALPHA2_SHADING_GOURAUD | \
+       R300_GA_COLOR_CONTROL_RGB3_SHADING_GOURAUD | R300_GA_COLOR_CONTROL_ALPHA3_SHADING_GOURAUD | \
+       R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST )
+/** TODO: might be candidate for removal, the GOURAUD stuff also looks buggy to me */
+#      define R300_RE_SHADE_MODEL_FLAT     ( \
+       R300_GA_COLOR_CONTROL_RGB0_SHADING_FLAT | R300_GA_COLOR_CONTROL_ALPHA0_SHADING_FLAT | \
+       R300_GA_COLOR_CONTROL_RGB1_SHADING_FLAT | R300_GA_COLOR_CONTROL_ALPHA1_SHADING_GOURAUD | \
+       R300_GA_COLOR_CONTROL_RGB2_SHADING_FLAT | R300_GA_COLOR_CONTROL_ALPHA2_SHADING_FLAT | \
+       R300_GA_COLOR_CONTROL_RGB3_SHADING_FLAT | R300_GA_COLOR_CONTROL_ALPHA3_SHADING_GOURAUD | \
+       R300_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST )
+
+/* Specifies red & green components of fill color -- S312 format -- Backwards comp. */
+#define R300_GA_SOLID_RG                         0x427c
+#      define GA_SOLID_RG_COLOR_GREEN_SHIFT 0
+#      define GA_SOLID_RG_COLOR_GREEN_MASK  0x0000ffff
+#      define GA_SOLID_RG_COLOR_RED_SHIFT   16
+#      define GA_SOLID_RG_COLOR_RED_MASK    0xffff0000
+/* Specifies blue & alpha components of fill color -- S312 format -- Backwards comp. */
+#define R300_GA_SOLID_BA                         0x4280
+#      define GA_SOLID_BA_COLOR_ALPHA_SHIFT 0
+#      define GA_SOLID_BA_COLOR_ALPHA_MASK  0x0000ffff
+#      define GA_SOLID_BA_COLOR_BLUE_SHIFT  16
+#      define GA_SOLID_BA_COLOR_BLUE_MASK   0xffff0000
+
+/* Polygon Mode
+ * Dangerous
+ */
+#define R300_GA_POLY_MODE                             0x4288
+#      define R300_GA_POLY_MODE_DISABLE           (0 << 0)
+#      define R300_GA_POLY_MODE_DUAL              (1 << 0) /* send 2 sets of 3 polys with specified poly type */
+/* reserved */
+#      define R300_GA_POLY_MODE_FRONT_PTYPE_POINT (0 << 4)
+#      define R300_GA_POLY_MODE_FRONT_PTYPE_LINE  (1 << 4)
+#      define R300_GA_POLY_MODE_FRONT_PTYPE_TRI   (2 << 4)
+/* reserved */
+#      define R300_GA_POLY_MODE_BACK_PTYPE_POINT  (0 << 7)
+#      define R300_GA_POLY_MODE_BACK_PTYPE_LINE   (1 << 7)
+#      define R300_GA_POLY_MODE_BACK_PTYPE_TRI    (2 << 7)
+/* reserved */
+
+/* Specifies the rouding mode for geometry & color SPFP to FP conversions. */
+#define R300_GA_ROUND_MODE                            0x428c
+#      define R300_GA_ROUND_MODE_GEOMETRY_ROUND_TRUNC   (0 << 0)
+#      define R300_GA_ROUND_MODE_GEOMETRY_ROUND_NEAREST (1 << 0)
+#      define R300_GA_ROUND_MODE_COLOR_ROUND_TRUNC      (0 << 2)
+#      define R300_GA_ROUND_MODE_COLOR_ROUND_NEAREST    (1 << 2)
+#      define R300_GA_ROUND_MODE_RGB_CLAMP_RGB          (0 << 4)
+#      define R300_GA_ROUND_MODE_RGB_CLAMP_FP20         (1 << 4)
+#      define R300_GA_ROUND_MODE_ALPHA_CLAMP_RGB        (0 << 5)
+#      define R300_GA_ROUND_MODE_ALPHA_CLAMP_FP20       (1 << 5)
+#      define R500_GA_ROUND_MODE_GEOMETRY_MASK_SHIFT    6
+#      define R500_GA_ROUND_MODE_GEOMETRY_MASK_MASK     0x000003c0
+
+/* Specifies x & y offsets for vertex data after conversion to FP.
+ * Offsets are in S15 format (subpixels -- 1/12 or 1/16, even in 8b
+ * subprecision).
+ */
+#define R300_GA_OFFSET                                0x4290
+#      define R300_GA_OFFSET_X_OFFSET_SHIFT 0
+#      define R300_GA_OFFSET_X_OFFSET_MASK  0x0000ffff
+#      define R300_GA_OFFSET_Y_OFFSET_SHIFT 16
+#      define R300_GA_OFFSET_Y_OFFSET_MASK  0xffff0000
+
+/* Specifies the scale to apply to fog. */
+#define R300_GA_FOG_SCALE                     0x4294
+/* Specifies the offset to apply to fog. */
+#define R300_GA_FOG_OFFSET                    0x4298
+/* Specifies number of cycles to assert reset, and also causes RB3D soft reset to assert. */
+#define R300_GA_SOFT_RESET                    0x429c
 
 /* 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.
@@ -615,11 +1097,11 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  * Some of the tests indicate that fgl has a fallback implementation of zbias
  * via pixel shaders.
  */
-#define R300_RE_ZBIAS_CNTL                    0x42A0 /* GUESS */
-#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
+#define R300_SU_TEX_WRAP                      0x42A0
+#define R300_SU_POLY_OFFSET_FRONT_SCALE       0x42A4
+#define R300_SU_POLY_OFFSET_FRONT_OFFSET      0x42A8
+#define R300_SU_POLY_OFFSET_BACK_SCALE        0x42AC
+#define R300_SU_POLY_OFFSET_BACK_OFFSET       0x42B0
 
 /* This register needs to be set to (1<<1) for RV350 to correctly
  * perform depth test (see --vb-triangles in r300_demo)
@@ -630,31 +1112,44 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  *  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_SU_POLY_OFFSET_ENABLE            0x42B4
+#      define R300_FRONT_ENABLE               (1 << 0)
+#      define R300_BACK_ENABLE                (1 << 1)
+#      define R300_PARA_ENABLE                (1 << 2)
 
-#define R300_RE_CULL_CNTL                   0x42B8
+#define R300_SU_CULL_MODE                      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)
 
+/* SU Depth Scale value */
+#define R300_SU_DEPTH_SCALE                 0x42c0
+/* SU Depth Offset value */
+#define R300_SU_DEPTH_OFFSET                0x42c4
+
 
 /* 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)
-       /* number of color interpolators used */
-#      define R300_RS_CNTL_CI_CNT_SHIFT         7
-#       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
+#define R300_RS_COUNT                      0x4300
+#       define R300_IT_COUNT_SHIFT               0
+#       define R300_IT_COUNT_MASK                0x0000007f
+#       define R300_IC_COUNT_SHIFT               7
+#       define R300_IC_COUNT_MASK                0x00000780
+#       define R300_W_ADDR_SHIFT                 12
+#       define R300_W_ADDR_MASK                  0x0003f000
+#       define R300_HIRES_DIS                    (0 << 18)
+#       define R300_HIRES_EN                     (1 << 18)
+
+#define R300_RS_INST_COUNT                       0x4304
+#       define R300_RS_INST_COUNT_SHIFT          0
+#       define R300_RS_INST_COUNT_MASK           0x0000000f
+#       define R300_RS_TX_OFFSET_SHIFT           5
+#      define R300_RS_TX_OFFSET_MASK            0x000000e0
 
 /* gap */
 
@@ -671,63 +1166,108 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  * 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
+#define R300_RS_IP_0                                   0x4310
+#define R300_RS_IP_1                                   0x4314
+#define R300_RS_IP_2                                   0x4318
+#define R300_RS_IP_3                                   0x431C
+#       define R300_RS_INTERP_SRC_SHIFT          2 /* TODO: check for removal */
+#       define R300_RS_INTERP_SRC_MASK           (7 << 2) /* TODO: check for removal */
+#      define R300_RS_TEX_PTR(x)                       (x << 0)
+#      define R300_RS_COL_PTR(x)                       (x << 6)
+#      define R300_RS_COL_FMT(x)                       (x << 9)
+#      define R300_RS_COL_FMT_RGBA                     0
+#      define R300_RS_COL_FMT_RGB0                     1
+#      define R300_RS_COL_FMT_RGB1                     2
+#      define R300_RS_COL_FMT_000A                     4
+#      define R300_RS_COL_FMT_0000                     5
+#      define R300_RS_COL_FMT_0001                     6
+#      define R300_RS_COL_FMT_111A                     8
+#      define R300_RS_COL_FMT_1110                     9
+#      define R300_RS_COL_FMT_1111                     10
+#      define R300_RS_SEL_S(x)                         (x << 13)
+#      define R300_RS_SEL_T(x)                         (x << 16)
+#      define R300_RS_SEL_R(x)                         (x << 19)
+#      define R300_RS_SEL_Q(x)                         (x << 22)
+#      define R300_RS_SEL_C0                           0
+#      define R300_RS_SEL_C1                           1
+#      define R300_RS_SEL_C2                           2
+#      define R300_RS_SEL_C3                           3
+#      define R300_RS_SEL_K0                           4
+#      define R300_RS_SEL_K1                           5
+
+
+/*  */
+#define R500_RS_INST_0                                 0x4320
+#define R500_RS_INST_1                                 0x4324
+#define R500_RS_INST_2                                 0x4328
+#define R500_RS_INST_3                                 0x432c
+#define R500_RS_INST_4                                 0x4330
+#define R500_RS_INST_5                                 0x4334
+#define R500_RS_INST_6                                 0x4338
+#define R500_RS_INST_7                                 0x433c
+#define R500_RS_INST_8                                 0x4340
+#define R500_RS_INST_9                                 0x4344
+#define R500_RS_INST_10                                        0x4348
+#define R500_RS_INST_11                                        0x434c
+#define R500_RS_INST_12                                        0x4350
+#define R500_RS_INST_13                                        0x4354
+#define R500_RS_INST_14                                        0x4358
+#define R500_RS_INST_15                                        0x435c
+#define R500_RS_INST_TEX_ID_SHIFT                      0
+#define R500_RS_INST_TEX_CN_WRITE                      (1 << 4)
+#define R500_RS_INST_TEX_ADDR_SHIFT                    5
+#define R500_RS_INST_COL_ID_SHIFT                      12
+#define R500_RS_INST_COL_CN_NO_WRITE                   (0 << 16)
+#define R500_RS_INST_COL_CN_WRITE                      (1 << 16)
+#define R500_RS_INST_COL_CN_WRITE_FBUFFER              (2 << 16)
+#define R500_RS_INST_COL_CN_WRITE_BACKFACE             (3 << 16)
+#define R500_RS_INST_COL_ADDR_SHIFT                    18
+#define R500_RS_INST_TEX_ADJ                           (1 << 25)
+#define R500_RS_INST_W_CN                              (1 << 26)
 
 /* 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.
- *
- * Apperently you may set the R300_RS_ROUTE_0_COLOR bit, but not provide any
- * R300_RS_ROUTE_0_COLOR_DEST value; this setup is used for clearing the state.
- * See r300_ioctl.c:r300EmitClearState. I'm not sure if this setup is strictly
- * correct or not. - Oliver.
- */
-#       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)
+#define R300_RS_INST_0                     0x4330
+#define R300_RS_INST_1                     0x4334
+#define R300_RS_INST_2                     0x4338
+#define R300_RS_INST_3                     0x433C /* GUESS */
+#define R300_RS_INST_4                     0x4340 /* GUESS */
+#define R300_RS_INST_5                     0x4344 /* GUESS */
+#define R300_RS_INST_6                     0x4348 /* GUESS */
+#define R300_RS_INST_7                     0x434C /* GUESS */
+#      define R300_RS_INST_TEX_ID(x)           ((x) << 0)
+#      define R300_RS_INST_TEX_CN_WRITE        (1 << 3)
+#      define R300_RS_INST_TEX_ADDR_SHIFT      6
+#      define R300_RS_INST_COL_ID(x)           ((x) << 11)
+#      define R300_RS_INST_COL_CN_WRITE        (1 << 14)
+#      define R300_RS_INST_COL_ADDR_SHIFT      17
+#      define R300_RS_INST_TEX_ADJ             (1 << 22)
+#      define R300_RS_COL_BIAS_UNUSED_SHIFT    23
+
 /* END: Rasterization / Interpolators - many guesses */
 
+/* Hierarchical Z Enable */
+#define R300_SC_HYPERZ                   0x43a4
+#      define R300_SC_HYPERZ_DISABLE     (0 << 0)
+#      define R300_SC_HYPERZ_ENABLE      (1 << 0)
+#      define R300_SC_HYPERZ_MIN         (0 << 1)
+#      define R300_SC_HYPERZ_MAX         (1 << 1)
+#      define R300_SC_HYPERZ_ADJ_256     (0 << 2)
+#      define R300_SC_HYPERZ_ADJ_128     (1 << 2)
+#      define R300_SC_HYPERZ_ADJ_64      (2 << 2)
+#      define R300_SC_HYPERZ_ADJ_32      (3 << 2)
+#      define R300_SC_HYPERZ_ADJ_16      (4 << 2)
+#      define R300_SC_HYPERZ_ADJ_8       (5 << 2)
+#      define R300_SC_HYPERZ_ADJ_4       (6 << 2)
+#      define R300_SC_HYPERZ_ADJ_2       (7 << 2)
+#      define R300_SC_HYPERZ_HZ_Z0MIN_NO (0 << 5)
+#      define R300_SC_HYPERZ_HZ_Z0MIN    (1 << 5)
+#      define R300_SC_HYPERZ_HZ_Z0MAX_NO (0 << 6)
+#      define R300_SC_HYPERZ_HZ_Z0MAX    (1 << 6)
+
+#define R300_SC_EDGERULE                 0x43a8
+
 /* BEGIN: Scissors and cliprects */
 
 /* There are four clipping rectangles. Their corner coordinates are inclusive.
@@ -744,21 +1284,21 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  * 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_SC_CLIPRECT_TL_0               0x43B0
+#define R300_SC_CLIPRECT_BR_0               0x43B4
+#define R300_SC_CLIPRECT_TL_1               0x43B8
+#define R300_SC_CLIPRECT_BR_1               0x43BC
+#define R300_SC_CLIPRECT_TL_2               0x43C0
+#define R300_SC_CLIPRECT_BR_2               0x43C4
+#define R300_SC_CLIPRECT_TL_3               0x43C8
+#define R300_SC_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_SC_CLIP_RULE                   0x43D0
 #       define R300_CLIP_OUT                     (1 << 0)
 #       define R300_CLIP_0                       (1 << 1)
 #       define R300_CLIP_1                       (1 << 2)
@@ -778,13 +1318,17 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 /* gap */
 
-#define R300_RE_SCISSORS_TL                 0x43E0
-#define R300_RE_SCISSORS_BR                 0x43E4
+#define R300_SC_SCISSORS_TL                 0x43E0
+#define R300_SC_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)
+
+/* Screen door sample mask */
+#define R300_SC_SCREENDOOR                 0x43e8
+
 /* END: Scissors and cliprects */
 
 /* BEGIN: Texture specification */
@@ -794,43 +1338,55 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  * 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_FILTER0_0                        0x4400
+#define R300_TX_FILTER0_1                        0x4404
+#define R300_TX_FILTER0_2                        0x4408
+#define R300_TX_FILTER0_3                        0x440c
+#define R300_TX_FILTER0_4                        0x4410
+#define R300_TX_FILTER0_5                        0x4414
+#define R300_TX_FILTER0_6                        0x4418
+#define R300_TX_FILTER0_7                        0x441c
+#define R300_TX_FILTER0_8                        0x4420
+#define R300_TX_FILTER0_9                        0x4424
+#define R300_TX_FILTER0_10                       0x4428
+#define R300_TX_FILTER0_11                       0x442c
+#define R300_TX_FILTER0_12                       0x4430
+#define R300_TX_FILTER0_13                       0x4434
+#define R300_TX_FILTER0_14                       0x4438
+#define R300_TX_FILTER0_15                       0x443c
 #       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_MIRROR_ONCE_TO_EDGE       3
+#       define R300_TX_CLAMP                     4
+#      define R300_TX_MIRROR_ONCE               5
 #       define R300_TX_CLAMP_TO_BORDER           6
+#      define R300_TX_MIRROR_ONCE_TO_BORDER     7
 #       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_WRAP_R_SHIFT              6
+#       define R300_TX_WRAP_R_MASK               (7 << 6)
+#      define R300_TX_MAG_FILTER_4              (0 << 9)
 #       define R300_TX_MAG_FILTER_NEAREST        (1 << 9)
 #       define R300_TX_MAG_FILTER_LINEAR         (2 << 9)
+#       define R300_TX_MAG_FILTER_ANISO          (3 << 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)
-#      define R300_TX_MIN_FILTER_ANISO_LINEAR              (0 << 13)
-#      define R300_TX_MIN_FILTER_ANISO_NEAREST_MIP_NEAREST (1 << 13)
-#      define R300_TX_MIN_FILTER_ANISO_NEAREST_MIP_LINEAR  (2 << 13)
-#       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_MIN_FILTER_ANISO          (3 << 11)
+#      define R300_TX_MIN_FILTER_MASK           (3 << 11)
+#      define R300_TX_MIN_FILTER_MIP_NONE       (0 << 13)
+#      define R300_TX_MIN_FILTER_MIP_NEAREST    (1 << 13)
+#      define R300_TX_MIN_FILTER_MIP_LINEAR     (2 << 13)
+#      define R300_TX_MIN_FILTER_MIP_MASK       (3 << 13)
+#      define R300_TX_MAX_ANISO_1_TO_1          (0 << 21)
+#      define R300_TX_MAX_ANISO_2_TO_1          (1 << 21)
+#      define R300_TX_MAX_ANISO_4_TO_1          (2 << 21)
+#      define R300_TX_MAX_ANISO_8_TO_1          (3 << 21)
+#      define R300_TX_MAX_ANISO_16_TO_1         (4 << 21)
+#      define R300_TX_MAX_ANISO_MASK            (7 << 21)
 
 #define R300_TX_FILTER1_0                      0x4440
 #      define R300_CHROMA_KEY_MODE_DISABLE    0
@@ -838,7 +1394,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #      define R300_CHROMA_KEY_BLEND           2
 #      define R300_MC_ROUND_NORMAL            (0<<2)
 #      define R300_MC_ROUND_MPEG4             (1<<2)
-#      define R300_LOD_BIAS_MASK           0x1fff
+#      define R300_LOD_BIAS_SHIFT             3
+#      define R300_LOD_BIAS_MASK              0x1ff8
 #      define R300_EDGE_ANISO_EDGE_DIAG       (0<<13)
 #      define R300_EDGE_ANISO_EDGE_ONLY       (1<<13)
 #      define R300_MC_COORD_TRUNCATE_DISABLE  (0<<14)
@@ -849,12 +1406,16 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #      define R300_TX_TRI_PERF_3_8            (3<<15)
 #      define R300_ANISO_THRESHOLD_MASK       (7<<17)
 
+#      define R500_MACRO_SWITCH               (1<<22)
+#      define R500_BORDER_FIX                 (1<<31)
+
 #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_DEPTHMASK_SHIFT           22
+#      define R300_TX_DEPTHMASK_MASK            (0xf << 22)
 #       define R300_TX_MAX_MIP_LEVEL_SHIFT       26
 #       define R300_TX_MAX_MIP_LEVEL_MASK        (0xf << 26)
 #       define R300_TX_SIZE_PROJECTED            (1<<30)
@@ -865,7 +1426,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
           They are given meanings as R, G, B and Alpha by the swizzle
           specification */
 #      define R300_TX_FORMAT_X8                    0x0
+#      define R500_TX_FORMAT_X1                    0x0 // bit set in format 2
 #      define R300_TX_FORMAT_X16                   0x1
+#      define R500_TX_FORMAT_X1_REV                0x0 // bit set in format 2
 #      define R300_TX_FORMAT_Y4X4                  0x2
 #      define R300_TX_FORMAT_Y8X8                  0x3
 #      define R300_TX_FORMAT_Y16X16                0x4
@@ -886,9 +1449,17 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #      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 */
+
+       /* These two values are wrong, but they're the only values that
+        * produce any even vaguely correct results.  Can r300 only do 16-bit
+        * depth textures?
+        */
+#      define R300_TX_FORMAT_X24_Y8                0x1e
+#      define R300_TX_FORMAT_X32                   0x1e
+
        /* 0x16 - some 16 bit green format.. ?? */
-#      define R300_TX_FORMAT_UNK25                (1 << 25) /* no swizzle */
-#      define R300_TX_FORMAT_CUBIC_MAP            (1 << 26)
+#      define R300_TX_FORMAT_3D                   (1 << 25)
+#      define R300_TX_FORMAT_CUBIC_MAP            (2 << 25)
 
        /* gap */
        /* Floating point formats */
@@ -941,7 +1512,18 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #      define R300_TX_FORMAT_YUV_MODE          0x00800000
 
-#define R300_TX_PITCH_0                            0x4500 /* obvious missing in gap */
+#define R300_TX_FORMAT2_0                  0x4500 /* obvious missing in gap */
+#       define R300_TX_PITCHMASK_SHIFT           0
+#       define R300_TX_PITCHMASK_MASK            (2047 << 0)
+#      define R500_TXFORMAT_MSB                 (1 << 14)
+#      define R500_TXWIDTH_BIT11                (1 << 15)
+#      define R500_TXHEIGHT_BIT11               (1 << 16)
+#      define R500_POW2FIX2FLT                  (1 << 17)
+#      define R500_SEL_FILTER4_TC0              (0 << 18)
+#      define R500_SEL_FILTER4_TC1              (1 << 18)
+#      define R500_SEL_FILTER4_TC2              (2 << 18)
+#      define R500_SEL_FILTER4_TC3              (3 << 18)
+
 #define R300_TX_OFFSET_0                    0x4540
        /* BEGIN: Guess from R200 */
 #       define R300_TXO_ENDIAN_NO_SWAP           (0 << 0)
@@ -949,15 +1531,50 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #       define R300_TXO_ENDIAN_WORD_SWAP         (2 << 0)
 #       define R300_TXO_ENDIAN_HALFDW_SWAP       (3 << 0)
 #       define R300_TXO_MACRO_TILE               (1 << 2)
+#       define R300_TXO_MICRO_TILE_LINEAR        (0 << 3)
 #       define R300_TXO_MICRO_TILE               (1 << 3)
+#       define R300_TXO_MICRO_TILE_SQUARE        (2 << 3)
 #       define R300_TXO_OFFSET_MASK              0xffffffe0
 #       define R300_TXO_OFFSET_SHIFT             5
        /* END: Guess from R200 */
 
 /* 32 bit chroma key */
 #define R300_TX_CHROMA_KEY_0                      0x4580
+#define R300_TX_CHROMA_KEY_1                      0x4584
+#define R300_TX_CHROMA_KEY_2                      0x4588
+#define R300_TX_CHROMA_KEY_3                      0x458c
+#define R300_TX_CHROMA_KEY_4                      0x4590
+#define R300_TX_CHROMA_KEY_5                      0x4594
+#define R300_TX_CHROMA_KEY_6                      0x4598
+#define R300_TX_CHROMA_KEY_7                      0x459c
+#define R300_TX_CHROMA_KEY_8                      0x45a0
+#define R300_TX_CHROMA_KEY_9                      0x45a4
+#define R300_TX_CHROMA_KEY_10                     0x45a8
+#define R300_TX_CHROMA_KEY_11                     0x45ac
+#define R300_TX_CHROMA_KEY_12                     0x45b0
+#define R300_TX_CHROMA_KEY_13                     0x45b4
+#define R300_TX_CHROMA_KEY_14                     0x45b8
+#define R300_TX_CHROMA_KEY_15                     0x45bc
 /* ff00ff00 == { 0, 1.0, 0, 1.0 } */
-#define R300_TX_BORDER_COLOR_0              0x45C0
+
+/* Border Color */
+#define R300_TX_BORDER_COLOR_0              0x45c0
+#define R300_TX_BORDER_COLOR_1              0x45c4
+#define R300_TX_BORDER_COLOR_2              0x45c8
+#define R300_TX_BORDER_COLOR_3              0x45cc
+#define R300_TX_BORDER_COLOR_4              0x45d0
+#define R300_TX_BORDER_COLOR_5              0x45d4
+#define R300_TX_BORDER_COLOR_6              0x45d8
+#define R300_TX_BORDER_COLOR_7              0x45dc
+#define R300_TX_BORDER_COLOR_8              0x45e0
+#define R300_TX_BORDER_COLOR_9              0x45e4
+#define R300_TX_BORDER_COLOR_10             0x45e8
+#define R300_TX_BORDER_COLOR_11             0x45ec
+#define R300_TX_BORDER_COLOR_12             0x45f0
+#define R300_TX_BORDER_COLOR_13             0x45f4
+#define R300_TX_BORDER_COLOR_14             0x45f8
+#define R300_TX_BORDER_COLOR_15             0x45fc
+
 
 /* END: Texture specification */
 
@@ -980,23 +1597,23 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  * 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_US_CONFIG                      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
+#define R300_US_PIXSIZE                     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_US_CODE_OFFSET                 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 << 6)
-#       define R300_PFS_CNTL_TEX_OFFSET_SHIFT    12
-#       define R300_PFS_CNTL_TEX_OFFSET_MASK     (31 << 12) /* GUESS */
+#       define R300_PFS_CNTL_TEX_OFFSET_SHIFT    13
+#       define R300_PFS_CNTL_TEX_OFFSET_MASK     (31 << 13)
 #       define R300_PFS_CNTL_TEX_END_SHIFT       18
-#       define R300_PFS_CNTL_TEX_END_MASK        (31 << 18) /* GUESS */
+#       define R300_PFS_CNTL_TEX_END_MASK        (31 << 18)
 
 /* gap */
 
@@ -1007,45 +1624,65 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  * Offsets are relative to the master offset from PFS_CNTL_2.
  */
-#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_OUTPUT_COLOR        (1 << 22)
-#              define R300_PFS_NODE_OUTPUT_DEPTH        (1 << 23)
+#define R300_US_CODE_ADDR_0                 0x4610
+#define R300_US_CODE_ADDR_1                 0x4614
+#define R300_US_CODE_ADDR_2                 0x4618
+#define R300_US_CODE_ADDR_3                 0x461C
+#       define R300_ALU_START_SHIFT         0
+#       define R300_ALU_START_MASK          (63 << 0)
+#       define R300_ALU_SIZE_SHIFT          6
+#       define R300_ALU_SIZE_MASK           (63 << 6)
+#       define R300_TEX_START_SHIFT         12
+#       define R300_TEX_START_MASK          (31 << 12)
+#       define R300_TEX_SIZE_SHIFT          17
+#       define R300_TEX_SIZE_MASK           (31 << 17)
+#      define R300_RGBA_OUT                (1 << 22)
+#      define R300_W_OUT                   (1 << 23)
 
 /* 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)
-       /* GUESS */
-#      define R300_FPITX_SRC_CONST              (1 << 5)
-#      define R300_FPITX_DST_SHIFT              6
-#      define R300_FPITX_DST_MASK               (31 << 6)
-#      define R300_FPITX_IMAGE_SHIFT            11
-       /* GUESS based on layout and native limits */
-#       define R300_FPITX_IMAGE_MASK             (15 << 11)
-/* 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_KIL        2
-#              define R300_FPITX_OP_TXP        3
-#              define R300_FPITX_OP_TXB        4
-#      define R300_FPITX_OPCODE_MASK           (7 << 15)
+#define R300_US_TEX_INST_0                  0x4620
+#      define R300_SRC_ADDR_SHIFT          0
+#      define R300_SRC_ADDR_MASK           (31 << 0)
+#      define R300_DST_ADDR_SHIFT          6
+#      define R300_DST_ADDR_MASK           (31 << 6)
+#      define R300_TEX_ID_SHIFT            11
+#       define R300_TEX_ID_MASK             (15 << 11)
+#      define R300_TEX_INST_SHIFT              15
+#              define R300_TEX_OP_NOP          0
+#              define R300_TEX_OP_LD           1
+#              define R300_TEX_OP_KIL          2
+#              define R300_TEX_OP_TXP          3
+#              define R300_TEX_OP_TXB          4
+#      define R300_TEX_INST_MASK               (7 << 15)
+
+/* Output format from the unfied shader */
+#define R300_US_OUT_FMT                     0x46A4
+#      define R300_US_OUT_FMT_C4_8         (0 << 0)
+#      define R300_US_OUT_FMT_C4_10        (1 << 0)
+#      define R300_US_OUT_FMT_C4_10_GAMMA  (2 << 0)
+#      define R300_US_OUT_FMT_C_16         (3 << 0)
+#      define R300_US_OUT_FMT_C2_16        (4 << 0)
+#      define R300_US_OUT_FMT_C4_16        (5 << 0)
+#      define R300_US_OUT_FMT_C_16_MPEG    (6 << 0)
+#      define R300_US_OUT_FMT_C2_16_MPEG   (7 << 0)
+#      define R300_US_OUT_FMT_C2_4         (8 << 0)
+#      define R300_US_OUT_FMT_C_3_3_2      (9 << 0)
+#      define R300_US_OUT_FMT_C_6_5_6      (10 << 0)
+#      define R300_US_OUT_FMT_C_11_11_10   (11 << 0)
+#      define R300_US_OUT_FMT_C_10_11_11   (12 << 0)
+#      define R300_US_OUT_FMT_C_2_10_10_10 (13 << 0)
+/* reserved */
+#      define R300_US_OUT_FMT_UNUSED       (15 << 0)
+#      define R300_US_OUT_FMT_C_16_FP      (16 << 0)
+#      define R300_US_OUT_FMT_C2_16_FP     (17 << 0)
+#      define R300_US_OUT_FMT_C4_16_FP     (18 << 0)
+#      define R300_US_OUT_FMT_C_32_FP      (19 << 0)
+#      define R300_US_OUT_FMT_C2_32_FP     (20 << 0)
+#      define R300_US_OUT_FMT_C4_32_FP     (20 << 0)
 
 /* ALU
  * The ALU instructions register blocks are enumerated according to the order
@@ -1111,172 +1748,256 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  *  - 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_SRC_MASK                0x0003ffff
-#       define R300_FPI1_DSTC_SHIFT              18
-#       define R300_FPI1_DSTC_MASK               (31 << 18)
-#              define R300_FPI1_DSTC_REG_MASK_SHIFT     23
-#       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_MASK_SHIFT  26
-#       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_SRC_MASK                0x0003ffff
-#       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_FPI3_DSTA_DEPTH              (1 << 27)
-
-#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
-       /* GUESS */
-#       define R300_FPI0_ARGC_HALF               22
-#       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_CMPH               (7 << 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_INSERT_NOP              (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
-       /* GUESS */
-#       define R300_FPI2_ARGA_HALF               18
-#       define R300_FPI2_ARG0A_SHIFT             0
-#       define R300_FPI2_ARG0A_MASK              (31 << 0)
-#       define R300_FPI2_ARG0A_NEG               (1 << 5)
-       /* GUESS */
-#      define R300_FPI2_ARG0A_ABS               (1 << 6)
-#       define R300_FPI2_ARG1A_SHIFT             7
-#       define R300_FPI2_ARG1A_MASK              (31 << 7)
-#       define R300_FPI2_ARG1A_NEG               (1 << 12)
-       /* GUESS */
-#      define R300_FPI2_ARG1A_ABS               (1 << 13)
-#       define R300_FPI2_ARG2A_SHIFT             14
-#       define R300_FPI2_ARG2A_MASK              (31 << 14)
-#       define R300_FPI2_ARG2A_NEG               (1 << 19)
-       /* GUESS */
-#      define R300_FPI2_ARG2A_ABS               (1 << 20)
-#       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)
+#define R300_US_ALU_RGB_ADDR_0                   0x46C0
+#       define R300_ALU_SRC0C_SHIFT             0
+#       define R300_ALU_SRC0C_MASK              (31 << 0)
+#       define R300_ALU_SRC0C_CONST             (1 << 5)
+#       define R300_ALU_SRC1C_SHIFT             6
+#       define R300_ALU_SRC1C_MASK              (31 << 6)
+#       define R300_ALU_SRC1C_CONST             (1 << 11)
+#       define R300_ALU_SRC2C_SHIFT             12
+#       define R300_ALU_SRC2C_MASK              (31 << 12)
+#       define R300_ALU_SRC2C_CONST             (1 << 17)
+#       define R300_ALU_SRC_MASK                0x0003ffff
+#       define R300_ALU_DSTC_SHIFT              18
+#       define R300_ALU_DSTC_MASK               (31 << 18)
+#              define R300_ALU_DSTC_REG_MASK_SHIFT     23
+#       define R300_ALU_DSTC_REG_X              (1 << 23)
+#       define R300_ALU_DSTC_REG_Y              (1 << 24)
+#       define R300_ALU_DSTC_REG_Z              (1 << 25)
+#              define R300_ALU_DSTC_OUTPUT_MASK_SHIFT  26
+#       define R300_ALU_DSTC_OUTPUT_X           (1 << 26)
+#       define R300_ALU_DSTC_OUTPUT_Y           (1 << 27)
+#       define R300_ALU_DSTC_OUTPUT_Z           (1 << 28)
+
+#define R300_US_ALU_ALPHA_ADDR_0                 0x47C0
+#       define R300_ALU_SRC0A_SHIFT             0
+#       define R300_ALU_SRC0A_MASK              (31 << 0)
+#       define R300_ALU_SRC0A_CONST             (1 << 5)
+#       define R300_ALU_SRC1A_SHIFT             6
+#       define R300_ALU_SRC1A_MASK              (31 << 6)
+#       define R300_ALU_SRC1A_CONST             (1 << 11)
+#       define R300_ALU_SRC2A_SHIFT             12
+#       define R300_ALU_SRC2A_MASK              (31 << 12)
+#       define R300_ALU_SRC2A_CONST             (1 << 17)
+#       define R300_ALU_SRC_MASK                0x0003ffff
+#       define R300_ALU_DSTA_SHIFT              18
+#       define R300_ALU_DSTA_MASK               (31 << 18)
+#       define R300_ALU_DSTA_REG                (1 << 23)
+#       define R300_ALU_DSTA_OUTPUT             (1 << 24)
+#              define R300_ALU_DSTA_DEPTH              (1 << 27)
+
+#define R300_US_ALU_RGB_INST_0                   0x48C0
+#       define R300_ALU_ARGC_SRC0C_XYZ          0
+#       define R300_ALU_ARGC_SRC0C_XXX          1
+#       define R300_ALU_ARGC_SRC0C_YYY          2
+#       define R300_ALU_ARGC_SRC0C_ZZZ          3
+#       define R300_ALU_ARGC_SRC1C_XYZ          4
+#       define R300_ALU_ARGC_SRC1C_XXX          5
+#       define R300_ALU_ARGC_SRC1C_YYY          6
+#       define R300_ALU_ARGC_SRC1C_ZZZ          7
+#       define R300_ALU_ARGC_SRC2C_XYZ          8
+#       define R300_ALU_ARGC_SRC2C_XXX          9
+#       define R300_ALU_ARGC_SRC2C_YYY          10
+#       define R300_ALU_ARGC_SRC2C_ZZZ          11
+#       define R300_ALU_ARGC_SRC0A              12
+#       define R300_ALU_ARGC_SRC1A              13
+#       define R300_ALU_ARGC_SRC2A              14
+#       define R300_ALU_ARGC_SRCP_XYZ           15
+#       define R300_ALU_ARGC_SRCP_XXX           16
+#       define R300_ALU_ARGC_SRCP_YYY           17
+#       define R300_ALU_ARGC_SRCP_ZZZ           18
+#       define R300_ALU_ARGC_SRCP_WWW           19
+#       define R300_ALU_ARGC_ZERO               20
+#       define R300_ALU_ARGC_ONE                21
+#       define R300_ALU_ARGC_HALF               22
+#       define R300_ALU_ARGC_SRC0C_YZX          23
+#       define R300_ALU_ARGC_SRC1C_YZX          24
+#       define R300_ALU_ARGC_SRC2C_YZX          25
+#       define R300_ALU_ARGC_SRC0C_ZXY          26
+#       define R300_ALU_ARGC_SRC1C_ZXY          27
+#       define R300_ALU_ARGC_SRC2C_ZXY          28
+#       define R300_ALU_ARGC_SRC0CA_WZY         29
+#       define R300_ALU_ARGC_SRC1CA_WZY         30
+#       define R300_ALU_ARGC_SRC2CA_WZY         31
+
+#       define R300_ALU_ARG0C_SHIFT             0
+#       define R300_ALU_ARG0C_MASK              (31 << 0)
+#       define R300_ALU_ARG0C_NOP               (0 << 5)
+#       define R300_ALU_ARG0C_NEG               (1 << 5)
+#       define R300_ALU_ARG0C_ABS               (2 << 5)
+#       define R300_ALU_ARG0C_NAB               (3 << 5)
+#       define R300_ALU_ARG1C_SHIFT             7
+#       define R300_ALU_ARG1C_MASK              (31 << 7)
+#       define R300_ALU_ARG1C_NOP               (0 << 12)
+#       define R300_ALU_ARG1C_NEG               (1 << 12)
+#       define R300_ALU_ARG1C_ABS               (2 << 12)
+#       define R300_ALU_ARG1C_NAB               (3 << 12)
+#       define R300_ALU_ARG2C_SHIFT             14
+#       define R300_ALU_ARG2C_MASK              (31 << 14)
+#       define R300_ALU_ARG2C_NOP               (0 << 19)
+#       define R300_ALU_ARG2C_NEG               (1 << 19)
+#       define R300_ALU_ARG2C_ABS               (2 << 19)
+#       define R300_ALU_ARG2C_NAB               (3 << 19)
+#       define R300_ALU_SRCP_1_MINUS_2_SRC0     (0 << 21)
+#       define R300_ALU_SRCP_SRC1_MINUS_SRC0    (1 << 21)
+#       define R300_ALU_SRCP_SRC1_PLUS_SRC0     (2 << 21)
+#       define R300_ALU_SRCP_1_MINUS_SRC0       (3 << 21)
+
+#       define R300_ALU_OUTC_MAD                (0 << 23)
+#       define R300_ALU_OUTC_DP3                (1 << 23)
+#       define R300_ALU_OUTC_DP4                (2 << 23)
+#       define R300_ALU_OUTC_D2A                (3 << 23)
+#       define R300_ALU_OUTC_MIN                (4 << 23)
+#       define R300_ALU_OUTC_MAX                (5 << 23)
+#       define R300_ALU_OUTC_CMPH               (7 << 23)
+#       define R300_ALU_OUTC_CMP                (8 << 23)
+#       define R300_ALU_OUTC_FRC                (9 << 23)
+#       define R300_ALU_OUTC_REPL_ALPHA         (10 << 23)
+
+#       define R300_ALU_OUTC_MOD_NOP            (0 << 27)
+#       define R300_ALU_OUTC_MOD_MUL2           (1 << 27)
+#       define R300_ALU_OUTC_MOD_MUL4           (2 << 27)
+#       define R300_ALU_OUTC_MOD_MUL8           (3 << 27)
+#       define R300_ALU_OUTC_MOD_DIV2           (4 << 27)
+#       define R300_ALU_OUTC_MOD_DIV4           (5 << 27)
+#       define R300_ALU_OUTC_MOD_DIV8           (6 << 27)
+
+#       define R300_ALU_OUTC_CLAMP              (1 << 30)
+#       define R300_ALU_INSERT_NOP              (1 << 31)
+
+#define R300_US_ALU_ALPHA_INST_0                 0x49C0
+#       define R300_ALU_ARGA_SRC0C_X            0
+#       define R300_ALU_ARGA_SRC0C_Y            1
+#       define R300_ALU_ARGA_SRC0C_Z            2
+#       define R300_ALU_ARGA_SRC1C_X            3
+#       define R300_ALU_ARGA_SRC1C_Y            4
+#       define R300_ALU_ARGA_SRC1C_Z            5
+#       define R300_ALU_ARGA_SRC2C_X            6
+#       define R300_ALU_ARGA_SRC2C_Y            7
+#       define R300_ALU_ARGA_SRC2C_Z            8
+#       define R300_ALU_ARGA_SRC0A              9
+#       define R300_ALU_ARGA_SRC1A              10
+#       define R300_ALU_ARGA_SRC2A              11
+#       define R300_ALU_ARGA_SRCP_X             12
+#       define R300_ALU_ARGA_SRCP_Y             13
+#       define R300_ALU_ARGA_SRCP_Z             14
+#       define R300_ALU_ARGA_SRCP_W             15
+
+#       define R300_ALU_ARGA_ZERO               16
+#       define R300_ALU_ARGA_ONE                17
+#       define R300_ALU_ARGA_HALF               18
+#       define R300_ALU_ARG0A_SHIFT             0
+#       define R300_ALU_ARG0A_MASK              (31 << 0)
+#       define R300_ALU_ARG0A_NOP               (0 << 5)
+#       define R300_ALU_ARG0A_NEG               (1 << 5)
+#      define R300_ALU_ARG0A_ABS                (2 << 5)
+#      define R300_ALU_ARG0A_NAB                (3 << 5)
+#       define R300_ALU_ARG1A_SHIFT             7
+#       define R300_ALU_ARG1A_MASK              (31 << 7)
+#       define R300_ALU_ARG1A_NOP               (0 << 12)
+#       define R300_ALU_ARG1A_NEG               (1 << 12)
+#      define R300_ALU_ARG1A_ABS                (2 << 12)
+#      define R300_ALU_ARG1A_NAB                (3 << 12)
+#       define R300_ALU_ARG2A_SHIFT             14
+#       define R300_ALU_ARG2A_MASK              (31 << 14)
+#       define R300_ALU_ARG2A_NOP               (0 << 19)
+#       define R300_ALU_ARG2A_NEG               (1 << 19)
+#      define R300_ALU_ARG2A_ABS                (2 << 19)
+#      define R300_ALU_ARG2A_NAB                (3 << 19)
+#       define R300_ALU_SRCP_1_MINUS_2_SRC0     (0 << 21)
+#       define R300_ALU_SRCP_SRC1_MINUS_SRC0    (1 << 21)
+#       define R300_ALU_SRCP_SRC1_PLUS_SRC0     (2 << 21)
+#       define R300_ALU_SRCP_1_MINUS_SRC0       (3 << 21)
+
+#       define R300_ALU_OUTA_MAD                (0 << 23)
+#       define R300_ALU_OUTA_DP4                (1 << 23)
+#       define R300_ALU_OUTA_MIN                (2 << 23)
+#       define R300_ALU_OUTA_MAX                (3 << 23)
+#       define R300_ALU_OUTA_CND                (5 << 23)
+#       define R300_ALU_OUTA_CMP                (6 << 23)
+#       define R300_ALU_OUTA_FRC                (7 << 23)
+#       define R300_ALU_OUTA_EX2                (8 << 23)
+#       define R300_ALU_OUTA_LG2                (9 << 23)
+#       define R300_ALU_OUTA_RCP                (10 << 23)
+#       define R300_ALU_OUTA_RSQ                (11 << 23)
+
+#       define R300_ALU_OUTA_MOD_NOP            (0 << 27)
+#       define R300_ALU_OUTA_MOD_MUL2           (1 << 27)
+#       define R300_ALU_OUTA_MOD_MUL4           (2 << 27)
+#       define R300_ALU_OUTA_MOD_MUL8           (3 << 27)
+#       define R300_ALU_OUTA_MOD_DIV2           (4 << 27)
+#       define R300_ALU_OUTA_MOD_DIV4           (5 << 27)
+#       define R300_ALU_OUTA_MOD_DIV8           (6 << 27)
+
+#       define R300_ALU_OUTA_CLAMP              (1 << 30)
 /* END: Fragment program instruction set */
 
-/* Fog state and color */
-#define R300_RE_FOG_STATE                   0x4BC0
-#       define R300_FOG_ENABLE                   (1 << 0)
-#      define R300_FOG_MODE_LINEAR              (0 << 1)
-#      define R300_FOG_MODE_EXP                 (1 << 1)
-#      define R300_FOG_MODE_EXP2                (2 << 1)
-#      define R300_FOG_MODE_MASK                (3 << 1)
-#define R300_FOG_COLOR_R                    0x4BC8
-#define R300_FOG_COLOR_G                    0x4BCC
-#define R300_FOG_COLOR_B                    0x4BD0
-
-#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)
+/* Fog: Fog Blending Enable */
+#define R300_FG_FOG_BLEND                             0x4bc0
+#       define R300_FG_FOG_BLEND_DISABLE              (0 << 0)
+#       define R300_FG_FOG_BLEND_ENABLE               (1 << 0)
+#      define R300_FG_FOG_BLEND_FN_LINEAR            (0 << 1)
+#      define R300_FG_FOG_BLEND_FN_EXP               (1 << 1)
+#      define R300_FG_FOG_BLEND_FN_EXP2              (2 << 1)
+#      define R300_FG_FOG_BLEND_FN_CONSTANT          (3 << 1)
+#      define R300_FG_FOG_BLEND_FN_MASK              (3 << 1)
+
+/* Fog: Red Component of Fog Color */
+#define R300_FG_FOG_COLOR_R                           0x4bc8
+/* Fog: Green Component of Fog Color */
+#define R300_FG_FOG_COLOR_G                           0x4bcc
+/* Fog: Blue Component of Fog Color */
+#define R300_FG_FOG_COLOR_B                           0x4bd0
+#      define R300_FG_FOG_COLOR_MASK 0x000003ff
+
+/* Fog: Constant Factor for Fog Blending */
+#define R300_FG_FOG_FACTOR                            0x4bc4
+#      define FG_FOG_FACTOR_MASK 0x000003ff
+
+/* Fog: Alpha function */
+#define R300_FG_ALPHA_FUNC                            0x4bd4
+#       define R300_FG_ALPHA_FUNC_VAL_MASK               0x000000ff
+#       define R300_FG_ALPHA_FUNC_NEVER                     (0 << 8)
+#       define R300_FG_ALPHA_FUNC_LESS                      (1 << 8)
+#       define R300_FG_ALPHA_FUNC_EQUAL                     (2 << 8)
+#       define R300_FG_ALPHA_FUNC_LE                        (3 << 8)
+#       define R300_FG_ALPHA_FUNC_GREATER                   (4 << 8)
+#       define R300_FG_ALPHA_FUNC_NOTEQUAL                  (5 << 8)
+#       define R300_FG_ALPHA_FUNC_GE                        (6 << 8)
+#       define R300_FG_ALPHA_FUNC_ALWAYS                    (7 << 8)
+#       define R300_ALPHA_TEST_OP_MASK                      (7 << 8)
+#       define R300_FG_ALPHA_FUNC_DISABLE                   (0 << 11)
+#       define R300_FG_ALPHA_FUNC_ENABLE                    (1 << 11)
+
+#       define R500_FG_ALPHA_FUNC_10BIT                     (0 << 12)
+#       define R500_FG_ALPHA_FUNC_8BIT                      (1 << 12)
+
+#       define R300_FG_ALPHA_FUNC_MASK_DISABLE              (0 << 16)
+#       define R300_FG_ALPHA_FUNC_MASK_ENABLE               (1 << 16)
+#       define R300_FG_ALPHA_FUNC_CFG_2_OF_4                (0 << 17)
+#       define R300_FG_ALPHA_FUNC_CFG_3_OF_6                (1 << 17)
+
+#       define R300_FG_ALPHA_FUNC_DITH_DISABLE              (0 << 20)
+#       define R300_FG_ALPHA_FUNC_DITH_ENABLE               (1 << 20)
+
+#       define R500_FG_ALPHA_FUNC_OFFSET_DISABLE            (0 << 24)
+#       define R500_FG_ALPHA_FUNC_OFFSET_ENABLE             (1 << 24) /* Not supported in R520 */
+#       define R500_FG_ALPHA_FUNC_DISC_ZERO_MASK_DISABLE    (0 << 25)
+#       define R500_FG_ALPHA_FUNC_DISC_ZERO_MASK_ENABLE     (1 << 25)
+
+#       define R500_FG_ALPHA_FUNC_FP16_DISABLE              (0 << 28)
+#       define R500_FG_ALPHA_FUNC_FP16_ENABLE               (1 << 28)
+
+
+/* Fog: Where does the depth come from? */
+#define R300_FG_DEPTH_SRC                  0x4bd8
+#      define R300_FG_DEPTH_SRC_SCAN   (0 << 0)
+#      define R300_FG_DEPTH_SRC_SHADER (1 << 0)
+
+/* Fog: Alpha Compare Value */
+#define R500_FG_ALPHA_VALUE                0x4be0
+#      define R500_FG_ALPHA_VALUE_MASK 0x0000ffff
 
 /* gap */
 
@@ -1285,12 +2006,33 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #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 */
+/* last consts */
 #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
 
+/* Unpipelined. */
+#define R300_RB3D_CCTL                      0x4e00
+#      define R300_RB3D_CCTL_NUM_MULTIWRITES_1_BUFFER                (0 << 5)
+#      define R300_RB3D_CCTL_NUM_MULTIWRITES_2_BUFFERS               (1 << 5)
+#      define R300_RB3D_CCTL_NUM_MULTIWRITES_3_BUFFERS               (2 << 5)
+#      define R300_RB3D_CCTL_NUM_MULTIWRITES_4_BUFFERS               (3 << 5)
+#      define R300_RB3D_CCTL_CLRCMP_FLIPE_DISABLE                    (0 << 7)
+#      define R300_RB3D_CCTL_CLRCMP_FLIPE_ENABLE                     (1 << 7)
+#      define R300_RB3D_CCTL_AA_COMPRESSION_DISABLE                  (0 << 9)
+#      define R300_RB3D_CCTL_AA_COMPRESSION_ENABLE                   (1 << 9)
+#      define R300_RB3D_CCTL_CMASK_DISABLE                           (0 << 10)
+#      define R300_RB3D_CCTL_CMASK_ENABLE                            (1 << 10)
+/* reserved */
+#      define R300_RB3D_CCTL_INDEPENDENT_COLOR_CHANNEL_MASK_DISABLE  (0 << 12)
+#      define R300_RB3D_CCTL_INDEPENDENT_COLOR_CHANNEL_MASK_ENABLE   (1 << 12)
+#      define R300_RB3D_CCTL_WRITE_COMPRESSION_ENABLE                (0 << 13)
+#      define R300_RB3D_CCTL_WRITE_COMPRESSION_DISABLE               (1 << 13)
+#      define R300_RB3D_CCTL_INDEPENDENT_COLORFORMAT_ENABLE_DISABLE  (0 << 14)
+#      define R300_RB3D_CCTL_INDEPENDENT_COLORFORMAT_ENABLE_ENABLE   (1 << 14)
+
+
 /* Notes:
  * - AFAIK fglrx always sets BLEND_UNKNOWN when blending is used in
  *   the application
@@ -1302,9 +2044,17 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #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)
+#       define R300_ALPHA_BLEND_ENABLE         (1 << 0)
+#       define R300_SEPARATE_ALPHA_ENABLE      (1 << 1)
+#       define R300_READ_ENABLE                (1 << 2)
+#       define R300_DISCARD_SRC_PIXELS_DIS     (0 << 3)
+#       define R300_DISCARD_SRC_PIXELS_SRC_ALPHA_0     (1 << 3)
+#       define R300_DISCARD_SRC_PIXELS_SRC_COLOR_0     (2 << 3)
+#       define R300_DISCARD_SRC_PIXELS_SRC_ALPHA_COLOR_0     (3 << 3)
+#       define R300_DISCARD_SRC_PIXELS_SRC_ALPHA_1     (4 << 3)
+#       define R300_DISCARD_SRC_PIXELS_SRC_COLOR_1     (5 << 3)
+#       define R300_DISCARD_SRC_PIXELS_SRC_ALPHA_COLOR_1     (6 << 3)
+
 /* the following are shared between CBLEND and ABLEND */
 #       define R300_FCN_MASK                         (3  << 12)
 #       define R300_COMB_FCN_ADD_CLAMP               (0  << 12)
@@ -1333,67 +2083,213 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #       define R300_BLEND_MASK                       (63)
 #       define R300_SRC_BLEND_SHIFT                  (16)
 #       define R300_DST_BLEND_SHIFT                  (24)
+
+/* Constant color used by the blender. Pipelined through the blender.
+ * Note: For R520, this field is ignored, use RB3D_CONSTANT_COLOR_GB__BLUE,
+ * RB3D_CONSTANT_COLOR_GB__GREEN, etc. instead.
+ */
 #define R300_RB3D_BLEND_COLOR               0x4E10
-#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 */
+/* 3D Color Channel Mask. If all the channels used in the current color format
+ * are disabled, then the cb will discard all the incoming quads. Pipelined
+ * through the blender.
+ */
+#define RB3D_COLOR_CHANNEL_MASK                  0x4E0C
+#      define RB3D_COLOR_CHANNEL_MASK_BLUE_MASK0  (1 << 0)
+#      define RB3D_COLOR_CHANNEL_MASK_GREEN_MASK0 (1 << 1)
+#      define RB3D_COLOR_CHANNEL_MASK_RED_MASK0   (1 << 2)
+#      define RB3D_COLOR_CHANNEL_MASK_ALPHA_MASK0 (1 << 3)
+#      define RB3D_COLOR_CHANNEL_MASK_BLUE_MASK1  (1 << 4)
+#      define RB3D_COLOR_CHANNEL_MASK_GREEN_MASK1 (1 << 5)
+#      define RB3D_COLOR_CHANNEL_MASK_RED_MASK1   (1 << 6)
+#      define RB3D_COLOR_CHANNEL_MASK_ALPHA_MASK1 (1 << 7)
+#      define RB3D_COLOR_CHANNEL_MASK_BLUE_MASK2  (1 << 8)
+#      define RB3D_COLOR_CHANNEL_MASK_GREEN_MASK2 (1 << 9)
+#      define RB3D_COLOR_CHANNEL_MASK_RED_MASK2   (1 << 10)
+#      define RB3D_COLOR_CHANNEL_MASK_ALPHA_MASK2 (1 << 11)
+#      define RB3D_COLOR_CHANNEL_MASK_BLUE_MASK3  (1 << 12)
+#      define RB3D_COLOR_CHANNEL_MASK_GREEN_MASK3 (1 << 13)
+#      define RB3D_COLOR_CHANNEL_MASK_RED_MASK3   (1 << 14)
+#      define RB3D_COLOR_CHANNEL_MASK_ALPHA_MASK3 (1 << 15)
+
+/* Clear color that is used when the color mask is set to 00. Unpipelined.
+ * Program this register with a 32-bit value in ARGB8888 or ARGB2101010
+ * formats, ignoring the fields.
+ */
+#define RB3D_COLOR_CLEAR_VALUE                   0x4e14
 
 /* gap */
 
-/* Bit 16: Larger tiles
+/* Color Compare Color. Stalls the 2d/3d datapath until it is idle. */
+#define RB3D_CLRCMP_CLR                     0x4e20
+
+/* Color Compare Mask. Stalls the 2d/3d datapath until it is idle. */
+#define RB3D_CLRCMP_MSK                     0x4e24
+
+/* Color Buffer Address Offset of multibuffer 0. Unpipelined. */
+#define R300_RB3D_COLOROFFSET0              0x4E28
+#       define R300_COLOROFFSET_MASK             0xFFFFFFE0
+/* Color Buffer Address Offset of multibuffer 1. Unpipelined. */
+#define R300_RB3D_COLOROFFSET1              0x4E2C
+/* Color Buffer Address Offset of multibuffer 2. Unpipelined. */
+#define R300_RB3D_COLOROFFSET2              0x4E30
+/* Color Buffer Address Offset of multibuffer 3. Unpipelined. */
+#define R300_RB3D_COLOROFFSET3              0x4E34
+
+/* Color buffer format and tiling control for all the multibuffers and the
+ * pitch of multibuffer 0 to 3. Unpipelined. The cache must be empty before any
+ * of the registers are changed.
+ *
+ * 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 */
+#       define R300_COLORPITCH_MASK              0x00003FFE
+#       define R300_COLOR_TILE_DISABLE            (0 << 16)
+#       define R300_COLOR_TILE_ENABLE             (1 << 16)
+#       define R300_COLOR_MICROTILE_DISABLE       (0 << 17)
+#       define R300_COLOR_MICROTILE_ENABLE        (1 << 17)
+#       define R300_COLOR_MICROTILE_ENABLE_SQUARE (2 << 17) /* Only available in 16-bit */
+#       define R300_COLOR_ENDIAN_NO_SWAP          (0 << 19)
+#       define R300_COLOR_ENDIAN_WORD_SWAP        (1 << 19)
+#       define R300_COLOR_ENDIAN_DWORD_SWAP       (2 << 19)
+#       define R300_COLOR_ENDIAN_HALF_DWORD_SWAP  (3 << 19)
+#      define R500_COLOR_FORMAT_ARGB10101010     (0 << 21)
+#      define R500_COLOR_FORMAT_UV1010           (1 << 21)
+#      define R500_COLOR_FORMAT_CI8              (2 << 21) /* 2D only */
+#      define R300_COLOR_FORMAT_ARGB1555         (3 << 21)
+#       define R300_COLOR_FORMAT_RGB565           (4 << 21)
+#       define R500_COLOR_FORMAT_ARGB2101010      (5 << 21)
+#       define R300_COLOR_FORMAT_ARGB8888         (6 << 21)
+#       define R300_COLOR_FORMAT_ARGB32323232     (7 << 21)
+/* reserved */
+#       define R300_COLOR_FORMAT_I8               (9 << 21)
+#       define R300_COLOR_FORMAT_ARGB16161616     (10 << 21)
+#       define R300_COLOR_FORMAT_VYUY             (11 << 21)
+#       define R300_COLOR_FORMAT_YVYU             (12 << 21)
+#       define R300_COLOR_FORMAT_UV88             (13 << 21)
+#       define R500_COLOR_FORMAT_I10              (14 << 21)
+#       define R300_COLOR_FORMAT_ARGB4444         (15 << 21)
+#define R300_RB3D_COLORPITCH1               0x4E3C
+#define R300_RB3D_COLORPITCH2               0x4E40
+#define R300_RB3D_COLORPITCH3               0x4E44
 
 /* gap */
 
-/* Guess by Vladimir.
+/* Destination Color Buffer Cache Control/Status. If the cb is in e2 mode, then
+ * a flush or free will not occur upon a write to this register, but a sync
+ * will be immediately sent if one is requested. If both DC_FLUSH and DC_FREE
+ * are zero but DC_FINISH is one, then a sync will be sent immediately -- the
+ * cb will not wait for all the previous operations to complete before sending
+ * the sync. Unpipelined except when DC_FINISH and DC_FREE are both set to
+ * zero.
+ *
  * Set to 0A before 3D operations, set to 02 afterwards.
  */
-#define R300_RB3D_DSTCACHE_CTLSTAT          0x4E4C
-#       define R300_RB3D_DSTCACHE_UNKNOWN_02             0x00000002
-#       define R300_RB3D_DSTCACHE_UNKNOWN_0A             0x0000000A
+#define R300_RB3D_DSTCACHE_CTLSTAT               0x4e4c
+#      define R300_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_NO_EFFECT         (0 << 0)
+#      define R300_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_NO_EFFECT_1       (1 << 0)
+#      define R300_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_FLUSH_DIRTY_3D    (2 << 0)
+#      define R300_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_FLUSH_DIRTY_3D_1  (3 << 0)
+#      define R300_RB3D_DSTCACHE_CTLSTAT_DC_FREE_NO_EFFECT          (0 << 2)
+#      define R300_RB3D_DSTCACHE_CTLSTAT_DC_FREE_NO_EFFECT_1        (1 << 2)
+#      define R300_RB3D_DSTCACHE_CTLSTAT_DC_FREE_FREE_3D_TAGS       (2 << 2)
+#      define R300_RB3D_DSTCACHE_CTLSTAT_DC_FREE_FREE_3D_TAGS_1     (3 << 2)
+#      define R300_RB3D_DSTCACHE_CTLSTAT_DC_FINISH_NO_SIGNAL        (0 << 4)
+#      define R300_RB3D_DSTCACHE_CTLSTAT_DC_FINISH_SIGNAL           (1 << 4)
+
+#define R300_RB3D_DITHER_CTL 0x4E50
+#      define R300_RB3D_DITHER_CTL_DITHER_MODE_TRUNCATE         (0 << 0)
+#      define R300_RB3D_DITHER_CTL_DITHER_MODE_ROUND            (1 << 0)
+#      define R300_RB3D_DITHER_CTL_DITHER_MODE_LUT              (2 << 0)
+/* reserved */
+#      define R300_RB3D_DITHER_CTL_ALPHA_DITHER_MODE_TRUNCATE   (0 << 2)
+#      define R300_RB3D_DITHER_CTL_ALPHA_DITHER_MODE_ROUND      (1 << 2)
+#      define R300_RB3D_DITHER_CTL_ALPHA_DITHER_MODE_LUT        (2 << 2)
+/* reserved */
+
+/* Resolve buffer destination address. The cache must be empty before changing
+ * this register if the cb is in resolve mode. Unpipelined
+ */
+#define R300_RB3D_AARESOLVE_OFFSET        0x4e80
+#      define R300_RB3D_AARESOLVE_OFFSET_SHIFT 5
+#      define R300_RB3D_AARESOLVE_OFFSET_MASK 0xffffffe0 /* At least according to the calculations of Christoph Brill */
+
+/* Resolve Buffer Pitch and Tiling Control. The cache must be empty before
+ * changing this register if the cb is in resolve mode. Unpipelined
+ */
+#define R300_RB3D_AARESOLVE_PITCH         0x4e84
+#      define R300_RB3D_AARESOLVE_PITCH_SHIFT 1
+#      define R300_RB3D_AARESOLVE_PITCH_MASK  0x00003ffe /* At least according to the calculations of Christoph Brill */
+
+/* Resolve Buffer Control. Unpipelined */
+#define R300_RB3D_AARESOLVE_CTL           0x4e88
+#      define R300_RB3D_AARESOLVE_CTL_AARESOLVE_MODE_NORMAL   (0 << 0)
+#      define R300_RB3D_AARESOLVE_CTL_AARESOLVE_MODE_RESOLVE  (1 << 0)
+#      define R300_RB3D_AARESOLVE_CTL_AARESOLVE_GAMMA_10      (0 << 1)
+#      define R300_RB3D_AARESOLVE_CTL_AARESOLVE_GAMMA_22      (1 << 1)
+#      define R300_RB3D_AARESOLVE_CTL_AARESOLVE_ALPHA_SAMPLE0 (0 << 2)
+#      define R300_RB3D_AARESOLVE_CTL_AARESOLVE_ALPHA_AVERAGE (1 << 2)
+
+
+/* Discard src pixels less than or equal to threshold. */
+#define R500_RB3D_DISCARD_SRC_PIXEL_LTE_THRESHOLD 0x4ea0
+/* Discard src pixels greater than or equal to threshold. */
+#define R500_RB3D_DISCARD_SRC_PIXEL_GTE_THRESHOLD 0x4ea4
+#      define R500_RB3D_DISCARD_SRC_PIXEL_THRESHOLD_BLUE_SHIFT 0
+#      define R500_RB3D_DISCARD_SRC_PIXEL_THRESHOLD_BLUE_MASK 0x000000ff
+#      define R500_RB3D_DISCARD_SRC_PIXEL_THRESHOLD_GREEN_SHIFT 8
+#      define R500_RB3D_DISCARD_SRC_PIXEL_THRESHOLD_GREEN_MASK 0x0000ff00
+#      define R500_RB3D_DISCARD_SRC_PIXEL_THRESHOLD_RED_SHIFT 16
+#      define R500_RB3D_DISCARD_SRC_PIXEL_THRESHOLD_RED_MASK 0x00ff0000
+#      define R500_RB3D_DISCARD_SRC_PIXEL_THRESHOLD_ALPHA_SHIFT 24
+#      define R500_RB3D_DISCARD_SRC_PIXEL_THRESHOLD_ALPHA_MASK 0xff000000
+
+/* 3D ROP Control. Stalls the 2d/3d datapath until it is idle. */
+#define R300_RB3D_ROPCNTL                             0x4e18
+#      define R300_RB3D_ROPCNTL_ROP_ENABLE            0x00000004
+#      define R300_RB3D_ROPCNTL_ROP_MASK              (15 << 8)
+#      define R300_RB3D_ROPCNTL_ROP_SHIFT             8
+
+/* Color Compare Flip. Stalls the 2d/3d datapath until it is idle. */
+#define R300_RB3D_CLRCMP_FLIPE                        0x4e1c
+
+/* Sets the fifo sizes */
+#define R500_RB3D_FIFO_SIZE                           0x4ef4
+#      define R500_RB3D_FIFO_SIZE_OP_FIFO_SIZE_FULL   (0 << 0)
+#      define R500_RB3D_FIFO_SIZE_OP_FIFO_SIZE_HALF   (1 << 0)
+#      define R500_RB3D_FIFO_SIZE_OP_FIFO_SIZE_QUATER (2 << 0)
+#      define R500_RB3D_FIFO_SIZE_OP_FIFO_SIZE_EIGTHS (3 << 0)
+
+/* Constant color used by the blender. Pipelined through the blender. */
+#define R500_RB3D_CONSTANT_COLOR_AR                   0x4ef8
+#      define R500_RB3D_CONSTANT_COLOR_AR_RED_MASK    0x0000ffff
+#      define R500_RB3D_CONSTANT_COLOR_AR_RED_SHIFT   0
+#      define R500_RB3D_CONSTANT_COLOR_AR_ALPHA_MASK  0xffff0000
+#      define R500_RB3D_CONSTANT_COLOR_AR_ALPHA_SHIFT 16
+
+/* Constant color used by the blender. Pipelined through the blender. */
+#define R500_RB3D_CONSTANT_COLOR_GB                   0x4efc
+#      define R500_RB3D_CONSTANT_COLOR_AR_BLUE_MASK   0x0000ffff
+#      define R500_RB3D_CONSTANT_COLOR_AR_BLUE_SHIFT  0
+#      define R500_RB3D_CONSTANT_COLOR_AR_GREEN_MASK  0xffff0000
+#      define R500_RB3D_CONSTANT_COLOR_AR_GREEN_SHIFT 16
 
 /* 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
-#       define R300_RB3D_Z_DISABLED_2            0x00000014
-#       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
+#define R300_ZB_CNTL                             0x4F00
+#      define R300_STENCIL_ENABLE               (1 << 0)
+#      define R300_Z_ENABLE                     (1 << 1)
+#      define R300_Z_WRITE_ENABLE               (1 << 2)
+#      define R300_Z_SIGNED_COMPARE             (1 << 3)
+#      define R300_STENCIL_FRONT_BACK           (1 << 4)
+
+#define R300_ZB_ZSTENCILCNTL                   0x4f04
        /* functions */
 #      define R300_ZS_NEVER                    0
 #      define R300_ZS_LESS                     1
@@ -1413,162 +2309,344 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #      define R300_ZS_INVERT                   5
 #      define R300_ZS_INCR_WRAP                6
 #      define R300_ZS_DECR_WRAP                7
+#      define R300_Z_FUNC_SHIFT                0
        /* 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
+#      define R300_S_FRONT_FUNC_SHIFT          3
+#      define R300_S_FRONT_SFAIL_OP_SHIFT      6
+#      define R300_S_FRONT_ZPASS_OP_SHIFT      9
+#      define R300_S_FRONT_ZFAIL_OP_SHIFT      12
+#      define R300_S_BACK_FUNC_SHIFT           15
+#      define R300_S_BACK_SFAIL_OP_SHIFT       18
+#      define R300_S_BACK_ZPASS_OP_SHIFT       21
+#      define R300_S_BACK_ZFAIL_OP_SHIFT       24
+
+#define R300_ZB_STENCILREFMASK                        0x4f08
+#      define R300_STENCILREF_SHIFT       0
+#      define R300_STENCILREF_MASK        0x000000ff
+#      define R300_STENCILMASK_SHIFT      8
+#      define R300_STENCILMASK_MASK       0x0000ff00
+#      define R300_STENCILWRITEMASK_SHIFT 16
+#      define R300_STENCILWRITEMASK_MASK  0x00ff0000
 
 /* 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)
-       /* 16 bit format or some aditional bit ? */
-#      define R300_DEPTH_FORMAT_UNK32          (32 << 0)
+#define R300_ZB_FORMAT                             0x4f10
+#      define R300_DEPTHFORMAT_16BIT_INT_Z   (0 << 0)
+#      define R300_DEPTHFORMAT_16BIT_13E3    (1 << 0)
+#      define R300_DEPTHFORMAT_24BIT_INT_Z_8BIT_STENCIL   (2 << 0)
+/* reserved up to (15 << 0) */
+#      define R300_INVERT_13E3_LEADING_ONES  (0 << 4)
+#      define R300_INVERT_13E3_LEADING_ZEROS (1 << 4)
 
-#define R300_RB3D_EARLY_Z                           0x4F14
-#      define R300_EARLY_Z_DISABLE              (0 << 0)
-#      define R300_EARLY_Z_ENABLE               (1 << 0)
+#define R300_ZB_ZTOP                             0x4F14
+#      define R300_ZTOP_DISABLE                 (0 << 0)
+#      define R300_ZTOP_ENABLE                  (1 << 0)
 
 /* gap */
 
-#define R300_RB3D_ZCACHE_CTLSTAT            0x4F18 /* GUESS */
-#       define R300_RB3D_ZCACHE_UNKNOWN_01  0x1
-#       define R300_RB3D_ZCACHE_UNKNOWN_03  0x3
+#define R300_ZB_ZCACHE_CTLSTAT            0x4f18
+#       define R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_NO_EFFECT      (0 << 0)
+#       define R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE (1 << 0)
+#       define R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_NO_EFFECT       (0 << 1)
+#       define R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE            (1 << 1)
+#       define R300_ZB_ZCACHE_CTLSTAT_ZC_BUSY_IDLE            (0 << 31)
+#       define R300_ZB_ZCACHE_CTLSTAT_ZC_BUSY_BUSY            (1 << 31)
+
+#define R300_ZB_BW_CNTL                     0x4f1c
+#      define R300_HIZ_DISABLE                              (0 << 0)
+#      define R300_HIZ_ENABLE                               (1 << 0)
+#      define R300_HIZ_MIN                                  (0 << 1)
+#      define R300_HIZ_MAX                                  (1 << 1)
+#      define R300_FAST_FILL_DISABLE                        (0 << 2)
+#      define R300_FAST_FILL_ENABLE                         (1 << 2)
+#      define R300_RD_COMP_DISABLE                          (0 << 3)
+#      define R300_RD_COMP_ENABLE                           (1 << 3)
+#      define R300_WR_COMP_DISABLE                          (0 << 4)
+#      define R300_WR_COMP_ENABLE                           (1 << 4)
+#      define R300_ZB_CB_CLEAR_RMW                          (0 << 5)
+#      define R300_ZB_CB_CLEAR_CACHE_LINEAR                 (1 << 5)
+#      define R300_FORCE_COMPRESSED_STENCIL_VALUE_DISABLE   (0 << 6)
+#      define R300_FORCE_COMPRESSED_STENCIL_VALUE_ENABLE    (1 << 6)
+
+#      define R500_ZEQUAL_OPTIMIZE_ENABLE                   (0 << 7)
+#      define R500_ZEQUAL_OPTIMIZE_DISABLE                  (1 << 7)
+#      define R500_SEQUAL_OPTIMIZE_ENABLE                   (0 << 8)
+#      define R500_SEQUAL_OPTIMIZE_DISABLE                  (1 << 8)
+
+#      define R500_BMASK_ENABLE                             (0 << 10)
+#      define R500_BMASK_DISABLE                            (1 << 10)
+#      define R500_HIZ_EQUAL_REJECT_DISABLE                 (0 << 11)
+#      define R500_HIZ_EQUAL_REJECT_ENABLE                  (1 << 11)
+#      define R500_HIZ_FP_EXP_BITS_DISABLE                  (0 << 12)
+#      define R500_HIZ_FP_EXP_BITS_1                        (1 << 12)
+#      define R500_HIZ_FP_EXP_BITS_2                        (2 << 12)
+#      define R500_HIZ_FP_EXP_BITS_3                        (3 << 12)
+#      define R500_HIZ_FP_EXP_BITS_4                        (4 << 12)
+#      define R500_HIZ_FP_EXP_BITS_5                        (5 << 12)
+#      define R500_HIZ_FP_INVERT_LEADING_ONES               (0 << 15)
+#      define R500_HIZ_FP_INVERT_LEADING_ZEROS              (1 << 15)
+#      define R500_TILE_OVERWRITE_RECOMPRESSION_ENABLE      (0 << 16)
+#      define R500_TILE_OVERWRITE_RECOMPRESSION_DISABLE     (1 << 16)
+#      define R500_CONTIGUOUS_6XAA_SAMPLES_ENABLE           (0 << 17)
+#      define R500_CONTIGUOUS_6XAA_SAMPLES_DISABLE          (1 << 17)
+#      define R500_PEQ_PACKING_DISABLE                      (0 << 18)
+#      define R500_PEQ_PACKING_ENABLE                       (1 << 18)
+#      define R500_COVERED_PTR_MASKING_DISABLE              (0 << 18)
+#      define R500_COVERED_PTR_MASKING_ENABLE               (1 << 18)
+
 
 /* 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
+/* Z Buffer Address Offset.
+ * Bits 31 to 5 are used for aligned Z buffer address offset for macro tiles.
  */
-#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)
-       /* Used in GL_POINT_DISTANCE_ATTENUATION_ARB, vector(scalar, vector) */
-#define R300_VPI_OUT_OP_UNK12                   (12 << 0)
-#define R300_VPI_OUT_OP_ARL                     (13 << 0)
-#define R300_VPI_OUT_OP_EXP                     (65 << 0)
-#define R300_VPI_OUT_OP_LOG                     (66 << 0)
-       /* Used in fog computations, scalar(scalar) */
-#define R300_VPI_OUT_OP_UNK67                   (67 << 0)
-#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)
-       /* Used in GL_POINT_DISTANCE_ATTENUATION_ARB, scalar(scalar) */
-#define R300_VPI_OUT_OP_UNK73                   (73 << 0)
-#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)
-       /* all temps, vector(scalar, vector, vector) */
-#define R300_VPI_OUT_OP_UNK129                  (129 << 0)
-
-#define R300_VPI_OUT_REG_CLASS_TEMPORARY        (0 << 8)
-#define R300_VPI_OUT_REG_CLASS_ADDR             (1 << 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
-       /* GUESS based on fglrx native limits */
-#define R300_VPI_OUT_REG_INDEX_MASK             (31 << 13)
-
-#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)
-
-#define R300_VPI_IN_REG_INDEX_SHIFT             5
-       /* GUESS based on fglrx native limits */
-#define R300_VPI_IN_REG_INDEX_MASK              (255 << 5)
-
-/* 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_ZB_DEPTHOFFSET               0x4f20
+
+/* Z Buffer Pitch and Endian Control */
+#define R300_ZB_DEPTHPITCH                0x4f24
+#       define R300_DEPTHPITCH_MASK              0x00003FFC
+#       define R300_DEPTHMACROTILE_DISABLE      (0 << 16)
+#       define R300_DEPTHMACROTILE_ENABLE       (1 << 16)
+#       define R300_DEPTHMICROTILE_LINEAR       (0 << 17)
+#       define R300_DEPTHMICROTILE_TILED        (1 << 17)
+#       define R300_DEPTHMICROTILE_TILED_SQUARE (2 << 17)
+#       define R300_DEPTHENDIAN_NO_SWAP         (0 << 18)
+#       define R300_DEPTHENDIAN_WORD_SWAP       (1 << 18)
+#       define R300_DEPTHENDIAN_DWORD_SWAP      (2 << 18)
+#       define R300_DEPTHENDIAN_HALF_DWORD_SWAP (3 << 18)
+
+/* Z Buffer Clear Value */
+#define R300_ZB_DEPTHCLEARVALUE                  0x4f28
+
+/* Hierarchical Z Memory Offset */
+#define R300_ZB_HIZ_OFFSET                       0x4f44
+
+/* Hierarchical Z Write Index */
+#define R300_ZB_HIZ_WRINDEX                      0x4f48
+
+/* Hierarchical Z Data */
+#define R300_ZB_HIZ_DWORD                        0x4f4c
+
+/* Hierarchical Z Read Index */
+#define R300_ZB_HIZ_RDINDEX                      0x4f50
+
+/* Hierarchical Z Pitch */
+#define R300_ZB_HIZ_PITCH                        0x4f54
+
+/* Z Buffer Z Pass Counter Data */
+#define R300_ZB_ZPASS_DATA                       0x4f58
+
+/* Z Buffer Z Pass Counter Address */
+#define R300_ZB_ZPASS_ADDR                       0x4f5c
+
+/* Depth buffer X and Y coordinate offset */
+#define R300_ZB_DEPTHXY_OFFSET                   0x4f60
+#      define R300_DEPTHX_OFFSET_SHIFT  1
+#      define R300_DEPTHX_OFFSET_MASK   0x000007FE
+#      define R300_DEPTHY_OFFSET_SHIFT  17
+#      define R300_DEPTHY_OFFSET_MASK   0x07FE0000
+
+/* Sets the fifo sizes */
+#define R500_ZB_FIFO_SIZE                        0x4fd0
+#      define R500_OP_FIFO_SIZE_FULL   (0 << 0)
+#      define R500_OP_FIFO_SIZE_HALF   (1 << 0)
+#      define R500_OP_FIFO_SIZE_QUATER (2 << 0)
+#      define R500_OP_FIFO_SIZE_EIGTHS (4 << 0)
+
+/* Stencil Reference Value and Mask for backfacing quads */
+/* R300_ZB_STENCILREFMASK handles front face */
+#define R500_ZB_STENCILREFMASK_BF                0x4fd4
+#      define R500_STENCILREF_SHIFT       0
+#      define R500_STENCILREF_MASK        0x000000ff
+#      define R500_STENCILMASK_SHIFT      8
+#      define R500_STENCILMASK_MASK       0x0000ff00
+#      define R500_STENCILWRITEMASK_SHIFT 16
+#      define R500_STENCILWRITEMASK_MASK  0x00ff0000
+
+/**
+ * \defgroup R3XX_R5XX_PROGRAMMABLE_VERTEX_SHADER_DESCRIPTION R3XX-R5XX PROGRAMMABLE VERTEX SHADER DESCRIPTION
+ *
+ * The PVS_DST_MATH_INST is used to identify whether the instruction is a Vector
+ * Engine instruction or a Math Engine instruction.
  */
-#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: Vertex program instruction set */
+
+/*\{*/
+
+enum {
+       /* R3XX */
+       VECTOR_NO_OP                    = 0,
+       VE_DOT_PRODUCT                  = 1,
+       VE_MULTIPLY                     = 2,
+       VE_ADD                          = 3,
+       VE_MULTIPLY_ADD                 = 4,
+       VE_DISTANCE_VECTOR              = 5,
+       VE_FRACTION                     = 6,
+       VE_MAXIMUM                      = 7,
+       VE_MINIMUM                      = 8,
+       VE_SET_GREATER_THAN_EQUAL       = 9,
+       VE_SET_LESS_THAN                = 10,
+       VE_MULTIPLYX2_ADD               = 11,
+       VE_MULTIPLY_CLAMP               = 12,
+       VE_FLT2FIX_DX                   = 13,
+       VE_FLT2FIX_DX_RND               = 14,
+       /* R5XX */
+       VE_PRED_SET_EQ_PUSH             = 15,
+       VE_PRED_SET_GT_PUSH             = 16,
+       VE_PRED_SET_GTE_PUSH            = 17,
+       VE_PRED_SET_NEQ_PUSH            = 18,
+       VE_COND_WRITE_EQ                = 19,
+       VE_COND_WRITE_GT                = 20,
+       VE_COND_WRITE_GTE               = 21,
+       VE_COND_WRITE_NEQ               = 22,
+       VE_COND_MUX_EQ                  = 23,
+       VE_COND_MUX_GT                  = 24,
+       VE_COND_MUX_GTE                 = 25,
+       VE_SET_GREATER_THAN             = 26,
+       VE_SET_EQUAL                    = 27,
+       VE_SET_NOT_EQUAL                = 28,
+};
+
+enum {
+       /* R3XX */
+       MATH_NO_OP                      = 0,
+       ME_EXP_BASE2_DX                 = 1,
+       ME_LOG_BASE2_DX                 = 2,
+       ME_EXP_BASEE_FF                 = 3,
+       ME_LIGHT_COEFF_DX               = 4,
+       ME_POWER_FUNC_FF                = 5,
+       ME_RECIP_DX                     = 6,
+       ME_RECIP_FF                     = 7,
+       ME_RECIP_SQRT_DX                = 8,
+       ME_RECIP_SQRT_FF                = 9,
+       ME_MULTIPLY                     = 10,
+       ME_EXP_BASE2_FULL_DX            = 11,
+       ME_LOG_BASE2_FULL_DX            = 12,
+       ME_POWER_FUNC_FF_CLAMP_B        = 13,
+       ME_POWER_FUNC_FF_CLAMP_B1       = 14,
+       ME_POWER_FUNC_FF_CLAMP_01       = 15,
+       ME_SIN                          = 16,
+       ME_COS                          = 17,
+       /* R5XX */
+       ME_LOG_BASE2_IEEE               = 18,
+       ME_RECIP_IEEE                   = 19,
+       ME_RECIP_SQRT_IEEE              = 20,
+       ME_PRED_SET_EQ                  = 21,
+       ME_PRED_SET_GT                  = 22,
+       ME_PRED_SET_GTE                 = 23,
+       ME_PRED_SET_NEQ                 = 24,
+       ME_PRED_SET_CLR                 = 25,
+       ME_PRED_SET_INV                 = 26,
+       ME_PRED_SET_POP                 = 27,
+       ME_PRED_SET_RESTORE             = 28,
+};
+
+enum {
+       /* R3XX */
+       PVS_MACRO_OP_2CLK_MADD          = 0,
+       PVS_MACRO_OP_2CLK_M2X_ADD       = 1,
+};
+
+enum {
+       PVS_SRC_REG_TEMPORARY           = 0,    /* Intermediate Storage */
+       PVS_SRC_REG_INPUT               = 1,    /* Input Vertex Storage */
+       PVS_SRC_REG_CONSTANT            = 2,    /* Constant State Storage */
+       PVS_SRC_REG_ALT_TEMPORARY       = 3,    /* Alternate Intermediate Storage */
+};
+
+enum {
+       PVS_DST_REG_TEMPORARY           = 0,    /* Intermediate Storage */
+       PVS_DST_REG_A0                  = 1,    /* Address Register Storage */
+       PVS_DST_REG_OUT                 = 2,    /* Output Memory. Used for all outputs */
+       PVS_DST_REG_OUT_REPL_X          = 3,    /* Output Memory & Replicate X to all channels */
+       PVS_DST_REG_ALT_TEMPORARY       = 4,    /* Alternate Intermediate Storage */
+       PVS_DST_REG_INPUT               = 5,    /* Output Memory & Replicate X to all channels */
+};
+
+enum {
+       PVS_SRC_SELECT_X                = 0,    /* Select X Component */
+       PVS_SRC_SELECT_Y                = 1,    /* Select Y Component */
+       PVS_SRC_SELECT_Z                = 2,    /* Select Z Component */
+       PVS_SRC_SELECT_W                = 3,    /* Select W Component */
+       PVS_SRC_SELECT_FORCE_0          = 4,    /* Force Component to 0.0 */
+       PVS_SRC_SELECT_FORCE_1          = 5,    /* Force Component to 1.0 */
+};
+
+/* PVS Opcode & Destination Operand Description */
+
+enum {
+       PVS_DST_OPCODE_MASK             = 0x3f,
+       PVS_DST_OPCODE_SHIFT            = 0,
+       PVS_DST_MATH_INST_MASK          = 0x1,
+       PVS_DST_MATH_INST_SHIFT         = 6,
+       PVS_DST_MACRO_INST_MASK         = 0x1,
+       PVS_DST_MACRO_INST_SHIFT        = 7,
+       PVS_DST_REG_TYPE_MASK           = 0xf,
+       PVS_DST_REG_TYPE_SHIFT          = 8,
+       PVS_DST_ADDR_MODE_1_MASK        = 0x1,
+       PVS_DST_ADDR_MODE_1_SHIFT       = 12,
+       PVS_DST_OFFSET_MASK             = 0x7f,
+       PVS_DST_OFFSET_SHIFT            = 13,
+       PVS_DST_WE_X_MASK               = 0x1,
+       PVS_DST_WE_X_SHIFT              = 20,
+       PVS_DST_WE_Y_MASK               = 0x1,
+       PVS_DST_WE_Y_SHIFT              = 21,
+       PVS_DST_WE_Z_MASK               = 0x1,
+       PVS_DST_WE_Z_SHIFT              = 22,
+       PVS_DST_WE_W_MASK               = 0x1,
+       PVS_DST_WE_W_SHIFT              = 23,
+       PVS_DST_VE_SAT_MASK             = 0x1,
+       PVS_DST_VE_SAT_SHIFT            = 24,
+       PVS_DST_ME_SAT_MASK             = 0x1,
+       PVS_DST_ME_SAT_SHIFT            = 25,
+       PVS_DST_PRED_ENABLE_MASK        = 0x1,
+       PVS_DST_PRED_ENABLE_SHIFT       = 26,
+       PVS_DST_PRED_SENSE_MASK         = 0x1,
+       PVS_DST_PRED_SENSE_SHIFT        = 27,
+       PVS_DST_DUAL_MATH_OP_MASK       = 0x3,
+       PVS_DST_DUAL_MATH_OP_SHIFT      = 27,
+       PVS_DST_ADDR_SEL_MASK           = 0x3,
+       PVS_DST_ADDR_SEL_SHIFT          = 29,
+       PVS_DST_ADDR_MODE_0_MASK        = 0x1,
+       PVS_DST_ADDR_MODE_0_SHIFT       = 31,
+};
+
+/* PVS Source Operand Description */
+
+enum {
+       PVS_SRC_REG_TYPE_MASK           = 0x3,
+       PVS_SRC_REG_TYPE_SHIFT          = 0,
+       SPARE_0_MASK                    = 0x1,
+       SPARE_0_SHIFT                   = 2,
+       PVS_SRC_ABS_XYZW_MASK           = 0x1,
+       PVS_SRC_ABS_XYZW_SHIFT          = 3,
+       PVS_SRC_ADDR_MODE_0_MASK        = 0x1,
+       PVS_SRC_ADDR_MODE_0_SHIFT       = 4,
+       PVS_SRC_OFFSET_MASK             = 0xff,
+       PVS_SRC_OFFSET_SHIFT            = 5,
+       PVS_SRC_SWIZZLE_X_MASK          = 0x7,
+       PVS_SRC_SWIZZLE_X_SHIFT         = 13,
+       PVS_SRC_SWIZZLE_Y_MASK          = 0x7,
+       PVS_SRC_SWIZZLE_Y_SHIFT         = 16,
+       PVS_SRC_SWIZZLE_Z_MASK          = 0x7,
+       PVS_SRC_SWIZZLE_Z_SHIFT         = 19,
+       PVS_SRC_SWIZZLE_W_MASK          = 0x7,
+       PVS_SRC_SWIZZLE_W_SHIFT         = 22,
+       PVS_SRC_MODIFIER_X_MASK         = 0x1,
+       PVS_SRC_MODIFIER_X_SHIFT        = 25,
+       PVS_SRC_MODIFIER_Y_MASK         = 0x1,
+       PVS_SRC_MODIFIER_Y_SHIFT        = 26,
+       PVS_SRC_MODIFIER_Z_MASK         = 0x1,
+       PVS_SRC_MODIFIER_Z_SHIFT        = 27,
+       PVS_SRC_MODIFIER_W_MASK         = 0x1,
+       PVS_SRC_MODIFIER_W_SHIFT        = 28,
+       PVS_SRC_ADDR_SEL_MASK           = 0x3,
+       PVS_SRC_ADDR_SEL_SHIFT          = 29,
+       PVS_SRC_ADDR_MODE_1_MASK        = 0x0,
+       PVS_SRC_ADDR_MODE_1_SHIFT       = 32,
+};
+
+/*\}*/
 
 /* BEGIN: Packet 3 commands */
 
@@ -1601,13 +2679,511 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define R300_PRIM_NUM_VERTICES_SHIFT            16
 #define R300_PRIM_NUM_VERTICES_MASK             0xffff
 
+
+
+/*
+ * The R500 unified shader (US) registers come in banks of 512 each, one
+ * for each instruction slot in the shader.  You can't touch them directly.
+ * R500_US_VECTOR_INDEX() sets the base instruction to modify; successive
+ * writes to R500_GA_US_VECTOR_DATA autoincrement the index after the
+ * instruction is fully specified.
+ */
+#define R500_US_ALU_ALPHA_INST_0                       0xa800
+#   define R500_ALPHA_OP_MAD                           0
+#   define R500_ALPHA_OP_DP                            1
+#   define R500_ALPHA_OP_MIN                           2
+#   define R500_ALPHA_OP_MAX                           3
+/* #define R500_ALPHA_OP_RESERVED                      4 */
+#   define R500_ALPHA_OP_CND                           5
+#   define R500_ALPHA_OP_CMP                           6
+#   define R500_ALPHA_OP_FRC                           7
+#   define R500_ALPHA_OP_EX2                           8
+#   define R500_ALPHA_OP_LN2                           9
+#   define R500_ALPHA_OP_RCP                           10
+#   define R500_ALPHA_OP_RSQ                           11
+#   define R500_ALPHA_OP_SIN                           12
+#   define R500_ALPHA_OP_COS                           13
+#   define R500_ALPHA_OP_MDH                           14
+#   define R500_ALPHA_OP_MDV                           15
+#   define R500_ALPHA_ADDRD(x)                         (x << 4)
+#   define R500_ALPHA_ADDRD_REL                                (1 << 11)
+#  define R500_ALPHA_SEL_A_SHIFT                       12
+#   define R500_ALPHA_SEL_A_SRC0                       (0 << 12)
+#   define R500_ALPHA_SEL_A_SRC1                       (1 << 12)
+#   define R500_ALPHA_SEL_A_SRC2                       (2 << 12)
+#   define R500_ALPHA_SEL_A_SRCP                       (3 << 12)
+#   define R500_ALPHA_SWIZ_A_R                         (0 << 14)
+#   define R500_ALPHA_SWIZ_A_G                         (1 << 14)
+#   define R500_ALPHA_SWIZ_A_B                         (2 << 14)
+#   define R500_ALPHA_SWIZ_A_A                         (3 << 14)
+#   define R500_ALPHA_SWIZ_A_0                         (4 << 14)
+#   define R500_ALPHA_SWIZ_A_HALF                      (5 << 14)
+#   define R500_ALPHA_SWIZ_A_1                         (6 << 14)
+/* #define R500_ALPHA_SWIZ_A_UNUSED                    (7 << 14) */
+#   define R500_ALPHA_MOD_A_NOP                                (0 << 17)
+#   define R500_ALPHA_MOD_A_NEG                                (1 << 17)
+#   define R500_ALPHA_MOD_A_ABS                                (2 << 17)
+#   define R500_ALPHA_MOD_A_NAB                                (3 << 17)
+#  define R500_ALPHA_SEL_B_SHIFT                       19
+#   define R500_ALPHA_SEL_B_SRC0                       (0 << 19)
+#   define R500_ALPHA_SEL_B_SRC1                       (1 << 19)
+#   define R500_ALPHA_SEL_B_SRC2                       (2 << 19)
+#   define R500_ALPHA_SEL_B_SRCP                       (3 << 19)
+#   define R500_ALPHA_SWIZ_B_R                         (0 << 21)
+#   define R500_ALPHA_SWIZ_B_G                         (1 << 21)
+#   define R500_ALPHA_SWIZ_B_B                         (2 << 21)
+#   define R500_ALPHA_SWIZ_B_A                         (3 << 21)
+#   define R500_ALPHA_SWIZ_B_0                         (4 << 21)
+#   define R500_ALPHA_SWIZ_B_HALF                      (5 << 21)
+#   define R500_ALPHA_SWIZ_B_1                         (6 << 21)
+/* #define R500_ALPHA_SWIZ_B_UNUSED                    (7 << 21) */
+#   define R500_ALPHA_MOD_B_NOP                                (0 << 24)
+#   define R500_ALPHA_MOD_B_NEG                                (1 << 24)
+#   define R500_ALPHA_MOD_B_ABS                                (2 << 24)
+#   define R500_ALPHA_MOD_B_NAB                                (3 << 24)
+#   define R500_ALPHA_OMOD_IDENTITY                    (0 << 26)
+#   define R500_ALPHA_OMOD_MUL_2                       (1 << 26)
+#   define R500_ALPHA_OMOD_MUL_4                       (2 << 26)
+#   define R500_ALPHA_OMOD_MUL_8                       (3 << 26)
+#   define R500_ALPHA_OMOD_DIV_2                       (4 << 26)
+#   define R500_ALPHA_OMOD_DIV_4                       (5 << 26)
+#   define R500_ALPHA_OMOD_DIV_8                       (6 << 26)
+#   define R500_ALPHA_OMOD_DISABLE                     (7 << 26)
+#   define R500_ALPHA_TARGET(x)                                (x << 29)
+#   define R500_ALPHA_W_OMASK                          (1 << 31)
+#define R500_US_ALU_ALPHA_ADDR_0                       0x9800
+#   define R500_ALPHA_ADDR0(x)                         (x << 0)
+#   define R500_ALPHA_ADDR0_CONST                      (1 << 8)
+#   define R500_ALPHA_ADDR0_REL                                (1 << 9)
+#   define R500_ALPHA_ADDR1(x)                         (x << 10)
+#   define R500_ALPHA_ADDR1_CONST                      (1 << 18)
+#   define R500_ALPHA_ADDR1_REL                                (1 << 19)
+#   define R500_ALPHA_ADDR2(x)                         (x << 20)
+#   define R500_ALPHA_ADDR2_CONST                      (1 << 28)
+#   define R500_ALPHA_ADDR2_REL                                (1 << 29)
+#   define R500_ALPHA_SRCP_OP_1_MINUS_2A0              (0 << 30)
+#   define R500_ALPHA_SRCP_OP_A1_MINUS_A0              (1 << 30)
+#   define R500_ALPHA_SRCP_OP_A1_PLUS_A0               (2 << 30)
+#   define R500_ALPHA_SRCP_OP_1_MINUS_A0               (3 << 30)
+#define R500_US_ALU_RGBA_INST_0                                0xb000
+#   define R500_ALU_RGBA_OP_MAD                                (0 << 0)
+#   define R500_ALU_RGBA_OP_DP3                                (1 << 0)
+#   define R500_ALU_RGBA_OP_DP4                                (2 << 0)
+#   define R500_ALU_RGBA_OP_D2A                                (3 << 0)
+#   define R500_ALU_RGBA_OP_MIN                                (4 << 0)
+#   define R500_ALU_RGBA_OP_MAX                                (5 << 0)
+/* #define R500_ALU_RGBA_OP_RESERVED                   (6 << 0) */
+#   define R500_ALU_RGBA_OP_CND                                (7 << 0)
+#   define R500_ALU_RGBA_OP_CMP                                (8 << 0)
+#   define R500_ALU_RGBA_OP_FRC                                (9 << 0)
+#   define R500_ALU_RGBA_OP_SOP                                (10 << 0)
+#   define R500_ALU_RGBA_OP_MDH                                (11 << 0)
+#   define R500_ALU_RGBA_OP_MDV                                (12 << 0)
+#   define R500_ALU_RGBA_ADDRD(x)                      (x << 4)
+#   define R500_ALU_RGBA_ADDRD_REL                     (1 << 11)
+#  define R500_ALU_RGBA_SEL_C_SHIFT                    12
+#   define R500_ALU_RGBA_SEL_C_SRC0                    (0 << 12)
+#   define R500_ALU_RGBA_SEL_C_SRC1                    (1 << 12)
+#   define R500_ALU_RGBA_SEL_C_SRC2                    (2 << 12)
+#   define R500_ALU_RGBA_SEL_C_SRCP                    (3 << 12)
+#   define R500_ALU_RGBA_R_SWIZ_R                      (0 << 14)
+#   define R500_ALU_RGBA_R_SWIZ_G                      (1 << 14)
+#   define R500_ALU_RGBA_R_SWIZ_B                      (2 << 14)
+#   define R500_ALU_RGBA_R_SWIZ_A                      (3 << 14)
+#   define R500_ALU_RGBA_R_SWIZ_0                      (4 << 14)
+#   define R500_ALU_RGBA_R_SWIZ_HALF                   (5 << 14)
+#   define R500_ALU_RGBA_R_SWIZ_1                      (6 << 14)
+/* #define R500_ALU_RGBA_R_SWIZ_UNUSED                 (7 << 14) */
+#   define R500_ALU_RGBA_G_SWIZ_R                      (0 << 17)
+#   define R500_ALU_RGBA_G_SWIZ_G                      (1 << 17)
+#   define R500_ALU_RGBA_G_SWIZ_B                      (2 << 17)
+#   define R500_ALU_RGBA_G_SWIZ_A                      (3 << 17)
+#   define R500_ALU_RGBA_G_SWIZ_0                      (4 << 17)
+#   define R500_ALU_RGBA_G_SWIZ_HALF                   (5 << 17)
+#   define R500_ALU_RGBA_G_SWIZ_1                      (6 << 17)
+/* #define R500_ALU_RGBA_G_SWIZ_UNUSED                 (7 << 17) */
+#   define R500_ALU_RGBA_B_SWIZ_R                      (0 << 20)
+#   define R500_ALU_RGBA_B_SWIZ_G                      (1 << 20)
+#   define R500_ALU_RGBA_B_SWIZ_B                      (2 << 20)
+#   define R500_ALU_RGBA_B_SWIZ_A                      (3 << 20)
+#   define R500_ALU_RGBA_B_SWIZ_0                      (4 << 20)
+#   define R500_ALU_RGBA_B_SWIZ_HALF                   (5 << 20)
+#   define R500_ALU_RGBA_B_SWIZ_1                      (6 << 20)
+/* #define R500_ALU_RGBA_B_SWIZ_UNUSED                 (7 << 20) */
+#   define R500_ALU_RGBA_MOD_C_NOP                     (0 << 23)
+#   define R500_ALU_RGBA_MOD_C_NEG                     (1 << 23)
+#   define R500_ALU_RGBA_MOD_C_ABS                     (2 << 23)
+#   define R500_ALU_RGBA_MOD_C_NAB                     (3 << 23)
+#  define R500_ALU_RGBA_ALPHA_SEL_C_SHIFT              25
+#   define R500_ALU_RGBA_ALPHA_SEL_C_SRC0              (0 << 25)
+#   define R500_ALU_RGBA_ALPHA_SEL_C_SRC1              (1 << 25)
+#   define R500_ALU_RGBA_ALPHA_SEL_C_SRC2              (2 << 25)
+#   define R500_ALU_RGBA_ALPHA_SEL_C_SRCP              (3 << 25)
+#   define R500_ALU_RGBA_A_SWIZ_R                      (0 << 27)
+#   define R500_ALU_RGBA_A_SWIZ_G                      (1 << 27)
+#   define R500_ALU_RGBA_A_SWIZ_B                      (2 << 27)
+#   define R500_ALU_RGBA_A_SWIZ_A                      (3 << 27)
+#   define R500_ALU_RGBA_A_SWIZ_0                      (4 << 27)
+#   define R500_ALU_RGBA_A_SWIZ_HALF                   (5 << 27)
+#   define R500_ALU_RGBA_A_SWIZ_1                      (6 << 27)
+/* #define R500_ALU_RGBA_A_SWIZ_UNUSED                 (7 << 27) */
+#   define R500_ALU_RGBA_ALPHA_MOD_C_NOP               (0 << 30)
+#   define R500_ALU_RGBA_ALPHA_MOD_C_NEG               (1 << 30)
+#   define R500_ALU_RGBA_ALPHA_MOD_C_ABS               (2 << 30)
+#   define R500_ALU_RGBA_ALPHA_MOD_C_NAB               (3 << 30)
+#define R500_US_ALU_RGB_INST_0                         0xa000
+#  define R500_ALU_RGB_SEL_A_SHIFT                     0
+#   define R500_ALU_RGB_SEL_A_SRC0                     (0 << 0)
+#   define R500_ALU_RGB_SEL_A_SRC1                     (1 << 0)
+#   define R500_ALU_RGB_SEL_A_SRC2                     (2 << 0)
+#   define R500_ALU_RGB_SEL_A_SRCP                     (3 << 0)
+#   define R500_ALU_RGB_R_SWIZ_A_R                     (0 << 2)
+#   define R500_ALU_RGB_R_SWIZ_A_G                     (1 << 2)
+#   define R500_ALU_RGB_R_SWIZ_A_B                     (2 << 2)
+#   define R500_ALU_RGB_R_SWIZ_A_A                     (3 << 2)
+#   define R500_ALU_RGB_R_SWIZ_A_0                     (4 << 2)
+#   define R500_ALU_RGB_R_SWIZ_A_HALF                  (5 << 2)
+#   define R500_ALU_RGB_R_SWIZ_A_1                     (6 << 2)
+/* #define R500_ALU_RGB_R_SWIZ_A_UNUSED                        (7 << 2) */
+#   define R500_ALU_RGB_G_SWIZ_A_R                     (0 << 5)
+#   define R500_ALU_RGB_G_SWIZ_A_G                     (1 << 5)
+#   define R500_ALU_RGB_G_SWIZ_A_B                     (2 << 5)
+#   define R500_ALU_RGB_G_SWIZ_A_A                     (3 << 5)
+#   define R500_ALU_RGB_G_SWIZ_A_0                     (4 << 5)
+#   define R500_ALU_RGB_G_SWIZ_A_HALF                  (5 << 5)
+#   define R500_ALU_RGB_G_SWIZ_A_1                     (6 << 5)
+/* #define R500_ALU_RGB_G_SWIZ_A_UNUSED                        (7 << 5) */
+#   define R500_ALU_RGB_B_SWIZ_A_R                     (0 << 8)
+#   define R500_ALU_RGB_B_SWIZ_A_G                     (1 << 8)
+#   define R500_ALU_RGB_B_SWIZ_A_B                     (2 << 8)
+#   define R500_ALU_RGB_B_SWIZ_A_A                     (3 << 8)
+#   define R500_ALU_RGB_B_SWIZ_A_0                     (4 << 8)
+#   define R500_ALU_RGB_B_SWIZ_A_HALF                  (5 << 8)
+#   define R500_ALU_RGB_B_SWIZ_A_1                     (6 << 8)
+/* #define R500_ALU_RGB_B_SWIZ_A_UNUSED                        (7 << 8) */
+#   define R500_ALU_RGB_MOD_A_NOP                      (0 << 11)
+#   define R500_ALU_RGB_MOD_A_NEG                      (1 << 11)
+#   define R500_ALU_RGB_MOD_A_ABS                      (2 << 11)
+#   define R500_ALU_RGB_MOD_A_NAB                      (3 << 11)
+#  define R500_ALU_RGB_SEL_B_SHIFT                     13
+#   define R500_ALU_RGB_SEL_B_SRC0                     (0 << 13)
+#   define R500_ALU_RGB_SEL_B_SRC1                     (1 << 13)
+#   define R500_ALU_RGB_SEL_B_SRC2                     (2 << 13)
+#   define R500_ALU_RGB_SEL_B_SRCP                     (3 << 13)
+#   define R500_ALU_RGB_R_SWIZ_B_R                     (0 << 15)
+#   define R500_ALU_RGB_R_SWIZ_B_G                     (1 << 15)
+#   define R500_ALU_RGB_R_SWIZ_B_B                     (2 << 15)
+#   define R500_ALU_RGB_R_SWIZ_B_A                     (3 << 15)
+#   define R500_ALU_RGB_R_SWIZ_B_0                     (4 << 15)
+#   define R500_ALU_RGB_R_SWIZ_B_HALF                  (5 << 15)
+#   define R500_ALU_RGB_R_SWIZ_B_1                     (6 << 15)
+/* #define R500_ALU_RGB_R_SWIZ_B_UNUSED                        (7 << 15) */
+#   define R500_ALU_RGB_G_SWIZ_B_R                     (0 << 18)
+#   define R500_ALU_RGB_G_SWIZ_B_G                     (1 << 18)
+#   define R500_ALU_RGB_G_SWIZ_B_B                     (2 << 18)
+#   define R500_ALU_RGB_G_SWIZ_B_A                     (3 << 18)
+#   define R500_ALU_RGB_G_SWIZ_B_0                     (4 << 18)
+#   define R500_ALU_RGB_G_SWIZ_B_HALF                  (5 << 18)
+#   define R500_ALU_RGB_G_SWIZ_B_1                     (6 << 18)
+/* #define R500_ALU_RGB_G_SWIZ_B_UNUSED                        (7 << 18) */
+#   define R500_ALU_RGB_B_SWIZ_B_R                     (0 << 21)
+#   define R500_ALU_RGB_B_SWIZ_B_G                     (1 << 21)
+#   define R500_ALU_RGB_B_SWIZ_B_B                     (2 << 21)
+#   define R500_ALU_RGB_B_SWIZ_B_A                     (3 << 21)
+#   define R500_ALU_RGB_B_SWIZ_B_0                     (4 << 21)
+#   define R500_ALU_RGB_B_SWIZ_B_HALF                  (5 << 21)
+#   define R500_ALU_RGB_B_SWIZ_B_1                     (6 << 21)
+/* #define R500_ALU_RGB_B_SWIZ_B_UNUSED                        (7 << 21) */
+#   define R500_ALU_RGB_MOD_B_NOP                      (0 << 24)
+#   define R500_ALU_RGB_MOD_B_NEG                      (1 << 24)
+#   define R500_ALU_RGB_MOD_B_ABS                      (2 << 24)
+#   define R500_ALU_RGB_MOD_B_NAB                      (3 << 24)
+#   define R500_ALU_RGB_OMOD_IDENTITY                  (0 << 26)
+#   define R500_ALU_RGB_OMOD_MUL_2                     (1 << 26)
+#   define R500_ALU_RGB_OMOD_MUL_4                     (2 << 26)
+#   define R500_ALU_RGB_OMOD_MUL_8                     (3 << 26)
+#   define R500_ALU_RGB_OMOD_DIV_2                     (4 << 26)
+#   define R500_ALU_RGB_OMOD_DIV_4                     (5 << 26)
+#   define R500_ALU_RGB_OMOD_DIV_8                     (6 << 26)
+#   define R500_ALU_RGB_OMOD_DISABLE                   (7 << 26)
+#   define R500_ALU_RGB_TARGET(x)                      (x << 29)
+#   define R500_ALU_RGB_WMASK                          (1 << 31)
+#define R500_US_ALU_RGB_ADDR_0                         0x9000
+#   define R500_RGB_ADDR0(x)                           (x << 0)
+#   define R500_RGB_ADDR0_CONST                                (1 << 8)
+#   define R500_RGB_ADDR0_REL                          (1 << 9)
+#   define R500_RGB_ADDR1(x)                           (x << 10)
+#   define R500_RGB_ADDR1_CONST                                (1 << 18)
+#   define R500_RGB_ADDR1_REL                          (1 << 19)
+#   define R500_RGB_ADDR2(x)                           (x << 20)
+#   define R500_RGB_ADDR2_CONST                                (1 << 28)
+#   define R500_RGB_ADDR2_REL                          (1 << 29)
+#   define R500_RGB_SRCP_OP_1_MINUS_2RGB0              (0 << 30)
+#   define R500_RGB_SRCP_OP_RGB1_MINUS_RGB0            (1 << 30)
+#   define R500_RGB_SRCP_OP_RGB1_PLUS_RGB0             (2 << 30)
+#   define R500_RGB_SRCP_OP_1_MINUS_RGB0               (3 << 30)
+#define R500_US_CMN_INST_0                             0xb800
+#  define R500_INST_TYPE_MASK                          (3 << 0)
+#   define R500_INST_TYPE_ALU                          (0 << 0)
+#   define R500_INST_TYPE_OUT                          (1 << 0)
+#   define R500_INST_TYPE_FC                           (2 << 0)
+#   define R500_INST_TYPE_TEX                          (3 << 0)
+#   define R500_INST_TEX_SEM_WAIT                      (1 << 2)
+#   define R500_INST_RGB_PRED_SEL_NONE                 (0 << 3)
+#   define R500_INST_RGB_PRED_SEL_RGBA                 (1 << 3)
+#   define R500_INST_RGB_PRED_SEL_RRRR                 (2 << 3)
+#   define R500_INST_RGB_PRED_SEL_GGGG                 (3 << 3)
+#   define R500_INST_RGB_PRED_SEL_BBBB                 (4 << 3)
+#   define R500_INST_RGB_PRED_SEL_AAAA                 (5 << 3)
+#   define R500_INST_RGB_PRED_INV                      (1 << 6)
+#   define R500_INST_WRITE_INACTIVE                    (1 << 7)
+#   define R500_INST_LAST                              (1 << 8)
+#   define R500_INST_NOP                               (1 << 9)
+#   define R500_INST_ALU_WAIT                          (1 << 10)
+#   define R500_INST_RGB_WMASK_R                       (1 << 11)
+#   define R500_INST_RGB_WMASK_G                       (1 << 12)
+#   define R500_INST_RGB_WMASK_B                       (1 << 13)
+#   define R500_INST_ALPHA_WMASK                       (1 << 14)
+#   define R500_INST_RGB_OMASK_R                       (1 << 15)
+#   define R500_INST_RGB_OMASK_G                       (1 << 16)
+#   define R500_INST_RGB_OMASK_B                       (1 << 17)
+#   define R500_INST_ALPHA_OMASK                       (1 << 18)
+#   define R500_INST_RGB_CLAMP                         (1 << 19)
+#   define R500_INST_ALPHA_CLAMP                       (1 << 20)
+#   define R500_INST_ALU_RESULT_SEL                    (1 << 21)
+#   define R500_INST_ALPHA_PRED_INV                    (1 << 22)
+#   define R500_INST_ALU_RESULT_OP_EQ                  (0 << 23)
+#   define R500_INST_ALU_RESULT_OP_LT                  (1 << 23)
+#   define R500_INST_ALU_RESULT_OP_GE                  (2 << 23)
+#   define R500_INST_ALU_RESULT_OP_NE                  (3 << 23)
+#   define R500_INST_ALPHA_PRED_SEL_NONE               (0 << 25)
+#   define R500_INST_ALPHA_PRED_SEL_RGBA               (1 << 25)
+#   define R500_INST_ALPHA_PRED_SEL_RRRR               (2 << 25)
+#   define R500_INST_ALPHA_PRED_SEL_GGGG               (3 << 25)
+#   define R500_INST_ALPHA_PRED_SEL_BBBB               (4 << 25)
+#   define R500_INST_ALPHA_PRED_SEL_AAAA               (5 << 25)
+/* XXX next four are kind of guessed */
+#   define R500_INST_STAT_WE_R                         (1 << 28)
+#   define R500_INST_STAT_WE_G                         (1 << 29)
+#   define R500_INST_STAT_WE_B                         (1 << 30)
+#   define R500_INST_STAT_WE_A                         (1 << 31)
+
+/* note that these are 8 bit lengths, despite the offsets, at least for R500 */
+#define R500_US_CODE_ADDR                              0x4630
+#   define R500_US_CODE_START_ADDR(x)                  (x << 0)
+#   define R500_US_CODE_END_ADDR(x)                    (x << 16)
+#define R500_US_CODE_OFFSET                            0x4638
+#   define R500_US_CODE_OFFSET_ADDR(x)                 (x << 0)
+#define R500_US_CODE_RANGE                             0x4634
+#   define R500_US_CODE_RANGE_ADDR(x)                  (x << 0)
+#   define R500_US_CODE_RANGE_SIZE(x)                  (x << 16)
+#define R500_US_CONFIG                                 0x4600
+#   define R500_ZERO_TIMES_ANYTHING_EQUALS_ZERO                (1 << 1)
+#define R500_US_FC_ADDR_0                              0xa000
+#   define R500_FC_BOOL_ADDR(x)                                (x << 0)
+#   define R500_FC_INT_ADDR(x)                         (x << 8)
+#   define R500_FC_JUMP_ADDR(x)                                (x << 16)
+#   define R500_FC_JUMP_GLOBAL                         (1 << 31)
+#define R500_US_FC_BOOL_CONST                          0x4620
+#   define R500_FC_KBOOL(x)                            (x)
+#define R500_US_FC_CTRL                                        0x4624
+#   define R500_FC_TEST_EN                             (1 << 30)
+#   define R500_FC_FULL_FC_EN                          (1 << 31)
+#define R500_US_FC_INST_0                              0x9800
+#   define R500_FC_OP_JUMP                             (0 << 0)
+#   define R500_FC_OP_LOOP                             (1 << 0)
+#   define R500_FC_OP_ENDLOOP                          (2 << 0)
+#   define R500_FC_OP_REP                              (3 << 0)
+#   define R500_FC_OP_ENDREP                           (4 << 0)
+#   define R500_FC_OP_BREAKLOOP                                (5 << 0)
+#   define R500_FC_OP_BREAKREP                         (6 << 0)
+#   define R500_FC_OP_CONTINUE                         (7 << 0)
+#   define R500_FC_B_ELSE                              (1 << 4)
+#   define R500_FC_JUMP_ANY                            (1 << 5)
+#   define R500_FC_A_OP_NONE                           (0 << 6)
+#   define R500_FC_A_OP_POP                            (1 << 6)
+#   define R500_FC_A_OP_PUSH                           (2 << 6)
+#   define R500_FC_JUMP_FUNC(x)                                (x << 8)
+#   define R500_FC_B_POP_CNT(x)                                (x << 16)
+#   define R500_FC_B_OP0_NONE                          (0 << 24)
+#   define R500_FC_B_OP0_DECR                          (1 << 24)
+#   define R500_FC_B_OP0_INCR                          (2 << 24)
+#   define R500_FC_B_OP1_DECR                          (0 << 26)
+#   define R500_FC_B_OP1_NONE                          (1 << 26)
+#   define R500_FC_B_OP1_INCR                          (2 << 26)
+#   define R500_FC_IGNORE_UNCOVERED                    (1 << 28)
+#define R500_US_FC_INT_CONST_0                         0x4c00
+#   define R500_FC_INT_CONST_KR(x)                     (x << 0)
+#   define R500_FC_INT_CONST_KG(x)                     (x << 8)
+#   define R500_FC_INT_CONST_KB(x)                     (x << 16)
+/* _0 through _15 */
+#define R500_US_FORMAT0_0                              0x4640
+#   define R500_FORMAT_TXWIDTH(x)                      (x << 0)
+#   define R500_FORMAT_TXHEIGHT(x)                     (x << 11)
+#   define R500_FORMAT_TXDEPTH(x)                      (x << 22)
+/* _0 through _3 */
+#define R500_US_OUT_FMT_0                              0x46a4
+#   define R500_OUT_FMT_C4_8                           (0 << 0)
+#   define R500_OUT_FMT_C4_10                          (1 << 0)
+#   define R500_OUT_FMT_C4_10_GAMMA                    (2 << 0)
+#   define R500_OUT_FMT_C_16                           (3 << 0)
+#   define R500_OUT_FMT_C2_16                          (4 << 0)
+#   define R500_OUT_FMT_C4_16                          (5 << 0)
+#   define R500_OUT_FMT_C_16_MPEG                      (6 << 0)
+#   define R500_OUT_FMT_C2_16_MPEG                     (7 << 0)
+#   define R500_OUT_FMT_C2_4                           (8 << 0)
+#   define R500_OUT_FMT_C_3_3_2                                (9 << 0)
+#   define R500_OUT_FMT_C_6_5_6                                (10 << 0)
+#   define R500_OUT_FMT_C_11_11_10                     (11 << 0)
+#   define R500_OUT_FMT_C_10_11_11                     (12 << 0)
+#   define R500_OUT_FMT_C_2_10_10_10                   (13 << 0)
+/* #define R500_OUT_FMT_RESERVED                       (14 << 0) */
+#   define R500_OUT_FMT_UNUSED                         (15 << 0)
+#   define R500_OUT_FMT_C_16_FP                                (16 << 0)
+#   define R500_OUT_FMT_C2_16_FP                       (17 << 0)
+#   define R500_OUT_FMT_C4_16_FP                       (18 << 0)
+#   define R500_OUT_FMT_C_32_FP                                (19 << 0)
+#   define R500_OUT_FMT_C2_32_FP                       (20 << 0)
+#   define R500_OUT_FMT_C4_32_FP                       (21 << 0)
+#   define R500_C0_SEL_A                               (0 << 8)
+#   define R500_C0_SEL_R                               (1 << 8)
+#   define R500_C0_SEL_G                               (2 << 8)
+#   define R500_C0_SEL_B                               (3 << 8)
+#   define R500_C1_SEL_A                               (0 << 10)
+#   define R500_C1_SEL_R                               (1 << 10)
+#   define R500_C1_SEL_G                               (2 << 10)
+#   define R500_C1_SEL_B                               (3 << 10)
+#   define R500_C2_SEL_A                               (0 << 12)
+#   define R500_C2_SEL_R                               (1 << 12)
+#   define R500_C2_SEL_G                               (2 << 12)
+#   define R500_C2_SEL_B                               (3 << 12)
+#   define R500_C3_SEL_A                               (0 << 14)
+#   define R500_C3_SEL_R                               (1 << 14)
+#   define R500_C3_SEL_G                               (2 << 14)
+#   define R500_C3_SEL_B                               (3 << 14)
+#   define R500_OUT_SIGN(x)                            (x << 16)
+#   define R500_ROUND_ADJ                              (1 << 20)
+#define R500_US_PIXSIZE                                        0x4604
+#   define R500_PIX_SIZE(x)                            (x)
+#define R500_US_TEX_ADDR_0                             0x9800
+#   define R500_TEX_SRC_ADDR(x)                                (x << 0)
+#   define R500_TEX_SRC_ADDR_REL                       (1 << 7)
+#   define R500_TEX_SRC_S_SWIZ_R                       (0 << 8)
+#   define R500_TEX_SRC_S_SWIZ_G                       (1 << 8)
+#   define R500_TEX_SRC_S_SWIZ_B                       (2 << 8)
+#   define R500_TEX_SRC_S_SWIZ_A                       (3 << 8)
+#   define R500_TEX_SRC_T_SWIZ_R                       (0 << 10)
+#   define R500_TEX_SRC_T_SWIZ_G                       (1 << 10)
+#   define R500_TEX_SRC_T_SWIZ_B                       (2 << 10)
+#   define R500_TEX_SRC_T_SWIZ_A                       (3 << 10)
+#   define R500_TEX_SRC_R_SWIZ_R                       (0 << 12)
+#   define R500_TEX_SRC_R_SWIZ_G                       (1 << 12)
+#   define R500_TEX_SRC_R_SWIZ_B                       (2 << 12)
+#   define R500_TEX_SRC_R_SWIZ_A                       (3 << 12)
+#   define R500_TEX_SRC_Q_SWIZ_R                       (0 << 14)
+#   define R500_TEX_SRC_Q_SWIZ_G                       (1 << 14)
+#   define R500_TEX_SRC_Q_SWIZ_B                       (2 << 14)
+#   define R500_TEX_SRC_Q_SWIZ_A                       (3 << 14)
+#   define R500_TEX_DST_ADDR(x)                                (x << 16)
+#   define R500_TEX_DST_ADDR_REL                       (1 << 23)
+#   define R500_TEX_DST_R_SWIZ_R                       (0 << 24)
+#   define R500_TEX_DST_R_SWIZ_G                       (1 << 24)
+#   define R500_TEX_DST_R_SWIZ_B                       (2 << 24)
+#   define R500_TEX_DST_R_SWIZ_A                       (3 << 24)
+#   define R500_TEX_DST_G_SWIZ_R                       (0 << 26)
+#   define R500_TEX_DST_G_SWIZ_G                       (1 << 26)
+#   define R500_TEX_DST_G_SWIZ_B                       (2 << 26)
+#   define R500_TEX_DST_G_SWIZ_A                       (3 << 26)
+#   define R500_TEX_DST_B_SWIZ_R                       (0 << 28)
+#   define R500_TEX_DST_B_SWIZ_G                       (1 << 28)
+#   define R500_TEX_DST_B_SWIZ_B                       (2 << 28)
+#   define R500_TEX_DST_B_SWIZ_A                       (3 << 28)
+#   define R500_TEX_DST_A_SWIZ_R                       (0 << 30)
+#   define R500_TEX_DST_A_SWIZ_G                       (1 << 30)
+#   define R500_TEX_DST_A_SWIZ_B                       (2 << 30)
+#   define R500_TEX_DST_A_SWIZ_A                       (3 << 30)
+#define R500_US_TEX_ADDR_DXDY_0                                0xa000
+#   define R500_DX_ADDR(x)                             (x << 0)
+#   define R500_DX_ADDR_REL                            (1 << 7)
+#   define R500_DX_S_SWIZ_R                            (0 << 8)
+#   define R500_DX_S_SWIZ_G                            (1 << 8)
+#   define R500_DX_S_SWIZ_B                            (2 << 8)
+#   define R500_DX_S_SWIZ_A                            (3 << 8)
+#   define R500_DX_T_SWIZ_R                            (0 << 10)
+#   define R500_DX_T_SWIZ_G                            (1 << 10)
+#   define R500_DX_T_SWIZ_B                            (2 << 10)
+#   define R500_DX_T_SWIZ_A                            (3 << 10)
+#   define R500_DX_R_SWIZ_R                            (0 << 12)
+#   define R500_DX_R_SWIZ_G                            (1 << 12)
+#   define R500_DX_R_SWIZ_B                            (2 << 12)
+#   define R500_DX_R_SWIZ_A                            (3 << 12)
+#   define R500_DX_Q_SWIZ_R                            (0 << 14)
+#   define R500_DX_Q_SWIZ_G                            (1 << 14)
+#   define R500_DX_Q_SWIZ_B                            (2 << 14)
+#   define R500_DX_Q_SWIZ_A                            (3 << 14)
+#   define R500_DY_ADDR(x)                             (x << 16)
+#   define R500_DY_ADDR_REL                            (1 << 17)
+#   define R500_DY_S_SWIZ_R                            (0 << 24)
+#   define R500_DY_S_SWIZ_G                            (1 << 24)
+#   define R500_DY_S_SWIZ_B                            (2 << 24)
+#   define R500_DY_S_SWIZ_A                            (3 << 24)
+#   define R500_DY_T_SWIZ_R                            (0 << 26)
+#   define R500_DY_T_SWIZ_G                            (1 << 26)
+#   define R500_DY_T_SWIZ_B                            (2 << 26)
+#   define R500_DY_T_SWIZ_A                            (3 << 26)
+#   define R500_DY_R_SWIZ_R                            (0 << 28)
+#   define R500_DY_R_SWIZ_G                            (1 << 28)
+#   define R500_DY_R_SWIZ_B                            (2 << 28)
+#   define R500_DY_R_SWIZ_A                            (3 << 28)
+#   define R500_DY_Q_SWIZ_R                            (0 << 30)
+#   define R500_DY_Q_SWIZ_G                            (1 << 30)
+#   define R500_DY_Q_SWIZ_B                            (2 << 30)
+#   define R500_DY_Q_SWIZ_A                            (3 << 30)
+#define R500_US_TEX_INST_0                             0x9000
+#   define R500_TEX_ID(x)                              (x << 16)
+#   define R500_TEX_INST_NOP                           (0 << 22)
+#   define R500_TEX_INST_LD                            (1 << 22)
+#   define R500_TEX_INST_TEXKILL                       (2 << 22)
+#   define R500_TEX_INST_PROJ                          (3 << 22)
+#   define R500_TEX_INST_LODBIAS                       (4 << 22)
+#   define R500_TEX_INST_LOD                           (5 << 22)
+#   define R500_TEX_INST_DXDY                          (6 << 22)
+#   define R500_TEX_SEM_ACQUIRE                                (1 << 25)
+#   define R500_TEX_IGNORE_UNCOVERED                   (1 << 26)
+#   define R500_TEX_UNSCALED                           (1 << 27)
+#define R300_US_W_FMT                                  0x46b4
+#   define R300_W_FMT_W0                               (0 << 0)
+#   define R300_W_FMT_W24                              (1 << 0)
+#   define R300_W_FMT_W24FP                            (2 << 0)
+#   define R300_W_SRC_US                               (0 << 2)
+#   define R300_W_SRC_RAS                              (1 << 2)
+
+
 /* 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.
+ * 0. VAP_VTX_FMT: The first parameter is not written to hardware
+ * 1. VAP_VF_CTL: The second parameter is a standard primitive emission dword.
  */
 #define R300_PACKET3_3D_DRAW_VBUF           0x00002800
 
+/* Draw a primitive from immediate vertices in this packet
+ * Up to 16382 dwords:
+ * 0. VAP_VTX_FMT: The first parameter is not written to hardware
+ * 1. VAP_VF_CTL: The second parameter is a standard primitive emission dword.
+ * 2 to end: Up to 16380 dwords of vertex data.
+ */
+#define R300_PACKET3_3D_DRAW_IMMD           0x00002900
+
+/* Draw a primitive from vertex data in arrays loaded via 3D_LOAD_VBPNTR and
+ * immediate vertices in this packet
+ * Up to 16382 dwords:
+ * 0. VAP_VTX_FMT: The first parameter is not written to hardware
+ * 1. VAP_VF_CTL: The second parameter is a standard primitive emission dword.
+ * 2 to end: Up to 16380 dwords of vertex data.
+ */
+#define R300_PACKET3_3D_DRAW_INDX           0x00002A00
+
+
 /* 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
@@ -1628,9 +3204,29 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #    define R300_EB_UNK1_SHIFT                      24
 #    define R300_EB_UNK1                    (0x80<<24)
 #    define R300_EB_UNK2                        0x0810
+
+/* Same as R300_PACKET3_3D_DRAW_VBUF but without VAP_VTX_FMT */
 #define R300_PACKET3_3D_DRAW_VBUF_2         0x00003400
+/* Same as R300_PACKET3_3D_DRAW_IMMD but without VAP_VTX_FMT */
+#define R300_PACKET3_3D_DRAW_IMMD_2         0x00003500
+/* Same as R300_PACKET3_3D_DRAW_INDX but without VAP_VTX_FMT */
 #define R300_PACKET3_3D_DRAW_INDX_2         0x00003600
 
+/* Clears a portion of hierachical Z RAM
+ * 3 dword parameters
+ * 0. START
+ * 1. COUNT: 13:0 (max is 0x3FFF)
+ * 2. CLEAR_VALUE: Value to write into HIZ RAM.
+ */
+#define R300_PACKET3_3D_CLEAR_HIZ           0x00003700
+
+/* Draws a set of primitives using vertex buffers pointed by the state data.
+ * At least 2 Parameters:
+ * 0. VAP_VF_CNTL: The first parameter is a standard primitive emission dword.
+ * 2 to end: Data or indices (see other 3D_DRAW_* packets for details)
+ */
+#define R300_PACKET3_3D_DRAW_128            0x00003900
+
 /* END: Packet 3 commands */
 
 
@@ -1652,3 +3248,5 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #endif /* _R300_REG_H */
 
 /* *INDENT-ON* */
+
+/* vim: set foldenable foldmarker=\\{,\\} foldmethod=marker : */
index c809679e6cd41cf54ae192dd23d39681104ed8f9..0a199e6faad1f5cc739521b16bf7a0f456c85a31 100644 (file)
@@ -74,6 +74,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r300_reg.h"
 #include "r300_tex.h"
 #include "r300_emit.h"
+#include "r300_fragprog.h"
 extern int future_hw_tcl_on;
 
 /**
@@ -268,13 +269,24 @@ static void r300RunRenderPrimitive(r300ContextPtr rmesa, GLcontext * ctx,
                return;
 
        if (vb->Elts) {
-               r300EmitAOS(rmesa, rmesa->state.aos_count, start);
                if (num_verts > 65535) {
                        /* not implemented yet */
                        WARN_ONCE("Too many elts\n");
                        return;
                }
+               /* Note: The following is incorrect, but it's the best I can do
+                * without a major refactoring of how DMA memory is handled.
+                * The problem: Ensuring that both vertex arrays *and* index
+                * arrays are at the right position, and then ensuring that
+                * the LOAD_VBPNTR, DRAW_INDX and INDX_BUFFER packets are emitted
+                * at once.
+                *
+                * So why is the following incorrect? Well, it seems like
+                * allocating the index array might actually evict the vertex
+                * arrays. *sigh*
+                */
                r300EmitElts(ctx, vb->Elts, num_verts);
+               r300EmitAOS(rmesa, rmesa->state.aos_count, start);
                r300FireEB(rmesa, rmesa->state.elt_dma.aos_offset, num_verts, type);
        } else {
                r300EmitAOS(rmesa, rmesa->state.aos_count, start);
@@ -334,13 +346,26 @@ static GLboolean r300RunRender(GLcontext * ctx,
 static int r300Fallback(GLcontext * ctx)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
-       struct r300_fragment_program *fp = (struct r300_fragment_program *)
+       /* Do we need to use new-style shaders?
+        * Also is there a better way to do this? */
+       if (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) {
+               struct r500_fragment_program *fp = (struct r500_fragment_program *)
            (char *)ctx->FragmentProgram._Current;
-
-       if (fp) {
-               if (!fp->translated)
-                       r300TranslateFragmentShader(r300, fp);
-               FALLBACK_IF(!fp->translated);
+               if (fp) {
+                       if (!fp->translated) {
+                               r500TranslateFragmentShader(r300, fp);
+                               FALLBACK_IF(!fp->translated);
+                       }
+               }
+       } else {
+               struct r300_fragment_program *fp = (struct r300_fragment_program *)
+           (char *)ctx->FragmentProgram._Current;
+               if (fp) {
+                       if (!fp->translated) {
+                               r300TranslateFragmentShader(r300, fp);
+                               FALLBACK_IF(!fp->translated);
+                       }
+               }
        }
 
        FALLBACK_IF(ctx->RenderMode != GL_RENDER);
@@ -352,8 +377,6 @@ static int r300Fallback(GLcontext * ctx)
                        || ctx->Stencil.WriteMask[0] !=
                        ctx->Stencil.WriteMask[1]));
 
-       FALLBACK_IF(ctx->Color.ColorLogicOpEnabled);
-
        if (ctx->Extensions.NV_point_sprite || ctx->Extensions.ARB_point_sprite)
                FALLBACK_IF(ctx->Point.PointSprite);
 
index 5f5ac7c4c71b39a9291b2499c66d3b581bb37c70..f30fd986e0f0c1029b60eb9cd7158be259433704 100644 (file)
@@ -1,8 +1,7 @@
-#include "glheader.h"
-#include "macros.h"
-#include "enums.h"
 
-#include "program.h"
+#include "main/glheader.h"
+
+#include "shader/program.h"
 #include "tnl/tnl.h"
 #include "r300_context.h"
 #include "r300_fragprog.h"
@@ -10,8 +9,10 @@
 static struct gl_program *r300NewProgram(GLcontext * ctx, GLenum target,
                                         GLuint id)
 {
+       r300ContextPtr rmesa = R300_CONTEXT(ctx);
        struct r300_vertex_program_cont *vp;
-       struct r300_fragment_program *fp;
+       struct r300_fragment_program *r300_fp;
+       struct r500_fragment_program *r500_fp;
 
        switch (target) {
        case GL_VERTEX_STATE_PROGRAM_NV:
@@ -20,14 +21,27 @@ static struct gl_program *r300NewProgram(GLcontext * ctx, GLenum target,
                return _mesa_init_vertex_program(ctx, &vp->mesa_program,
                                                 target, id);
        case GL_FRAGMENT_PROGRAM_ARB:
-               fp = CALLOC_STRUCT(r300_fragment_program);
-               fp->ctx = ctx;
-               return _mesa_init_fragment_program(ctx, &fp->mesa_program,
-                                                  target, id);
+               if (rmesa->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) {
+                       r500_fp = CALLOC_STRUCT(r500_fragment_program);
+                       r500_fp->ctx = ctx;
+                       return _mesa_init_fragment_program(ctx, &r500_fp->mesa_program,
+                                                          target, id);
+               } else {
+                       r300_fp = CALLOC_STRUCT(r300_fragment_program);
+                       return _mesa_init_fragment_program(ctx, &r300_fp->mesa_program,
+                                                          target, id);
+               }
+
        case GL_FRAGMENT_PROGRAM_NV:
-               fp = CALLOC_STRUCT(r300_fragment_program);
-               return _mesa_init_fragment_program(ctx, &fp->mesa_program,
-                                                  target, id);
+               if (rmesa->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) {
+                       r500_fp = CALLOC_STRUCT(r500_fragment_program);
+                       return _mesa_init_fragment_program(ctx, &r500_fp->mesa_program,
+                                                          target, id);
+               } else {
+                       r300_fp = CALLOC_STRUCT(r300_fragment_program);
+                       return _mesa_init_fragment_program(ctx, &r300_fp->mesa_program,
+                                                          target, id);
+               }
        default:
                _mesa_problem(ctx, "Bad target in r300NewProgram");
        }
@@ -43,15 +57,20 @@ static void r300DeleteProgram(GLcontext * ctx, struct gl_program *prog)
 static void
 r300ProgramStringNotify(GLcontext * ctx, GLenum target, struct gl_program *prog)
 {
+       r300ContextPtr rmesa = R300_CONTEXT(ctx);
        struct r300_vertex_program_cont *vp = (void *)prog;
-       struct r300_fragment_program *fp = (struct r300_fragment_program *)prog;
+       struct r300_fragment_program *r300_fp = (struct r300_fragment_program *)prog;
+       struct r500_fragment_program *r500_fp = (struct r500_fragment_program *)prog;
 
        switch (target) {
        case GL_VERTEX_PROGRAM_ARB:
                vp->progs = NULL;
                break;
        case GL_FRAGMENT_PROGRAM_ARB:
-               fp->translated = GL_FALSE;
+               if (rmesa->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515)
+                       r500_fp->translated = GL_FALSE;
+               else
+                       r300_fp->translated = GL_FALSE;
                break;
        }
 
index 088216c76ee952467047b7ff99ca9ffef3730cf3..15cd05316186cd68a08348b8a0a5c6b9e1760d91 100644 (file)
@@ -70,20 +70,28 @@ extern void _tnl_UpdateFixedFunctionProgram(GLcontext * ctx);
 
 static void r300BlendColor(GLcontext * ctx, const GLfloat cf[4])
 {
-       GLubyte color[4];
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
 
        R300_STATECHANGE(rmesa, blend_color);
 
-       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->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) {
+               GLuint r = IROUND(cf[0]*1023.0f);
+               GLuint g = IROUND(cf[1]*1023.0f);
+               GLuint b = IROUND(cf[2]*1023.0f);
+               GLuint a = IROUND(cf[3]*1023.0f);
 
-       rmesa->hw.blend_color.cmd[1] = PACK_COLOR_8888(color[3], color[0],
-                                                      color[1], color[2]);
-       rmesa->hw.blend_color.cmd[2] = 0;
-       rmesa->hw.blend_color.cmd[3] = 0;
+               rmesa->hw.blend_color.cmd[1] = r | (a << 16);
+               rmesa->hw.blend_color.cmd[2] = b | (g << 16);
+       } else {
+               GLubyte color[4];
+               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.blend_color.cmd[1] = PACK_COLOR_8888(color[3], color[0],
+                                                       color[1], color[2]);
+       }
 }
 
 /**
@@ -189,7 +197,7 @@ static void r300SetBlendCntl(r300ContextPtr r300, int func, int eqn,
         */
 #if 0
        if (new_ablend == new_cblend) {
-               new_cblend |= R300_BLEND_NO_SEPARATE;
+               new_cblend |= R300_DISCARD_SRC_PIXELS_SRC_ALPHA_0;
        }
 #endif
        new_cblend |= cbits;
@@ -295,7 +303,9 @@ static void r300SetBlendState(GLcontext * ctx)
 
        r300SetBlendCntl(r300,
                         func, eqn,
-                        R300_BLEND_UNKNOWN | R300_BLEND_ENABLE, funcA, eqnA);
+                        (R300_SEPARATE_ALPHA_ENABLE |
+                         R300_READ_ENABLE |
+                         R300_ALPHA_BLEND_ENABLE), funcA, eqnA);
 }
 
 static void r300BlendEquationSeparate(GLcontext * ctx,
@@ -311,6 +321,83 @@ static void r300BlendFuncSeparate(GLcontext * ctx,
        r300SetBlendState(ctx);
 }
 
+/**
+ * Translate LogicOp enums into hardware representation.
+ * Both use a very logical bit-wise layout, but unfortunately the order
+ * of bits is reversed.
+ */
+static GLuint translate_logicop(GLenum logicop)
+{
+       GLuint bits = logicop - GL_CLEAR;
+       bits = ((bits & 1) << 3) | ((bits & 2) << 1) | ((bits & 4) >> 1) | ((bits & 8) >> 3);
+       return bits << R300_RB3D_ROPCNTL_ROP_SHIFT;
+}
+
+/**
+ * Used internally to update the r300->hw hardware state to match the
+ * current OpenGL state.
+ */
+static void r300SetLogicOpState(GLcontext *ctx)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       R300_STATECHANGE(r300, rop);
+       if (RGBA_LOGICOP_ENABLED(ctx)) {
+               r300->hw.rop.cmd[1] = R300_RB3D_ROPCNTL_ROP_ENABLE |
+                       translate_logicop(ctx->Color.LogicOp);
+       } else {
+               r300->hw.rop.cmd[1] = 0;
+       }
+}
+
+/**
+ * Called by Mesa when an application program changes the LogicOp state
+ * via glLogicOp.
+ */
+static void r300LogicOpcode(GLcontext *ctx, GLenum logicop)
+{
+       if (RGBA_LOGICOP_ENABLED(ctx))
+               r300SetLogicOpState(ctx);
+}
+
+static void r300ClipPlane( GLcontext *ctx, GLenum plane, const GLfloat *eq )
+{
+       r300ContextPtr rmesa = R300_CONTEXT(ctx);
+       GLint p;
+       GLint *ip;
+
+       /* no VAP UCP on non-TCL chipsets */
+       if (!(rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL))
+                       return;
+
+       p = (GLint) plane - (GLint) GL_CLIP_PLANE0;
+       ip = (GLint *)ctx->Transform._ClipUserPlane[p];
+
+       R300_STATECHANGE( rmesa, vpucp[p] );
+       rmesa->hw.vpucp[p].cmd[R300_VPUCP_X] = ip[0];
+       rmesa->hw.vpucp[p].cmd[R300_VPUCP_Y] = ip[1];
+       rmesa->hw.vpucp[p].cmd[R300_VPUCP_Z] = ip[2];
+       rmesa->hw.vpucp[p].cmd[R300_VPUCP_W] = ip[3];
+}
+
+static void r300SetClipPlaneState(GLcontext * ctx, GLenum cap, GLboolean state)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       GLuint p;
+
+       /* no VAP UCP on non-TCL chipsets */
+       if (!(r300->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL))
+               return;
+
+       p = cap - GL_CLIP_PLANE0;
+       R300_STATECHANGE(r300, vap_clip_cntl);
+       if (state) {
+               r300->hw.vap_clip_cntl.cmd[1] |= (R300_VAP_UCP_ENABLE_0 << p);
+               r300ClipPlane(ctx, cap, NULL);
+       } else {
+               r300->hw.vap_clip_cntl.cmd[1] &= ~(R300_VAP_UCP_ENABLE_0 << p);
+       }
+}
+
 /**
  * Update our tracked culling state based on Mesa's state.
  */
@@ -350,44 +437,52 @@ static void r300UpdateCulling(GLcontext * ctx)
        r300->hw.cul.cmd[R300_CUL_CULL] = val;
 }
 
-static void r300SetEarlyZState(GLcontext * ctx)
+static void r300SetPolygonOffsetState(GLcontext * ctx, GLboolean state)
 {
-       /* updates register R300_RB3D_EARLY_Z (0x4F14)
-          if depth test is not enabled it should be R300_EARLY_Z_DISABLE
-          if depth is enabled and alpha not it should be R300_EARLY_Z_ENABLE
-          if depth and alpha is enabled it should be R300_EARLY_Z_DISABLE
-        */
        r300ContextPtr r300 = R300_CONTEXT(ctx);
 
-       R300_STATECHANGE(r300, zstencil_format);
-       switch (ctx->Visual.depthBits) {
-       case 16:
-               r300->hw.zstencil_format.cmd[1] = R300_DEPTH_FORMAT_16BIT_INT_Z;
-               break;
-       case 24:
-               r300->hw.zstencil_format.cmd[1] = R300_DEPTH_FORMAT_24BIT_INT_Z;
-               break;
-       default:
-               fprintf(stderr, "Error: Unsupported depth %d... exiting\n", ctx->Visual.depthBits);
-               _mesa_exit(-1);
+       R300_STATECHANGE(r300, occlusion_cntl);
+       if (state) {
+               r300->hw.occlusion_cntl.cmd[1] |= (3 << 0);
+       } else {
+               r300->hw.occlusion_cntl.cmd[1] &= ~(3 << 0);
        }
+}
 
-       // r300->hw.zstencil_format.cmd[1] |= R300_DEPTH_FORMAT_UNK32;
+static GLboolean current_fragment_program_writes_depth(GLcontext* ctx)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
 
-       if (ctx->Color.AlphaEnabled && ctx->Color.AlphaFunc != GL_ALWAYS)
-               /* disable early Z */
-               r300->hw.zstencil_format.cmd[2] = R300_EARLY_Z_DISABLE;
-       else {
-               if (ctx->Depth.Test && ctx->Depth.Func != GL_NEVER)
-                       /* enable early Z */
-                       r300->hw.zstencil_format.cmd[2] = R300_EARLY_Z_ENABLE;
-               else
-                       /* disable early Z */
-                       r300->hw.zstencil_format.cmd[2] = R300_EARLY_Z_DISABLE;
+       if (r300->radeon.radeonScreen->chip_family < CHIP_FAMILY_RV515) {
+               struct r300_fragment_program *fp = (struct r300_fragment_program *)
+                       (char *)ctx->FragmentProgram._Current;
+               return (fp && fp->WritesDepth);
+       } else {
+               struct r500_fragment_program* fp =
+                       (struct r500_fragment_program*)(char*)
+                       ctx->FragmentProgram._Current;
+               return (fp && fp->writes_depth);
        }
+}
 
-       r300->hw.zstencil_format.cmd[3] = 0x00000003;
-       r300->hw.zstencil_format.cmd[4] = 0x00000000;
+static void r300SetEarlyZState(GLcontext * ctx)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       GLuint topZ = R300_ZTOP_ENABLE;
+
+       if (ctx->Color.AlphaEnabled && ctx->Color.AlphaFunc != GL_ALWAYS)
+               topZ = R300_ZTOP_DISABLE;
+       if (current_fragment_program_writes_depth(ctx))
+               topZ = R300_ZTOP_DISABLE;
+
+       if (topZ != r300->hw.zstencil_format.cmd[2]) {
+               /* Note: This completely reemits the stencil format.
+                * I have not tested whether this is strictly necessary,
+                * or if emitting a write to ZB_ZTOP is enough.
+                */
+               R300_STATECHANGE(r300, zstencil_format);
+               r300->hw.zstencil_format.cmd[2] = topZ;
+       }
 }
 
 static void r300SetAlphaState(GLcontext * ctx)
@@ -401,35 +496,36 @@ static void r300SetAlphaState(GLcontext * ctx)
 
        switch (ctx->Color.AlphaFunc) {
        case GL_NEVER:
-               pp_misc |= R300_ALPHA_TEST_FAIL;
+               pp_misc |= R300_FG_ALPHA_FUNC_NEVER;
                break;
        case GL_LESS:
-               pp_misc |= R300_ALPHA_TEST_LESS;
+               pp_misc |= R300_FG_ALPHA_FUNC_LESS;
                break;
        case GL_EQUAL:
-               pp_misc |= R300_ALPHA_TEST_EQUAL;
+               pp_misc |= R300_FG_ALPHA_FUNC_EQUAL;
                break;
        case GL_LEQUAL:
-               pp_misc |= R300_ALPHA_TEST_LEQUAL;
+               pp_misc |= R300_FG_ALPHA_FUNC_LE;
                break;
        case GL_GREATER:
-               pp_misc |= R300_ALPHA_TEST_GREATER;
+               pp_misc |= R300_FG_ALPHA_FUNC_GREATER;
                break;
        case GL_NOTEQUAL:
-               pp_misc |= R300_ALPHA_TEST_NEQUAL;
+               pp_misc |= R300_FG_ALPHA_FUNC_NOTEQUAL;
                break;
        case GL_GEQUAL:
-               pp_misc |= R300_ALPHA_TEST_GEQUAL;
+               pp_misc |= R300_FG_ALPHA_FUNC_GE;
                break;
        case GL_ALWAYS:
-               /*pp_misc |= R300_ALPHA_TEST_PASS; */
+               /*pp_misc |= FG_ALPHA_FUNC_ALWAYS; */
                really_enabled = GL_FALSE;
                break;
        }
 
        if (really_enabled) {
-               pp_misc |= R300_ALPHA_TEST_ENABLE;
-               pp_misc |= (refByte & R300_REF_ALPHA_MASK);
+               pp_misc |= R300_FG_ALPHA_FUNC_ENABLE;
+               pp_misc |= R500_FG_ALPHA_FUNC_8BIT;
+               pp_misc |= (refByte & R300_FG_ALPHA_FUNC_VAL_MASK);
        } else {
                pp_misc = 0x0;
        }
@@ -476,38 +572,53 @@ static void r300SetDepthState(GLcontext * ctx)
        r300ContextPtr r300 = R300_CONTEXT(ctx);
 
        R300_STATECHANGE(r300, zs);
-       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_DEPTH_FUNC_SHIFT);
+       r300->hw.zs.cmd[R300_ZS_CNTL_0] &= R300_STENCIL_ENABLE|R300_STENCIL_FRONT_BACK;
+       r300->hw.zs.cmd[R300_ZS_CNTL_1] &= ~(R300_ZS_MASK << R300_Z_FUNC_SHIFT);
 
-       if (ctx->Depth.Test && ctx->Depth.Func != GL_NEVER) {
+       if (ctx->Depth.Test) {
+               r300->hw.zs.cmd[R300_ZS_CNTL_0] |= R300_Z_ENABLE;
                if (ctx->Depth.Mask)
-                       r300->hw.zs.cmd[R300_ZS_CNTL_0] |=
-                           R300_RB3D_Z_TEST_AND_WRITE;
-               else
-                       r300->hw.zs.cmd[R300_ZS_CNTL_0] |= R300_RB3D_Z_TEST;
-
-               r300->hw.zs.cmd[R300_ZS_CNTL_1] |=
-                   translate_func(ctx->Depth.
-                                  Func) << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT;
-       } else {
-               r300->hw.zs.cmd[R300_ZS_CNTL_0] |= R300_RB3D_Z_DISABLED_1;
+                       r300->hw.zs.cmd[R300_ZS_CNTL_0] |= R300_Z_WRITE_ENABLE;
                r300->hw.zs.cmd[R300_ZS_CNTL_1] |=
-                   translate_func(GL_NEVER) << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT;
+                   translate_func(ctx->Depth.Func) << R300_Z_FUNC_SHIFT;
        }
 
        r300SetEarlyZState(ctx);
 }
 
+static void r300SetStencilState(GLcontext * ctx, GLboolean state)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+
+       if (r300->state.stencil.hw_stencil) {
+               R300_STATECHANGE(r300, zs);
+               if (state) {
+                       r300->hw.zs.cmd[R300_ZS_CNTL_0] |=
+                           R300_STENCIL_ENABLE;
+               } else {
+                       r300->hw.zs.cmd[R300_ZS_CNTL_0] &=
+                           ~R300_STENCIL_ENABLE;
+               }
+       } else {
+#if R200_MERGED
+               FALLBACK(&r300->radeon, RADEON_FALLBACK_STENCIL, state);
+#endif
+       }
+}
+
 static void r300UpdatePolygonMode(GLcontext * ctx)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
-       uint32_t hw_mode = 0;
+       uint32_t hw_mode = R300_GA_POLY_MODE_DISABLE;
 
+       /* Only do something if a polygon mode is wanted, default is GL_FILL */
        if (ctx->Polygon.FrontMode != GL_FILL ||
            ctx->Polygon.BackMode != GL_FILL) {
                GLenum f, b;
 
+               /* Handle GL_CW (clock wise and GL_CCW (counter clock wise)
+                * correctly by selecting the correct front and back face
+                */
                if (ctx->Polygon.FrontFace == GL_CCW) {
                        f = ctx->Polygon.FrontMode;
                        b = ctx->Polygon.BackMode;
@@ -516,29 +627,30 @@ static void r300UpdatePolygonMode(GLcontext * ctx)
                        b = ctx->Polygon.FrontMode;
                }
 
-               hw_mode |= R300_PM_ENABLED;
+               /* Enable polygon mode */
+               hw_mode |= R300_GA_POLY_MODE_DUAL;
 
                switch (f) {
                case GL_LINE:
-                       hw_mode |= R300_PM_FRONT_LINE;
+                       hw_mode |= R300_GA_POLY_MODE_FRONT_PTYPE_LINE;
                        break;
-               case GL_POINT:  /* noop */
-                       hw_mode |= R300_PM_FRONT_POINT;
+               case GL_POINT:
+                       hw_mode |= R300_GA_POLY_MODE_FRONT_PTYPE_POINT;
                        break;
                case GL_FILL:
-                       hw_mode |= R300_PM_FRONT_FILL;
+                       hw_mode |= R300_GA_POLY_MODE_FRONT_PTYPE_TRI;
                        break;
                }
 
                switch (b) {
                case GL_LINE:
-                       hw_mode |= R300_PM_BACK_LINE;
+                       hw_mode |= R300_GA_POLY_MODE_BACK_PTYPE_LINE;
                        break;
-               case GL_POINT:  /* noop */
-                       hw_mode |= R300_PM_BACK_POINT;
+               case GL_POINT:
+                       hw_mode |= R300_GA_POLY_MODE_BACK_PTYPE_POINT;
                        break;
                case GL_FILL:
-                       hw_mode |= R300_PM_BACK_FILL;
+                       hw_mode |= R300_GA_POLY_MODE_BACK_PTYPE_TRI;
                        break;
                }
        }
@@ -606,9 +718,10 @@ 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);
+       int mask = (r ? RB3D_COLOR_CHANNEL_MASK_RED_MASK0 : 0) |
+           (g ? RB3D_COLOR_CHANNEL_MASK_GREEN_MASK0 : 0) |
+           (b ? RB3D_COLOR_CHANNEL_MASK_BLUE_MASK0 : 0) |
+           (a ? RB3D_COLOR_CHANNEL_MASK_ALPHA_MASK0 : 0);
 
        if (mask != r300->hw.cmk.cmd[R300_CMK_COLORMASK]) {
                R300_STATECHANGE(r300, cmk);
@@ -634,15 +747,13 @@ static void r300Fogfv(GLcontext * ctx, GLenum pname, const GLfloat * param)
 
        switch (pname) {
        case GL_FOG_MODE:
-               if (!ctx->Fog.Enabled)
-                       return;
                switch (ctx->Fog.Mode) {
                case GL_LINEAR:
                        R300_STATECHANGE(r300, fogs);
                        r300->hw.fogs.cmd[R300_FOGS_STATE] =
                            (r300->hw.fogs.
-                            cmd[R300_FOGS_STATE] & ~R300_FOG_MODE_MASK) |
-                           R300_FOG_MODE_LINEAR;
+                            cmd[R300_FOGS_STATE] & ~R300_FG_FOG_BLEND_FN_MASK) |
+                           R300_FG_FOG_BLEND_FN_LINEAR;
 
                        if (ctx->Fog.Start == ctx->Fog.End) {
                                fogScale.f = -1.0;
@@ -659,8 +770,8 @@ static void r300Fogfv(GLcontext * ctx, GLenum pname, const GLfloat * param)
                        R300_STATECHANGE(r300, fogs);
                        r300->hw.fogs.cmd[R300_FOGS_STATE] =
                            (r300->hw.fogs.
-                            cmd[R300_FOGS_STATE] & ~R300_FOG_MODE_MASK) |
-                           R300_FOG_MODE_EXP;
+                            cmd[R300_FOGS_STATE] & ~R300_FG_FOG_BLEND_FN_MASK) |
+                           R300_FG_FOG_BLEND_FN_EXP;
                        fogScale.f = 0.0933 * ctx->Fog.Density;
                        fogStart.f = 0.0;
                        break;
@@ -668,8 +779,8 @@ static void r300Fogfv(GLcontext * ctx, GLenum pname, const GLfloat * param)
                        R300_STATECHANGE(r300, fogs);
                        r300->hw.fogs.cmd[R300_FOGS_STATE] =
                            (r300->hw.fogs.
-                            cmd[R300_FOGS_STATE] & ~R300_FOG_MODE_MASK) |
-                           R300_FOG_MODE_EXP2;
+                            cmd[R300_FOGS_STATE] & ~R300_FG_FOG_BLEND_FN_MASK) |
+                           R300_FG_FOG_BLEND_FN_EXP2;
                        fogScale.f = 0.3 * ctx->Fog.Density;
                        fogStart.f = 0.0;
                default:
@@ -727,6 +838,24 @@ static void r300Fogfv(GLcontext * ctx, GLenum pname, const GLfloat * param)
        }
 }
 
+static void r300SetFogState(GLcontext * ctx, GLboolean state)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+
+       R300_STATECHANGE(r300, fogs);
+       if (state) {
+               r300->hw.fogs.cmd[R300_FOGS_STATE] |= R300_FG_FOG_BLEND_ENABLE;
+
+               r300Fogfv(ctx, GL_FOG_MODE, NULL);
+               r300Fogfv(ctx, GL_FOG_DENSITY, &ctx->Fog.Density);
+               r300Fogfv(ctx, GL_FOG_START, &ctx->Fog.Start);
+               r300Fogfv(ctx, GL_FOG_END, &ctx->Fog.End);
+               r300Fogfv(ctx, GL_FOG_COLOR, ctx->Fog.Color);
+       } else {
+               r300->hw.fogs.cmd[R300_FOGS_STATE] &= ~R300_FG_FOG_BLEND_ENABLE;
+       }
+}
+
 /* =============================================================
  * Point state
  */
@@ -742,6 +871,31 @@ static void r300PointSize(GLcontext * ctx, GLfloat size)
            ((int)(size * 6) << R300_POINTSIZE_Y_SHIFT);
 }
 
+static void r300PointParameter(GLcontext * ctx, GLenum pname, const GLfloat * param)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+
+       switch (pname) {
+       case GL_POINT_SIZE_MIN:
+               R300_STATECHANGE(r300, ga_point_minmax);
+               r300->hw.ga_point_minmax.cmd[1] &= ~R300_GA_POINT_MINMAX_MIN_MASK;
+               r300->hw.ga_point_minmax.cmd[1] |= (GLuint)(ctx->Point.MinSize * 6.0);
+               break;
+       case GL_POINT_SIZE_MAX:
+               R300_STATECHANGE(r300, ga_point_minmax);
+               r300->hw.ga_point_minmax.cmd[1] &= ~R300_GA_POINT_MINMAX_MAX_MASK;
+               r300->hw.ga_point_minmax.cmd[1] |= (GLuint)(ctx->Point.MaxSize * 6.0)
+                       << R300_GA_POINT_MINMAX_MAX_SHIFT;
+               break;
+       case GL_POINT_DISTANCE_ATTENUATION:
+               break;
+       case GL_POINT_FADE_THRESHOLD_SIZE:
+               break;
+       default:
+               break;
+       }
+}
+
 /* =============================================================
  * Line state
  */
@@ -821,37 +975,36 @@ static void r300StencilFuncSeparate(GLcontext * ctx, GLenum face,
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
        GLuint refmask =
            (((ctx->Stencil.
-              Ref[0] & 0xff) << R300_RB3D_ZS2_STENCIL_REF_SHIFT) | ((ctx->
-                                                                     Stencil.
-                                                                     ValueMask
-                                                                     [0] &
-                                                                     0xff)
-                                                                    <<
-                                                                    R300_RB3D_ZS2_STENCIL_MASK_SHIFT));
+              Ref[0] & 0xff) << R300_STENCILREF_SHIFT) | ((ctx->
+                                                           Stencil.
+                                                           ValueMask
+                                                           [0] &
+                                                           0xff)
+                                                          <<
+                                                          R300_STENCILMASK_SHIFT));
 
        GLuint flag;
 
        R300_STATECHANGE(rmesa, zs);
-
+       rmesa->hw.zs.cmd[R300_ZS_CNTL_0] |= R300_STENCIL_FRONT_BACK;
        rmesa->hw.zs.cmd[R300_ZS_CNTL_1] &= ~((R300_ZS_MASK <<
-                                              R300_RB3D_ZS1_FRONT_FUNC_SHIFT)
+                                              R300_S_FRONT_FUNC_SHIFT)
                                              | (R300_ZS_MASK <<
-                                                R300_RB3D_ZS1_BACK_FUNC_SHIFT));
+                                                R300_S_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));
+           ~((R300_STENCILREF_MASK << R300_STENCILREF_SHIFT) |
+             (R300_STENCILREF_MASK << R300_STENCILMASK_SHIFT));
 
        flag = translate_func(ctx->Stencil.Function[0]);
        rmesa->hw.zs.cmd[R300_ZS_CNTL_1] |=
-           (flag << R300_RB3D_ZS1_FRONT_FUNC_SHIFT);
+           (flag << R300_S_FRONT_FUNC_SHIFT);
 
        if (ctx->Stencil._TestTwoSide)
                flag = translate_func(ctx->Stencil.Function[1]);
 
        rmesa->hw.zs.cmd[R300_ZS_CNTL_1] |=
-           (flag << R300_RB3D_ZS1_BACK_FUNC_SHIFT);
+           (flag << R300_S_BACK_FUNC_SHIFT);
        rmesa->hw.zs.cmd[R300_ZS_CNTL_2] |= refmask;
 }
 
@@ -861,11 +1014,12 @@ static void r300StencilMaskSeparate(GLcontext * ctx, GLenum face, GLuint mask)
 
        R300_STATECHANGE(rmesa, zs);
        rmesa->hw.zs.cmd[R300_ZS_CNTL_2] &=
-           ~(R300_RB3D_ZS2_STENCIL_MASK <<
-             R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT);
+           ~(R300_STENCILREF_MASK <<
+             R300_STENCILWRITEMASK_SHIFT);
        rmesa->hw.zs.cmd[R300_ZS_CNTL_2] |=
            (ctx->Stencil.
-            WriteMask[0] & 0xff) << R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT;
+            WriteMask[0] & R300_STENCILREF_MASK) <<
+            R300_STENCILWRITEMASK_SHIFT;
 }
 
 static void r300StencilOpSeparate(GLcontext * ctx, GLenum face,
@@ -876,49 +1030,37 @@ static void r300StencilOpSeparate(GLcontext * ctx, GLenum face,
        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);
+           (R300_ZS_MASK << R300_Z_FUNC_SHIFT) |
+           (R300_ZS_MASK << R300_S_FRONT_FUNC_SHIFT) |
+           (R300_ZS_MASK << R300_S_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)
+            R300_S_FRONT_SFAIL_OP_SHIFT)
            | (translate_stencil_op(ctx->Stencil.ZFailFunc[0]) <<
-              R300_RB3D_ZS1_FRONT_ZFAIL_OP_SHIFT)
+              R300_S_FRONT_ZFAIL_OP_SHIFT)
            | (translate_stencil_op(ctx->Stencil.ZPassFunc[0]) <<
-              R300_RB3D_ZS1_FRONT_ZPASS_OP_SHIFT);
+              R300_S_FRONT_ZPASS_OP_SHIFT);
 
        if (ctx->Stencil._TestTwoSide) {
                rmesa->hw.zs.cmd[R300_ZS_CNTL_1] |=
                    (translate_stencil_op(ctx->Stencil.FailFunc[1]) <<
-                    R300_RB3D_ZS1_BACK_FAIL_OP_SHIFT)
+                    R300_S_BACK_SFAIL_OP_SHIFT)
                    | (translate_stencil_op(ctx->Stencil.ZFailFunc[1]) <<
-                      R300_RB3D_ZS1_BACK_ZFAIL_OP_SHIFT)
+                      R300_S_BACK_ZFAIL_OP_SHIFT)
                    | (translate_stencil_op(ctx->Stencil.ZPassFunc[1]) <<
-                      R300_RB3D_ZS1_BACK_ZPASS_OP_SHIFT);
+                      R300_S_BACK_ZPASS_OP_SHIFT);
        } else {
                rmesa->hw.zs.cmd[R300_ZS_CNTL_1] |=
                    (translate_stencil_op(ctx->Stencil.FailFunc[0]) <<
-                    R300_RB3D_ZS1_BACK_FAIL_OP_SHIFT)
+                    R300_S_BACK_SFAIL_OP_SHIFT)
                    | (translate_stencil_op(ctx->Stencil.ZFailFunc[0]) <<
-                      R300_RB3D_ZS1_BACK_ZFAIL_OP_SHIFT)
+                      R300_S_BACK_ZFAIL_OP_SHIFT)
                    | (translate_stencil_op(ctx->Stencil.ZPassFunc[0]) <<
-                      R300_RB3D_ZS1_BACK_ZPASS_OP_SHIFT);
+                      R300_S_BACK_ZPASS_OP_SHIFT);
        }
 }
 
-static void r300ClearStencil(GLcontext * ctx, GLint s)
-{
-       r300ContextPtr rmesa = R300_CONTEXT(ctx);
-
-       rmesa->state.stencil.clear =
-           ((GLuint) (ctx->Stencil.Clear & 0xff) |
-            (R300_RB3D_ZS2_STENCIL_MASK <<
-             R300_RB3D_ZS2_STENCIL_MASK_SHIFT) | ((ctx->Stencil.
-                                                   WriteMask[0] & 0xff) <<
-                                                  R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT));
-}
-
 /* =============================================================
  * Window position and viewport transformation
  */
@@ -1006,12 +1148,12 @@ void r300UpdateDrawBuffer(GLcontext * ctx)
        struct gl_framebuffer *fb = ctx->DrawBuffer;
        driRenderbuffer *drb;
 
-       if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT) {
+       if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) {
                /* draw to front */
                drb =
                    (driRenderbuffer *) fb->Attachment[BUFFER_FRONT_LEFT].
                    Renderbuffer;
-       } else if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT) {
+       } else if (fb->_ColorDrawBufferIndexes[0] == BUFFER_BACK_LEFT) {
                /* draw to back */
                drb =
                    (driRenderbuffer *) fb->Attachment[BUFFER_BACK_LEFT].
@@ -1183,8 +1325,8 @@ static unsigned long gen_fixed_filter(unsigned long f)
            (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)) {
+       if ((f & ((7 - 1) << R300_TX_WRAP_R_SHIFT)) ==
+           (R300_TX_CLAMP << R300_TX_WRAP_R_SHIFT)) {
                needs_fixing |= 4;
        }
 
@@ -1192,7 +1334,7 @@ static unsigned long gen_fixed_filter(unsigned long f)
                return f;
 
        mag = f & R300_TX_MAG_FILTER_MASK;
-       min = f & R300_TX_MIN_FILTER_MASK;
+       min = f & (R300_TX_MIN_FILTER_MASK|R300_TX_MIN_FILTER_MIP_MASK);
 
        /* TODO: Check for anisto filters too */
        if ((mag != R300_TX_MAG_FILTER_NEAREST)
@@ -1224,12 +1366,100 @@ static unsigned long gen_fixed_filter(unsigned long f)
                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;
+               f &= ~((7 - 1) << R300_TX_WRAP_R_SHIFT);
+               f |= R300_TX_CLAMP_TO_EDGE << R300_TX_WRAP_R_SHIFT;
        }
        return f;
 }
 
+static void r300SetupFragmentShaderTextures(GLcontext *ctx, int *tmu_mappings)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       int i;
+       struct r300_fragment_program *fp = (struct r300_fragment_program *)
+           (char *)ctx->FragmentProgram._Current;
+       struct r300_fragment_program_code *code = &fp->code;
+
+       R300_STATECHANGE(r300, fpt);
+
+       for (i = 0; i < code->tex.length; i++) {
+               int unit;
+               int opcode;
+               unsigned long val;
+
+               unit = code->tex.inst[i] >> R300_TEX_ID_SHIFT;
+               unit &= 15;
+
+               val = code->tex.inst[i];
+               val &= ~R300_TEX_ID_MASK;
+
+               opcode =
+                       (val & R300_TEX_INST_MASK) >> R300_TEX_INST_SHIFT;
+               if (opcode == R300_TEX_OP_KIL) {
+                       r300->hw.fpt.cmd[R300_FPT_INSTR_0 + i] = val;
+               } else {
+                       if (tmu_mappings[unit] >= 0) {
+                               val |=
+                                       tmu_mappings[unit] <<
+                                       R300_TEX_ID_SHIFT;
+                               r300->hw.fpt.cmd[R300_FPT_INSTR_0 + i] = val;
+                       } else {
+                               // We get here when the corresponding texture image is incomplete
+                               // (e.g. incomplete mipmaps etc.)
+                               r300->hw.fpt.cmd[R300_FPT_INSTR_0 + i] = val;
+                       }
+               }
+       }
+
+       r300->hw.fpt.cmd[R300_FPT_CMD_0] =
+               cmdpacket0(R300_US_TEX_INST_0, code->tex.length);
+}
+
+static void r500SetupFragmentShaderTextures(GLcontext *ctx, int *tmu_mappings)
+{
+       int i;
+       struct r500_fragment_program *fp = (struct r500_fragment_program *)
+           (char *)ctx->FragmentProgram._Current;
+       struct r500_fragment_program_code *code = &fp->code;
+
+       /* find all the texture instructions and relocate the texture units */
+       for (i = 0; i < code->inst_end + 1; i++) {
+               if ((code->inst[i].inst0 & 0x3) == R500_INST_TYPE_TEX) {
+                       uint32_t val;
+                       int unit, opcode, new_unit;
+
+                       val = code->inst[i].inst1;
+
+                       unit = (val >> 16) & 0xf;
+
+                       val &= ~(0xf << 16);
+
+                       opcode = val & (0x7 << 22);
+                       if (opcode == R500_TEX_INST_TEXKILL) {
+                               new_unit = 0;
+                       } else {
+                               if (tmu_mappings[unit] >= 0) {
+                                       new_unit = tmu_mappings[unit];
+                               } else {
+                                       new_unit = 0;
+                               }
+                       }
+                       val |= R500_TEX_ID(new_unit);
+                       code->inst[i].inst1 = val;
+               }
+       }
+}
+
+static GLuint translate_lod_bias(GLfloat bias)
+{
+       GLint b = (int)(bias*32);
+       if (b >= (1 << 9))
+               b = (1 << 9)-1;
+       else if (b < -(1 << 9))
+               b = -(1 << 9);
+       return (((GLuint)b) << R300_LOD_BIAS_SHIFT) & R300_LOD_BIAS_MASK;
+}
+
 static void r300SetupTextures(GLcontext * ctx)
 {
        int i, mtu;
@@ -1293,8 +1523,14 @@ static void r300SetupTextures(GLcontext * ctx)
                        r300->hw.tex.filter.cmd[R300_TEX_VALUE_0 +
                                                hw_tmu] =
                            gen_fixed_filter(t->filter) | (hw_tmu << 28);
-                       /* Currently disabled! */
-                       r300->hw.tex.filter_1.cmd[R300_TEX_VALUE_0 + hw_tmu] = 0x0;     //0x20501f80;
+                       /* Note: There is a LOD bias per texture unit and a LOD bias
+                        * per texture object. We add them here to get the correct behaviour.
+                        * (The per-texture object LOD bias was introduced in OpenGL 1.4
+                        * and is not present in the EXT_texture_object extension).
+                        */
+                       r300->hw.tex.filter_1.cmd[R300_TEX_VALUE_0 + hw_tmu] =
+                               t->filter_1 |
+                               translate_lod_bias(ctx->Texture.Unit[i].LodBias + t->base.tObj->LodBias);
                        r300->hw.tex.size.cmd[R300_TEX_VALUE_0 + hw_tmu] =
                            t->size;
                        r300->hw.tex.format.cmd[R300_TEX_VALUE_0 +
@@ -1325,7 +1561,7 @@ static void r300SetupTextures(GLcontext * ctx)
        }
 
        r300->hw.tex.filter.cmd[R300_TEX_CMD_0] =
-           cmdpacket0(R300_TX_FILTER_0, last_hw_tmu + 1);
+           cmdpacket0(R300_TX_FILTER0_0, last_hw_tmu + 1);
        r300->hw.tex.filter_1.cmd[R300_TEX_CMD_0] =
            cmdpacket0(R300_TX_FILTER1_0, last_hw_tmu + 1);
        r300->hw.tex.size.cmd[R300_TEX_CMD_0] =
@@ -1333,7 +1569,7 @@ static void r300SetupTextures(GLcontext * ctx)
        r300->hw.tex.format.cmd[R300_TEX_CMD_0] =
            cmdpacket0(R300_TX_FORMAT_0, last_hw_tmu + 1);
        r300->hw.tex.pitch.cmd[R300_TEX_CMD_0] =
-           cmdpacket0(R300_TX_PITCH_0, last_hw_tmu + 1);
+           cmdpacket0(R300_TX_FORMAT2_0, last_hw_tmu + 1);
        r300->hw.tex.offset.cmd[R300_TEX_CMD_0] =
            cmdpacket0(R300_TX_OFFSET_0, last_hw_tmu + 1);
        r300->hw.tex.chroma_key.cmd[R300_TEX_CMD_0] =
@@ -1344,39 +1580,18 @@ static void r300SetupTextures(GLcontext * ctx)
        if (!fp)                /* should only happenen once, just after context is created */
                return;
 
-       R300_STATECHANGE(r300, fpt);
-
-       for (i = 0; i < fp->tex.length; i++) {
-               int unit;
-               int opcode;
-               unsigned long val;
-
-               unit = fp->tex.inst[i] >> R300_FPITX_IMAGE_SHIFT;
-               unit &= 15;
-
-               val = fp->tex.inst[i];
-               val &= ~R300_FPITX_IMAGE_MASK;
-
-               opcode =
-                   (val & R300_FPITX_OPCODE_MASK) >> R300_FPITX_OPCODE_SHIFT;
-               if (opcode == R300_FPITX_OP_KIL) {
-                       r300->hw.fpt.cmd[R300_FPT_INSTR_0 + i] = val;
-               } else {
-                       if (tmu_mappings[unit] >= 0) {
-                               val |=
-                                   tmu_mappings[unit] <<
-                                   R300_FPITX_IMAGE_SHIFT;
-                               r300->hw.fpt.cmd[R300_FPT_INSTR_0 + i] = val;
-                       } else {
-                               // We get here when the corresponding texture image is incomplete
-                               // (e.g. incomplete mipmaps etc.)
-                               r300->hw.fpt.cmd[R300_FPT_INSTR_0 + i] = val;
-                       }
+       if (r300->radeon.radeonScreen->chip_family < CHIP_FAMILY_RV515) {
+               if (fp->mesa_program.UsesKill && last_hw_tmu < 0) {
+                       // The KILL operation requires the first texture unit
+                       // to be enabled.
+                       r300->hw.txe.cmd[R300_TXE_ENABLE] |= 1;
+                       r300->hw.tex.filter.cmd[R300_TEX_VALUE_0] = 0;
+                       r300->hw.tex.filter.cmd[R300_TEX_CMD_0] =
+                               cmdpacket0(R300_TX_FILTER0_0, 1);
                }
-       }
-
-       r300->hw.fpt.cmd[R300_FPT_CMD_0] =
-           cmdpacket0(R300_PFS_TEXI_0, fp->tex.length);
+               r300SetupFragmentShaderTextures(ctx, tmu_mappings);
+       } else
+               r500SetupFragmentShaderTextures(ctx, tmu_mappings);
 
        if (RADEON_DEBUG & DEBUG_STATE)
                fprintf(stderr, "TX_ENABLE: %08x  last_hw_tmu=%d\n",
@@ -1396,21 +1611,17 @@ static void r300SetupRSUnit(GLcontext * ctx)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
        /* I'm still unsure if these are needed */
-       GLuint interp_magic[8] = {
-               0x00,
-               R300_RS_INTERP_1_UNKNOWN,
-               R300_RS_INTERP_2_UNKNOWN,
-               R300_RS_INTERP_3_UNKNOWN,
-               0x00,
-               0x00,
-               0x00,
-               0x00
-       };
+       GLuint interp_col[8];
+        TNLcontext *tnl = TNL_CONTEXT(ctx);
+       struct vertex_buffer *VB = &tnl->vb;
        union r300_outputs_written OutputsWritten;
        GLuint InputsRead;
        int fp_reg, high_rr;
-       int in_texcoords, col_interp_nr;
-       int i;
+       int col_interp_nr;
+       int rs_tex_count = 0, rs_col_count = 0;
+       int i, count;
+
+       memset(interp_col, 0, sizeof(interp_col));
 
        if (hw_tcl_on)
                OutputsWritten.vp_outputs = CURRENT_VERTEX_SHADER(ctx)->key.OutputsWritten;
@@ -1428,9 +1639,9 @@ static void r300SetupRSUnit(GLcontext * ctx)
        R300_STATECHANGE(r300, rc);
        R300_STATECHANGE(r300, rr);
 
-       fp_reg = in_texcoords = col_interp_nr = high_rr = 0;
+       fp_reg = col_interp_nr = high_rr = 0;
 
-       r300->hw.rr.cmd[R300_RR_ROUTE_1] = 0;
+       r300->hw.rr.cmd[R300_RR_INST_1] = 0;
 
        if (InputsRead & FRAG_BIT_WPOS) {
                for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
@@ -1446,15 +1657,53 @@ static void r300SetupRSUnit(GLcontext * ctx)
                InputsRead &= ~FRAG_BIT_WPOS;
        }
 
+       if (InputsRead & FRAG_BIT_COL0) {
+               count = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->size;
+               interp_col[0] |= R300_RS_COL_PTR(rs_col_count);
+               if (count == 3)
+                       interp_col[0] |= R300_RS_COL_FMT(R300_RS_COL_FMT_RGB1);
+               rs_col_count += count;
+       }
+       else
+               interp_col[0] = R300_RS_COL_FMT(R300_RS_COL_FMT_0001);
+
+       if (InputsRead & FRAG_BIT_COL1) {
+               count = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->size;
+               if (count == 3)
+                       interp_col[1] |= R300_RS_COL_FMT(R300_RS_COL_FMT_RGB0);
+               interp_col[1] |= R300_RS_COL_PTR(1);
+               rs_col_count += count;
+       }
+
+
        for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
-               r300->hw.ri.cmd[R300_RI_INTERP_0 + i] = 0 | R300_RS_INTERP_USED | (in_texcoords << R300_RS_INTERP_SRC_SHIFT)
-                   | interp_magic[i];
+               int swiz;
+
+               /* with TCL we always seem to route 4 components */
+               if (hw_tcl_on)
+                 count = 4;
+               else
+                 count = VB->AttribPtr[_TNL_ATTRIB_TEX(i)]->size;
+
+               r300->hw.ri.cmd[R300_RI_INTERP_0 + i] = interp_col[i] | rs_tex_count;
+               switch(count) {
+               case 4: swiz = R300_RS_SEL_S(0) | R300_RS_SEL_T(1) | R300_RS_SEL_R(2) | R300_RS_SEL_Q(3); break;
+               case 3: swiz = R300_RS_SEL_S(0) | R300_RS_SEL_T(1) | R300_RS_SEL_R(2) | R300_RS_SEL_Q(R300_RS_SEL_K1); break;
+               default:
+               case 1:
+               case 2: swiz = R300_RS_SEL_S(0) | R300_RS_SEL_T(1) | R300_RS_SEL_R(R300_RS_SEL_K0) | R300_RS_SEL_Q(R300_RS_SEL_K1); break;
+               };
+
+               r300->hw.ri.cmd[R300_RI_INTERP_0 + i] |= swiz;
 
-               r300->hw.rr.cmd[R300_RR_ROUTE_0 + fp_reg] = 0;
+               r300->hw.rr.cmd[R300_RR_INST_0 + fp_reg] = 0;
                if (InputsRead & (FRAG_BIT_TEX0 << i)) {
+
+                       rs_tex_count += count;
+
                        //assert(r300->state.texture.tc_count != 0);
-                       r300->hw.rr.cmd[R300_RR_ROUTE_0 + fp_reg] |= R300_RS_ROUTE_ENABLE | i   /* source INTERP */
-                           | (fp_reg << R300_RS_ROUTE_DEST_SHIFT);
+                       r300->hw.rr.cmd[R300_RR_INST_0 + fp_reg] |= R300_RS_INST_TEX_CN_WRITE | i       /* source INTERP */
+                           | (fp_reg << R300_RS_INST_TEX_ADDR_SHIFT);
                        high_rr = fp_reg;
 
                        /* Passing invalid data here can lock the GPU. */
@@ -1465,15 +1714,171 @@ static void r300SetupRSUnit(GLcontext * ctx)
                                WARN_ONCE("fragprog wants coords for tex%d, vp doesn't provide them!\n", i);
                        }
                }
-               /* Need to count all coords enabled at vof */
-               if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten, VERT_RESULT_TEX0 + i, _TNL_ATTRIB_TEX(i))) {
-                       in_texcoords++;
+       }
+
+       if (InputsRead & FRAG_BIT_COL0) {
+               if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten, VERT_RESULT_COL0, _TNL_ATTRIB_COLOR0)) {
+                       r300->hw.rr.cmd[R300_RR_INST_0] |= R300_RS_INST_COL_ID(0) | R300_RS_INST_COL_CN_WRITE | (fp_reg++ << R300_RS_INST_COL_ADDR_SHIFT);
+                       InputsRead &= ~FRAG_BIT_COL0;
+                       col_interp_nr++;
+               } else {
+                       WARN_ONCE("fragprog wants col0, vp doesn't provide it\n");
+               }
+       }
+
+       if (InputsRead & FRAG_BIT_COL1) {
+               if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten, VERT_RESULT_COL1, _TNL_ATTRIB_COLOR1)) {
+                       r300->hw.rr.cmd[R300_RR_INST_1] |= R300_RS_INST_COL_ID(1) | R300_RS_INST_COL_CN_WRITE | (fp_reg++ << R300_RS_INST_COL_ADDR_SHIFT);
+                       InputsRead &= ~FRAG_BIT_COL1;
+                       if (high_rr < 1)
+                               high_rr = 1;
+                       col_interp_nr++;
+               } else {
+                       WARN_ONCE("fragprog wants col1, vp doesn't provide it\n");
+               }
+       }
+
+       /* Need at least one. This might still lock as the values are undefined... */
+       if (rs_tex_count == 0 && col_interp_nr == 0) {
+               r300->hw.rr.cmd[R300_RR_INST_0] |= R300_RS_INST_COL_ID(0) | R300_RS_INST_COL_CN_WRITE | (fp_reg++ << R300_RS_INST_COL_ADDR_SHIFT);
+               col_interp_nr++;
+       }
+
+       r300->hw.rc.cmd[1] = 0 | (rs_tex_count << R300_IT_COUNT_SHIFT)
+         | (col_interp_nr << R300_IC_COUNT_SHIFT)
+         | R300_HIRES_EN;
+
+       assert(high_rr >= 0);
+       r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(R300_RS_INST_0, high_rr + 1);
+       r300->hw.rc.cmd[2] = high_rr;
+
+       if (InputsRead)
+               WARN_ONCE("Don't know how to satisfy InputsRead=0x%08x\n", InputsRead);
+}
+
+static void r500SetupRSUnit(GLcontext * ctx)
+{
+       r300ContextPtr r300 = R300_CONTEXT(ctx);
+       /* I'm still unsure if these are needed */
+       GLuint interp_col[8];
+       union r300_outputs_written OutputsWritten;
+        TNLcontext *tnl = TNL_CONTEXT(ctx);
+       struct vertex_buffer *VB = &tnl->vb;
+       GLuint InputsRead;
+       int fp_reg, high_rr;
+       int rs_col_count = 0;
+       int in_texcoords, col_interp_nr;
+       int i, count;
+
+       memset(interp_col, 0, sizeof(interp_col));
+       if (hw_tcl_on)
+               OutputsWritten.vp_outputs = CURRENT_VERTEX_SHADER(ctx)->key.OutputsWritten;
+       else
+               RENDERINPUTS_COPY(OutputsWritten.index_bitset, r300->state.render_inputs_bitset);
+
+       if (ctx->FragmentProgram._Current)
+               InputsRead = ctx->FragmentProgram._Current->Base.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);
+
+       fp_reg = col_interp_nr = high_rr = in_texcoords = 0;
+
+       r300->hw.rr.cmd[R300_RR_INST_1] = 0;
+
+       if (InputsRead & FRAG_BIT_WPOS) {
+               for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
+                       if (!(InputsRead & (FRAG_BIT_TEX0 << i)))
+                               break;
+
+               if (i == ctx->Const.MaxTextureUnits) {
+                       fprintf(stderr, "\tno free texcoord found...\n");
+                       _mesa_exit(-1);
+               }
+
+               InputsRead |= (FRAG_BIT_TEX0 << i);
+               InputsRead &= ~FRAG_BIT_WPOS;
+       }
+
+       if (InputsRead & FRAG_BIT_COL0) {
+               count = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->size;
+               interp_col[0] |= R500_RS_COL_PTR(rs_col_count);
+               if (count == 3)
+                       interp_col[0] |= R500_RS_COL_FMT(R300_RS_COL_FMT_RGB1);
+               rs_col_count += count;
+       }
+       else
+               interp_col[0] = R500_RS_COL_FMT(R300_RS_COL_FMT_0001);
+
+       if (InputsRead & FRAG_BIT_COL1) {
+               count = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->size;
+               interp_col[1] |= R500_RS_COL_PTR(1);
+               if (count == 3)
+                       interp_col[1] |= R500_RS_COL_FMT(R300_RS_COL_FMT_RGB0);
+               rs_col_count += count;
+       }
+
+       for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
+               GLuint swiz = 0;
+
+               /* with TCL we always seem to route 4 components */
+               if (InputsRead & (FRAG_BIT_TEX0 << i)) {
+
+                 if (hw_tcl_on)
+                   count = 4;
+                 else
+                   count = VB->AttribPtr[_TNL_ATTRIB_TEX(i)]->size;
+
+                 /* always have on texcoord */
+                 swiz |= in_texcoords++ << R500_RS_IP_TEX_PTR_S_SHIFT;
+                 if (count >= 2)
+                   swiz |= in_texcoords++ << R500_RS_IP_TEX_PTR_T_SHIFT;
+                 else
+                   swiz |= R500_RS_IP_PTR_K0 << R500_RS_IP_TEX_PTR_T_SHIFT;
+
+                 if (count >= 3)
+                   swiz |= in_texcoords++ << R500_RS_IP_TEX_PTR_R_SHIFT;
+                 else
+                   swiz |= R500_RS_IP_PTR_K0 << R500_RS_IP_TEX_PTR_R_SHIFT;
+
+                 if (count == 4)
+                   swiz |= in_texcoords++ << R500_RS_IP_TEX_PTR_Q_SHIFT;
+                 else
+                   swiz |= R500_RS_IP_PTR_K1 << R500_RS_IP_TEX_PTR_Q_SHIFT;
+
+               } else
+                  swiz = (R500_RS_IP_PTR_K0 << R500_RS_IP_TEX_PTR_S_SHIFT) |
+                         (R500_RS_IP_PTR_K0 << R500_RS_IP_TEX_PTR_T_SHIFT) |
+                         (R500_RS_IP_PTR_K0 << R500_RS_IP_TEX_PTR_R_SHIFT) |
+                         (R500_RS_IP_PTR_K1 << R500_RS_IP_TEX_PTR_Q_SHIFT);
+
+               r300->hw.ri.cmd[R300_RI_INTERP_0 + i] = interp_col[i] | swiz;
+
+               r300->hw.rr.cmd[R300_RR_INST_0 + fp_reg] = 0;
+               if (InputsRead & (FRAG_BIT_TEX0 << i)) {
+                       //assert(r300->state.texture.tc_count != 0);
+                       r300->hw.rr.cmd[R300_RR_INST_0 + fp_reg] |= R500_RS_INST_TEX_CN_WRITE | i       /* source INTERP */
+                           | (fp_reg << R500_RS_INST_TEX_ADDR_SHIFT);
+                       high_rr = fp_reg;
+
+                       /* Passing invalid data here can lock the GPU. */
+                       if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten, VERT_RESULT_TEX0 + i, _TNL_ATTRIB_TEX(i))) {
+                               InputsRead &= ~(FRAG_BIT_TEX0 << i);
+                               fp_reg++;
+                       } else {
+                               WARN_ONCE("fragprog wants coords for tex%d, vp doesn't provide them!\n", i);
+                       }
                }
        }
 
        if (InputsRead & FRAG_BIT_COL0) {
                if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten, VERT_RESULT_COL0, _TNL_ATTRIB_COLOR0)) {
-                       r300->hw.rr.cmd[R300_RR_ROUTE_0] |= 0 | R300_RS_ROUTE_0_COLOR | (fp_reg++ << R300_RS_ROUTE_0_COLOR_DEST_SHIFT);
+                       r300->hw.rr.cmd[R300_RR_INST_0] |= R500_RS_INST_COL_CN_WRITE | (fp_reg++ << R500_RS_INST_COL_ADDR_SHIFT);
                        InputsRead &= ~FRAG_BIT_COL0;
                        col_interp_nr++;
                } else {
@@ -1483,7 +1888,7 @@ static void r300SetupRSUnit(GLcontext * ctx)
 
        if (InputsRead & FRAG_BIT_COL1) {
                if (R300_OUTPUTS_WRITTEN_TEST(OutputsWritten, VERT_RESULT_COL1, _TNL_ATTRIB_COLOR1)) {
-                       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);
+                       r300->hw.rr.cmd[R300_RR_INST_1] |= (1 << 12) | R500_RS_INST_COL_CN_WRITE |  (fp_reg++ << R500_RS_INST_COL_ADDR_SHIFT);
                        InputsRead &= ~FRAG_BIT_COL1;
                        if (high_rr < 1)
                                high_rr = 1;
@@ -1495,22 +1900,25 @@ static void r300SetupRSUnit(GLcontext * ctx)
 
        /* Need at least one. This might still lock as the values are undefined... */
        if (in_texcoords == 0 && col_interp_nr == 0) {
-               r300->hw.rr.cmd[R300_RR_ROUTE_0] |= 0 | R300_RS_ROUTE_0_COLOR | (fp_reg++ << R300_RS_ROUTE_0_COLOR_DEST_SHIFT);
+               r300->hw.rr.cmd[R300_RR_INST_0] |= 0 | R500_RS_INST_COL_CN_WRITE | (fp_reg++ << R500_RS_INST_COL_ADDR_SHIFT);
                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;
+       r300->hw.rc.cmd[1] = 0 | (in_texcoords << R300_IT_COUNT_SHIFT)
+         | (col_interp_nr << R300_IC_COUNT_SHIFT)
+         | R300_HIRES_EN;
 
        assert(high_rr >= 0);
-       r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(R300_RS_ROUTE_0, high_rr + 1);
+       r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(R500_RS_INST_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);
 }
 
+
+
+
 #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; \
@@ -1518,7 +1926,7 @@ static void r300SetupRSUnit(GLcontext * ctx)
        if(_nc>_p->vpu.count)_p->vpu.count=_nc;\
        }while(0)
 
-static inline void r300SetupVertexProgramFragment(r300ContextPtr r300, int dest, struct r300_vertex_shader_fragment *vsf)
+static INLINE void r300SetupVertexProgramFragment(r300ContextPtr r300, int dest, struct r300_vertex_shader_fragment *vsf)
 {
        int i;
 
@@ -1556,10 +1964,68 @@ static inline void r300SetupVertexProgramFragment(r300ContextPtr r300, int dest,
        }
 }
 
+#define MIN3(a, b, c)  ((a) < (b) ? MIN2(a, c) : MIN2(b, c))
+
+
+static void r300VapCntl(r300ContextPtr rmesa, GLuint input_count,
+                       GLuint output_count, GLuint temp_count)
+{
+    int vtx_mem_size;
+    int pvs_num_slots;
+    int pvs_num_cntrls;
+
+    /* Flush PVS engine before changing PVS_NUM_SLOTS, PVS_NUM_CNTRLS.
+     * See r500 docs 6.5.2 - done in emit */
+
+    /* avoid division by zero */
+    if (input_count == 0) input_count = 1;
+    if (output_count == 0) output_count = 1;
+    if (temp_count == 0) temp_count = 1;
+
+    if (rmesa->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515)
+       vtx_mem_size = 128;
+    else
+       vtx_mem_size = 72;
+
+    pvs_num_slots = MIN3(10, vtx_mem_size/input_count, vtx_mem_size/output_count);
+    pvs_num_cntrls = MIN2(6, vtx_mem_size/temp_count);
+
+    R300_STATECHANGE(rmesa, vap_cntl);
+    if (rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL) {
+       rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] =
+           (pvs_num_slots << R300_PVS_NUM_SLOTS_SHIFT) |
+           (pvs_num_cntrls << R300_PVS_NUM_CNTLRS_SHIFT) |
+           (12 << R300_VF_MAX_VTX_NUM_SHIFT);
+       if (rmesa->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515)
+           rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= R500_TCL_STATE_OPTIMIZATION;
+    } else
+       /* not sure about non-tcl */
+       rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] = ((10 << R300_PVS_NUM_SLOTS_SHIFT) |
+                                   (5 << R300_PVS_NUM_CNTLRS_SHIFT) |
+                                   (5 << R300_VF_MAX_VTX_NUM_SHIFT));
+
+    if (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV515)
+       rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (2 << R300_PVS_NUM_FPUS_SHIFT);
+    else if ((rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV530) ||
+            (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV560) ||
+            (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV570))
+       rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (5 << R300_PVS_NUM_FPUS_SHIFT);
+    else if ((rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV410) ||
+            (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R420))
+       rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (6 << R300_PVS_NUM_FPUS_SHIFT);
+    else if ((rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R520) ||
+            (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R580))
+       rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (8 << R300_PVS_NUM_FPUS_SHIFT);
+    else
+       rmesa->hw.vap_cntl.cmd[R300_VAP_CNTL_INSTR] |= (4 << R300_PVS_NUM_FPUS_SHIFT);
+
+}
+
 static void r300SetupDefaultVertexProgram(r300ContextPtr rmesa)
 {
        struct r300_vertex_shader_state *prog = &(rmesa->state.vertex_shader);
        GLuint o_reg = 0;
+       GLuint i_reg = 0;
        int i;
        int inst_count = 0;
        int param_count = 0;
@@ -1567,31 +2033,42 @@ static void r300SetupDefaultVertexProgram(r300ContextPtr rmesa)
 
        for (i = VERT_ATTRIB_POS; i < VERT_ATTRIB_MAX; i++) {
                if (rmesa->state.sw_tcl_inputs[i] != -1) {
-                       prog->program.body.i[program_end + 0] = EASY_VSF_OP(MUL, o_reg++, ALL, RESULT);
-                       prog->program.body.i[program_end + 1] = VSF_REG(rmesa->state.sw_tcl_inputs[i]);
-                       prog->program.body.i[program_end + 2] = VSF_ATTR_UNITY(rmesa->state.sw_tcl_inputs[i]);
-                       prog->program.body.i[program_end + 3] = VSF_UNITY(rmesa->state.sw_tcl_inputs[i]);
+                       prog->program.body.i[program_end + 0] = PVS_OP_DST_OPERAND(VE_MULTIPLY, GL_FALSE, GL_FALSE, o_reg++, VSF_FLAG_ALL, PVS_DST_REG_OUT);
+                       prog->program.body.i[program_end + 1] = PVS_SRC_OPERAND(rmesa->state.sw_tcl_inputs[i], PVS_SRC_SELECT_X, PVS_SRC_SELECT_Y, PVS_SRC_SELECT_Z, PVS_SRC_SELECT_W, PVS_SRC_REG_INPUT, VSF_FLAG_NONE);
+                       prog->program.body.i[program_end + 2] = PVS_SRC_OPERAND(rmesa->state.sw_tcl_inputs[i], PVS_SRC_SELECT_FORCE_1, PVS_SRC_SELECT_FORCE_1, PVS_SRC_SELECT_FORCE_1, PVS_SRC_SELECT_FORCE_1, PVS_SRC_REG_INPUT, VSF_FLAG_NONE);
+                       prog->program.body.i[program_end + 3] = PVS_SRC_OPERAND(rmesa->state.sw_tcl_inputs[i], PVS_SRC_SELECT_FORCE_1, PVS_SRC_SELECT_FORCE_1, PVS_SRC_SELECT_FORCE_1, PVS_SRC_SELECT_FORCE_1, PVS_SRC_REG_INPUT, VSF_FLAG_NONE);
                        program_end += 4;
+                       i_reg++;
                }
        }
 
        prog->program.length = program_end;
 
-       r300SetupVertexProgramFragment(rmesa, R300_PVS_UPLOAD_PROGRAM,
+       r300SetupVertexProgramFragment(rmesa, R300_PVS_CODE_START,
                                       &(prog->program));
        inst_count = (prog->program.length / 4) - 1;
 
+       r300VapCntl(rmesa, i_reg, o_reg, 0);
+
        R300_STATECHANGE(rmesa, pvs);
        rmesa->hw.pvs.cmd[R300_PVS_CNTL_1] =
-           (0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) |
-           (inst_count << R300_PVS_CNTL_1_POS_END_SHIFT) |
-           (inst_count << R300_PVS_CNTL_1_PROGRAM_END_SHIFT);
+           (0 << R300_PVS_FIRST_INST_SHIFT) |
+           (inst_count << R300_PVS_XYZW_VALID_INST_SHIFT) |
+           (inst_count << R300_PVS_LAST_INST_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);
+           (0 << R300_PVS_CONST_BASE_OFFSET_SHIFT) |
+           (param_count << R300_PVS_MAX_CONST_ADDR_SHIFT);
        rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] =
-           (inst_count << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT) |
-           (inst_count << R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT);
+           (inst_count << R300_PVS_LAST_VTX_SRC_INST_SHIFT);
+}
+
+static int bit_count (int x)
+{
+    x = ((x & 0xaaaaaaaaU) >> 1) + (x & 0x55555555U);
+    x = ((x & 0xccccccccU) >> 2) + (x & 0x33333333U);
+    x = (x >> 16) + (x & 0xffff);
+    x = ((x & 0xf0f0) >> 4) + (x & 0x0f0f);
+    return (x >> 8) + (x & 0x00ff);
 }
 
 static void r300SetupRealVertexProgram(r300ContextPtr rmesa)
@@ -1612,20 +2089,22 @@ static void r300SetupRealVertexProgram(r300ContextPtr rmesa)
        bump_vpu_count(rmesa->hw.vpp.cmd, param_count);
        param_count /= 4;
 
-       r300SetupVertexProgramFragment(rmesa, R300_PVS_UPLOAD_PROGRAM, &(prog->program));
+       r300SetupVertexProgramFragment(rmesa, R300_PVS_CODE_START, &(prog->program));
        inst_count = (prog->program.length / 4) - 1;
 
+       r300VapCntl(rmesa, bit_count(prog->key.InputsRead),
+                   bit_count(prog->key.OutputsWritten), prog->num_temporaries);
+
        R300_STATECHANGE(rmesa, pvs);
        rmesa->hw.pvs.cmd[R300_PVS_CNTL_1] =
-         (0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) |
-         (inst_count << R300_PVS_CNTL_1_POS_END_SHIFT) |
-         (inst_count << R300_PVS_CNTL_1_PROGRAM_END_SHIFT);
+         (0 << R300_PVS_FIRST_INST_SHIFT) |
+         (inst_count << R300_PVS_XYZW_VALID_INST_SHIFT) |
+         (inst_count << R300_PVS_LAST_INST_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);
+         (0 << R300_PVS_CONST_BASE_OFFSET_SHIFT) |
+         (param_count << R300_PVS_MAX_CONST_ADDR_SHIFT);
        rmesa->hw.pvs.cmd[R300_PVS_CNTL_3] =
-         (inst_count << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT) |
-         (inst_count << R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT);
+         (inst_count << R300_PVS_LAST_VTX_SRC_INST_SHIFT);
 }
 
 static void r300SetupVertexProgram(r300ContextPtr rmesa)
@@ -1648,13 +2127,6 @@ static void r300SetupVertexProgram(r300ContextPtr rmesa)
                r300SetupDefaultVertexProgram(rmesa);
        }
 
-
-       /* FIXME: 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
 }
 
 /**
@@ -1664,84 +2136,54 @@ static void r300SetupVertexProgram(r300ContextPtr rmesa)
  */
 static void r300Enable(GLcontext * ctx, GLenum cap, GLboolean state)
 {
-       r300ContextPtr r300 = R300_CONTEXT(ctx);
-
        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:
+               /* empty */
                break;
-
        case GL_FOG:
-               R300_STATECHANGE(r300, fogs);
-               if (state) {
-                       r300->hw.fogs.cmd[R300_FOGS_STATE] |= R300_FOG_ENABLE;
-
-                       r300Fogfv(ctx, GL_FOG_MODE, NULL);
-                       r300Fogfv(ctx, GL_FOG_DENSITY, &ctx->Fog.Density);
-                       r300Fogfv(ctx, GL_FOG_START, &ctx->Fog.Start);
-                       r300Fogfv(ctx, GL_FOG_END, &ctx->Fog.End);
-                       r300Fogfv(ctx, GL_FOG_COLOR, ctx->Fog.Color);
-               } else {
-                       r300->hw.fogs.cmd[R300_FOGS_STATE] &= ~R300_FOG_ENABLE;
-               }
-
+               r300SetFogState(ctx, state);
                break;
-
        case GL_ALPHA_TEST:
                r300SetAlphaState(ctx);
                break;
-
-       case GL_BLEND:
        case GL_COLOR_LOGIC_OP:
+               r300SetLogicOpState(ctx);
+               /* fall-through, because logic op overrides blending */
+       case GL_BLEND:
                r300SetBlendState(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:
+               r300SetClipPlaneState(ctx, cap, state);
+               break;
        case GL_DEPTH_TEST:
                r300SetDepthState(ctx);
                break;
-
        case GL_STENCIL_TEST:
-               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
-               }
+               r300SetStencilState(ctx, state);
                break;
-
        case GL_CULL_FACE:
                r300UpdateCulling(ctx);
                break;
-
        case GL_POLYGON_OFFSET_POINT:
        case GL_POLYGON_OFFSET_LINE:
        case GL_POLYGON_OFFSET_FILL:
-               R300_STATECHANGE(r300, occlusion_cntl);
-               if (state) {
-                       r300->hw.occlusion_cntl.cmd[1] |= (3 << 0);
-               } else {
-                       r300->hw.occlusion_cntl.cmd[1] &= ~(3 << 0);
-               }
+               r300SetPolygonOffsetState(ctx, state);
                break;
        default:
                radeonEnable(ctx, cap, state);
-               return;
+               break;
        }
 }
 
@@ -1784,15 +2226,11 @@ static void r300ResetHwState(r300ContextPtr r300)
        r300UpdateTextureState(ctx);
 
        r300SetBlendState(ctx);
+       r300SetLogicOpState(ctx);
 
        r300AlphaFunc(ctx, ctx->Color.AlphaFunc, ctx->Color.AlphaRef);
        r300Enable(ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled);
 
-       if (!has_tcl)
-               r300->hw.vap_cntl.cmd[1] = 0x0014045a;
-       else
-               r300->hw.vap_cntl.cmd[1] = 0x0030045A;  //0x0030065a /* Dangerous */
-
        r300->hw.vte.cmd[1] = R300_VPORT_X_SCALE_ENA
            | R300_VPORT_X_OFFSET_ENA
            | R300_VPORT_Y_SCALE_ENA
@@ -1801,8 +2239,8 @@ static void r300ResetHwState(r300ContextPtr r300)
            | 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;
+       r300->hw.vap_vf_max_vtx_indx.cmd[1] = 0x00FFFFFF;
+       r300->hw.vap_vf_max_vtx_indx.cmd[2] = 0x00000000;
 
 #ifdef MESA_LITTLE_ENDIAN
        r300->hw.vap_cntl_status.cmd[1] = R300_VC_NO_SWAP;
@@ -1814,54 +2252,53 @@ static void r300ResetHwState(r300ContextPtr r300)
        if (!has_tcl)
                r300->hw.vap_cntl_status.cmd[1] |= R300_VAP_TCL_BYPASS;
 
-       r300->hw.unk21DC.cmd[1] = 0xAAAAAAAA;
-
-       r300->hw.unk221C.cmd[1] = R300_221C_NORMAL;
-
-       r300->hw.vap_clip.cmd[1] = r300PackFloat32(1.0); /* X */
-       r300->hw.vap_clip.cmd[2] = r300PackFloat32(1.0); /* X */
-       r300->hw.vap_clip.cmd[3] = r300PackFloat32(1.0); /* Y */
-       r300->hw.vap_clip.cmd[4] = r300PackFloat32(1.0); /* Y */
+       r300->hw.vap_psc_sgn_norm_cntl.cmd[1] = 0xAAAAAAAA;
 
        /* XXX: Other families? */
        if (has_tcl) {
+               r300->hw.vap_clip_cntl.cmd[1] = R300_PS_UCP_MODE_DIST_COP;
+
+               r300->hw.vap_clip.cmd[1] = r300PackFloat32(1.0); /* X */
+               r300->hw.vap_clip.cmd[2] = r300PackFloat32(1.0); /* X */
+               r300->hw.vap_clip.cmd[3] = r300PackFloat32(1.0); /* Y */
+               r300->hw.vap_clip.cmd[4] = r300PackFloat32(1.0); /* Y */
+
                switch (r300->radeon.radeonScreen->chip_family) {
                case CHIP_FAMILY_R300:
-                       r300->hw.unk2288.cmd[1] = R300_2288_R300;
+                       r300->hw.vap_pvs_vtx_timeout_reg.cmd[1] = R300_2288_R300;
                        break;
                default:
-                       r300->hw.unk2288.cmd[1] = R300_2288_RV350;
+                       r300->hw.vap_pvs_vtx_timeout_reg.cmd[1] = R300_2288_RV350;
                        break;
                }
        }
 
        r300->hw.gb_enable.cmd[1] = R300_GB_POINT_STUFF_ENABLE
            | R300_GB_LINE_STUFF_ENABLE
-           | R300_GB_TRIANGLE_STUFF_ENABLE /*| R300_GB_UNK31 */ ;
+           | R300_GB_TRIANGLE_STUFF_ENABLE;
 
        r300->hw.gb_misc.cmd[R300_GB_MISC_MSPOS_0] = 0x66666666;
        r300->hw.gb_misc.cmd[R300_GB_MISC_MSPOS_1] = 0x06666666;
 
-       /* XXX: Other families? */
        r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] =
-           R300_GB_TILE_ENABLE | R300_GB_TILE_SIZE_16;
-       switch (r300->radeon.radeonScreen->chip_family) {
-       case CHIP_FAMILY_R300:
-       case CHIP_FAMILY_R350:
+           R300_GB_TILE_ENABLE | R300_GB_TILE_SIZE_16 /*| R300_GB_SUBPIXEL_1_16*/;
+       switch (r300->radeon.radeonScreen->num_gb_pipes) {
+       case 1:
+       default:
                r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] |=
-                   R300_GB_TILE_PIPE_COUNT_R300;
+                   R300_GB_TILE_PIPE_COUNT_RV300;
                break;
-       case CHIP_FAMILY_RV410:
+       case 2:
                r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] |=
-                   R300_GB_TILE_PIPE_COUNT_RV410;
+                   R300_GB_TILE_PIPE_COUNT_R300;
                break;
-       case CHIP_FAMILY_R420:
+       case 3:
                r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] |=
-                   R300_GB_TILE_PIPE_COUNT_R420;
+                   R300_GB_TILE_PIPE_COUNT_R420_3P;
                break;
-       default:
+       case 4:
                r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] |=
-                   R300_GB_TILE_PIPE_COUNT_RV300;
+                   R300_GB_TILE_PIPE_COUNT_R420;
                break;
        }
 
@@ -1869,26 +2306,26 @@ static void r300ResetHwState(r300ContextPtr r300)
        r300->hw.gb_misc.cmd[R300_GB_MISC_SELECT] = R300_GB_FOG_SELECT_1_1_W;
 
        /* XXX: Enable anti-aliasing? */
-       r300->hw.gb_misc.cmd[R300_GB_MISC_AA_CONFIG] = R300_AA_DISABLE;
+       r300->hw.gb_misc.cmd[R300_GB_MISC_AA_CONFIG] = GB_AA_CONFIG_AA_DISABLE;
 
-       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.ga_point_s0.cmd[1] = r300PackFloat32(0.0);
+       r300->hw.ga_point_s0.cmd[2] = r300PackFloat32(0.0);
+       r300->hw.ga_point_s0.cmd[3] = r300PackFloat32(1.0);
+       r300->hw.ga_point_s0.cmd[4] = r300PackFloat32(1.0);
 
-       r300->hw.unk4214.cmd[1] = 0x00050005;
+       r300->hw.ga_triangle_stipple.cmd[1] = 0x00050005;
 
        r300PointSize(ctx, 1.0);
 
-       r300->hw.unk4230.cmd[1] = 0x18000006;
-       r300->hw.unk4230.cmd[2] = 0x00020006;
-       r300->hw.unk4230.cmd[3] = r300PackFloat32(1.0 / 192.0);
+       r300->hw.ga_point_minmax.cmd[1] = 0x18000006;
+       r300->hw.ga_point_minmax.cmd[2] = 0x00020006;
+       r300->hw.ga_point_minmax.cmd[3] = r300PackFloat32(1.0 / 192.0);
 
        r300LineWidth(ctx, 1.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.ga_line_stipple.cmd[1] = 0;
+       r300->hw.ga_line_stipple.cmd[2] = r300PackFloat32(0.0);
+       r300->hw.ga_line_stipple.cmd[3] = r300PackFloat32(1.0);
 
        r300ShadeModel(ctx, ctx->Light.ShadeModel);
 
@@ -1902,19 +2339,23 @@ static void r300ResetHwState(r300ContextPtr r300)
        r300Enable(ctx, GL_POLYGON_OFFSET_LINE, ctx->Polygon.OffsetLine);
        r300Enable(ctx, GL_POLYGON_OFFSET_FILL, ctx->Polygon.OffsetFill);
 
-       r300->hw.unk42C0.cmd[1] = 0x4B7FFFFF;
-       r300->hw.unk42C0.cmd[2] = 0x00000000;
+       r300->hw.su_depth_scale.cmd[1] = 0x4B7FFFFF;
+       r300->hw.su_depth_scale.cmd[2] = 0x00000000;
 
-       r300->hw.unk43A4.cmd[1] = 0x0000001C;
-       r300->hw.unk43A4.cmd[2] = 0x2DA49525;
+       r300->hw.sc_hyperz.cmd[1] = 0x0000001C;
+       r300->hw.sc_hyperz.cmd[2] = 0x2DA49525;
 
-       r300->hw.unk43E8.cmd[1] = 0x00FFFFFF;
+       r300->hw.sc_screendoor.cmd[1] = 0x00FFFFFF;
 
-       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;
+       r300->hw.us_out_fmt.cmd[1] = R500_OUT_FMT_C4_8  |
+         R500_C0_SEL_B | R500_C1_SEL_G | R500_C2_SEL_R | R500_C3_SEL_A;
+       r300->hw.us_out_fmt.cmd[2] = R500_OUT_FMT_UNUSED |
+         R500_C0_SEL_B | R500_C1_SEL_G | R500_C2_SEL_R | R500_C3_SEL_A;
+       r300->hw.us_out_fmt.cmd[3] = R500_OUT_FMT_UNUSED |
+         R500_C0_SEL_B | R500_C1_SEL_G | R500_C2_SEL_R | R500_C3_SEL_A;
+       r300->hw.us_out_fmt.cmd[4] = R500_OUT_FMT_UNUSED |
+         R500_C0_SEL_B | R500_C1_SEL_G | R500_C2_SEL_R | R500_C3_SEL_A;
+       r300->hw.us_out_fmt.cmd[5] = R300_W_FMT_W24;
 
        r300Enable(ctx, GL_FOG, ctx->Fog.Enabled);
        r300Fogfv(ctx, GL_FOG_MODE, NULL);
@@ -1924,9 +2365,9 @@ static void r300ResetHwState(r300ContextPtr r300)
        r300Fogfv(ctx, GL_FOG_COLOR, ctx->Fog.Color);
        r300Fogfv(ctx, GL_FOG_COORDINATE_SOURCE_EXT, NULL);
 
-       r300->hw.unk4BD8.cmd[1] = 0;
+       r300->hw.fg_depth_src.cmd[1] = 0;
 
-       r300->hw.unk4E00.cmd[1] = 0;
+       r300->hw.rb3d_cctl.cmd[1] = 0;
 
        r300BlendColor(ctx, ctx->Color.BlendColor);
 
@@ -1944,20 +2385,20 @@ static void r300ResetHwState(r300ContextPtr r300)
        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.rb3d_dither_ctl.cmd[1] = 0;
+       r300->hw.rb3d_dither_ctl.cmd[2] = 0;
+       r300->hw.rb3d_dither_ctl.cmd[3] = 0;
+       r300->hw.rb3d_dither_ctl.cmd[4] = 0;
+       r300->hw.rb3d_dither_ctl.cmd[5] = 0;
+       r300->hw.rb3d_dither_ctl.cmd[6] = 0;
+       r300->hw.rb3d_dither_ctl.cmd[7] = 0;
+       r300->hw.rb3d_dither_ctl.cmd[8] = 0;
+       r300->hw.rb3d_dither_ctl.cmd[9] = 0;
 
-       r300->hw.unk4E88.cmd[1] = 0;
+       r300->hw.rb3d_aaresolve_ctl.cmd[1] = 0;
 
-       r300->hw.unk4EA0.cmd[1] = 0x00000000;
-       r300->hw.unk4EA0.cmd[2] = 0xffffffff;
+       r300->hw.rb3d_discard_src_pixel_lte_threshold.cmd[1] = 0x00000000;
+       r300->hw.rb3d_discard_src_pixel_lte_threshold.cmd[2] = 0xffffffff;
 
        r300->hw.zb.cmd[R300_ZB_OFFSET] =
            r300->radeon.radeonScreen->depthOffset +
@@ -1966,22 +2407,40 @@ static void r300ResetHwState(r300ContextPtr r300)
 
        if (r300->radeon.sarea->tiling_enabled) {
                /* XXX: Turn off when clearing buffers ? */
-               r300->hw.zb.cmd[R300_ZB_PITCH] |= R300_DEPTH_TILE_ENABLE;
+               r300->hw.zb.cmd[R300_ZB_PITCH] |= R300_DEPTHMACROTILE_ENABLE;
 
                if (ctx->Visual.depthBits == 24)
                        r300->hw.zb.cmd[R300_ZB_PITCH] |=
-                           R300_DEPTH_MICROTILE_ENABLE;
+                           R300_DEPTHMICROTILE_TILED;
        }
 
-       r300->hw.unk4F28.cmd[1] = 0;
+       r300->hw.zb_depthclearvalue.cmd[1] = 0;
+
+       switch (ctx->Visual.depthBits) {
+       case 16:
+               r300->hw.zstencil_format.cmd[1] = R300_DEPTHFORMAT_16BIT_INT_Z;
+               break;
+       case 24:
+               r300->hw.zstencil_format.cmd[1] = R300_DEPTHFORMAT_24BIT_INT_Z_8BIT_STENCIL;
+               break;
+       default:
+               fprintf(stderr, "Error: Unsupported depth %d... exiting\n", ctx->Visual.depthBits);
+               _mesa_exit(-1);
+       }
+
+       r300->hw.zstencil_format.cmd[2] = R300_ZTOP_DISABLE;
+       r300->hw.zstencil_format.cmd[3] = 0x00000003;
+       r300->hw.zstencil_format.cmd[4] = 0x00000000;
+       r300SetEarlyZState(ctx);
 
        r300->hw.unk4F30.cmd[1] = 0;
        r300->hw.unk4F30.cmd[2] = 0;
 
-       r300->hw.unk4F44.cmd[1] = 0;
+       r300->hw.zb_hiz_offset.cmd[1] = 0;
 
-       r300->hw.unk4F54.cmd[1] = 0;
+       r300->hw.zb_hiz_pitch.cmd[1] = 0;
 
+       r300VapCntl(r300, 0, 0, 0);
        if (has_tcl) {
                r300->hw.vps.cmd[R300_VPS_ZERO_0] = 0;
                r300->hw.vps.cmd[R300_VPS_ZERO_1] = 0;
@@ -2027,17 +2486,40 @@ void r300UpdateShaders(r300ContextPtr rmesa)
                        hw_tcl_on = future_hw_tcl_on = 0;
                        r300ResetHwState(rmesa);
 
+                       r300UpdateStateParameters(ctx, _NEW_PROGRAM);
                        return;
                }
-               r300UpdateStateParameters(ctx, _NEW_PROGRAM);
        }
+       r300UpdateStateParameters(ctx, _NEW_PROGRAM);
 }
 
+static const GLfloat *get_fragmentprogram_constant(GLcontext *ctx,
+       struct gl_program *program, struct prog_src_register srcreg)
+{
+       static const GLfloat dummy[4] = { 0, 0, 0, 0 };
+
+       switch(srcreg.File) {
+       case PROGRAM_LOCAL_PARAM:
+               return program->LocalParams[srcreg.Index];
+       case PROGRAM_ENV_PARAM:
+               return ctx->FragmentProgram.Parameters[srcreg.Index];
+       case PROGRAM_STATE_VAR:
+       case PROGRAM_NAMED_PARAM:
+       case PROGRAM_CONSTANT:
+               return program->Parameters->ParameterValues[srcreg.Index];
+       default:
+               _mesa_problem(ctx, "get_fragmentprogram_constant: Unknown\n");
+               return dummy;
+       }
+}
+
+
 static void r300SetupPixelShader(r300ContextPtr rmesa)
 {
        GLcontext *ctx = rmesa->radeon.glCtx;
        struct r300_fragment_program *fp = (struct r300_fragment_program *)
            (char *)ctx->FragmentProgram._Current;
+       struct r300_fragment_program_code *code;
        int i, k;
 
        if (!fp)                /* should only happenen once, just after context is created */
@@ -2049,76 +2531,174 @@ static void r300SetupPixelShader(r300ContextPtr rmesa)
                        __FUNCTION__);
                return;
        }
+       code = &fp->code;
 
-       R300_STATECHANGE(rmesa, fpi[0]);
-       rmesa->hw.fpi[0].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR0_0, fp->alu_end + 1);
-       for (i = 0; i <= fp->alu_end; i++) {
-               rmesa->hw.fpi[0].cmd[R300_FPI_INSTR_0 + i] = fp->alu.inst[i].inst0;
-       }
+       r300SetupTextures(ctx);
 
+       R300_STATECHANGE(rmesa, fpi[0]);
        R300_STATECHANGE(rmesa, fpi[1]);
-       rmesa->hw.fpi[1].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR1_0, fp->alu_end + 1);
-       for (i = 0; i <= fp->alu_end; i++) {
-               rmesa->hw.fpi[1].cmd[R300_FPI_INSTR_0 + i] = fp->alu.inst[i].inst1;
-       }
-
        R300_STATECHANGE(rmesa, fpi[2]);
-       rmesa->hw.fpi[2].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR2_0, fp->alu_end + 1);
-       for (i = 0; i <= fp->alu_end; i++) {
-               rmesa->hw.fpi[2].cmd[R300_FPI_INSTR_0 + i] = fp->alu.inst[i].inst2;
-       }
-
        R300_STATECHANGE(rmesa, fpi[3]);
-       rmesa->hw.fpi[3].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR3_0, fp->alu_end + 1);
-       for (i = 0; i <= fp->alu_end; i++) {
-               rmesa->hw.fpi[3].cmd[R300_FPI_INSTR_0 + i] = fp->alu.inst[i].inst3;
+       rmesa->hw.fpi[0].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_US_ALU_RGB_INST_0, code->alu.length);
+       rmesa->hw.fpi[1].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_US_ALU_RGB_ADDR_0, code->alu.length);
+       rmesa->hw.fpi[2].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_US_ALU_ALPHA_INST_0, code->alu.length);
+       rmesa->hw.fpi[3].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_US_ALU_ALPHA_ADDR_0, code->alu.length);
+       for (i = 0; i < code->alu.length; i++) {
+               rmesa->hw.fpi[0].cmd[R300_FPI_INSTR_0 + i] = code->alu.inst[i].inst0;
+               rmesa->hw.fpi[1].cmd[R300_FPI_INSTR_0 + i] = code->alu.inst[i].inst1;
+               rmesa->hw.fpi[2].cmd[R300_FPI_INSTR_0 + i] = code->alu.inst[i].inst2;
+               rmesa->hw.fpi[3].cmd[R300_FPI_INSTR_0 + i] = code->alu.inst[i].inst3;
        }
 
        R300_STATECHANGE(rmesa, fp);
-       rmesa->hw.fp.cmd[R300_FP_CNTL0] = fp->cur_node | (fp->first_node_has_tex << 3);
-       rmesa->hw.fp.cmd[R300_FP_CNTL1] = fp->max_temp_idx;
+       rmesa->hw.fp.cmd[R300_FP_CNTL0] = code->cur_node | (code->first_node_has_tex << 3);
+       rmesa->hw.fp.cmd[R300_FP_CNTL1] = code->max_temp_idx;
        rmesa->hw.fp.cmd[R300_FP_CNTL2] =
-         (fp->alu_offset << R300_PFS_CNTL_ALU_OFFSET_SHIFT) |
-         (fp->alu_end << R300_PFS_CNTL_ALU_END_SHIFT) |
-         (fp->tex_offset << R300_PFS_CNTL_TEX_OFFSET_SHIFT) |
-         (fp->tex_end << R300_PFS_CNTL_TEX_END_SHIFT);
+         (0 << R300_PFS_CNTL_ALU_OFFSET_SHIFT) |
+         ((code->alu.length-1) << R300_PFS_CNTL_ALU_END_SHIFT) |
+         (0 << R300_PFS_CNTL_TEX_OFFSET_SHIFT) |
+         ((code->tex.length ? code->tex.length-1 : 0) << R300_PFS_CNTL_TEX_END_SHIFT);
        /* I just want to say, the way these nodes are stored.. weird.. */
-       for (i = 0, k = (4 - (fp->cur_node + 1)); i < 4; i++, k++) {
-               if (i < (fp->cur_node + 1)) {
+       for (i = 0, k = (4 - (code->cur_node + 1)); i < 4; i++, k++) {
+               if (i < (code->cur_node + 1)) {
                        rmesa->hw.fp.cmd[R300_FP_NODE0 + k] =
-                         (fp->node[i].alu_offset << R300_PFS_NODE_ALU_OFFSET_SHIFT) |
-                         (fp->node[i].alu_end << R300_PFS_NODE_ALU_END_SHIFT) |
-                         (fp->node[i].tex_offset << R300_PFS_NODE_TEX_OFFSET_SHIFT) |
-                         (fp->node[i].tex_end << R300_PFS_NODE_TEX_END_SHIFT) |
-                         fp->node[i].flags;
+                         (code->node[i].alu_offset << R300_ALU_START_SHIFT) |
+                         (code->node[i].alu_end << R300_ALU_SIZE_SHIFT) |
+                         (code->node[i].tex_offset << R300_TEX_START_SHIFT) |
+                         (code->node[i].tex_end << R300_TEX_SIZE_SHIFT) |
+                         code->node[i].flags;
                } else {
                        rmesa->hw.fp.cmd[R300_FP_NODE0 + (3 - i)] = 0;
                }
        }
 
        R300_STATECHANGE(rmesa, fpp);
-       rmesa->hw.fpp.cmd[R300_FPP_CMD_0] = cmdpacket0(R300_PFS_PARAM_0_X, fp->const_nr * 4);
-       for (i = 0; i < fp->const_nr; i++) {
-               rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 0] = r300PackFloat24(fp->constant[i][0]);
-               rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 1] = r300PackFloat24(fp->constant[i][1]);
-               rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 2] = r300PackFloat24(fp->constant[i][2]);
-               rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 3] = r300PackFloat24(fp->constant[i][3]);
+       rmesa->hw.fpp.cmd[R300_FPP_CMD_0] = cmdpacket0(R300_PFS_PARAM_0_X, code->const_nr * 4);
+       for (i = 0; i < code->const_nr; i++) {
+               const GLfloat *constant = get_fragmentprogram_constant(ctx,
+                       &fp->mesa_program.Base, code->constant[i]);
+               rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 0] = r300PackFloat24(constant[0]);
+               rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 1] = r300PackFloat24(constant[1]);
+               rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 2] = r300PackFloat24(constant[2]);
+               rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 3] = r300PackFloat24(constant[3]);
        }
 }
 
+#define bump_r500fp_count(ptr, new_count)   do{\
+       drm_r300_cmd_header_t* _p=((drm_r300_cmd_header_t*)(ptr));\
+       int _nc=(new_count)/6; \
+       assert(_nc < 256); \
+       if(_nc>_p->r500fp.count)_p->r500fp.count=_nc;\
+} while(0)
+
+#define bump_r500fp_const_count(ptr, new_count)   do{\
+       drm_r300_cmd_header_t* _p=((drm_r300_cmd_header_t*)(ptr));\
+       int _nc=(new_count)/4; \
+       assert(_nc < 256); \
+       if(_nc>_p->r500fp.count)_p->r500fp.count=_nc;\
+} while(0)
+
+static void r500SetupPixelShader(r300ContextPtr rmesa)
+{
+       GLcontext *ctx = rmesa->radeon.glCtx;
+       struct r500_fragment_program *fp = (struct r500_fragment_program *)
+           (char *)ctx->FragmentProgram._Current;
+       int i;
+       struct r500_fragment_program_code *code;
+
+       if (!fp)                /* should only happenen once, just after context is created */
+               return;
+
+       ((drm_r300_cmd_header_t *) rmesa->hw.r500fp.cmd)->r500fp.count = 0;
+       ((drm_r300_cmd_header_t *) rmesa->hw.r500fp_const.cmd)->r500fp.count = 0;
+
+       r500TranslateFragmentShader(rmesa, fp);
+       if (!fp->translated) {
+               fprintf(stderr, "%s: No valid fragment shader, exiting\n",
+                       __FUNCTION__);
+               return;
+       }
+       code = &fp->code;
+
+       if (fp->mesa_program.FogOption != GL_NONE) {
+               /* Enable HW fog. Try not to squish GL context.
+                * (Anybody sane remembered to set glFog() opts first!) */
+               r300SetFogState(ctx, GL_TRUE);
+               ctx->Fog.Mode = fp->mesa_program.FogOption;
+               r300Fogfv(ctx, GL_FOG_MODE, NULL);
+       } else
+               /* Make sure HW is matching GL context. */
+               r300SetFogState(ctx, ctx->Fog.Enabled);
+
+       r300SetupTextures(ctx);
+
+       R300_STATECHANGE(rmesa, fp);
+       rmesa->hw.fp.cmd[R500_FP_PIXSIZE] = code->max_temp_idx;
+
+       rmesa->hw.fp.cmd[R500_FP_CODE_ADDR] =
+           R500_US_CODE_START_ADDR(code->inst_offset) |
+           R500_US_CODE_END_ADDR(code->inst_end);
+       rmesa->hw.fp.cmd[R500_FP_CODE_RANGE] =
+           R500_US_CODE_RANGE_ADDR(code->inst_offset) |
+           R500_US_CODE_RANGE_SIZE(code->inst_end);
+       rmesa->hw.fp.cmd[R500_FP_CODE_OFFSET] =
+           R500_US_CODE_OFFSET_ADDR(0); /* FIXME when we add flow control */
+
+       R300_STATECHANGE(rmesa, r500fp);
+       /* Emit our shader... */
+       for (i = 0; i < code->inst_end+1; i++) {
+               rmesa->hw.r500fp.cmd[i*6+1] = code->inst[i].inst0;
+               rmesa->hw.r500fp.cmd[i*6+2] = code->inst[i].inst1;
+               rmesa->hw.r500fp.cmd[i*6+3] = code->inst[i].inst2;
+               rmesa->hw.r500fp.cmd[i*6+4] = code->inst[i].inst3;
+               rmesa->hw.r500fp.cmd[i*6+5] = code->inst[i].inst4;
+               rmesa->hw.r500fp.cmd[i*6+6] = code->inst[i].inst5;
+       }
+
+       bump_r500fp_count(rmesa->hw.r500fp.cmd, (code->inst_end + 1) * 6);
+
+       R300_STATECHANGE(rmesa, r500fp_const);
+       for (i = 0; i < code->const_nr; i++) {
+               const GLfloat *constant = get_fragmentprogram_constant(ctx,
+                       &fp->mesa_program.Base, code->constant[i]);
+               rmesa->hw.r500fp_const.cmd[R300_FPP_PARAM_0 + 4 * i + 0] = r300PackFloat32(constant[0]);
+               rmesa->hw.r500fp_const.cmd[R300_FPP_PARAM_0 + 4 * i + 1] = r300PackFloat32(constant[1]);
+               rmesa->hw.r500fp_const.cmd[R300_FPP_PARAM_0 + 4 * i + 2] = r300PackFloat32(constant[2]);
+               rmesa->hw.r500fp_const.cmd[R300_FPP_PARAM_0 + 4 * i + 3] = r300PackFloat32(constant[3]);
+       }
+       bump_r500fp_const_count(rmesa->hw.r500fp_const.cmd, code->const_nr * 4);
+
+}
+
 void r300UpdateShaderStates(r300ContextPtr rmesa)
 {
        GLcontext *ctx;
        ctx = rmesa->radeon.glCtx;
 
        r300UpdateTextureState(ctx);
+       r300SetEarlyZState(ctx);
 
-       r300SetupPixelShader(rmesa);
-       r300SetupTextures(ctx);
+       GLuint fgdepthsrc = R300_FG_DEPTH_SRC_SCAN;
+       if (current_fragment_program_writes_depth(ctx))
+               fgdepthsrc = R300_FG_DEPTH_SRC_SHADER;
+       if (fgdepthsrc != rmesa->hw.fg_depth_src.cmd[1]) {
+               R300_STATECHANGE(rmesa, fg_depth_src);
+               rmesa->hw.fg_depth_src.cmd[1] = fgdepthsrc;
+       }
+
+       if (rmesa->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515)
+               r500SetupPixelShader(rmesa);
+       else
+               r300SetupPixelShader(rmesa);
+
+       if (rmesa->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515)
+               r500SetupRSUnit(ctx);
+       else
+               r300SetupRSUnit(ctx);
 
        if ((rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL))
                r300SetupVertexProgram(rmesa);
-       r300SetupRSUnit(ctx);
+
 }
 
 /**
@@ -2158,13 +2738,11 @@ void r300InitState(r300ContextPtr r300)
        switch (ctx->Visual.depthBits) {
        case 16:
                r300->state.depth.scale = 1.0 / (GLfloat) 0xffff;
-               depth_fmt = R300_DEPTH_FORMAT_16BIT_INT_Z;
-               r300->state.stencil.clear = 0x00000000;
+               depth_fmt = R300_DEPTHFORMAT_16BIT_INT_Z;
                break;
        case 24:
                r300->state.depth.scale = 1.0 / (GLfloat) 0xffffff;
-               depth_fmt = R300_DEPTH_FORMAT_24BIT_INT_Z;
-               r300->state.stencil.clear = 0x00ff0000;
+               depth_fmt = R300_DEPTHFORMAT_24BIT_INT_Z_8BIT_STENCIL;
                break;
        default:
                fprintf(stderr, "Error: Unsupported depth %d... exiting\n",
@@ -2188,6 +2766,24 @@ static void r300RenderMode(GLcontext * ctx, GLenum mode)
        (void)mode;
 }
 
+void r300UpdateClipPlanes( GLcontext *ctx )
+{
+       r300ContextPtr rmesa = R300_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];
+
+                       R300_STATECHANGE( rmesa, vpucp[p] );
+                       rmesa->hw.vpucp[p].cmd[R300_VPUCP_X] = ip[0];
+                       rmesa->hw.vpucp[p].cmd[R300_VPUCP_Y] = ip[1];
+                       rmesa->hw.vpucp[p].cmd[R300_VPUCP_Z] = ip[2];
+                       rmesa->hw.vpucp[p].cmd[R300_VPUCP_W] = ip[3];
+               }
+       }
+}
+
 /**
  * Initialize driver's state callback functions
  */
@@ -2208,9 +2804,12 @@ void r300InitStateFuncs(struct dd_function_table *functions)
        functions->Fogfv = r300Fogfv;
        functions->FrontFace = r300FrontFace;
        functions->ShadeModel = r300ShadeModel;
+       functions->LogicOpcode = r300LogicOpcode;
+
+       /* ARB_point_parameters */
+       functions->PointParameterfv = r300PointParameter;
 
        /* Stencil related */
-       functions->ClearStencil = r300ClearStencil;
        functions->StencilFuncSeparate = r300StencilFuncSeparate;
        functions->StencilMaskSeparate = r300StencilMaskSeparate;
        functions->StencilOpSeparate = r300StencilOpSeparate;
@@ -2225,4 +2824,6 @@ void r300InitStateFuncs(struct dd_function_table *functions)
        functions->PolygonMode = r300PolygonMode;
 
        functions->RenderMode = r300RenderMode;
+
+       functions->ClipPlane = r300ClipPlane;
 }
index 365f7ecd0c62bc05bd4ffd1c4e11eb456428f17b..0589ab7cad97f1e262ed1875d427b6f9e434edf2 100644 (file)
@@ -65,13 +65,16 @@ do {                                                        \
     \
 } while (0)
 
-extern void r300UpdateStateParameters(GLcontext * ctx, GLuint new_state);
-extern void r300InitState(r300ContextPtr r300);
-extern void r300InitStateFuncs(struct dd_function_table *functions);
-extern void r300UpdateViewportOffset(GLcontext * ctx);
-extern void r300UpdateDrawBuffer(GLcontext * ctx);
-
-extern void r300UpdateShaders(r300ContextPtr rmesa);
-extern void r300UpdateShaderStates(r300ContextPtr rmesa);
+// r300_state.c
+extern int future_hw_tcl_on;
+void _tnl_UpdateFixedFunctionProgram (GLcontext * ctx);
+void r300UpdateViewportOffset (GLcontext * ctx);
+void r300UpdateDrawBuffer (GLcontext * ctx);
+void r300UpdateStateParameters (GLcontext * ctx, GLuint new_state);
+void r300UpdateShaders (r300ContextPtr rmesa);
+void r300UpdateShaderStates (r300ContextPtr rmesa);
+void r300InitState (r300ContextPtr r300);
+void r300UpdateClipPlanes (GLcontext * ctx);
+void r300InitStateFuncs (struct dd_function_table *functions);
 
 #endif                         /* __R300_STATE_H__ */
index c949f33bf33eb348432555c2aa15971258073408..8aebd9be3ea0b9f434576702c7d2609c23b280f6 100644 (file)
@@ -40,6 +40,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "enums.h"
 #include "image.h"
 #include "imports.h"
+#include "light.h"
 #include "macros.h"
 
 #include "swrast/s_context.h"
@@ -77,31 +78,6 @@ do {                                                                 \
    rmesa->swtcl.vertex_attr_count++;                                   \
 } while (0)
 
-/* this differs from the VIR0 in emit.c - TODO merge them using another option */
-static GLuint r300VAPInputRoute0(uint32_t * dst, GLvector4f ** attribptr,
-                                int *inputs, GLint * tab, GLuint nr)
-{
-       GLuint i, dw;
-
-       /* type, inputs, stop bit, size */
-       for (i = 0; i + 1 < nr; i += 2) {
-               dw = (inputs[tab[i]] << 8) | 0x3;
-               dw |= ((inputs[tab[i + 1]] << 8) | 0x3) << 16;
-               if (i + 2 == nr) {
-                       dw |= (R300_VAP_INPUT_ROUTE_END << 16);
-               }
-               dst[i >> 1] = dw;
-       }
-
-       if (nr & 1) {
-               dw = (inputs[tab[nr - 1]] << 8) | 0x3;
-               dw |= R300_VAP_INPUT_ROUTE_END;
-               dst[nr >> 1] = dw;
-       }
-
-       return (nr + 1) >> 1;
-}
-
 static void r300SetVertexFormat( GLcontext *ctx )
 {
        r300ContextPtr rmesa = R300_CONTEXT( ctx );
@@ -117,19 +93,24 @@ static void r300SetVertexFormat( GLcontext *ctx )
        GLint tab[VERT_ATTRIB_MAX];
        int swizzle[VERT_ATTRIB_MAX][4];
        GLuint i, nr;
+       GLuint sz, vap_fmt_1 = 0;
 
        DECLARE_RENDERINPUTS(render_inputs_bitset);
        RENDERINPUTS_COPY(render_inputs_bitset, tnl->render_inputs_bitset);
        RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset );
        RENDERINPUTS_COPY(rmesa->state.render_inputs_bitset, render_inputs_bitset);
 
+       vte = rmesa->hw.vte.cmd[1];
+       vte &= ~(R300_VTX_XY_FMT | R300_VTX_Z_FMT | R300_VTX_W0_FMT);
        /* Important:
         */
        if ( VB->NdcPtr != NULL ) {
                VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
+               vte |= R300_VTX_XY_FMT | R300_VTX_Z_FMT;
        }
        else {
                VB->AttribPtr[VERT_ATTRIB_POS] = VB->ClipPtr;
+               vte |= R300_VTX_W0_FMT;
        }
 
        assert( VB->AttribPtr[VERT_ATTRIB_POS] != NULL );
@@ -139,14 +120,15 @@ static void r300SetVertexFormat( GLcontext *ctx )
         * build up a hardware vertex.
         */
        if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POS)) {
-               vap_vte_cntl |= R300_VTX_W0_FMT;
+               sz = VB->AttribPtr[VERT_ATTRIB_POS]->size;
                InputsRead |= 1 << VERT_ATTRIB_POS;
                OutputsWritten |= 1 << VERT_RESULT_HPOS;
-               EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F );
-       } else
+               EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_1F + sz - 1 );
+               offset = sz;
+       } else {
+               offset = 4;
                EMIT_PAD(4 * sizeof(float));
-
-       offset = 4;
+       }
 
        if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POINTSIZE )) {
                EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F );
@@ -155,18 +137,19 @@ static void r300SetVertexFormat( GLcontext *ctx )
        }
 
        if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_COLOR0)) {
+               sz = VB->AttribPtr[VERT_ATTRIB_COLOR0]->size;
                rmesa->swtcl.coloroffset = offset;
                InputsRead |= 1 << VERT_ATTRIB_COLOR0;
                OutputsWritten |= 1 << VERT_RESULT_COL0;
-               EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F );
+               EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_1F + sz - 1 );
+               offset += sz;
        }
 
-       offset += 4;
-
        rmesa->swtcl.specoffset = 0;
        if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) {
+               sz = VB->AttribPtr[VERT_ATTRIB_COLOR1]->size;
                rmesa->swtcl.specoffset = offset;
-               EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_4F );
+               EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_1F + sz - 1 );
                InputsRead |= 1 << VERT_ATTRIB_COLOR1;
                OutputsWritten |= 1 << VERT_RESULT_COL1;
        }
@@ -176,9 +159,11 @@ static void r300SetVertexFormat( GLcontext *ctx )
 
                for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
                        if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(i) )) {
+                               sz = VB->TexCoordPtr[i]->size;
                                InputsRead |= 1 << (VERT_ATTRIB_TEX0 + i);
                                OutputsWritten |= 1 << (VERT_RESULT_TEX0 + i);
-                               EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_4F );
+                               EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_1F + sz - 1 );
+                               vap_fmt_1 |= sz << (3 * i);
                        }
                }
        }
@@ -237,7 +222,7 @@ static void r300SetVertexFormat( GLcontext *ctx )
    
        R300_STATECHANGE(rmesa, vof);
        rmesa->hw.vof.cmd[R300_VOF_CNTL_0] = r300VAPOutputCntl0(ctx, OutputsWritten);
-       rmesa->hw.vof.cmd[R300_VOF_CNTL_1] = r300VAPOutputCntl1(ctx, OutputsWritten);
+       rmesa->hw.vof.cmd[R300_VOF_CNTL_1] = vap_fmt_1;
    
        rmesa->swtcl.vertex_size =
                _tnl_install_attrs( ctx,
@@ -249,7 +234,7 @@ static void r300SetVertexFormat( GLcontext *ctx )
 
        RENDERINPUTS_COPY( rmesa->tnl_index_bitset, index_bitset );
 
-       vte = rmesa->hw.vte.cmd[1];
+
        R300_STATECHANGE(rmesa, vte);
        rmesa->hw.vte.cmd[1] = vte;
        rmesa->hw.vte.cmd[2] = rmesa->swtcl.vertex_size;
@@ -590,6 +575,7 @@ static void r300RenderStart(GLcontext *ctx)
        r300ChooseRenderState(ctx);     
        r300SetVertexFormat(ctx);
 
+       r300UpdateShaders(rmesa);
        r300UpdateShaderStates(rmesa);
 
        r300EmitCacheFlush(rmesa);
index 1805cecd0af36c3778db7d90bda4ceac2e80e506..f7f49729bc890ea07aaa38aa8fe823b400099fd6 100644 (file)
@@ -52,129 +52,59 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "xmlpool.h"
 
+
+static unsigned int translate_wrap_mode(GLenum wrapmode)
+{
+       switch(wrapmode) {
+       case GL_REPEAT: return R300_TX_REPEAT;
+       case GL_CLAMP: return R300_TX_CLAMP;
+       case GL_CLAMP_TO_EDGE: return R300_TX_CLAMP_TO_EDGE;
+       case GL_CLAMP_TO_BORDER: return R300_TX_CLAMP_TO_BORDER;
+       case GL_MIRRORED_REPEAT: return R300_TX_REPEAT | R300_TX_MIRRORED;
+       case GL_MIRROR_CLAMP_EXT: return R300_TX_CLAMP | R300_TX_MIRRORED;
+       case GL_MIRROR_CLAMP_TO_EDGE_EXT: return R300_TX_CLAMP_TO_EDGE | R300_TX_MIRRORED;
+       case GL_MIRROR_CLAMP_TO_BORDER_EXT: return R300_TX_CLAMP_TO_BORDER | R300_TX_MIRRORED;
+       default:
+               _mesa_problem(NULL, "bad wrap mode in %s", __FUNCTION__);
+               return 0;
+       }
+}
+
+
 /**
- * Set the texture wrap modes.
+ * Update the cached hardware registers based on the current 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)
+static void r300UpdateTexWrap(r300TexObjPtr t)
 {
-       unsigned long hw_swrap = 0, hw_twrap = 0, hw_qwrap = 0;
+       struct gl_texture_object *tObj = t->base.tObj;
 
        t->filter &=
-           ~(R300_TX_WRAP_S_MASK | R300_TX_WRAP_T_MASK | R300_TX_WRAP_Q_MASK);
+           ~(R300_TX_WRAP_S_MASK | R300_TX_WRAP_T_MASK | R300_TX_WRAP_R_MASK);
 
-       switch (swrap) {
-       case GL_REPEAT:
-               hw_swrap |= R300_TX_REPEAT;
-               break;
-       case GL_CLAMP:
-               hw_swrap |= R300_TX_CLAMP;
-               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;
-               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__);
-       }
+       t->filter |= translate_wrap_mode(tObj->WrapS) << R300_TX_WRAP_S_SHIFT;
 
-       switch (twrap) {
-       case GL_REPEAT:
-               hw_twrap |= R300_TX_REPEAT;
-               break;
-       case GL_CLAMP:
-               hw_twrap |= R300_TX_CLAMP;
-               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;
-               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__);
-       }
+       if (tObj->Target != GL_TEXTURE_1D) {
+               t->filter |= translate_wrap_mode(tObj->WrapT) << R300_TX_WRAP_T_SHIFT;
 
-       switch (rwrap) {
-       case GL_REPEAT:
-               hw_qwrap |= R300_TX_REPEAT;
-               break;
-       case GL_CLAMP:
-               hw_qwrap |= R300_TX_CLAMP;
-               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;
-               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__);
+               if (tObj->Target == GL_TEXTURE_3D)
+                       t->filter |= translate_wrap_mode(tObj->WrapR) << R300_TX_WRAP_R_SHIFT;
        }
-
-       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;
 }
 
-static void r300SetTexMaxAnisotropy(r300TexObjPtr t, GLfloat max)
+static GLuint aniso_filter(GLfloat anisotropy)
 {
-
-       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;
+       if (anisotropy >= 16.0) {
+               return R300_TX_MAX_ANISO_16_TO_1;
+       } else if (anisotropy >= 8.0) {
+               return R300_TX_MAX_ANISO_8_TO_1;
+       } else if (anisotropy >= 4.0) {
+               return R300_TX_MAX_ANISO_4_TO_1;
+       } else if (anisotropy >= 2.0) {
+               return R300_TX_MAX_ANISO_2_TO_1;
        } else {
-               t->filter |= R300_TX_MAX_ANISO_16_TO_1;
+               return R300_TX_MAX_ANISO_1_TO_1;
        }
 }
 
@@ -184,54 +114,47 @@ static void r300SetTexMaxAnisotropy(r300TexObjPtr t, GLfloat max)
  * \param t Texture whose filter modes are to be set
  * \param minf Texture minification mode
  * \param magf Texture magnification mode
+ * \param anisotropy Maximum anisotropy level
  */
-
-static void r300SetTexFilter(r300TexObjPtr t, GLenum minf, GLenum magf)
+static void r300SetTexFilter(r300TexObjPtr t, GLenum minf, GLenum magf, GLfloat anisotropy)
 {
-       GLuint anisotropy = (t->filter & R300_TX_MAX_ANISO_MASK);
+       t->filter &= ~(R300_TX_MIN_FILTER_MASK | R300_TX_MIN_FILTER_MIP_MASK | R300_TX_MAG_FILTER_MASK | R300_TX_MAX_ANISO_MASK);
+       t->filter_1 &= ~R300_EDGE_ANISO_EDGE_ONLY;
 
-       t->filter &= ~(R300_TX_MIN_FILTER_MASK | R300_TX_MAG_FILTER_MASK);
+       /* Note that EXT_texture_filter_anisotropic is extremely vague about
+        * how anisotropic filtering interacts with the "normal" filter modes.
+        * When anisotropic filtering is enabled, we override min and mag
+        * filter settings completely. This includes driconf's settings.
+        */
+       if (anisotropy >= 2.0 && (minf != GL_NEAREST) && (magf != GL_NEAREST)) {
+               t->filter |= R300_TX_MAG_FILTER_ANISO
+                       | R300_TX_MIN_FILTER_ANISO
+                       | R300_TX_MIN_FILTER_MIP_LINEAR
+                       | aniso_filter(anisotropy);
+               if (RADEON_DEBUG & DEBUG_TEXTURE)
+                       fprintf(stderr, "Using maximum anisotropy of %f\n", anisotropy);
+               return;
+       }
 
-       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_NEAREST_MIP_LINEAR;
-                       break;
-               case GL_LINEAR_MIPMAP_NEAREST:
-                       t->filter |= R300_TX_MIN_FILTER_LINEAR_MIP_NEAREST;
-                       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;
-               }
+       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|R300_TX_MIN_FILTER_MIP_NEAREST;
+               break;
+       case GL_NEAREST_MIPMAP_LINEAR:
+               t->filter |= R300_TX_MIN_FILTER_NEAREST|R300_TX_MIN_FILTER_MIP_LINEAR;
+               break;
+       case GL_LINEAR_MIPMAP_NEAREST:
+               t->filter |= R300_TX_MIN_FILTER_LINEAR|R300_TX_MIN_FILTER_MIP_NEAREST;
+               break;
+       case GL_LINEAR_MIPMAP_LINEAR:
+               t->filter |= R300_TX_MIN_FILTER_LINEAR|R300_TX_MIN_FILTER_MIP_LINEAR;
+               break;
        }
 
        /* Note we don't have 3D mipmaps so only use the mag filter setting
@@ -249,7 +172,7 @@ static void r300SetTexFilter(r300TexObjPtr t, GLenum minf, GLenum magf)
 
 static void r300SetTexBorderColor(r300TexObjPtr t, GLubyte c[4])
 {
-       t->pp_border_color = PACK_COLOR_8888(c[0], c[1], c[2], c[3]);
+       t->pp_border_color = PACK_COLOR_8888(c[3], c[0], c[1], c[2]);
 }
 
 /**
@@ -277,9 +200,8 @@ static r300TexObjPtr r300AllocTexObj(struct gl_texture_object *texObj)
 
                make_empty_list(&t->base);
 
-               r300SetTexWrap(t, texObj->WrapS, texObj->WrapT, texObj->WrapR);
-               r300SetTexMaxAnisotropy(t, texObj->MaxAnisotropy);
-               r300SetTexFilter(t, texObj->MinFilter, texObj->MagFilter);
+               r300UpdateTexWrap(t);
+               r300SetTexFilter(t, texObj->MinFilter, texObj->MagFilter, texObj->MaxAnisotropy);
                r300SetTexBorderColor(t, texObj->_BorderChan);
        }
 
@@ -482,6 +404,25 @@ static const struct gl_texture_format *r300ChooseTextureFormat(GLcontext * ctx,
        case GL_RGBA32F_ARB:
                return &_mesa_texformat_rgba_float32;
 
+       case GL_DEPTH_COMPONENT:
+       case GL_DEPTH_COMPONENT16:
+       case GL_DEPTH_COMPONENT24:
+       case GL_DEPTH_COMPONENT32:
+#if 0
+               switch (type) {
+               case GL_UNSIGNED_BYTE:
+               case GL_UNSIGNED_SHORT:
+                       return &_mesa_texformat_z16;
+               case GL_UNSIGNED_INT:
+                       return &_mesa_texformat_z32;
+               case GL_UNSIGNED_INT_24_8_EXT:
+               default:
+                       return &_mesa_texformat_z24_s8;
+               }
+#else
+               return &_mesa_texformat_z16;
+#endif
+
        default:
                _mesa_problem(ctx,
                              "unexpected internalFormat 0x%x in r300ChooseTextureFormat",
@@ -957,60 +898,6 @@ r300TexSubImage3D(GLcontext * ctx, GLenum target, GLint level,
        t->dirty_images[0] |= (1 << level);
 }
 
-static void r300TexEnv(GLcontext * ctx, GLenum target,
-                      GLenum pname, const GLfloat * param)
-{
-       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_LOD_BIAS_EXT:{
-#if 0                          /* Needs to be relocated in order to make sure we got the right tmu */
-                       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;
-                       }
-#endif
-                       break;
-               }
-
-       default:
-               return;
-       }
-}
-
 /**
  * Changes variables and flags for a state update, which will happen at the
  * next UpdateTextureState
@@ -1031,14 +918,13 @@ static void r300TexParameter(GLcontext * ctx, GLenum target,
        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);
+               r300SetTexFilter(t, texObj->MinFilter, texObj->MagFilter, texObj->MaxAnisotropy);
                break;
 
        case GL_TEXTURE_WRAP_S:
        case GL_TEXTURE_WRAP_T:
        case GL_TEXTURE_WRAP_R:
-               r300SetTexWrap(t, texObj->WrapS, texObj->WrapT, texObj->WrapR);
+               r300UpdateTexWrap(t);
                break;
 
        case GL_TEXTURE_BORDER_COLOR:
@@ -1057,13 +943,24 @@ static void r300TexParameter(GLcontext * ctx, GLenum target,
                driSwapOutTextureObject((driTextureObject *) t);
                break;
 
+       case GL_DEPTH_TEXTURE_MODE:
+               if (!texObj->Image[0][texObj->BaseLevel])
+                       return;
+               if (texObj->Image[0][texObj->BaseLevel]->TexFormat->BaseFormat
+                   == GL_DEPTH_COMPONENT) {
+                       r300SetDepthTexMode(texObj);
+                       break;
+               } else {
+                       /* If the texture isn't a depth texture, changing this
+                        * state won't cause any changes to the hardware.
+                        * Don't force a flush of texture state.
+                        */
+                       return;
+               }
+
        default:
                return;
        }
-
-       /* Mark this texobj as dirty (one bit per tex unit)
-        */
-       t->dirty_state = TEX_ALL;
 }
 
 static void r300BindTexture(GLcontext * ctx, GLenum target,
@@ -1146,7 +1043,6 @@ void r300InitTextureFuncs(struct dd_function_table *functions)
        functions->DeleteTexture = r300DeleteTexture;
        functions->IsTextureResident = driIsTextureResident;
 
-       functions->TexEnv = r300TexEnv;
        functions->TexParameter = r300TexParameter;
 
        functions->CompressedTexImage2D = r300CompressedTexImage2D;
index f67a8e6ba6536e16c449864921fc8f36c42914cf..b86d45bfe050269a1e73ff98ed55bd13f2de7a4a 100644 (file)
@@ -35,6 +35,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #ifndef __r300_TEX_H__
 #define __r300_TEX_H__
 
+extern void r300SetDepthTexMode(struct gl_texture_object *tObj);
+
 extern void r300SetTexOffset(__DRIcontext *pDRICtx, GLint texname,
                             unsigned long long offset, GLint depth,
                             GLuint pitch);
index 38f0da8b7c07d3ea56fedafeec117fc9fb3fc53c..69847a4022d02097de0045cec3120cd60b871716 100644 (file)
@@ -349,7 +349,7 @@ static void r300UploadSubImage(r300ContextPtr rmesa, r300TexObjPtr t,
        imageWidth = texImage->Width;
        imageHeight = texImage->Height;
 
-       offset = t->bufAddr + t->base.totalSize / 6 * face;
+       offset = t->bufAddr;
 
        if (RADEON_DEBUG & (DEBUG_TEXTURE | DEBUG_IOCTL)) {
                GLint imageX = 0;
@@ -505,7 +505,7 @@ int r300UploadTexImages(r300ContextPtr rmesa, r300TexObjPtr t, GLuint face)
                        t->base.lastLevel);
        }
 
-       if (!t || t->base.totalSize == 0)
+       if (t->base.totalSize == 0)
                return 0;
 
        if (RADEON_DEBUG & DEBUG_SYNC) {
@@ -534,10 +534,6 @@ int r300UploadTexImages(r300ContextPtr rmesa, r300TexObjPtr t, GLuint face)
                        /* hope it's safe to add that here... */
                        t->offset |= 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.
index 1d2909fd214b37687ca34826d046afd717d35093..d19832f86181eecf202a04310322b35188ce06f0 100644 (file)
@@ -115,11 +115,186 @@ static const struct tx_table {
        _ASSIGN(LUMINANCE_ALPHA_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, Y, FL_I16A16)),
        _ASSIGN(INTENSITY_FLOAT32, R300_EASY_TX_FORMAT(X, X, X, X, FL_I32)),
        _ASSIGN(INTENSITY_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, X, FL_I16)),
+       _ASSIGN(Z16, R300_EASY_TX_FORMAT(X, X, X, X, X16)),
+       _ASSIGN(Z24_S8, R300_EASY_TX_FORMAT(X, X, X, X, X24_Y8)),
+       _ASSIGN(Z32, R300_EASY_TX_FORMAT(X, X, X, X, X32)),
        /* *INDENT-ON* */
 };
 
 #undef _ASSIGN
 
+void r300SetDepthTexMode(struct gl_texture_object *tObj)
+{
+       static const GLuint formats[3][3] = {
+               {
+                       R300_EASY_TX_FORMAT(X, X, X, ONE, X16),
+                       R300_EASY_TX_FORMAT(X, X, X, X, X16),
+                       R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, X16),
+               },
+               {
+                       R300_EASY_TX_FORMAT(X, X, X, ONE, X24_Y8),
+                       R300_EASY_TX_FORMAT(X, X, X, X, X24_Y8),
+                       R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, X24_Y8),
+               },
+               {
+                       R300_EASY_TX_FORMAT(X, X, X, ONE, X32),
+                       R300_EASY_TX_FORMAT(X, X, X, X, X32),
+                       R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, X32),
+               },
+       };
+       const GLuint *format;
+       r300TexObjPtr t;
+
+       if (!tObj)
+               return;
+
+       t = (r300TexObjPtr) tObj->DriverData;
+
+
+       switch (tObj->Image[0][tObj->BaseLevel]->TexFormat->MesaFormat) {
+       case MESA_FORMAT_Z16:
+               format = formats[0];
+               break;
+       case MESA_FORMAT_Z24_S8:
+               format = formats[1];
+               break;
+       case MESA_FORMAT_Z32:
+               format = formats[2];
+               break;
+       default:
+               /* Error...which should have already been caught by higher
+                * levels of Mesa.
+                */
+               ASSERT(0);
+               return;
+       }
+
+       switch (tObj->DepthMode) {
+       case GL_LUMINANCE:
+               t->format = format[0];
+               break;
+       case GL_INTENSITY:
+               t->format = format[1];
+               break;
+       case GL_ALPHA:
+               t->format = format[2];
+               break;
+       default:
+               /* Error...which should have already been caught by higher
+                * levels of Mesa.
+                */
+               ASSERT(0);
+               return;
+       }
+}
+
+
+/**
+ * Compute sizes and fill in offset and blit information for the given
+ * image (determined by \p face and \p level).
+ *
+ * \param curOffset points to the offset at which the image is to be stored
+ * and is updated by this function according to the size of the image.
+ */
+static void compute_tex_image_offset(
+       struct gl_texture_object *tObj,
+       GLuint face,
+       GLint level,
+       GLint* curOffset)
+{
+       r300TexObjPtr t = (r300TexObjPtr) tObj->DriverData;
+       const struct gl_texture_image* texImage;
+       GLuint blitWidth = R300_BLIT_WIDTH_BYTES;
+       GLuint texelBytes;
+       GLuint size;
+
+       texImage = tObj->Image[0][level + t->base.firstLevel];
+       if (!texImage)
+               return;
+
+       texelBytes = texImage->TexFormat->TexelBytes;
+
+       /* find image size in bytes */
+       if (texImage->IsCompressed) {
+               if ((t->format & R300_TX_FORMAT_DXT1) ==
+                       R300_TX_FORMAT_DXT1) {
+                       // fprintf(stderr,"DXT 1 %d %08X\n", texImage->Width, t->format);
+                       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 */
+                       WARN_ONCE
+                               ("DXT 3/5 suffers from multitexturing problems!\n");
+                       // fprintf(stderr,"DXT 3/5 %d\n", texImage->Width);
+                       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;
+               blitWidth = 64 / texelBytes;
+       } else if (t->tile_bits & R300_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);
+
+       if (RADEON_DEBUG & DEBUG_TEXTURE)
+               fprintf(stderr, "w=%d h=%d d=%d tb=%d intFormat=%d\n",
+                       texImage->Width, texImage->Height,
+                       texImage->Depth,
+                       texImage->TexFormat->TexelBytes,
+                       texImage->InternalFormat);
+
+       /* All images are aligned to a 32-byte offset */
+       *curOffset = (*curOffset + 0x1f) & ~0x1f;
+
+       if (texelBytes) {
+               /* fix x and y coords up later together with offset */
+               t->image[face][level].x = *curOffset;
+               t->image[face][level].y = 0;
+               t->image[face][level].width =
+                       MIN2(size / texelBytes, blitWidth);
+               t->image[face][level].height =
+                       (size / texelBytes) / t->image[face][level].width;
+       } else {
+               t->image[face][level].x = *curOffset % R300_BLIT_WIDTH_BYTES;
+               t->image[face][level].y = *curOffset / R300_BLIT_WIDTH_BYTES;
+               t->image[face][level].width =
+                       MIN2(size, R300_BLIT_WIDTH_BYTES);
+               t->image[face][level].height = size / t->image[face][level].width;
+       }
+
+       if (RADEON_DEBUG & DEBUG_TEXTURE)
+               fprintf(stderr,
+                       "level %d, face %d: %dx%d x=%d y=%d w=%d h=%d size=%d at %d\n",
+                       level, face, texImage->Width, texImage->Height,
+                       t->image[face][level].x, t->image[face][level].y,
+                       t->image[face][level].width, t->image[face][level].height,
+                       size, *curOffset);
+
+       *curOffset += size;
+}
+
+
+
 /**
  * This function computes the number of bytes of storage needed for
  * the given texture object (all mipmap levels, all cube faces).
@@ -137,7 +312,7 @@ static void r300SetTexImages(r300ContextPtr rmesa,
        r300TexObjPtr t = (r300TexObjPtr) tObj->DriverData;
        const struct gl_texture_image *baseImage =
            tObj->Image[0][tObj->BaseLevel];
-       GLint curOffset, blitWidth;
+       GLint curOffset;
        GLint i, texelBytes;
        GLint numLevels;
        GLint log2Width, log2Height, log2Depth;
@@ -146,7 +321,12 @@ static void r300SetTexImages(r300ContextPtr rmesa,
         */
        if (!t->image_override
            && VALID_FORMAT(baseImage->TexFormat->MesaFormat)) {
-               t->format = tx_table[baseImage->TexFormat->MesaFormat].format;
+               if (baseImage->TexFormat->BaseFormat == GL_DEPTH_COMPONENT) {
+                       r300SetDepthTexMode(tObj);
+               } else {
+                       t->format = tx_table[baseImage->TexFormat->MesaFormat].format;
+               }
+
                t->filter |= tx_table[baseImage->TexFormat->MesaFormat].filter;
        } else if (!t->image_override) {
                _mesa_problem(NULL, "unexpected texture format in %s",
@@ -171,8 +351,6 @@ static void r300SetTexImages(r300ContextPtr rmesa,
         * 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 = R300_BLIT_WIDTH_BYTES;
        t->tile_bits = 0;
 
        /* figure out if this texture is suitable for tiling. */
@@ -202,94 +380,23 @@ static void r300SetTexImages(r300ContextPtr rmesa,
        }
 #endif
 
-       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) {
-                       if ((t->format & R300_TX_FORMAT_DXT1) ==
-                           R300_TX_FORMAT_DXT1) {
-                               // fprintf(stderr,"DXT 1 %d %08X\n", texImage->Width, t->format);
-                               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 */
-                               WARN_ONCE
-                                   ("DXT 3/5 suffers from multitexturing problems!\n");
-                               // fprintf(stderr,"DXT 3/5 %d\n", texImage->Width);
-                               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;
-                       blitWidth = 64 / texelBytes;
-               } else if (t->tile_bits & R300_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);
-
-               if (RADEON_DEBUG & DEBUG_TEXTURE)
-                       fprintf(stderr, "w=%d h=%d d=%d tb=%d intFormat=%d\n",
-                               texImage->Width, texImage->Height,
-                               texImage->Depth,
-                               texImage->TexFormat->TexelBytes,
-                               texImage->InternalFormat);
-
-               /* Align to 32-byte offset.  It is faster to do this unconditionally
-                * (no branch penalty).
-                */
+       curOffset = 0;
 
-               curOffset = (curOffset + 0x1f) & ~0x1f;
+       if (tObj->Target == GL_TEXTURE_CUBE_MAP) {
+               ASSERT(log2Width == log2Height);
+               t->format |= R300_TX_FORMAT_CUBIC_MAP;
 
-               if (texelBytes) {
-                       /* fix x and y coords up later together with offset */
-                       t->image[0][i].x = curOffset;
-                       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 % R300_BLIT_WIDTH_BYTES;
-                       t->image[0][i].y = curOffset / R300_BLIT_WIDTH_BYTES;
-                       t->image[0][i].width =
-                           MIN2(size, R300_BLIT_WIDTH_BYTES);
-                       t->image[0][i].height = size / t->image[0][i].width;
+               for(i = 0; i < numLevels; i++) {
+                       GLuint face;
+                       for(face = 0; face < 6; face++)
+                               compute_tex_image_offset(tObj, face, i, &curOffset);
                }
+       } else {
+               if (tObj->Target == GL_TEXTURE_3D)
+                       t->format |= R300_TX_FORMAT_3D;
 
-               if (RADEON_DEBUG & DEBUG_TEXTURE)
-                       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;
+               for (i = 0; i < numLevels; i++)
+                       compute_tex_image_offset(tObj, 0, i, &curOffset);
        }
 
        /* Align the total size of texture memory block.
@@ -297,43 +404,27 @@ static void r300SetTexImages(r300ContextPtr rmesa,
        t->base.totalSize =
            (curOffset + RADEON_OFFSET_MASK) & ~RADEON_OFFSET_MASK;
 
-       /* Setup remaining cube face blits, if needed */
-       if (tObj->Target == GL_TEXTURE_CUBE_MAP) {
-               GLuint face;
-               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; /* total texmem needed */
-       }
-
-       if (tObj->Target == GL_TEXTURE_CUBE_MAP) {
-               ASSERT(log2Width == log2Height);
-               t->format |= R300_TX_FORMAT_CUBIC_MAP;
-       }
-
        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))
+               R300_TX_HEIGHTMASK_SHIFT)
+            | ((tObj->Image[0][t->base.firstLevel]->DepthLog2) <<
+               R300_TX_DEPTHMASK_SHIFT))
            | ((numLevels - 1) << R300_TX_MAX_MIP_LEVEL_SHIFT);
 
+       t->pitch = 0;
+
        /* 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 =
+               t->pitch |=
                    (tObj->Image[0][t->base.firstLevel]->Width + 63) & ~(63);
        } else if (tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
-               unsigned int align = blitWidth - 1;
-               t->pitch = ((tObj->Image[0][t->base.firstLevel]->Width *
+               unsigned int align = (64 / texelBytes) - 1;
+               t->pitch |= ((tObj->Image[0][t->base.firstLevel]->Width *
                             texelBytes) + 63) & ~(63);
                t->size |= R300_TX_SIZE_TXPITCH_EN;
                if (!t->image_override)
@@ -341,14 +432,17 @@ static void r300SetTexImages(r300ContextPtr rmesa,
                            (((tObj->Image[0][t->base.firstLevel]->Width) +
                              align) & ~align) - 1;
        } else {
-               t->pitch =
+               t->pitch |=
                    ((tObj->Image[0][t->base.firstLevel]->Width *
                      texelBytes) + 63) & ~(63);
        }
 
-       t->dirty_state = TEX_ALL;
-
-       /* FYI: r300UploadTexImages( rmesa, t ) used to be called here */
+       if (rmesa->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) {
+           if (tObj->Image[0][t->base.firstLevel]->Width > 2048)
+               t->pitch_reg |= R500_TXWIDTH_BIT11;
+           if (tObj->Image[0][t->base.firstLevel]->Height > 2048)
+               t->pitch_reg |= R500_TXHEIGHT_BIT11;
+       }
 }
 
 /* ================================================================
@@ -485,7 +579,6 @@ static GLboolean r300UpdateTexture(GLcontext * ctx, int unit)
 
                rmesa->state.texture.unit[unit].texobj = t;
                t->base.bound |= (1 << unit);
-               t->dirty_state |= 1 << unit;
                driUpdateTextureLRU((driTextureObject *) t);    /* XXX: should be locked! */
        }
 
@@ -495,12 +588,11 @@ static GLboolean r300UpdateTexture(GLcontext * ctx, int unit)
 void r300SetTexOffset(__DRIcontext * pDRICtx, GLint texname,
                      unsigned long long offset, GLint depth, GLuint pitch)
 {
-       r300ContextPtr rmesa =
-           (r300ContextPtr) ((__DRIcontextPrivate *) pDRICtx->private)->
-           driverPrivate;
+       r300ContextPtr rmesa = pDRICtx->driverPrivate;
        struct gl_texture_object *tObj =
            _mesa_lookup_texture(rmesa->radeon.glCtx, texname);
        r300TexObjPtr t;
+       uint32_t pitch_val;
 
        if (!tObj)
                return;
@@ -513,28 +605,30 @@ void r300SetTexOffset(__DRIcontext * pDRICtx, GLint texname,
                return;
 
        t->offset = offset;
-       t->pitch_reg = pitch;
+       t->pitch_reg &= (1 << 13) -1;
+       pitch_val = pitch;
 
        switch (depth) {
        case 32:
                t->format = R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8);
                t->filter |= tx_table[2].filter;
-               t->pitch_reg /= 4;
+               pitch_val /= 4;
                break;
        case 24:
        default:
                t->format = R300_EASY_TX_FORMAT(X, Y, Z, ONE, W8Z8Y8X8);
                t->filter |= tx_table[4].filter;
-               t->pitch_reg /= 4;
+               pitch_val /= 4;
                break;
        case 16:
                t->format = R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5);
                t->filter |= tx_table[5].filter;
-               t->pitch_reg /= 2;
+               pitch_val /= 2;
                break;
        }
+       pitch_val--;
 
-       t->pitch_reg--;
+       t->pitch_reg |= pitch_val;
 }
 
 static GLboolean r300UpdateTextureUnit(GLcontext * ctx, int unit)
index 7d4e8c95112b1e0ce5410f139cbaafb37ed51923..c4e325e6a762a2a21dad256f70dc5ca15f414704 100644 (file)
@@ -1,6 +1,7 @@
 /**************************************************************************
 
-Copyright (C) 2005 Aapo Tahkola.
+Copyright (C) 2005  Aapo Tahkola <aet@rasterburn.org>
+Copyright (C) 2008  Oliver McFadden <z3ro.geek@gmail.com>
 
 All Rights Reserved.
 
@@ -25,20 +26,12 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 **************************************************************************/
 
-/**
- * \file
- *
- * \author Aapo Tahkola <aet@rasterburn.org>
- *
- * \author Oliver McFadden <z3ro.geek@gmail.com>
- *
- * For a description of the vertex program instruction set see r300_reg.h.
- */
+/* Radeon R5xx Acceleration, Revision 1.2 */
 
-#include "glheader.h"
-#include "macros.h"
-#include "enums.h"
-#include "program.h"
+#include "main/glheader.h"
+#include "main/macros.h"
+#include "main/enums.h"
+#include "shader/program.h"
 #include "shader/prog_instruction.h"
 #include "shader/prog_parameter.h"
 #include "shader/prog_statevars.h"
@@ -46,71 +39,38 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "r300_context.h"
 
-#if SWIZZLE_X != VSF_IN_COMPONENT_X || \
-    SWIZZLE_Y != VSF_IN_COMPONENT_Y || \
-    SWIZZLE_Z != VSF_IN_COMPONENT_Z || \
-    SWIZZLE_W != VSF_IN_COMPONENT_W || \
-    SWIZZLE_ZERO != VSF_IN_COMPONENT_ZERO || \
-    SWIZZLE_ONE != VSF_IN_COMPONENT_ONE || \
-    WRITEMASK_X != VSF_FLAG_X || \
-    WRITEMASK_Y != VSF_FLAG_Y || \
-    WRITEMASK_Z != VSF_FLAG_Z || \
-    WRITEMASK_W != VSF_FLAG_W
-#error Cannot change these!
-#endif
-
 /* TODO: Get rid of t_src_class call */
 #define CMP_SRCS(a, b) ((a.RelAddr != b.RelAddr) || (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 ZERO_SRC_0 (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) | (src[0].RelAddr << 4))
-
-#define ZERO_SRC_1 (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) | (src[1].RelAddr << 4))
-
-#define ZERO_SRC_2 (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) | (src[2].RelAddr << 4))
-
-#define ONE_SRC_0 (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) | (src[0].RelAddr << 4))
-
-#define ONE_SRC_1 (MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), \
-                                   SWIZZLE_ONE, SWIZZLE_ONE, \
-                                   SWIZZLE_ONE, SWIZZLE_ONE, \
-                                   t_src_class(src[1].File), VSF_FLAG_NONE) | (src[1].RelAddr << 4))
-
-#define ONE_SRC_2 (MAKE_VSF_SOURCE(t_src_index(vp, &src[2]), \
-                                   SWIZZLE_ONE, SWIZZLE_ONE, \
-                                   SWIZZLE_ONE, SWIZZLE_ONE, \
-                                   t_src_class(src[2].File), VSF_FLAG_NONE) | (src[2].RelAddr << 4))
+                      ((t_src_class(a.File) == PVS_SRC_REG_CONSTANT && \
+                        t_src_class(b.File) == PVS_SRC_REG_CONSTANT) || \
+                       (t_src_class(a.File) == PVS_SRC_REG_INPUT && \
+                        t_src_class(b.File) == PVS_SRC_REG_INPUT)))) \
 
-/* DP4 version seems to trigger some hw peculiarity */
-//#define PREFER_DP4
+/*
+ * Take an already-setup and valid source then swizzle it appropriately to
+ * obtain a constant ZERO or ONE source.
+ */
+#define __CONST(x, y)  \
+       (PVS_SRC_OPERAND(t_src_index(vp, &src[x]),      \
+                          t_swizzle(y),        \
+                          t_swizzle(y),        \
+                          t_swizzle(y),        \
+                          t_swizzle(y),        \
+                          t_src_class(src[x].File), \
+                          VSF_FLAG_NONE) | (src[x].RelAddr << 4))
 
 #define FREE_TEMPS() \
        do { \
-               if(u_temp_i < vp->num_temporaries) { \
-                       WARN_ONCE("Ran out of temps, num temps %d, us %d\n", vp->num_temporaries, u_temp_i); \
+               int u_temp_used = (VSF_MAX_FRAGMENT_TEMPS - 1) - u_temp_i; \
+               if((vp->num_temporaries + u_temp_used) > VSF_MAX_FRAGMENT_TEMPS) { \
+                       WARN_ONCE("Ran out of temps, num temps %d, us %d\n", vp->num_temporaries, u_temp_used); \
                        vp->native = GL_FALSE; \
                } \
                u_temp_i=VSF_MAX_FRAGMENT_TEMPS-1; \
        } while (0)
 
 int r300VertexProgUpdateParams(GLcontext * ctx,
-                              struct r300_vertex_program_cont *vp,
-                              float *dst)
+                              struct r300_vertex_program_cont *vp, float *dst)
 {
        int pi;
        struct gl_vertex_program *mesa_vp = &vp->mesa_program;
@@ -141,7 +101,6 @@ int r300VertexProgUpdateParams(GLcontext * ctx,
        paramList = mesa_vp->Base.Parameters;
        for (pi = 0; pi < paramList->NumParameters; pi++) {
                switch (paramList->Parameters[pi].Type) {
-
                case PROGRAM_STATE_VAR:
                case PROGRAM_NAMED_PARAM:
                        //fprintf(stderr, "%s", vp->Parameters->Parameters[pi].Name);
@@ -151,7 +110,6 @@ int r300VertexProgUpdateParams(GLcontext * ctx,
                        *dst++ = paramList->ParameterValues[pi][2];
                        *dst++ = paramList->ParameterValues[pi][3];
                        break;
-
                default:
                        _mesa_problem(NULL, "Bad param type in %s",
                                      __FUNCTION__);
@@ -173,11 +131,11 @@ static unsigned long t_dst_class(enum register_file file)
 
        switch (file) {
        case PROGRAM_TEMPORARY:
-               return VSF_OUT_CLASS_TMP;
+               return PVS_DST_REG_TEMPORARY;
        case PROGRAM_OUTPUT:
-               return VSF_OUT_CLASS_RESULT;
+               return PVS_DST_REG_OUT;
        case PROGRAM_ADDRESS:
-               return VSF_OUT_CLASS_ADDR;
+               return PVS_DST_REG_A0;
                /*
                   case PROGRAM_INPUT:
                   case PROGRAM_LOCAL_PARAM:
@@ -205,19 +163,17 @@ static unsigned long t_dst_index(struct r300_vertex_program *vp,
 
 static unsigned long t_src_class(enum register_file file)
 {
-
        switch (file) {
        case PROGRAM_TEMPORARY:
-               return VSF_IN_CLASS_TMP;
-
+               return PVS_SRC_REG_TEMPORARY;
        case PROGRAM_INPUT:
-               return VSF_IN_CLASS_ATTR;
-
+               return PVS_SRC_REG_INPUT;
        case PROGRAM_LOCAL_PARAM:
        case PROGRAM_ENV_PARAM:
        case PROGRAM_NAMED_PARAM:
+       case PROGRAM_CONSTANT:
        case PROGRAM_STATE_VAR:
-               return VSF_IN_CLASS_PARAM;
+               return PVS_SRC_REG_CONSTANT;
                /*
                   case PROGRAM_OUTPUT:
                   case PROGRAM_WRITE_ONLY:
@@ -230,7 +186,7 @@ static unsigned long t_src_class(enum register_file file)
        }
 }
 
-static inline unsigned long t_swizzle(GLubyte swizzle)
+static INLINE unsigned long t_swizzle(GLubyte swizzle)
 {
 /* this is in fact a NOP as the Mesa SWIZZLE_* are all identical to VSF_IN_COMPONENT_* */
        return swizzle;
@@ -242,8 +198,8 @@ 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);
+               fprintf(stderr, "vp null in call to %s from %s\n", __FUNCTION__,
+                       caller);
                return;
        }
 
@@ -292,7 +248,7 @@ static unsigned long t_src(struct r300_vertex_program *vp,
        /* src->NegateBase uses the NEGATE_ flags from program_instruction.h,
         * which equal our VSF_FLAGS_ values, so it's safe to just pass it here.
         */
-       return MAKE_VSF_SOURCE(t_src_index(vp, src),
+       return PVS_SRC_OPERAND(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)),
@@ -307,7 +263,7 @@ static unsigned long t_src_scalar(struct r300_vertex_program *vp,
        /* src->NegateBase uses the NEGATE_ flags from program_instruction.h,
         * which equal our VSF_FLAGS_ values, so it's safe to just pass it here.
         */
-       return MAKE_VSF_SOURCE(t_src_index(vp, src),
+       return PVS_SRC_OPERAND(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)),
@@ -330,397 +286,364 @@ static GLboolean valid_dst(struct r300_vertex_program *vp,
        return GL_TRUE;
 }
 
-/*
- * Instruction    Inputs  Output   Description
- * -----------    ------  ------   --------------------------------
- * ABS            v       v        absolute value
- * ADD            v,v     v        add
- * ARL            s       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
- *
- * Table X.5:  Summary of vertex program instructions.  "v" indicates a
- * floating-point vector input or output, "s" indicates a floating-point
- * scalar input, "ssss" indicates a scalar output replicated across a
- * 4-component result vector, and "a" indicates a single address register
- * component.
- */
-
-static GLuint *t_opcode_abs(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeABS(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
        //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
 
-       inst[0] =
-           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));
-
+       inst[0] = PVS_OP_DST_OPERAND(VE_MAXIMUM,
+                                    GL_FALSE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
        inst[1] = t_src(vp, &src[0]);
-       inst[2] =
-           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].
-                            NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+       inst[2] = PVS_SRC_OPERAND(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].
+                                  NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
            (src[0].RelAddr << 4);
        inst[3] = 0;
 
        return inst;
 }
 
-static GLuint *t_opcode_add(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeADD(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
-       unsigned long hw_op;
-
-#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;
-
-       inst[0] =
-           MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
-                       t_dst_mask(vpi->DstReg.WriteMask),
-                       t_dst_class(vpi->DstReg.File));
-       inst[1] = ONE_SRC_0;
-       inst[2] = t_src(vp, &src[0]);
-       inst[3] = t_src(vp, &src[1]);
-#else
-       inst[0] =
-           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));
+       inst[0] = PVS_OP_DST_OPERAND(VE_ADD,
+                                    GL_FALSE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
        inst[1] = t_src(vp, &src[0]);
        inst[2] = t_src(vp, &src[1]);
-       inst[3] = ZERO_SRC_1;
-
-#endif
+       inst[3] = __CONST(1, SWIZZLE_ZERO);
 
        return inst;
 }
 
-static GLuint *t_opcode_arl(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeARL(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
-       inst[0] =
-           MAKE_VSF_OP(R300_VPI_OUT_OP_ARL, t_dst_index(vp, &vpi->DstReg),
-                       t_dst_mask(vpi->DstReg.WriteMask),
-                       t_dst_class(vpi->DstReg.File));
-
+       inst[0] = PVS_OP_DST_OPERAND(VE_FLT2FIX_DX,
+                                    GL_FALSE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
        inst[1] = t_src(vp, &src[0]);
-       inst[2] = ZERO_SRC_0;
-       inst[3] = ZERO_SRC_0;
+       inst[2] = __CONST(0, SWIZZLE_ZERO);
+       inst[3] = __CONST(0, SWIZZLE_ZERO);
 
        return inst;
 }
 
-static GLuint *t_opcode_dp3(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeDP3(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
        //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ZERO} PARAM 0{} {X Y Z ZERO}
 
-       inst[0] =
-           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));
-
-       inst[1] =
-           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].
-                           NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) |
+       inst[0] = PVS_OP_DST_OPERAND(VE_DOT_PRODUCT,
+                                    GL_FALSE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
+       inst[1] = PVS_SRC_OPERAND(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].
+                                 NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) |
            (src[0].RelAddr << 4);
-
        inst[2] =
-           MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
+           PVS_SRC_OPERAND(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),
+                           t_swizzle(GET_SWZ(src[1].Swizzle, 2)), SWIZZLE_ZERO,
+                           t_src_class(src[1].File),
                            src[1].
                            NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) |
            (src[1].RelAddr << 4);
-
-       inst[3] = ZERO_SRC_1;
+       inst[3] = __CONST(1, SWIZZLE_ZERO);
 
        return inst;
 }
 
-static GLuint *t_opcode_dp4(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeDP4(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
-       inst[0] =
-           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));
-
+       inst[0] = PVS_OP_DST_OPERAND(VE_DOT_PRODUCT,
+                                    GL_FALSE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
        inst[1] = t_src(vp, &src[0]);
        inst[2] = t_src(vp, &src[1]);
-       inst[3] = ZERO_SRC_1;
+       inst[3] = __CONST(1, SWIZZLE_ZERO);
 
        return inst;
 }
 
-static GLuint *t_opcode_dph(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeDPH(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
        //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ONE} PARAM 0{} {X Y Z W}
-       inst[0] =
-           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));
-
-       inst[1] =
-           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].
-                           NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) |
+       inst[0] = PVS_OP_DST_OPERAND(VE_DOT_PRODUCT,
+                                    GL_FALSE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
+       inst[1] = PVS_SRC_OPERAND(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)),
+                                 PVS_SRC_SELECT_FORCE_1,
+                                 t_src_class(src[0].File),
+                                 src[0].
+                                 NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) |
            (src[0].RelAddr << 4);
        inst[2] = t_src(vp, &src[1]);
-       inst[3] = ZERO_SRC_1;
+       inst[3] = __CONST(1, SWIZZLE_ZERO);
 
        return inst;
 }
 
-static GLuint *t_opcode_dst(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeDST(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
-       inst[0] =
-           MAKE_VSF_OP(R300_VPI_OUT_OP_DST, t_dst_index(vp, &vpi->DstReg),
-                       t_dst_mask(vpi->DstReg.WriteMask),
-                       t_dst_class(vpi->DstReg.File));
-
+       inst[0] = PVS_OP_DST_OPERAND(VE_DISTANCE_VECTOR,
+                                    GL_FALSE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
        inst[1] = t_src(vp, &src[0]);
        inst[2] = t_src(vp, &src[1]);
-       inst[3] = ZERO_SRC_1;
+       inst[3] = __CONST(1, SWIZZLE_ZERO);
 
        return inst;
 }
 
-static GLuint *t_opcode_ex2(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeEX2(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
-       inst[0] =
-           MAKE_VSF_OP(R300_VPI_OUT_OP_EX2, t_dst_index(vp, &vpi->DstReg),
-                       t_dst_mask(vpi->DstReg.WriteMask),
-                       t_dst_class(vpi->DstReg.File));
-
+       inst[0] = PVS_OP_DST_OPERAND(ME_EXP_BASE2_FULL_DX,
+                                    GL_TRUE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
        inst[1] = t_src_scalar(vp, &src[0]);
-       inst[2] = ZERO_SRC_0;
-       inst[3] = ZERO_SRC_0;
+       inst[2] = __CONST(0, SWIZZLE_ZERO);
+       inst[3] = __CONST(0, SWIZZLE_ZERO);
 
        return inst;
 }
 
-static GLuint *t_opcode_exp(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeEXP(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
-       inst[0] =
-           MAKE_VSF_OP(R300_VPI_OUT_OP_EXP, t_dst_index(vp, &vpi->DstReg),
-                       t_dst_mask(vpi->DstReg.WriteMask),
-                       t_dst_class(vpi->DstReg.File));
-
+       inst[0] = PVS_OP_DST_OPERAND(ME_EXP_BASE2_DX,
+                                    GL_TRUE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
        inst[1] = t_src_scalar(vp, &src[0]);
-       inst[2] = ZERO_SRC_0;
-       inst[3] = ZERO_SRC_0;
+       inst[2] = __CONST(0, SWIZZLE_ZERO);
+       inst[3] = __CONST(0, SWIZZLE_ZERO);
 
        return inst;
 }
 
-static GLuint *t_opcode_flr(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3], int *u_temp_i)
+static GLuint *r300TranslateOpcodeFLR(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3],
+                                     int *u_temp_i)
 {
        /* 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 */
 
-       inst[0] =
-           MAKE_VSF_OP(R300_VPI_OUT_OP_FRC, *u_temp_i,
-                       t_dst_mask(vpi->DstReg.WriteMask),
-                       VSF_OUT_CLASS_TMP);
-
+       inst[0] = PVS_OP_DST_OPERAND(VE_FRACTION,
+                                    GL_FALSE,
+                                    GL_FALSE,
+                                    *u_temp_i,
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    PVS_DST_REG_TEMPORARY);
        inst[1] = t_src(vp, &src[0]);
-       inst[2] = ZERO_SRC_0;
-       inst[3] = ZERO_SRC_0;
+       inst[2] = __CONST(0, SWIZZLE_ZERO);
+       inst[3] = __CONST(0, SWIZZLE_ZERO);
        inst += 4;
 
-       inst[0] =
-           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));
-
+       inst[0] = PVS_OP_DST_OPERAND(VE_ADD,
+                                    GL_FALSE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
        inst[1] = t_src(vp, &src[0]);
-       inst[2] =
-           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[0].
-                            NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE
-                           /*VSF_FLAG_ALL */ );
-
-       inst[3] = ZERO_SRC_0;
+       inst[2] = PVS_SRC_OPERAND(*u_temp_i,
+                                 PVS_SRC_SELECT_X,
+                                 PVS_SRC_SELECT_Y,
+                                 PVS_SRC_SELECT_Z,
+                                 PVS_SRC_SELECT_W, PVS_SRC_REG_TEMPORARY,
+                                 /* Not 100% sure about this */
+                                 (!src[0].
+                                  NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE
+                                 /*VSF_FLAG_ALL */ );
+       inst[3] = __CONST(0, SWIZZLE_ZERO);
        (*u_temp_i)--;
 
        return inst;
 }
 
-static GLuint *t_opcode_frc(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeFRC(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
-       inst[0] =
-           MAKE_VSF_OP(R300_VPI_OUT_OP_FRC, t_dst_index(vp, &vpi->DstReg),
-                       t_dst_mask(vpi->DstReg.WriteMask),
-                       t_dst_class(vpi->DstReg.File));
-
+       inst[0] = PVS_OP_DST_OPERAND(VE_FRACTION,
+                                    GL_FALSE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
        inst[1] = t_src(vp, &src[0]);
-       inst[2] = ZERO_SRC_0;
-       inst[3] = ZERO_SRC_0;
+       inst[2] = __CONST(0, SWIZZLE_ZERO);
+       inst[3] = __CONST(0, SWIZZLE_ZERO);
 
        return inst;
 }
 
-static GLuint *t_opcode_lg2(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeLG2(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
        // LG2 RESULT 1.X Y Z W PARAM 0{} {X X X X}
 
-       inst[0] =
-           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));
-
-       inst[1] =
-           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].
-                           NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+       inst[0] = PVS_OP_DST_OPERAND(ME_LOG_BASE2_FULL_DX,
+                                    GL_TRUE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
+       inst[1] = PVS_SRC_OPERAND(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].
+                                 NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
            (src[0].RelAddr << 4);
-       inst[2] = ZERO_SRC_0;
-       inst[3] = ZERO_SRC_0;
+       inst[2] = __CONST(0, SWIZZLE_ZERO);
+       inst[3] = __CONST(0, SWIZZLE_ZERO);
 
        return inst;
 }
 
-static GLuint *t_opcode_lit(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeLIT(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
        //LIT TMP 1.Y Z TMP 1{} {X W Z Y} TMP 1{} {Y W Z X} TMP 1{} {Y X Z W}
 
-       inst[0] =
-           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));
+       inst[0] = PVS_OP_DST_OPERAND(ME_LIGHT_COEFF_DX,
+                                    GL_TRUE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
        /* NOTE: Users swizzling might not work. */
-       inst[1] = 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
-                                 VSF_IN_COMPONENT_ZERO,        // z
-                                 t_swizzle(GET_SWZ(src[0].Swizzle, 1)),        // y
+       inst[1] = PVS_SRC_OPERAND(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 0)),      // X
+                                 t_swizzle(GET_SWZ(src[0].Swizzle, 3)),        // W
+                                 PVS_SRC_SELECT_FORCE_0,       // Z
+                                 t_swizzle(GET_SWZ(src[0].Swizzle, 1)),        // Y
                                  t_src_class(src[0].File),
                                  src[0].
-                                 NegateBase ? VSF_FLAG_ALL :
-                                 VSF_FLAG_NONE) | (src[0].RelAddr << 4);
-       inst[2] = 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
-                                 VSF_IN_COMPONENT_ZERO,        // z
-                                 t_swizzle(GET_SWZ(src[0].Swizzle, 0)),        // x
+                                 NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+           (src[0].RelAddr << 4);
+       inst[2] = PVS_SRC_OPERAND(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)),      // Y
+                                 t_swizzle(GET_SWZ(src[0].Swizzle, 3)),        // W
+                                 PVS_SRC_SELECT_FORCE_0,       // Z
+                                 t_swizzle(GET_SWZ(src[0].Swizzle, 0)),        // X
                                  t_src_class(src[0].File),
                                  src[0].
-                                 NegateBase ? VSF_FLAG_ALL :
-                                 VSF_FLAG_NONE) | (src[0].RelAddr << 4);
-       inst[3] = 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
-                                 VSF_IN_COMPONENT_ZERO,        // z
-                                 t_swizzle(GET_SWZ(src[0].Swizzle, 3)),        // w
+                                 NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+           (src[0].RelAddr << 4);
+       inst[3] = PVS_SRC_OPERAND(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)),      // Y
+                                 t_swizzle(GET_SWZ(src[0].Swizzle, 0)),        // X
+                                 PVS_SRC_SELECT_FORCE_0,       // Z
+                                 t_swizzle(GET_SWZ(src[0].Swizzle, 3)),        // W
                                  t_src_class(src[0].File),
                                  src[0].
-                                 NegateBase ? VSF_FLAG_ALL :
-                                 VSF_FLAG_NONE) | (src[0].RelAddr << 4);
+                                 NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+           (src[0].RelAddr << 4);
 
        return inst;
 }
 
-static GLuint *t_opcode_log(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeLOG(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
-       inst[0] =
-           MAKE_VSF_OP(R300_VPI_OUT_OP_LOG, t_dst_index(vp, &vpi->DstReg),
-                       t_dst_mask(vpi->DstReg.WriteMask),
-                       t_dst_class(vpi->DstReg.File));
-
+       inst[0] = PVS_OP_DST_OPERAND(ME_LOG_BASE2_DX,
+                                    GL_TRUE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
        inst[1] = t_src_scalar(vp, &src[0]);
-       inst[2] = ZERO_SRC_0;
-       inst[3] = ZERO_SRC_0;
+       inst[2] = __CONST(0, SWIZZLE_ZERO);
+       inst[3] = __CONST(0, SWIZZLE_ZERO);
 
        return inst;
 }
 
-static GLuint *t_opcode_mad(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeMAD(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
-       unsigned long hw_op;
-
-       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;
-
-       inst[0] =
-           MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
-                       t_dst_mask(vpi->DstReg.WriteMask),
-                       t_dst_class(vpi->DstReg.File));
+       inst[0] = PVS_OP_DST_OPERAND(PVS_MACRO_OP_2CLK_MADD,
+                                    GL_FALSE,
+                                    GL_TRUE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
        inst[1] = t_src(vp, &src[0]);
        inst[2] = t_src(vp, &src[1]);
        inst[3] = t_src(vp, &src[2]);
@@ -728,323 +651,302 @@ static GLuint *t_opcode_mad(struct r300_vertex_program *vp,
        return inst;
 }
 
-static GLuint *t_opcode_max(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeMAX(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
-       inst[0] =
-           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));
-
+       inst[0] = PVS_OP_DST_OPERAND(VE_MAXIMUM,
+                                    GL_FALSE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
        inst[1] = t_src(vp, &src[0]);
        inst[2] = t_src(vp, &src[1]);
-       inst[3] = ZERO_SRC_1;
+       inst[3] = __CONST(1, SWIZZLE_ZERO);
 
        return inst;
 }
 
-static GLuint *t_opcode_min(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeMIN(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
-       inst[0] =
-           MAKE_VSF_OP(R300_VPI_OUT_OP_MIN, t_dst_index(vp, &vpi->DstReg),
-                       t_dst_mask(vpi->DstReg.WriteMask),
-                       t_dst_class(vpi->DstReg.File));
-
+       inst[0] = PVS_OP_DST_OPERAND(VE_MINIMUM,
+                                    GL_FALSE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
        inst[1] = t_src(vp, &src[0]);
        inst[2] = t_src(vp, &src[1]);
-       inst[3] = ZERO_SRC_1;
+       inst[3] = __CONST(1, SWIZZLE_ZERO);
 
        return inst;
 }
 
-static GLuint *t_opcode_mov(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeMOV(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
        //ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO}
 
-#if 1
-       inst[0] =
-           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));
+       inst[0] = PVS_OP_DST_OPERAND(VE_ADD,
+                                    GL_FALSE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
        inst[1] = t_src(vp, &src[0]);
-       inst[2] = ZERO_SRC_0;
-       inst[3] = ZERO_SRC_0;
-#else
-       hw_op =
-           (src[0].File ==
-            PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
-           R300_VPI_OUT_OP_MAD;
-
-       inst[0] =
-           MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
-                       t_dst_mask(vpi->DstReg.WriteMask),
-                       t_dst_class(vpi->DstReg.File));
-       inst[1] = t_src(vp, &src[0]);
-       inst[2] = ONE_SRC_0;
-       inst[3] = ZERO_SRC_0;
-#endif
+       inst[2] = __CONST(0, SWIZZLE_ZERO);
+       inst[3] = __CONST(0, SWIZZLE_ZERO);
 
        return inst;
 }
 
-static GLuint *t_opcode_mul(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeMUL(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
-       unsigned long hw_op;
-
-       // 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;
-
-       inst[0] =
-           MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
-                       t_dst_mask(vpi->DstReg.WriteMask),
-                       t_dst_class(vpi->DstReg.File));
+       inst[0] = PVS_OP_DST_OPERAND(VE_MULTIPLY,
+                                    GL_FALSE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
        inst[1] = t_src(vp, &src[0]);
        inst[2] = t_src(vp, &src[1]);
-
-       inst[3] = ZERO_SRC_1;
+       inst[3] = __CONST(1, SWIZZLE_ZERO);
 
        return inst;
 }
 
-static GLuint *t_opcode_pow(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodePOW(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
-       inst[0] =
-           MAKE_VSF_OP(R300_VPI_OUT_OP_POW, t_dst_index(vp, &vpi->DstReg),
-                       t_dst_mask(vpi->DstReg.WriteMask),
-                       t_dst_class(vpi->DstReg.File));
+       inst[0] = PVS_OP_DST_OPERAND(ME_POWER_FUNC_FF,
+                                    GL_TRUE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
        inst[1] = t_src_scalar(vp, &src[0]);
-       inst[2] = ZERO_SRC_0;
+       inst[2] = __CONST(0, SWIZZLE_ZERO);
        inst[3] = t_src_scalar(vp, &src[1]);
 
        return inst;
 }
 
-static GLuint *t_opcode_rcp(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeRCP(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
-       inst[0] =
-           MAKE_VSF_OP(R300_VPI_OUT_OP_RCP, t_dst_index(vp, &vpi->DstReg),
-                       t_dst_mask(vpi->DstReg.WriteMask),
-                       t_dst_class(vpi->DstReg.File));
-
+       inst[0] = PVS_OP_DST_OPERAND(ME_RECIP_DX,
+                                    GL_TRUE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
        inst[1] = t_src_scalar(vp, &src[0]);
-       inst[2] = ZERO_SRC_0;
-       inst[3] = ZERO_SRC_0;
+       inst[2] = __CONST(0, SWIZZLE_ZERO);
+       inst[3] = __CONST(0, SWIZZLE_ZERO);
 
        return inst;
 }
 
-static GLuint *t_opcode_rsq(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeRSQ(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
-       inst[0] =
-           MAKE_VSF_OP(R300_VPI_OUT_OP_RSQ, t_dst_index(vp, &vpi->DstReg),
-                       t_dst_mask(vpi->DstReg.WriteMask),
-                       t_dst_class(vpi->DstReg.File));
-
+       inst[0] = PVS_OP_DST_OPERAND(ME_RECIP_SQRT_DX,
+                                    GL_TRUE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
        inst[1] = t_src_scalar(vp, &src[0]);
-       inst[2] = ZERO_SRC_0;
-       inst[3] = ZERO_SRC_0;
+       inst[2] = __CONST(0, SWIZZLE_ZERO);
+       inst[3] = __CONST(0, SWIZZLE_ZERO);
 
        return inst;
 }
 
-static GLuint *t_opcode_sge(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeSGE(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
-       inst[0] =
-           MAKE_VSF_OP(R300_VPI_OUT_OP_SGE, t_dst_index(vp, &vpi->DstReg),
-                       t_dst_mask(vpi->DstReg.WriteMask),
-                       t_dst_class(vpi->DstReg.File));
-
+       inst[0] = PVS_OP_DST_OPERAND(VE_SET_GREATER_THAN_EQUAL,
+                                    GL_FALSE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
        inst[1] = t_src(vp, &src[0]);
        inst[2] = t_src(vp, &src[1]);
-       inst[3] = ZERO_SRC_1;
+       inst[3] = __CONST(1, SWIZZLE_ZERO);
 
        return inst;
 }
 
-static GLuint *t_opcode_slt(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeSLT(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
-       inst[0] =
-           MAKE_VSF_OP(R300_VPI_OUT_OP_SLT, t_dst_index(vp, &vpi->DstReg),
-                       t_dst_mask(vpi->DstReg.WriteMask),
-                       t_dst_class(vpi->DstReg.File));
-
+       inst[0] = PVS_OP_DST_OPERAND(VE_SET_LESS_THAN,
+                                    GL_FALSE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
        inst[1] = t_src(vp, &src[0]);
        inst[2] = t_src(vp, &src[1]);
-       inst[3] = ZERO_SRC_1;
+       inst[3] = __CONST(1, SWIZZLE_ZERO);
 
        return inst;
 }
 
-static GLuint *t_opcode_sub(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeSUB(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
-       unsigned long hw_op;
-
        //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;
-
-       inst[0] =
-           MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
-                       t_dst_mask(vpi->DstReg.WriteMask),
-                       t_dst_class(vpi->DstReg.File));
+#if 0
+       inst[0] = PVS_OP_DST_OPERAND(VE_ADD,
+                                    GL_FALSE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
        inst[1] = t_src(vp, &src[0]);
-       inst[2] = ONE_SRC_0;
-       inst[3] =
-           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].
-                            NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+       inst[2] = PVS_SRC_OPERAND(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].
+                                  NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
            (src[1].RelAddr << 4);
+       inst[3] = 0;
 #else
        inst[0] =
-           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));
-
+           PVS_OP_DST_OPERAND(VE_MULTIPLY_ADD,
+                              GL_FALSE,
+                              GL_FALSE,
+                              t_dst_index(vp, &vpi->DstReg),
+                              t_dst_mask(vpi->DstReg.WriteMask),
+                              t_dst_class(vpi->DstReg.File));
        inst[1] = t_src(vp, &src[0]);
-       inst[2] =
-           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].
-                            NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+       inst[2] = __CONST(0, SWIZZLE_ONE);
+       inst[3] = PVS_SRC_OPERAND(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].
+                                  NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
            (src[1].RelAddr << 4);
-       inst[3] = 0;
 #endif
 
        return inst;
 }
 
-static GLuint *t_opcode_swz(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3])
+static GLuint *r300TranslateOpcodeSWZ(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3])
 {
        //ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO}
 
-#if 1
-       inst[0] =
-           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));
+       inst[0] = PVS_OP_DST_OPERAND(VE_ADD,
+                                    GL_FALSE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
        inst[1] = t_src(vp, &src[0]);
-       inst[2] = ZERO_SRC_0;
-       inst[3] = ZERO_SRC_0;
-#else
-       hw_op =
-           (src[0].File ==
-            PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
-           R300_VPI_OUT_OP_MAD;
-
-       inst[0] =
-           MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
-                       t_dst_mask(vpi->DstReg.WriteMask),
-                       t_dst_class(vpi->DstReg.File));
-       inst[1] = t_src(vp, &src[0]);
-       inst[2] = ONE_SRC_0;
-       inst[3] = ZERO_SRC_0;
-#endif
+       inst[2] = __CONST(0, SWIZZLE_ZERO);
+       inst[3] = __CONST(0, SWIZZLE_ZERO);
 
        return inst;
 }
 
-static GLuint *t_opcode_xpd(struct r300_vertex_program *vp,
-                           struct prog_instruction *vpi, GLuint * inst,
-                           struct prog_src_register src[3], int *u_temp_i)
+static GLuint *r300TranslateOpcodeXPD(struct r300_vertex_program *vp,
+                                     struct prog_instruction *vpi,
+                                     GLuint * inst,
+                                     struct prog_src_register src[3],
+                                     int *u_temp_i)
 {
        /* mul r0, r1.yzxw, r2.zxyw
           mad r0, -r2.yzxw, r1.zxyw, r0
-          NOTE: might need MAD_2
         */
 
-       inst[0] =
-           MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, *u_temp_i,
-                       t_dst_mask(vpi->DstReg.WriteMask),
-                       VSF_OUT_CLASS_TMP);
-
-       inst[1] = 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
+       inst[0] = PVS_OP_DST_OPERAND(VE_MULTIPLY_ADD,
+                                    GL_FALSE,
+                                    GL_FALSE,
+                                    *u_temp_i,
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    PVS_DST_REG_TEMPORARY);
+       inst[1] = PVS_SRC_OPERAND(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].
-                                 NegateBase ? VSF_FLAG_ALL :
-                                 VSF_FLAG_NONE) | (src[0].RelAddr << 4);
-
-       inst[2] = 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
+                                 NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+           (src[0].RelAddr << 4);
+       inst[2] = PVS_SRC_OPERAND(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].
-                                 NegateBase ? VSF_FLAG_ALL :
-                                 VSF_FLAG_NONE) | (src[1].RelAddr << 4);
-
-       inst[3] = ZERO_SRC_1;
+                                 NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+           (src[1].RelAddr << 4);
+       inst[3] = __CONST(1, SWIZZLE_ZERO);
        inst += 4;
-       (*u_temp_i)--;
 
-       inst[0] =
-           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));
-
-       inst[1] = 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
+       inst[0] = PVS_OP_DST_OPERAND(VE_MULTIPLY_ADD,
+                                    GL_FALSE,
+                                    GL_FALSE,
+                                    t_dst_index(vp, &vpi->DstReg),
+                                    t_dst_mask(vpi->DstReg.WriteMask),
+                                    t_dst_class(vpi->DstReg.File));
+       inst[1] = PVS_SRC_OPERAND(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].
-                                  NegateBase) ? VSF_FLAG_ALL :
-                                 VSF_FLAG_NONE) | (src[1].RelAddr << 4);
-
-       inst[2] = 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
+                                  NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+           (src[1].RelAddr << 4);
+       inst[2] = PVS_SRC_OPERAND(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].
-                                 NegateBase ? VSF_FLAG_ALL :
-                                 VSF_FLAG_NONE) | (src[0].RelAddr << 4);
-
+                                 NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+           (src[0].RelAddr << 4);
        inst[3] =
-           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);
+           PVS_SRC_OPERAND(*u_temp_i, PVS_SRC_SELECT_X, PVS_SRC_SELECT_Y,
+                           PVS_SRC_SELECT_Z, PVS_SRC_SELECT_W,
+                           PVS_SRC_REG_TEMPORARY, VSF_FLAG_NONE);
+
+       (*u_temp_i)--;
 
        return inst;
 }
@@ -1145,23 +1047,24 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp,
                if (num_operands == 3) {        /* TODO: scalars */
                        if (CMP_SRCS(src[1], src[2])
                            || CMP_SRCS(src[0], src[2])) {
-                               inst[0] =
-                                   MAKE_VSF_OP(R300_VPI_OUT_OP_ADD,
-                                               u_temp_i, VSF_FLAG_ALL,
-                                               VSF_OUT_CLASS_TMP);
-
+                               inst[0] = PVS_OP_DST_OPERAND(VE_ADD,
+                                                            GL_FALSE,
+                                                            GL_FALSE,
+                                                            u_temp_i,
+                                                            VSF_FLAG_ALL,
+                                                            PVS_DST_REG_TEMPORARY);
                                inst[1] =
-                                   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) |
-                                   (src[2].RelAddr << 4);
-
-                               inst[2] = ZERO_SRC_2;
-                               inst[3] = ZERO_SRC_2;
+                                   PVS_SRC_OPERAND(t_src_index(vp, &src[2]),
+                                                   SWIZZLE_X,
+                                                   SWIZZLE_Y,
+                                                   SWIZZLE_Z,
+                                                   SWIZZLE_W,
+                                                   t_src_class(src[2].File),
+                                                   VSF_FLAG_NONE) | (src[2].
+                                                                     RelAddr <<
+                                                                     4);
+                               inst[2] = __CONST(2, SWIZZLE_ZERO);
+                               inst[3] = __CONST(2, SWIZZLE_ZERO);
                                inst += 4;
 
                                src[2].File = PROGRAM_TEMPORARY;
@@ -1173,23 +1076,24 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp,
 
                if (num_operands >= 2) {
                        if (CMP_SRCS(src[1], src[0])) {
-                               inst[0] =
-                                   MAKE_VSF_OP(R300_VPI_OUT_OP_ADD,
-                                               u_temp_i, VSF_FLAG_ALL,
-                                               VSF_OUT_CLASS_TMP);
-
+                               inst[0] = PVS_OP_DST_OPERAND(VE_ADD,
+                                                            GL_FALSE,
+                                                            GL_FALSE,
+                                                            u_temp_i,
+                                                            VSF_FLAG_ALL,
+                                                            PVS_DST_REG_TEMPORARY);
                                inst[1] =
-                                   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) |
-                                   (src[0].RelAddr << 4);
-
-                               inst[2] = ZERO_SRC_0;
-                               inst[3] = ZERO_SRC_0;
+                                   PVS_SRC_OPERAND(t_src_index(vp, &src[0]),
+                                                   SWIZZLE_X,
+                                                   SWIZZLE_Y,
+                                                   SWIZZLE_Z,
+                                                   SWIZZLE_W,
+                                                   t_src_class(src[0].File),
+                                                   VSF_FLAG_NONE) | (src[0].
+                                                                     RelAddr <<
+                                                                     4);
+                               inst[2] = __CONST(0, SWIZZLE_ZERO);
+                               inst[3] = __CONST(0, SWIZZLE_ZERO);
                                inst += 4;
 
                                src[0].File = PROGRAM_TEMPORARY;
@@ -1201,89 +1105,87 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp,
 
                switch (vpi->Opcode) {
                case OPCODE_ABS:
-                       inst = t_opcode_abs(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeABS(vp, vpi, inst, src);
                        break;
                case OPCODE_ADD:
-                       inst = t_opcode_add(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeADD(vp, vpi, inst, src);
                        break;
                case OPCODE_ARL:
-                       inst = t_opcode_arl(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeARL(vp, vpi, inst, src);
                        break;
                case OPCODE_DP3:
-                       inst = t_opcode_dp3(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeDP3(vp, vpi, inst, src);
                        break;
                case OPCODE_DP4:
-                       inst = t_opcode_dp4(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeDP4(vp, vpi, inst, src);
                        break;
                case OPCODE_DPH:
-                       inst = t_opcode_dph(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeDPH(vp, vpi, inst, src);
                        break;
                case OPCODE_DST:
-                       inst = t_opcode_dst(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeDST(vp, vpi, inst, src);
                        break;
                case OPCODE_EX2:
-                       inst = t_opcode_ex2(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeEX2(vp, vpi, inst, src);
                        break;
                case OPCODE_EXP:
-                       inst = t_opcode_exp(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeEXP(vp, vpi, inst, src);
                        break;
                case OPCODE_FLR:
-                       inst =
-                           t_opcode_flr(vp, vpi, inst, src, /* FIXME */
-                                        &u_temp_i);
+                       inst = r300TranslateOpcodeFLR(vp, vpi, inst, src,       /* FIXME */
+                                                     &u_temp_i);
                        break;
                case OPCODE_FRC:
-                       inst = t_opcode_frc(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeFRC(vp, vpi, inst, src);
                        break;
                case OPCODE_LG2:
-                       inst = t_opcode_lg2(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeLG2(vp, vpi, inst, src);
                        break;
                case OPCODE_LIT:
-                       inst = t_opcode_lit(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeLIT(vp, vpi, inst, src);
                        break;
                case OPCODE_LOG:
-                       inst = t_opcode_log(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeLOG(vp, vpi, inst, src);
                        break;
                case OPCODE_MAD:
-                       inst = t_opcode_mad(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeMAD(vp, vpi, inst, src);
                        break;
                case OPCODE_MAX:
-                       inst = t_opcode_max(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeMAX(vp, vpi, inst, src);
                        break;
                case OPCODE_MIN:
-                       inst = t_opcode_min(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeMIN(vp, vpi, inst, src);
                        break;
                case OPCODE_MOV:
-                       inst = t_opcode_mov(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeMOV(vp, vpi, inst, src);
                        break;
                case OPCODE_MUL:
-                       inst = t_opcode_mul(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeMUL(vp, vpi, inst, src);
                        break;
                case OPCODE_POW:
-                       inst = t_opcode_pow(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodePOW(vp, vpi, inst, src);
                        break;
                case OPCODE_RCP:
-                       inst = t_opcode_rcp(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeRCP(vp, vpi, inst, src);
                        break;
                case OPCODE_RSQ:
-                       inst = t_opcode_rsq(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeRSQ(vp, vpi, inst, src);
                        break;
                case OPCODE_SGE:
-                       inst = t_opcode_sge(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeSGE(vp, vpi, inst, src);
                        break;
                case OPCODE_SLT:
-                       inst = t_opcode_slt(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeSLT(vp, vpi, inst, src);
                        break;
                case OPCODE_SUB:
-                       inst = t_opcode_sub(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeSUB(vp, vpi, inst, src);
                        break;
                case OPCODE_SWZ:
-                       inst = t_opcode_swz(vp, vpi, inst, src);
+                       inst = r300TranslateOpcodeSWZ(vp, vpi, inst, src);
                        break;
                case OPCODE_XPD:
-                       inst =
-                           t_opcode_xpd(vp, vpi, inst, src, /* FIXME */
-                                        &u_temp_i);
+                       inst = r300TranslateOpcodeXPD(vp, vpi, inst, src,       /* FIXME */
+                                                     &u_temp_i);
                        break;
                default:
                        assert(0);
@@ -1291,6 +1193,23 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp,
                }
        }
 
+       /* Some outputs may be artificially added, to match the inputs
+          of the fragment program. Blank the outputs here. */
+       for (i = 0; i < VERT_RESULT_MAX; i++) {
+               if (vp->key.OutputsAdded & (1 << i)) {
+                       inst[0] = PVS_OP_DST_OPERAND(VE_ADD,
+                                                    GL_FALSE,
+                                                    GL_FALSE,
+                                                    vp->outputs[i],
+                                                    VSF_FLAG_ALL,
+                                                    PVS_DST_REG_OUT);
+                       inst[1] = __CONST(0, SWIZZLE_ZERO);
+                       inst[2] = __CONST(0, SWIZZLE_ZERO);
+                       inst[3] = __CONST(0, SWIZZLE_ZERO);
+                       inst += 4;
+               }
+       }
+
        vp->program.length = (inst - vp->program.body.i);
        if (vp->program.length >= VSF_MAX_FRAGMENT_LENGTH) {
                vp->program.length = 0;
@@ -1303,14 +1222,16 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp,
 #endif
 }
 
+/* DP4 version seems to trigger some hw peculiarity */
+//#define PREFER_DP4
+
 static void position_invariant(struct gl_program *prog)
 {
        struct prog_instruction *vpi;
        struct gl_program_parameter_list *paramList;
        int i;
 
-       gl_state_index tokens[STATE_LENGTH] =
-           { STATE_MVP_MATRIX, 0, 0, 0, 0 };
+       gl_state_index tokens[STATE_LENGTH] = { STATE_MVP_MATRIX, 0, 0, 0, 0 };
 
        /* tokens[4] = matrix modifier */
 #ifdef PREFER_DP4
@@ -1390,8 +1311,8 @@ static void position_invariant(struct gl_program *prog)
        assert(vpi->Opcode == OPCODE_END);
 }
 
-static void insert_wpos(struct r300_vertex_program *vp,
-                       struct gl_program *prog, GLuint temp_index)
+static void insert_wpos(struct r300_vertex_program *vp, struct gl_program *prog,
+                       GLuint temp_index)
 {
        struct prog_instruction *vpi;
        struct prog_instruction *vpi_insert;
@@ -1404,8 +1325,8 @@ static void insert_wpos(struct r300_vertex_program *vp,
                                prog->NumInstructions - 1);
        /* END */
        _mesa_copy_instructions(&vpi[prog->NumInstructions + 1],
-                               &prog->Instructions[prog->NumInstructions -
-                                                   1], 1);
+                               &prog->Instructions[prog->NumInstructions - 1],
+                               1);
        vpi_insert = &vpi[prog->NumInstructions - 1];
 
        vpi_insert[i].Opcode = OPCODE_MOV;
@@ -1485,6 +1406,15 @@ static struct r300_vertex_program *build_program(struct r300_vertex_program_key
        return vp;
 }
 
+static void add_outputs(struct r300_vertex_program_key *key, GLint vert)
+{
+       if (key->OutputsWritten & (1 << vert))
+               return;
+
+       key->OutputsWritten |= 1 << vert;
+       key->OutputsAdded |= 1 << vert;
+}
+
 void r300SelectVertexShader(r300ContextPtr r300)
 {
        GLcontext *ctx = ctx = r300->radeon.glCtx;
@@ -1495,8 +1425,9 @@ void r300SelectVertexShader(r300ContextPtr r300)
        struct r300_vertex_program *vp;
        GLint wpos_idx;
 
-       vpc =
-           (struct r300_vertex_program_cont *)ctx->VertexProgram._Current;
+       vpc = (struct r300_vertex_program_cont *)ctx->VertexProgram._Current;
+       wanted_key.InputsRead = vpc->mesa_program.Base.InputsRead;
+       wanted_key.OutputsWritten = vpc->mesa_program.Base.OutputsWritten;
        InputsRead = ctx->FragmentProgram._Current->Base.InputsRead;
 
        wpos_idx = -1;
@@ -1510,33 +1441,29 @@ void r300SelectVertexShader(r300ContextPtr r300)
                        _mesa_exit(-1);
                }
 
-               InputsRead |= (FRAG_BIT_TEX0 << i);
+               wanted_key.OutputsWritten |= 1 << (VERT_RESULT_TEX0 + i);
                wpos_idx = i;
        }
-       wanted_key.InputsRead = vpc->mesa_program.Base.InputsRead;
-       wanted_key.OutputsWritten = vpc->mesa_program.Base.OutputsWritten;
 
-       wanted_key.OutputsWritten |= 1 << VERT_RESULT_HPOS;
+       add_outputs(&wanted_key, VERT_RESULT_HPOS);
 
        if (InputsRead & FRAG_BIT_COL0) {
-               wanted_key.OutputsWritten |= 1 << VERT_RESULT_COL0;
+               add_outputs(&wanted_key, VERT_RESULT_COL0);
        }
 
-       if ((InputsRead & FRAG_BIT_COL1)) {
-               wanted_key.OutputsWritten |= 1 << VERT_RESULT_COL1;
+       if (InputsRead & FRAG_BIT_COL1) {
+               add_outputs(&wanted_key, VERT_RESULT_COL1);
        }
 
        for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
                if (InputsRead & (FRAG_BIT_TEX0 << i)) {
-                       wanted_key.OutputsWritten |=
-                           1 << (VERT_RESULT_TEX0 + i);
+                       add_outputs(&wanted_key, VERT_RESULT_TEX0 + i);
                }
        }
 
        if (vpc->mesa_program.IsPositionInvariant) {
                /* we wan't position don't we ? */
                wanted_key.InputsRead |= (1 << VERT_ATTRIB_POS);
-               wanted_key.OutputsWritten |= (1 << VERT_RESULT_HPOS);
        }
 
        for (vp = vpc->progs; vp; vp = vp->next)
index 3df0eee799108b83af29504abea50bc85593ade9..2f35f02bc848fa42863363c824c2aa500ea9a9dc 100644 (file)
@@ -3,6 +3,25 @@
 
 #include "r300_reg.h"
 
+#define PVS_OP_DST_OPERAND(opcode, math_inst, macro_inst, reg_index, reg_writemask, reg_class) \
+        (((opcode & PVS_DST_OPCODE_MASK) << PVS_DST_OPCODE_SHIFT)      \
+        | ((math_inst & PVS_DST_MATH_INST_MASK) << PVS_DST_MATH_INST_SHIFT)    \
+        | ((macro_inst & PVS_DST_MACRO_INST_MASK) << PVS_DST_MACRO_INST_SHIFT) \
+        | ((reg_index & PVS_DST_OFFSET_MASK) << PVS_DST_OFFSET_SHIFT)  \
+        | ((reg_writemask & 0xf) << PVS_DST_WE_X_SHIFT)        /* X Y Z W */   \
+        | ((reg_class & PVS_DST_REG_TYPE_MASK) << PVS_DST_REG_TYPE_SHIFT))
+
+#define PVS_SRC_OPERAND(in_reg_index, comp_x, comp_y, comp_z, comp_w, reg_class, negate)       \
+       (((in_reg_index & PVS_SRC_OFFSET_MASK) << PVS_SRC_OFFSET_SHIFT)                         \
+        | ((comp_x & PVS_SRC_SWIZZLE_X_MASK) << PVS_SRC_SWIZZLE_X_SHIFT)                       \
+        | ((comp_y & PVS_SRC_SWIZZLE_Y_MASK) << PVS_SRC_SWIZZLE_Y_SHIFT)                       \
+        | ((comp_z & PVS_SRC_SWIZZLE_Z_MASK) << PVS_SRC_SWIZZLE_Z_SHIFT)                       \
+        | ((comp_w & PVS_SRC_SWIZZLE_W_MASK) << PVS_SRC_SWIZZLE_W_SHIFT)                       \
+        | ((negate & 0xf) << PVS_SRC_MODIFIER_X_SHIFT) /* X Y Z W */                           \
+        | ((reg_class & PVS_SRC_REG_TYPE_MASK) << PVS_SRC_REG_TYPE_SHIFT))
+
+#if 1
+
 #define VSF_FLAG_X     1
 #define VSF_FLAG_Y     2
 #define VSF_FLAG_Z     4
 #define VSF_FLAG_ALL  0xf
 #define VSF_FLAG_NONE  0
 
-#define VSF_OUT_CLASS_TMP      0
-#define VSF_OUT_CLASS_ADDR     1
-#define VSF_OUT_CLASS_RESULT   2
-
-/* first DWORD 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 DWORDs 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
 
 #endif
diff --git a/src/mesa/drivers/dri/r300/r500_fragprog.c b/src/mesa/drivers/dri/r300/r500_fragprog.c
new file mode 100644 (file)
index 0000000..75dae86
--- /dev/null
@@ -0,0 +1,700 @@
+/*
+ * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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 "r500_fragprog.h"
+
+#include "radeon_nqssadce.h"
+#include "radeon_program_alu.h"
+
+
+static struct prog_src_register shadow_ambient(struct gl_program *program, int tmu)
+{
+       gl_state_index fail_value_tokens[STATE_LENGTH] = {
+               STATE_INTERNAL, STATE_SHADOW_AMBIENT, 0, 0, 0
+       };
+       struct prog_src_register reg = { 0, };
+
+       fail_value_tokens[2] = tmu;
+       reg.File = PROGRAM_STATE_VAR;
+       reg.Index = _mesa_add_state_reference(program->Parameters, fail_value_tokens);
+       reg.Swizzle = SWIZZLE_WWWW;
+       return reg;
+}
+
+/**
+ * Transform TEX, TXP, TXB, and KIL instructions in the following way:
+ *  - premultiply texture coordinates for RECT
+ *  - extract operand swizzles
+ *  - introduce a temporary register when write masks are needed
+ *
+ */
+static GLboolean transform_TEX(
+       struct radeon_transform_context *t,
+       struct prog_instruction* orig_inst, void* data)
+{
+       struct r500_fragment_program_compiler *compiler =
+               (struct r500_fragment_program_compiler*)data;
+       struct prog_instruction inst = *orig_inst;
+       struct prog_instruction* tgt;
+       GLboolean destredirect = GL_FALSE;
+
+       if (inst.Opcode != OPCODE_TEX &&
+           inst.Opcode != OPCODE_TXB &&
+           inst.Opcode != OPCODE_TXP &&
+           inst.Opcode != OPCODE_KIL)
+               return GL_FALSE;
+
+       /* ARB_shadow & EXT_shadow_funcs */
+       if (inst.Opcode != OPCODE_KIL &&
+           t->Program->ShadowSamplers & (1 << inst.TexSrcUnit)) {
+               GLuint comparefunc = GL_NEVER + compiler->fp->state.unit[inst.TexSrcUnit].texture_compare_func;
+
+               if (comparefunc == GL_NEVER || comparefunc == GL_ALWAYS) {
+                       tgt = radeonAppendInstructions(t->Program, 1);
+
+                       tgt->Opcode = OPCODE_MOV;
+                       tgt->DstReg = inst.DstReg;
+                       if (comparefunc == GL_ALWAYS) {
+                               tgt->SrcReg[0].File = PROGRAM_BUILTIN;
+                               tgt->SrcReg[0].Swizzle = SWIZZLE_1111;
+                       } else {
+                               tgt->SrcReg[0] = shadow_ambient(t->Program, inst.TexSrcUnit);
+                       }
+                       return GL_TRUE;
+               }
+
+               inst.DstReg.File = PROGRAM_TEMPORARY;
+               inst.DstReg.Index = radeonFindFreeTemporary(t);
+               inst.DstReg.WriteMask = WRITEMASK_XYZW;
+       } else if (inst.Opcode != OPCODE_KIL && inst.DstReg.File != PROGRAM_TEMPORARY) {
+               int tempreg = radeonFindFreeTemporary(t);
+
+               inst.DstReg.File = PROGRAM_TEMPORARY;
+               inst.DstReg.Index = tempreg;
+               inst.DstReg.WriteMask = WRITEMASK_XYZW;
+               destredirect = GL_TRUE;
+       }
+
+       tgt = radeonAppendInstructions(t->Program, 1);
+       _mesa_copy_instructions(tgt, &inst, 1);
+
+       if (inst.Opcode != OPCODE_KIL &&
+           t->Program->ShadowSamplers & (1 << inst.TexSrcUnit)) {
+               GLuint comparefunc = GL_NEVER + compiler->fp->state.unit[inst.TexSrcUnit].texture_compare_func;
+               GLuint depthmode = compiler->fp->state.unit[inst.TexSrcUnit].depth_texture_mode;
+               int rcptemp = radeonFindFreeTemporary(t);
+               int pass, fail;
+
+               tgt = radeonAppendInstructions(t->Program, 3);
+
+               tgt[0].Opcode = OPCODE_RCP;
+               tgt[0].DstReg.File = PROGRAM_TEMPORARY;
+               tgt[0].DstReg.Index = rcptemp;
+               tgt[0].DstReg.WriteMask = WRITEMASK_W;
+               tgt[0].SrcReg[0] = inst.SrcReg[0];
+               tgt[0].SrcReg[0].Swizzle = SWIZZLE_WWWW;
+
+               tgt[1].Opcode = OPCODE_MAD;
+               tgt[1].DstReg = inst.DstReg;
+               tgt[1].DstReg.WriteMask = orig_inst->DstReg.WriteMask;
+               tgt[1].SrcReg[0] = inst.SrcReg[0];
+               tgt[1].SrcReg[0].Swizzle = SWIZZLE_ZZZZ;
+               tgt[1].SrcReg[1].File = PROGRAM_TEMPORARY;
+               tgt[1].SrcReg[1].Index = rcptemp;
+               tgt[1].SrcReg[1].Swizzle = SWIZZLE_WWWW;
+               tgt[1].SrcReg[2].File = PROGRAM_TEMPORARY;
+               tgt[1].SrcReg[2].Index = inst.DstReg.Index;
+               if (depthmode == 0) /* GL_LUMINANCE */
+                       tgt[1].SrcReg[2].Swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z);
+               else if (depthmode == 2) /* GL_ALPHA */
+                       tgt[1].SrcReg[2].Swizzle = SWIZZLE_WWWW;
+
+               /* Recall that SrcReg[0] is tex, SrcReg[2] is r and:
+                *   r  < tex  <=>      -tex+r < 0
+                *   r >= tex  <=> not (-tex+r < 0 */
+               if (comparefunc == GL_LESS || comparefunc == GL_GEQUAL)
+                       tgt[1].SrcReg[2].NegateBase = tgt[0].SrcReg[2].NegateBase ^ NEGATE_XYZW;
+               else
+                       tgt[1].SrcReg[0].NegateBase = tgt[0].SrcReg[0].NegateBase ^ NEGATE_XYZW;
+
+               tgt[2].Opcode = OPCODE_CMP;
+               tgt[2].DstReg = orig_inst->DstReg;
+               tgt[2].SrcReg[0].File = PROGRAM_TEMPORARY;
+               tgt[2].SrcReg[0].Index = tgt[1].DstReg.Index;
+
+               if (comparefunc == GL_LESS || comparefunc == GL_GREATER) {
+                       pass = 1;
+                       fail = 2;
+               } else {
+                       pass = 2;
+                       fail = 1;
+               }
+
+               tgt[2].SrcReg[pass].File = PROGRAM_BUILTIN;
+               tgt[2].SrcReg[pass].Swizzle = SWIZZLE_1111;
+               tgt[2].SrcReg[fail] = shadow_ambient(t->Program, inst.TexSrcUnit);
+       } else if (destredirect) {
+               tgt = radeonAppendInstructions(t->Program, 1);
+
+               tgt->Opcode = OPCODE_MOV;
+               tgt->DstReg = orig_inst->DstReg;
+               tgt->SrcReg[0].File = PROGRAM_TEMPORARY;
+               tgt->SrcReg[0].Index = inst.DstReg.Index;
+       }
+
+       return GL_TRUE;
+}
+
+
+static void update_params(r300ContextPtr r300, struct r500_fragment_program *fp)
+{
+       struct gl_fragment_program *mp = &fp->mesa_program;
+
+       /* Ask Mesa nicely to fill in ParameterValues for us */
+       if (mp->Base.Parameters)
+               _mesa_load_state_parameters(r300->radeon.glCtx, mp->Base.Parameters);
+}
+
+
+/**
+ * Transform the program to support fragment.position.
+ *
+ * Introduce a small fragment at the start of the program that will be
+ * the only code that directly reads the FRAG_ATTRIB_WPOS input.
+ * All other code pieces that reference that input will be rewritten
+ * to read from a newly allocated temporary.
+ *
+ * \todo if/when r5xx supports the radeon_program architecture, this is a
+ * likely candidate for code sharing.
+ */
+static void insert_WPOS_trailer(struct r500_fragment_program_compiler *compiler)
+{
+       GLuint InputsRead = compiler->fp->mesa_program.Base.InputsRead;
+
+       if (!(InputsRead & FRAG_BIT_WPOS))
+               return;
+
+       static gl_state_index tokens[STATE_LENGTH] = {
+               STATE_INTERNAL, STATE_R300_WINDOW_DIMENSION, 0, 0, 0
+       };
+       struct prog_instruction *fpi;
+       GLuint window_index;
+       int i = 0;
+       GLuint tempregi = _mesa_find_free_register(compiler->program, PROGRAM_TEMPORARY);
+
+       _mesa_insert_instructions(compiler->program, 0, 3);
+       fpi = compiler->program->Instructions;
+
+       /* perspective divide */
+       fpi[i].Opcode = OPCODE_RCP;
+
+       fpi[i].DstReg.File = PROGRAM_TEMPORARY;
+       fpi[i].DstReg.Index = tempregi;
+       fpi[i].DstReg.WriteMask = WRITEMASK_W;
+       fpi[i].DstReg.CondMask = COND_TR;
+
+       fpi[i].SrcReg[0].File = PROGRAM_INPUT;
+       fpi[i].SrcReg[0].Index = FRAG_ATTRIB_WPOS;
+       fpi[i].SrcReg[0].Swizzle = SWIZZLE_WWWW;
+       i++;
+
+       fpi[i].Opcode = OPCODE_MUL;
+
+       fpi[i].DstReg.File = PROGRAM_TEMPORARY;
+       fpi[i].DstReg.Index = tempregi;
+       fpi[i].DstReg.WriteMask = WRITEMASK_XYZ;
+       fpi[i].DstReg.CondMask = COND_TR;
+
+       fpi[i].SrcReg[0].File = PROGRAM_INPUT;
+       fpi[i].SrcReg[0].Index = FRAG_ATTRIB_WPOS;
+       fpi[i].SrcReg[0].Swizzle = SWIZZLE_XYZW;
+
+       fpi[i].SrcReg[1].File = PROGRAM_TEMPORARY;
+       fpi[i].SrcReg[1].Index = tempregi;
+       fpi[i].SrcReg[1].Swizzle = SWIZZLE_WWWW;
+       i++;
+
+       /* viewport transformation */
+       window_index = _mesa_add_state_reference(compiler->program->Parameters, tokens);
+
+       fpi[i].Opcode = OPCODE_MAD;
+
+       fpi[i].DstReg.File = PROGRAM_TEMPORARY;
+       fpi[i].DstReg.Index = tempregi;
+       fpi[i].DstReg.WriteMask = WRITEMASK_XYZ;
+       fpi[i].DstReg.CondMask = COND_TR;
+
+       fpi[i].SrcReg[0].File = PROGRAM_TEMPORARY;
+       fpi[i].SrcReg[0].Index = tempregi;
+       fpi[i].SrcReg[0].Swizzle =
+           MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_ZERO);
+
+       fpi[i].SrcReg[1].File = PROGRAM_STATE_VAR;
+       fpi[i].SrcReg[1].Index = window_index;
+       fpi[i].SrcReg[1].Swizzle =
+           MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_ZERO);
+
+       fpi[i].SrcReg[2].File = PROGRAM_STATE_VAR;
+       fpi[i].SrcReg[2].Index = window_index;
+       fpi[i].SrcReg[2].Swizzle =
+           MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_ZERO);
+       i++;
+
+       for (; i < compiler->program->NumInstructions; ++i) {
+               int reg;
+               for (reg = 0; reg < 3; reg++) {
+                       if (fpi[i].SrcReg[reg].File == PROGRAM_INPUT &&
+                           fpi[i].SrcReg[reg].Index == FRAG_ATTRIB_WPOS) {
+                               fpi[i].SrcReg[reg].File = PROGRAM_TEMPORARY;
+                               fpi[i].SrcReg[reg].Index = tempregi;
+                       }
+               }
+       }
+}
+
+
+static void nqssadce_init(struct nqssadce_state* s)
+{
+       s->Outputs[FRAG_RESULT_COLR].Sourced = WRITEMASK_XYZW;
+       s->Outputs[FRAG_RESULT_DEPR].Sourced = WRITEMASK_W;
+}
+
+static GLboolean is_native_swizzle(GLuint opcode, struct prog_src_register reg)
+{
+       GLuint relevant;
+       int i;
+
+       if (opcode == OPCODE_TEX ||
+           opcode == OPCODE_TXB ||
+           opcode == OPCODE_TXP ||
+           opcode == OPCODE_KIL) {
+               if (reg.Abs)
+                       return GL_FALSE;
+
+               if (reg.NegateAbs)
+                       reg.NegateBase ^= 15;
+
+               if (opcode == OPCODE_KIL) {
+                       if (reg.Swizzle != SWIZZLE_NOOP)
+                               return GL_FALSE;
+               } else {
+                       for(i = 0; i < 4; ++i) {
+                               GLuint swz = GET_SWZ(reg.Swizzle, i);
+                               if (swz == SWIZZLE_NIL) {
+                                       reg.NegateBase &= ~(1 << i);
+                                       continue;
+                               }
+                               if (swz >= 4)
+                                       return GL_FALSE;
+                       }
+               }
+
+               if (reg.NegateBase)
+                       return GL_FALSE;
+
+               return GL_TRUE;
+       } else if (opcode == OPCODE_DDX || opcode == OPCODE_DDY) {
+               /* DDX/MDH and DDY/MDV explicitly ignore incoming swizzles;
+                * if it doesn't fit perfectly into a .xyzw case... */
+               if (reg.Swizzle == SWIZZLE_NOOP && !reg.Abs
+                               && !reg.NegateBase && !reg.NegateAbs)
+                       return GL_TRUE;
+
+               return GL_FALSE;
+       } else {
+               /* ALU instructions support almost everything */
+               if (reg.Abs)
+                       return GL_TRUE;
+
+               relevant = 0;
+               for(i = 0; i < 3; ++i) {
+                       GLuint swz = GET_SWZ(reg.Swizzle, i);
+                       if (swz != SWIZZLE_NIL && swz != SWIZZLE_ZERO)
+                               relevant |= 1 << i;
+               }
+               if ((reg.NegateBase & relevant) && ((reg.NegateBase & relevant) != relevant))
+                       return GL_FALSE;
+
+               return GL_TRUE;
+       }
+}
+
+/**
+ * Implement a MOV with a potentially non-native swizzle.
+ *
+ * The only thing we *cannot* do in an ALU instruction is per-component
+ * negation. Therefore, we split the MOV into two instructions when necessary.
+ */
+static void nqssadce_build_swizzle(struct nqssadce_state *s,
+       struct prog_dst_register dst, struct prog_src_register src)
+{
+       struct prog_instruction *inst;
+       GLuint negatebase[2] = { 0, 0 };
+       int i;
+
+       for(i = 0; i < 4; ++i) {
+               GLuint swz = GET_SWZ(src.Swizzle, i);
+               if (swz == SWIZZLE_NIL)
+                       continue;
+               negatebase[GET_BIT(src.NegateBase, i)] |= 1 << i;
+       }
+
+       _mesa_insert_instructions(s->Program, s->IP, (negatebase[0] ? 1 : 0) + (negatebase[1] ? 1 : 0));
+       inst = s->Program->Instructions + s->IP;
+
+       for(i = 0; i <= 1; ++i) {
+               if (!negatebase[i])
+                       continue;
+
+               inst->Opcode = OPCODE_MOV;
+               inst->DstReg = dst;
+               inst->DstReg.WriteMask = negatebase[i];
+               inst->SrcReg[0] = src;
+               inst++;
+               s->IP++;
+       }
+}
+
+static GLuint build_dtm(GLuint depthmode)
+{
+       switch(depthmode) {
+       default:
+       case GL_LUMINANCE: return 0;
+       case GL_INTENSITY: return 1;
+       case GL_ALPHA: return 2;
+       }
+}
+
+static GLuint build_func(GLuint comparefunc)
+{
+       return comparefunc - GL_NEVER;
+}
+
+
+/**
+ * Collect all external state that is relevant for compiling the given
+ * fragment program.
+ */
+static void build_state(
+       r300ContextPtr r300,
+       struct r500_fragment_program *fp,
+       struct r500_fragment_program_external_state *state)
+{
+       int unit;
+
+       _mesa_bzero(state, sizeof(*state));
+
+       for(unit = 0; unit < 16; ++unit) {
+               if (fp->mesa_program.Base.ShadowSamplers & (1 << unit)) {
+                       struct gl_texture_object* tex = r300->radeon.glCtx->Texture.Unit[unit]._Current;
+
+                       state->unit[unit].depth_texture_mode = build_dtm(tex->DepthMode);
+                       state->unit[unit].texture_compare_func = build_func(tex->CompareFunc);
+               }
+       }
+}
+
+static void dump_program(struct r500_fragment_program_code *code);
+
+void r500TranslateFragmentShader(r300ContextPtr r300,
+                                struct r500_fragment_program *fp)
+{
+       struct r500_fragment_program_external_state state;
+
+       build_state(r300, fp, &state);
+       if (_mesa_memcmp(&fp->state, &state, sizeof(state))) {
+               /* TODO: cache compiled programs */
+               fp->translated = GL_FALSE;
+               _mesa_memcpy(&fp->state, &state, sizeof(state));
+       }
+
+       if (!fp->translated) {
+               struct r500_fragment_program_compiler compiler;
+
+               compiler.r300 = r300;
+               compiler.fp = fp;
+               compiler.code = &fp->code;
+               compiler.program = _mesa_clone_program(r300->radeon.glCtx, &fp->mesa_program.Base);
+
+               if (RADEON_DEBUG & DEBUG_PIXEL) {
+                       _mesa_printf("Compiler: Initial program:\n");
+                       _mesa_print_program(compiler.program);
+               }
+
+               insert_WPOS_trailer(&compiler);
+
+               struct radeon_program_transformation transformations[] = {
+                       { &transform_TEX, &compiler },
+                       { &radeonTransformALU, 0 },
+                       { &radeonTransformDeriv, 0 },
+                       { &radeonTransformTrigScale, 0 }
+               };
+               radeonLocalTransform(r300->radeon.glCtx, compiler.program,
+                       4, transformations);
+
+               if (RADEON_DEBUG & DEBUG_PIXEL) {
+                       _mesa_printf("Compiler: after native rewrite:\n");
+                       _mesa_print_program(compiler.program);
+               }
+
+               struct radeon_nqssadce_descr nqssadce = {
+                       .Init = &nqssadce_init,
+                       .IsNativeSwizzle = &is_native_swizzle,
+                       .BuildSwizzle = &nqssadce_build_swizzle,
+                       .RewriteDepthOut = GL_TRUE
+               };
+               radeonNqssaDce(r300->radeon.glCtx, compiler.program, &nqssadce);
+
+               if (RADEON_DEBUG & DEBUG_PIXEL) {
+                       _mesa_printf("Compiler: after NqSSA-DCE:\n");
+                       _mesa_print_program(compiler.program);
+               }
+
+               fp->translated = r500FragmentProgramEmit(&compiler);
+
+               /* Subtle: Rescue any parameters that have been added during transformations */
+               _mesa_free_parameter_list(fp->mesa_program.Base.Parameters);
+               fp->mesa_program.Base.Parameters = compiler.program->Parameters;
+               compiler.program->Parameters = 0;
+
+               _mesa_reference_program(r300->radeon.glCtx, &compiler.program, 0);
+
+               r300UpdateStateParameters(r300->radeon.glCtx, _NEW_PROGRAM);
+
+               if (RADEON_DEBUG & DEBUG_PIXEL) {
+                       if (fp->translated) {
+                               _mesa_printf("Machine-readable code:\n");
+                               dump_program(&fp->code);
+                       }
+               }
+
+       }
+
+       update_params(r300, fp);
+
+}
+
+static char *toswiz(int swiz_val) {
+  switch(swiz_val) {
+  case 0: return "R";
+  case 1: return "G";
+  case 2: return "B";
+  case 3: return "A";
+  case 4: return "0";
+  case 5: return "1/2";
+  case 6: return "1";
+  case 7: return "U";
+  }
+  return NULL;
+}
+
+static char *toop(int op_val)
+{
+  char *str = NULL;
+  switch (op_val) {
+  case 0: str = "MAD"; break;
+  case 1: str = "DP3"; break;
+  case 2: str = "DP4"; break;
+  case 3: str = "D2A"; break;
+  case 4: str = "MIN"; break;
+  case 5: str = "MAX"; break;
+  case 6: str = "Reserved"; break;
+  case 7: str = "CND"; break;
+  case 8: str = "CMP"; break;
+  case 9: str = "FRC"; break;
+  case 10: str = "SOP"; break;
+  case 11: str = "MDH"; break;
+  case 12: str = "MDV"; break;
+  }
+  return str;
+}
+
+static char *to_alpha_op(int op_val)
+{
+  char *str = NULL;
+  switch (op_val) {
+  case 0: str = "MAD"; break;
+  case 1: str = "DP"; break;
+  case 2: str = "MIN"; break;
+  case 3: str = "MAX"; break;
+  case 4: str = "Reserved"; break;
+  case 5: str = "CND"; break;
+  case 6: str = "CMP"; break;
+  case 7: str = "FRC"; break;
+  case 8: str = "EX2"; break;
+  case 9: str = "LN2"; break;
+  case 10: str = "RCP"; break;
+  case 11: str = "RSQ"; break;
+  case 12: str = "SIN"; break;
+  case 13: str = "COS"; break;
+  case 14: str = "MDH"; break;
+  case 15: str = "MDV"; break;
+  }
+  return str;
+}
+
+static char *to_mask(int val)
+{
+  char *str = NULL;
+  switch(val) {
+  case 0: str = "NONE"; break;
+  case 1: str = "R"; break;
+  case 2: str = "G"; break;
+  case 3: str = "RG"; break;
+  case 4: str = "B"; break;
+  case 5: str = "RB"; break;
+  case 6: str = "GB"; break;
+  case 7: str = "RGB"; break;
+  case 8: str = "A"; break;
+  case 9: str = "AR"; break;
+  case 10: str = "AG"; break;
+  case 11: str = "ARG"; break;
+  case 12: str = "AB"; break;
+  case 13: str = "ARB"; break;
+  case 14: str = "AGB"; break;
+  case 15: str = "ARGB"; break;
+  }
+  return str;
+}
+
+static char *to_texop(int val)
+{
+  switch(val) {
+  case 0: return "NOP";
+  case 1: return "LD";
+  case 2: return "TEXKILL";
+  case 3: return "PROJ";
+  case 4: return "LODBIAS";
+  case 5: return "LOD";
+  case 6: return "DXDY";
+  }
+  return NULL;
+}
+
+static void dump_program(struct r500_fragment_program_code *code)
+{
+
+  fprintf(stderr, "R500 Fragment Program:\n--------\n");
+
+  int n;
+  uint32_t inst;
+  uint32_t inst0;
+  char *str = NULL;
+
+  if (code->const_nr) {
+    fprintf(stderr, "--------\nConstants:\n");
+    for (n = 0; n < code->const_nr; n++) {
+      fprintf(stderr, "Constant %d: %i[%i]\n", n,
+        code->constant[n].File, code->constant[n].Index);
+    }
+    fprintf(stderr, "--------\n");
+  }
+
+  for (n = 0; n < code->inst_end+1; n++) {
+    inst0 = inst = code->inst[n].inst0;
+    fprintf(stderr,"%d\t0:CMN_INST   0x%08x:", n, inst);
+    switch(inst & 0x3) {
+    case R500_INST_TYPE_ALU: str = "ALU"; break;
+    case R500_INST_TYPE_OUT: str = "OUT"; break;
+    case R500_INST_TYPE_FC: str = "FC"; break;
+    case R500_INST_TYPE_TEX: str = "TEX"; break;
+    };
+    fprintf(stderr,"%s %s %s %s %s ", str,
+           inst & R500_INST_TEX_SEM_WAIT ? "TEX_WAIT" : "",
+           inst & R500_INST_LAST ? "LAST" : "",
+           inst & R500_INST_NOP ? "NOP" : "",
+           inst & R500_INST_ALU_WAIT ? "ALU WAIT" : "");
+    fprintf(stderr,"wmask: %s omask: %s\n", to_mask((inst >> 11) & 0xf),
+           to_mask((inst >> 15) & 0xf));
+
+    switch(inst0 & 0x3) {
+    case 0:
+    case 1:
+      fprintf(stderr,"\t1:RGB_ADDR   0x%08x:", code->inst[n].inst1);
+      inst = code->inst[n].inst1;
+
+      fprintf(stderr,"Addr0: %d%c, Addr1: %d%c, Addr2: %d%c, srcp:%d\n",
+             inst & 0xff, (inst & (1<<8)) ? 'c' : 't',
+             (inst >> 10) & 0xff, (inst & (1<<18)) ? 'c' : 't',
+             (inst >> 20) & 0xff, (inst & (1<<28)) ? 'c' : 't',
+             (inst >> 30));
+
+      fprintf(stderr,"\t2:ALPHA_ADDR 0x%08x:", code->inst[n].inst2);
+      inst = code->inst[n].inst2;
+      fprintf(stderr,"Addr0: %d%c, Addr1: %d%c, Addr2: %d%c, srcp:%d\n",
+             inst & 0xff, (inst & (1<<8)) ? 'c' : 't',
+             (inst >> 10) & 0xff, (inst & (1<<18)) ? 'c' : 't',
+             (inst >> 20) & 0xff, (inst & (1<<28)) ? 'c' : 't',
+             (inst >> 30));
+      fprintf(stderr,"\t3 RGB_INST:  0x%08x:", code->inst[n].inst3);
+      inst = code->inst[n].inst3;
+      fprintf(stderr,"rgb_A_src:%d %s/%s/%s %d rgb_B_src:%d %s/%s/%s %d\n",
+             (inst) & 0x3, toswiz((inst >> 2) & 0x7), toswiz((inst >> 5) & 0x7), toswiz((inst >> 8) & 0x7),
+             (inst >> 11) & 0x3,
+             (inst >> 13) & 0x3, toswiz((inst >> 15) & 0x7), toswiz((inst >> 18) & 0x7), toswiz((inst >> 21) & 0x7),
+             (inst >> 24) & 0x3);
+
+
+      fprintf(stderr,"\t4 ALPHA_INST:0x%08x:", code->inst[n].inst4);
+      inst = code->inst[n].inst4;
+      fprintf(stderr,"%s dest:%d%s alp_A_src:%d %s %d alp_B_src:%d %s %d w:%d\n", to_alpha_op(inst & 0xf),
+             (inst >> 4) & 0x7f, inst & (1<<11) ? "(rel)":"",
+             (inst >> 12) & 0x3, toswiz((inst >> 14) & 0x7), (inst >> 17) & 0x3,
+             (inst >> 19) & 0x3, toswiz((inst >> 21) & 0x7), (inst >> 24) & 0x3,
+             (inst >> 31) & 0x1);
+
+      fprintf(stderr,"\t5 RGBA_INST: 0x%08x:", code->inst[n].inst5);
+      inst = code->inst[n].inst5;
+      fprintf(stderr,"%s dest:%d%s rgb_C_src:%d %s/%s/%s %d alp_C_src:%d %s %d\n", toop(inst & 0xf),
+             (inst >> 4) & 0x7f, inst & (1<<11) ? "(rel)":"",
+             (inst >> 12) & 0x3, toswiz((inst >> 14) & 0x7), toswiz((inst >> 17) & 0x7), toswiz((inst >> 20) & 0x7),
+             (inst >> 23) & 0x3,
+             (inst >> 25) & 0x3, toswiz((inst >> 27) & 0x7), (inst >> 30) & 0x3);
+      break;
+    case 2:
+      break;
+    case 3:
+      inst = code->inst[n].inst1;
+      fprintf(stderr,"\t1:TEX_INST:  0x%08x: id: %d op:%s, %s, %s %s\n", inst, (inst >> 16) & 0xf,
+             to_texop((inst >> 22) & 0x7), (inst & (1<<25)) ? "ACQ" : "",
+             (inst & (1<<26)) ? "IGNUNC" : "", (inst & (1<<27)) ? "UNSCALED" : "SCALED");
+      inst = code->inst[n].inst2;
+      fprintf(stderr,"\t2:TEX_ADDR:  0x%08x: src: %d%s %s/%s/%s/%s dst: %d%s %s/%s/%s/%s\n", inst,
+             inst & 127, inst & (1<<7) ? "(rel)" : "",
+             toswiz((inst >> 8) & 0x3), toswiz((inst >> 10) & 0x3),
+             toswiz((inst >> 12) & 0x3), toswiz((inst >> 14) & 0x3),
+             (inst >> 16) & 127, inst & (1<<23) ? "(rel)" : "",
+             toswiz((inst >> 24) & 0x3), toswiz((inst >> 26) & 0x3),
+             toswiz((inst >> 28) & 0x3), toswiz((inst >> 30) & 0x3));
+
+      fprintf(stderr,"\t3:TEX_DXDY:  0x%08x\n", code->inst[n].inst3);
+      break;
+    }
+    fprintf(stderr,"\n");
+  }
+
+}
diff --git a/src/mesa/drivers/dri/r300/r500_fragprog.h b/src/mesa/drivers/dri/r300/r500_fragprog.h
new file mode 100644 (file)
index 0000000..8641cee
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * 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>
+ *   Jerome Glisse <j.glisse@gmail.com>
+ */
+#ifndef __R500_FRAGPROG_H_
+#define __R500_FRAGPROG_H_
+
+#include "glheader.h"
+#include "macros.h"
+#include "enums.h"
+#include "shader/prog_parameter.h"
+#include "shader/prog_print.h"
+#include "shader/program.h"
+#include "shader/prog_instruction.h"
+
+#include "r300_context.h"
+#include "r300_state.h"
+#include "radeon_program.h"
+
+struct r500_fragment_program;
+
+extern void r500TranslateFragmentShader(r300ContextPtr r300,
+                                       struct r500_fragment_program *fp);
+
+struct r500_fragment_program_compiler {
+       r300ContextPtr r300;
+       struct r500_fragment_program *fp;
+       struct r500_fragment_program_code *code;
+       struct gl_program *program;
+};
+
+extern GLboolean r500FragmentProgramEmit(struct r500_fragment_program_compiler *compiler);
+
+#endif
diff --git a/src/mesa/drivers/dri/r300/r500_fragprog_emit.c b/src/mesa/drivers/dri/r300/r500_fragprog_emit.c
new file mode 100644 (file)
index 0000000..4631235
--- /dev/null
@@ -0,0 +1,327 @@
+/*
+ * Copyright (C) 2005 Ben Skeggs.
+ *
+ * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
+ * Adaptation and modification for ATI/AMD Radeon R500 GPU chipsets.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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
+ *
+ * \author Ben Skeggs <darktama@iinet.net.au>
+ *
+ * \author Jerome Glisse <j.glisse@gmail.com>
+ *
+ * \author Corbin Simpson <MostAwesomeDude@gmail.com>
+ *
+ * \todo Depth write, WPOS/FOGC inputs
+ *
+ * \todo FogOption
+ *
+ */
+
+#include "r500_fragprog.h"
+
+#include "radeon_program_pair.h"
+
+
+#define PROG_CODE \
+       struct r500_fragment_program_compiler *c = (struct r500_fragment_program_compiler*)data; \
+       struct r500_fragment_program_code *code = c->code
+
+#define error(fmt, args...) do {                       \
+               fprintf(stderr, "%s::%s(): " fmt "\n",  \
+                       __FILE__, __FUNCTION__, ##args);        \
+       } while(0)
+
+
+/**
+ * Callback to register hardware constants.
+ */
+static GLboolean emit_const(void *data, GLuint file, GLuint idx, GLuint *hwindex)
+{
+       PROG_CODE;
+
+       for (*hwindex = 0; *hwindex < code->const_nr; ++*hwindex) {
+               if (code->constant[*hwindex].File == file &&
+                   code->constant[*hwindex].Index == idx)
+                       break;
+       }
+
+       if (*hwindex >= code->const_nr) {
+               if (*hwindex >= PFS_NUM_CONST_REGS) {
+                       error("Out of hw constants!\n");
+                       return GL_FALSE;
+               }
+
+               code->const_nr++;
+               code->constant[*hwindex].File = file;
+               code->constant[*hwindex].Index = idx;
+       }
+
+       return GL_TRUE;
+}
+
+static GLuint translate_rgb_op(GLuint opcode)
+{
+       switch(opcode) {
+       case OPCODE_CMP: return R500_ALU_RGBA_OP_CMP;
+       case OPCODE_DDX: return R500_ALU_RGBA_OP_MDH;
+       case OPCODE_DDY: return R500_ALU_RGBA_OP_MDV;
+       case OPCODE_DP3: return R500_ALU_RGBA_OP_DP3;
+       case OPCODE_DP4: return R500_ALU_RGBA_OP_DP4;
+       case OPCODE_FRC: return R500_ALU_RGBA_OP_FRC;
+       default:
+               error("translate_rgb_op(%d): unknown opcode\n", opcode);
+               /* fall through */
+       case OPCODE_NOP:
+               /* fall through */
+       case OPCODE_MAD: return R500_ALU_RGBA_OP_MAD;
+       case OPCODE_MAX: return R500_ALU_RGBA_OP_MAX;
+       case OPCODE_MIN: return R500_ALU_RGBA_OP_MIN;
+       case OPCODE_REPL_ALPHA: return R500_ALU_RGBA_OP_SOP;
+       }
+}
+
+static GLuint translate_alpha_op(GLuint opcode)
+{
+       switch(opcode) {
+       case OPCODE_CMP: return R500_ALPHA_OP_CMP;
+       case OPCODE_COS: return R500_ALPHA_OP_COS;
+       case OPCODE_DDX: return R500_ALPHA_OP_MDH;
+       case OPCODE_DDY: return R500_ALPHA_OP_MDV;
+       case OPCODE_DP3: return R500_ALPHA_OP_DP;
+       case OPCODE_DP4: return R500_ALPHA_OP_DP;
+       case OPCODE_EX2: return R500_ALPHA_OP_EX2;
+       case OPCODE_FRC: return R500_ALPHA_OP_FRC;
+       case OPCODE_LG2: return R500_ALPHA_OP_LN2;
+       default:
+               error("translate_alpha_op(%d): unknown opcode\n", opcode);
+               /* fall through */
+       case OPCODE_NOP:
+               /* fall through */
+       case OPCODE_MAD: return R500_ALPHA_OP_MAD;
+       case OPCODE_MAX: return R500_ALPHA_OP_MAX;
+       case OPCODE_MIN: return R500_ALPHA_OP_MIN;
+       case OPCODE_RCP: return R500_ALPHA_OP_RCP;
+       case OPCODE_RSQ: return R500_ALPHA_OP_RSQ;
+       case OPCODE_SIN: return R500_ALPHA_OP_SIN;
+       }
+}
+
+static GLuint fix_hw_swizzle(GLuint swz)
+{
+       if (swz == 5) swz = 6;
+       if (swz == SWIZZLE_NIL) swz = 4;
+       return swz;
+}
+
+static GLuint translate_arg_rgb(struct radeon_pair_instruction *inst, int arg)
+{
+       GLuint t = inst->RGB.Arg[arg].Source;
+       int comp;
+       t |= inst->RGB.Arg[arg].Negate << 11;
+       t |= inst->RGB.Arg[arg].Abs << 12;
+
+       for(comp = 0; comp < 3; ++comp)
+               t |= fix_hw_swizzle(GET_SWZ(inst->RGB.Arg[arg].Swizzle, comp)) << (3*comp + 2);
+
+       return t;
+}
+
+static GLuint translate_arg_alpha(struct radeon_pair_instruction *inst, int i)
+{
+       GLuint t = inst->Alpha.Arg[i].Source;
+       t |= fix_hw_swizzle(inst->Alpha.Arg[i].Swizzle) << 2;
+       t |= inst->Alpha.Arg[i].Negate << 5;
+       t |= inst->Alpha.Arg[i].Abs << 6;
+       return t;
+}
+
+static void use_temporary(struct r500_fragment_program_code* code, GLuint index)
+{
+       if (index > code->max_temp_idx)
+               code->max_temp_idx = index;
+}
+
+static GLuint use_source(struct r500_fragment_program_code* code, struct radeon_pair_instruction_source src)
+{
+       if (!src.Constant)
+               use_temporary(code, src.Index);
+       return src.Index | src.Constant << 8;
+}
+
+
+/**
+ * Emit a paired ALU instruction.
+ */
+static GLboolean emit_paired(void *data, struct radeon_pair_instruction *inst)
+{
+       PROG_CODE;
+
+       if (code->inst_end >= 511) {
+               error("emit_alu: Too many instructions");
+               return GL_FALSE;
+       }
+
+       int ip = ++code->inst_end;
+
+       code->inst[ip].inst5 = translate_rgb_op(inst->RGB.Opcode);
+       code->inst[ip].inst4 = translate_alpha_op(inst->Alpha.Opcode);
+
+       if (inst->RGB.OutputWriteMask || inst->Alpha.OutputWriteMask || inst->Alpha.DepthWriteMask)
+               code->inst[ip].inst0 = R500_INST_TYPE_OUT;
+       else
+               code->inst[ip].inst0 = R500_INST_TYPE_ALU;
+       code->inst[ip].inst0 |= R500_INST_TEX_SEM_WAIT;
+
+       code->inst[ip].inst0 |= (inst->RGB.WriteMask << 11) | (inst->Alpha.WriteMask << 14);
+       code->inst[ip].inst0 |= (inst->RGB.OutputWriteMask << 15) | (inst->Alpha.OutputWriteMask << 18);
+       if (inst->Alpha.DepthWriteMask) {
+               code->inst[ip].inst4 |= R500_ALPHA_W_OMASK;
+               c->fp->writes_depth = GL_TRUE;
+       }
+
+       code->inst[ip].inst4 |= R500_ALPHA_ADDRD(inst->Alpha.DestIndex);
+       code->inst[ip].inst5 |= R500_ALU_RGBA_ADDRD(inst->RGB.DestIndex);
+       use_temporary(code, inst->Alpha.DestIndex);
+       use_temporary(code, inst->RGB.DestIndex);
+
+       if (inst->RGB.Saturate)
+               code->inst[ip].inst0 |= R500_INST_RGB_CLAMP;
+       if (inst->Alpha.Saturate)
+               code->inst[ip].inst0 |= R500_INST_ALPHA_CLAMP;
+
+       code->inst[ip].inst1 |= R500_RGB_ADDR0(use_source(code, inst->RGB.Src[0]));
+       code->inst[ip].inst1 |= R500_RGB_ADDR1(use_source(code, inst->RGB.Src[1]));
+       code->inst[ip].inst1 |= R500_RGB_ADDR2(use_source(code, inst->RGB.Src[2]));
+
+       code->inst[ip].inst2 |= R500_ALPHA_ADDR0(use_source(code, inst->Alpha.Src[0]));
+       code->inst[ip].inst2 |= R500_ALPHA_ADDR1(use_source(code, inst->Alpha.Src[1]));
+       code->inst[ip].inst2 |= R500_ALPHA_ADDR2(use_source(code, inst->Alpha.Src[2]));
+
+       code->inst[ip].inst3 |= translate_arg_rgb(inst, 0) << R500_ALU_RGB_SEL_A_SHIFT;
+       code->inst[ip].inst3 |= translate_arg_rgb(inst, 1) << R500_ALU_RGB_SEL_B_SHIFT;
+       code->inst[ip].inst5 |= translate_arg_rgb(inst, 2) << R500_ALU_RGBA_SEL_C_SHIFT;
+
+       code->inst[ip].inst4 |= translate_arg_alpha(inst, 0) << R500_ALPHA_SEL_A_SHIFT;
+       code->inst[ip].inst4 |= translate_arg_alpha(inst, 1) << R500_ALPHA_SEL_B_SHIFT;
+       code->inst[ip].inst5 |= translate_arg_alpha(inst, 2) << R500_ALU_RGBA_ALPHA_SEL_C_SHIFT;
+
+       return GL_TRUE;
+}
+
+static GLuint translate_strq_swizzle(struct prog_src_register src)
+{
+       GLuint swiz = 0;
+       int i;
+       for (i = 0; i < 4; i++)
+               swiz |= (GET_SWZ(src.Swizzle, i) & 0x3) << i*2;
+       return swiz;
+}
+
+/**
+ * Emit a single TEX instruction
+ */
+static GLboolean emit_tex(void *data, struct prog_instruction *inst)
+{
+       PROG_CODE;
+
+       if (code->inst_end >= 511) {
+               error("emit_tex: Too many instructions");
+               return GL_FALSE;
+       }
+
+       int ip = ++code->inst_end;
+
+       code->inst[ip].inst0 = R500_INST_TYPE_TEX
+               | (inst->DstReg.WriteMask << 11)
+               | R500_INST_TEX_SEM_WAIT;
+       code->inst[ip].inst1 = R500_TEX_ID(inst->TexSrcUnit)
+               | R500_TEX_SEM_ACQUIRE | R500_TEX_IGNORE_UNCOVERED;
+
+       if (inst->TexSrcTarget == TEXTURE_RECT_INDEX)
+               code->inst[ip].inst1 |= R500_TEX_UNSCALED;
+
+       switch (inst->Opcode) {
+       case OPCODE_KIL:
+               code->inst[ip].inst1 |= R500_TEX_INST_TEXKILL;
+               break;
+       case OPCODE_TEX:
+               code->inst[ip].inst1 |= R500_TEX_INST_LD;
+               break;
+       case OPCODE_TXB:
+               code->inst[ip].inst1 |= R500_TEX_INST_LODBIAS;
+               break;
+       case OPCODE_TXP:
+               code->inst[ip].inst1 |= R500_TEX_INST_PROJ;
+               break;
+       default:
+               error("emit_tex can't handle opcode %x\n", inst->Opcode);
+       }
+
+       code->inst[ip].inst2 = R500_TEX_SRC_ADDR(inst->SrcReg[0].Index)
+               | (translate_strq_swizzle(inst->SrcReg[0]) << 8)
+               | R500_TEX_DST_ADDR(inst->DstReg.Index)
+               | R500_TEX_DST_R_SWIZ_R | R500_TEX_DST_G_SWIZ_G
+               | R500_TEX_DST_B_SWIZ_B | R500_TEX_DST_A_SWIZ_A;
+
+       return GL_TRUE;
+}
+
+static const struct radeon_pair_handler pair_handler = {
+       .EmitConst = emit_const,
+       .EmitPaired = emit_paired,
+       .EmitTex = emit_tex,
+       .MaxHwTemps = 128
+};
+
+GLboolean r500FragmentProgramEmit(struct r500_fragment_program_compiler *compiler)
+{
+       struct r500_fragment_program_code *code = compiler->code;
+
+       _mesa_bzero(code, sizeof(*code));
+       code->max_temp_idx = 1;
+       code->inst_offset = 0;
+       code->inst_end = -1;
+
+       if (!radeonPairProgram(compiler->r300->radeon.glCtx, compiler->program, &pair_handler, compiler))
+               return GL_FALSE;
+
+       if ((code->inst[code->inst_end].inst0 & R500_INST_TYPE_MASK) != R500_INST_TYPE_OUT) {
+               /* This may happen when dead-code elimination is disabled or
+                * when most of the fragment program logic is leading to a KIL */
+               if (code->inst_end >= 511) {
+                       error("Introducing fake OUT: Too many instructions");
+                       return GL_FALSE;
+               }
+
+               int ip = ++code->inst_end;
+               code->inst[ip].inst0 = R500_INST_TYPE_OUT | R500_INST_TEX_SEM_WAIT;
+       }
+
+       return GL_TRUE;
+}
index e9634b427a66970695817f7d1c48bf1882ab2413..3fc724a5531b8496344069e8207c2ece7a2d7344 100644 (file)
@@ -135,6 +135,7 @@ GLboolean radeonInitContext(radeonContextPtr radeon,
        /* Fill in additional standard functions. */
        radeonInitDriverFuncs(functions);
 
+       radeon->radeonScreen = screen;
        /* Allocate and initialize the Mesa context */
        if (sharedContextPrivate)
                shareCtx = ((radeonContextPtr)sharedContextPrivate)->glCtx;
@@ -156,9 +157,8 @@ GLboolean radeonInitContext(radeonContextPtr radeon,
        radeon->dri.hwContext = driContextPriv->hHWContext;
        radeon->dri.hwLock = &sPriv->pSAREA->lock;
        radeon->dri.fd = sPriv->fd;
-       radeon->dri.drmMinor = sPriv->drmMinor;
+       radeon->dri.drmMinor = sPriv->drm_version.minor;
 
-       radeon->radeonScreen = screen;
        radeon->sarea = (drm_radeon_sarea_t *) ((GLubyte *) sPriv->pSAREA +
                                               screen->sarea_priv_offset);
 
@@ -177,10 +177,7 @@ GLboolean radeonInitContext(radeonContextPtr radeon,
                        radeon->do_usleeps ? "usleeps" : "busy waits",
                        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);
+       (*sPriv->systemTime->getUST) (&radeon->swap_ust);
 
        return GL_TRUE;
 }
@@ -277,9 +274,15 @@ GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv,
                                radeon->glCtx);
 
                if (radeon->dri.drawable != driDrawPriv) {
-                       driDrawableInitVBlank(driDrawPriv,
-                                             radeon->vblank_flags,
-                                             &radeon->vbl_seq);
+                       if (driDrawPriv->swap_interval == (unsigned)-1) {
+                               driDrawPriv->vblFlags =
+                                       (radeon->radeonScreen->irq != 0)
+                                       ? driGetDefaultVBlankFlags(&radeon->
+                                                                  optionCache)
+                                       : VBLANK_FLAG_NO_IRQ;
+
+                               driDrawableInitVBlank(driDrawPriv);
+                       }
                }
 
                radeon->dri.readable = driReadPriv;
index 2f239417a973a625fccc7529e6334872a13f8d88..7458d63723f706b20ec206e95e5938e575eb5ce9 100644 (file)
@@ -53,16 +53,6 @@ struct radeon_context;
 typedef struct radeon_context radeonContextRec;
 typedef struct radeon_context *radeonContextPtr;
 
-#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                0x0001
@@ -182,10 +172,7 @@ struct radeon_context {
        GLuint irqsEmitted;
        drm_radeon_irq_wait_t iw;
 
-       /* VBI / buffer swap */
-       GLuint vbl_seq;
-       GLuint vblank_flags;
-
+       /* buffer swap */
        int64_t swap_ust;
        int64_t swap_missed_ust;
 
index 0b8656b9c1d7e1001a49a574d7ab123b9e31e047..0c1a19507b230b18965e557385c2de1912bad3de 100644 (file)
@@ -157,13 +157,14 @@ static void radeonWaitForFrameCompletion(radeonContextPtr radeon)
 
 /* Copy the back color buffer to the front color buffer.
  */
-void radeonCopyBuffer(const __DRIdrawablePrivate * dPriv,
+void radeonCopyBuffer(__DRIdrawablePrivate * dPriv,
                      const drm_clip_rect_t      * rect)
 {
        radeonContextPtr radeon;
        GLint nbox, i, ret;
        GLboolean missed_target;
        int64_t ust;
+       __DRIscreenPrivate *psp = dPriv->driScreenPriv;
 
        assert(dPriv);
        assert(dPriv->driContextPriv);
@@ -187,8 +188,7 @@ void radeonCopyBuffer(const __DRIdrawablePrivate * dPriv,
        if (!rect)
        {
            UNLOCK_HARDWARE(radeon);
-           driWaitForVBlank(dPriv, &radeon->vbl_seq, radeon->vblank_flags,
-                            &missed_target);
+           driWaitForVBlank(dPriv, &missed_target);
            LOCK_HARDWARE(radeon);
        }
 
@@ -215,16 +215,18 @@ void radeonCopyBuffer(const __DRIdrawablePrivate * dPriv,
                        if (rect->y2 < b->y2)
                            b->y2 = rect->y2;
 
-                       if (b->x1 < b->x2 && b->y1 < b->y2)
-                           b++;
+                       if (b->x1 >= b->x2 || b->y1 >= b->y2)
+                           continue;
                    }
-                   else
-                       b++;
 
+                   b++;
                    n++;
                }
                radeon->sarea->nbox = n;
 
+               if (!n)
+                  continue;
+
                ret = drmCommandNone(radeon->dri.fd, DRM_RADEON_SWAP);
 
                if (ret) {
@@ -241,7 +243,7 @@ void radeonCopyBuffer(const __DRIdrawablePrivate * dPriv,
            ((r300ContextPtr)radeon)->hw.all_dirty = GL_TRUE;
 
            radeon->swap_count++;
-           (*dri_interface->getUST) (&ust);
+           (*psp->systemTime->getUST) (&ust);
            if (missed_target) {
                radeon->swap_missed_count++;
                radeon->swap_missed_ust = ust - radeon->swap_ust;
@@ -253,11 +255,12 @@ void radeonCopyBuffer(const __DRIdrawablePrivate * dPriv,
        }
 }
 
-void radeonPageFlip(const __DRIdrawablePrivate * dPriv)
+void radeonPageFlip(__DRIdrawablePrivate * dPriv)
 {
        radeonContextPtr radeon;
        GLint ret;
        GLboolean missed_target;
+       __DRIscreenPrivate *psp = dPriv->driScreenPriv;
 
        assert(dPriv);
        assert(dPriv->driContextPriv);
@@ -293,11 +296,10 @@ void radeonPageFlip(const __DRIdrawablePrivate * dPriv)
         */
        radeonWaitForFrameCompletion(radeon);
        UNLOCK_HARDWARE(radeon);
-       driWaitForVBlank(dPriv, &radeon->vbl_seq, radeon->vblank_flags,
-                        &missed_target);
+       driWaitForVBlank(dPriv, &missed_target);
        if (missed_target) {
                radeon->swap_missed_count++;
-               (void)(*dri_interface->getUST) (&radeon->swap_missed_ust);
+               (void)(*psp->systemTime->getUST) (&radeon->swap_missed_ust);
        }
        LOCK_HARDWARE(radeon);
 
@@ -311,7 +313,7 @@ void radeonPageFlip(const __DRIdrawablePrivate * dPriv)
        }
 
        radeon->swap_count++;
-       (void)(*dri_interface->getUST) (&radeon->swap_ust);
+       (void)(*psp->systemTime->getUST) (&radeon->swap_ust);
 
         driFlipRenderbuffers(radeon->glCtx->WinSysDrawBuffer, 
                              radeon->sarea->pfCurrentPage);
index 3a80d36c6223e87033faed58c94fd7640bd21b36..210001e8e07271f79d90e3994ca529dda62c7224 100644 (file)
@@ -46,9 +46,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #endif
 #include "radeon_drm.h"
 
-extern void radeonCopyBuffer(const __DRIdrawablePrivate * drawable,
+extern void radeonCopyBuffer(__DRIdrawablePrivate * drawable,
                             const drm_clip_rect_t      * rect);
-extern void radeonPageFlip(const __DRIdrawablePrivate * drawable);
+extern void radeonPageFlip(__DRIdrawablePrivate * drawable);
 extern void radeonFlush(GLcontext * ctx);
 extern void radeonFinish(GLcontext * ctx);
 extern void radeonWaitForIdleLocked(radeonContextPtr radeon);
index bc3c2d6c6b36e5996578ca4f87a1df448a5ebcd4..d54a821c635d49ac2e36e277563ea4c00bc79ad0 100644 (file)
@@ -68,8 +68,8 @@ void radeonUpdatePageFlipping(radeonContextPtr rmesa)
        }
 
        use_back = rmesa->glCtx->DrawBuffer ?
-           (rmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] ==
-            BUFFER_BIT_BACK_LEFT) : 1;
+           (rmesa->glCtx->DrawBuffer->_ColorDrawBufferIndexes[0] ==
+            BUFFER_BACK_LEFT) : 1;
        use_back ^= (rmesa->sarea->pfCurrentPage == 1);
 
        if (use_back) {
diff --git a/src/mesa/drivers/dri/r300/radeon_nqssadce.c b/src/mesa/drivers/dri/r300/radeon_nqssadce.c
new file mode 100644 (file)
index 0000000..97ce016
--- /dev/null
@@ -0,0 +1,284 @@
+/*
+ * Copyright (C) 2008 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.
+ *
+ */
+
+/**
+ * @file
+ *
+ * "Not-quite SSA" and Dead-Code Elimination.
+ *
+ * @note This code uses SWIZZLE_NIL in a source register to indicate that
+ * the corresponding component is ignored by the corresponding instruction.
+ */
+
+#include "radeon_nqssadce.h"
+
+
+/**
+ * Return the @ref register_state for the given register (or 0 for untracked
+ * registers, i.e. constants).
+ */
+static struct register_state *get_reg_state(struct nqssadce_state* s, GLuint file, GLuint index)
+{
+       switch(file) {
+       case PROGRAM_TEMPORARY: return &s->Temps[index];
+       case PROGRAM_OUTPUT: return &s->Outputs[index];
+       default: return 0;
+       }
+}
+
+
+/**
+ * Left multiplication of a register with a swizzle
+ *
+ * @note Works correctly only for X, Y, Z, W swizzles, not for constant swizzles.
+ */
+static struct prog_src_register lmul_swizzle(GLuint swizzle, struct prog_src_register srcreg)
+{
+       struct prog_src_register tmp = srcreg;
+       int i;
+       tmp.Swizzle = 0;
+       tmp.NegateBase = 0;
+       for(i = 0; i < 4; ++i) {
+               GLuint swz = GET_SWZ(swizzle, i);
+               if (swz < 4) {
+                       tmp.Swizzle |= GET_SWZ(srcreg.Swizzle, swz) << (i*3);
+                       tmp.NegateBase |= GET_BIT(srcreg.NegateBase, swz) << i;
+               } else {
+                       tmp.Swizzle |= swz << (i*3);
+               }
+       }
+       return tmp;
+}
+
+
+static struct prog_instruction* track_used_srcreg(struct nqssadce_state* s,
+       struct prog_instruction *inst, GLint src, GLuint sourced)
+{
+       int i;
+       GLuint deswz_source = 0;
+
+       for(i = 0; i < 4; ++i) {
+               if (GET_BIT(sourced, i)) {
+                       GLuint swz = GET_SWZ(inst->SrcReg[src].Swizzle, i);
+                       deswz_source |= 1 << swz;
+               } else {
+                       inst->SrcReg[src].Swizzle &= ~(7 << (3*i));
+                       inst->SrcReg[src].Swizzle |= SWIZZLE_NIL << (3*i);
+               }
+       }
+
+       if (!s->Descr->IsNativeSwizzle(inst->Opcode, inst->SrcReg[src])) {
+               struct prog_dst_register dstreg = inst->DstReg;
+               dstreg.File = PROGRAM_TEMPORARY;
+               dstreg.Index = _mesa_find_free_register(s->Program, PROGRAM_TEMPORARY);
+               dstreg.WriteMask = sourced;
+
+               s->Descr->BuildSwizzle(s, dstreg, inst->SrcReg[src]);
+
+               inst = s->Program->Instructions + s->IP;
+               inst->SrcReg[src].File = PROGRAM_TEMPORARY;
+               inst->SrcReg[src].Index = dstreg.Index;
+               inst->SrcReg[src].Swizzle = 0;
+               inst->SrcReg[src].NegateBase = 0;
+               inst->SrcReg[src].Abs = 0;
+               inst->SrcReg[src].NegateAbs = 0;
+               for(i = 0; i < 4; ++i) {
+                       if (GET_BIT(sourced, i))
+                               inst->SrcReg[src].Swizzle |= i << (3*i);
+                       else
+                               inst->SrcReg[src].Swizzle |= SWIZZLE_NIL << (3*i);
+               }
+               deswz_source = sourced;
+       }
+
+       struct register_state *regstate = get_reg_state(s, inst->SrcReg[src].File, inst->SrcReg[src].Index);
+       if (regstate)
+               regstate->Sourced |= deswz_source & 0xf;
+
+       return inst;
+}
+
+
+static void rewrite_depth_out(struct prog_instruction *inst)
+{
+       if (inst->DstReg.WriteMask & WRITEMASK_Z) {
+               inst->DstReg.WriteMask = WRITEMASK_W;
+       } else {
+               inst->DstReg.WriteMask = 0;
+               return;
+       }
+
+       switch (inst->Opcode) {
+       case OPCODE_FRC:
+       case OPCODE_MOV:
+               inst->SrcReg[0] = lmul_swizzle(SWIZZLE_ZZZZ, inst->SrcReg[0]);
+               break;
+       case OPCODE_ADD:
+       case OPCODE_MAX:
+       case OPCODE_MIN:
+       case OPCODE_MUL:
+               inst->SrcReg[0] = lmul_swizzle(SWIZZLE_ZZZZ, inst->SrcReg[0]);
+               inst->SrcReg[1] = lmul_swizzle(SWIZZLE_ZZZZ, inst->SrcReg[1]);
+               break;
+       case OPCODE_CMP:
+       case OPCODE_MAD:
+               inst->SrcReg[0] = lmul_swizzle(SWIZZLE_ZZZZ, inst->SrcReg[0]);
+               inst->SrcReg[1] = lmul_swizzle(SWIZZLE_ZZZZ, inst->SrcReg[1]);
+               inst->SrcReg[2] = lmul_swizzle(SWIZZLE_ZZZZ, inst->SrcReg[2]);
+               break;
+       default:
+               // Scalar instructions needn't be reswizzled
+               break;
+       }
+}
+
+static void unalias_srcregs(struct prog_instruction *inst, GLuint oldindex, GLuint newindex)
+{
+       int nsrc = _mesa_num_inst_src_regs(inst->Opcode);
+       int i;
+       for(i = 0; i < nsrc; ++i)
+               if (inst->SrcReg[i].File == PROGRAM_TEMPORARY && inst->SrcReg[i].Index == oldindex)
+                       inst->SrcReg[i].Index = newindex;
+}
+
+static void unalias_temporary(struct nqssadce_state* s, GLuint oldindex)
+{
+       GLuint newindex = _mesa_find_free_register(s->Program, PROGRAM_TEMPORARY);
+       int ip;
+       for(ip = 0; ip < s->IP; ++ip) {
+               struct prog_instruction* inst = s->Program->Instructions + ip;
+               if (inst->DstReg.File == PROGRAM_TEMPORARY && inst->DstReg.Index == oldindex)
+                       inst->DstReg.Index = newindex;
+               unalias_srcregs(inst, oldindex, newindex);
+       }
+       unalias_srcregs(s->Program->Instructions + s->IP, oldindex, newindex);
+}
+
+
+/**
+ * Handle one instruction.
+ */
+static void process_instruction(struct nqssadce_state* s)
+{
+       struct prog_instruction *inst = s->Program->Instructions + s->IP;
+
+       if (inst->Opcode == OPCODE_END)
+               return;
+
+       if (inst->Opcode != OPCODE_KIL) {
+               if (s->Descr->RewriteDepthOut) {
+                       if (inst->DstReg.File == PROGRAM_OUTPUT && inst->DstReg.Index == FRAG_RESULT_DEPR)
+                               rewrite_depth_out(inst);
+               }
+
+               struct register_state *regstate = get_reg_state(s, inst->DstReg.File, inst->DstReg.Index);
+               if (!regstate) {
+                       _mesa_problem(s->Ctx, "NqssaDce: bad destination register (%i[%i])\n",
+                               inst->DstReg.File, inst->DstReg.Index);
+                       return;
+               }
+
+               inst->DstReg.WriteMask &= regstate->Sourced;
+               regstate->Sourced &= ~inst->DstReg.WriteMask;
+
+               if (inst->DstReg.WriteMask == 0) {
+                       _mesa_delete_instructions(s->Program, s->IP, 1);
+                       return;
+               }
+
+               if (inst->DstReg.File == PROGRAM_TEMPORARY && !regstate->Sourced)
+                       unalias_temporary(s, inst->DstReg.Index);
+       }
+
+       /* Attention: Due to swizzle emulation code, the following
+        * might change the instruction stream under us, so we have
+        * to be careful with the inst pointer. */
+       switch (inst->Opcode) {
+       case OPCODE_DDX:
+       case OPCODE_DDY:
+       case OPCODE_FRC:
+       case OPCODE_MOV:
+               inst = track_used_srcreg(s, inst, 0, inst->DstReg.WriteMask);
+               break;
+       case OPCODE_ADD:
+       case OPCODE_MAX:
+       case OPCODE_MIN:
+       case OPCODE_MUL:
+               inst = track_used_srcreg(s, inst, 0, inst->DstReg.WriteMask);
+               inst = track_used_srcreg(s, inst, 1, inst->DstReg.WriteMask);
+               break;
+       case OPCODE_CMP:
+       case OPCODE_MAD:
+               inst = track_used_srcreg(s, inst, 0, inst->DstReg.WriteMask);
+               inst = track_used_srcreg(s, inst, 1, inst->DstReg.WriteMask);
+               inst = track_used_srcreg(s, inst, 2, inst->DstReg.WriteMask);
+               break;
+       case OPCODE_COS:
+       case OPCODE_EX2:
+       case OPCODE_LG2:
+       case OPCODE_RCP:
+       case OPCODE_RSQ:
+       case OPCODE_SIN:
+               inst = track_used_srcreg(s, inst, 0, 0x1);
+               break;
+       case OPCODE_DP3:
+               inst = track_used_srcreg(s, inst, 0, 0x7);
+               inst = track_used_srcreg(s, inst, 1, 0x7);
+               break;
+       case OPCODE_DP4:
+               inst = track_used_srcreg(s, inst, 0, 0xf);
+               inst = track_used_srcreg(s, inst, 1, 0xf);
+               break;
+       case OPCODE_KIL:
+       case OPCODE_TEX:
+       case OPCODE_TXB:
+       case OPCODE_TXP:
+               inst = track_used_srcreg(s, inst, 0, 0xf);
+               break;
+       default:
+               _mesa_problem(s->Ctx, "NqssaDce: Unknown opcode %d\n", inst->Opcode);
+               return;
+       }
+}
+
+
+void radeonNqssaDce(GLcontext *ctx, struct gl_program *p, struct radeon_nqssadce_descr* descr)
+{
+       struct nqssadce_state s;
+
+       _mesa_bzero(&s, sizeof(s));
+       s.Ctx = ctx;
+       s.Program = p;
+       s.Descr = descr;
+       s.Descr->Init(&s);
+       s.IP = p->NumInstructions;
+
+       while(s.IP > 0) {
+               s.IP--;
+               process_instruction(&s);
+       }
+}
diff --git a/src/mesa/drivers/dri/r300/radeon_nqssadce.h b/src/mesa/drivers/dri/r300/radeon_nqssadce.h
new file mode 100644 (file)
index 0000000..a4f94ab
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2008 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.
+ *
+ */
+
+#ifndef __RADEON_PROGRAM_NQSSADCE_H_
+#define __RADEON_PROGRAM_NQSSADCE_H_
+
+#include "radeon_program.h"
+
+
+struct register_state {
+       /**
+        * Bitmask indicating which components of the register are sourced
+        * by later instructions.
+        */
+       GLuint Sourced : 4;
+};
+
+/**
+ * Maintain state such as which registers are used, which registers are
+ * read from, etc.
+ */
+struct nqssadce_state {
+       GLcontext *Ctx;
+       struct gl_program *Program;
+       struct radeon_nqssadce_descr *Descr;
+
+       /**
+        * All instructions after this instruction pointer have been dealt with.
+        */
+       int IP;
+
+       /**
+        * Which registers are read by subsequent instructions?
+        */
+       struct register_state Temps[MAX_PROGRAM_TEMPS];
+       struct register_state Outputs[VERT_RESULT_MAX];
+};
+
+
+/**
+ * This structure contains a description of the hardware in-so-far as
+ * it is required for the NqSSA-DCE pass.
+ */
+struct radeon_nqssadce_descr {
+       /**
+        * Fill in which outputs
+        */
+       void (*Init)(struct nqssadce_state *);
+
+       /**
+        * Check whether the given swizzle, absolute and negate combination
+        * can be implemented natively by the hardware for this opcode.
+        */
+       GLboolean (*IsNativeSwizzle)(GLuint opcode, struct prog_src_register reg);
+
+       /**
+        * Emit (at the current IP) the instruction MOV dst, src;
+        * The transformation will work recursively on the emitted instruction(s).
+        */
+       void (*BuildSwizzle)(struct nqssadce_state*, struct prog_dst_register dst, struct prog_src_register src);
+
+       /**
+        * Rewrite instructions that write to DEPR.z to write to DEPR.w
+        * instead (rewriting is done *before* the WriteMask test).
+        */
+       GLboolean RewriteDepthOut;
+       void *Data;
+};
+
+void radeonNqssaDce(GLcontext *ctx, struct gl_program *p, struct radeon_nqssadce_descr* descr);
+
+#endif /* __RADEON_PROGRAM_NQSSADCE_H_ */
diff --git a/src/mesa/drivers/dri/r300/radeon_program.c b/src/mesa/drivers/dri/r300/radeon_program.c
new file mode 100644 (file)
index 0000000..da5e7ae
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2008 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.
+ *
+ */
+
+#include "radeon_program.h"
+
+#include "shader/prog_print.h"
+
+
+/**
+ * Transform the given clause in the following way:
+ *  1. Replace it with an empty clause
+ *  2. For every instruction in the original clause, try the given
+ *     transformations in order.
+ *  3. If one of the transformations returns GL_TRUE, assume that it
+ *     has emitted the appropriate instruction(s) into the new clause;
+ *     otherwise, copy the instruction verbatim.
+ *
+ * \note The transformation is currently not recursive; in other words,
+ * instructions emitted by transformations are not transformed.
+ *
+ * \note The transform is called 'local' because it can only look at
+ * one instruction at a time.
+ */
+void radeonLocalTransform(
+       GLcontext *Ctx,
+       struct gl_program *program,
+       int num_transformations,
+       struct radeon_program_transformation* transformations)
+{
+       struct radeon_transform_context ctx;
+       int ip;
+
+       ctx.Ctx = Ctx;
+       ctx.Program = program;
+       ctx.OldInstructions = program->Instructions;
+       ctx.OldNumInstructions = program->NumInstructions;
+
+       program->Instructions = 0;
+       program->NumInstructions = 0;
+
+       for(ip = 0; ip < ctx.OldNumInstructions; ++ip) {
+               struct prog_instruction *instr = ctx.OldInstructions + ip;
+               int i;
+
+               for(i = 0; i < num_transformations; ++i) {
+                       struct radeon_program_transformation* t = transformations + i;
+
+                       if (t->function(&ctx, instr, t->userData))
+                               break;
+               }
+
+               if (i >= num_transformations) {
+                       struct prog_instruction* dest = radeonAppendInstructions(program, 1);
+                       _mesa_copy_instructions(dest, instr, 1);
+               }
+       }
+
+       _mesa_free_instructions(ctx.OldInstructions, ctx.OldNumInstructions);
+}
+
+
+static void scan_instructions(GLboolean* used, const struct prog_instruction* insts, GLuint count)
+{
+       GLuint i;
+       for (i = 0; i < count; i++) {
+               const struct prog_instruction *inst = insts + i;
+               const GLuint n = _mesa_num_inst_src_regs(inst->Opcode);
+               GLuint k;
+
+               for (k = 0; k < n; k++) {
+                       if (inst->SrcReg[k].File == PROGRAM_TEMPORARY)
+                               used[inst->SrcReg[k].Index] = GL_TRUE;
+               }
+       }
+}
+
+GLint radeonFindFreeTemporary(struct radeon_transform_context *t)
+{
+       GLboolean used[MAX_PROGRAM_TEMPS];
+       GLuint i;
+
+       _mesa_memset(used, 0, sizeof(used));
+       scan_instructions(used, t->Program->Instructions, t->Program->NumInstructions);
+       scan_instructions(used, t->OldInstructions, t->OldNumInstructions);
+
+       for (i = 0; i < MAX_PROGRAM_TEMPS; i++) {
+               if (!used[i])
+                       return i;
+       }
+
+       return -1;
+}
+
+
+/**
+ * Append the given number of instructions to the program and return a
+ * pointer to the first new instruction.
+ */
+struct prog_instruction *radeonAppendInstructions(struct gl_program *program, int count)
+{
+       int oldnum = program->NumInstructions;
+       _mesa_insert_instructions(program, oldnum, count);
+       return program->Instructions + oldnum;
+}
diff --git a/src/mesa/drivers/dri/r300/radeon_program.h b/src/mesa/drivers/dri/r300/radeon_program.h
new file mode 100644 (file)
index 0000000..2e01dd4
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2008 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.
+ *
+ */
+
+#ifndef __RADEON_PROGRAM_H_
+#define __RADEON_PROGRAM_H_
+
+#include "glheader.h"
+#include "macros.h"
+#include "enums.h"
+#include "shader/program.h"
+#include "shader/prog_instruction.h"
+
+
+enum {
+       CLAUSE_MIXED = 0,
+       CLAUSE_ALU,
+       CLAUSE_TEX
+};
+
+enum {
+       PROGRAM_BUILTIN = PROGRAM_FILE_MAX /**< not a real register, but a special swizzle constant */
+};
+
+enum {
+       OPCODE_REPL_ALPHA = MAX_OPCODE /**< used in paired instructions */
+};
+
+#define SWIZZLE_0000 MAKE_SWIZZLE4(SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ZERO)
+#define SWIZZLE_1111 MAKE_SWIZZLE4(SWIZZLE_ONE, SWIZZLE_ONE, SWIZZLE_ONE, SWIZZLE_ONE)
+
+/**
+ * Transformation context that is passed to local transformations.
+ *
+ * Care must be taken with some operations during transformation,
+ * e.g. finding new temporary registers must use @ref radeonFindFreeTemporary
+ */
+struct radeon_transform_context {
+       GLcontext *Ctx;
+       struct gl_program *Program;
+       struct prog_instruction *OldInstructions;
+       GLuint OldNumInstructions;
+};
+
+/**
+ * A transformation that can be passed to \ref radeonLocalTransform.
+ *
+ * The function will be called once for each instruction.
+ * It has to either emit the appropriate transformed code for the instruction
+ * and return GL_TRUE, or return GL_FALSE if it doesn't understand the
+ * instruction.
+ *
+ * The function gets passed the userData as last parameter.
+ */
+struct radeon_program_transformation {
+       GLboolean (*function)(
+               struct radeon_transform_context*,
+               struct prog_instruction*,
+               void*);
+       void *userData;
+};
+
+void radeonLocalTransform(
+       GLcontext* ctx,
+       struct gl_program *program,
+       int num_transformations,
+       struct radeon_program_transformation* transformations);
+
+/**
+ * Find a usable free temporary register during program transformation
+ */
+GLint radeonFindFreeTemporary(struct radeon_transform_context *ctx);
+
+struct prog_instruction *radeonAppendInstructions(struct gl_program *program, int count);
+
+#endif
diff --git a/src/mesa/drivers/dri/r300/radeon_program_alu.c b/src/mesa/drivers/dri/r300/radeon_program_alu.c
new file mode 100644 (file)
index 0000000..1ef71e7
--- /dev/null
@@ -0,0 +1,658 @@
+/*
+ * Copyright (C) 2008 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.
+ *
+ */
+
+/**
+ * @file
+ *
+ * Shareable transformations that transform "special" ALU instructions
+ * into ALU instructions that are supported by hardware.
+ *
+ */
+
+#include "radeon_program_alu.h"
+
+#include "shader/prog_parameter.h"
+
+
+static struct prog_instruction *emit1(struct gl_program* p,
+       gl_inst_opcode Opcode, GLuint Saturate, struct prog_dst_register DstReg,
+       struct prog_src_register SrcReg)
+{
+       struct prog_instruction *fpi = radeonAppendInstructions(p, 1);
+
+       fpi->Opcode = Opcode;
+       fpi->SaturateMode = Saturate;
+       fpi->DstReg = DstReg;
+       fpi->SrcReg[0] = SrcReg;
+       return fpi;
+}
+
+static struct prog_instruction *emit2(struct gl_program* p,
+       gl_inst_opcode Opcode, GLuint Saturate, struct prog_dst_register DstReg,
+       struct prog_src_register SrcReg0, struct prog_src_register SrcReg1)
+{
+       struct prog_instruction *fpi = radeonAppendInstructions(p, 1);
+
+       fpi->Opcode = Opcode;
+       fpi->SaturateMode = Saturate;
+       fpi->DstReg = DstReg;
+       fpi->SrcReg[0] = SrcReg0;
+       fpi->SrcReg[1] = SrcReg1;
+       return fpi;
+}
+
+static struct prog_instruction *emit3(struct gl_program* p,
+       gl_inst_opcode Opcode, GLuint Saturate, struct prog_dst_register DstReg,
+       struct prog_src_register SrcReg0, struct prog_src_register SrcReg1,
+       struct prog_src_register SrcReg2)
+{
+       struct prog_instruction *fpi = radeonAppendInstructions(p, 1);
+
+       fpi->Opcode = Opcode;
+       fpi->SaturateMode = Saturate;
+       fpi->DstReg = DstReg;
+       fpi->SrcReg[0] = SrcReg0;
+       fpi->SrcReg[1] = SrcReg1;
+       fpi->SrcReg[2] = SrcReg2;
+       return fpi;
+}
+
+static void set_swizzle(struct prog_src_register *SrcReg, int coordinate, int swz)
+{
+       SrcReg->Swizzle &= ~(7 << (3*coordinate));
+       SrcReg->Swizzle |= swz << (3*coordinate);
+}
+
+static void set_negate_base(struct prog_src_register *SrcReg, int coordinate, int negate)
+{
+       SrcReg->NegateBase &= ~(1 << coordinate);
+       SrcReg->NegateBase |= (negate << coordinate);
+}
+
+static struct prog_dst_register dstreg(int file, int index)
+{
+       struct prog_dst_register dst;
+       dst.File = file;
+       dst.Index = index;
+       dst.WriteMask = WRITEMASK_XYZW;
+       dst.CondMask = COND_TR;
+       dst.CondSwizzle = SWIZZLE_NOOP;
+       dst.CondSrc = 0;
+       dst.pad = 0;
+       return dst;
+}
+
+static struct prog_dst_register dstregtmpmask(int index, int mask)
+{
+       struct prog_dst_register dst;
+       dst.File = PROGRAM_TEMPORARY;
+       dst.Index = index;
+       dst.WriteMask = mask;
+       dst.CondMask = COND_TR;
+       dst.CondSwizzle = SWIZZLE_NOOP;
+       dst.CondSrc = 0;
+       dst.pad = 0;
+       return dst;
+}
+
+static const struct prog_src_register builtin_zero = {
+       .File = PROGRAM_BUILTIN,
+       .Index = 0,
+       .Swizzle = SWIZZLE_0000
+};
+static const struct prog_src_register builtin_one = {
+       .File = PROGRAM_BUILTIN,
+       .Index = 0,
+       .Swizzle = SWIZZLE_1111
+};
+static const struct prog_src_register srcreg_undefined = {
+       .File = PROGRAM_UNDEFINED,
+       .Index = 0,
+       .Swizzle = SWIZZLE_NOOP
+};
+
+static struct prog_src_register srcreg(int file, int index)
+{
+       struct prog_src_register src = srcreg_undefined;
+       src.File = file;
+       src.Index = index;
+       return src;
+}
+
+static struct prog_src_register srcregswz(int file, int index, int swz)
+{
+       struct prog_src_register src = srcreg_undefined;
+       src.File = file;
+       src.Index = index;
+       src.Swizzle = swz;
+       return src;
+}
+
+static struct prog_src_register absolute(struct prog_src_register reg)
+{
+       struct prog_src_register newreg = reg;
+       newreg.Abs = 1;
+       newreg.NegateBase = 0;
+       newreg.NegateAbs = 0;
+       return newreg;
+}
+
+static struct prog_src_register negate(struct prog_src_register reg)
+{
+       struct prog_src_register newreg = reg;
+       newreg.NegateAbs = !newreg.NegateAbs;
+       return newreg;
+}
+
+static struct prog_src_register swizzle(struct prog_src_register reg, GLuint x, GLuint y, GLuint z, GLuint w)
+{
+       struct prog_src_register swizzled = reg;
+       swizzled.Swizzle = MAKE_SWIZZLE4(
+               x >= 4 ? x : GET_SWZ(reg.Swizzle, x),
+               y >= 4 ? y : GET_SWZ(reg.Swizzle, y),
+               z >= 4 ? z : GET_SWZ(reg.Swizzle, z),
+               w >= 4 ? w : GET_SWZ(reg.Swizzle, w));
+       return swizzled;
+}
+
+static struct prog_src_register scalar(struct prog_src_register reg)
+{
+       return swizzle(reg, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X);
+}
+
+static void transform_ABS(struct radeon_transform_context* t,
+       struct prog_instruction* inst)
+{
+       struct prog_src_register src = inst->SrcReg[0];
+       src.Abs = 1;
+       src.NegateBase = 0;
+       src.NegateAbs = 0;
+       emit1(t->Program, OPCODE_MOV, inst->SaturateMode, inst->DstReg, src);
+}
+
+static void transform_DPH(struct radeon_transform_context* t,
+       struct prog_instruction* inst)
+{
+       struct prog_src_register src0 = inst->SrcReg[0];
+       if (src0.NegateAbs) {
+               if (src0.Abs) {
+                       int tempreg = radeonFindFreeTemporary(t);
+                       emit1(t->Program, OPCODE_MOV, 0, dstreg(PROGRAM_TEMPORARY, tempreg), src0);
+                       src0 = srcreg(src0.File, src0.Index);
+               } else {
+                       src0.NegateAbs = 0;
+                       src0.NegateBase ^= NEGATE_XYZW;
+               }
+       }
+       set_swizzle(&src0, 3, SWIZZLE_ONE);
+       set_negate_base(&src0, 3, 0);
+       emit2(t->Program, OPCODE_DP4, inst->SaturateMode, inst->DstReg, src0, inst->SrcReg[1]);
+}
+
+/**
+ * [1, src0.y*src1.y, src0.z, src1.w]
+ * So basically MUL with lotsa swizzling.
+ */
+static void transform_DST(struct radeon_transform_context* t,
+       struct prog_instruction* inst)
+{
+       emit2(t->Program, OPCODE_MUL, inst->SaturateMode, inst->DstReg,
+               swizzle(inst->SrcReg[0], SWIZZLE_ONE, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_ONE),
+               swizzle(inst->SrcReg[1], SWIZZLE_ONE, SWIZZLE_Y, SWIZZLE_ONE, SWIZZLE_W));
+}
+
+static void transform_FLR(struct radeon_transform_context* t,
+       struct prog_instruction* inst)
+{
+       int tempreg = radeonFindFreeTemporary(t);
+       emit1(t->Program, OPCODE_FRC, 0, dstreg(PROGRAM_TEMPORARY, tempreg), inst->SrcReg[0]);
+       emit2(t->Program, OPCODE_ADD, inst->SaturateMode, inst->DstReg,
+               inst->SrcReg[0], negate(srcreg(PROGRAM_TEMPORARY, tempreg)));
+}
+
+/**
+ * Definition of LIT (from ARB_fragment_program):
+ *
+ *  tmp = VectorLoad(op0);
+ *  if (tmp.x < 0) tmp.x = 0;
+ *  if (tmp.y < 0) tmp.y = 0;
+ *  if (tmp.w < -(128.0-epsilon)) tmp.w = -(128.0-epsilon);
+ *  else if (tmp.w > 128-epsilon) tmp.w = 128-epsilon;
+ *  result.x = 1.0;
+ *  result.y = tmp.x;
+ *  result.z = (tmp.x > 0) ? RoughApproxPower(tmp.y, tmp.w) : 0.0;
+ *  result.w = 1.0;
+ *
+ * The longest path of computation is the one leading to result.z,
+ * consisting of 5 operations. This implementation of LIT takes
+ * 5 slots, if the subsequent optimization passes are clever enough
+ * to pair instructions correctly.
+ */
+static void transform_LIT(struct radeon_transform_context* t,
+       struct prog_instruction* inst)
+{
+       static const GLfloat LitConst[4] = { -127.999999 };
+
+       GLuint constant;
+       GLuint constant_swizzle;
+       GLuint temp;
+       int needTemporary = 0;
+       struct prog_src_register srctemp;
+
+       constant = _mesa_add_unnamed_constant(t->Program->Parameters, LitConst, 1, &constant_swizzle);
+
+       if (inst->DstReg.WriteMask != WRITEMASK_XYZW) {
+               needTemporary = 1;
+       } else if (inst->DstReg.File != PROGRAM_TEMPORARY) {
+               // LIT is typically followed by DP3/DP4, so there's no point
+               // in creating special code for this case
+               needTemporary = 1;
+       }
+
+       if (needTemporary) {
+               temp = radeonFindFreeTemporary(t);
+       } else {
+               temp = inst->DstReg.Index;
+       }
+       srctemp = srcreg(PROGRAM_TEMPORARY, temp);
+
+       // tmp.x = max(0.0, Src.x);
+       // tmp.y = max(0.0, Src.y);
+       // tmp.w = clamp(Src.z, -128+eps, 128-eps);
+       emit2(t->Program, OPCODE_MAX, 0,
+               dstregtmpmask(temp, WRITEMASK_XYW),
+               inst->SrcReg[0],
+               swizzle(srcreg(PROGRAM_CONSTANT, constant),
+                       SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ZERO, constant_swizzle&3));
+       emit2(t->Program, OPCODE_MIN, 0,
+               dstregtmpmask(temp, WRITEMASK_Z),
+               swizzle(srctemp, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W),
+               negate(srcregswz(PROGRAM_CONSTANT, constant, constant_swizzle)));
+
+       // tmp.w = Pow(tmp.y, tmp.w)
+       emit1(t->Program, OPCODE_LG2, 0,
+               dstregtmpmask(temp, WRITEMASK_W),
+               swizzle(srctemp, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y));
+       emit2(t->Program, OPCODE_MUL, 0,
+               dstregtmpmask(temp, WRITEMASK_W),
+               swizzle(srctemp, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W),
+               swizzle(srctemp, SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z));
+       emit1(t->Program, OPCODE_EX2, 0,
+               dstregtmpmask(temp, WRITEMASK_W),
+               swizzle(srctemp, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W));
+
+       // tmp.z = (tmp.x > 0) ? tmp.w : 0.0
+       emit3(t->Program, OPCODE_CMP, inst->SaturateMode,
+               dstregtmpmask(temp, WRITEMASK_Z),
+               negate(swizzle(srctemp, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X)),
+               swizzle(srctemp, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W),
+               builtin_zero);
+
+       // tmp.x, tmp.y, tmp.w = 1.0, tmp.x, 1.0
+       emit1(t->Program, OPCODE_MOV, inst->SaturateMode,
+               dstregtmpmask(temp, WRITEMASK_XYW),
+               swizzle(srctemp, SWIZZLE_ONE, SWIZZLE_X, SWIZZLE_ONE, SWIZZLE_ONE));
+
+       if (needTemporary)
+               emit1(t->Program, OPCODE_MOV, 0, inst->DstReg, srctemp);
+}
+
+static void transform_LRP(struct radeon_transform_context* t,
+       struct prog_instruction* inst)
+{
+       int tempreg = radeonFindFreeTemporary(t);
+
+       emit2(t->Program, OPCODE_ADD, 0,
+               dstreg(PROGRAM_TEMPORARY, tempreg),
+               inst->SrcReg[1], negate(inst->SrcReg[2]));
+       emit3(t->Program, OPCODE_MAD, inst->SaturateMode,
+               inst->DstReg,
+               inst->SrcReg[0], srcreg(PROGRAM_TEMPORARY, tempreg), inst->SrcReg[2]);
+}
+
+static void transform_POW(struct radeon_transform_context* t,
+       struct prog_instruction* inst)
+{
+       int tempreg = radeonFindFreeTemporary(t);
+       struct prog_dst_register tempdst = dstreg(PROGRAM_TEMPORARY, tempreg);
+       struct prog_src_register tempsrc = srcreg(PROGRAM_TEMPORARY, tempreg);
+       tempdst.WriteMask = WRITEMASK_W;
+       tempsrc.Swizzle = SWIZZLE_WWWW;
+
+       emit1(t->Program, OPCODE_LG2, 0, tempdst, scalar(inst->SrcReg[0]));
+       emit2(t->Program, OPCODE_MUL, 0, tempdst, tempsrc, scalar(inst->SrcReg[1]));
+       emit1(t->Program, OPCODE_EX2, inst->SaturateMode, inst->DstReg, tempsrc);
+}
+
+static void transform_RSQ(struct radeon_transform_context* t,
+       struct prog_instruction* inst)
+{
+       emit1(t->Program, OPCODE_RSQ, inst->SaturateMode, inst->DstReg, absolute(inst->SrcReg[0]));
+}
+
+static void transform_SGE(struct radeon_transform_context* t,
+       struct prog_instruction* inst)
+{
+       int tempreg = radeonFindFreeTemporary(t);
+
+       emit2(t->Program, OPCODE_ADD, 0, dstreg(PROGRAM_TEMPORARY, tempreg), inst->SrcReg[0], negate(inst->SrcReg[1]));
+       emit3(t->Program, OPCODE_CMP, inst->SaturateMode, inst->DstReg,
+               srcreg(PROGRAM_TEMPORARY, tempreg), builtin_zero, builtin_one);
+}
+
+static void transform_SLT(struct radeon_transform_context* t,
+       struct prog_instruction* inst)
+{
+       int tempreg = radeonFindFreeTemporary(t);
+
+       emit2(t->Program, OPCODE_ADD, 0, dstreg(PROGRAM_TEMPORARY, tempreg), inst->SrcReg[0], negate(inst->SrcReg[1]));
+       emit3(t->Program, OPCODE_CMP, inst->SaturateMode, inst->DstReg,
+               srcreg(PROGRAM_TEMPORARY, tempreg), builtin_one, builtin_zero);
+}
+
+static void transform_SUB(struct radeon_transform_context* t,
+       struct prog_instruction* inst)
+{
+       emit2(t->Program, OPCODE_ADD, inst->SaturateMode, inst->DstReg, inst->SrcReg[0], negate(inst->SrcReg[1]));
+}
+
+static void transform_SWZ(struct radeon_transform_context* t,
+       struct prog_instruction* inst)
+{
+       emit1(t->Program, OPCODE_MOV, inst->SaturateMode, inst->DstReg, inst->SrcReg[0]);
+}
+
+static void transform_XPD(struct radeon_transform_context* t,
+       struct prog_instruction* inst)
+{
+       int tempreg = radeonFindFreeTemporary(t);
+
+       emit2(t->Program, OPCODE_MUL, 0, dstreg(PROGRAM_TEMPORARY, tempreg),
+               swizzle(inst->SrcReg[0], SWIZZLE_Z, SWIZZLE_X, SWIZZLE_Y, SWIZZLE_W),
+               swizzle(inst->SrcReg[1], SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_X, SWIZZLE_W));
+       emit3(t->Program, OPCODE_MAD, inst->SaturateMode, inst->DstReg,
+               swizzle(inst->SrcReg[0], SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_X, SWIZZLE_W),
+               swizzle(inst->SrcReg[1], SWIZZLE_Z, SWIZZLE_X, SWIZZLE_Y, SWIZZLE_W),
+               negate(srcreg(PROGRAM_TEMPORARY, tempreg)));
+}
+
+
+/**
+ * Can be used as a transformation for @ref radeonClauseLocalTransform,
+ * no userData necessary.
+ *
+ * Eliminates the following ALU instructions:
+ *  ABS, DPH, DST, FLR, LIT, LRP, POW, SGE, SLT, SUB, SWZ, XPD
+ * using:
+ *  MOV, ADD, MUL, MAD, FRC, DP3, LG2, EX2, CMP
+ *
+ * Transforms RSQ to Radeon's native RSQ by explicitly setting
+ * absolute value.
+ *
+ * @note should be applicable to R300 and R500 fragment programs.
+ */
+GLboolean radeonTransformALU(struct radeon_transform_context* t,
+       struct prog_instruction* inst,
+       void* unused)
+{
+       switch(inst->Opcode) {
+       case OPCODE_ABS: transform_ABS(t, inst); return GL_TRUE;
+       case OPCODE_DPH: transform_DPH(t, inst); return GL_TRUE;
+       case OPCODE_DST: transform_DST(t, inst); return GL_TRUE;
+       case OPCODE_FLR: transform_FLR(t, inst); return GL_TRUE;
+       case OPCODE_LIT: transform_LIT(t, inst); return GL_TRUE;
+       case OPCODE_LRP: transform_LRP(t, inst); return GL_TRUE;
+       case OPCODE_POW: transform_POW(t, inst); return GL_TRUE;
+       case OPCODE_RSQ: transform_RSQ(t, inst); return GL_TRUE;
+       case OPCODE_SGE: transform_SGE(t, inst); return GL_TRUE;
+       case OPCODE_SLT: transform_SLT(t, inst); return GL_TRUE;
+       case OPCODE_SUB: transform_SUB(t, inst); return GL_TRUE;
+       case OPCODE_SWZ: transform_SWZ(t, inst); return GL_TRUE;
+       case OPCODE_XPD: transform_XPD(t, inst); return GL_TRUE;
+       default:
+               return GL_FALSE;
+       }
+}
+
+
+static void sincos_constants(struct radeon_transform_context* t, GLuint *constants)
+{
+       static const GLfloat SinCosConsts[2][4] = {
+               {
+                       1.273239545,            // 4/PI
+                       -0.405284735,           // -4/(PI*PI)
+                       3.141592654,            // PI
+                       0.2225                  // weight
+               },
+               {
+                       0.75,
+                       0.5,
+                       0.159154943,            // 1/(2*PI)
+                       6.283185307             // 2*PI
+               }
+       };
+       int i;
+
+       for(i = 0; i < 2; ++i) {
+               GLuint swz;
+               constants[i] = _mesa_add_unnamed_constant(t->Program->Parameters, SinCosConsts[i], 4, &swz);
+               ASSERT(swz == SWIZZLE_NOOP);
+       }
+}
+
+/**
+ * Approximate sin(x), where x is clamped to (-pi/2, pi/2).
+ *
+ * MUL tmp.xy, src, { 4/PI, -4/(PI^2) }
+ * MAD tmp.x, tmp.y, |src|, tmp.x
+ * MAD tmp.y, tmp.x, |tmp.x|, -tmp.x
+ * MAD dest, tmp.y, weight, tmp.x
+ */
+static void sin_approx(struct radeon_transform_context* t,
+       struct prog_dst_register dst, struct prog_src_register src, const GLuint* constants)
+{
+       GLuint tempreg = radeonFindFreeTemporary(t);
+
+       emit2(t->Program, OPCODE_MUL, 0, dstregtmpmask(tempreg, WRITEMASK_XY),
+               swizzle(src, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X),
+               srcreg(PROGRAM_CONSTANT, constants[0]));
+       emit3(t->Program, OPCODE_MAD, 0, dstregtmpmask(tempreg, WRITEMASK_X),
+               swizzle(srcreg(PROGRAM_TEMPORARY, tempreg), SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y),
+               absolute(swizzle(src, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X)),
+               swizzle(srcreg(PROGRAM_TEMPORARY, tempreg), SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X));
+       emit3(t->Program, OPCODE_MAD, 0, dstregtmpmask(tempreg, WRITEMASK_Y),
+               swizzle(srcreg(PROGRAM_TEMPORARY, tempreg), SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X),
+               absolute(swizzle(srcreg(PROGRAM_TEMPORARY, tempreg), SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X)),
+               negate(swizzle(srcreg(PROGRAM_TEMPORARY, tempreg), SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X)));
+       emit3(t->Program, OPCODE_MAD, 0, dst,
+               swizzle(srcreg(PROGRAM_TEMPORARY, tempreg), SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y),
+               swizzle(srcreg(PROGRAM_CONSTANT, constants[0]), SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W),
+               swizzle(srcreg(PROGRAM_TEMPORARY, tempreg), SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X));
+}
+
+/**
+ * Translate the trigonometric functions COS, SIN, and SCS
+ * using only the basic instructions
+ *  MOV, ADD, MUL, MAD, FRC
+ */
+GLboolean radeonTransformTrigSimple(struct radeon_transform_context* t,
+       struct prog_instruction* inst,
+       void* unused)
+{
+       if (inst->Opcode != OPCODE_COS &&
+           inst->Opcode != OPCODE_SIN &&
+           inst->Opcode != OPCODE_SCS)
+               return GL_FALSE;
+
+       GLuint constants[2];
+       GLuint tempreg = radeonFindFreeTemporary(t);
+
+       sincos_constants(t, constants);
+
+       if (inst->Opcode == OPCODE_COS) {
+               // MAD tmp.x, src, 1/(2*PI), 0.75
+               // FRC tmp.x, tmp.x
+               // MAD tmp.z, tmp.x, 2*PI, -PI
+               emit3(t->Program, OPCODE_MAD, 0, dstregtmpmask(tempreg, WRITEMASK_W),
+                       swizzle(inst->SrcReg[0], SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X),
+                       swizzle(srcreg(PROGRAM_CONSTANT, constants[1]), SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z),
+                       swizzle(srcreg(PROGRAM_CONSTANT, constants[1]), SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X));
+               emit1(t->Program, OPCODE_FRC, 0, dstregtmpmask(tempreg, WRITEMASK_W),
+                       swizzle(srcreg(PROGRAM_TEMPORARY, tempreg), SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W));
+               emit3(t->Program, OPCODE_MAD, 0, dstregtmpmask(tempreg, WRITEMASK_W),
+                       swizzle(srcreg(PROGRAM_TEMPORARY, tempreg), SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W),
+                       swizzle(srcreg(PROGRAM_CONSTANT, constants[1]), SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W),
+                       negate(swizzle(srcreg(PROGRAM_CONSTANT, constants[0]), SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z)));
+
+               sin_approx(t, inst->DstReg,
+                       swizzle(srcreg(PROGRAM_TEMPORARY, tempreg), SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W),
+                       constants);
+       } else if (inst->Opcode == OPCODE_SIN) {
+               emit3(t->Program, OPCODE_MAD, 0, dstregtmpmask(tempreg, WRITEMASK_W),
+                       swizzle(inst->SrcReg[0], SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X),
+                       swizzle(srcreg(PROGRAM_CONSTANT, constants[1]), SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z),
+                       swizzle(srcreg(PROGRAM_CONSTANT, constants[1]), SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y));
+               emit1(t->Program, OPCODE_FRC, 0, dstregtmpmask(tempreg, WRITEMASK_W),
+                       swizzle(srcreg(PROGRAM_TEMPORARY, tempreg), SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W));
+               emit3(t->Program, OPCODE_MAD, 0, dstregtmpmask(tempreg, WRITEMASK_W),
+                       swizzle(srcreg(PROGRAM_TEMPORARY, tempreg), SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W),
+                       swizzle(srcreg(PROGRAM_CONSTANT, constants[1]), SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W),
+                       negate(swizzle(srcreg(PROGRAM_CONSTANT, constants[0]), SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z)));
+
+               sin_approx(t, inst->DstReg,
+                       swizzle(srcreg(PROGRAM_TEMPORARY, tempreg), SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W),
+                       constants);
+       } else {
+               emit3(t->Program, OPCODE_MAD, 0, dstregtmpmask(tempreg, WRITEMASK_XY),
+                       swizzle(inst->SrcReg[0], SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X),
+                       swizzle(srcreg(PROGRAM_CONSTANT, constants[1]), SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z),
+                       swizzle(srcreg(PROGRAM_CONSTANT, constants[1]), SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W));
+               emit1(t->Program, OPCODE_FRC, 0, dstregtmpmask(tempreg, WRITEMASK_XY),
+                       srcreg(PROGRAM_TEMPORARY, tempreg));
+               emit3(t->Program, OPCODE_MAD, 0, dstregtmpmask(tempreg, WRITEMASK_XY),
+                       srcreg(PROGRAM_TEMPORARY, tempreg),
+                       swizzle(srcreg(PROGRAM_CONSTANT, constants[1]), SWIZZLE_W, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W),
+                       negate(swizzle(srcreg(PROGRAM_CONSTANT, constants[0]), SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z, SWIZZLE_Z)));
+
+               struct prog_dst_register dst = inst->DstReg;
+
+               dst.WriteMask = inst->DstReg.WriteMask & WRITEMASK_X;
+               sin_approx(t, dst,
+                       swizzle(srcreg(PROGRAM_TEMPORARY, tempreg), SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X),
+                       constants);
+
+               dst.WriteMask = inst->DstReg.WriteMask & WRITEMASK_Y;
+               sin_approx(t, dst,
+                       swizzle(srcreg(PROGRAM_TEMPORARY, tempreg), SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y),
+                       constants);
+       }
+
+       return GL_TRUE;
+}
+
+
+/**
+ * Transform the trigonometric functions COS, SIN, and SCS
+ * to include pre-scaling by 1/(2*PI) and taking the fractional
+ * part, so that the input to COS and SIN is always in the range [0,1).
+ * SCS is replaced by one COS and one SIN instruction.
+ *
+ * @warning This transformation implicitly changes the semantics of SIN and COS!
+ */
+GLboolean radeonTransformTrigScale(struct radeon_transform_context* t,
+       struct prog_instruction* inst,
+       void* unused)
+{
+       if (inst->Opcode != OPCODE_COS &&
+           inst->Opcode != OPCODE_SIN &&
+           inst->Opcode != OPCODE_SCS)
+               return GL_FALSE;
+
+       static const GLfloat RCP_2PI[] = { 0.15915494309189535 };
+       GLuint temp;
+       GLuint constant;
+       GLuint constant_swizzle;
+
+       temp = radeonFindFreeTemporary(t);
+       constant = _mesa_add_unnamed_constant(t->Program->Parameters, RCP_2PI, 1, &constant_swizzle);
+
+       emit2(t->Program, OPCODE_MUL, 0, dstregtmpmask(temp, WRITEMASK_W),
+               swizzle(inst->SrcReg[0], SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X),
+               srcregswz(PROGRAM_CONSTANT, constant, constant_swizzle));
+       emit1(t->Program, OPCODE_FRC, 0, dstregtmpmask(temp, WRITEMASK_W),
+               srcreg(PROGRAM_TEMPORARY, temp));
+
+       if (inst->Opcode == OPCODE_COS) {
+               emit1(t->Program, OPCODE_COS, inst->SaturateMode, inst->DstReg,
+                       srcregswz(PROGRAM_TEMPORARY, temp, SWIZZLE_WWWW));
+       } else if (inst->Opcode == OPCODE_SIN) {
+               emit1(t->Program, OPCODE_SIN, inst->SaturateMode,
+                       inst->DstReg, srcregswz(PROGRAM_TEMPORARY, temp, SWIZZLE_WWWW));
+       } else if (inst->Opcode == OPCODE_SCS) {
+               struct prog_dst_register moddst = inst->DstReg;
+
+               if (inst->DstReg.WriteMask & WRITEMASK_X) {
+                       moddst.WriteMask = WRITEMASK_X;
+                       emit1(t->Program, OPCODE_COS, inst->SaturateMode, moddst,
+                               srcregswz(PROGRAM_TEMPORARY, temp, SWIZZLE_WWWW));
+               }
+               if (inst->DstReg.WriteMask & WRITEMASK_Y) {
+                       moddst.WriteMask = WRITEMASK_Y;
+                       emit1(t->Program, OPCODE_SIN, inst->SaturateMode, moddst,
+                               srcregswz(PROGRAM_TEMPORARY, temp, SWIZZLE_WWWW));
+               }
+       }
+
+       return GL_TRUE;
+}
+
+/**
+ * Rewrite DDX/DDY instructions to properly work with r5xx shaders.
+ * The r5xx MDH/MDV instruction provides per-quad partial derivatives.
+ * It takes the form A*B+C. A and C are set by setting src0. B should be -1.
+ *
+ * @warning This explicitly changes the form of DDX and DDY!
+ */
+
+GLboolean radeonTransformDeriv(struct radeon_transform_context* t,
+       struct prog_instruction* inst,
+       void* unused)
+{
+       if (inst->Opcode != OPCODE_DDX && inst->Opcode != OPCODE_DDY)
+               return GL_FALSE;
+
+       struct prog_src_register B = inst->SrcReg[1];
+
+       B.Swizzle = MAKE_SWIZZLE4(SWIZZLE_ONE, SWIZZLE_ONE,
+                                               SWIZZLE_ONE, SWIZZLE_ONE);
+       B.NegateBase = NEGATE_XYZW;
+
+       emit2(t->Program, inst->Opcode, inst->SaturateMode, inst->DstReg,
+               inst->SrcReg[0], B);
+
+       return GL_TRUE;
+}
diff --git a/src/mesa/drivers/dri/r300/radeon_program_alu.h b/src/mesa/drivers/dri/r300/radeon_program_alu.h
new file mode 100644 (file)
index 0000000..b459581
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2008 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.
+ *
+ */
+
+#ifndef __RADEON_PROGRAM_ALU_H_
+#define __RADEON_PROGRAM_ALU_H_
+
+#include "radeon_program.h"
+
+GLboolean radeonTransformALU(
+       struct radeon_transform_context *t,
+       struct prog_instruction*,
+       void*);
+
+GLboolean radeonTransformTrigSimple(
+       struct radeon_transform_context *t,
+       struct prog_instruction*,
+       void*);
+
+GLboolean radeonTransformTrigScale(
+       struct radeon_transform_context *t,
+       struct prog_instruction*,
+       void*);
+
+GLboolean radeonTransformDeriv(
+       struct radeon_transform_context *t,
+       struct prog_instruction*,
+       void*);
+
+#endif /* __RADEON_PROGRAM_ALU_H_ */
diff --git a/src/mesa/drivers/dri/r300/radeon_program_pair.c b/src/mesa/drivers/dri/r300/radeon_program_pair.c
new file mode 100644 (file)
index 0000000..5ad50d2
--- /dev/null
@@ -0,0 +1,1001 @@
+/*
+ * Copyright (C) 2008 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.
+ *
+ */
+
+/**
+ * @file
+ *
+ * Perform temporary register allocation and attempt to pair off instructions
+ * in RGB and Alpha pairs. Also attempts to optimize the TEX instruction
+ * vs. ALU instruction scheduling.
+ */
+
+#include "radeon_program_pair.h"
+
+#include "radeon_context.h"
+
+#include "shader/prog_print.h"
+
+#define error(fmt, args...) do { \
+       _mesa_problem(s->Ctx, "%s::%s(): " fmt "\n",    \
+               __FILE__, __FUNCTION__, ##args);        \
+       s->Error = GL_TRUE;                             \
+} while(0)
+
+struct pair_state_instruction {
+       GLuint IsTex:1; /**< Is a texture instruction */
+       GLuint NeedRGB:1; /**< Needs the RGB ALU */
+       GLuint NeedAlpha:1; /**< Needs the Alpha ALU */
+       GLuint IsTranscendent:1; /**< Is a special transcendent instruction */
+
+       /**
+        * Number of (read and write) dependencies that must be resolved before
+        * this instruction can be scheduled.
+        */
+       GLuint NumDependencies:5;
+
+       /**
+        * Next instruction in the linked list of ready instructions.
+        */
+       struct pair_state_instruction *NextReady;
+
+       /**
+        * Values that this instruction writes
+        */
+       struct reg_value *Values[4];
+};
+
+
+/**
+ * Used to keep track of which instructions read a value.
+ */
+struct reg_value_reader {
+       GLuint IP; /**< IP of the instruction that performs this access */
+       struct reg_value_reader *Next;
+};
+
+/**
+ * Used to keep track which values are stored in each component of a
+ * PROGRAM_TEMPORARY.
+ */
+struct reg_value {
+       GLuint IP; /**< IP of the instruction that writes this value */
+       struct reg_value *Next; /**< Pointer to the next value to be written to the same PROGRAM_TEMPORARY component */
+
+       /**
+        * Unordered linked list of instructions that read from this value.
+        */
+       struct reg_value_reader *Readers;
+
+       /**
+        * Number of readers of this value. This is calculated during @ref scan_instructions
+        * and continually decremented during code emission.
+        * When this count reaches zero, the instruction that writes the @ref Next value
+        * can be scheduled.
+        */
+       GLuint NumReaders;
+};
+
+/**
+ * Used to translate a PROGRAM_INPUT or PROGRAM_TEMPORARY Mesa register
+ * to the proper hardware temporary.
+ */
+struct pair_register_translation {
+       GLuint Allocated:1;
+       GLuint HwIndex:8;
+       GLuint RefCount:23; /**< # of times this occurs in an unscheduled instruction SrcReg or DstReg */
+
+       /**
+        * Notes the value that is currently contained in each component
+        * (only used for PROGRAM_TEMPORARY registers).
+        */
+       struct reg_value *Value[4];
+};
+
+struct pair_state {
+       GLcontext *Ctx;
+       struct gl_program *Program;
+       const struct radeon_pair_handler *Handler;
+       GLboolean Error;
+       GLboolean Debug;
+       GLboolean Verbose;
+       void *UserData;
+
+       /**
+        * Translate Mesa registers to hardware registers
+        */
+       struct pair_register_translation Inputs[FRAG_ATTRIB_MAX];
+       struct pair_register_translation Temps[MAX_PROGRAM_TEMPS];
+
+       /**
+        * Derived information about program instructions.
+        */
+       struct pair_state_instruction *Instructions;
+
+       struct {
+               GLuint RefCount; /**< # of times this occurs in an unscheduled SrcReg or DstReg */
+       } HwTemps[128];
+
+       /**
+        * Linked list of instructions that can be scheduled right now,
+        * based on which ALU/TEX resources they require.
+        */
+       struct pair_state_instruction *ReadyFullALU;
+       struct pair_state_instruction *ReadyRGB;
+       struct pair_state_instruction *ReadyAlpha;
+       struct pair_state_instruction *ReadyTEX;
+
+       /**
+        * Pool of @ref reg_value structures for fast allocation.
+        */
+       struct reg_value *ValuePool;
+       GLuint ValuePoolUsed;
+       struct reg_value_reader *ReaderPool;
+       GLuint ReaderPoolUsed;
+};
+
+
+static struct pair_register_translation *get_register(struct pair_state *s, GLuint file, GLuint index)
+{
+       switch(file) {
+       case PROGRAM_TEMPORARY: return &s->Temps[index];
+       case PROGRAM_INPUT: return &s->Inputs[index];
+       default: return 0;
+       }
+}
+
+static void alloc_hw_reg(struct pair_state *s, GLuint file, GLuint index, GLuint hwindex)
+{
+       struct pair_register_translation *t = get_register(s, file, index);
+       ASSERT(!s->HwTemps[hwindex].RefCount);
+       ASSERT(!t->Allocated);
+       s->HwTemps[hwindex].RefCount = t->RefCount;
+       t->Allocated = 1;
+       t->HwIndex = hwindex;
+}
+
+static GLuint get_hw_reg(struct pair_state *s, GLuint file, GLuint index)
+{
+       GLuint hwindex;
+
+       struct pair_register_translation *t = get_register(s, file, index);
+       if (!t) {
+               _mesa_problem(s->Ctx, "get_hw_reg: %i[%i]\n", file, index);
+               return 0;
+       }
+
+       if (t->Allocated)
+               return t->HwIndex;
+
+       for(hwindex = 0; hwindex < s->Handler->MaxHwTemps; ++hwindex)
+               if (!s->HwTemps[hwindex].RefCount)
+                       break;
+
+       if (hwindex >= s->Handler->MaxHwTemps) {
+               error("Ran out of hardware temporaries");
+               return 0;
+       }
+
+       alloc_hw_reg(s, file, index, hwindex);
+       return hwindex;
+}
+
+
+static void deref_hw_reg(struct pair_state *s, GLuint hwindex)
+{
+       if (!s->HwTemps[hwindex].RefCount) {
+               error("Hwindex %i refcount error", hwindex);
+               return;
+       }
+
+       s->HwTemps[hwindex].RefCount--;
+}
+
+static void add_pairinst_to_list(struct pair_state_instruction **list, struct pair_state_instruction *pairinst)
+{
+       pairinst->NextReady = *list;
+       *list = pairinst;
+}
+
+/**
+ * The instruction at the given IP has become ready. Link it into the ready
+ * instructions.
+ */
+static void instruction_ready(struct pair_state *s, int ip)
+{
+       struct pair_state_instruction *pairinst = s->Instructions + ip;
+
+       if (s->Verbose)
+               _mesa_printf("instruction_ready(%i)\n", ip);
+
+       if (pairinst->IsTex)
+               add_pairinst_to_list(&s->ReadyTEX, pairinst);
+       else if (!pairinst->NeedAlpha)
+               add_pairinst_to_list(&s->ReadyRGB, pairinst);
+       else if (!pairinst->NeedRGB)
+               add_pairinst_to_list(&s->ReadyAlpha, pairinst);
+       else
+               add_pairinst_to_list(&s->ReadyFullALU, pairinst);
+}
+
+
+/**
+ * Finally rewrite ADD, MOV, MUL as the appropriate native instruction
+ * and reverse the order of arguments for CMP.
+ */
+static void final_rewrite(struct pair_state *s, struct prog_instruction *inst)
+{
+       struct prog_src_register tmp;
+
+       switch(inst->Opcode) {
+       case OPCODE_ADD:
+               inst->SrcReg[2] = inst->SrcReg[1];
+               inst->SrcReg[1].File = PROGRAM_BUILTIN;
+               inst->SrcReg[1].Swizzle = SWIZZLE_1111;
+               inst->SrcReg[1].NegateBase = 0;
+               inst->SrcReg[1].NegateAbs = 0;
+               inst->Opcode = OPCODE_MAD;
+               break;
+       case OPCODE_CMP:
+               tmp = inst->SrcReg[2];
+               inst->SrcReg[2] = inst->SrcReg[0];
+               inst->SrcReg[0] = tmp;
+               break;
+       case OPCODE_MOV:
+               /* AMD say we should use CMP.
+                * However, when we transform
+                *  KIL -r0;
+                * into
+                *  CMP tmp, -r0, -r0, 0;
+                *  KIL tmp;
+                * we get incorrect behaviour on R500 when r0 == 0.0.
+                * It appears that the R500 KIL hardware treats -0.0 as less
+                * than zero.
+                */
+               inst->SrcReg[1].File = PROGRAM_BUILTIN;
+               inst->SrcReg[1].Swizzle = SWIZZLE_1111;
+               inst->SrcReg[2].File = PROGRAM_BUILTIN;
+               inst->SrcReg[2].Swizzle = SWIZZLE_0000;
+               inst->Opcode = OPCODE_MAD;
+               break;
+       case OPCODE_MUL:
+               inst->SrcReg[2].File = PROGRAM_BUILTIN;
+               inst->SrcReg[2].Swizzle = SWIZZLE_0000;
+               inst->Opcode = OPCODE_MAD;
+               break;
+       default:
+               /* nothing to do */
+               break;
+       }
+}
+
+
+/**
+ * Classify an instruction according to which ALUs etc. it needs
+ */
+static void classify_instruction(struct pair_state *s,
+       struct prog_instruction *inst, struct pair_state_instruction *pairinst)
+{
+       pairinst->NeedRGB = (inst->DstReg.WriteMask & WRITEMASK_XYZ) ? 1 : 0;
+       pairinst->NeedAlpha = (inst->DstReg.WriteMask & WRITEMASK_W) ? 1 : 0;
+
+       switch(inst->Opcode) {
+       case OPCODE_ADD:
+       case OPCODE_CMP:
+       case OPCODE_DDX:
+       case OPCODE_DDY:
+       case OPCODE_FRC:
+       case OPCODE_MAD:
+       case OPCODE_MAX:
+       case OPCODE_MIN:
+       case OPCODE_MOV:
+       case OPCODE_MUL:
+               break;
+       case OPCODE_COS:
+       case OPCODE_EX2:
+       case OPCODE_LG2:
+       case OPCODE_RCP:
+       case OPCODE_RSQ:
+       case OPCODE_SIN:
+               pairinst->IsTranscendent = 1;
+               pairinst->NeedAlpha = 1;
+               break;
+       case OPCODE_DP4:
+               pairinst->NeedAlpha = 1;
+               /* fall through */
+       case OPCODE_DP3:
+               pairinst->NeedRGB = 1;
+               break;
+       case OPCODE_KIL:
+       case OPCODE_TEX:
+       case OPCODE_TXB:
+       case OPCODE_TXP:
+       case OPCODE_END:
+               pairinst->IsTex = 1;
+               break;
+       default:
+               error("Unknown opcode %d\n", inst->Opcode);
+               break;
+       }
+}
+
+
+/**
+ * Count which (input, temporary) register is read and written how often,
+ * and scan the instruction stream to find dependencies.
+ */
+static void scan_instructions(struct pair_state *s)
+{
+       struct prog_instruction *inst;
+       struct pair_state_instruction *pairinst;
+       GLuint ip;
+
+       for(inst = s->Program->Instructions, pairinst = s->Instructions, ip = 0;
+           inst->Opcode != OPCODE_END;
+           ++inst, ++pairinst, ++ip) {
+               final_rewrite(s, inst);
+               classify_instruction(s, inst, pairinst);
+
+               int nsrc = _mesa_num_inst_src_regs(inst->Opcode);
+               int j;
+               for(j = 0; j < nsrc; j++) {
+                       struct pair_register_translation *t =
+                               get_register(s, inst->SrcReg[j].File, inst->SrcReg[j].Index);
+                       if (!t)
+                               continue;
+
+                       t->RefCount++;
+
+                       if (inst->SrcReg[j].File == PROGRAM_TEMPORARY) {
+                               int i;
+                               for(i = 0; i < 4; ++i) {
+                                       GLuint swz = GET_SWZ(inst->SrcReg[j].Swizzle, i);
+                                       if (swz >= 4)
+                                               continue; /* constant or NIL swizzle */
+                                       if (!t->Value[swz])
+                                               continue; /* this is an undefined read */
+
+                                       /* Do not add a dependency if this instruction
+                                        * also rewrites the value. The code below adds
+                                        * a dependency for the DstReg, which is a superset
+                                        * of the SrcReg dependency. */
+                                       if (inst->DstReg.File == PROGRAM_TEMPORARY &&
+                                           inst->DstReg.Index == inst->SrcReg[j].Index &&
+                                           GET_BIT(inst->DstReg.WriteMask, swz))
+                                               continue;
+
+                                       struct reg_value_reader* r = &s->ReaderPool[s->ReaderPoolUsed++];
+                                       pairinst->NumDependencies++;
+                                       t->Value[swz]->NumReaders++;
+                                       r->IP = ip;
+                                       r->Next = t->Value[swz]->Readers;
+                                       t->Value[swz]->Readers = r;
+                               }
+                       }
+               }
+
+               int ndst = _mesa_num_inst_dst_regs(inst->Opcode);
+               if (ndst) {
+                       struct pair_register_translation *t =
+                               get_register(s, inst->DstReg.File, inst->DstReg.Index);
+                       if (t) {
+                               t->RefCount++;
+
+                               if (inst->DstReg.File == PROGRAM_TEMPORARY) {
+                                       int j;
+                                       for(j = 0; j < 4; ++j) {
+                                               if (!GET_BIT(inst->DstReg.WriteMask, j))
+                                                       continue;
+
+                                               struct reg_value* v = &s->ValuePool[s->ValuePoolUsed++];
+                                               v->IP = ip;
+                                               if (t->Value[j]) {
+                                                       pairinst->NumDependencies++;
+                                                       t->Value[j]->Next = v;
+                                               }
+                                               t->Value[j] = v;
+                                               pairinst->Values[j] = v;
+                                       }
+                               }
+                       }
+               }
+
+               if (s->Verbose)
+                       _mesa_printf("scan(%i): NumDeps = %i\n", ip, pairinst->NumDependencies);
+
+               if (!pairinst->NumDependencies)
+                       instruction_ready(s, ip);
+       }
+
+       /* Clear the PROGRAM_TEMPORARY state */
+       int i, j;
+       for(i = 0; i < MAX_PROGRAM_TEMPS; ++i) {
+               for(j = 0; j < 4; ++j)
+                       s->Temps[i].Value[j] = 0;
+       }
+}
+
+
+/**
+ * Reserve hardware temporary registers for the program inputs.
+ *
+ * @note This allocation is performed explicitly, because the order of inputs
+ * is determined by the RS hardware.
+ */
+static void allocate_input_registers(struct pair_state *s)
+{
+       GLuint InputsRead = s->Program->InputsRead;
+       int i;
+       GLuint hwindex = 0;
+
+       /* Texcoords come first */
+       for (i = 0; i < s->Ctx->Const.MaxTextureUnits; i++) {
+               if (InputsRead & (FRAG_BIT_TEX0 << i))
+                       alloc_hw_reg(s, PROGRAM_INPUT, FRAG_ATTRIB_TEX0+i, hwindex++);
+       }
+       InputsRead &= ~FRAG_BITS_TEX_ANY;
+
+       /* fragment position treated as a texcoord */
+       if (InputsRead & FRAG_BIT_WPOS)
+               alloc_hw_reg(s, PROGRAM_INPUT, FRAG_ATTRIB_WPOS, hwindex++);
+       InputsRead &= ~FRAG_BIT_WPOS;
+
+       /* Then primary colour */
+       if (InputsRead & FRAG_BIT_COL0)
+               alloc_hw_reg(s, PROGRAM_INPUT, FRAG_ATTRIB_COL0, hwindex++);
+       InputsRead &= ~FRAG_BIT_COL0;
+
+       /* Secondary color */
+       if (InputsRead & FRAG_BIT_COL1)
+               alloc_hw_reg(s, PROGRAM_INPUT, FRAG_ATTRIB_COL1, hwindex++);
+       InputsRead &= ~FRAG_BIT_COL1;
+
+       /* Anything else */
+       if (InputsRead)
+               error("Don't know how to handle inputs 0x%x\n", InputsRead);
+}
+
+
+static void decrement_dependencies(struct pair_state *s, int ip)
+{
+       struct pair_state_instruction *pairinst = s->Instructions + ip;
+       ASSERT(pairinst->NumDependencies > 0);
+       if (!--pairinst->NumDependencies)
+               instruction_ready(s, ip);
+}
+
+/**
+ * Update the dependency tracking state based on what the instruction
+ * at the given IP does.
+ */
+static void commit_instruction(struct pair_state *s, int ip)
+{
+       struct prog_instruction *inst = s->Program->Instructions + ip;
+       struct pair_state_instruction *pairinst = s->Instructions + ip;
+
+       if (s->Verbose)
+               _mesa_printf("commit_instruction(%i)\n", ip);
+
+       if (inst->DstReg.File == PROGRAM_TEMPORARY) {
+               struct pair_register_translation *t = &s->Temps[inst->DstReg.Index];
+               deref_hw_reg(s, t->HwIndex);
+
+               int i;
+               for(i = 0; i < 4; ++i) {
+                       if (!GET_BIT(inst->DstReg.WriteMask, i))
+                               continue;
+
+                       t->Value[i] = pairinst->Values[i];
+                       if (t->Value[i]->NumReaders) {
+                               struct reg_value_reader *r;
+                               for(r = pairinst->Values[i]->Readers; r; r = r->Next)
+                                       decrement_dependencies(s, r->IP);
+                       } else if (t->Value[i]->Next) {
+                               /* This happens when the only reader writes
+                                * the register at the same time */
+                               decrement_dependencies(s, t->Value[i]->Next->IP);
+                       }
+               }
+       }
+
+       int nsrc = _mesa_num_inst_src_regs(inst->Opcode);
+       int i;
+       for(i = 0; i < nsrc; i++) {
+               struct pair_register_translation *t = get_register(s, inst->SrcReg[i].File, inst->SrcReg[i].Index);
+               if (!t)
+                       continue;
+
+               deref_hw_reg(s, get_hw_reg(s, inst->SrcReg[i].File, inst->SrcReg[i].Index));
+
+               if (inst->SrcReg[i].File != PROGRAM_TEMPORARY)
+                       continue;
+
+               int j;
+               for(j = 0; j < 4; ++j) {
+                       GLuint swz = GET_SWZ(inst->SrcReg[i].Swizzle, j);
+                       if (swz >= 4)
+                               continue;
+                       if (!t->Value[swz])
+                               continue;
+
+                       /* Do not free a dependency if this instruction
+                        * also rewrites the value. See scan_instructions. */
+                       if (inst->DstReg.File == PROGRAM_TEMPORARY &&
+                           inst->DstReg.Index == inst->SrcReg[i].Index &&
+                           GET_BIT(inst->DstReg.WriteMask, swz))
+                               continue;
+
+                       if (!--t->Value[swz]->NumReaders) {
+                               if (t->Value[swz]->Next)
+                                       decrement_dependencies(s, t->Value[swz]->Next->IP);
+                       }
+               }
+       }
+}
+
+
+/**
+ * Emit all ready texture instructions in a single block.
+ *
+ * Emit as a single block to (hopefully) sample many textures in parallel,
+ * and to avoid hardware indirections on R300.
+ *
+ * In R500, we don't really know when the result of a texture instruction
+ * arrives. So allocate all destinations first, to make sure they do not
+ * arrive early and overwrite a texture coordinate we're going to use later
+ * in the block.
+ */
+static void emit_all_tex(struct pair_state *s)
+{
+       struct pair_state_instruction *readytex;
+       struct pair_state_instruction *pairinst;
+
+       ASSERT(s->ReadyTEX);
+
+       // Don't let the ready list change under us!
+       readytex = s->ReadyTEX;
+       s->ReadyTEX = 0;
+
+       // Allocate destination hardware registers in one block to avoid conflicts.
+       for(pairinst = readytex; pairinst; pairinst = pairinst->NextReady) {
+               int ip = pairinst - s->Instructions;
+               struct prog_instruction *inst = s->Program->Instructions + ip;
+               if (inst->Opcode != OPCODE_KIL)
+                       get_hw_reg(s, inst->DstReg.File, inst->DstReg.Index);
+       }
+
+       if (s->Debug)
+               _mesa_printf(" BEGIN_TEX\n");
+
+       if (s->Handler->BeginTexBlock)
+               s->Error = s->Error || !s->Handler->BeginTexBlock(s->UserData);
+
+       for(pairinst = readytex; pairinst; pairinst = pairinst->NextReady) {
+               int ip = pairinst - s->Instructions;
+               struct prog_instruction *inst = s->Program->Instructions + ip;
+               commit_instruction(s, ip);
+
+               if (inst->Opcode != OPCODE_KIL)
+                       inst->DstReg.Index = get_hw_reg(s, inst->DstReg.File, inst->DstReg.Index);
+               inst->SrcReg[0].Index = get_hw_reg(s, inst->SrcReg[0].File, inst->SrcReg[0].Index);
+
+               if (s->Debug) {
+                       _mesa_printf("   ");
+                       _mesa_print_instruction(inst);
+               }
+               s->Error = s->Error || !s->Handler->EmitTex(s->UserData, inst);
+       }
+
+       if (s->Debug)
+               _mesa_printf(" END_TEX\n");
+}
+
+
+static int alloc_pair_source(struct pair_state *s, struct radeon_pair_instruction *pair,
+       struct prog_src_register src, GLboolean rgb, GLboolean alpha)
+{
+       int candidate = -1;
+       int candidate_quality = -1;
+       int i;
+
+       if (!rgb && !alpha)
+               return 0;
+
+       GLuint constant;
+       GLuint index;
+
+       if (src.File == PROGRAM_TEMPORARY || src.File == PROGRAM_INPUT) {
+               constant = 0;
+               index = get_hw_reg(s, src.File, src.Index);
+       } else {
+               constant = 1;
+               s->Error |= !s->Handler->EmitConst(s->UserData, src.File, src.Index, &index);
+       }
+
+       for(i = 0; i < 3; ++i) {
+               int q = 0;
+               if (rgb) {
+                       if (pair->RGB.Src[i].Used) {
+                               if (pair->RGB.Src[i].Constant != constant ||
+                                   pair->RGB.Src[i].Index != index)
+                                       continue;
+                               q++;
+                       }
+               }
+               if (alpha) {
+                       if (pair->Alpha.Src[i].Used) {
+                               if (pair->Alpha.Src[i].Constant != constant ||
+                                   pair->Alpha.Src[i].Index != index)
+                                       continue;
+                               q++;
+                       }
+               }
+               if (q > candidate_quality) {
+                       candidate_quality = q;
+                       candidate = i;
+               }
+       }
+
+       if (candidate >= 0) {
+               if (rgb) {
+                       pair->RGB.Src[candidate].Used = 1;
+                       pair->RGB.Src[candidate].Constant = constant;
+                       pair->RGB.Src[candidate].Index = index;
+               }
+               if (alpha) {
+                       pair->Alpha.Src[candidate].Used = 1;
+                       pair->Alpha.Src[candidate].Constant = constant;
+                       pair->Alpha.Src[candidate].Index = index;
+               }
+       }
+
+       return candidate;
+}
+
+/**
+ * Fill the given ALU instruction's opcodes and source operands into the given pair,
+ * if possible.
+ */
+static GLboolean fill_instruction_into_pair(struct pair_state *s, struct radeon_pair_instruction *pair, int ip)
+{
+       struct pair_state_instruction *pairinst = s->Instructions + ip;
+       struct prog_instruction *inst = s->Program->Instructions + ip;
+
+       ASSERT(!pairinst->NeedRGB || pair->RGB.Opcode == OPCODE_NOP);
+       ASSERT(!pairinst->NeedAlpha || pair->Alpha.Opcode == OPCODE_NOP);
+
+       if (pairinst->NeedRGB) {
+               if (pairinst->IsTranscendent)
+                       pair->RGB.Opcode = OPCODE_REPL_ALPHA;
+               else
+                       pair->RGB.Opcode = inst->Opcode;
+               if (inst->SaturateMode == SATURATE_ZERO_ONE)
+                       pair->RGB.Saturate = 1;
+       }
+       if (pairinst->NeedAlpha) {
+               pair->Alpha.Opcode = inst->Opcode;
+               if (inst->SaturateMode == SATURATE_ZERO_ONE)
+                       pair->Alpha.Saturate = 1;
+       }
+
+       int nargs = _mesa_num_inst_src_regs(inst->Opcode);
+       int i;
+
+       /* Special case for DDX/DDY (MDH/MDV). */
+       if (inst->Opcode == OPCODE_DDX || inst->Opcode == OPCODE_DDY) {
+               if (pair->RGB.Src[0].Used || pair->Alpha.Src[0].Used)
+                       return GL_FALSE;
+               else
+                       nargs++;
+       }
+
+       for(i = 0; i < nargs; ++i) {
+               int source;
+               if (pairinst->NeedRGB && !pairinst->IsTranscendent) {
+                       GLboolean srcrgb = GL_FALSE;
+                       GLboolean srcalpha = GL_FALSE;
+                       GLuint negatebase = 0;
+                       int j;
+                       for(j = 0; j < 3; ++j) {
+                               GLuint swz = GET_SWZ(inst->SrcReg[i].Swizzle, j);
+                               if (swz < 3)
+                                       srcrgb = GL_TRUE;
+                               else if (swz < 4)
+                                       srcalpha = GL_TRUE;
+                               if (swz != SWIZZLE_NIL && GET_BIT(inst->SrcReg[i].NegateBase, j))
+                                       negatebase = 1;
+                       }
+                       source = alloc_pair_source(s, pair, inst->SrcReg[i], srcrgb, srcalpha);
+                       if (source < 0)
+                               return GL_FALSE;
+                       pair->RGB.Arg[i].Source = source;
+                       pair->RGB.Arg[i].Swizzle = inst->SrcReg[i].Swizzle & 0x1ff;
+                       pair->RGB.Arg[i].Abs = inst->SrcReg[i].Abs;
+                       pair->RGB.Arg[i].Negate = (negatebase & ~pair->RGB.Arg[i].Abs) ^ inst->SrcReg[i].NegateAbs;
+               }
+               if (pairinst->NeedAlpha) {
+                       GLboolean srcrgb = GL_FALSE;
+                       GLboolean srcalpha = GL_FALSE;
+                       GLuint negatebase = GET_BIT(inst->SrcReg[i].NegateBase, pairinst->IsTranscendent ? 0 : 3);
+                       GLuint swz = GET_SWZ(inst->SrcReg[i].Swizzle, pairinst->IsTranscendent ? 0 : 3);
+                       if (swz < 3)
+                               srcrgb = GL_TRUE;
+                       else if (swz < 4)
+                               srcalpha = GL_TRUE;
+                       source = alloc_pair_source(s, pair, inst->SrcReg[i], srcrgb, srcalpha);
+                       if (source < 0)
+                               return GL_FALSE;
+                       pair->Alpha.Arg[i].Source = source;
+                       pair->Alpha.Arg[i].Swizzle = swz;
+                       pair->Alpha.Arg[i].Abs = inst->SrcReg[i].Abs;
+                       pair->Alpha.Arg[i].Negate = (negatebase & ~pair->RGB.Arg[i].Abs) ^ inst->SrcReg[i].NegateAbs;
+               }
+       }
+
+       return GL_TRUE;
+}
+
+
+/**
+ * Fill in the destination register information.
+ *
+ * This is split from filling in source registers because we want
+ * to avoid allocating hardware temporaries for destinations until
+ * we are absolutely certain that we're going to emit a certain
+ * instruction pairing.
+ */
+static void fill_dest_into_pair(struct pair_state *s, struct radeon_pair_instruction *pair, int ip)
+{
+       struct pair_state_instruction *pairinst = s->Instructions + ip;
+       struct prog_instruction *inst = s->Program->Instructions + ip;
+
+       if (inst->DstReg.File == PROGRAM_OUTPUT) {
+               if (inst->DstReg.Index == FRAG_RESULT_COLR) {
+                       pair->RGB.OutputWriteMask |= inst->DstReg.WriteMask & WRITEMASK_XYZ;
+                       pair->Alpha.OutputWriteMask |= GET_BIT(inst->DstReg.WriteMask, 3);
+               } else if (inst->DstReg.Index == FRAG_RESULT_DEPR) {
+                       pair->Alpha.DepthWriteMask |= GET_BIT(inst->DstReg.WriteMask, 3);
+               }
+       } else {
+               GLuint hwindex = get_hw_reg(s, inst->DstReg.File, inst->DstReg.Index);
+               if (pairinst->NeedRGB) {
+                       pair->RGB.DestIndex = hwindex;
+                       pair->RGB.WriteMask |= inst->DstReg.WriteMask & WRITEMASK_XYZ;
+               }
+               if (pairinst->NeedAlpha) {
+                       pair->Alpha.DestIndex = hwindex;
+                       pair->Alpha.WriteMask |= GET_BIT(inst->DstReg.WriteMask, 3);
+               }
+       }
+}
+
+
+/**
+ * Find a good ALU instruction or pair of ALU instruction and emit it.
+ *
+ * Prefer emitting full ALU instructions, so that when we reach a point
+ * where no full ALU instruction can be emitted, we have more candidates
+ * for RGB/Alpha pairing.
+ */
+static void emit_alu(struct pair_state *s)
+{
+       struct radeon_pair_instruction pair;
+
+       if (s->ReadyFullALU || !(s->ReadyRGB && s->ReadyAlpha)) {
+               int ip;
+               if (s->ReadyFullALU) {
+                       ip = s->ReadyFullALU - s->Instructions;
+                       s->ReadyFullALU = s->ReadyFullALU->NextReady;
+               } else if (s->ReadyRGB) {
+                       ip = s->ReadyRGB - s->Instructions;
+                       s->ReadyRGB = s->ReadyRGB->NextReady;
+               } else {
+                       ip = s->ReadyAlpha - s->Instructions;
+                       s->ReadyAlpha = s->ReadyAlpha->NextReady;
+               }
+
+               _mesa_bzero(&pair, sizeof(pair));
+               fill_instruction_into_pair(s, &pair, ip);
+               fill_dest_into_pair(s, &pair, ip);
+               commit_instruction(s, ip);
+       } else {
+               struct pair_state_instruction **prgb;
+               struct pair_state_instruction **palpha;
+
+               /* Some pairings might fail because they require too
+                * many source slots; try all possible pairings if necessary */
+               for(prgb = &s->ReadyRGB; *prgb; prgb = &(*prgb)->NextReady) {
+                       for(palpha = &s->ReadyAlpha; *palpha; palpha = &(*palpha)->NextReady) {
+                               int rgbip = *prgb - s->Instructions;
+                               int alphaip = *palpha - s->Instructions;
+                               _mesa_bzero(&pair, sizeof(pair));
+                               fill_instruction_into_pair(s, &pair, rgbip);
+                               if (!fill_instruction_into_pair(s, &pair, alphaip))
+                                       continue;
+                               *prgb = (*prgb)->NextReady;
+                               *palpha = (*palpha)->NextReady;
+                               fill_dest_into_pair(s, &pair, rgbip);
+                               fill_dest_into_pair(s, &pair, alphaip);
+                               commit_instruction(s, rgbip);
+                               commit_instruction(s, alphaip);
+                               goto success;
+                       }
+               }
+
+               /* No success in pairing; just take the first RGB instruction */
+               int ip = s->ReadyRGB - s->Instructions;
+               s->ReadyRGB = s->ReadyRGB->NextReady;
+               _mesa_bzero(&pair, sizeof(pair));
+               fill_instruction_into_pair(s, &pair, ip);
+               fill_dest_into_pair(s, &pair, ip);
+               commit_instruction(s, ip);
+       success: ;
+       }
+
+       if (s->Debug)
+               radeonPrintPairInstruction(&pair);
+
+       s->Error = s->Error || !s->Handler->EmitPaired(s->UserData, &pair);
+}
+
+
+GLboolean radeonPairProgram(GLcontext *ctx, struct gl_program *program,
+       const struct radeon_pair_handler* handler, void *userdata)
+{
+       struct pair_state s;
+
+       _mesa_bzero(&s, sizeof(s));
+       s.Ctx = ctx;
+       s.Program = program;
+       s.Handler = handler;
+       s.UserData = userdata;
+       s.Debug = (RADEON_DEBUG & DEBUG_PIXEL) ? GL_TRUE : GL_FALSE;
+       s.Verbose = GL_FALSE && s.Debug;
+
+       s.Instructions = (struct pair_state_instruction*)_mesa_calloc(
+               sizeof(struct pair_state_instruction)*s.Program->NumInstructions);
+       s.ValuePool = (struct reg_value*)_mesa_calloc(sizeof(struct reg_value)*s.Program->NumInstructions*4);
+       s.ReaderPool = (struct reg_value_reader*)_mesa_calloc(
+               sizeof(struct reg_value_reader)*s.Program->NumInstructions*12);
+
+       if (s.Debug)
+               _mesa_printf("Emit paired program\n");
+
+       scan_instructions(&s);
+       allocate_input_registers(&s);
+
+       while(!s.Error &&
+             (s.ReadyTEX || s.ReadyRGB || s.ReadyAlpha || s.ReadyFullALU)) {
+               if (s.ReadyTEX)
+                       emit_all_tex(&s);
+
+               while(s.ReadyFullALU || s.ReadyRGB || s.ReadyAlpha)
+                       emit_alu(&s);
+       }
+
+       if (s.Debug)
+               _mesa_printf(" END\n");
+
+       _mesa_free(s.Instructions);
+       _mesa_free(s.ValuePool);
+       _mesa_free(s.ReaderPool);
+
+       return !s.Error;
+}
+
+
+static void print_pair_src(int i, struct radeon_pair_instruction_source* src)
+{
+       _mesa_printf("  Src%i = %s[%i]", i, src->Constant ? "CNST" : "TEMP", src->Index);
+}
+
+static const char* opcode_string(GLuint opcode)
+{
+       if (opcode == OPCODE_REPL_ALPHA)
+               return "SOP";
+       else
+               return _mesa_opcode_string(opcode);
+}
+
+static int num_pairinst_args(GLuint opcode)
+{
+       if (opcode == OPCODE_REPL_ALPHA)
+               return 0;
+       else
+               return _mesa_num_inst_src_regs(opcode);
+}
+
+static char swizzle_char(GLuint swz)
+{
+       switch(swz) {
+       case SWIZZLE_X: return 'x';
+       case SWIZZLE_Y: return 'y';
+       case SWIZZLE_Z: return 'z';
+       case SWIZZLE_W: return 'w';
+       case SWIZZLE_ZERO: return '0';
+       case SWIZZLE_ONE: return '1';
+       case SWIZZLE_NIL: return '_';
+       default: return '?';
+       }
+}
+
+void radeonPrintPairInstruction(struct radeon_pair_instruction *inst)
+{
+       int nargs;
+       int i;
+
+       _mesa_printf("       RGB:  ");
+       for(i = 0; i < 3; ++i) {
+               if (inst->RGB.Src[i].Used)
+                       print_pair_src(i, inst->RGB.Src + i);
+       }
+       _mesa_printf("\n");
+       _mesa_printf("       Alpha:");
+       for(i = 0; i < 3; ++i) {
+               if (inst->Alpha.Src[i].Used)
+                       print_pair_src(i, inst->Alpha.Src + i);
+       }
+       _mesa_printf("\n");
+
+       _mesa_printf("  %s%s", opcode_string(inst->RGB.Opcode), inst->RGB.Saturate ? "_SAT" : "");
+       if (inst->RGB.WriteMask)
+               _mesa_printf(" TEMP[%i].%s%s%s", inst->RGB.DestIndex,
+                       (inst->RGB.WriteMask & 1) ? "x" : "",
+                       (inst->RGB.WriteMask & 2) ? "y" : "",
+                       (inst->RGB.WriteMask & 4) ? "z" : "");
+       if (inst->RGB.OutputWriteMask)
+               _mesa_printf(" COLOR.%s%s%s",
+                       (inst->RGB.OutputWriteMask & 1) ? "x" : "",
+                       (inst->RGB.OutputWriteMask & 2) ? "y" : "",
+                       (inst->RGB.OutputWriteMask & 4) ? "z" : "");
+       nargs = num_pairinst_args(inst->RGB.Opcode);
+       for(i = 0; i < nargs; ++i) {
+               const char* abs = inst->RGB.Arg[i].Abs ? "|" : "";
+               const char* neg = inst->RGB.Arg[i].Negate ? "-" : "";
+               _mesa_printf(", %s%sSrc%i.%c%c%c%s", neg, abs, inst->RGB.Arg[i].Source,
+                       swizzle_char(GET_SWZ(inst->RGB.Arg[i].Swizzle, 0)),
+                       swizzle_char(GET_SWZ(inst->RGB.Arg[i].Swizzle, 1)),
+                       swizzle_char(GET_SWZ(inst->RGB.Arg[i].Swizzle, 2)),
+                       abs);
+       }
+       _mesa_printf("\n");
+
+       _mesa_printf("  %s%s", opcode_string(inst->Alpha.Opcode), inst->Alpha.Saturate ? "_SAT" : "");
+       if (inst->Alpha.WriteMask)
+               _mesa_printf(" TEMP[%i].w", inst->Alpha.DestIndex);
+       if (inst->Alpha.OutputWriteMask)
+               _mesa_printf(" COLOR.w");
+       if (inst->Alpha.DepthWriteMask)
+               _mesa_printf(" DEPTH.w");
+       nargs = num_pairinst_args(inst->Alpha.Opcode);
+       for(i = 0; i < nargs; ++i) {
+               const char* abs = inst->Alpha.Arg[i].Abs ? "|" : "";
+               const char* neg = inst->Alpha.Arg[i].Negate ? "-" : "";
+               _mesa_printf(", %s%sSrc%i.%c%s", neg, abs, inst->Alpha.Arg[i].Source,
+                       swizzle_char(inst->Alpha.Arg[i].Swizzle), abs);
+       }
+       _mesa_printf("\n");
+}
diff --git a/src/mesa/drivers/dri/r300/radeon_program_pair.h b/src/mesa/drivers/dri/r300/radeon_program_pair.h
new file mode 100644 (file)
index 0000000..4624a24
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2008 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.
+ *
+ */
+
+#ifndef __RADEON_PROGRAM_PAIR_H_
+#define __RADEON_PROGRAM_PAIR_H_
+
+#include "radeon_program.h"
+
+
+/**
+ * Represents a paired instruction, as found in R300 and R500
+ * fragment programs.
+ */
+struct radeon_pair_instruction_source {
+       GLuint Index:8;
+       GLuint Constant:1;
+       GLuint Used:1;
+};
+
+struct radeon_pair_instruction_rgb {
+       GLuint Opcode:8;
+       GLuint DestIndex:8;
+       GLuint WriteMask:3;
+       GLuint OutputWriteMask:3;
+       GLuint Saturate:1;
+
+       struct radeon_pair_instruction_source Src[3];
+
+       struct {
+               GLuint Source:2;
+               GLuint Swizzle:9;
+               GLuint Abs:1;
+               GLuint Negate:1;
+       } Arg[3];
+};
+
+struct radeon_pair_instruction_alpha {
+       GLuint Opcode:8;
+       GLuint DestIndex:8;
+       GLuint WriteMask:1;
+       GLuint OutputWriteMask:1;
+       GLuint DepthWriteMask:1;
+       GLuint Saturate:1;
+
+       struct radeon_pair_instruction_source Src[3];
+
+       struct {
+               GLuint Source:2;
+               GLuint Swizzle:3;
+               GLuint Abs:1;
+               GLuint Negate:1;
+       } Arg[3];
+};
+
+struct radeon_pair_instruction {
+       struct radeon_pair_instruction_rgb RGB;
+       struct radeon_pair_instruction_alpha Alpha;
+};
+
+
+/**
+ *
+ */
+struct radeon_pair_handler {
+       /**
+        * Fill in the proper hardware index for the given constant register.
+        *
+        * @return GL_FALSE on error.
+        */
+       GLboolean (*EmitConst)(void*, GLuint file, GLuint index, GLuint *hwindex);
+
+       /**
+        * Write a paired instruction to the hardware.
+        *
+        * @return GL_FALSE on error.
+        */
+       GLboolean (*EmitPaired)(void*, struct radeon_pair_instruction*);
+
+       /**
+        * Write a texture instruction to the hardware.
+        * Register indices have already been rewritten to the allocated
+        * hardware register numbers.
+        *
+        * @return GL_FALSE on error.
+        */
+       GLboolean (*EmitTex)(void*, struct prog_instruction*);
+
+       /**
+        * Called before a block of contiguous, independent texture
+        * instructions is emitted.
+        */
+       GLboolean (*BeginTexBlock)(void*);
+
+       GLuint MaxHwTemps;
+};
+
+GLboolean radeonPairProgram(GLcontext *ctx, struct gl_program *program,
+       const struct radeon_pair_handler*, void *userdata);
+
+void radeonPrintPairInstruction(struct radeon_pair_instruction *inst);
+
+#endif /* __RADEON_PROGRAM_PAIR_H_ */
index eae09d6b35eb95dd4939e97e26f7bc1c54eab820..3616d8b14de3e08b6c27a43bec51dda6f385fad5 100644 (file)
@@ -172,6 +172,8 @@ radeon_mba_z16(const driRenderbuffer * drb, GLint x, GLint y)
 
 /* 16-bit depth buffer functions
  */
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d )                                       \
    *(GLushort *)(buf + radeon_mba_z16( drb, _x + xo, _y + yo )) = d;
 
@@ -186,6 +188,8 @@ radeon_mba_z16(const driRenderbuffer * drb, GLint x, GLint y)
  * Careful: It looks like the R300 uses ZZZS byte order while the R200
  * uses SZZZ for 24 bit depth, 8 bit stencil mode.
  */
+#define VALUE_TYPE GLuint
+
 #ifdef COMPILE_R300
 #define WRITE_DEPTH( _x, _y, d )                                       \
 do {                                                                   \
@@ -282,6 +286,30 @@ static void radeonSpanRenderStart(GLcontext * ctx)
 #endif
        LOCK_HARDWARE(rmesa);
        radeonWaitForIdleLocked(rmesa);
+
+       /* Read 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.
+        *
+        * Note that we should probably be reading some otherwise unused
+        * region of VRAM, otherwise we might get incorrect results when
+        * reading pixels from the top left of the screen.
+        *
+        * I found this problem on an R420 with glean's texCube test.
+        * Note that the R200 span code also *writes* the first pixel in the
+        * framebuffer, but I've found this to be unnecessary.
+        *  -- Nicolai Hähnle, June 2008
+        */
+       {
+               int p;
+               driRenderbuffer *drb =
+                       (driRenderbuffer *) ctx->WinSysDrawBuffer->_ColorDrawBuffers[0];
+               volatile int *buf =
+                       (volatile int *)(rmesa->dri.screen->pFB + drb->offset);
+               p = *buf;
+       }
 }
 
 static void radeonSpanRenderFinish(GLcontext * ctx)
index 82bfd951b9245317d67f4a55bc0b4acbc40d82b2..d81318ce20c81d7a31ebc540ff28b0f72e07405b 100644 (file)
@@ -125,8 +125,8 @@ void radeonUpdateScissor(GLcontext* ctx)
 
                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;
+               radeon->state.scissor.rect.x2 = x1 + ctx->Scissor.Width;
+               radeon->state.scissor.rect.y2 = y1 + ctx->Scissor.Height;
 
                radeonRecalcScissorRects(radeon);
        }
@@ -152,7 +152,7 @@ void radeonSetCliprects(radeonContextPtr radeon)
        GLframebuffer *const draw_fb = (GLframebuffer*)drawable->driverPrivate;
        GLframebuffer *const read_fb = (GLframebuffer*)readable->driverPrivate;
 
-       if (draw_fb->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT) {
+       if (draw_fb->_ColorDrawBufferIndexes[0] == BUFFER_BACK_LEFT) {
                /* Can't ignore 2d windows if we are page flipping. */
                if (drawable->numBackClipRects == 0 || radeon->doPageFlip ||
                    radeon->sarea->pfCurrentPage == 1) {
index 7318099093a9f524f50300344d0d557eb69f62e9..55a73eab209994081d08b5f66d171a6f4b17c907 100644 (file)
 #define PCI_CHIP_RV410_564F            0x564F
 #define PCI_CHIP_RV410_5652            0x5652
 #define PCI_CHIP_RV410_5653            0x5653
+#define PCI_CHIP_RV410_5657            0x5657
 #define PCI_CHIP_RS300_5834            0x5834
 #define PCI_CHIP_RS300_5835            0x5835
 #define PCI_CHIP_RS480_5954            0x5954
 #define PCI_CHIP_RV410_5E4C            0x5E4C
 #define PCI_CHIP_RV410_5E4D            0x5E4D
 #define PCI_CHIP_RV410_5E4F            0x5E4F
+
+#define PCI_CHIP_R520_7100              0x7100
+#define PCI_CHIP_R520_7101              0x7101
+#define PCI_CHIP_R520_7102              0x7102
+#define PCI_CHIP_R520_7103              0x7103
+#define PCI_CHIP_R520_7104              0x7104
+#define PCI_CHIP_R520_7105              0x7105
+#define PCI_CHIP_R520_7106              0x7106
+#define PCI_CHIP_R520_7108              0x7108
+#define PCI_CHIP_R520_7109              0x7109
+#define PCI_CHIP_R520_710A              0x710A
+#define PCI_CHIP_R520_710B              0x710B
+#define PCI_CHIP_R520_710C              0x710C
+#define PCI_CHIP_R520_710E              0x710E
+#define PCI_CHIP_R520_710F              0x710F
+#define PCI_CHIP_RV515_7140             0x7140
+#define PCI_CHIP_RV515_7141             0x7141
+#define PCI_CHIP_RV515_7142             0x7142
+#define PCI_CHIP_RV515_7143             0x7143
+#define PCI_CHIP_RV515_7144             0x7144
+#define PCI_CHIP_RV515_7145             0x7145
+#define PCI_CHIP_RV515_7146             0x7146
+#define PCI_CHIP_RV515_7147             0x7147
+#define PCI_CHIP_RV515_7149             0x7149
+#define PCI_CHIP_RV515_714A             0x714A
+#define PCI_CHIP_RV515_714B             0x714B
+#define PCI_CHIP_RV515_714C             0x714C
+#define PCI_CHIP_RV515_714D             0x714D
+#define PCI_CHIP_RV515_714E             0x714E
+#define PCI_CHIP_RV515_714F             0x714F
+#define PCI_CHIP_RV515_7151             0x7151
+#define PCI_CHIP_RV515_7152             0x7152
+#define PCI_CHIP_RV515_7153             0x7153
+#define PCI_CHIP_RV515_715E             0x715E
+#define PCI_CHIP_RV515_715F             0x715F
+#define PCI_CHIP_RV515_7180             0x7180
+#define PCI_CHIP_RV515_7181             0x7181
+#define PCI_CHIP_RV515_7183             0x7183
+#define PCI_CHIP_RV515_7186             0x7186
+#define PCI_CHIP_RV515_7187             0x7187
+#define PCI_CHIP_RV515_7188             0x7188
+#define PCI_CHIP_RV515_718A             0x718A
+#define PCI_CHIP_RV515_718B             0x718B
+#define PCI_CHIP_RV515_718C             0x718C
+#define PCI_CHIP_RV515_718D             0x718D
+#define PCI_CHIP_RV515_718F             0x718F
+#define PCI_CHIP_RV515_7193             0x7193
+#define PCI_CHIP_RV515_7196             0x7196
+#define PCI_CHIP_RV515_719B             0x719B
+#define PCI_CHIP_RV515_719F             0x719F
+#define PCI_CHIP_RV530_71C0             0x71C0
+#define PCI_CHIP_RV530_71C1             0x71C1
+#define PCI_CHIP_RV530_71C2             0x71C2
+#define PCI_CHIP_RV530_71C3             0x71C3
+#define PCI_CHIP_RV530_71C4             0x71C4
+#define PCI_CHIP_RV530_71C5             0x71C5
+#define PCI_CHIP_RV530_71C6             0x71C6
+#define PCI_CHIP_RV530_71C7             0x71C7
+#define PCI_CHIP_RV530_71CD             0x71CD
+#define PCI_CHIP_RV530_71CE             0x71CE
+#define PCI_CHIP_RV530_71D2             0x71D2
+#define PCI_CHIP_RV530_71D4             0x71D4
+#define PCI_CHIP_RV530_71D5             0x71D5
+#define PCI_CHIP_RV530_71D6             0x71D6
+#define PCI_CHIP_RV530_71DA             0x71DA
+#define PCI_CHIP_RV530_71DE             0x71DE
+#define PCI_CHIP_RV515_7200             0x7200
+#define PCI_CHIP_RV515_7210             0x7210
+#define PCI_CHIP_RV515_7211             0x7211
+#define PCI_CHIP_R580_7240              0x7240
+#define PCI_CHIP_R580_7243              0x7243
+#define PCI_CHIP_R580_7244              0x7244
+#define PCI_CHIP_R580_7245              0x7245
+#define PCI_CHIP_R580_7246              0x7246
+#define PCI_CHIP_R580_7247              0x7247
+#define PCI_CHIP_R580_7248              0x7248
+#define PCI_CHIP_R580_7249              0x7249
+#define PCI_CHIP_R580_724A              0x724A
+#define PCI_CHIP_R580_724B              0x724B
+#define PCI_CHIP_R580_724C              0x724C
+#define PCI_CHIP_R580_724D              0x724D
+#define PCI_CHIP_R580_724E              0x724E
+#define PCI_CHIP_R580_724F              0x724F
+#define PCI_CHIP_RV570_7280             0x7280
+#define PCI_CHIP_RV560_7281             0x7281
+#define PCI_CHIP_RV560_7283             0x7283
+#define PCI_CHIP_R580_7284              0x7284
+#define PCI_CHIP_RV560_7287             0x7287
+#define PCI_CHIP_RV570_7288             0x7288
+#define PCI_CHIP_RV570_7289             0x7289
+#define PCI_CHIP_RV570_728B             0x728B
+#define PCI_CHIP_RV570_728C             0x728C
+#define PCI_CHIP_RV560_7290             0x7290
+#define PCI_CHIP_RV560_7291             0x7291
+#define PCI_CHIP_RV560_7293             0x7293
+#define PCI_CHIP_RV560_7297             0x7297
+
 #define PCI_CHIP_RS350_7834            0x7834
 #define PCI_CHIP_RS350_7835            0x7835
+#define PCI_CHIP_RS690_791E             0x791E
+#define PCI_CHIP_RS690_791F             0x791F
+#define PCI_CHIP_RS740_796C             0x796C
+#define PCI_CHIP_RS740_796D             0x796D
+#define PCI_CHIP_RS740_796E             0x796E
+#define PCI_CHIP_RS740_796F             0x796F
+
 
 enum {
    CHIP_FAMILY_R100,
@@ -165,6 +270,14 @@ enum {
    CHIP_FAMILY_R420,
    CHIP_FAMILY_RV410,
    CHIP_FAMILY_RS400,
+   CHIP_FAMILY_RS690,
+   CHIP_FAMILY_RS740,
+   CHIP_FAMILY_RV515,
+   CHIP_FAMILY_R520,
+   CHIP_FAMILY_RV530,
+   CHIP_FAMILY_R580,
+   CHIP_FAMILY_RV560,
+   CHIP_FAMILY_RV570,
    CHIP_FAMILY_LAST
 };
 
index ba93a054ae2cfc9dbcb66672103e047eec67f61f..1e992c0b3d62aff5d126e0fc32f3ac7ece819ad0 100644 (file)
@@ -34,14 +34,15 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *   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 "main/glheader.h"
+#include "main/api_arrayelt.h"
+#include "main/context.h"
+#include "main/simple_list.h"
+#include "main/imports.h"
+#include "main/matrix.h"
+#include "main/extensions.h"
+#include "main/framebuffer.h"
+#include "main/state.h"
 
 #include "swrast/swrast.h"
 #include "swrast_setup/swrast_setup.h"
@@ -231,14 +232,14 @@ radeonCreateContext( const __GLcontextModes *glVisual,
                                                  "def_max_anisotropy");
 
    if ( driQueryOptionb( &rmesa->optionCache, "hyperz" ) ) {
-      if ( sPriv->drmMinor < 13 )
+      if ( sPriv->drm_version.minor < 13 )
         fprintf( stderr, "DRM version 1.%d too old to support HyperZ, "
-                         "disabling.\n",sPriv->drmMinor );
+                         "disabling.\n", sPriv->drm_version.minor );
       else
         rmesa->using_hyperz = GL_TRUE;
    }
 
-   if ( sPriv->drmMinor >= 15 )
+   if ( sPriv->drm_version.minor >= 15 )
       rmesa->texmicrotile = GL_TRUE;
 
    /* Init default driver functions then plug in our Radeon-specific functions
@@ -269,7 +270,7 @@ radeonCreateContext( const __GLcontextModes *glVisual,
    rmesa->dri.hwContext = driContextPriv->hHWContext;
    rmesa->dri.hwLock = &sPriv->pSAREA->lock;
    rmesa->dri.fd = sPriv->fd;
-   rmesa->dri.drmMinor = sPriv->drmMinor;
+   rmesa->dri.drmMinor = sPriv->drm_version.minor;
 
    rmesa->radeonScreen = screen;
    rmesa->sarea = (drm_radeon_sarea_t *)((GLubyte *)sPriv->pSAREA +
@@ -422,10 +423,7 @@ radeonCreateContext( const __GLcontextModes *glVisual,
 
    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 );
+   (*sPriv->systemTime->getUST)( & rmesa->swap_ust );
 
 
 #if DO_DEBUG
@@ -590,16 +588,18 @@ radeonMakeCurrent( __DRIcontextPrivate *driContextPriv,
       if (RADEON_DEBUG & DEBUG_DRI)
         fprintf(stderr, "%s ctx %p\n", __FUNCTION__, (void *) newCtx->glCtx);
 
-      if ( newCtx->dri.drawable != driDrawPriv ) {
-         /* XXX we may need to validate the drawable here!!! */
-        driDrawableInitVBlank( driDrawPriv, newCtx->vblank_flags,
-                               &newCtx->vbl_seq );
-      }
-
       newCtx->dri.readable = driReadPriv;
 
       if ( (newCtx->dri.drawable != driDrawPriv) ||
            newCtx->lastStamp != driDrawPriv->lastStamp ) {
+        if (driDrawPriv->swap_interval == (unsigned)-1) {
+           driDrawPriv->vblFlags = (newCtx->radeonScreen->irq != 0)
+              ? driGetDefaultVBlankFlags(&newCtx->optionCache)
+              : VBLANK_FLAG_NO_IRQ;
+
+           driDrawableInitVBlank( driDrawPriv );
+        }
+
         newCtx->dri.drawable = driDrawPriv;
 
         radeonSetCliprects(newCtx);
index 8dedd66f563f8a9e5edcc8416ec4b11f93118acb..bc43fc596013b994d9798daa9bf52828655a2150 100644 (file)
@@ -161,6 +161,8 @@ struct radeon_tex_obj {
        drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS];
        /* Six, for the cube faces */
 
+       GLboolean image_override; /* Image overridden by GLX_EXT_tfp */
+
        GLuint pp_txfilter;     /* hardware register values */
        GLuint pp_txformat;
        GLuint pp_txoffset;     /* Image location in texmem.
@@ -667,9 +669,6 @@ struct radeon_context {
 
        /* VBI
         */
-       GLuint vbl_seq;
-       GLuint vblank_flags;
-
        int64_t swap_ust;
        int64_t swap_missed_ust;
 
@@ -708,9 +707,9 @@ struct radeon_context {
 
 #define RADEON_CONTEXT(ctx)            ((radeonContextPtr)(ctx->DriverCtx))
 
-static __inline GLuint radeonPackColor(GLuint cpp,
-                                      GLubyte r, GLubyte g,
-                                      GLubyte b, GLubyte a)
+static INLINE GLuint radeonPackColor(GLuint cpp,
+                                     GLubyte r, GLubyte g,
+                                     GLubyte b, GLubyte a)
 {
        switch (cpp) {
        case 2:
index a0c563c7cba4af7e7c78e02b87f6b00448db2f6f..e681ca0889cd6e60f92fa0caaabc8d8bb1339dae 100644 (file)
@@ -862,13 +862,14 @@ static void radeonWaitForFrameCompletion( radeonContextPtr rmesa )
 
 /* Copy the back color buffer to the front color buffer.
  */
-void radeonCopyBuffer( const __DRIdrawablePrivate *dPriv,
+void radeonCopyBuffer( __DRIdrawablePrivate *dPriv,
                       const drm_clip_rect_t      *rect)
 {
    radeonContextPtr rmesa;
    GLint nbox, i, ret;
    GLboolean   missed_target;
    int64_t ust;
+   __DRIscreenPrivate *psp;
 
    assert(dPriv);
    assert(dPriv->driContextPriv);
@@ -890,7 +891,7 @@ void radeonCopyBuffer( const __DRIdrawablePrivate *dPriv,
    if (!rect)
    {
        UNLOCK_HARDWARE( rmesa );
-       driWaitForVBlank( dPriv, & rmesa->vbl_seq, rmesa->vblank_flags, & missed_target );
+       driWaitForVBlank( dPriv, & missed_target );
        LOCK_HARDWARE( rmesa );
    }
 
@@ -917,16 +918,18 @@ void radeonCopyBuffer( const __DRIdrawablePrivate *dPriv,
              if (rect->y2 < b->y2)
                  b->y2 = rect->y2;
 
-             if (b->x1 < b->x2 && b->y1 < b->y2)
-                 b++;
+             if (b->x1 >= b->x2 || b->y1 >= b->y2)
+                 continue;
          }
-         else
-             b++;
 
+         b++;
          n++;
       }
       rmesa->sarea->nbox = n;
 
+      if (!n)
+        continue;
+
       ret = drmCommandNone( rmesa->dri.fd, DRM_RADEON_SWAP );
 
       if ( ret ) {
@@ -939,8 +942,9 @@ void radeonCopyBuffer( const __DRIdrawablePrivate *dPriv,
    UNLOCK_HARDWARE( rmesa );
    if (!rect)
    {
+       psp = dPriv->driScreenPriv;
        rmesa->swap_count++;
-       (*dri_interface->getUST)( & ust );
+       (*psp->systemTime->getUST)( & ust );
        if ( missed_target ) {
           rmesa->swap_missed_count++;
           rmesa->swap_missed_ust = ust - rmesa->swap_ust;
@@ -951,17 +955,19 @@ void radeonCopyBuffer( const __DRIdrawablePrivate *dPriv,
    }
 }
 
-void radeonPageFlip( const __DRIdrawablePrivate *dPriv )
+void radeonPageFlip( __DRIdrawablePrivate *dPriv )
 {
    radeonContextPtr rmesa;
    GLint ret;
    GLboolean   missed_target;
+   __DRIscreenPrivate *psp;
 
    assert(dPriv);
    assert(dPriv->driContextPriv);
    assert(dPriv->driContextPriv->driverPrivate);
 
    rmesa = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
+   psp = dPriv->driScreenPriv;
 
    if ( RADEON_DEBUG & DEBUG_IOCTL ) {
       fprintf(stderr, "%s: pfCurrentPage: %d\n", __FUNCTION__,
@@ -986,10 +992,10 @@ void radeonPageFlip( const __DRIdrawablePrivate *dPriv )
     */
    radeonWaitForFrameCompletion( rmesa );
    UNLOCK_HARDWARE( rmesa );
-   driWaitForVBlank( dPriv, & rmesa->vbl_seq, rmesa->vblank_flags, & missed_target );
+   driWaitForVBlank( dPriv, & missed_target );
    if ( missed_target ) {
       rmesa->swap_missed_count++;
-      (void) (*dri_interface->getUST)( & rmesa->swap_missed_ust );
+      (void) (*psp->systemTime->getUST)( & rmesa->swap_missed_ust );
    }
    LOCK_HARDWARE( rmesa );
 
@@ -1003,7 +1009,7 @@ void radeonPageFlip( const __DRIdrawablePrivate *dPriv )
    }
 
    rmesa->swap_count++;
-   (void) (*dri_interface->getUST)( & rmesa->swap_ust );
+   (void) (*psp->systemTime->getUST)( & rmesa->swap_ust );
 
    /* Get ready for drawing next frame.  Update the renderbuffers'
     * flippedOffset/Pitch fields so we draw into the right place.
index 020a5c21e2d647a93821be5eae63b8026d4fb99f..f8c96af3f7ba37e7bceaabb56b49128925d2f927 100644 (file)
@@ -86,9 +86,9 @@ extern void radeonReleaseDmaRegion( radeonContextPtr rmesa,
                                    struct radeon_dma_region *region,
                                    const char *caller );
 
-extern void radeonCopyBuffer( const __DRIdrawablePrivate *drawable,
+extern void radeonCopyBuffer( __DRIdrawablePrivate *drawable,
                              const drm_clip_rect_t      *rect);
-extern void radeonPageFlip( const __DRIdrawablePrivate *drawable );
+extern void radeonPageFlip( __DRIdrawablePrivate *drawable );
 extern void radeonFlush( GLcontext *ctx );
 extern void radeonFinish( GLcontext *ctx );
 extern void radeonWaitForIdleLocked( radeonContextPtr rmesa );
@@ -123,7 +123,7 @@ do {                                                                \
    memcpy( rmesa->hw.ATOM.lastcmd, rmesa->hw.ATOM.cmd, \
           rmesa->hw.ATOM.cmd_size * 4)
 
-static __inline int RADEON_DB_STATECHANGE( 
+static INLINE int RADEON_DB_STATECHANGE( 
    radeonContextPtr rmesa,
    struct radeon_state_atom *atom )
 {
@@ -176,7 +176,7 @@ do {                                                        \
  * 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,
+static INLINE void radeonEnsureCmdBufSpace( radeonContextPtr rmesa,
                                              int bytes )
 {
    if (rmesa->store.cmd_used + bytes > RADEON_CMD_BUF_SZ)
@@ -186,7 +186,7 @@ static __inline void radeonEnsureCmdBufSpace( radeonContextPtr rmesa,
 
 /* Alloc space in the command buffer
  */
-static __inline char *radeonAllocCmdBuf( radeonContextPtr rmesa,
+static INLINE char *radeonAllocCmdBuf( radeonContextPtr rmesa,
                                         int bytes, const char *where )
 {
    if (rmesa->store.cmd_used + bytes > RADEON_CMD_BUF_SZ)
index 762848fc26031be4d23c1439a3863efb3d450f27..edf804c60ae4f21bf043e15b0c9044fb185a8264 100644 (file)
@@ -48,10 +48,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #if !RADEON_COMMON
 #include "radeon_context.h"
 #include "radeon_span.h"
+#include "radeon_tex.h"
 #elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
 #include "r200_context.h"
 #include "r200_ioctl.h"
 #include "r200_span.h"
+#include "r200_tex.h"
 #elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
 #include "r300_context.h"
 #include "r300_fragprog.h"
@@ -88,7 +90,7 @@ DRI_CONF_BEGIN
         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_ALLOW_LARGE_TEXTURES(1)
+        DRI_CONF_ALLOW_LARGE_TEXTURES(2)
     DRI_CONF_SECTION_END
     DRI_CONF_SECTION_DEBUG
         DRI_CONF_NO_RAST(false)
@@ -115,7 +117,7 @@ DRI_CONF_BEGIN
         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_ALLOW_LARGE_TEXTURES(1)
+        DRI_CONF_ALLOW_LARGE_TEXTURES(2)
         DRI_CONF_TEXTURE_BLEND_QUALITY(1.0,"0.0:1.0")
     DRI_CONF_SECTION_END
     DRI_CONF_SECTION_DEBUG
@@ -177,7 +179,7 @@ DRI_CONF_OPT_BEGIN_V(fp_optimization,enum,def,"0:1") \
         DRI_CONF_DESC_END \
 DRI_CONF_OPT_END
 
-const char __driConfigOptions[] =
+PUBLIC const char __driConfigOptions[] =
 DRI_CONF_BEGIN
        DRI_CONF_SECTION_PERFORMANCE
                DRI_CONF_TCL_MODE(DRI_CONF_TCL_CODEGEN)
@@ -186,14 +188,13 @@ DRI_CONF_BEGIN
                DRI_CONF_MAX_TEXTURE_IMAGE_UNITS(8, 2, 8)
                DRI_CONF_MAX_TEXTURE_COORD_UNITS(8, 2, 8)
                DRI_CONF_COMMAND_BUFFER_SIZE(8, 8, 32)
-               DRI_CONF_DISABLE_FALLBACK(false)
+               DRI_CONF_DISABLE_FALLBACK(true)
                DRI_CONF_DISABLE_DOUBLE_SIDE_STENCIL(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_FORCE_S3TC_ENABLE(false)
                DRI_CONF_DISABLE_S3TC(false)
                DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER)
                DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC)
@@ -204,7 +205,7 @@ DRI_CONF_BEGIN
                DRI_CONF_NO_RAST(false)
        DRI_CONF_SECTION_END
 DRI_CONF_END;
-static const GLuint __driNConfigOptions = 18;
+static const GLuint __driNConfigOptions = 17;
 
 #ifndef RADEON_DEBUG
 int RADEON_DEBUG = 0;
@@ -242,25 +243,26 @@ radeonGetParam(int fd, int param, void *value)
 {
   int ret;
   drm_radeon_getparam_t gp;
-  
+
   gp.param = param;
   gp.value = value;
-  
+
   ret = drmCommandWriteRead( fd, DRM_RADEON_GETPARAM, &gp, sizeof(gp));
   return ret;
 }
 
-static __GLcontextModes *
-radeonFillInModes( unsigned pixel_bits, unsigned depth_bits,
-                unsigned stencil_bits, GLboolean have_back_buffer )
+static const __DRIconfig **
+radeonFillInModes( __DRIscreenPrivate *psp,
+                  unsigned pixel_bits, unsigned depth_bits,
+                  unsigned stencil_bits, GLboolean have_back_buffer )
 {
-    __GLcontextModes * modes;
-    __GLcontextModes * m;
-    unsigned num_modes;
+    __DRIconfig **configs;
+    __GLcontextModes *m;
     unsigned depth_buffer_factor;
     unsigned back_buffer_factor;
     GLenum fb_format;
     GLenum fb_type;
+    int 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
@@ -277,7 +279,7 @@ radeonFillInModes( unsigned pixel_bits, unsigned depth_bits,
 
     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.
@@ -288,8 +290,6 @@ radeonFillInModes( unsigned pixel_bits, unsigned depth_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;
@@ -299,21 +299,11 @@ radeonFillInModes( unsigned pixel_bits, unsigned depth_bits,
         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 ) ) {
+    configs = driCreateConfigs(fb_format, fb_type,
+                              depth_bits_array, stencil_bits_array,
+                              depth_buffer_factor,
+                              back_buffer_modes, back_buffer_factor);
+    if (configs == NULL) {
        fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
                 __func__, __LINE__ );
        return NULL;
@@ -321,15 +311,43 @@ radeonFillInModes( unsigned pixel_bits, unsigned depth_bits,
 
     /* 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) ) {
+    for (i = 0; configs[i]; i++) {
+       m = &configs[i]->modes;
+       if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
            m->visualRating = GLX_SLOW_CONFIG;
        }
     }
 
-    return modes;
+    return (const __DRIconfig **) configs;
 }
 
+#if !RADEON_COMMON
+static const __DRItexOffsetExtension radeonTexOffsetExtension = {
+    { __DRI_TEX_OFFSET, __DRI_TEX_OFFSET_VERSION },
+    radeonSetTexOffset,
+};
+#endif
+
+#if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
+static const __DRIallocateExtension r200AllocateExtension = {
+    { __DRI_ALLOCATE, __DRI_ALLOCATE_VERSION },
+    r200AllocateMemoryMESA,
+    r200FreeMemoryMESA,
+    r200GetMemoryOffsetMESA
+};
+
+static const __DRItexOffsetExtension r200texOffsetExtension = {
+    { __DRI_TEX_OFFSET, __DRI_TEX_OFFSET_VERSION },
+   r200SetTexOffset,
+};
+#endif
+
+#if RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
+static const __DRItexOffsetExtension r300texOffsetExtension = {
+    { __DRI_TEX_OFFSET, __DRI_TEX_OFFSET_VERSION },
+   r300SetTexOffset,
+};
+#endif
 
 /* Create the device specific screen private data struct.
  */
@@ -339,9 +357,9 @@ 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;
+   int i;
+   int ret;
+   uint32_t temp;
 
    if (sPriv->devPrivSize != sizeof(RADEONDRIRec)) {
       fprintf(stderr,"\nERROR!  sizeof(RADEONDRIRec) does not match passed size from device driver\n");
@@ -372,7 +390,7 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv )
       int ret;
       ret = radeonGetParam( sPriv->fd, RADEON_PARAM_GART_BUFFER_OFFSET,
                            &screen->gart_buffer_offset);
-       
+
       if (ret) {
         FREE( screen );
         fprintf(stderr, "drm_radeon_getparam_t (RADEON_PARAM_GART_BUFFER_OFFSET): %d\n", ret);
@@ -394,13 +412,13 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv )
         fprintf(stderr, "drm_radeon_getparam_t (RADEON_PARAM_IRQ_NR): %d\n", ret);
         return NULL;
       }
-      screen->drmSupportsCubeMapsR200 = (sPriv->drmMinor >= 7);
-      screen->drmSupportsBlendColor = (sPriv->drmMinor >= 11);
-      screen->drmSupportsTriPerf = (sPriv->drmMinor >= 16);
-      screen->drmSupportsFragShader = (sPriv->drmMinor >= 18);
-      screen->drmSupportsPointSprites = (sPriv->drmMinor >= 13);
-      screen->drmSupportsCubeMapsR100 = (sPriv->drmMinor >= 15);
-      screen->drmSupportsVertexProgram = (sPriv->drmMinor >= 25);
+      screen->drmSupportsCubeMapsR200 = (sPriv->drm_version.minor >= 7);
+      screen->drmSupportsBlendColor = (sPriv->drm_version.minor >= 11);
+      screen->drmSupportsTriPerf = (sPriv->drm_version.minor >= 16);
+      screen->drmSupportsFragShader = (sPriv->drm_version.minor >= 18);
+      screen->drmSupportsPointSprites = (sPriv->drm_version.minor >= 13);
+      screen->drmSupportsCubeMapsR100 = (sPriv->drm_version.minor >= 15);
+      screen->drmSupportsVertexProgram = (sPriv->drm_version.minor >= 25);
    }
 
    screen->mmio.handle = dri_priv->registerHandle;
@@ -534,7 +552,11 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv )
       screen->chip_family = CHIP_FAMILY_RS300;
       break;
 
+      /* 9500 with 1 pipe verified by: Reid Linnemann <lreid@cs.okstate.edu> */
    case PCI_CHIP_R300_AD:
+      screen->chip_family = CHIP_FAMILY_RV350;
+      screen->chip_flags = RADEON_CHIPSET_TCL;
+      break;
    case PCI_CHIP_R300_AE:
    case PCI_CHIP_R300_AF:
    case PCI_CHIP_R300_AG:
@@ -632,17 +654,18 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv )
       screen->chip_flags = RADEON_CHIPSET_TCL;
       break;
 
+   case PCI_CHIP_RV410_5E4C:
+   case PCI_CHIP_RV410_5E4F:
    case PCI_CHIP_RV410_564A:
    case PCI_CHIP_RV410_564B:
    case PCI_CHIP_RV410_564F:
    case PCI_CHIP_RV410_5652:
    case PCI_CHIP_RV410_5653:
+   case PCI_CHIP_RV410_5657:
    case PCI_CHIP_RV410_5E48:
    case PCI_CHIP_RV410_5E4A:
    case PCI_CHIP_RV410_5E4B:
-   case PCI_CHIP_RV410_5E4C:
    case PCI_CHIP_RV410_5E4D:
-   case PCI_CHIP_RV410_5E4F:
       screen->chip_family = CHIP_FAMILY_RV410;
       screen->chip_flags = RADEON_CHIPSET_TCL;
       break;
@@ -656,7 +679,132 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv )
    case PCI_CHIP_RC410_5A61:
    case PCI_CHIP_RC410_5A62:
       screen->chip_family = CHIP_FAMILY_RS400;
-      fprintf(stderr, "Warning, xpress200 detected.\n");
+      break;
+
+   case PCI_CHIP_RS690_791E:
+   case PCI_CHIP_RS690_791F:
+      screen->chip_family = CHIP_FAMILY_RS690;
+      break;
+   case PCI_CHIP_RS740_796C:
+   case PCI_CHIP_RS740_796D:
+   case PCI_CHIP_RS740_796E:
+   case PCI_CHIP_RS740_796F:
+      screen->chip_family = CHIP_FAMILY_RS740;
+      break;
+
+   case PCI_CHIP_R520_7100:
+   case PCI_CHIP_R520_7101:
+   case PCI_CHIP_R520_7102:
+   case PCI_CHIP_R520_7103:
+   case PCI_CHIP_R520_7104:
+   case PCI_CHIP_R520_7105:
+   case PCI_CHIP_R520_7106:
+   case PCI_CHIP_R520_7108:
+   case PCI_CHIP_R520_7109:
+   case PCI_CHIP_R520_710A:
+   case PCI_CHIP_R520_710B:
+   case PCI_CHIP_R520_710C:
+   case PCI_CHIP_R520_710E:
+   case PCI_CHIP_R520_710F:
+      screen->chip_family = CHIP_FAMILY_R520;
+      screen->chip_flags = RADEON_CHIPSET_TCL;
+      break;
+
+   case PCI_CHIP_RV515_7140:
+   case PCI_CHIP_RV515_7141:
+   case PCI_CHIP_RV515_7142:
+   case PCI_CHIP_RV515_7143:
+   case PCI_CHIP_RV515_7144:
+   case PCI_CHIP_RV515_7145:
+   case PCI_CHIP_RV515_7146:
+   case PCI_CHIP_RV515_7147:
+   case PCI_CHIP_RV515_7149:
+   case PCI_CHIP_RV515_714A:
+   case PCI_CHIP_RV515_714B:
+   case PCI_CHIP_RV515_714C:
+   case PCI_CHIP_RV515_714D:
+   case PCI_CHIP_RV515_714E:
+   case PCI_CHIP_RV515_714F:
+   case PCI_CHIP_RV515_7151:
+   case PCI_CHIP_RV515_7152:
+   case PCI_CHIP_RV515_7153:
+   case PCI_CHIP_RV515_715E:
+   case PCI_CHIP_RV515_715F:
+   case PCI_CHIP_RV515_7180:
+   case PCI_CHIP_RV515_7181:
+   case PCI_CHIP_RV515_7183:
+   case PCI_CHIP_RV515_7186:
+   case PCI_CHIP_RV515_7187:
+   case PCI_CHIP_RV515_7188:
+   case PCI_CHIP_RV515_718A:
+   case PCI_CHIP_RV515_718B:
+   case PCI_CHIP_RV515_718C:
+   case PCI_CHIP_RV515_718D:
+   case PCI_CHIP_RV515_718F:
+   case PCI_CHIP_RV515_7193:
+   case PCI_CHIP_RV515_7196:
+   case PCI_CHIP_RV515_719B:
+   case PCI_CHIP_RV515_719F:
+   case PCI_CHIP_RV515_7200:
+   case PCI_CHIP_RV515_7210:
+   case PCI_CHIP_RV515_7211:
+      screen->chip_family = CHIP_FAMILY_RV515;
+      screen->chip_flags = RADEON_CHIPSET_TCL;
+      break;
+
+   case PCI_CHIP_RV530_71C0:
+   case PCI_CHIP_RV530_71C1:
+   case PCI_CHIP_RV530_71C2:
+   case PCI_CHIP_RV530_71C3:
+   case PCI_CHIP_RV530_71C4:
+   case PCI_CHIP_RV530_71C5:
+   case PCI_CHIP_RV530_71C6:
+   case PCI_CHIP_RV530_71C7:
+   case PCI_CHIP_RV530_71CD:
+   case PCI_CHIP_RV530_71CE:
+   case PCI_CHIP_RV530_71D2:
+   case PCI_CHIP_RV530_71D4:
+   case PCI_CHIP_RV530_71D5:
+   case PCI_CHIP_RV530_71D6:
+   case PCI_CHIP_RV530_71DA:
+   case PCI_CHIP_RV530_71DE:
+      screen->chip_family = CHIP_FAMILY_RV530;
+      screen->chip_flags = RADEON_CHIPSET_TCL;
+      break;
+
+   case PCI_CHIP_R580_7240:
+   case PCI_CHIP_R580_7243:
+   case PCI_CHIP_R580_7244:
+   case PCI_CHIP_R580_7245:
+   case PCI_CHIP_R580_7246:
+   case PCI_CHIP_R580_7247:
+   case PCI_CHIP_R580_7248:
+   case PCI_CHIP_R580_7249:
+   case PCI_CHIP_R580_724A:
+   case PCI_CHIP_R580_724B:
+   case PCI_CHIP_R580_724C:
+   case PCI_CHIP_R580_724D:
+   case PCI_CHIP_R580_724E:
+   case PCI_CHIP_R580_724F:
+   case PCI_CHIP_R580_7284:
+      screen->chip_family = CHIP_FAMILY_R580;
+      screen->chip_flags = RADEON_CHIPSET_TCL;
+      break;
+
+   case PCI_CHIP_RV570_7280:
+   case PCI_CHIP_RV560_7281:
+   case PCI_CHIP_RV560_7283:
+   case PCI_CHIP_RV560_7287:
+   case PCI_CHIP_RV570_7288:
+   case PCI_CHIP_RV570_7289:
+   case PCI_CHIP_RV570_728B:
+   case PCI_CHIP_RV570_728C:
+   case PCI_CHIP_RV560_7290:
+   case PCI_CHIP_RV560_7291:
+   case PCI_CHIP_RV560_7293:
+   case PCI_CHIP_RV560_7297:
+      screen->chip_family = CHIP_FAMILY_RV560;
+      screen->chip_flags = RADEON_CHIPSET_TCL;
       break;
 
    default:
@@ -665,11 +813,19 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv )
       return NULL;
    }
    if ((screen->chip_family == CHIP_FAMILY_R350 || screen->chip_family == CHIP_FAMILY_R300) &&
-       sPriv->ddxMinor < 2) {
+       sPriv->ddx_version.minor < 2) {
       fprintf(stderr, "xf86-video-ati-6.6.2 or newer needed for Radeon 9500/9700/9800 cards.\n");
       return NULL;
    }
 
+   if ((sPriv->drm_version.minor < 29) && (screen->chip_family >= CHIP_FAMILY_RV515)) {
+      fprintf(stderr, "R500 support requires a newer drm.\n");
+      return NULL;
+   }
+
+   if (getenv("R300_NO_TCL"))
+     screen->chip_flags &= ~RADEON_CHIPSET_TCL;
+
    if (screen->chip_family <= CHIP_FAMILY_RS200)
       screen->chip_flags |= RADEON_CLASS_R100;
    else if (screen->chip_family <= CHIP_FAMILY_RV280)
@@ -680,9 +836,51 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv )
    screen->cpp = dri_priv->bpp / 8;
    screen->AGPMode = dri_priv->AGPMode;
 
-   screen->fbLocation  = ( INREG( RADEON_MC_FB_LOCATION ) & 0xffff ) << 16;
+   ret = radeonGetParam( sPriv->fd, RADEON_PARAM_FB_LOCATION,
+                         &temp);
+   if (ret) {
+       if (screen->chip_family < CHIP_FAMILY_RS690)
+          screen->fbLocation      = ( INREG( RADEON_MC_FB_LOCATION ) & 0xffff) << 16;
+       else {
+           FREE( screen );
+           fprintf(stderr, "Unable to get fb location need newer drm\n");
+           return NULL;
+       }
+   } else {
+       screen->fbLocation = (temp & 0xffff) << 16;
+   }
+
+   if (screen->chip_family >= CHIP_FAMILY_RV515) {
+       ret = radeonGetParam( sPriv->fd, RADEON_PARAM_NUM_GB_PIPES,
+                            &temp);
+       if (ret) {
+          fprintf(stderr, "Unable to get num_pipes, need newer drm\n");
+          switch (screen->chip_family) {
+          case CHIP_FAMILY_R300:
+          case CHIP_FAMILY_R350:
+              screen->num_gb_pipes = 2;
+              break;
+          case CHIP_FAMILY_R420:
+          case CHIP_FAMILY_R520:
+          case CHIP_FAMILY_R580:
+          case CHIP_FAMILY_RV560:
+          case CHIP_FAMILY_RV570:
+              screen->num_gb_pipes = 4;
+              break;
+          case CHIP_FAMILY_RV350:
+          case CHIP_FAMILY_RV515:
+          case CHIP_FAMILY_RV530:
+          case CHIP_FAMILY_RV410:
+          default:
+              screen->num_gb_pipes = 1;
+              break;
+          }
+       } else {
+          screen->num_gb_pipes = temp;
+       }
+   }
 
-   if ( sPriv->drmMinor >= 10 ) {
+   if ( sPriv->drm_version.minor >= 10 ) {
       drm_radeon_setparam_t sp;
 
       sp.param = RADEON_SETPARAM_FB_LOCATION;
@@ -700,8 +898,11 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv )
    screen->depthPitch  = dri_priv->depthPitch;
 
    /* Check if ddx has set up a surface reg to cover depth buffer */
-   screen->depthHasSurface = ((sPriv->ddxMajor > 4) &&
-      (screen->chip_flags & RADEON_CHIPSET_TCL));
+   screen->depthHasSurface = (sPriv->ddx_version.major > 4) ||
+      /* these chips don't use tiled z without hyperz. So always pretend
+         we have set up a surface which will cause linear reads/writes */
+      ((screen->chip_family & RADEON_CLASS_R100) &&
+      !(screen->chip_flags & RADEON_CHIPSET_TCL));
 
    if ( dri_priv->textureSize == 0 ) {
       screen->texOffset[RADEON_LOCAL_TEX_HEAP] = screen->gart_texture_offset;
@@ -730,29 +931,34 @@ radeonCreateScreen( __DRIscreenPrivate *sPriv )
         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" );
-      if (IS_R200_CLASS(screen))
-        (*glx_enable_extension)( psc, "GLX_MESA_allocate_memory" );
+   i = 0;
+   screen->extensions[i++] = &driCopySubBufferExtension.base;
+   screen->extensions[i++] = &driFrameTrackingExtension.base;
+   screen->extensions[i++] = &driReadDrawableExtension;
 
-      (*glx_enable_extension)( psc, "GLX_MESA_copy_sub_buffer" );
-      (*glx_enable_extension)( psc, "GLX_SGI_make_current_read" );
+   if ( screen->irq != 0 ) {
+       screen->extensions[i++] = &driSwapControlExtension.base;
+       screen->extensions[i++] = &driMediaStreamCounterExtension.base;
    }
 
+#if !RADEON_COMMON
+   screen->extensions[i++] = &radeonTexOffsetExtension.base;
+#endif
+
 #if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
-   if (IS_R200_CLASS(screen)) {
-      sPriv->psc->allocateMemory = (void *) r200AllocateMemoryMESA;
-      sPriv->psc->freeMemory     = (void *) r200FreeMemoryMESA;
-      sPriv->psc->memoryOffset   = (void *) r200GetMemoryOffsetMESA;
-   }
+   if (IS_R200_CLASS(screen))
+       screen->extensions[i++] = &r200AllocateExtension.base;
+
+   screen->extensions[i++] = &r200texOffsetExtension.base;
 #endif
 
+#if RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
+   screen->extensions[i++] = &r300texOffsetExtension.base;
+#endif
+
+   screen->extensions[i++] = NULL;
+   sPriv->extensions = screen->extensions;
+
    screen->driScreen = sPriv;
    screen->sarea_priv_offset = dri_priv->sarea_priv_offset;
    return screen;
@@ -935,71 +1141,16 @@ static void radeonDestroyContext(__DRIcontextPrivate * driContextPriv)
 
 #endif
 
-#if !RADEON_COMMON || (RADEON_COMMON && defined(RADEON_COMMON_FOR_R300))
-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,
-   .CopySubBuffer   = radeonCopySubBuffer,
-#if RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)
-   .setTexOffset    = r300SetTexOffset,
-#endif
-};
-#else
-static const struct __DriverAPIRec r200API = {
-   .InitDriver      = radeonInitDriver,
-   .DestroyScreen   = radeonDestroyScreen,
-   .CreateContext   = r200CreateContext,
-   .DestroyContext  = r200DestroyContext,
-   .CreateBuffer    = radeonCreateBuffer,
-   .DestroyBuffer   = radeonDestroyBuffer,
-   .SwapBuffers     = r200SwapBuffers,
-   .MakeCurrent     = r200MakeCurrent,
-   .UnbindContext   = r200UnbindContext,
-   .GetSwapInfo     = getSwapInfo,
-   .GetMSC          = driGetMSC32,
-   .WaitForMSC      = driWaitForMSC32,
-   .WaitForSBC      = NULL,
-   .SwapBuffersMSC  = NULL,
-   .CopySubBuffer   = r200CopySubBuffer
-};
-#endif
-
 /**
- * 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.
+ * This is the driver specific part of the createNewScreen entry point.
  *
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on 
- *         failure.
+ * \todo maybe fold this into intelInitDriver
+ *
+ * \return the __GLcontextModes supported by this driver
  */
-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 )
+static const __DRIconfig **
+radeonInitScreen(__DRIscreenPrivate *psp)
 {
-   __DRIscreenPrivate *psp;
 #if !RADEON_COMMON
    static const char *driver_name = "Radeon";
    static const __DRIutilversion2 ddx_expected = { 4, 5, 0, 0 };
@@ -1016,57 +1167,42 @@ __driCreateNewScreen_20050727( __DRInativeDisplay *dpy,
    static const __DRIversion dri_expected = { 4, 0, 0 };
    static const __DRIversion drm_expected = { 1, 24, 0 };
 #endif
-
-   dri_interface = interface;
+   RADEONDRIPtr dri_priv = (RADEONDRIPtr) psp->pDevPriv;
 
    if ( ! driCheckDriDdxDrmVersions3( driver_name,
-                                     dri_version, & dri_expected,
-                                     ddx_version, & ddx_expected,
-                                     drm_version, & drm_expected ) ) {
+                                     &psp->dri_version, & dri_expected,
+                                     &psp->ddx_version, & ddx_expected,
+                                     &psp->drm_version, & drm_expected ) ) {
       return NULL;
    }
-#if !RADEON_COMMON || (RADEON_COMMON && defined(RADEON_COMMON_FOR_R300))
-   psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
-                                 ddx_version, dri_version, drm_version,
-                                 frame_buffer, pSAREA, fd,
-                                 internal_api_version, &radeonAPI);
-#elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
-   psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
-                                 ddx_version, dri_version, drm_version,
-                                 frame_buffer, pSAREA, fd,
-                                 internal_api_version, &r200API);
-#endif
 
-   if ( psp != NULL ) {
-      RADEONDRIPtr dri_priv = (RADEONDRIPtr) psp->pDevPriv;
-      if (driver_modes) {
-         *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 );
+   /* 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 );
 #if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
-      driInitExtensions( NULL, blend_extensions, GL_FALSE );
-      driInitSingleExtension( NULL, ARB_vp_extension );
-      driInitSingleExtension( NULL, NV_vp_extension );
-      driInitSingleExtension( NULL, ATI_fs_extension );
-      driInitExtensions( NULL, point_extensions, GL_FALSE );
+   driInitExtensions( NULL, blend_extensions, GL_FALSE );
+   driInitSingleExtension( NULL, ARB_vp_extension );
+   driInitSingleExtension( NULL, NV_vp_extension );
+   driInitSingleExtension( NULL, ATI_fs_extension );
+   driInitExtensions( NULL, point_extensions, GL_FALSE );
 #endif
-   }
 
-   return (void *) psp;
+   if (!radeonInitDriver(psp))
+       return NULL;
+
+   return radeonFillInModes( psp,
+                            dri_priv->bpp,
+                            (dri_priv->bpp == 16) ? 16 : 24,
+                            (dri_priv->bpp == 16) ? 0  : 8,
+                            (dri_priv->backOffset != dri_priv->depthOffset) );
 }
 
 
@@ -1099,3 +1235,41 @@ getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo )
 
    return 0;
 }
+
+#if !RADEON_COMMON || (RADEON_COMMON && defined(RADEON_COMMON_FOR_R300))
+const struct __DriverAPIRec driDriverAPI = {
+   .InitScreen      = radeonInitScreen,
+   .DestroyScreen   = radeonDestroyScreen,
+   .CreateContext   = radeonCreateContext,
+   .DestroyContext  = radeonDestroyContext,
+   .CreateBuffer    = radeonCreateBuffer,
+   .DestroyBuffer   = radeonDestroyBuffer,
+   .SwapBuffers     = radeonSwapBuffers,
+   .MakeCurrent     = radeonMakeCurrent,
+   .UnbindContext   = radeonUnbindContext,
+   .GetSwapInfo     = getSwapInfo,
+   .GetDrawableMSC  = driDrawableGetMSC32,
+   .WaitForMSC      = driWaitForMSC32,
+   .WaitForSBC      = NULL,
+   .SwapBuffersMSC  = NULL,
+   .CopySubBuffer   = radeonCopySubBuffer,
+};
+#else
+const struct __DriverAPIRec driDriverAPI = {
+   .InitScreen      = radeonInitScreen,
+   .DestroyScreen   = radeonDestroyScreen,
+   .CreateContext   = r200CreateContext,
+   .DestroyContext  = r200DestroyContext,
+   .CreateBuffer    = radeonCreateBuffer,
+   .DestroyBuffer   = radeonDestroyBuffer,
+   .SwapBuffers     = r200SwapBuffers,
+   .MakeCurrent     = r200MakeCurrent,
+   .UnbindContext   = r200UnbindContext,
+   .GetSwapInfo     = getSwapInfo,
+   .GetDrawableMSC  = driDrawableGetMSC32,
+   .WaitForMSC      = driWaitForMSC32,
+   .WaitForSBC      = NULL,
+   .SwapBuffersMSC  = NULL,
+   .CopySubBuffer   = r200CopySubBuffer,
+};
+#endif
index c9b0c3af1252f04ac72a3c909db444ccda6e1847..b84c70bfae9c429144d77c94a0877f9bc3dc7608 100644 (file)
@@ -102,6 +102,10 @@ typedef struct {
 
    /* Configuration cache with default values for all contexts */
    driOptionCache optionCache;
+
+   const __DRIextension *extensions[8];
+
+   int num_gb_pipes;
 } radeonScreenRec, *radeonScreenPtr;
 
 #define IS_R100_CLASS(screen) \
index 732a85ecf0bdf6af17a4575f9ebe962847de0795..e7ab3677b36120bf25b394b690d7de25e6c19f3a 100644 (file)
@@ -173,6 +173,8 @@ radeon_mba_z16(const driRenderbuffer * drb, GLint x, GLint y)
 
 /* 16-bit depth buffer functions
  */
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d )                                       \
    *(GLushort *)(buf + radeon_mba_z16( drb, _x + xo, _y + yo )) = d;
 
@@ -187,6 +189,8 @@ radeon_mba_z16(const driRenderbuffer * drb, GLint x, GLint y)
  * Careful: It looks like the R300 uses ZZZS byte order while the R200
  * uses SZZZ for 24 bit depth, 8 bit stencil mode.
  */
+#define VALUE_TYPE GLuint
+
 #ifdef COMPILE_R300
 #define WRITE_DEPTH( _x, _y, d )                                       \
 do {                                                                   \
index 1fe5c244cdbaffb956577d1c7f88de1226417cfe..3437de16bb71f52deec6e8ca7043fb44e3ae520d 100644 (file)
@@ -1639,8 +1639,7 @@ void radeonSetCliprects( radeonContextPtr rmesa )
    GLframebuffer *const draw_fb = (GLframebuffer*) drawable->driverPrivate;
    GLframebuffer *const read_fb = (GLframebuffer*) readable->driverPrivate;
 
-   if (draw_fb->_ColorDrawBufferMask[0]
-       == BUFFER_BIT_BACK_LEFT) {
+   if (draw_fb->_ColorDrawBufferIndexes[0] == BUFFER_BACK_LEFT) {
       /* Can't ignore 2d windows if we are page flipping.
        */
       if ( drawable->numBackClipRects == 0 || rmesa->doPageFlip ) {
@@ -1692,17 +1691,18 @@ static void radeonDrawBuffer( GLcontext *ctx, GLenum mode )
 
    RADEON_FIREVERTICES(rmesa); /* don't pipeline cliprect changes */
 
-   /*
-    * _ColorDrawBufferMask is easier to cope with than <mode>.
-    * Check for software fallback, update cliprects.
-    */
-   switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
-   case BUFFER_BIT_FRONT_LEFT:
-   case BUFFER_BIT_BACK_LEFT:
+   if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) {
+      /* 0 (GL_NONE) buffers or multiple color drawing buffers */
+      FALLBACK( rmesa, RADEON_FALLBACK_DRAW_BUFFER, GL_TRUE );
+      return;
+   }
+
+   switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) {
+   case BUFFER_FRONT_LEFT:
+   case BUFFER_BACK_LEFT:
       FALLBACK( rmesa, RADEON_FALLBACK_DRAW_BUFFER, GL_FALSE );
       break;
    default:
-      /* 0 (GL_NONE) buffers or multiple color drawing buffers */
       FALLBACK( rmesa, RADEON_FALLBACK_DRAW_BUFFER, GL_TRUE );
       return;
    }
@@ -2221,11 +2221,11 @@ radeonUpdateDrawBuffer(GLcontext *ctx)
    struct gl_framebuffer *fb = ctx->DrawBuffer;
    driRenderbuffer *drb;
 
-   if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT) {
+   if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) {
       /* draw to front */
       drb = (driRenderbuffer *) fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
    }
-   else if (fb->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT) {
+   else if (fb->_ColorDrawBufferIndexes[0] == BUFFER_BACK_LEFT) {
       /* draw to back */
       drb = (driRenderbuffer *) fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer;
    }
index d35be1ca884860953d15c5f28a639dab1cfbcd7c..4c11ff7ab42313af312a0e1c08f7bab6d21afafd 100644 (file)
@@ -417,7 +417,7 @@ static GLboolean radeon_run_tcl_render( GLcontext *ctx,
 
    for (i = 0 ; i < VB->PrimitiveCount ; i++)
    {
-      GLuint prim = VB->Primitive[i].mode;
+      GLuint prim = _tnl_translate_prim(&VB->Primitive[i]);
       GLuint start = VB->Primitive[i].start;
       GLuint length = VB->Primitive[i].count;
 
index bdf086dfeec70b030b722429eb15d3aa5bdbc624..80008808289011a83a3f2da2d4f6cc2534931133 100644 (file)
@@ -37,6 +37,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #ifndef __RADEON_TEX_H__
 #define __RADEON_TEX_H__
 
+extern void radeonSetTexOffset(__DRIcontext *pDRICtx, GLint texname,
+                               unsigned long long offset, GLint depth,
+                               GLuint pitch);
+
 extern void radeonUpdateTextureState( GLcontext *ctx );
 
 extern int radeonUploadTexImages( radeonContextPtr rmesa, radeonTexObjPtr t,
index f7520f1dea32e05d844fe360fa5a3578a1c5638b..523c597271d3e9252cb8ab2db598f20703f21bbd 100644 (file)
@@ -333,7 +333,7 @@ int radeonUploadTexImages( radeonContextPtr rmesa, radeonTexObjPtr t, GLuint fac
 {
    int numLevels;
 
-   if ( !t || t->base.totalSize == 0 )
+   if ( !t || t->base.totalSize == 0 || t->image_override )
       return 0;
 
    if ( RADEON_DEBUG & (DEBUG_TEXTURE|DEBUG_IOCTL) ) {
index ae8d527cf46e5e6a5e2479ddcf9a4a8d334e1cae..90c6379eae90d5558a79238bf895c8d01cf9f4ca 100644 (file)
@@ -39,6 +39,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "context.h"
 #include "macros.h"
 #include "texformat.h"
+#include "texobj.h"
 #include "enums.h"
 
 #include "radeon_context.h"
@@ -83,7 +84,7 @@ tx_table[] =
    _ALPHA_REV(RGBA8888),
    _ALPHA(ARGB8888),
    _ALPHA_REV(ARGB8888),
-   _INVALID(RGB888),
+   [ MESA_FORMAT_RGB888 ] = { RADEON_TXFORMAT_ARGB8888, 0 },
    _COLOR(RGB565),
    _COLOR_REV(RGB565),
    _ALPHA(ARGB4444),
@@ -133,18 +134,19 @@ static void radeonSetTexImages( radeonContextPtr rmesa,
 
    /* 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;
+   if ( !t->image_override ) {
+      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;
@@ -340,11 +342,13 @@ static void radeonSetTexImages( radeonContextPtr rmesa,
     * 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;
+   if ( !t->image_override ) {
+      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;
 
@@ -839,6 +843,44 @@ static GLboolean radeonUpdateTextureEnv( GLcontext *ctx, int unit )
    return GL_TRUE;
 }
 
+void radeonSetTexOffset(__DRIcontext * pDRICtx, GLint texname,
+                        unsigned long long offset, GLint depth, GLuint pitch)
+{
+       radeonContextPtr rmesa = pDRICtx->driverPrivate;
+       struct gl_texture_object *tObj =
+           _mesa_lookup_texture(rmesa->glCtx, texname);
+       radeonTexObjPtr t;
+
+       if (tObj == NULL)
+               return;
+
+       t = (radeonTexObjPtr) tObj->DriverData;
+
+       t->image_override = GL_TRUE;
+
+       if (!offset)
+               return;
+
+       t->pp_txoffset = offset;
+       t->pp_txpitch = pitch - 32;
+
+       switch (depth) {
+       case 32:
+               t->pp_txformat = tx_table[MESA_FORMAT_ARGB8888].format;
+               t->pp_txfilter |= tx_table[MESA_FORMAT_ARGB8888].filter;
+               break;
+       case 24:
+       default:
+               t->pp_txformat = tx_table[MESA_FORMAT_RGB888].format;
+               t->pp_txfilter |= tx_table[MESA_FORMAT_RGB888].filter;
+               break;
+       case 16:
+               t->pp_txformat = tx_table[MESA_FORMAT_RGB565].format;
+               t->pp_txfilter |= tx_table[MESA_FORMAT_RGB565].filter;
+               break;
+       }
+}
+
 #define TEXOBJ_TXFILTER_MASK (RADEON_MAX_MIP_LEVEL_MASK |      \
                              RADEON_MIN_FILTER_MASK |          \
                              RADEON_MAG_FILTER_MASK |          \
@@ -1135,7 +1177,7 @@ static GLboolean enable_tex_2d( GLcontext *ctx, int unit )
       RADEON_FIREVERTICES( rmesa );
       radeonSetTexImages( rmesa, tObj );
       radeonUploadTexImages( rmesa, (radeonTexObjPtr) tObj->DriverData, 0 );
-      if ( !t->base.memBlock ) 
+      if ( !t->base.memBlock && !t->image_override 
        return GL_FALSE;
    }
 
@@ -1202,7 +1244,8 @@ static GLboolean enable_tex_rect( GLcontext *ctx, int unit )
       RADEON_FIREVERTICES( rmesa );
       radeonSetTexImages( rmesa, tObj );
       radeonUploadTexImages( rmesa, (radeonTexObjPtr) tObj->DriverData, 0 );
-      if ( !t->base.memBlock /* && !rmesa->prefer_gart_client_texturing  FIXME */ ) {
+      if ( !t->base.memBlock &&
+           !t->image_override /* && !rmesa->prefer_gart_client_texturing  FIXME */ ) {
         fprintf(stderr, "%s: upload failed\n", __FUNCTION__);
         return GL_FALSE;
       }
index 6f527f3a834c5495460757c551657a531c9bb92d..ed698103fff92b835ab2e08d186bc837f25153c3 100644 (file)
@@ -419,9 +419,9 @@ struct s3v_context {
 #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 )
+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));
index 3bc871b7eafa5de6a97ed0af178aaddcabc5859f..7e9b4529df44fc99af146dea49207cd5fb61aa48 100644 (file)
@@ -19,6 +19,7 @@
 #include <stdio.h>
 #endif
 
+#undef DEBUG
 #if GENERIC_DEBUG
 #define DEBUG(str) printf str
 #else
index 6aaa94976e3493b7a7d63282ad9461a9097a782d..fa3f85e52b34c432c51cc67e4e64ff2da140496d 100644 (file)
@@ -66,7 +66,7 @@ static const GLuint hw_prim[GL_POLYGON+1] = {
        PrimType_Polygon
 };
 
-static __inline void s3vStartPrimitive( s3vContextPtr vmesa, GLenum prim )
+static INLINE void s3vStartPrimitive( s3vContextPtr vmesa, GLenum prim )
 {
        __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
 
@@ -110,7 +110,7 @@ static __inline void s3vStartPrimitive( s3vContextPtr vmesa, GLenum prim )
        vmesa->restore_primitive = _hw_prim;
 }
 
-static __inline void s3vEndPrimitive( s3vContextPtr vmesa )
+static INLINE void s3vEndPrimitive( s3vContextPtr vmesa )
 {
 /*     GLcontext *ctx = vmesa->glCtx; */
        DEBUG(("s3vEndPrimitive\n"));
@@ -170,7 +170,7 @@ static GLboolean s3v_run_render( GLcontext *ctx,
 
        for (i = 0 ; i < VB->PrimitiveCount ; i++ )
        {
-                GLuint prim = VB->Primitive[i].mode;
+               GLuint prim = _tnl_translate_prim(&VB->Primitive[i]);
                GLuint start = VB->Primitive[i].start;
                GLuint length = VB->Primitive[i].count;
 
index de78f9f6b1bd8e801c52f2c971bd99302ad9c162..f9f7c0d1eeecd55a6f242e7191f93a4ddb76ca75 100644 (file)
@@ -128,6 +128,8 @@ do { \
 
 /* 16 bit depthbuffer functions.
  */
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d ) \
    *(GLushort *)(buf + _x*2 + _y*dPriv->w*2) = d
 
@@ -143,6 +145,8 @@ do { \
 /* 32 bit depthbuffer functions.
  */
 #if 0
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d )       \
    *(GLuint *)(buf + _x*4 + _y*pitch) = d;
 
@@ -157,6 +161,8 @@ do { \
 /* 24/8 bit interleaved depth/stencil functions
  */
 #if 0
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d ) { \
    GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch);    \
    tmp &= 0xff; \
index c66fd6dac311e3e2dd16b7430544b8bca5840996..663dabdb914c2a91852b9eea15991378b0372d9b 100644 (file)
@@ -17,8 +17,8 @@
 
 /* #define DEBUG(str) printf str */
 
-static GLboolean 
-s3vInitDriver(__DRIscreenPrivate *sPriv)
+static const __DRIconfig **
+s3vInitScreen(__DRIscreen *sPriv)
 {
     sPriv->private = (void *) s3vCreateScreen( sPriv );
 
@@ -27,7 +27,7 @@ s3vInitDriver(__DRIscreenPrivate *sPriv)
        return GL_FALSE;
     }
 
-    return GL_TRUE;
+   return NULL;
 }
 
 static void 
@@ -327,34 +327,14 @@ s3vUnbindContext( __DRIcontextPrivate *driContextPriv )
    return GL_TRUE;
 }
 
-
-static struct __DriverAPIRec s3vAPI = {
-   s3vInitDriver,
-   s3vDestroyScreen,
-   s3vCreateContext,
-   s3vDestroyContext,
-   s3vCreateBuffer,
-   s3vDestroyBuffer,
-   s3vSwapBuffers,
-   s3vMakeCurrent,
-   s3vUnbindContext,
+const struct __DriverAPIRec driDriverAPI = {
+   .InitScreen    = s3vInitScreen,
+   .DestroyScreen  = s3vDestroyScreen,
+   .CreateContext  = s3vCreateContext,
+   .DestroyContext = s3vDestroyContext,
+   .CreateBuffer   = s3vCreateBuffer,
+   .DestroyBuffer  = s3vDestroyBuffer,
+   .SwapBuffers           = s3vSwapBuffers,
+   .MakeCurrent           = s3vMakeCurrent,
+   .UnbindContext  = 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
index 00171253290e16bec356a1e412077e8c2e8a3a00..04c1bd6a34a061d10a07125f8a5b5f3f146bfae6 100644 (file)
@@ -168,16 +168,17 @@ static const struct tnl_pipeline_stage *savage_pipeline[] = {
 };
 
 
-/* this is first function called in dirver*/
+PUBLIC const __DRIextension *savageScreenExtensions[] = {
+    &driCoreExtension.base,
+    &driLegacyExtension.base,
+    &driReadDrawableExtension,
+};
 
 static GLboolean
 savageInitDriver(__DRIscreenPrivate *sPriv)
 {
   savageScreenPrivate *savageScreen;
   SAVAGEDRIPtr         gDRIPriv = (SAVAGEDRIPtr)sPriv->pDevPriv;
-   PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
-     (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
-
 
    if (sPriv->devPrivSize != sizeof(SAVAGEDRIRec)) {
       fprintf(stderr,"\nERROR!  sizeof(SAVAGEDRIRec) does not match passed size from device driver\n");
@@ -265,10 +266,7 @@ savageInitDriver(__DRIscreenPrivate *sPriv)
    driParseOptionInfo (&savageScreen->optionCache,
                       __driConfigOptions, __driNConfigOptions);
 
-   if (glx_enable_extension != NULL) {
-      (*glx_enable_extension)(sPriv->psc->screenConfigs,
-                             "GLX_SGI_make_current_read");
-   }
+   sPriv->extensions = savageScreenExtensions;
 
 #if 0
    savageDDFastPathInit();
@@ -295,34 +293,6 @@ savageDestroyScreen(__DRIscreenPrivate *sPriv)
    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,
@@ -525,7 +495,7 @@ savageCreateContext( const __GLcontextModes *mesaVis,
                                            "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) {
+   if (imesa->enable_fastpath && sPriv->drm_version.minor < 2) {
       fprintf (stderr,
               "*** Disabling fast path because your DRM version is buggy "
               "or doesn't\n*** support ELTS. You need at least Savage DRM "
@@ -732,7 +702,7 @@ void savageXMesaSetClipRects(savageContextPtr imesa)
    __DRIdrawablePrivate *dPriv = imesa->driDrawable;
 
    if ((dPriv->numBackClipRects == 0)
-       || (imesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT)) {
+       || (imesa->glCtx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT)) {
       imesa->numClipRects = dPriv->numClipRects;
       imesa->pClipRects = dPriv->pClipRects;
       imesa->drawX = dPriv->x;
@@ -917,32 +887,18 @@ void savageGetLock( savageContextPtr imesa, GLuint flags )
    }
 }
 
-
-
-static const struct __DriverAPIRec savageAPI = {
-   savageInitDriver,
-   savageDestroyScreen,
-   savageCreateContext,
-   savageDestroyContext,
-   savageCreateBuffer,
-   savageDestroyBuffer,
-   savageSwapBuffers,
-   savageMakeCurrent,
-   savageUnbindContext
-};
-
-
-static __GLcontextModes *
-savageFillInModes( unsigned pixel_bits, unsigned depth_bits,
+static const  __DRIconfig **
+savageFillInModes( __DRIscreenPrivate *psp,
+                  unsigned pixel_bits, unsigned depth_bits,
                   unsigned stencil_bits, GLboolean have_back_buffer )
 {
-    __GLcontextModes * modes;
+    __DRIconfig **configs;
     __GLcontextModes * m;
-    unsigned num_modes;
     unsigned depth_buffer_factor;
     unsigned back_buffer_factor;
     GLenum fb_format;
     GLenum fb_type;
+    int 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
@@ -973,8 +929,6 @@ savageFillInModes( unsigned pixel_bits, unsigned depth_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;
@@ -984,21 +938,11 @@ savageFillInModes( unsigned pixel_bits, unsigned depth_bits,
         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 ) ) {
+    configs = driCreateConfigs(fb_format, fb_type,
+                              depth_bits_array, stencil_bits_array,
+                              depth_buffer_factor,
+                              back_buffer_modes, back_buffer_factor);
+    if (configs == NULL) {
        fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
                 __func__, __LINE__ );
        return NULL;
@@ -1006,74 +950,68 @@ savageFillInModes( unsigned pixel_bits, unsigned depth_bits,
 
     /* 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) ) {
+    for (i = 0; configs[i]; i++) {
+       m = &configs[i]->modes;
+       if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
            m->visualRating = GLX_SLOW_CONFIG;
        }
     }
 
-    return modes;
+    return (const __DRIconfig **) configs;
 }
 
 
 /**
- * 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.
+ * This is the driver specific part of the createNewScreen entry point.
  * 
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on 
- *         failure.
+ * \todo maybe fold this into intelInitDriver
+ *
+ * \return the __GLcontextModes supported by this driver
  */
-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 )
-                            
+static const __DRIconfig **
+savageInitScreen(__DRIscreenPrivate *psp)
 {
-   __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;
+   SAVAGEDRIPtr dri_priv = (SAVAGEDRIPtr)psp->pDevPriv;
 
    if ( ! driCheckDriDdxDrmVersions2( "Savage",
-                                     dri_version, & dri_expected,
-                                     ddx_version, & ddx_expected,
-                                     drm_version, & drm_expected ) ) {
+                                     &psp->dri_version, & dri_expected,
+                                     &psp->ddx_version, & ddx_expected,
+                                     &psp->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;
+   /* 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 );
+
+   if (!savageInitDriver(psp))
+       return NULL;
+
+   return savageFillInModes( psp,
+                            dri_priv->cpp*8,
+                            (dri_priv->cpp == 2) ? 16 : 24,
+                            (dri_priv->cpp == 2) ? 0  : 8,
+                            (dri_priv->backOffset != dri_priv->depthOffset) );
 }
+
+const struct __DriverAPIRec driDriverAPI = {
+   savageInitScreen, 
+   savageDestroyScreen,
+   savageCreateContext,
+   savageDestroyContext,
+   savageCreateBuffer,
+   savageDestroyBuffer,
+   savageSwapBuffers,
+   savageMakeCurrent,
+   savageUnbindContext
+};
index 98629048aefa017b82105e55cd2412b2a48b87d2..639605cc5177ee7dc309257fd47161f7617dde67 100644 (file)
@@ -64,19 +64,19 @@ void savageSwapBuffers( __DRIdrawablePrivate *dPriv );
 
 extern void savageGetDMABuffer( savageContextPtr imesa );
 
-static __inline
+static INLINE
 void savageReleaseIndexedVerts( savageContextPtr imesa )
 {
     imesa->firstElt = -1;
 }
 
-static __inline
+static INLINE
 GLboolean savageHaveIndexedVerts( savageContextPtr imesa )
 {
     return (imesa->firstElt != -1);
 }
 
-static __inline
+static INLINE
 uint32_t *savageAllocVtxBuf( savageContextPtr imesa, GLuint words )
 {
    struct savage_vtxbuf_t *buffer = imesa->vtxBuf;
@@ -115,7 +115,7 @@ uint32_t *savageAllocVtxBuf( savageContextPtr imesa, GLuint words )
    return head;
 }
 
-static __inline
+static INLINE
 uint32_t *savageAllocIndexedVerts( savageContextPtr imesa, GLuint n )
 {
     uint32_t *ret;
@@ -131,7 +131,7 @@ uint32_t *savageAllocIndexedVerts( savageContextPtr imesa, GLuint n )
  * - Actually allocate entries for the indices in the command buffer.
  *   (This allocation must succeed without wrapping the cmd buffer!)
  */
-static __inline
+static INLINE
 void savageFlushElts( savageContextPtr imesa )
 {
     if (imesa->elts.cmd) {
@@ -148,7 +148,7 @@ void savageFlushElts( savageContextPtr imesa )
 /* Allocate a command buffer entry with <bytes> bytes of arguments:
  * - implies savageFlushElts
  */
-static __inline
+static INLINE
 drm_savage_cmd_header_t *savageAllocCmdBuf( savageContextPtr imesa, GLuint bytes )
 {
     drm_savage_cmd_header_t *ret;
@@ -171,7 +171,7 @@ drm_savage_cmd_header_t *savageAllocCmdBuf( savageContextPtr imesa, GLuint bytes
  *   incomplete indexed drawing command yet
  * - increments the number of elts. Final allocation is done in savageFlushElts
  */
-static __inline
+static INLINE
 uint16_t *savageAllocElts( savageContextPtr imesa, GLuint n )
 {
     uint16_t *ret;
index 514434c427177e08ef80f6f43d53f2725024c97f..f2f19984b13cb08023f68047e1f2153a222f3703 100644 (file)
@@ -198,7 +198,7 @@ static GLboolean savage_run_render( GLcontext *ctx,
 
    for (i = 0 ; i < VB->PrimitiveCount ; i++)
    {
-      GLuint prim = VB->Primitive[i].mode;
+      GLuint prim = _tnl_translate_prim(&VB->Primitive[i]);
       GLuint start = VB->Primitive[i].start;
       GLuint length = VB->Primitive[i].count;
 
index 61ab9e6d64a7a7736ef3695be75cfe820eb2d9e4..00fd1259fd6fcee3e18cf041c0613808b3653922 100644 (file)
@@ -93,6 +93,8 @@
 /* 16 bit integer depthbuffer functions
  * Depth range is reversed. See also savageCalcViewport.
  */
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d ) \
     *(GLushort *)(buf + ((_x)<<1) + (_y)*pitch) = 0xFFFF - d
 
 
 /* 16 bit float depthbuffer functions
  */
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d ) \
     *(GLushort *)(buf + ((_x)<<1) + (_y)*pitch) = \
         savageEncodeFloat16( 1.0 - (GLfloat)d/65535.0 )
 /* 8-bit stencil /24-bit integer depth depthbuffer functions.
  * Depth range is reversed. See also savageCalcViewport.
  */
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d ) do {                          \
    GLuint tmp = *(GLuint *)(buf + ((_x)<<2) + (_y)*pitch);     \
    tmp &= 0xFF000000;                                          \
 
 /* 24 bit float depthbuffer functions
  */
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d ) do {                          \
     GLuint tmp = *(GLuint *)(buf + ((_x)<<2) + (_y)*pitch);    \
     tmp &= 0xFF000000;                                         \
index f6a312e820e378e73f63252831e7b0145582eb41..53a7f8b97c8679a62960735e93cfe8fda807c4d6 100644 (file)
@@ -55,7 +55,7 @@ savageSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis,
  *
  * Note that there is no encoding for numbers < 2^-16.
  */
-static __inline GLuint savageEncodeFloat16( GLdouble x )
+static INLINE GLuint savageEncodeFloat16( GLdouble x )
 {
     GLint r = (GLint)(x * 0x10000000);
     GLint exp = 0;
@@ -67,7 +67,7 @@ static __inline GLuint savageEncodeFloat16( GLdouble x )
     }
     return exp > 0xf ? 0xffff : (r - 0x1000) | (exp << 12);
 }
-static __inline GLdouble savageDecodeFloat16( GLuint x )
+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),
@@ -92,7 +92,7 @@ static __inline GLdouble savageDecodeFloat16( GLuint x )
  *
  * Details analogous to the 16-bit format.
  */
-static __inline GLuint savageEncodeFloat24( GLdouble x )
+static INLINE GLuint savageEncodeFloat24( GLdouble x )
 {
     int64_t r = (int64_t)(x * ((int64_t)1 << (19+32)));
     GLint exp = 0;
@@ -105,7 +105,7 @@ static __inline GLuint savageEncodeFloat24( GLdouble x )
     return exp > 0x1f ? 0xffffff : (r - 0x80000) | (exp << 19);
 }
 #define _1 (int64_t)1
-static __inline GLdouble savageDecodeFloat24( GLuint x )
+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),
index 84fd3157edfb0dfbeab4d1c7149f1184a3dd24ed..ceef34c03ecf2d2ee9df8b4ec770e06ce6e06fae 100644 (file)
@@ -76,7 +76,7 @@
 static void savageBlendFunc_s4(GLcontext *);
 static void savageBlendFunc_s3d(GLcontext *);
 
-static __inline__ GLuint savagePackColor(GLuint format, 
+static INLINE GLuint savagePackColor(GLuint format, 
                                          GLubyte r, GLubyte g, 
                                          GLubyte b, GLubyte a)
 {
@@ -640,15 +640,17 @@ static void savageDDDrawBuffer(GLcontext *ctx, GLenum mode )
     savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
     uint32_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:
+    if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) {
+       FALLBACK( ctx, SAVAGE_FALLBACK_DRAW_BUFFER, GL_TRUE );
+        return;
+    }
+
+    switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) {
+    case BUFFER_FRONT_LEFT:
         imesa->IsDouble = GL_FALSE;
        imesa->regs.s4.destCtrl.ni.offset = imesa->savageScreen->frontOffset>>11;
        break;
-    case BUFFER_BIT_BACK_LEFT:
+    case BUFFER_BACK_LEFT:
         imesa->IsDouble = GL_TRUE;
        imesa->regs.s4.destCtrl.ni.offset = imesa->savageScreen->backOffset>>11;
        break;
index dbe30d4c947715d62dd96450d723dd3e54465d4f..1d4bfa53ca0925b64440d32076cb436e674cc8ec 100644 (file)
@@ -101,7 +101,7 @@ static const savageTileInfo tileInfo_s3d_s4[5] = {
  * \param w   width in bytes
  */
 #define SUBTILE_FUNC(w,h)                                      \
-static __inline GLubyte *savageUploadSubtile_##w##x##h         \
+static INLINE GLubyte *savageUploadSubtile_##w##x##h           \
 (GLubyte *dest, GLubyte *src, GLuint srcStride)                        \
 {                                                              \
     GLuint y;                                                  \
@@ -1016,7 +1016,7 @@ static void savageUploadTexImages( savageContextPtr imesa, savageTexObjPtr t )
       /* 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) {
+      if (imesa->savageScreen->driScrnPriv->drm_version.minor >= 3) {
          unsigned int heap = t->base.heap->heapId;
          LOCK_HARDWARE(imesa);
          savageWaitEvent (imesa, imesa->textureHeaps[heap]->timestamp);
@@ -1713,7 +1713,7 @@ static void savageTimestampTextures( savageContextPtr imesa )
     * 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) {
+       imesa->savageScreen->driScrnPriv->drm_version.minor >= 3) {
        unsigned int e;
        FLUSH_BATCH(imesa);
        e = savageEmitEvent(imesa, SAVAGE_WAIT_3D);
index a1c7bb167e7c02c3454f7a86c89eb2eaf64847de..39b74285f11b8f023c39437f4847d60f3a3e4fa3 100644 (file)
@@ -95,7 +95,7 @@ do {                                          \
 } while (0)
 #endif
 
-static void __inline__ savage_draw_triangle (savageContextPtr imesa,
+static void INLINE savage_draw_triangle (savageContextPtr imesa,
                                             savageVertexPtr v0,
                                             savageVertexPtr v1,
                                             savageVertexPtr v2) {
@@ -108,7 +108,7 @@ static void __inline__ savage_draw_triangle (savageContextPtr imesa,
    EMIT_VERT (j, vb, vertsize, 0, v2);
 }
 
-static void __inline__ savage_draw_quad (savageContextPtr imesa,
+static void INLINE savage_draw_quad (savageContextPtr imesa,
                                         savageVertexPtr v0,
                                         savageVertexPtr v1,
                                         savageVertexPtr v2,
@@ -125,7 +125,7 @@ static void __inline__ savage_draw_quad (savageContextPtr imesa,
    EMIT_VERT (j, vb, vertsize, 0, v3);
 }
 
-static __inline__ void savage_draw_point (savageContextPtr imesa,
+static INLINE void savage_draw_point (savageContextPtr imesa,
                                          savageVertexPtr tmp) {
    GLuint vertsize = imesa->HwVertexSize;
    uint32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize);
@@ -161,7 +161,7 @@ static __inline__ void savage_draw_point (savageContextPtr imesa,
    EMIT_VERT (j, vb, vertsize, 2, tmp);
 }
 
-static __inline__ void savage_draw_line (savageContextPtr imesa,
+static INLINE void savage_draw_line (savageContextPtr imesa,
                                         savageVertexPtr v0,
                                         savageVertexPtr v1 ) {
    GLuint vertsize = imesa->HwVertexSize;
@@ -219,7 +219,7 @@ do {                                                        \
    tmp.f[vertex_size-1] *= rhw;                                \
 } while (0)
 
-static void __inline__ savage_ptex_tri (savageContextPtr imesa,
+static void INLINE savage_ptex_tri (savageContextPtr imesa,
                                        savageVertexPtr v0,
                                        savageVertexPtr v1,
                                        savageVertexPtr v2) {
@@ -233,7 +233,7 @@ static void __inline__ savage_ptex_tri (savageContextPtr imesa,
    PTEX_VERTEX (j, tmp, vertsize, 0, v2); EMIT_VERT (j, vb, vertsize, 0, &tmp);
 }
 
-static __inline__ void savage_ptex_line (savageContextPtr imesa,
+static INLINE void savage_ptex_line (savageContextPtr imesa,
                                         savageVertexPtr v0,
                                         savageVertexPtr v1 ) {
    GLuint vertsize = imesa->HwVertexSize;
@@ -281,7 +281,7 @@ static __inline__ void savage_ptex_line (savageContextPtr imesa,
    EMIT_VERT (j, vb, vertsize, 2, &tmp1);
 } 
 
-static __inline__ void savage_ptex_point (savageContextPtr imesa,
+static INLINE void savage_ptex_point (savageContextPtr imesa,
                                          savageVertexPtr v0) {
    GLuint vertsize = imesa->HwVertexSize;
    uint32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize);
@@ -934,7 +934,7 @@ do {                                                                        \
 #define SAVAGE_EMIT_ST1  0x0300
 
 
-static __inline__ GLuint savageChooseVertexFormat_s3d( GLcontext *ctx )
+static INLINE GLuint savageChooseVertexFormat_s3d( GLcontext *ctx )
 {
    savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
@@ -997,7 +997,7 @@ static __inline__ GLuint savageChooseVertexFormat_s3d( GLcontext *ctx )
 }
 
 
-static __inline__ GLuint savageChooseVertexFormat_s4( GLcontext *ctx )
+static INLINE GLuint savageChooseVertexFormat_s4( GLcontext *ctx )
 {
    savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
index 08402fb3e2a5d6c7bb1b654b5b35b59f82b5e43a..e47e663c35870bba1d652f26a44451911043e75f 100644 (file)
@@ -497,25 +497,27 @@ void sis6326DDDrawBuffer( GLcontext *ctx, GLenum mode )
    __GLSiSHardware *current = &smesa->current;
 
    if(getenv("SIS_DRAW_FRONT"))
-      ctx->DrawBuffer->_ColorDrawBufferMask[0] = GL_FRONT_LEFT;
+      ctx->DrawBuffer->_ColorDrawBufferIndexes[0] = BUFFER_FRONT_LEFT;
+
+   if (ctx->DrawBuffer->_NumColorDrawBuffers > 1) {
+      FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_TRUE );
+      return;
+   }
 
-   /*
-    * _DrawDestMask is easier to cope with than <mode>.
-    */
    current->hwDstSet &= ~MASK_DstBufferPitch;
-   switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
-   case BUFFER_BIT_FRONT_LEFT:
+
+   switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) {
+   case BUFFER_FRONT_LEFT:
       current->hwOffsetDest = smesa->front.offset;
       current->hwDstSet |= smesa->front.pitch;
       FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE );
       break;
-   case BUFFER_BIT_BACK_LEFT:
+   case BUFFER_BACK_LEFT:
       current->hwOffsetDest = smesa->back.offset;
       current->hwDstSet |= smesa->back.pitch;
       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;
    }
index b81812d6cec102bcd6d4644033dcd50f890bb488..895e4ab08d2147b1d3f314b0f18a7541cf1f0f0a 100644 (file)
@@ -400,8 +400,10 @@ struct sis_context
 #define MMIO_READ(reg) *(volatile GLint *)(smesa->IOBase + (reg))
 #define MMIO_READf(reg) *(volatile GLfloat *)(smesa->IOBase + (reg))
 
-#if defined(__i386__) || defined(__amd64__)
+#if defined(__i386__) || defined(__x86_64__)
 #define MMIO_WMB()     __asm __volatile("" : : : "memory")
+#elif defined(__ia64__)
+#define MMIO_WMB()     __asm __volatile("mf" : : : "memory")
 #else
 #error platform needs WMB
 #endif
index f55027e0945482a895f357c4d78fa2e62a6ada21..5888996af901957550a0285ee927cd041a53a763 100644 (file)
@@ -64,12 +64,10 @@ static const GLuint __driNConfigOptions = 3;
 
 extern const struct dri_extension card_extensions[];
 
-static __GLcontextModes *
-sisFillInModes(int bpp)
+static const __DRIconfig **
+sisFillInModes(__DRIscreenPrivate *psp, int bpp)
 {
-   __GLcontextModes *modes;
-   __GLcontextModes *m;
-   unsigned num_modes;
+   __DRIconfig **configs;
    unsigned depth_buffer_factor;
    unsigned back_buffer_factor;
    GLenum fb_format;
@@ -92,9 +90,6 @@ sisFillInModes(int bpp)
    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;
@@ -103,25 +98,15 @@ sisFillInModes(int bpp)
       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)) {
+   configs = driCreateConfigs(fb_format, fb_type, depth_bits_array,
+                             stencil_bits_array, depth_buffer_factor,
+                             back_buffer_modes, back_buffer_factor);
+   if (configs == NULL) {
       fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, __LINE__);
       return NULL;
    }
 
-   return modes;
+   return (const __DRIconfig **) configs;
 }
 
 
@@ -287,23 +272,52 @@ sisSwapBuffers(__DRIdrawablePrivate *dPriv)
 }
 
 
-/* Initialize the driver specific screen private data.
+/**
+ * This is the driver specific part of the createNewScreen entry point.
+ * 
+ * \todo maybe fold this into intelInitDriver
+ *
+ * \return the __GLcontextModes supported by this driver
  */
-static GLboolean
-sisInitDriver( __DRIscreenPrivate *sPriv )
+static const __DRIconfig **
+sisInitScreen(__DRIscreenPrivate *psp)
 {
-   sPriv->private = (void *) sisCreateScreen( sPriv );
+   static const __DRIversion ddx_expected = {0, 8, 0};
+   static const __DRIversion dri_expected = {4, 0, 0};
+   static const __DRIversion drm_expected = {1, 0, 0};
+   static const char *driver_name = "SiS";
+   SISDRIPtr dri_priv = (SISDRIPtr)psp->pDevPriv;
 
-   if ( !sPriv->private ) {
-      sisDestroyScreen( sPriv );
-      return GL_FALSE;
+   if (!driCheckDriDdxDrmVersions2(driver_name,
+                                  &psp->dri_version, &dri_expected,
+                                  &psp->ddx_version, &ddx_expected,
+                                  &psp->drm_version, &drm_expected))
+      return NULL;
+
+   /* 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 );
+
+   psp->private = sisCreateScreen(psp);
+
+   if (!psp->private) {
+      sisDestroyScreen(psp);
+      return NULL;
    }
 
-   return GL_TRUE;
+   return sisFillInModes(psp, dri_priv->bytesPerPixel * 8);
 }
 
-static struct __DriverAPIRec sisAPI = {
-   .InitDriver      = sisInitDriver,
+const struct __DriverAPIRec driDriverAPI = {
+   .InitScreen      = sisInitScreen,
    .DestroyScreen   = sisDestroyScreen,
    .CreateContext   = sisCreateContext,
    .DestroyContext  = sisDestroyContext,
@@ -313,69 +327,9 @@ static struct __DriverAPIRec sisAPI = {
    .MakeCurrent     = sisMakeCurrent,
    .UnbindContext   = sisUnbindContext,
    .GetSwapInfo     = NULL,
-   .GetMSC          = NULL,
+   .GetDrawableMSC  = 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};
-   static const char *driver_name = "SiS";
-   dri_interface = interface;
-
-   if (!driCheckDriDdxDrmVersions2(driver_name, 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;
-}
index dc50bda877b96e821039ceb1ff688a245cc82a73..9e9a509755d8090577877ad26338fdeaa802fe5f 100644 (file)
@@ -84,6 +84,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 /* 16 bit depthbuffer functions.
  */
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d )       \
    *(GLushort *)(buf + (_x)*2 + (_y)*srb->pitch) = d;
 
@@ -96,6 +98,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 /* 32 bit depthbuffer functions.
  */
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d )       \
    *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) = d;
 
@@ -108,6 +112,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 /* 8/24 bit interleaved depth/stencil functions
  */
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d ) {                             \
    GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch);   \
    tmp &= 0xff000000;                                          \
index 305c63f73f7e781fbd7d0d7e11fb22b9c44b2e17..cb672c2c7ce4dc524d1933ff317989e9b4e1ddcf 100644 (file)
@@ -546,23 +546,24 @@ void sisDDDrawBuffer( GLcontext *ctx, GLenum mode )
    __GLSiSHardware *prev = &smesa->prev;
    __GLSiSHardware *current = &smesa->current;
 
-   /*
-    * _DrawDestMask is easier to cope with than <mode>.
-    */
+   if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) {
+      FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_TRUE );
+      return;
+   }
+
    current->hwDstSet &= ~MASK_DstBufferPitch;
-   switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
-   case BUFFER_BIT_FRONT_LEFT:
+   switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) {
+   case BUFFER_FRONT_LEFT:
       FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE );
       current->hwOffsetDest = smesa->front.offset >> 1;
       current->hwDstSet |= smesa->front.pitch >> 2;
       break;
-   case BUFFER_BIT_BACK_LEFT:
+   case BUFFER_BACK_LEFT:
       FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE );
       current->hwOffsetDest = smesa->back.offset >> 1;
       current->hwDstSet |= smesa->back.pitch >> 2;
       break;
    default:
-      /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
       FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_TRUE );
       return;
    }
index 5e10c610f809723afff80df503968f4c6ff90cdc..a98dfa3ec3b01fa1a485a681748d25f635051b9a 100644 (file)
@@ -129,6 +129,8 @@ sisAllocTexImage( sisContextPtr smesa, sisTexObjPtr t, int level,
 static void
 sisFreeTexImage( sisContextPtr smesa, sisTexObjPtr t, int level )
 {
+   assert(level >= 0);
+   assert(level < SIS_MAX_TEXTURE_LEVELS);
    if (t->image[level].Data == NULL)
       return;
 
@@ -212,7 +214,7 @@ sisDeleteTexture( GLcontext * ctx, struct gl_texture_object *texObj )
        */
       return;
    }
-   for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
+   for (i = 0; i < SIS_MAX_TEXTURE_LEVELS; i++) {
       sisFreeTexImage( smesa, t, i );
    }
 
index a0e39dcd3c9abd9cadf0cef2d96c82599b609a0b..adbbb8ae13735c0013e069b056463dce486ef1e1 100644 (file)
@@ -848,7 +848,7 @@ static void sisRenderStart( GLcontext *ctx )
 
    RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset );
 
-   if (ctx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT && 
+   if (ctx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT && 
       smesa->driDrawable->numClipRects != 0)
    {
       multipass_cliprect(ctx, 0);
index 499eb4d24d4e86b3b0e296e17c8973fc02cf2398..7ee276c66ea009c41ca0c1228d795e3443b32f22 100644 (file)
@@ -47,7 +47,7 @@ do {                                                  \
       sisFlushPrims(smesa);                            \
 } while (0)
 
-static __inline GLuint *sisAllocDmaLow(sisContextPtr smesa, int bytes)
+static INLINE GLuint *sisAllocDmaLow(sisContextPtr smesa, int bytes)
 {
    GLuint *start;
 
index e670a5bf760938bc7c95f21b15a91e048c126c2b..f75e17318fc873bf702caa97299bcaa83c5e656d 100644 (file)
@@ -234,7 +234,7 @@ static void TAG(sis6326_draw_point_mmio)(sisContextPtr smesa, char *verts)
 }
 #endif
 
-static __inline void TAG(sis_vert_init)( void )
+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);
diff --git a/src/mesa/drivers/dri/swrast/Makefile b/src/mesa/drivers/dri/swrast/Makefile
new file mode 100644 (file)
index 0000000..5f3a4f2
--- /dev/null
@@ -0,0 +1,24 @@
+# src/mesa/drivers/dri/swrast/Makefile
+
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = swrast_dri.so
+
+DRIVER_SOURCES = \
+       swrast.c \
+       swrast_span.c
+
+C_SOURCES = \
+       $(SWRAST_COMMON_SOURCES) \
+       $(DRIVER_SOURCES)
+
+ASM_SOURCES =
+
+SWRAST_COMMON_SOURCES = \
+       ../../common/driverfuncs.c \
+       ../common/utils.c
+
+include ../Makefile.template
+
+symlinks:
diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c
new file mode 100644 (file)
index 0000000..304d077
--- /dev/null
@@ -0,0 +1,730 @@
+/*
+ * Copyright (C) 2008 George Sapountzis <gsap7@yahoo.gr>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * DRI software rasterizer
+ *
+ * This is the mesa swrast module packaged into a DRI driver structure.
+ *
+ * The front-buffer is allocated by the loader. The loader provides read/write
+ * callbacks for access to the front-buffer. The driver uses a scratch row for
+ * front-buffer rendering to avoid repeated calls to the loader.
+ *
+ * The back-buffer is allocated by the driver and is private.
+ */
+
+#include "context.h"
+#include "extensions.h"
+#include "framebuffer.h"
+#include "imports.h"
+#include "renderbuffer.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 "vbo/vbo.h"
+#include "drivers/common/driverfuncs.h"
+#include "utils.h"
+
+#include "swrast_priv.h"
+
+
+#define need_GL_VERSION_1_3
+#define need_GL_VERSION_1_4
+#define need_GL_VERSION_1_5
+#define need_GL_VERSION_2_0
+#define need_GL_VERSION_2_1
+
+/* sw extensions for imaging */
+#define need_GL_EXT_blend_color
+#define need_GL_EXT_blend_minmax
+#define need_GL_EXT_convolution
+#define need_GL_EXT_histogram
+#define need_GL_SGI_color_table
+
+/* sw extensions not associated with some GL version */
+#define need_GL_ARB_shader_objects
+#define need_GL_ARB_vertex_program
+#define need_GL_APPLE_vertex_array_object
+#define need_GL_ATI_fragment_shader
+#define need_GL_EXT_depth_bounds_test
+#define need_GL_EXT_framebuffer_object
+#define need_GL_EXT_framebuffer_blit
+#define need_GL_EXT_gpu_program_parameters
+#define need_GL_EXT_paletted_texture
+#define need_GL_IBM_multimode_draw_arrays
+#define need_GL_MESA_resize_buffers
+#define need_GL_NV_vertex_program
+#define need_GL_NV_fragment_program
+
+#include "extension_helper.h"
+
+const struct dri_extension card_extensions[] =
+{
+    { "GL_VERSION_1_3",                        GL_VERSION_1_3_functions },
+    { "GL_VERSION_1_4",                        GL_VERSION_1_4_functions },
+    { "GL_VERSION_1_5",                        GL_VERSION_1_5_functions },
+    { "GL_VERSION_2_0",                        GL_VERSION_2_0_functions },
+    { "GL_VERSION_2_1",                        GL_VERSION_2_1_functions },
+
+    { "GL_EXT_blend_color",            GL_EXT_blend_color_functions },
+    { "GL_EXT_blend_minmax",           GL_EXT_blend_minmax_functions },
+    { "GL_EXT_convolution",            GL_EXT_convolution_functions },
+    { "GL_EXT_histogram",              GL_EXT_histogram_functions },
+    { "GL_SGI_color_table",            GL_SGI_color_table_functions },
+
+    { "GL_ARB_shader_objects",         GL_ARB_shader_objects_functions },
+    { "GL_ARB_vertex_program",         GL_ARB_vertex_program_functions },
+    { "GL_APPLE_vertex_array_object",  GL_APPLE_vertex_array_object_functions },
+    { "GL_ATI_fragment_shader",                GL_ATI_fragment_shader_functions },
+    { "GL_EXT_depth_bounds_test",      GL_EXT_depth_bounds_test_functions },
+    { "GL_EXT_framebuffer_object",     GL_EXT_framebuffer_object_functions },
+    { "GL_EXT_framebuffer_blit",       GL_EXT_framebuffer_blit_functions },
+    { "GL_EXT_gpu_program_parameters", GL_EXT_gpu_program_parameters_functions },
+    { "GL_EXT_paletted_texture",       GL_EXT_paletted_texture_functions },
+    { "GL_IBM_multimode_draw_arrays",  GL_IBM_multimode_draw_arrays_functions },
+    { "GL_MESA_resize_buffers",                GL_MESA_resize_buffers_functions },
+    { "GL_NV_vertex_program",          GL_NV_vertex_program_functions },
+    { "GL_NV_fragment_program",                GL_NV_fragment_program_functions },
+    { NULL,                            NULL }
+};
+
+
+/**
+ * Screen and config-related functions
+ */
+
+static void
+setupLoaderExtensions(__DRIscreen *psp,
+                     const __DRIextension **extensions)
+{
+    int i;
+
+    for (i = 0; extensions[i]; i++) {
+       if (strcmp(extensions[i]->name, __DRI_SWRAST_LOADER) == 0)
+           psp->swrast_loader = (__DRIswrastLoaderExtension *) extensions[i];
+    }
+}
+
+static __DRIconfig **
+swrastFillInModes(__DRIscreen *psp,
+                 unsigned pixel_bits, unsigned depth_bits,
+                 unsigned stencil_bits, GLboolean have_back_buffer)
+{
+    __DRIconfig **configs;
+    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
+    };
+
+    u_int8_t depth_bits_array[4];
+    u_int8_t stencil_bits_array[4];
+
+    depth_bits_array[0] = 0;
+    depth_bits_array[1] = 0;
+    depth_bits_array[2] = depth_bits;
+    depth_bits_array[3] = depth_bits;
+
+    /* Just like with the accumulation buffer, always provide some modes
+     * with a stencil buffer.
+     */
+    stencil_bits_array[0] = 0;
+    stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits;
+    stencil_bits_array[2] = 0;
+    stencil_bits_array[3] = (stencil_bits == 0) ? 8 : stencil_bits;
+
+    depth_buffer_factor = 4;
+    back_buffer_factor = 2;
+
+    if (pixel_bits == 8) {
+       fb_format = GL_RGB;
+       fb_type = GL_UNSIGNED_BYTE_2_3_3_REV;
+    }
+    else 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;
+    }
+
+    configs = driCreateConfigs(fb_format, fb_type,
+                              depth_bits_array, stencil_bits_array,
+                              depth_buffer_factor, back_buffer_modes,
+                              back_buffer_factor);
+    if (configs == NULL) {
+       fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
+               __LINE__);
+       return NULL;
+    }
+
+    return configs;
+}
+
+static __DRIscreen *
+driCreateNewScreen(int scrn, const __DRIextension **extensions,
+                  const __DRIconfig ***driver_configs, void *data)
+{
+    static const __DRIextension *emptyExtensionList[] = { NULL };
+    __DRIscreen *psp;
+    __DRIconfig **configs8, **configs16, **configs32;
+
+    (void) data;
+
+    TRACE;
+
+    psp = _mesa_calloc(sizeof(*psp));
+    if (!psp)
+       return NULL;
+
+    setupLoaderExtensions(psp, extensions);
+
+    psp->num = scrn;
+    psp->extensions = emptyExtensionList;
+
+    configs8  = swrastFillInModes(psp,  8,  8, 0, 1);
+    configs16 = swrastFillInModes(psp, 16, 16, 0, 1);
+    configs32 = swrastFillInModes(psp, 32, 24, 8, 1);
+
+    configs16 = (__DRIconfig **)driConcatConfigs(configs8, configs16);
+
+    *driver_configs = driConcatConfigs(configs16, configs32);
+
+    driInitExtensions( NULL, card_extensions, GL_FALSE );
+
+    return psp;
+}
+
+static void driDestroyScreen(__DRIscreen *psp)
+{
+    TRACE;
+
+    if (psp) {
+       _mesa_free(psp);
+    }
+}
+
+static const __DRIextension **driGetExtensions(__DRIscreen *psp)
+{
+    TRACE;
+
+    return psp->extensions;
+}
+
+
+/**
+ * Framebuffer and renderbuffer-related functions.
+ */
+
+static GLuint
+choose_pixel_format(const GLvisual *v)
+{
+    if (v->rgbMode) {
+       int bpp = v->rgbBits;
+
+       if (bpp == 32
+           && v->redMask   == 0xff0000
+           && v->greenMask == 0x00ff00
+           && v->blueMask  == 0x0000ff)
+           return PF_A8R8G8B8;
+       else if (bpp == 16
+           && v->redMask   == 0xf800
+           && v->greenMask == 0x07e0
+           && v->blueMask  == 0x001f)
+           return PF_R5G6B5;
+       else if (bpp == 8
+           && v->redMask   == 0x07
+           && v->greenMask == 0x38
+           && v->blueMask  == 0xc0)
+           return PF_R3G3B2;
+    }
+    else {
+       if (v->indexBits == 8)
+           return PF_CI8;
+    }
+
+    _mesa_problem( NULL, "unexpected format in %s", __FUNCTION__ );
+    return 0;
+}
+
+static void
+swrast_delete_renderbuffer(struct gl_renderbuffer *rb)
+{
+    TRACE;
+
+    _mesa_free(rb->Data);
+    _mesa_free(rb);
+}
+
+static GLboolean
+swrast_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
+                          GLenum internalFormat, GLuint width, GLuint height)
+{
+    struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
+    int bpp;
+    unsigned mask = PITCH_ALIGN_BITS - 1;
+
+    TRACE;
+
+    rb->Data = NULL;
+    rb->Width = width;
+    rb->Height = height;
+
+    switch (internalFormat) {
+    case GL_RGB:
+       bpp = rb->RedBits + rb->GreenBits + rb->BlueBits;
+       break;
+    case GL_RGBA:
+       bpp = rb->RedBits + rb->GreenBits + rb->BlueBits + rb->AlphaBits;
+       break;
+    case GL_COLOR_INDEX8_EXT:
+       bpp = rb->IndexBits;
+       break;
+    default:
+       _mesa_problem( NULL, "unexpected format in %s", __FUNCTION__ );
+       return GL_FALSE;
+    }
+
+    /* always pad to PITCH_ALIGN_BITS */
+    xrb->pitch = ((width * bpp + mask) & ~mask) / 8;
+
+    return GL_TRUE;
+}
+
+static GLboolean
+swrast_alloc_back_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
+                         GLenum internalFormat, GLuint width, GLuint height)
+{
+    struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
+
+    TRACE;
+
+    _mesa_free(rb->Data);
+
+    swrast_alloc_front_storage(ctx, rb, internalFormat, width, height);
+
+    rb->Data = _mesa_malloc(height * xrb->pitch);
+
+    return GL_TRUE;
+}
+
+static struct swrast_renderbuffer *
+swrast_new_renderbuffer(const GLvisual *visual, GLboolean front)
+{
+    struct swrast_renderbuffer *xrb = _mesa_calloc(sizeof *xrb);
+    GLuint pixel_format;
+
+    TRACE;
+
+    if (!xrb)
+       return NULL;
+
+    _mesa_init_renderbuffer(&xrb->Base, 0);
+
+    pixel_format = choose_pixel_format(visual);
+
+    xrb->Base.Delete = swrast_delete_renderbuffer;
+    if (front) {
+       xrb->Base.AllocStorage = swrast_alloc_front_storage;
+       swrast_set_span_funcs_front(xrb, pixel_format);
+    }
+    else {
+       xrb->Base.AllocStorage = swrast_alloc_back_storage;
+       swrast_set_span_funcs_back(xrb, pixel_format);
+    }
+
+    switch (pixel_format) {
+    case PF_A8R8G8B8:
+       xrb->Base.InternalFormat = GL_RGBA;
+       xrb->Base._BaseFormat = GL_RGBA;
+       xrb->Base.DataType = GL_UNSIGNED_BYTE;
+       xrb->Base.RedBits   = 8 * sizeof(GLubyte);
+       xrb->Base.GreenBits = 8 * sizeof(GLubyte);
+       xrb->Base.BlueBits  = 8 * sizeof(GLubyte);
+       xrb->Base.AlphaBits = 8 * sizeof(GLubyte);
+       break;
+    case PF_R5G6B5:
+       xrb->Base.InternalFormat = GL_RGB;
+       xrb->Base._BaseFormat = GL_RGB;
+       xrb->Base.DataType = GL_UNSIGNED_BYTE;
+       xrb->Base.RedBits   = 5 * sizeof(GLubyte);
+       xrb->Base.GreenBits = 6 * sizeof(GLubyte);
+       xrb->Base.BlueBits  = 5 * sizeof(GLubyte);
+       xrb->Base.AlphaBits = 0;
+       break;
+    case PF_R3G3B2:
+       xrb->Base.InternalFormat = GL_RGB;
+       xrb->Base._BaseFormat = GL_RGB;
+       xrb->Base.DataType = GL_UNSIGNED_BYTE;
+       xrb->Base.RedBits   = 3 * sizeof(GLubyte);
+       xrb->Base.GreenBits = 3 * sizeof(GLubyte);
+       xrb->Base.BlueBits  = 2 * sizeof(GLubyte);
+       xrb->Base.AlphaBits = 0;
+       break;
+    case PF_CI8:
+       xrb->Base.InternalFormat = GL_COLOR_INDEX8_EXT;
+       xrb->Base._BaseFormat = GL_COLOR_INDEX;
+       xrb->Base.DataType = GL_UNSIGNED_BYTE;
+       xrb->Base.IndexBits = 8 * sizeof(GLubyte);
+       break;
+    default:
+       return NULL;
+    }
+
+    return xrb;
+}
+
+static __DRIdrawable *
+driCreateNewDrawable(__DRIscreen *screen,
+                    const __DRIconfig *config, void *data)
+{
+    __DRIdrawable *buf;
+    struct swrast_renderbuffer *frontrb, *backrb;
+
+    TRACE;
+
+    buf = _mesa_calloc(sizeof *buf);
+    if (!buf)
+       return NULL;
+
+    buf->loaderPrivate = data;
+
+    buf->driScreenPriv = screen;
+
+    buf->row = _mesa_malloc(MAX_WIDTH * 4);
+
+    /* basic framebuffer setup */
+    _mesa_initialize_framebuffer(&buf->Base, &config->modes);
+
+    /* add front renderbuffer */
+    frontrb = swrast_new_renderbuffer(&config->modes, GL_TRUE);
+    _mesa_add_renderbuffer(&buf->Base, BUFFER_FRONT_LEFT, &frontrb->Base);
+
+    /* add back renderbuffer */
+    if (config->modes.doubleBufferMode) {
+       backrb = swrast_new_renderbuffer(&config->modes, GL_FALSE);
+       _mesa_add_renderbuffer(&buf->Base, BUFFER_BACK_LEFT, &backrb->Base);
+    }
+
+    /* add software renderbuffers */
+    _mesa_add_soft_renderbuffers(&buf->Base,
+                                GL_FALSE, /* color */
+                                config->modes.haveDepthBuffer,
+                                config->modes.haveStencilBuffer,
+                                config->modes.haveAccumBuffer,
+                                GL_FALSE, /* alpha */
+                                GL_FALSE /* aux bufs */);
+
+    return buf;
+}
+
+static void
+driDestroyDrawable(__DRIdrawable *buf)
+{
+    TRACE;
+
+    if (buf) {
+       struct gl_framebuffer *fb = &buf->Base;
+
+       _mesa_free(buf->row);
+
+       fb->DeletePending = GL_TRUE;
+       _mesa_unreference_framebuffer(&fb);
+    }
+}
+
+static void driSwapBuffers(__DRIdrawable *buf)
+{
+    GET_CURRENT_CONTEXT(ctx);
+
+    struct swrast_renderbuffer *frontrb =
+       swrast_renderbuffer(buf->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
+    struct swrast_renderbuffer *backrb =
+       swrast_renderbuffer(buf->Base.Attachment[BUFFER_BACK_LEFT].Renderbuffer);
+
+    __DRIscreen *screen = buf->driScreenPriv;
+
+    TRACE;
+
+    /* check for signle-buffered */
+    if (backrb == NULL)
+       return;
+
+    /* check if swapping currently bound buffer */
+    if (ctx && ctx->DrawBuffer == &(buf->Base)) {
+       /* flush pending rendering */
+       _mesa_notifySwapBuffers(ctx);
+    }
+
+    screen->swrast_loader->putImage(buf, __DRI_SWRAST_IMAGE_OP_SWAP,
+                                   0, 0,
+                                   frontrb->Base.Width,
+                                   frontrb->Base.Height,
+                                   backrb->Base.Data,
+                                   buf->loaderPrivate);
+}
+
+
+/**
+ * General device driver functions.
+ */
+
+static void
+get_window_size( GLframebuffer *fb, GLsizei *w, GLsizei *h )
+{
+    __DRIdrawable *buf = swrast_drawable(fb);
+    __DRIscreen *screen = buf->driScreenPriv;
+    int x, y;
+
+    screen->swrast_loader->getDrawableInfo(buf,
+                                          &x, &y, w, h,
+                                          buf->loaderPrivate);
+}
+
+static void
+swrast_check_and_update_window_size( GLcontext *ctx, GLframebuffer *fb )
+{
+    GLsizei width, height;
+
+    get_window_size(fb, &width, &height);
+    if (fb->Width != width || fb->Height != height) {
+       _mesa_resize_framebuffer(ctx, fb, width, height);
+    }
+}
+
+static const GLubyte *
+get_string(GLcontext *ctx, GLenum pname)
+{
+    (void) ctx;
+    switch (pname) {
+       case GL_VENDOR:
+           return (const GLubyte *) "Mesa Project";
+       case GL_RENDERER:
+           return (const GLubyte *) "Software Rasterizer";
+       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 );
+    _vbo_InvalidateState( ctx, new_state );
+    _tnl_InvalidateState( ctx, new_state );
+}
+
+static void
+viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+    GLframebuffer *draw = ctx->WinSysDrawBuffer;
+    GLframebuffer *read = ctx->WinSysReadBuffer;
+
+    swrast_check_and_update_window_size(ctx, draw);
+    swrast_check_and_update_window_size(ctx, read);
+}
+
+static void
+swrast_init_driver_functions(struct dd_function_table *driver)
+{
+    driver->GetString = get_string;
+    driver->UpdateState = update_state;
+    driver->GetBufferSize = NULL;
+    driver->Viewport = viewport;
+}
+
+
+/**
+ * Context-related functions.
+ */
+
+static __DRIcontext *
+driCreateNewContext(__DRIscreen *screen, const __DRIconfig *config,
+                   __DRIcontext *shared, void *data)
+{
+    __DRIcontext *ctx;
+    GLcontext *mesaCtx;
+    struct dd_function_table functions;
+
+    TRACE;
+
+    ctx = _mesa_calloc(sizeof *ctx);
+    if (!ctx)
+       return NULL;
+
+    ctx->loaderPrivate = data;
+
+    ctx->driScreenPriv = screen;
+
+    /* build table of device driver functions */
+    _mesa_init_driver_functions(&functions);
+    swrast_init_driver_functions(&functions);
+
+    if (!_mesa_initialize_context(&ctx->Base, &config->modes,
+                                 shared ? &shared->Base : NULL,
+                                 &functions, (void *) ctx)) {
+      _mesa_free(ctx);
+      return NULL;
+    }
+
+    mesaCtx = &ctx->Base;
+
+    /* do bounds checking to prevent segfaults and server crashes! */
+    mesaCtx->Const.CheckArrayBounds = GL_TRUE;
+
+    /* create module contexts */
+    _swrast_CreateContext( mesaCtx );
+    _vbo_CreateContext( mesaCtx );
+    _tnl_CreateContext( mesaCtx );
+    _swsetup_CreateContext( mesaCtx );
+    _swsetup_Wakeup( mesaCtx );
+
+    /* use default TCL pipeline */
+    {
+       TNLcontext *tnl = TNL_CONTEXT(mesaCtx);
+       tnl->Driver.RunPipeline = _tnl_run_pipeline;
+    }
+
+    _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);
+    _mesa_enable_2_1_extensions(mesaCtx);
+
+    return ctx;
+}
+
+static void
+driDestroyContext(__DRIcontext *ctx)
+{
+    GLcontext *mesaCtx;
+    TRACE;
+
+    if (ctx) {
+       mesaCtx = &ctx->Base;
+       _swsetup_DestroyContext( mesaCtx );
+       _swrast_DestroyContext( mesaCtx );
+       _tnl_DestroyContext( mesaCtx );
+       _vbo_DestroyContext( mesaCtx );
+       _mesa_destroy_context( mesaCtx );
+    }
+}
+
+static int
+driCopyContext(__DRIcontext *dst, __DRIcontext *src, unsigned long mask)
+{
+    TRACE;
+
+    _mesa_copy_context(&src->Base, &dst->Base, mask);
+    return GL_TRUE;
+}
+
+static int driBindContext(__DRIcontext *ctx,
+                         __DRIdrawable *draw,
+                         __DRIdrawable *read)
+{
+    GLcontext *mesaCtx;
+    GLframebuffer *mesaDraw;
+    GLframebuffer *mesaRead;
+    TRACE;
+
+    if (ctx) {
+       if (!draw || !read)
+           return GL_FALSE;
+
+       mesaCtx = &ctx->Base;
+       mesaDraw = &draw->Base;
+       mesaRead = &read->Base;
+
+       /* check for same context and buffer */
+       if (mesaCtx == _mesa_get_current_context()
+           && mesaCtx->DrawBuffer == mesaDraw
+           && mesaCtx->ReadBuffer == mesaRead) {
+           return GL_TRUE;
+       }
+
+       _glapi_check_multithread();
+
+       swrast_check_and_update_window_size(mesaCtx, mesaDraw);
+       if (read != draw)
+           swrast_check_and_update_window_size(mesaCtx, mesaRead);
+
+       _mesa_make_current( mesaCtx,
+                           mesaDraw,
+                           mesaRead );
+    }
+    else {
+       /* unbind */
+       _mesa_make_current( NULL, NULL, NULL );
+    }
+
+    return GL_TRUE;
+}
+
+static int driUnbindContext(__DRIcontext *ctx)
+{
+    TRACE;
+    (void) ctx;
+    return GL_TRUE;
+}
+
+
+static const __DRIcoreExtension driCoreExtension = {
+    { __DRI_CORE, __DRI_CORE_VERSION },
+    NULL, /* driCreateNewScreen */
+    driDestroyScreen,
+    driGetExtensions,
+    driGetConfigAttrib,
+    driIndexConfigAttrib,
+    NULL, /* driCreateNewDrawable */
+    driDestroyDrawable,
+    driSwapBuffers,
+    driCreateNewContext,
+    driCopyContext,
+    driDestroyContext,
+    driBindContext,
+    driUnbindContext
+};
+
+static const __DRIswrastExtension driSWRastExtension = {
+    { __DRI_SWRAST, __DRI_SWRAST_VERSION },
+    driCreateNewScreen,
+    driCreateNewDrawable
+};
+
+/* This is the table of extensions that the loader will dlsym() for. */
+PUBLIC const __DRIextension *__driDriverExtensions[] = {
+    &driCoreExtension.base,
+    &driSWRastExtension.base,
+    NULL
+};
diff --git a/src/mesa/drivers/dri/swrast/swrast_priv.h b/src/mesa/drivers/dri/swrast/swrast_priv.h
new file mode 100644 (file)
index 0000000..a614823
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  7.1
+ *
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Authors:
+ *    George Sapountzis <gsap7@yahoo.gr>
+ */
+
+
+#ifndef _SWRAST_PRIV_H
+#define _SWRAST_PRIV_H
+
+#include <GL/gl.h>
+#include <GL/internal/dri_interface.h>
+#include "mtypes.h"
+
+
+/**
+ * Debugging
+ */
+#define DEBUG_CORE     0
+#define DEBUG_SPAN     0
+
+#if DEBUG_CORE
+#define TRACE _mesa_printf("--> %s\n", __FUNCTION__)
+#else
+#define TRACE
+#endif
+
+#if DEBUG_SPAN
+#define TRACE_SPAN _mesa_printf("--> %s\n", __FUNCTION__)
+#else
+#define TRACE_SPAN
+#endif
+
+
+/**
+ * Data types
+ */
+struct __DRIscreenRec {
+    int num;
+
+    const __DRIextension **extensions;
+
+    const __DRIswrastLoaderExtension *swrast_loader;
+};
+
+struct __DRIcontextRec {
+    GLcontext Base;
+
+    void *loaderPrivate;
+
+    __DRIscreen *driScreenPriv;
+};
+
+struct __DRIdrawableRec {
+    GLframebuffer Base;
+
+    void *loaderPrivate;
+
+    __DRIscreen *driScreenPriv;
+
+    /* scratch row for optimized front-buffer rendering */
+    char *row;
+};
+
+struct swrast_renderbuffer {
+    struct gl_renderbuffer Base;
+
+    /* renderbuffer pitch (in bytes) */
+    GLuint pitch;
+};
+
+static INLINE __DRIcontext *
+swrast_context(GLcontext *ctx)
+{
+    return (__DRIcontext *) ctx;
+}
+
+static INLINE __DRIdrawable *
+swrast_drawable(GLframebuffer *fb)
+{
+    return (__DRIdrawable *) fb;
+}
+
+static INLINE struct swrast_renderbuffer *
+swrast_renderbuffer(struct gl_renderbuffer *rb)
+{
+    return (struct swrast_renderbuffer *) rb;
+}
+
+
+/**
+ * Pixel formats we support
+ */
+#define PF_CI8        1                /**< Color Index mode */
+#define PF_A8R8G8B8   2                /**< 32-bit TrueColor:  8-A, 8-R, 8-G, 8-B bits */
+#define PF_R5G6B5     3                /**< 16-bit TrueColor:  5-R, 6-G, 5-B bits */
+#define PF_R3G3B2     4                /**<  8-bit TrueColor:  3-R, 3-G, 2-B bits */
+
+
+/**
+ * Renderbuffer pitch alignment (in bits).
+ *
+ * The xorg loader requires padding images to 32 bits. However, this should
+ * become a screen/drawable parameter XXX
+ */
+#define PITCH_ALIGN_BITS 32
+
+
+/* swrast_span.c */
+
+extern void
+swrast_set_span_funcs_back(struct swrast_renderbuffer *xrb,
+                          GLuint pixel_format);
+
+extern void
+swrast_set_span_funcs_front(struct swrast_renderbuffer *xrb,
+                           GLuint pixel_format);
+
+#endif /* _SWRAST_PRIV_H_ */
diff --git a/src/mesa/drivers/dri/swrast/swrast_span.c b/src/mesa/drivers/dri/swrast/swrast_span.c
new file mode 100644 (file)
index 0000000..5e99036
--- /dev/null
@@ -0,0 +1,367 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  7.1
+ *
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Authors:
+ *    George Sapountzis <gsap7@yahoo.gr>
+ */
+
+#include "swrast_priv.h"
+
+#define YFLIP(_xrb, Y) ((_xrb)->Base.Height - (Y) - 1)
+
+/*
+ * Dithering support takes the "computation" extreme in the "computation vs.
+ * storage" trade-off. This approach is very simple to implement and any
+ * computational overhead should be acceptable. XMesa uses table lookups for
+ * around 8KB of storage overhead per visual.
+ */
+#define DITHER 1
+
+static const 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,
+};
+
+#if DITHER
+#define DITHER_COMP(X, Y) kernel[((X) & 0x3) | (((Y) & 0x3) << 2)]
+
+#define DITHER_CLAMP(X) (((X) < CHAN_MAX) ? (X) : CHAN_MAX)
+#else
+#define DITHER_COMP(X, Y) 0
+
+#define DITHER_CLAMP(X) (X)
+#endif
+
+
+/*
+ * Pixel macros shared across front/back buffer span functions.
+ */
+
+/* 32-bit BGRA */
+#define STORE_PIXEL_A8R8G8B8(DST, X, Y, VALUE) \
+   DST[3] = VALUE[ACOMP]; \
+   DST[2] = VALUE[RCOMP]; \
+   DST[1] = VALUE[GCOMP]; \
+   DST[0] = VALUE[BCOMP]
+#define STORE_PIXEL_RGB_A8R8G8B8(DST, X, Y, VALUE) \
+   DST[3] = 0xff; \
+   DST[2] = VALUE[RCOMP]; \
+   DST[1] = VALUE[GCOMP]; \
+   DST[0] = VALUE[BCOMP]
+#define FETCH_PIXEL_A8R8G8B8(DST, SRC) \
+   DST[ACOMP] = SRC[3]; \
+   DST[RCOMP] = SRC[2]; \
+   DST[GCOMP] = SRC[1]; \
+   DST[BCOMP] = SRC[0]
+
+
+/* 16-bit BGR */
+#define STORE_PIXEL_R5G6B5(DST, X, Y, VALUE) \
+   do { \
+   int d = DITHER_COMP(X, Y) >> 6; \
+   GLushort *p = (GLushort *)DST; \
+   *p = ( ((DITHER_CLAMP((VALUE[RCOMP]) + d) & 0xf8) << 8) | \
+         ((DITHER_CLAMP((VALUE[GCOMP]) + d) & 0xfc) << 3) | \
+         ((DITHER_CLAMP((VALUE[BCOMP]) + d) & 0xf8) >> 3) ); \
+   } while(0)
+#define FETCH_PIXEL_R5G6B5(DST, SRC) \
+   do { \
+   GLushort p = *(GLushort *)SRC; \
+   DST[ACOMP] = 0xff; \
+   DST[RCOMP] = ((p >> 8) & 0xf8) * 255 / 0xf8; \
+   DST[GCOMP] = ((p >> 3) & 0xfc) * 255 / 0xfc; \
+   DST[BCOMP] = ((p << 3) & 0xf8) * 255 / 0xf8; \
+   } while(0)
+
+
+/* 8-bit BGR */
+#define STORE_PIXEL_R3G3B2(DST, X, Y, VALUE) \
+   do { \
+   int d = DITHER_COMP(X, Y) >> 3; \
+   GLubyte *p = (GLubyte *)DST; \
+   *p = ( ((DITHER_CLAMP((VALUE[RCOMP]) + d) & 0xe0) >> 5) | \
+         ((DITHER_CLAMP((VALUE[GCOMP]) + d) & 0xe0) >> 2) | \
+         ((DITHER_CLAMP((VALUE[BCOMP]) + d) & 0xc0) >> 0) ); \
+   } while(0)
+#define FETCH_PIXEL_R3G3B2(DST, SRC) \
+   do { \
+   GLubyte p = *(GLubyte *)SRC; \
+   DST[ACOMP] = 0xff; \
+   DST[RCOMP] = ((p << 5) & 0xe0) * 255 / 0xe0; \
+   DST[GCOMP] = ((p << 2) & 0xe0) * 255 / 0xe0; \
+   DST[BCOMP] = ((p << 0) & 0xc0) * 255 / 0xc0; \
+   } while(0)
+
+
+/*
+ * Generate code for back-buffer span functions.
+ */
+
+/* 32-bit BGRA */
+#define NAME(FUNC) FUNC##_A8R8G8B8
+#define RB_TYPE GLubyte
+#define SPAN_VARS \
+   struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
+#define INIT_PIXEL_PTR(P, X, Y) \
+   GLubyte *P = (GLubyte *)xrb->Base.Data + YFLIP(xrb, Y) * xrb->pitch + (X) * 4;
+#define INC_PIXEL_PTR(P) P += 4
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+   STORE_PIXEL_A8R8G8B8(DST, X, Y, VALUE)
+#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \
+   STORE_PIXEL_RGB_A8R8G8B8(DST, X, Y, VALUE)
+#define FETCH_PIXEL(DST, SRC) \
+   FETCH_PIXEL_A8R8G8B8(DST, SRC)
+
+#include "swrast/s_spantemp.h"
+
+
+/* 16-bit BGR */
+#define NAME(FUNC) FUNC##_R5G6B5
+#define RB_TYPE GLubyte
+#define SPAN_VARS \
+   struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
+#define INIT_PIXEL_PTR(P, X, Y) \
+   GLubyte *P = (GLubyte *)xrb->Base.Data + YFLIP(xrb, Y) * xrb->pitch + (X) * 2;
+#define INC_PIXEL_PTR(P) P += 2
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+   STORE_PIXEL_R5G6B5(DST, X, Y, VALUE)
+#define FETCH_PIXEL(DST, SRC) \
+   FETCH_PIXEL_R5G6B5(DST, SRC)
+
+#include "swrast/s_spantemp.h"
+
+
+/* 8-bit BGR */
+#define NAME(FUNC) FUNC##_R3G3B2
+#define RB_TYPE GLubyte
+#define SPAN_VARS \
+   struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
+#define INIT_PIXEL_PTR(P, X, Y) \
+   GLubyte *P = (GLubyte *)xrb->Base.Data + YFLIP(xrb, Y) * xrb->pitch + (X) * 1;
+#define INC_PIXEL_PTR(P) P += 1
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+   STORE_PIXEL_R3G3B2(DST, X, Y, VALUE)
+#define FETCH_PIXEL(DST, SRC) \
+   FETCH_PIXEL_R3G3B2(DST, SRC)
+
+#include "swrast/s_spantemp.h"
+
+
+/* 8-bit color index */
+#define NAME(FUNC) FUNC##_CI8
+#define CI_MODE
+#define RB_TYPE GLubyte
+#define SPAN_VARS \
+   struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
+#define INIT_PIXEL_PTR(P, X, Y) \
+   GLubyte *P = (GLubyte *)xrb->Base.Data + YFLIP(xrb, Y) * xrb->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"
+
+
+/*
+ * Generate code for front-buffer span functions.
+ */
+
+/* 32-bit BGRA */
+#define NAME(FUNC) FUNC##_A8R8G8B8_front
+#define RB_TYPE GLubyte
+#define SPAN_VARS \
+   struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
+#define INIT_PIXEL_PTR(P, X, Y) \
+   GLubyte *P = (GLubyte *)row;
+#define INC_PIXEL_PTR(P) P += 4
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+   STORE_PIXEL_A8R8G8B8(DST, X, Y, VALUE)
+#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \
+   STORE_PIXEL_RGB_A8R8G8B8(DST, X, Y, VALUE)
+#define FETCH_PIXEL(DST, SRC) \
+   FETCH_PIXEL_A8R8G8B8(DST, SRC)
+
+#include "swrast_spantemp.h"
+
+
+/* 16-bit BGR */
+#define NAME(FUNC) FUNC##_R5G6B5_front
+#define RB_TYPE GLubyte
+#define SPAN_VARS \
+   struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
+#define INIT_PIXEL_PTR(P, X, Y) \
+   GLubyte *P = (GLubyte *)row;
+#define INC_PIXEL_PTR(P) P += 2
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+   STORE_PIXEL_R5G6B5(DST, X, Y, VALUE)
+#define FETCH_PIXEL(DST, SRC) \
+   FETCH_PIXEL_R5G6B5(DST, SRC)
+
+#include "swrast_spantemp.h"
+
+
+/* 8-bit BGR */
+#define NAME(FUNC) FUNC##_R3G3B2_front
+#define RB_TYPE GLubyte
+#define SPAN_VARS \
+   struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
+#define INIT_PIXEL_PTR(P, X, Y) \
+   GLubyte *P = (GLubyte *)row;
+#define INC_PIXEL_PTR(P) P += 1
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+   STORE_PIXEL_R3G3B2(DST, X, Y, VALUE)
+#define FETCH_PIXEL(DST, SRC) \
+   FETCH_PIXEL_R3G3B2(DST, SRC)
+
+#include "swrast_spantemp.h"
+
+
+/* 8-bit color index */
+#define NAME(FUNC) FUNC##_CI8_front
+#define CI_MODE
+#define RB_TYPE GLubyte
+#define SPAN_VARS \
+   struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb);
+#define INIT_PIXEL_PTR(P, X, Y) \
+   GLubyte *P = (GLubyte *)row;
+#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_spantemp.h"
+
+
+/*
+ * Back-buffers are malloced memory and always private.
+ *
+ * BACK_PIXMAP (not supported)
+ * BACK_XIMAGE
+ */
+void
+swrast_set_span_funcs_back(struct swrast_renderbuffer *xrb,
+                          GLuint pixel_format)
+{
+    switch (pixel_format) {
+    case PF_A8R8G8B8:
+       xrb->Base.GetRow = get_row_A8R8G8B8;
+       xrb->Base.GetValues = get_values_A8R8G8B8;
+       xrb->Base.PutRow = put_row_A8R8G8B8;
+       xrb->Base.PutRowRGB = put_row_rgb_A8R8G8B8;
+       xrb->Base.PutMonoRow = put_mono_row_A8R8G8B8;
+       xrb->Base.PutValues = put_values_A8R8G8B8;
+       xrb->Base.PutMonoValues = put_mono_values_A8R8G8B8;
+       break;
+    case PF_R5G6B5:
+       xrb->Base.GetRow = get_row_R5G6B5;
+       xrb->Base.GetValues = get_values_R5G6B5;
+       xrb->Base.PutRow = put_row_R5G6B5;
+       xrb->Base.PutRowRGB = put_row_rgb_R5G6B5;
+       xrb->Base.PutMonoRow = put_mono_row_R5G6B5;
+       xrb->Base.PutValues = put_values_R5G6B5;
+       xrb->Base.PutMonoValues = put_mono_values_R5G6B5;
+       break;
+    case PF_R3G3B2:
+       xrb->Base.GetRow = get_row_R3G3B2;
+       xrb->Base.GetValues = get_values_R3G3B2;
+       xrb->Base.PutRow = put_row_R3G3B2;
+       xrb->Base.PutRowRGB = put_row_rgb_R3G3B2;
+       xrb->Base.PutMonoRow = put_mono_row_R3G3B2;
+       xrb->Base.PutValues = put_values_R3G3B2;
+       xrb->Base.PutMonoValues = put_mono_values_R3G3B2;
+       break;
+    case PF_CI8:
+       xrb->Base.GetRow = get_row_CI8;
+       xrb->Base.GetValues = get_values_CI8;
+       xrb->Base.PutRow = put_row_CI8;
+       xrb->Base.PutMonoRow = put_mono_row_CI8;
+       xrb->Base.PutValues = put_values_CI8;
+       xrb->Base.PutMonoValues = put_mono_values_CI8;
+       break;
+    default:
+       assert(0);
+       return;
+    }
+}
+
+
+/*
+ * Front-buffers are provided by the loader, the xorg loader uses pixmaps.
+ *
+ * WINDOW,          An X window
+ * GLXWINDOW,       GLX window
+ * PIXMAP,          GLX pixmap
+ * PBUFFER          GLX Pbuffer
+ */
+void
+swrast_set_span_funcs_front(struct swrast_renderbuffer *xrb,
+                           GLuint pixel_format)
+{
+    switch (pixel_format) {
+    case PF_A8R8G8B8:
+       xrb->Base.GetRow = get_row_A8R8G8B8_front;
+       xrb->Base.GetValues = get_values_A8R8G8B8_front;
+       xrb->Base.PutRow = put_row_A8R8G8B8_front;
+       xrb->Base.PutRowRGB = put_row_rgb_A8R8G8B8_front;
+       xrb->Base.PutMonoRow = put_mono_row_A8R8G8B8_front;
+       xrb->Base.PutValues = put_values_A8R8G8B8_front;
+       xrb->Base.PutMonoValues = put_mono_values_A8R8G8B8_front;
+       break;
+    case PF_R5G6B5:
+       xrb->Base.GetRow = get_row_R5G6B5_front;
+       xrb->Base.GetValues = get_values_R5G6B5_front;
+       xrb->Base.PutRow = put_row_R5G6B5_front;
+       xrb->Base.PutRowRGB = put_row_rgb_R5G6B5_front;
+       xrb->Base.PutMonoRow = put_mono_row_R5G6B5_front;
+       xrb->Base.PutValues = put_values_R5G6B5_front;
+       xrb->Base.PutMonoValues = put_mono_values_R5G6B5_front;
+       break;
+    case PF_R3G3B2:
+       xrb->Base.GetRow = get_row_R3G3B2_front;
+       xrb->Base.GetValues = get_values_R3G3B2_front;
+       xrb->Base.PutRow = put_row_R3G3B2_front;
+       xrb->Base.PutRowRGB = put_row_rgb_R3G3B2_front;
+       xrb->Base.PutMonoRow = put_mono_row_R3G3B2_front;
+       xrb->Base.PutValues = put_values_R3G3B2_front;
+       xrb->Base.PutMonoValues = put_mono_values_R3G3B2_front;
+       break;
+    case PF_CI8:
+       xrb->Base.GetRow = get_row_CI8_front;
+       xrb->Base.GetValues = get_values_CI8_front;
+       xrb->Base.PutRow = put_row_CI8_front;
+       xrb->Base.PutMonoRow = put_mono_row_CI8_front;
+       xrb->Base.PutValues = put_values_CI8_front;
+       xrb->Base.PutMonoValues = put_mono_values_CI8_front;
+       break;
+    default:
+       assert(0);
+       return;
+    }
+}
diff --git a/src/mesa/drivers/dri/swrast/swrast_spantemp.h b/src/mesa/drivers/dri/swrast/swrast_spantemp.h
new file mode 100644 (file)
index 0000000..187a240
--- /dev/null
@@ -0,0 +1,328 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  6.5.1
+ *
+ * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/*
+ * Modified version of swrast/s_spantemp.h for front-buffer rendering. The
+ * no-mask paths use a scratch row to avoid repeated calls to the loader.
+ *
+ * For the mask paths we always use an array of 4 elements of RB_TYPE. This is
+ * to satisfy the xorg loader requirement of an image pitch of 32 bits and
+ * should be ok for other loaders also.
+ */
+
+
+#ifndef _SWRAST_SPANTEMP_ONCE
+#define _SWRAST_SPANTEMP_ONCE
+
+static INLINE void
+PUT_PIXEL( GLcontext *glCtx, GLint x, GLint y, GLubyte *p )
+{
+    __DRIcontext *ctx = swrast_context(glCtx);
+    __DRIdrawable *draw = swrast_drawable(glCtx->DrawBuffer);
+
+    __DRIscreen *screen = ctx->driScreenPriv;
+
+    screen->swrast_loader->putImage(draw, __DRI_SWRAST_IMAGE_OP_DRAW,
+                                   x, y, 1, 1, (char *)p,
+                                   draw->loaderPrivate);
+}
+
+
+static INLINE void
+GET_PIXEL( GLcontext *glCtx, GLint x, GLint y, GLubyte *p )
+{
+    __DRIcontext *ctx = swrast_context(glCtx);
+    __DRIdrawable *read = swrast_drawable(glCtx->ReadBuffer);
+
+    __DRIscreen *screen = ctx->driScreenPriv;
+
+    screen->swrast_loader->getImage(read, x, y, 1, 1, (char *)p,
+                                   read->loaderPrivate);
+}
+
+static INLINE void
+PUT_ROW( GLcontext *glCtx, GLint x, GLint y, GLuint n, char *row )
+{
+    __DRIcontext *ctx = swrast_context(glCtx);
+    __DRIdrawable *draw = swrast_drawable(glCtx->DrawBuffer);
+
+    __DRIscreen *screen = ctx->driScreenPriv;
+
+    screen->swrast_loader->putImage(draw, __DRI_SWRAST_IMAGE_OP_DRAW,
+                                   x, y, n, 1, row,
+                                   draw->loaderPrivate);
+}
+
+static INLINE void
+GET_ROW( GLcontext *glCtx, GLint x, GLint y, GLuint n, char *row )
+{
+    __DRIcontext *ctx = swrast_context(glCtx);
+    __DRIdrawable *read = swrast_drawable(glCtx->ReadBuffer);
+
+    __DRIscreen *screen = ctx->driScreenPriv;
+
+    screen->swrast_loader->getImage(read, x, y, n, 1, row,
+                                   read->loaderPrivate);
+}
+
+#endif /* _SWRAST_SPANTEMP_ONCE */
+
+
+/*
+ * 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(BASE)  to generate the function name (i.e. add prefix or suffix)
+ *   RB_TYPE  the renderbuffer DataType
+ *   CI_MODE  if set, color index mode, else RGBA
+ *   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"
+
+
+#ifdef CI_MODE
+#define RB_COMPONENTS 1
+#elif !defined(RB_COMPONENTS)
+#define RB_COMPONENTS 4
+#endif
+
+
+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
+#ifdef CI_MODE
+   RB_TYPE *dest = (RB_TYPE *) values;
+#else
+   RB_TYPE (*dest)[RB_COMPONENTS] = (RB_TYPE (*)[RB_COMPONENTS]) values;
+#endif
+   GLuint i;
+   char *row = swrast_drawable(ctx->ReadBuffer)->row;
+   INIT_PIXEL_PTR(pixel, x, y);
+   GET_ROW( ctx, x, YFLIP(xrb, y), count, row );
+   for (i = 0; i < count; i++) {
+      FETCH_PIXEL(dest[i], pixel);
+      INC_PIXEL_PTR(pixel);
+   }
+   (void) rb;
+}
+
+
+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
+#ifdef CI_MODE
+   RB_TYPE *dest = (RB_TYPE *) values;
+#else
+   RB_TYPE (*dest)[RB_COMPONENTS] = (RB_TYPE (*)[RB_COMPONENTS]) values;
+#endif
+   GLuint i;
+   for (i = 0; i < count; i++) {
+      RB_TYPE pixel[4];
+      GET_PIXEL(ctx, x[i], YFLIP(xrb, y[i]), pixel);
+      FETCH_PIXEL(dest[i], pixel);
+   }
+   (void) rb;
+}
+
+
+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
+   const RB_TYPE (*src)[RB_COMPONENTS] = (const RB_TYPE (*)[RB_COMPONENTS]) values;
+   GLuint i;
+   if (mask) {
+      for (i = 0; i < count; i++) {
+         if (mask[i]) {
+            RB_TYPE pixel[4];
+            STORE_PIXEL(pixel, x + i, y, src[i]);
+            PUT_PIXEL(ctx, x + i, YFLIP(xrb, y), pixel);
+         }
+      }
+   }
+   else {
+      char *row = swrast_drawable(ctx->DrawBuffer)->row;
+      INIT_PIXEL_PTR(pixel, x, y);
+      for (i = 0; i < count; i++) {
+         STORE_PIXEL(pixel, x + i, y, src[i]);
+         INC_PIXEL_PTR(pixel);
+      }
+      PUT_ROW( ctx, x, YFLIP(xrb, y), count, row );
+   }
+   (void) rb;
+}
+
+
+#if !defined(CI_MODE)
+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
+   const RB_TYPE (*src)[3] = (const RB_TYPE (*)[3]) values;
+   GLuint i;
+   if (mask) {
+      for (i = 0; i < count; i++) {
+         if (mask[i]) {
+            RB_TYPE pixel[4];
+#ifdef STORE_PIXEL_RGB
+            STORE_PIXEL_RGB(pixel, x + i, y, src[i]);
+#else
+            STORE_PIXEL(pixel, x + i, y, src[i]);
+#endif
+            PUT_PIXEL(ctx, x + i, YFLIP(xrb, y), pixel);
+         }
+      }
+   }
+   else {
+      char *row = swrast_drawable(ctx->DrawBuffer)->row;
+      INIT_PIXEL_PTR(pixel, x, y);
+      for (i = 0; i < count; 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);
+      }
+      PUT_ROW( ctx, x, YFLIP(xrb, y), count, row );
+   }
+   (void) rb;
+}
+#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
+   const RB_TYPE *src = (const RB_TYPE *) value;
+   GLuint i;
+   if (mask) {
+      for (i = 0; i < count; i++) {
+         if (mask[i]) {
+            RB_TYPE pixel[4];
+            STORE_PIXEL(pixel, x + i, y, src);
+            PUT_PIXEL(ctx, x + i, YFLIP(xrb, y), pixel);
+         }
+      }
+   }
+   else {
+      char *row = swrast_drawable(ctx->DrawBuffer)->row;
+      INIT_PIXEL_PTR(pixel, x, y);
+      for (i = 0; i < count; i++) {
+         STORE_PIXEL(pixel, x + i, y, src);
+         INC_PIXEL_PTR(pixel);
+      }
+      PUT_ROW( ctx, x, YFLIP(xrb, y), count, row );
+   }
+   (void) rb;
+}
+
+
+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
+   const RB_TYPE (*src)[RB_COMPONENTS] = (const RB_TYPE (*)[RB_COMPONENTS]) values;
+   GLuint i;
+   ASSERT(mask);
+   for (i = 0; i < count; i++) {
+      if (mask[i]) {
+         RB_TYPE pixel[4];
+         STORE_PIXEL(pixel, x[i], y[i], src[i]);
+         PUT_PIXEL(ctx, x[i], YFLIP(xrb, y[i]), pixel);
+      }
+   }
+   (void) rb;
+}
+
+
+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
+   const RB_TYPE *src = (const RB_TYPE *) value;
+   GLuint i;
+   ASSERT(mask);
+   for (i = 0; i < count; i++) {
+      if (mask[i]) {
+         RB_TYPE pixel[4];
+         STORE_PIXEL(pixel, x[i], y[i], src);
+         PUT_PIXEL(ctx, x[i], YFLIP(xrb, y[i]), pixel);
+      }
+   }
+   (void) rb;
+}
+
+
+#undef NAME
+#undef RB_TYPE
+#undef RB_COMPONENTS
+#undef CI_MODE
+#undef SPAN_VARS
+#undef INIT_PIXEL_PTR
+#undef INC_PIXEL_PTR
+#undef STORE_PIXEL
+#undef STORE_PIXEL_RGB
+#undef FETCH_PIXEL
index 05673cd1867f33f1fa0c8f3e174af94b72dea090..c88a3ef96ff31b996bbd9d70e9beb0fbe57c21e7 100644 (file)
@@ -983,9 +983,9 @@ FX_grColorMaskv_NoLock(GLcontext *ctx, const GLboolean rgba[4]);
 #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 )
+static INLINE GrColor_t tdfxPackColor( GLuint cpp,
+                                       GLubyte r, GLubyte g,
+                                       GLubyte b, GLubyte a )
 {
    switch ( cpp ) {
    case 2:
index e374f09df3af3d3092679071bc0c9b4fb832ec19..cf840c57a7a6bced9ce3f8bf170a9ddcd40e0c60 100644 (file)
@@ -274,7 +274,7 @@ static void tdfxClear( GLcontext *ctx, GLbitfield mask )
                                         fxMesa->Color.ClearAlpha,
                                         fxMesa->Depth.Clear);
         FX_grColorMaskv_NoLock(ctx, true4);
-        if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_FRONT_LEFT)
+        if (ctx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT)
             fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER);
         if (!ctx->Depth.Test || !ctx->Depth.Mask)
            fxMesa->Glide.grDepthMask(FXFALSE);
@@ -294,7 +294,7 @@ static void tdfxClear( GLcontext *ctx, GLbitfield mask )
                fxMesa->Glide.grDepthMask(FXTRUE);
             }
             FX_grColorMaskv_NoLock(ctx, true4);
-            if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_FRONT_LEFT)
+            if (ctx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT)
                fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER);
          }
       }
index 776166439444ec94b481b24b8afdb038d4ddeba7..cdfc8a002d9d25e3bc27f65dc9ab0f284b4538ce 100644 (file)
@@ -62,6 +62,11 @@ DRI_CONF_BEGIN
     DRI_CONF_SECTION_END
 DRI_CONF_END;
 
+static const __DRIextension *tdfxExtensions[] = {
+    &driReadDrawableExtension,
+    NULL
+};
+
 static const GLuint __driNConfigOptions = 1;
 
 extern const struct dri_extension card_extensions[];
@@ -72,9 +77,6 @@ tdfxCreateScreen( __DRIscreenPrivate *sPriv )
 {
    tdfxScreenPrivate *fxScreen;
    TDFXDRIPtr fxDRIPriv = (TDFXDRIPtr) sPriv->pDevPriv;
-   PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
-     (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
-   void *const psc = sPriv->psc->screenConfigs;
 
    if (sPriv->devPrivSize != sizeof(TDFXDRIRec)) {
       fprintf(stderr,"\nERROR!  sizeof(TDFXDRIRec) does not match passed size from device driver\n");
@@ -115,9 +117,7 @@ tdfxCreateScreen( __DRIscreenPrivate *sPriv )
       return GL_FALSE;
    }
 
-   if (glx_enable_extension != NULL) {
-      (*glx_enable_extension)(psc, "GLX_SGI_make_current_read");
-   }
+   sPriv->extensions = tdfxExtensions;
 
    return GL_TRUE;
 }
@@ -343,36 +343,14 @@ tdfxSwapBuffers( __DRIdrawablePrivate *driDrawPriv )
    }
 }
 
-
-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)
+static const __DRIconfig **
+tdfxFillInModes(__DRIscreenPrivate *psp,
+               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
@@ -380,120 +358,96 @@ static __GLcontextModes *tdfxFillInModes(unsigned pixel_bits,
         * 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 && deep) ? 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;
-                       }
-                   }
-               }
-           }
+       static const GLenum db_modes[2] = { GLX_NONE, GLX_SWAP_UNDEFINED_OML };
+       uint8_t depth_bits_array[4];
+       uint8_t stencil_bits_array[4];
+       if(deep) {
+               depth_bits_array[0] = 0;
+               depth_bits_array[1] = 24;
+               stencil_bits_array[0] = 0;
+               stencil_bits_array[1] = 8;
+       } else {
+               depth_bits_array[0] = depth_bits;
+               depth_bits_array[1] = 0;
+               depth_bits_array[2] = depth_bits;
+               depth_bits_array[3] = 0;
+               stencil_bits_array[0] = 0;
+               stencil_bits_array[1] = 0;
+               stencil_bits_array[2] = 8;
+               stencil_bits_array[3] = 8;
        }
 
-       return modes;
+       return driCreateConfigs(
+               deep ? GL_RGBA : GL_RGB,
+               deep ? GL_UNSIGNED_INT_8_8_8_8 : GL_UNSIGNED_SHORT_5_6_5,
+               depth_bits_array,
+               stencil_bits_array,
+               deep ? 2 : 4,
+               db_modes, 2);
 }
 
 /**
- * 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.
+ * This is the driver specific part of the createNewScreen entry point.
+ * 
+ * \todo maybe fold this into intelInitDriver
  *
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
- *         failure.
+ * \return the __GLcontextModes supported by this driver
  */
-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 )
+static const __DRIconfig **
+tdfxInitScreen(__DRIscreen *psp)
 {
-   __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;
+   /* divined from tdfx_dri.c, sketchy */
+   TDFXDRIPtr dri_priv = (TDFXDRIPtr) psp->pDevPriv;
+
+   /* XXX i wish it was like this */
+   /* bpp = dri_priv->bpp */
+   int bpp = (dri_priv->cpp > 2) ? 24 : 16;
 
    if ( ! driCheckDriDdxDrmVersions2( "tdfx",
-                                     dri_version, & dri_expected,
-                                     ddx_version, & ddx_expected,
-                                     drm_version, & drm_expected ) ) {
+                                     &psp->dri_version, & dri_expected,
+                                     &psp->ddx_version, & ddx_expected,
+                                     &psp->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;
+   /* 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 );
 
-      /* XXX i wish it was like this */
-      /* bpp = dri_priv->bpp */
+   if (!tdfxInitDriver(psp))
+      return NULL;
       
-      *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;
+   return tdfxFillInModes(psp,
+                         bpp, (bpp == 16) ? 16 : 24,
+                         (bpp == 16) ? 0 : 8,
+                         (dri_priv->backOffset!=dri_priv->depthOffset));
 }
+
+const struct __DriverAPIRec driDriverAPI = {
+   .InitScreen      = tdfxInitScreen,
+   .DestroyScreen   = tdfxDestroyScreen,
+   .CreateContext   = tdfxCreateContext,
+   .DestroyContext  = tdfxDestroyContext,
+   .CreateBuffer    = tdfxCreateBuffer,
+   .DestroyBuffer   = tdfxDestroyBuffer,
+   .SwapBuffers     = tdfxSwapBuffers,
+   .MakeCurrent     = tdfxMakeCurrent,
+   .UnbindContext   = tdfxUnbindContext,
+   .GetSwapInfo     = NULL,
+   .GetDrawableMSC  = NULL,
+   .WaitForMSC      = NULL,
+   .WaitForSBC      = NULL,
+   .SwapBuffersMSC  = NULL
+};
index 3688c76a5c9d6f26e4f6784a681aaa66ab071dc7..781964e3c63c6e9a33cef806b018633584285b0c 100644 (file)
@@ -1032,21 +1032,23 @@ static void tdfxDDDrawBuffer( GLcontext *ctx, GLenum mode )
 
    FLUSH_BATCH( fxMesa );
 
-   /*
-    * _ColorDrawBufferMask is easier to cope with than <mode>.
-    */
-   switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
-   case BUFFER_BIT_FRONT_LEFT:
+   if (ctx->DrawBuffer->_NumColorDrawBuffers > 1) {
+      FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_TRUE );
+      return;
+   }
+
+   switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) {
+   case BUFFER_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:
+   case BUFFER_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:
+   case -1:
       FX_grColorMaskv( ctx, false4 );
       FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE );
       break;
index 8dc7f0dc781e837011241f71c4f63db2bd461c25..2b6d19c4a5749f51848563c612c7ecb0cfdc692c 100644 (file)
@@ -417,56 +417,46 @@ tridentInitDriver(__DRIscreenPrivate *sPriv)
     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 )
+/**
+ * This is the driver specific part of the createNewScreen entry point.
+ * 
+ * \todo maybe fold this into intelInitDriver
+ *
+ * \return the __GLcontextModes supported by this driver
+ */
+const __DRIconfig **tridentInitScreen(__DRIscreenPrivate *psp)
 {
-    __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 ) ) {
+                                     &psp->dri_version, & dri_expected,
+                                     &psp->ddx_version, & ddx_expected,
+                                     &psp->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 (!tridentInitDriver(psp))
+       return NULL;
 
-    if ( psp != NULL ) {
+    /* Wait... what?  This driver doesn't report any modes... */
 #if 0
-       TRIDENTDRIPtr dri_priv = (TRIDENTDRIPtr) psp->pDevPriv;
-       *driver_modes = tridentFillInModes( dri_priv->bytesPerPixel * 8,
-                                          GL_TRUE );
+   TRIDENTDRIPtr dri_priv = (TRIDENTDRIPtr) psp->pDevPriv;
+   *driver_modes = tridentFillInModes( dri_priv->bytesPerPixel * 8,
+                                      GL_TRUE );
 #endif
-    }
-    return (void *) psp;
+
+   return NULL;
 }
+
+const struct __DriverAPIRec driDriverAPI = {
+   tridentInitScreen,
+   tridentDestroyScreen,
+   tridentCreateContext,
+   tridentDestroyContext,
+   tridentCreateBuffer,
+   tridentDestroyBuffer,
+   tridentSwapBuffers,
+   tridentMakeCurrent,
+   tridentUnbindContext,
+};
index 1d3ca84400da2d4ce78b52b525d6705104303d04..82b53df884b73777db667e2b6f1f79961fb18d99 100644 (file)
 #undef TAG
 
 /* these require that base be dword-aligned */
-static inline void MMIO_OUT32(unsigned char *base, unsigned int offset,
+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)
+static INLINE unsigned int MMIO_IN32(unsigned char *base, unsigned int offset)
 {
     unsigned int *addr = (unsigned int *)(base + offset);
     return *addr;
index 5303bd422ed3ca36d2cc9a5cea082fdec5cb9510..cc2e52ab2796acab2960bfe089d8ff8d099ed401 100644 (file)
@@ -51,9 +51,9 @@
 #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 )
+static INLINE GLuint tridentPackColor( GLuint cpp,
+                                       GLubyte r, GLubyte g,
+                                       GLubyte b, GLubyte a )
 {
    switch ( cpp ) {
    case 2:
index 4d25d328e333d96d68ed80ae735db4c4f9f8d261..ed7001d48dfb3c97cef878273e813746074fb59a 100644 (file)
@@ -123,7 +123,7 @@ static const GLubyte *viaGetString(GLcontext *ctx, GLenum name)
  * 
  * \returns A pixel width that meets the alignment requirements.
  */
-static __inline__ unsigned
+static INLINE unsigned
 buffer_align( unsigned width )
 {
     return (width + 0x0f) & ~0x0f;
@@ -601,9 +601,6 @@ viaCreateContext(const __GLcontextModes *visual,
     _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;
@@ -661,14 +658,10 @@ viaCreateContext(const __GLcontextModes *visual,
         driQueryOptionb(&vmesa->optionCache, "no_rast"))
        FALLBACK(vmesa, VIA_FALLBACK_USER_DISABLE, 1);
 
-    vmesa->vblank_flags =
-       vmesa->viaScreen->irqEnabled ?
-        driGetDefaultVBlankFlags(&vmesa->optionCache) : VBLANK_FLAG_NO_IRQ;
-
     if (getenv("VIA_PAGEFLIP"))
        vmesa->allowPageFlip = 1;
 
-    (*dri_interface->getUST)( &vmesa->swap_ust );
+    (*sPriv->systemTime->getUST)( &vmesa->swap_ust );
 
 
     vmesa->regMMIOBase = (GLuint *)((unsigned long)viaScreen->reg);
@@ -686,46 +679,48 @@ void
 viaDestroyContext(__DRIcontextPrivate *driContextPriv)
 {
     GET_CURRENT_CONTEXT(ctx);
-    struct via_context *vmesa = 
+    struct via_context *vmesa =
        (struct via_context *)driContextPriv->driverPrivate;
     struct via_context *current = ctx ? VIA_CONTEXT(ctx) : NULL;
+
     assert(vmesa); /* should never be null */
 
+    if (vmesa->driDrawable) {
+       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);
+       }
+    }
+
     /* 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);
-        _vbo_DestroyContext(vmesa->glCtx);
-        _swrast_DestroyContext(vmesa->glCtx);
-        /* free the Mesa context */
-       _mesa_destroy_context(vmesa->glCtx);
-       /* release our data */
-       FreeBuffer(vmesa);
+    _swsetup_DestroyContext(vmesa->glCtx);
+    _tnl_DestroyContext(vmesa->glCtx);
+    _vbo_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));
+    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));
 
-       driDestroyOptionCache(&vmesa->optionCache);
+    driDestroyOptionCache(&vmesa->optionCache);
 
-       FREE(vmesa);
-    }
+    FREE(vmesa);
 }
 
 
@@ -733,17 +728,18 @@ void viaXMesaWindowMoved(struct via_context *vmesa)
 {
    __DRIdrawablePrivate *const drawable = vmesa->driDrawable;
    __DRIdrawablePrivate *const readable = vmesa->driReadable;
-   struct via_renderbuffer *const draw_buffer = 
-     (struct via_renderbuffer *) drawable->driverPrivate;
-   struct via_renderbuffer *const read_buffer =
-     (struct via_renderbuffer *) readable->driverPrivate;
+   struct via_renderbuffer * draw_buffer;
+   struct via_renderbuffer * read_buffer;
    GLuint bytePerPixel = vmesa->viaScreen->bitsPerPixel >> 3;
 
    if (!drawable)
       return;
+
+   draw_buffer =  (struct via_renderbuffer *) drawable->driverPrivate;
+   read_buffer =  (struct via_renderbuffer *) readable->driverPrivate;
    
-   switch (vmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0]) {
-   case BUFFER_BIT_BACK_LEFT: 
+   switch (vmesa->glCtx->DrawBuffer->_ColorDrawBufferIndexes[0]) {
+   case BUFFER_BACK_LEFT: 
       if (drawable->numBackClipRects == 0) {
         vmesa->numClipRects = drawable->numClipRects;
         vmesa->pClipRects = drawable->pClipRects;
@@ -753,7 +749,7 @@ void viaXMesaWindowMoved(struct via_context *vmesa)
         vmesa->pClipRects = drawable->pBackClipRects;
       }
       break;
-   case BUFFER_BIT_FRONT_LEFT:
+   case BUFFER_FRONT_LEFT:
       vmesa->numClipRects = drawable->numClipRects;
       vmesa->pClipRects = drawable->pClipRects;
       break;
@@ -839,13 +835,17 @@ viaMakeCurrent(__DRIcontextPrivate *driContextPriv,
         drawBuffer = (GLframebuffer *)driDrawPriv->driverPrivate;
         readBuffer = (GLframebuffer *)driReadPriv->driverPrivate;
 
-       if (vmesa->driDrawable != driDrawPriv) {
-          driDrawableInitVBlank(driDrawPriv, vmesa->vblank_flags,
-                                &vmesa->vbl_seq);
-       }
-
        if ((vmesa->driDrawable != driDrawPriv)
           || (vmesa->driReadable != driReadPriv)) {
+         if (driDrawPriv->swap_interval == (unsigned)-1) {
+            driDrawPriv->vblFlags =
+               vmesa->viaScreen->irqEnabled ?
+               driGetDefaultVBlankFlags(&vmesa->optionCache) :
+               VBLANK_FLAG_NO_IRQ;
+
+            driDrawableInitVBlank(driDrawPriv);
+         }
+
          vmesa->driDrawable = driDrawPriv;
          vmesa->driReadable = driReadPriv;
 
index fecd2782fbaae98afc5597dcfb07be94cf199458..acd6f2e2b1cfe3c0d5bace717e69f40a67e6b8c8 100644 (file)
@@ -289,7 +289,6 @@ struct via_context {
    drm_context_t hHWContext;
    drm_hw_lock_t *driHwLock;
    int driFd;
-   __DRInativeDisplay *display;
 
    /**
     * DRI drawable bound to this context for drawing.
@@ -322,9 +321,6 @@ struct via_context {
     */
    driOptionCache optionCache;
 
-   GLuint vblank_flags;
-   GLuint vbl_seq;
-
    int64_t swap_ust;
    int64_t swap_missed_ust;
 
index 4a733fb00c23a0f13218da633531600a66384f5e..482a1a63d7074ffc62a666f31bc9ccb452fb0344 100644 (file)
@@ -507,11 +507,12 @@ void viaWaitIdleLocked( struct via_context *vmesa, GLboolean light )
  * except that WAIT_IDLE() will spin the CPU polling, while this is
  * IRQ driven.
  */
-static void viaWaitIdleVBlank( const __DRIdrawablePrivate *dPriv, 
+static void viaWaitIdleVBlank(  __DRIdrawablePrivate *dPriv, 
                               struct via_context *vmesa,
                               GLuint value )
 {
    GLboolean missed_target;
+   __DRIscreenPrivate *psp = dPriv->driScreenPriv;
 
    VIA_FLUSH_DMA(vmesa); 
 
@@ -523,11 +524,10 @@ static void viaWaitIdleVBlank( const __DRIdrawablePrivate *dPriv,
          vmesa->thrashing)
         viaSwapOutWork(vmesa);
 
-      driWaitForVBlank( dPriv, & vmesa->vbl_seq, 
-                       vmesa->vblank_flags, & missed_target );
+      driWaitForVBlank( dPriv, & missed_target );
       if ( missed_target ) {
         vmesa->swap_missed_count++;
-        (*dri_interface->getUST)( &vmesa->swap_missed_ust );
+        (*psp->systemTime->getUST)( &vmesa->swap_missed_ust );
       }
    } 
    while (!viaCheckBreadcrumb(vmesa, value));   
@@ -591,10 +591,11 @@ void viaResetPageFlippingLocked(struct via_context *vmesa)
 /*
  * Copy the back buffer to the front buffer. 
  */
-void viaCopyBuffer(const __DRIdrawablePrivate *dPriv)
+void viaCopyBuffer(__DRIdrawablePrivate *dPriv)
 {
    struct via_context *vmesa = 
       (struct via_context *)dPriv->driContextPriv->driverPrivate;
+   __DRIscreenPrivate *psp = dPriv->driScreenPriv;
 
    if (VIA_DEBUG & DEBUG_IOCTL)
       fprintf(stderr, 
@@ -607,7 +608,7 @@ void viaCopyBuffer(const __DRIdrawablePrivate *dPriv)
 
    VIA_FLUSH_DMA(vmesa);
 
-   if (vmesa->vblank_flags == VBLANK_FLAG_SYNC &&
+   if (dPriv->vblFlags == VBLANK_FLAG_SYNC &&
        vmesa->lastBreadcrumbWrite > 1)
       viaWaitIdleVBlank(dPriv, vmesa, vmesa->lastBreadcrumbWrite-1);
    else
@@ -630,18 +631,19 @@ void viaCopyBuffer(const __DRIdrawablePrivate *dPriv)
    viaEmitBreadcrumbLocked(vmesa);
    UNLOCK_HARDWARE(vmesa);
 
-   (*dri_interface->getUST)( &vmesa->swap_ust );
+   (*psp->systemTime->getUST)( &vmesa->swap_ust );
 }
 
 
-void viaPageFlip(const __DRIdrawablePrivate *dPriv)
+void viaPageFlip(__DRIdrawablePrivate *dPriv)
 {
     struct via_context *vmesa = 
        (struct via_context *)dPriv->driContextPriv->driverPrivate;
     struct via_renderbuffer buffer_tmp;
+    __DRIscreenPrivate *psp = dPriv->driScreenPriv;
 
     VIA_FLUSH_DMA(vmesa);
-   if (vmesa->vblank_flags == VBLANK_FLAG_SYNC &&
+   if (dPriv->vblFlags == VBLANK_FLAG_SYNC &&
        vmesa->lastBreadcrumbWrite > 1)
       viaWaitIdleVBlank(dPriv, vmesa, vmesa->lastBreadcrumbWrite - 1);
    else
@@ -654,7 +656,7 @@ void viaPageFlip(const __DRIdrawablePrivate *dPriv)
     viaEmitBreadcrumbLocked(vmesa);
     UNLOCK_HARDWARE(vmesa);
 
-    (*dri_interface->getUST)( &vmesa->swap_ust );
+    (*psp->systemTime->getUST)( &vmesa->swap_ust );
 
 
     /* KW: FIXME: When buffers are freed, could free frontbuffer by
index a81b427d807ea44445e4dacdf4a4a63a4c3d01c6..14a833a97d001eee270f88ab99e7b375e2830050 100644 (file)
@@ -33,8 +33,8 @@ 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 viaCopyBuffer(__DRIdrawablePrivate *dpriv);
+void viaPageFlip(__DRIdrawablePrivate *dpriv);
 void viaCheckDma(struct via_context *vmesa, GLuint bytes);
 void viaResetPageFlippingLocked(struct via_context *vmesa);
 void viaWaitIdle(struct via_context *vmesa, GLboolean light);
@@ -58,7 +58,7 @@ void viaEmitBreadcrumb( struct via_context *vmesa );
 
 void viaWrapPrimitive( struct via_context *vmesa );
 
-static __inline__ GLuint *viaAllocDma(struct via_context *vmesa, int bytes)
+static INLINE GLuint *viaAllocDma(struct via_context *vmesa, int bytes)
 {
    if (vmesa->dmaLow + bytes > VIA_DMA_HIGHWATER) {
       viaFlushDma(vmesa);
@@ -72,7 +72,7 @@ static __inline__ GLuint *viaAllocDma(struct via_context *vmesa, int bytes)
 }
 
 
-static GLuint __inline__ *viaExtendPrimitive(struct via_context *vmesa, int bytes)
+static GLuint INLINE *viaExtendPrimitive(struct via_context *vmesa, int bytes)
 {
    if (vmesa->dmaLow + bytes > VIA_DMA_HIGHWATER) {
       viaWrapPrimitive(vmesa);
index 387473ef5229f1f9bfede21b410f6234cde52407..d7e373d7dd0815b3e81305cb7aa7cf1d8a03fe04 100644 (file)
@@ -106,7 +106,7 @@ static GLboolean via_run_fastrender(GLcontext *ctx,
     tnl->clipspace.new_inputs |= VERT_BIT_POS;
 
     for (i = 0; i < VB->PrimitiveCount; ++i) {
-        GLuint mode = VB->Primitive[i].mode;
+        GLuint mode = _tnl_translate_prim(&VB->Primitive[i]);
         GLuint start = VB->Primitive[i].start;
         GLuint length = VB->Primitive[i].count;
         if (length)
index b81549df0e9f542eb14c9a59a9027be9b61c7e46..9c8eb908f160b8a376eee98a044f3e4f524a6b5c 100644 (file)
@@ -24,8 +24,8 @@
 
 #include <stdio.h>
 
-#include "utils.h"
 #include "dri_util.h"
+#include "utils.h"
 #include "glheader.h"
 #include "context.h"
 #include "framebuffer.h"
@@ -48,7 +48,7 @@
 
 #include "xmlpool.h"
 
-const char __driConfigOptions[] =
+PUBLIC const char __driConfigOptions[] =
 DRI_CONF_BEGIN
     DRI_CONF_SECTION_PERFORMANCE
         DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
@@ -64,8 +64,6 @@ 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;
@@ -98,9 +96,7 @@ 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;
+    int i;
 
     if (sPriv->devPrivSize != sizeof(VIADRIRec)) {
       fprintf(stderr,"\nERROR!  sizeof(VIADRIRec) does not match passed size from device driver\n");
@@ -175,17 +171,17 @@ viaInitDriver(__DRIscreenPrivate *sPriv)
 
     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_SGI_make_current_read" );
-       (*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" );
+    i = 0;
+    viaScreen->extensions[i++] = &driFrameTrackingExtension.base;
+    viaScreen->extensions[i++] = &driReadDrawableExtension;
+    if ( viaScreen->irqEnabled ) {
+       viaScreen->extensions[i++] = &driSwapControlExtension.base;
+       viaScreen->extensions[i++] = &driMediaStreamCounterExtension.base;
     }
 
+    viaScreen->extensions[i++] = NULL;
+    sPriv->extensions = viaScreen->extensions;
+
     return GL_TRUE;
 }
 
@@ -323,32 +319,11 @@ viaDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
    _mesa_unreference_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 )
+static const __DRIconfig **
+viaFillInModes( __DRIscreenPrivate *psp,
+               unsigned pixel_bits, GLboolean have_back_buffer )
 {
-    __GLcontextModes * modes;
-    __GLcontextModes * m;
-    unsigned num_modes;
+    __DRIconfig **configs;
     const unsigned back_buffer_factor = (have_back_buffer) ? 2 : 1;
     GLenum fb_format;
     GLenum fb_type;
@@ -369,9 +344,6 @@ viaFillInModes( unsigned pixel_bits, GLboolean have_back_buffer )
     static const uint8_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;
@@ -381,94 +353,61 @@ viaFillInModes( unsigned pixel_bits, GLboolean have_back_buffer )
         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__ );
+    configs = driCreateConfigs(fb_format, fb_type,
+                              depth_bits_array, stencil_bits_array,
+                              depth_buffer_factor, back_buffer_modes,
+                              back_buffer_factor);
+    if (configs == NULL) {
+       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;
+    return (const __DRIconfig **) configs;
 }
 
 
 /**
- * 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.
+ * This is the driver specific part of the createNewScreen entry point.
  * 
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on 
- *         failure.
+ * \todo maybe fold this into intelInitDriver
+ *
+ * \return the __GLcontextModes supported by this driver
  */
-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 )
-                            
+static const __DRIconfig **
+viaInitScreen(__DRIscreenPrivate *psp)
 {
-   __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 };
    static const char *driver_name = "Unichrome";
-
-   dri_interface = interface;
+   VIADRIPtr dri_priv = (VIADRIPtr) psp->pDevPriv;
 
    if ( ! driCheckDriDdxDrmVersions2( driver_name,
-                                     dri_version, & dri_expected,
-                                     ddx_version, & ddx_expected,
-                                     drm_version, & drm_expected) ) {
+                                     &psp->dri_version, & dri_expected,
+                                     &psp->ddx_version, & ddx_expected,
+                                     &psp->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 );
-   }
 
-   return (void *) psp;
+   /* 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 );
+
+   if (!viaInitDriver(psp))
+       return NULL;
+
+   return viaFillInModes( psp, dri_priv->bytesPerPixel * 8, GL_TRUE );
+
 }
 
 
@@ -497,3 +436,20 @@ getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo )
 
    return 0;
 }
+
+const struct __DriverAPIRec driDriverAPI = {
+   .InitScreen      = viaInitScreen,
+   .DestroyScreen   = viaDestroyScreen,
+   .CreateContext   = viaCreateContext,
+   .DestroyContext  = viaDestroyContext,
+   .CreateBuffer    = viaCreateBuffer,
+   .DestroyBuffer   = viaDestroyBuffer,
+   .SwapBuffers     = viaSwapBuffers,
+   .MakeCurrent     = viaMakeCurrent,
+   .UnbindContext   = viaUnbindContext,
+   .GetSwapInfo     = getSwapInfo,
+   .GetDrawableMSC  = driDrawableGetMSC32,
+   .WaitForMSC      = driWaitForMSC32,
+   .WaitForSBC      = NULL,
+   .SwapBuffersMSC  = NULL
+};
index 84aa5aef88e0f0e4d221b38829a212325b29f789..c3ef722ff0720fe780e1644630d8f26a8be6c932 100644 (file)
@@ -70,6 +70,8 @@ typedef struct {
 
     /* Configuration cache with default values for all contexts */
     driOptionCache optionCache;
+
+    const __DRIextension *extensions[5];
 } viaScreenPrivate;
 
 
index 3a16dadd238e0fba4b80a23f4b862ba4fa3b5dbc..15e29c52cd9c386b0d3ce5a67812a2f124b0a90f 100644 (file)
@@ -86,6 +86,7 @@
 
 #define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS 
 
+#define VALUE_TYPE GLushort
 
 #define WRITE_DEPTH(_x, _y, d)                      \
     *(GLushort *)(buf + (_x) * 2 + (_y) * depth_pitch) = d;
@@ -98,6 +99,8 @@
 
 /* 32 bit depthbuffer functions.
  */
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH(_x, _y, d)                      \
     *(GLuint *)(buf + (_x) * 4 + (_y) * depth_pitch) = d;
 
 
 /* 24/8 bit interleaved depth/stencil functions
  */
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d ) {                     \
    GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch);  \
    tmp &= 0x000000ff;                                  \
index 5b0453423ef157204bdcad89810aed6193394bfa..7957003bcb03acaaccd8c20257258dfeecfc6855 100644 (file)
@@ -511,9 +511,9 @@ void viaEmitState(struct via_context *vmesa)
 }
 
 
-static __inline__ GLuint viaPackColor(GLuint bpp,
-                                      GLubyte r, GLubyte g,
-                                      GLubyte b, GLubyte a)
+static INLINE GLuint viaPackColor(GLuint bpp,
+                                  GLubyte r, GLubyte g,
+                                  GLubyte b, GLubyte a)
 {
     switch (bpp) {
     case 16:
@@ -656,13 +656,18 @@ static void viaDrawBuffer(GLcontext *ctx, GLenum mode)
    if (!ctx->DrawBuffer)
       return;
 
-   switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
-   case BUFFER_BIT_FRONT_LEFT:
+   if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) {
+      FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_TRUE);
+      return;
+   }
+
+   switch ( ctx->DrawBuffer->_ColorDrawBufferIndexes[0] ) {
+   case BUFFER_FRONT_LEFT:
       VIA_FLUSH_DMA(vmesa);
       vmesa->drawBuffer = &vmesa->front;
       FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_FALSE);
       break;
-   case BUFFER_BIT_BACK_LEFT:
+   case BUFFER_BACK_LEFT:
       VIA_FLUSH_DMA(vmesa);
       vmesa->drawBuffer = &vmesa->back;
       FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_FALSE);
index 0261a3ff177e14f6ddbd684928035a95b6be051d..15f15a89a6f3373936b9a5b130a9341831902bfe 100644 (file)
@@ -820,9 +820,7 @@ static void viaTexImage(GLcontext *ctx,
 
    /* GL_SGIS_generate_mipmap */
    if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
-      _mesa_generate_mipmap(ctx, target,
-                            &ctx->Texture.Unit[ctx->Texture.CurrentUnit],
-                            texObj);
+      _mesa_generate_mipmap(ctx, target, texObj);
    }
 
    _mesa_unmap_teximage_pbo(ctx, packing);
index 4cc7942b1b617fe88b3a8b21fb6fc92212ba5d2e..b97dacde24154b8a80216ae01f824d8bba0f821e 100644 (file)
@@ -625,13 +625,12 @@ static void viaFastRenderClippedPoly(GLcontext *ctx, const GLuint *elts,
     }
 }
 
+
 /**********************************************************************/
 /*                    Choose render functions                         */
 /**********************************************************************/
 
 
-
-
 #define _VIA_NEW_VERTEX (_NEW_TEXTURE |                         \
                          _DD_NEW_SEPARATE_SPECULAR |            \
                          _DD_NEW_TRI_UNFILLED |                 \
@@ -665,14 +664,17 @@ static void viaChooseRenderState(GLcontext *ctx)
       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 & (ANY_FALLBACK_FLAGS | ANY_RASTER_FLAGS)) {
+      if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
+         index |= VIA_TWOSIDE_BIT;
+      if (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL)
+         index |= VIA_UNFILLED_BIT;
+      if (flags & DD_TRI_OFFSET)
+         index |= VIA_OFFSET_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;
       
@@ -683,11 +685,8 @@ static void viaChooseRenderState(GLcontext *ctx)
         vmesa->drawTri = via_fallback_tri;
    }
 
-
-   if ((flags & DD_SEPARATE_SPECULAR) &&
-       ctx->Light.ShadeModel == GL_FLAT) {
+   if ((flags & DD_SEPARATE_SPECULAR) && ctx->Light.ShadeModel == GL_FLAT)
       index = VIA_MAX_TRIFUNC; /* flat specular */
-   }
 
    if (vmesa->renderIndex != index) {
       vmesa->renderIndex = index;
index c0ef54f604f7e7b55410de175cc3a25d244faa40..ee73f29a46ae942cc294dc9b26287e4fb8cb5b18 100644 (file)
@@ -25,8 +25,7 @@ default: $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
 
 
 $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(CORE_MESA) $(OBJECTS)
-       @ $(TOP)/bin/mklib -o $(GL_LIB) \
-               -linker '$(CC)' -ldflags '$(LDFLAGS)' \
+       @ $(MKLIB) -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
                -major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \
                -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \
                $(CORE_MESA) $(OBJECTS) $(GL_LIB_DEPS)
index e95a424698c4d41928d162d158864a93adb6a8a4..f3da4a5ba259c5fcafaa2bec5653f89b89d86b47 100644 (file)
@@ -790,6 +790,11 @@ glFBDevCreateContext( const GLFBDevVisualPtr visual, GLFBDevContextPtr share )
    }
 
    _mesa_enable_sw_extensions(glctx);
+   _mesa_enable_1_3_extensions(glctx);
+   _mesa_enable_1_4_extensions(glctx);
+   _mesa_enable_1_5_extensions(glctx);
+   _mesa_enable_2_0_extensions(glctx);
+   _mesa_enable_2_1_extensions(glctx);
 
    return ctx;
 }
index 4e56f7bde50881bde789c72917424d3b4d78112d..c082fd827f2bad1fbc1fa49c542ac22a815fd38b 100644 (file)
@@ -1955,8 +1955,8 @@ fx_check_IsInHardware(GLcontext * ctx)
       return FX_FALLBACK_STENCIL;
    }
 
-   if (ctx->DrawBuffer->_ColorDrawBufferMask[0] != BUFFER_BIT_FRONT_LEFT &&
-       ctx->DrawBuffer->_ColorDrawBufferMask[0] != BUFFER_BIT_BACK_LEFT) {
+   if ((ctx->DrawBuffer->_ColorDrawBufferIndexes[0] != BUFFER_BIT_FRONT_LEFT) &&
+       (ctx->DrawBuffer->_ColorDrawBufferIndexes[0] != BUFFER_BIT_BACK_LEFT)) {
       return FX_FALLBACK_DRAW_BUFFER;
    }
 
index 3ea9f73dd2043c48530dc44adbb666e771cc1ef5..d3a58a301c2c15c5f33988b9471f2688e53cd788 100644 (file)
 #undef BYTESPERPIXEL
 #define BYTESPERPIXEL 2
 
+#define VALUE_TYPE GLushort
+
 #define WRITE_DEPTH( _x, _y, d )                                       \
     *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = d
 
 #undef BYTESPERPIXEL
 #define BYTESPERPIXEL 4
 
+#define VALUE_TYPE GLuint
+
 #define WRITE_DEPTH( _x, _y, d )                                       \
     *(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch) = d << 8
 
index 858457ddd40118798e13b17145f47ba2ee5233d4..dc4abd44d4937fc9168fed27e63ef15c5a296148 100644 (file)
@@ -41,4 +41,4 @@ glslcompiler.o: glslcompiler.c
 
 
 clean:
-       rm -f *.o *~ $(PROGRAM)
+       -rm -f *.o *~ $(PROGRAM)
index fa8dffcb3ef307228310fedb0de9cb1d1cefd8a6..d6a18b1d755080861842f633c388c50e2de1a388 100644 (file)
@@ -45,11 +45,10 @@ default:
 osmesa8: $(TOP)/lib/$(OSMESA_LIB_NAME)
 
 $(TOP)/lib/$(OSMESA_LIB_NAME): $(OBJECTS)
-       $(TOP)/bin/mklib -o $(OSMESA_LIB) \
-               -linker "$(CC)" \
+       $(MKLIB) -o $(OSMESA_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
                -major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \
-               -install $(TOP)/$(LIB_DIR) \
-               $(MKLIB_OPTIONS) \
+               -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \
+               -id $(INSTALL_LIB_DIR)/lib$(OSMESA_LIB).$(MESA_MAJOR).dylib \
                $(OSMESA_LIB_DEPS) $(OBJECTS)
 
 
@@ -58,11 +57,10 @@ $(TOP)/lib/$(OSMESA_LIB_NAME): $(OBJECTS)
 # The libOSMesa16/libOSMesa32 libraries do not use libGL but rather are built
 # with all the other Mesa sources (compiled with -DCHAN_BITS=16/32
 osmesa16: $(OBJECTS) $(CORE_MESA)
-       $(TOP)/bin/mklib -o $(OSMESA_LIB) \
-               -linker "$(CC)" \
+       $(MKLIB) -o $(OSMESA_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
                -major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \
-               -install $(TOP)/$(LIB_DIR) \
-               $(MKLIB_OPTIONS) \
+               -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \
+               -id $(INSTALL_LIB_DIR)/lib$(OSMESA_LIB).$(MESA_MAJOR).dylib \
                $(OSMESA_LIB_DEPS) $(OBJECTS) $(CORE_MESA)
 
 
diff --git a/src/mesa/drivers/osmesa/descrip.mms b/src/mesa/drivers/osmesa/descrip.mms
new file mode 100644 (file)
index 0000000..6c2f322
--- /dev/null
@@ -0,0 +1,45 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen  joukj@hrem.nano.tudelft.nl
+# Last revision : 3 October 2007
+
+.first
+       define gl [----.include.gl]
+       define math [--.math]
+       define tnl [--.tnl]
+       define vbo [--.vbo]
+       define swrast [--.swrast]
+       define swrast_setup [--.swrast_setup]
+       define array_cache [--.array_cache]
+       define drivers [-]
+       define glapi [--.glapi]
+       define main [--.main]
+       define shader [--.shader]
+
+.include [----]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [----.include],[--.main],[--.glapi],[--.shader]
+LIBDIR = [----.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)/float=ieee/ieee=denorm
+
+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
index 399997bdecba51edbf2fa77fbe934cdcc4de8213..f2367bbbb70cf953c7d80957ffe295aeb49f7710 100644 (file)
@@ -1226,6 +1226,8 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
       _mesa_enable_1_3_extensions(&(osmesa->mesa));
       _mesa_enable_1_4_extensions(&(osmesa->mesa));
       _mesa_enable_1_5_extensions(&(osmesa->mesa));
+      _mesa_enable_2_0_extensions(&(osmesa->mesa));
+      _mesa_enable_2_1_extensions(&(osmesa->mesa));
 
       osmesa->gl_buffer = _mesa_create_framebuffer(osmesa->gl_visual);
       if (!osmesa->gl_buffer) {
index c7c095333fe3e45ec6de36f5a582c15805de99c7..f2ec9c0364a2b4a90e58ca7c5830218cd6886ec9 100644 (file)
@@ -39,7 +39,7 @@
 
 #if 0
 /* this doesn't compile with GCC on RedHat 6.1 */
-static inline int RGB2BGR24(int c)
+static INLINE int RGB2BGR24(int c)
 {
        asm("rorw  $8, %0\n"     
            "rorl $16, %0\n"     
index d089c20c050d1d5d6667e5e67871f77080d43a5c..8eea3cbe648e0a2adffe9411914601b441082171 100644 (file)
@@ -39,7 +39,7 @@
 
 #if 0
 /* this doesn't compile with GCC on RedHat 6.1 */
-static inline int RGB2BGR32(int c)
+static INLINE int RGB2BGR32(int c)
 {
        asm("rorw  $8, %0\n"     
            "rorl $16, %0\n"     
index c525945426fa6e8f71d8c69097adfb034be3c3f0..3f2d644e86efe208c0f2e83250f9715a64111512 100644 (file)
@@ -867,8 +867,6 @@ EXPORTS
        _glapi_get_proc_address
        _mesa_add_soft_renderbuffers
        _mesa_add_renderbuffer
-       _mesa_attach_shader
-       _mesa_bind_attrib_location
        _mesa_buffer_data
        _mesa_buffer_get_subdata
        _mesa_buffer_map
@@ -877,24 +875,20 @@ EXPORTS
        _mesa_bzero
        _mesa_calloc
        _mesa_choose_tex_format
-       _mesa_compile_shader
        _mesa_compressed_texture_size
        _mesa_create_framebuffer
-       _mesa_create_program
-       _mesa_create_shader
        _mesa_create_visual
        _mesa_delete_array_object
        _mesa_delete_buffer_object
        _mesa_delete_program
-       _mesa_delete_program2
-       _mesa_delete_shader
        _mesa_delete_texture_object
        _mesa_destroy_framebuffer
        _mesa_destroy_visual
-       _mesa_detach_shader
        _mesa_enable_1_3_extensions
        _mesa_enable_1_4_extensions
        _mesa_enable_1_5_extensions
+       _mesa_enable_2_0_extensions
+       _mesa_enable_2_1_extensions
        _mesa_enable_sw_extensions
        _mesa_error
        _mesa_finish_render_texture
@@ -902,28 +896,15 @@ EXPORTS
        _mesa_free
        _mesa_free_context_data
        _mesa_free_texture_image_data
-       _mesa_get_active_attrib
-       _mesa_get_active_uniform 
-       _mesa_get_attached_shaders
-       _mesa_get_attrib_location
+       _mesa_generate_mipmap
        _mesa_get_compressed_teximage
        _mesa_get_current_context
-       _mesa_get_handle
-       _mesa_get_programiv
-       _mesa_get_program_info_log
        _mesa_get_program_register
-       _mesa_get_shaderiv
-       _mesa_get_shader_info_log
-       _mesa_get_shader_source
        _mesa_get_teximage
-       _mesa_get_uniformfv
-       _mesa_get_uniform_location
        _mesa_init_driver_functions
+       _mesa_init_glsl_driver_functions
        _mesa_init_renderbuffer
        _mesa_initialize_context
-       _mesa_is_program
-       _mesa_is_shader
-       _mesa_link_program
        _mesa_make_current
        _mesa_memcpy
        _mesa_memset
@@ -942,7 +923,6 @@ EXPORTS
        _mesa_render_texture
        _mesa_ResizeBuffersMESA
        _mesa_resize_framebuffer
-       _mesa_shader_source
        _mesa_store_compressed_teximage1d
        _mesa_store_compressed_teximage2d
        _mesa_store_compressed_teximage3d
@@ -957,12 +937,9 @@ EXPORTS
        _mesa_store_texsubimage3d
        _mesa_strcmp
        _mesa_test_proxy_teximage
-       _mesa_uniform
-       _mesa_uniform_matrix
        _mesa_unreference_framebuffer
        _mesa_update_framebuffer_visual
        _mesa_use_program
-       _mesa_validate_program
        _mesa_Viewport
        _swrast_Accum
        _swrast_Bitmap
index 6e00d08abafa616147887db685e090e0aafebb00..9f0bb9122a995a8da788a02368904ee7c537926d 100644 (file)
@@ -54,7 +54,7 @@
 #include <windows.h>
 
 #endif
-
+#include "config.h"
 #include "glapi.h"
 #include "GL/wmesa.h"   /* protos for wmesa* functions */
 
@@ -69,10 +69,12 @@ struct __pixelformat__
     GLboolean doubleBuffered;
 };
 
+
+
 /* These are the PFD's supported by this driver. */
 struct __pixelformat__ pfd[] =
 {
-#if 0
+#if 0 
     /* Double Buffer, alpha */
     {  
        {       
@@ -86,7 +88,7 @@ struct __pixelformat__        pfd[] =
            8, 16,      
            8, 24,
            0, 0, 0, 0, 0,      
-           16, 8,      
+           DEFAULT_SOFTWARE_DEPTH_BITS,        8,      
            0, 0, 0,    
            0, 0, 0 
        },
@@ -105,13 +107,13 @@ struct __pixelformat__    pfd[] =
            8, 16,      
            8, 24,
            0, 0, 0, 0, 0,      
-           16, 8,
+           DEFAULT_SOFTWARE_DEPTH_BITS,        8,      
            0, 0, 0,    
            0, 0, 0
        },
         GL_FALSE
     },
-#endif
+#endif 
     /* Double Buffer, no alpha */
     {  
        {       
@@ -125,7 +127,7 @@ struct __pixelformat__      pfd[] =
            8, 16,
            0, 0,
            0, 0, 0, 0, 0,
-           16, 8,
+           DEFAULT_SOFTWARE_DEPTH_BITS,        8,      
            0, 0, 0, 
            0, 0, 0 
        },
@@ -144,7 +146,7 @@ struct __pixelformat__      pfd[] =
            8, 16,
            0, 0,
            0, 0, 0, 0, 0,
-           16, 8,
+           DEFAULT_SOFTWARE_DEPTH_BITS,        8,      
            0, 0, 0,
            0, 0, 0 
        },
@@ -578,6 +580,13 @@ WINGDIAPI BOOL GLAPIENTRY wglUseFontBitmapsA(HDC hdc, DWORD first,
     return success;
 }
 
+WINGDIAPI BOOL GLAPIENTRY wglShareLists(HGLRC hglrc1,
+                                       HGLRC hglrc2)
+{
+    WMesaShareLists((WMesaContext)hglrc1, (WMesaContext)hglrc2);
+    return(TRUE);
+}
+
 
 
 /* NOT IMPLEMENTED YET */
@@ -597,13 +606,6 @@ WINGDIAPI HGLRC GLAPIENTRY wglCreateLayerContext(HDC hdc,
     return(NULL);
 }
 
-WINGDIAPI BOOL GLAPIENTRY wglShareLists(HGLRC hglrc1,
-                                       HGLRC hglrc2)
-{
-    (void) hglrc1; (void) hglrc2;
-    return(TRUE);
-}
-
 
 WINGDIAPI BOOL GLAPIENTRY wglUseFontBitmapsW(HDC hdc,
                                             DWORD first,
index 5b67439f0f2577f106e63491b698ff7b804132e0..9dafb74723163f0e9d2e4c8876d82f55e4c58f99 100644 (file)
@@ -118,6 +118,7 @@ static void wmSetPixelFormat(WMesaFramebuffer pwfb, HDC hDC)
     /* Only 16 and 32 bit targets are supported now */
     assert(pwfb->cColorBits == 0 ||
           pwfb->cColorBits == 16 || 
+          pwfb->cColorBits == 24 || 
           pwfb->cColorBits == 32);
 
     switch(pwfb->cColorBits){
@@ -127,6 +128,7 @@ static void wmSetPixelFormat(WMesaFramebuffer pwfb, HDC hDC)
     case 16:
        pwfb->pixelformat = PF_5R6G5B;
        break;
+    case 24:
     case 32:
        pwfb->pixelformat = PF_8R8G8B;
        break;
@@ -458,23 +460,84 @@ static void write_rgba_span_front(const GLcontext *ctx,
                                   const GLubyte rgba[][4], 
                                   const GLubyte mask[] )
 {
-    WMesaContext pwc = wmesa_context(ctx);
-    GLuint i;
-    
-    (void) ctx;
-    y=FLIP(y);
-    if (mask) {
-       for (i=0; i<n; i++)
-           if (mask[i])
-               SetPixel(pwc->hDC, x+i, y, RGB(rgba[i][RCOMP], rgba[i][GCOMP], 
-                                              rgba[i][BCOMP]));
-    }
-    else {
-       for (i=0; i<n; i++)
-           SetPixel(pwc->hDC, x+i, y, RGB(rgba[i][RCOMP], rgba[i][GCOMP], 
-                                          rgba[i][BCOMP]));
-    }
-    
+   WMesaContext pwc = wmesa_context(ctx);
+   WMesaFramebuffer pwfb = wmesa_lookup_framebuffer(pwc->hDC);
+   CONST BITMAPINFO bmi=
+   {
+      {
+         sizeof(BITMAPINFOHEADER),
+         n, 1, 1, 32, BI_RGB, 0, 1, 1, 0, 0
+      }
+   };
+   HBITMAP bmp=0;
+   HDC mdc=0;
+   typedef union
+   {
+      unsigned i;
+      struct {
+         unsigned b:8, g:8, r:8, a:8;
+      };
+   } BGRA;
+   BGRA *bgra, c;
+   int i;
+
+   if (n < 16) {   // the value 16 is just guessed
+      y=FLIP(y);
+      if (mask) {
+         for (i=0; i<n; i++)
+            if (mask[i])
+               SetPixel(pwc->hDC, x+i, y,
+                        RGB(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]));
+      }
+      else {
+         for (i=0; i<n; i++)
+            SetPixel(pwc->hDC, x+i, y,
+                     RGB(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]));
+      }
+   }
+   else {
+      if (!pwfb) {
+         _mesa_problem(NULL, "wmesa: write_rgba_span_front on unknown hdc");
+         return;
+      }
+      bgra=malloc(n*sizeof(BGRA));
+      if (!bgra) {
+         _mesa_problem(NULL, "wmesa: write_rgba_span_front: out of memory");
+         return;
+      }
+      c.a=0;
+      if (mask) {
+         for (i=0; i<n; i++) {
+            if (mask[i]) {
+               c.r=rgba[i][RCOMP];
+               c.g=rgba[i][GCOMP];
+               c.b=rgba[i][BCOMP];
+               c.a=rgba[i][ACOMP];
+               bgra[i]=c;
+            }
+            else
+               bgra[i].i=0;
+         }
+      }
+      else {
+         for (i=0; i<n; i++) {
+            c.r=rgba[i][RCOMP];
+            c.g=rgba[i][GCOMP];
+            c.b=rgba[i][BCOMP];
+            c.a=rgba[i][ACOMP];
+            bgra[i]=c;
+         }
+      }
+      bmp=CreateBitmap(n, 1,  1, 32, bgra);
+      mdc=CreateCompatibleDC(pwfb->hDC);
+      SelectObject(mdc, bmp);
+      y=FLIP(y);
+      BitBlt(pwfb->hDC, x, y, n, 1, mdc, 0, 0, SRCCOPY);
+      SelectObject(mdc, 0);
+      DeleteObject(bmp);
+      DeleteDC(mdc);
+      free(bgra);
+   }
 }
 
 /* Write a horizontal span of RGB color pixels with a boolean mask. */
@@ -793,6 +856,195 @@ static void read_rgba_pixels_32(const GLcontext *ctx,
 }
 
 
+/*********************************************************************/
+
+/* DOUBLE BUFFER 24-bit */
+
+#define WMSETPIXEL24(pwc, y, x, r, g, b) { \
+LPBYTE lpb = ((LPBYTE)((pwc)->pbPixels + (pwc)->ScanWidth * (y)) + (3 * x)); \
+lpb[0] = (b); \
+lpb[1] = (g); \
+lpb[2] = (r); }
+
+/* Write a horizontal span of RGBA color pixels with a boolean mask. */
+static void write_rgba_span_24(const GLcontext *ctx, 
+                              struct gl_renderbuffer *rb, 
+                              GLuint n, GLint x, GLint y,
+                              const GLubyte rgba[][4], 
+                              const GLubyte mask[] )
+{
+    WMesaContext pwc = wmesa_context(ctx);
+    WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer);
+    GLuint i;
+    LPBYTE lpb;
+
+    (void) ctx;
+    
+    y=FLIP(y);
+    lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y)) + (3 * x);
+    if (mask) {
+       for (i=0; i<n; i++)
+           if (mask[i]) {
+                lpb[3*i] = rgba[i][BCOMP];
+                lpb[3*i+1] = rgba[i][GCOMP];
+                lpb[3*i+2] = rgba[i][RCOMP];
+           }
+    }
+    else {
+           for (i=0; i<n; i++) {
+            *lpb++ = rgba[i][BCOMP];
+            *lpb++ = rgba[i][GCOMP];
+            *lpb++ = rgba[i][RCOMP];
+           }
+    }
+}
+
+
+/* Write a horizontal span of RGB color pixels with a boolean mask. */
+static void write_rgb_span_24(const GLcontext *ctx, 
+                             struct gl_renderbuffer *rb, 
+                             GLuint n, GLint x, GLint y,
+                             const GLubyte rgb[][3], 
+                             const GLubyte mask[] )
+{
+    WMesaContext pwc = wmesa_context(ctx);
+    WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer);
+    GLuint i;
+    LPBYTE lpb;
+
+    (void) ctx;
+    
+    y=FLIP(y);
+    lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y)) + (3 * x);
+    if (mask) {
+       for (i=0; i<n; i++)
+           if (mask[i]) {
+            lpb[3*i] = rgb[i][BCOMP];
+            lpb[3*i+1] = rgb[i][GCOMP];
+            lpb[3*i+2] = rgb[i][RCOMP];
+           }
+    }
+    else {
+       for (i=0; i<n; i++) {
+               *lpb++ = rgb[i][BCOMP];
+               *lpb++ = rgb[i][GCOMP];
+               *lpb++ = rgb[i][RCOMP];
+       }
+    }
+}
+
+/*
+ * Write a horizontal span of pixels with a boolean mask.  The current color
+ * is used for all pixels.
+ */
+static void write_mono_rgba_span_24(const GLcontext *ctx, 
+                                   struct gl_renderbuffer *rb,
+                                   GLuint n, GLint x, GLint y,
+                                   const GLchan color[4], 
+                                   const GLubyte mask[])
+{
+    LPBYTE lpb;
+    GLuint i;
+    WMesaContext pwc = wmesa_context(ctx);
+    WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer);
+    lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y)) + (3 * x);
+    y=FLIP(y);
+    if (mask) {
+       for (i=0; i<n; i++)
+           if (mask[i]) {
+               lpb[3*i] = color[BCOMP];
+               lpb[3*i+1] = color[GCOMP];
+               lpb[3*i+2] = color[RCOMP];
+           }
+    }
+    else
+       for (i=0; i<n; i++) {
+               *lpb++ = color[BCOMP];
+               *lpb++ = color[GCOMP];
+               *lpb++ = color[RCOMP];          
+       }
+}
+
+/* Write an array of RGBA pixels with a boolean mask. */
+static void write_rgba_pixels_24(const GLcontext *ctx, 
+                                struct gl_renderbuffer *rb,
+                                GLuint n, const GLint x[], const GLint y[],
+                                const GLubyte rgba[][4], 
+                                const GLubyte mask[])
+{
+    GLuint i;
+    WMesaContext pwc = wmesa_context(ctx);
+    WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer);
+    for (i=0; i<n; i++)
+       if (mask[i])
+           WMSETPIXEL24(pwfb, FLIP(y[i]), x[i],
+                        rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
+}
+
+/*
+ * Write an array of pixels with a boolean mask.  The current color
+ * is used for all pixels.
+ */
+static void write_mono_rgba_pixels_24(const GLcontext *ctx, 
+                                     struct gl_renderbuffer *rb,
+                                     GLuint n,
+                                     const GLint x[], const GLint y[],
+                                     const GLchan color[4],
+                                     const GLubyte mask[])
+{
+    GLuint i;
+    WMesaContext pwc = wmesa_context(ctx);
+    WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer);
+    for (i=0; i<n; i++)
+       if (mask[i])
+           WMSETPIXEL24(pwfb, FLIP(y[i]),x[i],color[RCOMP],
+                        color[GCOMP], color[BCOMP]);
+}
+
+/* Read a horizontal span of color pixels. */
+static void read_rgba_span_24(const GLcontext *ctx, 
+                             struct gl_renderbuffer *rb,
+                             GLuint n, GLint x, GLint y,
+                             GLubyte rgba[][4] )
+{
+    GLuint i;
+    LPBYTE lpb;
+    WMesaContext pwc = wmesa_context(ctx);
+    WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer);
+    
+    y = FLIP(y);
+    lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y)) + (3 * x);
+    for (i=0; i<n; i++) {
+       rgba[i][RCOMP] = lpb[3*i+2];
+       rgba[i][GCOMP] = lpb[3*i+1];
+       rgba[i][BCOMP] = lpb[3*i];
+       rgba[i][ACOMP] = 255;
+    }
+}
+
+
+/* Read an array of color pixels. */
+static void read_rgba_pixels_24(const GLcontext *ctx, 
+                               struct gl_renderbuffer *rb,
+                               GLuint n, const GLint x[], const GLint y[],
+                               GLubyte rgba[][4])
+{
+    GLuint i;
+    LPBYTE lpb;
+    WMesaContext pwc = wmesa_context(ctx);
+    WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer);
+
+    for (i=0; i<n; i++) {
+       GLint y2 = FLIP(y[i]);
+       lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y2)) + (3 * x[i]);
+       rgba[i][RCOMP] = lpb[3*i+2];
+       rgba[i][GCOMP] = lpb[3*i+1];
+       rgba[i][BCOMP] = lpb[3*i];
+       rgba[i][ACOMP] = 255;
+  }
+}
+
+
 /*********************************************************************/
 
 /* DOUBLE BUFFER 16-bit */
@@ -1016,7 +1268,7 @@ wmesa_renderbuffer_storage(GLcontext *ctx,
  * on if we're drawing to the front or back color buffer.
  */
 void wmesa_set_renderbuffer_funcs(struct gl_renderbuffer *rb, int pixelformat,
-                                  int double_buffer)
+                                  BYTE cColorBits, int double_buffer)
 {
     if (double_buffer) {
         /* back buffer */
@@ -1036,16 +1288,32 @@ void wmesa_set_renderbuffer_funcs(struct gl_renderbuffer *rb, int pixelformat,
             rb->BlueBits = 5;
            break;
        case PF_8R8G8B:
-           rb->PutRow = write_rgba_span_32;
-           rb->PutRowRGB = write_rgb_span_32;
-           rb->PutMonoRow = write_mono_rgba_span_32;
-           rb->PutValues = write_rgba_pixels_32;
-           rb->PutMonoValues = write_mono_rgba_pixels_32;
-           rb->GetRow = read_rgba_span_32;
-           rb->GetValues = read_rgba_pixels_32;
+               if (cColorBits == 24)
+               {
+                   rb->PutRow = write_rgba_span_24;
+                   rb->PutRowRGB = write_rgb_span_24;
+                   rb->PutMonoRow = write_mono_rgba_span_24;
+                   rb->PutValues = write_rgba_pixels_24;
+                   rb->PutMonoValues = write_mono_rgba_pixels_24;
+                   rb->GetRow = read_rgba_span_24;
+                   rb->GetValues = read_rgba_pixels_24;
+               rb->RedBits = 8;
+               rb->GreenBits = 8;
+               rb->BlueBits = 8;               
+               }
+               else
+               {
+               rb->PutRow = write_rgba_span_32;
+               rb->PutRowRGB = write_rgb_span_32;
+               rb->PutMonoRow = write_mono_rgba_span_32;
+               rb->PutValues = write_rgba_pixels_32;
+               rb->PutMonoValues = write_mono_rgba_pixels_32;
+               rb->GetRow = read_rgba_span_32;
+               rb->GetValues = read_rgba_pixels_32;
             rb->RedBits = 8;
             rb->GreenBits = 8;
             rb->BlueBits = 8;
+               }
            break;
        default:
            break;
@@ -1352,11 +1620,11 @@ void WMesaMakeCurrent(WMesaContext c, HDC hdc)
         if (visual->doubleBufferMode == 1) {
             rb = wmesa_new_renderbuffer();
             _mesa_add_renderbuffer(&pwfb->Base, BUFFER_BACK_LEFT, rb);
-            wmesa_set_renderbuffer_funcs(rb, pwfb->pixelformat, 1);
+            wmesa_set_renderbuffer_funcs(rb, pwfb->pixelformat, pwfb->cColorBits, 1);
        }
         rb = wmesa_new_renderbuffer();
         _mesa_add_renderbuffer(&pwfb->Base, BUFFER_FRONT_LEFT, rb);
-        wmesa_set_renderbuffer_funcs(rb, pwfb->pixelformat, 0);
+        wmesa_set_renderbuffer_funcs(rb, pwfb->pixelformat, pwfb->cColorBits, 0);
 
        /* Let Mesa own the Depth, Stencil, and Accum buffers */
         _mesa_add_soft_renderbuffers(&pwfb->Base,
@@ -1401,6 +1669,11 @@ void WMesaSwapBuffers( HDC hdc )
     }
 }
 
+void WMesaShareLists(WMesaContext ctx_to_share, WMesaContext ctx)
+{
+       _mesa_share_state(&ctx->gl_ctx, &ctx_to_share->gl_ctx); 
+}
+
 /* This is hopefully a temporary hack to define some needed dispatch
  * table entries.  Hopefully, I'll find a better solution.  The
  * dispatch table generation scripts ought to be making these dummy
@@ -1439,15 +1712,19 @@ void gl_dispatch_stub_650(void){}
 void gl_dispatch_stub_651(void){}
 void gl_dispatch_stub_652(void){}
 void gl_dispatch_stub_653(void){}
+void gl_dispatch_stub_733(void){}
 void gl_dispatch_stub_734(void){}
 void gl_dispatch_stub_735(void){}
 void gl_dispatch_stub_736(void){}
 void gl_dispatch_stub_737(void){}
 void gl_dispatch_stub_738(void){}
+void gl_dispatch_stub_744(void){}
 void gl_dispatch_stub_745(void){}
 void gl_dispatch_stub_746(void){}
 void gl_dispatch_stub_760(void){}
 void gl_dispatch_stub_761(void){}
+void gl_dispatch_stub_763(void){}
+void gl_dispatch_stub_765(void){}
 void gl_dispatch_stub_766(void){}
 void gl_dispatch_stub_767(void){}
 void gl_dispatch_stub_768(void){}
index 51226eeae1177fce5e7df57beff039e49e62ab11..d2780e62c979fa10f64587ce964c5f136712192d 100644 (file)
@@ -55,11 +55,11 @@ default: $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
 
 
 $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) $(CORE_MESA)
-       @ $(TOP)/bin/mklib -o $(GL_LIB) \
-               -linker '$(CC)' -ldflags '$(LDFLAGS)' \
+       @ $(MKLIB) -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
                -major $(GL_MAJOR) -minor $(GL_MINOR) -patch $(GL_TINY) \
-               -install $(TOP)/$(LIB_DIR) \
-               $(MKLIB_OPTIONS) $(GL_LIB_DEPS) $(OBJECTS) $(CORE_MESA)
+               -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \
+               -id $(INSTALL_LIB_DIR)/lib$(GL_LIB).$(GL_MAJOR).dylib \
+               $(GL_LIB_DEPS) $(OBJECTS) $(CORE_MESA)
 
 
 
diff --git a/src/mesa/drivers/x11/descrip.mms b/src/mesa/drivers/x11/descrip.mms
new file mode 100644 (file)
index 0000000..648f683
--- /dev/null
@@ -0,0 +1,55 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen  joukj@hrem.nano.tudelft.nl
+# Last revision : 3 October 2007
+
+.first
+       define gl [----.include.gl]
+       define math [--.math]
+       define tnl [--.tnl]
+       define vbo [--.vbo]
+       define swrast [--.swrast]
+       define swrast_setup [--.swrast_setup]
+       define array_cache [--.array_cache]
+       define drivers [-]
+       define glapi [--.glapi]
+       define main [--.main]
+       define shader [--.shader]
+
+.include [----]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [----.include],[--.main],[--.glapi],[--.shader]
+LIBDIR = [----.lib]
+CFLAGS =/include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)/float=ieee/ieee=denorm
+
+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
index 7a170b4d3d10b7e0eb3fddd5b9e03bc4397e10ff..e5cd8f0b8054166f3bffeaccfedb1ca8c41088df 100644 (file)
@@ -1183,11 +1183,12 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig )
           * GLX_ARB_multisample
           */
          case GLX_SAMPLE_BUFFERS_ARB:
-            /* ms not supported */
-            return NULL;
          case GLX_SAMPLES_ARB:
-            /* ms not supported */
-            return NULL;
+           parselist++;
+           if (*parselist++ != 0)
+              /* ms not supported */
+              return NULL;
+           break;
 
          /*
           * FBConfig attribs.
index 309a0008d768cb1ca540ad3b512ea7df0ea77078..c2ccce6f520801c7f47e33c7d916a03830543e5b 100644 (file)
@@ -34,8 +34,8 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include "glheader.h"
-#include "glapi.h"
+#include "main/glheader.h"
+#include "glapi/glapi.h"
 #include "glxapi.h"
 
 
index a402191f1310f5744e7a7722816ef9024882a615..15e8390583402489f1bbf3d3d57ecc328c94c452 100644 (file)
@@ -34,6 +34,7 @@
 
 #ifdef XFree86Server
 
+# include "xorg-server.h"
 # include "resource.h"
 # include "windowstr.h"
 
diff --git a/src/mesa/drivers/x11/sources b/src/mesa/drivers/x11/sources
deleted file mode 100644 (file)
index d76d65e..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-# Note: only listing sources needed for X server renderer
-MESA_DRIVER_X11_SOURCES = \
-xm_api.c \
-xm_buffer.c \
-xm_dd.c \
-xm_line.c \
-xm_span.c \
-xm_tri.c
index 18b033666f0ad265805da1993afd52af939316a9..2eb88c1557d5b2892ab38db556b7092ee8f0eb7c 100644 (file)
 #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 "macros.h"
-#include "renderbuffer.h"
-#include "teximage.h"
+#include "main/context.h"
+#include "main/extensions.h"
+#include "main/framebuffer.h"
+#include "glapi/glthread.h"
+#include "main/imports.h"
+#include "main/macros.h"
+#include "main/renderbuffer.h"
+#include "main/teximage.h"
 #include "swrast/swrast.h"
 #include "swrast_setup/swrast_setup.h"
 #include "vbo/vbo.h"
@@ -1339,6 +1339,67 @@ xmesa_convert_from_x_visual_type( int visualType )
 /**********************************************************************/
 
 
+#ifdef IN_DRI_DRIVER
+#define need_GL_VERSION_1_3
+#define need_GL_VERSION_1_4
+#define need_GL_VERSION_1_5
+#define need_GL_VERSION_2_0
+
+/* sw extensions for imaging */
+#define need_GL_EXT_blend_color
+#define need_GL_EXT_blend_minmax
+#define need_GL_EXT_convolution
+#define need_GL_EXT_histogram
+#define need_GL_SGI_color_table
+
+/* sw extensions not associated with some GL version */
+#define need_GL_ARB_shader_objects
+#define need_GL_ARB_vertex_program
+#define need_GL_APPLE_vertex_array_object
+#define need_GL_ATI_fragment_shader
+#define need_GL_EXT_depth_bounds_test
+#define need_GL_EXT_framebuffer_object
+#define need_GL_EXT_framebuffer_blit
+#define need_GL_EXT_gpu_program_parameters
+#define need_GL_EXT_paletted_texture
+#define need_GL_IBM_multimode_draw_arrays
+#define need_GL_MESA_resize_buffers
+#define need_GL_NV_vertex_program
+#define need_GL_NV_fragment_program
+
+#include "extension_helper.h"
+#include "utils.h"
+
+const struct dri_extension card_extensions[] =
+{
+   { "GL_VERSION_1_3",                 GL_VERSION_1_3_functions },
+   { "GL_VERSION_1_4",                 GL_VERSION_1_4_functions },
+   { "GL_VERSION_1_5",                 GL_VERSION_1_5_functions },
+   { "GL_VERSION_2_0",                 GL_VERSION_2_0_functions },
+
+   { "GL_EXT_blend_color",             GL_EXT_blend_color_functions },
+   { "GL_EXT_blend_minmax",            GL_EXT_blend_minmax_functions },
+   { "GL_EXT_convolution",             GL_EXT_convolution_functions },
+   { "GL_EXT_histogram",               GL_EXT_histogram_functions },
+   { "GL_SGI_color_table",             GL_SGI_color_table_functions },
+
+   { "GL_ARB_shader_objects",          GL_ARB_shader_objects_functions },
+   { "GL_ARB_vertex_program",          GL_ARB_vertex_program_functions },
+   { "GL_APPLE_vertex_array_object",   GL_APPLE_vertex_array_object_functions },
+   { "GL_ATI_fragment_shader",         GL_ATI_fragment_shader_functions },
+   { "GL_EXT_depth_bounds_test",       GL_EXT_depth_bounds_test_functions },
+   { "GL_EXT_framebuffer_object",      GL_EXT_framebuffer_object_functions },
+   { "GL_EXT_framebuffer_blit",                GL_EXT_framebuffer_blit_functions },
+   { "GL_EXT_gpu_program_parameters",  GL_EXT_gpu_program_parameters_functions },
+   { "GL_EXT_paletted_texture",                GL_EXT_paletted_texture_functions },
+   { "GL_IBM_multimode_draw_arrays",   GL_IBM_multimode_draw_arrays_functions },
+   { "GL_MESA_resize_buffers",         GL_MESA_resize_buffers_functions },
+   { "GL_NV_vertex_program",           GL_NV_vertex_program_functions },
+   { "GL_NV_fragment_program",         GL_NV_fragment_program_functions },
+   { NULL,                             NULL }
+};
+#endif
+
 /*
  * Create a new X/Mesa visual.
  * Input:  display - X11 display
@@ -1384,6 +1445,14 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
    XMesaVisual v;
    GLint red_bits, green_bits, blue_bits, alpha_bits;
 
+#ifdef IN_DRI_DRIVER
+   /* driInitExtensions() should be called once per screen to setup extension
+    * indices.  There is no need to call it when the context is created since
+    * XMesa enables mesa sw extensions on its own.
+    */
+   driInitExtensions( NULL, card_extensions, GL_FALSE );
+#endif
+
 #ifndef XFree86Server
    /* For debugging only */
    if (_mesa_getenv("MESA_XSYNC")) {
@@ -1570,8 +1639,9 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
    _mesa_enable_1_4_extensions(mesaCtx);
    _mesa_enable_1_5_extensions(mesaCtx);
    _mesa_enable_2_0_extensions(mesaCtx);
+   _mesa_enable_2_1_extensions(mesaCtx);
 #if ENABLE_EXT_texure_compression_s3tc
-    if (c->Mesa_DXTn) {
+    if (mesaCtx->Mesa_DXTn) {
        _mesa_enable_extension(mesaCtx, "GL_EXT_texture_compression_s3tc");
        _mesa_enable_extension(mesaCtx, "GL_S3_s3tc");
     }
index 34287effe1cf77f2baa3053c8b5e201b66e76af4..ec094b6021dd16a620844def2fa7ce89d794454b 100644 (file)
@@ -424,7 +424,42 @@ xmesa_clear_buffers(GLcontext *ctx, GLbitfield buffers)
 
 
 #ifndef XFree86Server
-/* XXX this was never tested in the Xserver environment */
+/* XXX these functions haven't been tested in the Xserver environment */
+
+
+/**
+ * Check if we can do an optimized glDrawPixels into an 8R8G8B visual.
+ */
+static GLboolean
+can_do_DrawPixels_8R8G8B(GLcontext *ctx, GLenum format, GLenum type)
+{
+   if (format == GL_BGRA &&
+       type == GL_UNSIGNED_BYTE &&
+       ctx->DrawBuffer &&
+       ctx->DrawBuffer->Name == 0 &&
+       ctx->Pixel.ZoomX == 1.0 &&        /* no zooming */
+       ctx->Pixel.ZoomY == 1.0 &&
+       ctx->_ImageTransferState == 0 /* no color tables, scale/bias, etc */) {
+      const SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+      if (swrast->NewState)
+         _swrast_validate_derived( ctx );
+      
+      if ((swrast->_RasterMask & ~CLIP_BIT) == 0) /* no blend, z-test, etc */ {
+         struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];
+         if (rb) {
+            struct xmesa_renderbuffer *xrb = xmesa_renderbuffer(rb->Wrapped);
+            if (xrb &&
+                xrb->pixmap && /* drawing to pixmap or window */
+                xrb->Base.AlphaBits == 0) {
+               return GL_TRUE;
+            }
+         }
+      }
+   }
+   return GL_FALSE;
+}
+
 
 /**
  * This function implements glDrawPixels() with an XPutImage call when
@@ -438,37 +473,16 @@ xmesa_DrawPixels_8R8G8B( GLcontext *ctx,
                          const struct gl_pixelstore_attrib *unpack,
                          const GLvoid *pixels )
 {
-   const SWcontext *swrast = SWRAST_CONTEXT( ctx );
-   struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];
-   struct xmesa_renderbuffer *xrb = xmesa_renderbuffer(rb->Wrapped);
-
-   if (swrast->NewState)
-      _swrast_validate_derived( ctx );
-
-   if (ctx->DrawBuffer->Name == 0 &&
-       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 &&
-       xrb->pixmap &&                    /* drawing to pixmap or window */
-       xrb->St.Base.AlphaBits == 0)
-   {
-      const XMesaContext xmesa = XMESA_CONTEXT(ctx);
-      XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
-      XMesaDisplay *dpy = xmesa->xm_visual->display;
-      const XMesaGC gc = xmbuf->cleargc;  /* effected by glColorMask */
+   if (can_do_DrawPixels_8R8G8B(ctx, format, type)) {
+      const SWcontext *swrast = SWRAST_CONTEXT( ctx );
+      struct gl_pixelstore_attrib clippedUnpack = *unpack;
       int dstX = x;
       int dstY = y;
       int w = width;
       int h = height;
-      struct gl_pixelstore_attrib clippedUnpack = *unpack;
 
-      ASSERT(xmesa->xm_visual->dithered_pf == PF_8R8G8B);
-      ASSERT(xmesa->xm_visual->undithered_pf == PF_8R8G8B);
-      ASSERT(dpy);
-      ASSERT(gc);
+      if (swrast->NewState)
+         _swrast_validate_derived( ctx );
 
       if (unpack->BufferObj->Name) {
          /* unpack from PBO */
@@ -493,14 +507,26 @@ xmesa_DrawPixels_8R8G8B( GLcontext *ctx,
       }
 
       if (_mesa_clip_drawpixels(ctx, &dstX, &dstY, &w, &h, &clippedUnpack)) {
+         const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+         XMesaDisplay *dpy = xmesa->xm_visual->display;
+         XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+         const XMesaGC gc = xmbuf->cleargc;  /* effected by glColorMask */
+         struct xmesa_renderbuffer *xrb
+            = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]->Wrapped);
+         const int srcX = clippedUnpack.SkipPixels;
+         const int srcY = clippedUnpack.SkipRows;
+         const int rowLength = clippedUnpack.RowLength;
+         XMesaImage ximage;
+
+         ASSERT(xmesa->xm_visual->dithered_pf == PF_8R8G8B);
+         ASSERT(xmesa->xm_visual->undithered_pf == PF_8R8G8B);
+         ASSERT(dpy);
+         ASSERT(gc);
+
          /* 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.
           */
-         int srcX = clippedUnpack.SkipPixels;
-         int srcY = clippedUnpack.SkipRows;
-         int rowLength = clippedUnpack.RowLength;
-         XMesaImage ximage;
          MEMSET(&ximage, 0, sizeof(XMesaImage));
          ximage.width = width;
          ximage.height = height;
@@ -511,9 +537,9 @@ xmesa_DrawPixels_8R8G8B( GLcontext *ctx,
          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.depth = 32;
          ximage.bits_per_pixel = 32;
+         ximage.bytes_per_line = -rowLength * 4; /* negative to flip image */
          /* 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;
@@ -534,6 +560,41 @@ xmesa_DrawPixels_8R8G8B( GLcontext *ctx,
 
 
 
+/**
+ * Check if we can do an optimized glDrawPixels into an 5R6G5B visual.
+ */
+static GLboolean
+can_do_DrawPixels_5R6G5B(GLcontext *ctx, GLenum format, GLenum type)
+{
+   if (format == GL_RGB &&
+       type == GL_UNSIGNED_SHORT_5_6_5 &&
+       !ctx->Color.DitherFlag &&  /* no dithering */
+       ctx->DrawBuffer &&
+       ctx->DrawBuffer->Name == 0 &&
+       ctx->Pixel.ZoomX == 1.0 &&        /* no zooming */
+       ctx->Pixel.ZoomY == 1.0 &&
+       ctx->_ImageTransferState == 0 /* no color tables, scale/bias, etc */) {
+      const SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+      if (swrast->NewState)
+         _swrast_validate_derived( ctx );
+      
+      if ((swrast->_RasterMask & ~CLIP_BIT) == 0) /* no blend, z-test, etc */ {
+         struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];
+         if (rb) {
+            struct xmesa_renderbuffer *xrb = xmesa_renderbuffer(rb->Wrapped);
+            if (xrb &&
+                xrb->pixmap && /* drawing to pixmap or window */
+                xrb->Base.AlphaBits == 0) {
+               return GL_TRUE;
+            }
+         }
+      }
+   }
+   return GL_FALSE;
+}
+
+
 /**
  * This function implements glDrawPixels() with an XPutImage call when
  * drawing to the front buffer (X Window drawable).  The image format
@@ -547,35 +608,17 @@ xmesa_DrawPixels_5R6G5B( GLcontext *ctx,
                          const struct gl_pixelstore_attrib *unpack,
                          const GLvoid *pixels )
 {
-   struct xmesa_renderbuffer *xrb
-      = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped);
-   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->cleargc;  /* effected by glColorMask */
-
-   ASSERT(dpy);
-   ASSERT(gc);
-   ASSERT(xmesa->xm_visual->undithered_pf == PF_5R6G5B);
-
-   if (swrast->NewState)
-      _swrast_validate_derived( ctx );
-
-   if (xrb->pixmap &&       /* drawing to pixmap or window */
-       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) {
+   if (can_do_DrawPixels_5R6G5B(ctx, format, type)) {
+      const SWcontext *swrast = SWRAST_CONTEXT( ctx );
+      struct gl_pixelstore_attrib clippedUnpack = *unpack;
       int dstX = x;
       int dstY = y;
       int w = width;
       int h = height;
-      struct gl_pixelstore_attrib clippedUnpack = *unpack;
 
+      if (swrast->NewState)
+         _swrast_validate_derived( ctx );
+      
       if (unpack->BufferObj->Name) {
          /* unpack from PBO */
          GLubyte *buf;
@@ -599,14 +642,25 @@ xmesa_DrawPixels_5R6G5B( GLcontext *ctx,
       }
 
       if (_mesa_clip_drawpixels(ctx, &dstX, &dstY, &w, &h, &clippedUnpack)) {
+         const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+         XMesaDisplay *dpy = xmesa->xm_visual->display;
+         XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+         const XMesaGC gc = xmbuf->cleargc;  /* effected by glColorMask */
+         struct xmesa_renderbuffer *xrb
+            = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]->Wrapped);
+         const int srcX = clippedUnpack.SkipPixels;
+         const int srcY = clippedUnpack.SkipRows;
+         const int rowLength = clippedUnpack.RowLength;
+         XMesaImage ximage;
+
+         ASSERT(xmesa->xm_visual->undithered_pf == PF_5R6G5B);
+         ASSERT(dpy);
+         ASSERT(gc);
+
          /* 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.
           */
-         int srcX = clippedUnpack.SkipPixels;
-         int srcY = clippedUnpack.SkipRows;
-         int rowLength = clippedUnpack.RowLength;
-         XMesaImage ximage;
          MEMSET(&ximage, 0, sizeof(XMesaImage));
          ximage.width = width;
          ximage.height = height;
@@ -618,8 +672,8 @@ xmesa_DrawPixels_5R6G5B( GLcontext *ctx,
          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;
+         ximage.bytes_per_line = -rowLength * 2; /* negative to flip image */
          /* 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;
@@ -639,6 +693,42 @@ xmesa_DrawPixels_5R6G5B( GLcontext *ctx,
 }
 
 
+/**
+ * Determine if we can do an optimized glCopyPixels.
+ */
+static GLboolean
+can_do_CopyPixels(GLcontext *ctx, GLenum type)
+{
+   if (type == GL_COLOR &&
+       ctx->_ImageTransferState == 0 &&  /* no color tables, scale/bias, etc */
+       ctx->Pixel.ZoomX == 1.0 &&        /* no zooming */
+       ctx->Pixel.ZoomY == 1.0 &&
+       ctx->Color.DrawBuffer[0] == GL_FRONT &&  /* copy to front buf */
+       ctx->Pixel.ReadBuffer == GL_FRONT &&    /* copy from front buf */
+       ctx->ReadBuffer->_ColorReadBuffer &&
+       ctx->DrawBuffer->_ColorDrawBuffers[0]) {
+      const SWcontext *swrast = SWRAST_CONTEXT( ctx );
+
+      if (swrast->NewState)
+         _swrast_validate_derived( ctx );
+
+      if ((swrast->_RasterMask & ~CLIP_BIT) == 0x0 &&
+          ctx->ReadBuffer &&
+          ctx->ReadBuffer->_ColorReadBuffer &&
+          ctx->DrawBuffer &&
+          ctx->DrawBuffer->_ColorDrawBuffers[0]) {
+         struct xmesa_renderbuffer *srcXrb
+            = xmesa_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer->Wrapped);
+         struct xmesa_renderbuffer *dstXrb
+            = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]->Wrapped);
+         if (srcXrb->pixmap && dstXrb->pixmap) {
+            return GL_TRUE;
+         }
+      }
+   }
+   return GL_FALSE;
+}
+
 
 /**
  * Implement glCopyPixels for the front color buffer (or back buffer Pixmap)
@@ -650,31 +740,19 @@ 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;
-   XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
-   const XMesaGC gc = xmbuf->cleargc;  /* effected by glColorMask */
-   struct xmesa_renderbuffer *srcXrb
-      = xmesa_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer->Wrapped);
-   struct xmesa_renderbuffer *dstXrb
-      = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped);
-
-   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) {
+   if (can_do_CopyPixels(ctx, type)) {
+      const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+      XMesaDisplay *dpy = xmesa->xm_visual->display;
+      XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+      const XMesaGC gc = xmbuf->cleargc;  /* effected by glColorMask */
+      struct xmesa_renderbuffer *srcXrb
+         = xmesa_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer->Wrapped);
+      struct xmesa_renderbuffer *dstXrb
+         = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]->Wrapped);
+
+      ASSERT(dpy);
+      ASSERT(gc);
+
       /* Note: we don't do any special clipping work here.  We could,
        * but X will do it for us.
        */
@@ -687,6 +765,7 @@ xmesa_CopyPixels( GLcontext *ctx,
       _swrast_CopyPixels(ctx, srcx, srcy, width, height, destx, desty, type );
    }
 }
+
 #endif /* XFree86Server */
 
 
@@ -1079,7 +1158,8 @@ xmesa_init_driver_functions( XMesaVisual xmvisual,
 #ifndef XFree86Server
    driver->CopyPixels = xmesa_CopyPixels;
    if (xmvisual->undithered_pf == PF_8R8G8B &&
-       xmvisual->dithered_pf == PF_8R8G8B) {
+       xmvisual->dithered_pf == PF_8R8G8B &&
+       xmvisual->BitsPerPixel == 32) {
       driver->DrawPixels = xmesa_DrawPixels_8R8G8B;
    }
    else if (xmvisual->undithered_pf == PF_5R6G5B) {
index ae4f4282dbb56fafdb306b66d48a6f1fa1a2af87..cbd69b011a1d15e7dcc33013ab43d5a3c1101f51 100644 (file)
@@ -64,7 +64,8 @@ FXcreateContext(XMesaVisual v, XMesaWindow w, XMesaContext c, XMesaBuffer b)
        attribs[numAttribs++] = FXMESA_NONE;
 
        /* [dBorca] we should take an envvar for `fxMesaSelectCurrentBoard'!!! */
-       hw = fxMesaSelectCurrentBoard(0);
+/*       hw = fxMesaSelectCurrentBoard(0); */
+       hw = GR_SSTTYPE_Voodoo2;
 
        /* if these fail, there's a new bug somewhere */
        ASSERT(b->mesa_buffer.Width > 0);
index deeae5019c4dbfea323ed3a8e1dd281ca8732cd9..9833b4c9f07f127b7dbd0bdea4a5e3399d41f3ae 100644 (file)
@@ -121,7 +121,7 @@ void xmesa_choose_point( GLcontext *ctx )
 
 
 #define GET_XRB(XRB)  struct xmesa_renderbuffer *XRB = \
-   xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped)
+   xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]->Wrapped)
 
 
 /*
@@ -587,8 +587,8 @@ get_line_func(GLcontext *ctx)
    const int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
    const struct xmesa_renderbuffer *xrb;
 
-   if ((ctx->DrawBuffer->_ColorDrawBufferMask[0]
-        & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) == 0)
+   if ((ctx->DrawBuffer->_ColorDrawBufferIndexes[0] != BUFFER_BIT_FRONT_LEFT) &&
+       (ctx->DrawBuffer->_ColorDrawBufferIndexes[0] != BUFFER_BIT_BACK_LEFT))
       return (swrast_line_func) NULL;
    if (ctx->RenderMode != GL_RENDER)      return (swrast_line_func) NULL;
    if (ctx->Line.SmoothFlag)              return (swrast_line_func) NULL;
@@ -598,7 +598,7 @@ get_line_func(GLcontext *ctx)
    if (swrast->_RasterMask & MULTI_DRAW_BIT) return (swrast_line_func) NULL;
    if (xmbuf->swAlpha)                    return (swrast_line_func) NULL;
 
-   xrb = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped);
+   xrb = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]->Wrapped);
 
    if (xrb->ximage
        && swrast->_RasterMask==DEPTH_BIT
@@ -661,8 +661,8 @@ get_line_func(GLcontext *ctx)
    }
 
 #ifndef XFree86Server
-   if (ctx->DrawBuffer->_NumColorDrawBuffers[0] == 1
-       && ctx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT
+   if (ctx->DrawBuffer->_NumColorDrawBuffers == 1
+       && ctx->DrawBuffer->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT
        && swrast->_RasterMask == LOGIC_OP_BIT
        && ctx->Color.LogicOp == GL_XOR
        && !ctx->Line.StippleFlag
index 9f17083f90124d972072053cbea9dc5dfa371e4b..158f284a5e29ab64ebf208603e275c3f88d18e52 100644 (file)
@@ -45,7 +45,7 @@
 
 
 #define GET_XRB(XRB)  struct xmesa_renderbuffer *XRB = \
-   xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped)
+   xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]->Wrapped)
 
 
 /**********************************************************************/
@@ -66,7 +66,7 @@
    XMesaContext xmesa = XMESA_CONTEXT(ctx);                    \
    GET_XRB(xrb);
 
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLint x = span.x, y = YFLIP(xrb, span.y);                   \
    GLuint i;                                                   \
    for (i = 0; i < span.end; i++, x++) {                       \
@@ -82,7 +82,7 @@
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
       span.z += span.zStep;                                    \
-   }
+   } }
 
 #include "swrast/s_tritemp.h"
 
 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
 #define SETUP_CODE                                             \
    GET_XRB(xrb);
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    for (i = 0; i < span.end; i++) {                            \
       const DEPTH_TYPE z = FixedToDepth(span.z);               \
       span.blue += span.blueStep;                              \
       span.alpha += span.alphaStep;                            \
       span.z += span.zStep;                                    \
-   }
+   } }
 
 #include "swrast/s_tritemp.h"
 
 #define SETUP_CODE                                             \
    GET_XRB(xrb);
 
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    for (i = 0; i < span.end; i++) {                            \
       const DEPTH_TYPE z = FixedToDepth(span.z);               \
       span.blue += span.blueStep;                              \
       span.alpha += span.alphaStep;                            \
       span.z += span.zStep;                                    \
-   }
+   } }
 
 #include "swrast/s_tritemp.h"
 
 #define SETUP_CODE                                             \
    GET_XRB(xrb);
 
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    for (i = 0; i < span.end; i++) {                            \
       const DEPTH_TYPE z = FixedToDepth(span.z);               \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
       span.z += span.zStep;                                    \
-   }
+   } }
 
 #include "swrast/s_tritemp.h"
 
 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
 #define SETUP_CODE                                             \
    GET_XRB(xrb);
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    for (i = 0; i < span.end; i++) {                            \
       const DEPTH_TYPE z = FixedToDepth(span.z);               \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
       span.z += span.zStep;                                    \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
 #define SETUP_CODE                                             \
    XMesaContext xmesa = XMESA_CONTEXT(ctx);                    \
    GET_XRB(xrb);
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    GLint x = span.x, y = YFLIP(xrb, span.y);                   \
    for (i = 0; i < span.end; i++, x++) {                       \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
       span.z += span.zStep;                                    \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
 #define SETUP_CODE                                             \
    GET_XRB(xrb);
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    for (i = 0; i < span.end; i++) {                            \
       const DEPTH_TYPE z = FixedToDepth(span.z);               \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
       span.z += span.zStep;                                    \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
 #define SETUP_CODE                                             \
    XMesaContext xmesa = XMESA_CONTEXT(ctx);                    \
    GET_XRB(xrb);
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    GLint x = span.x, y = YFLIP(xrb, span.y);                   \
    for (i = 0; i < span.end; i++, x++) {                       \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
       span.z += span.zStep;                                    \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
 #define SETUP_CODE                                             \
    GET_XRB(xrb);
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    GLint x = span.x, y = YFLIP(xrb, span.y);                   \
    XDITHER_SETUP(y);                                           \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
       span.z += span.zStep;                                    \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
 #define SETUP_CODE                                             \
    GET_XRB(xrb);                                               \
    XMesaImage *img = xrb->ximage;
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    GLint x = span.x, y = YFLIP(xrb, span.y);                   \
    XDITHER_SETUP(y);                                           \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
       span.z += span.zStep;                                    \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
 #define SETUP_CODE                                             \
    GET_XRB(xrb);
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    LOOKUP_SETUP;                                               \
    for (i = 0; i < span.end; i++) {                            \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
       span.z += span.zStep;                                    \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
 #define SETUP_CODE                                             \
    XMesaContext xmesa = XMESA_CONTEXT(ctx);                    \
    GET_XRB(xrb);
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    GLint x = span.x, y = YFLIP(xrb, span.y);                   \
    for (i = 0; i < span.end; i++, x++) {                       \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
       span.z += span.zStep;                                    \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
    XMesaImage *img = xrb->ximage;                              \
    unsigned long pixel;                                                \
    PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]);
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    GLint x = span.x, y = YFLIP(xrb, span.y);                   \
    for (i = 0; i < span.end; i++, x++) {                       \
          zRow[i] = z;                                          \
       }                                                                \
       span.z += span.zStep;                                    \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
    GET_XRB(xrb);                                       \
    GLuint p = PACK_8A8B8G8R( v2->color[0], v2->color[1],\
                              v2->color[2], v2->color[3]);
-#define RENDER_SPAN( span )                            \
+#define RENDER_SPAN( span ) {                          \
    GLuint i;                                           \
    for (i = 0; i < span.end; i++) {                    \
       const DEPTH_TYPE z = FixedToDepth(span.z);       \
          zRow[i] = z;                                  \
       }                                                        \
       span.z += span.zStep;                            \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
    GET_XRB(xrb);                                       \
    GLuint p = PACK_8A8R8G8B(v2->color[0], v2->color[1],        \
                             v2->color[2], v2->color[3]);
-#define RENDER_SPAN( span )                            \
+#define RENDER_SPAN( span ) {                          \
    GLuint i;                                           \
    for (i = 0; i < span.end; i++) {                    \
       const DEPTH_TYPE z = FixedToDepth(span.z);       \
          zRow[i] = z;                                  \
       }                                                        \
       span.z += span.zStep;                            \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
 #define SETUP_CODE                                     \
    GET_XRB(xrb);                                       \
    GLuint p = PACK_8R8G8B( v2->color[0], v2->color[1], v2->color[2] );
-#define RENDER_SPAN( span )                    \
+#define RENDER_SPAN( span ) {                  \
    GLuint i;                                   \
    for (i = 0; i < span.end; i++) {            \
       DEPTH_TYPE z = FixedToDepth(span.z);     \
          zRow[i] = z;                          \
       }                                                \
       span.z += span.zStep;                    \
-   }
+   } }
 
 #include "swrast/s_tritemp.h"
 
 #define SETUP_CODE                                     \
    GET_XRB(xrb);                                       \
    const GLubyte *color = v2->color;
-#define RENDER_SPAN( span )                            \
+#define RENDER_SPAN( span ) {                          \
    GLuint i;                                           \
    for (i = 0; i < span.end; i++) {                    \
       const DEPTH_TYPE z = FixedToDepth(span.z);       \
          zRow[i] = z;                                  \
       }                                                        \
       span.z += span.zStep;                            \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
    XMesaContext xmesa = XMESA_CONTEXT(ctx);                    \
    GET_XRB(xrb);                                               \
    XMesaImage *img = xrb->ximage;
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    GLint x = span.x, y = YFLIP(xrb, span.y);                   \
    for (i = 0; i < span.end; i++, x++) {                       \
          zRow[i] = z;                                          \
       }                                                                \
       span.z += span.zStep;                                    \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
 #define SETUP_CODE                                     \
    GET_XRB(xrb);                                       \
    GLushort p = PACK_5R6G5B( v2->color[0], v2->color[1], v2->color[2] );
-#define RENDER_SPAN( span )                            \
+#define RENDER_SPAN( span ) {                          \
    GLuint i;                                           \
    for (i = 0; i < span.end; i++) {                    \
       const DEPTH_TYPE z = FixedToDepth(span.z);       \
          zRow[i] = z;                                  \
       }                                                        \
       span.z += span.zStep;                            \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
    XMesaContext xmesa = XMESA_CONTEXT(ctx);                    \
    GET_XRB(xrb);                                               \
    const GLubyte *color = v2->color;
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    GLint x = span.x, y = YFLIP(xrb, span.y);                   \
    for (i = 0; i < span.end; i++, x++) {                       \
          zRow[i] = z;                                          \
       }                                                                \
       span.z += span.zStep;                                    \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
 #define SETUP_CODE                                             \
    GET_XRB(xrb);                                               \
    FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    GLint x = span.x, y = YFLIP(xrb, span.y);                   \
    FLAT_DITHER_ROW_SETUP(YFLIP(xrb, y));                       \
          zRow[i] = z;                                          \
       }                                                                \
       span.z += span.zStep;                                    \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
    GET_XRB(xrb);                                       \
    XMesaImage *img = xrb->ximage;              \
    FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    GLint x = span.x, y = YFLIP(xrb, span.y);   \
    FLAT_DITHER_ROW_SETUP(y);                                   \
          zRow[i] = z;                                          \
       }                                                                \
       span.z += span.zStep;                                    \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
    GLubyte r = v2->color[0];                                   \
    GLubyte g = v2->color[1];                                   \
    GLubyte b = v2->color[2];
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    GLint x = span.x, y = YFLIP(xrb, span.y);   \
    for (i = 0; i < span.end; i++, x++) {                       \
          zRow[i] = z;                                          \
       }                                                                \
       span.z += span.zStep;                                    \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
    GLubyte g = v2->color[1];                           \
    GLubyte b = v2->color[2];                           \
    GLubyte p = LOOKUP(r,g,b);
-#define RENDER_SPAN( span )                            \
+#define RENDER_SPAN( span ) {                          \
    GLuint i;                                           \
    for (i = 0; i < span.end; i++) {                    \
       const DEPTH_TYPE z = FixedToDepth(span.z);       \
          zRow[i] = z;                                  \
       }                                                        \
       span.z += span.zStep;                            \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
    XMesaContext xmesa = XMESA_CONTEXT(ctx);                    \
    GET_XRB(xrb);                                               \
    XMesaImage *img = xrb->ximage;
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    GLint x = span.x, y = YFLIP(xrb, span.y);   \
    for (i = 0; i < span.end; i++, x++) {                       \
       span.red += span.redStep;                                        \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
 #define SETUP_CODE                                             \
    GET_XRB(xrb);
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    for (i = 0; i < span.end; i++) {                            \
       pRow[i] = PACK_8A8B8G8R(FixedToInt(span.red),            \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
       span.alpha += span.alphaStep;                            \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
 #define SETUP_CODE                                             \
    GET_XRB(xrb);
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    for (i = 0; i < span.end; i++) {                            \
       pRow[i] = PACK_8A8R8G8B(FixedToInt(span.red),            \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
       span.alpha += span.alphaStep;                            \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
 #define SETUP_CODE                                             \
    GET_XRB(xrb);
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    for (i = 0; i < span.end; i++) {                            \
       pRow[i] = PACK_8R8G8B(FixedToInt(span.red),              \
       span.red += span.redStep;                                        \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
 #define SETUP_CODE                                     \
    GET_XRB(xrb);
-#define RENDER_SPAN( span )                            \
+#define RENDER_SPAN( span ) {                          \
    GLuint i;                                           \
    PIXEL_TYPE *pixel = pRow;                           \
    for (i = 0; i < span.end; i++, pixel++) {           \
       span.red += span.redStep;                                \
       span.green += span.greenStep;                    \
       span.blue += span.blueStep;                      \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
    XMesaContext xmesa = XMESA_CONTEXT(ctx);                    \
    GET_XRB(xrb);                                               \
    XMesaImage *img = xrb->ximage;
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    GLint x = span.x, y = YFLIP(xrb, span.y);   \
    for (i = 0; i < span.end; i++, x++) {                       \
       span.red += span.redStep;                                        \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
 #define SETUP_CODE                                             \
    GET_XRB(xrb);
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    for (i = 0; i < span.end; i++) {                            \
       pRow[i] = (PIXEL_TYPE) PACK_5R6G5B(FixedToInt(span.red), \
       span.red += span.redStep;                                        \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
 #define SETUP_CODE                                             \
    XMesaContext xmesa = XMESA_CONTEXT(ctx);                    \
    GET_XRB(xrb);
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    GLint x = span.x, y = YFLIP(xrb, span.y);   \
    for (i = 0; i < span.end; i++, x++) {                       \
       span.red += span.redStep;                                        \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
 #define SETUP_CODE                                             \
    GET_XRB(xrb);
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    GLint x = span.x, y = YFLIP(xrb, span.y);   \
    XDITHER_SETUP(y);                                           \
       span.red += span.redStep;                                        \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
 #define SETUP_CODE                                             \
    GET_XRB(xrb);                                               \
    XMesaImage *img = xrb->ximage;
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    GLint x = span.x, y = YFLIP(xrb, span.y);   \
    XDITHER_SETUP(y);                                           \
       span.red += span.redStep;                                        \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
 #define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
 #define SETUP_CODE                                             \
    GET_XRB(xrb);
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    LOOKUP_SETUP;                                               \
    for (i = 0; i < span.end; i++) {                            \
       span.red += span.redStep;                                        \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
 #define SETUP_CODE                                             \
    XMesaContext xmesa = XMESA_CONTEXT(ctx);                    \
    GET_XRB(xrb);
-#define RENDER_SPAN( span )                                    \
+#define RENDER_SPAN( span ) {                                  \
    GLuint i;                                                   \
    GLint x = span.x, y = YFLIP(xrb, span.y);   \
    for (i = 0; i < span.end; i++, x++) {                       \
       span.red += span.redStep;                                        \
       span.green += span.greenStep;                            \
       span.blue += span.blueStep;                              \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
    XMesaImage *img = xrb->ximage;                              \
    unsigned long pixel;                                                \
    PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]);
-#define RENDER_SPAN( span )                                    \
+#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"
 
 
    GET_XRB(xrb);                                       \
    unsigned long p = PACK_8B8G8R( v2->color[0],                \
                 v2->color[1], v2->color[2] );
-#define RENDER_SPAN( span )                            \
+#define RENDER_SPAN( span ) {                          \
    GLuint i;                                           \
    for (i = 0; i < span.end; i++) {                    \
       pRow[i] = (PIXEL_TYPE) p;                                \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
    GET_XRB(xrb);                                       \
    unsigned long p = PACK_8R8G8B( v2->color[0],                \
                 v2->color[1], v2->color[2] );
-#define RENDER_SPAN( span )                            \
+#define RENDER_SPAN( span ) {                          \
    GLuint i;                                           \
    for (i = 0; i < span.end; i++) {                    \
       pRow[i] = (PIXEL_TYPE) p;                                \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
    GET_XRB(xrb);                                       \
    unsigned long p = PACK_8R8G8B( v2->color[0],                \
                 v2->color[1], v2->color[2] );
-#define RENDER_SPAN( span )                            \
+#define RENDER_SPAN( span ) {                          \
    GLuint i;                                           \
    for (i = 0; i < span.end; i++) {                    \
       pRow[i] = (PIXEL_TYPE) p;                                \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
 #define SETUP_CODE                                     \
    GET_XRB(xrb);                                       \
    const GLubyte *color = v2->color;
-#define RENDER_SPAN( span )                            \
+#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"
 
 
    XMesaContext xmesa = XMESA_CONTEXT(ctx);                    \
    GET_XRB(xrb);                                               \
    XMesaImage *img = xrb->ximage;
-#define RENDER_SPAN( span )                                    \
+#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(p, x, y, v2->color[0],                   \
                v2->color[1], v2->color[2] );                   \
       XMesaPutPixel(img, x, y, p);                             \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
    GET_XRB(xrb);                                       \
    unsigned long p = PACK_5R6G5B( v2->color[0],                \
                 v2->color[1], v2->color[2] );
-#define RENDER_SPAN( span )                            \
+#define RENDER_SPAN( span ) {                          \
    GLuint i;                                           \
    for (i = 0; i < span.end; i++) {                    \
       pRow[i] = (PIXEL_TYPE) p;                                \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
    XMesaContext xmesa = XMESA_CONTEXT(ctx);                    \
    GET_XRB(xrb);                                               \
    const GLubyte *color = v2->color;
-#define RENDER_SPAN( span )                                    \
+#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"
 
 
 #define SETUP_CODE                                             \
    GET_XRB(xrb);                                               \
    FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
-#define RENDER_SPAN( span )                                    \
+#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"
 
 
    GET_XRB(xrb);                                               \
    XMesaImage *img = xrb->ximage;                              \
    FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
-#define RENDER_SPAN( span )                                    \
+#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"
 
 
    GLubyte r = v2->color[0];                                   \
    GLubyte g = v2->color[1];                                   \
    GLubyte b = v2->color[2];
-#define RENDER_SPAN( span )                                    \
+#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"
 
 
    GLubyte g = v2->color[1];                           \
    GLubyte b = v2->color[2];                           \
    GLubyte p = LOOKUP(r,g,b);
-#define RENDER_SPAN( span )                            \
+#define RENDER_SPAN( span ) {                          \
    GLuint i;                                           \
    for (i = 0; i < span.end; i++) {                    \
       pRow[i] = (PIXEL_TYPE) p;                                \
-   }
+   } }
 #include "swrast/s_tritemp.h"
 
 
@@ -1502,8 +1502,8 @@ get_triangle_func(GLcontext *ctx)
 #endif
 
    /* trivial fallback tests */
-   if ((ctx->DrawBuffer->_ColorDrawBufferMask[0]
-        & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) == 0)
+   if ((ctx->DrawBuffer->_ColorDrawBufferIndexes[0] != BUFFER_BIT_FRONT_LEFT) &&
+       (ctx->DrawBuffer->_ColorDrawBufferIndexes[0] != BUFFER_BIT_BACK_LEFT))
       return (swrast_tri_func) NULL;
    if (ctx->RenderMode != GL_RENDER)
       return (swrast_tri_func) NULL;
@@ -1519,7 +1519,7 @@ get_triangle_func(GLcontext *ctx)
    if (xmbuf->swAlpha)
       return (swrast_tri_func) NULL;
 
-   xrb = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped);
+   xrb = xmesa_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]->Wrapped);
 
    if (xrb->ximage) {
       if (   ctx->Light.ShadeModel==GL_SMOOTH
index fd2dfcd79aaeece3a09abacf1be29cedf03b3178..e0e69274d403d10104e9a0f0e11b59d3c071e92b 100644 (file)
@@ -130,7 +130,7 @@ struct xmesa_visual {
 
 
 /**
- * Context info, dDerived from GLcontext.
+ * Context info, derived from GLcontext.
  * Basically corresponds to a GLXContext.
  */
 struct xmesa_context {
@@ -549,7 +549,6 @@ xmesa_renderbuffer(struct gl_renderbuffer *rb)
 /**
  * Return pointer to XMesaContext corresponding to a Mesa GLcontext.
  * Since we're using structure containment, it's just a cast!.
- * XXX should use inlined function for better type safety.
  */
 static INLINE XMesaContext
 XMESA_CONTEXT(GLcontext *ctx)
@@ -561,7 +560,6 @@ XMESA_CONTEXT(GLcontext *ctx)
 /**
  * Return pointer to XMesaBuffer corresponding to a Mesa GLframebuffer.
  * Since we're using structure containment, it's just a cast!.
- * XXX should use inlined function for better type safety.
  */
 static INLINE XMesaBuffer
 XMESA_BUFFER(GLframebuffer *b)
diff --git a/src/mesa/gl.pc.in b/src/mesa/gl.pc.in
new file mode 100644 (file)
index 0000000..1927880
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@INSTALL_DIR@
+exec_prefix=${prefix}
+libdir=@INSTALL_LIB_DIR@
+includedir=@INSTALL_INC_DIR@
+
+Name: gl
+Description: Mesa OpenGL library
+Requires:
+Version: @VERSION@
+Libs: -L${libdir} -lGL
+Cflags: -I${includedir}
index 66f250c003f935b1f37f817df52e5b063ee5a04a..1b0de2ad231b9c382c403ab4adea127705f1471c 100644 (file)
     <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="FRAMEBUFFER_BINDING_EXT"        count="1" value="0x8CA6">
+        <size name="Get" mode="get"/>
+    </enum>
+    <enum name="RENDERBUFFER_BINDING_EXT"       count="1" value="0x8CA7">
+        <size name="Get" mode="get"/>
+    </enum>
+    <enum name="MAX_COLOR_ATTACHMENTS_EXT"      count="1" value="0x8CDF">
+        <size name="Get" mode="get"/>
+    </enum>
+    <enum name="MAX_RENDERBUFFER_SIZE_EXT"      count="1" value="0x84E8">
+        <size name="Get" mode="get"/>
+    </enum>
     <enum name="INVALID_FRAMEBUFFER_OPERATION_EXT"        value="0x0506"/>
 
     <function name="IsRenderbufferEXT" offset="assign">
index c52c0903478a0f47928e8c36a352e230f3780788..adc53d92494d0cfcab6f9622a0f33ad539db37a4 100644 (file)
@@ -20,17 +20,30 @@ OUTPUTS = glprocs.h glapitemp.h glapioffsets.h glapitable.h dispatch.h \
        ../../glx/x11/indirect_size.c
 
 
-#XORG_BASE = /home/idr/devel/graphics/Xorg/xserver/xorg
-GLX_DIR   = $(XORG_BASE)/GL/glx
+GLX_DIR = $(XORG_BASE)/glx
 
-SERVER_OUTPUTS = $(GLX_DIR)/indirect_dispatch.c \
+SERVER_GLAPI_FILES = \
+       $(GLX_DIR)/glapi.h \
+       $(GLX_DIR)/glapi.c \
+       $(GLX_DIR)/glthread.c \
+       $(GLX_DIR)/glthread.h
+
+SERVER_OUTPUTS = \
+       $(GLX_DIR)/indirect_dispatch.c \
        $(GLX_DIR)/indirect_dispatch_swap.c \
        $(GLX_DIR)/indirect_dispatch.h \
        $(GLX_DIR)/indirect_reqsize.c \
        $(GLX_DIR)/indirect_reqsize.h \
+       $(GLX_DIR)/indirect_size.h \
        $(GLX_DIR)/indirect_size_get.c \
        $(GLX_DIR)/indirect_size_get.h \
-       $(GLX_DIR)/indirect_table.c
+       $(GLX_DIR)/indirect_table.c \
+       $(GLX_DIR)/glapitemp.h \
+       $(GLX_DIR)/glapitable.h \
+       $(GLX_DIR)/glapioffsets.h \
+       $(GLX_DIR)/glprocs.h \
+       $(GLX_DIR)/dispatch.h \
+       $(SERVER_GLAPI_FILES)
 
 API_XML = gl_API.xml \
        EXT_framebuffer_object.xml \
@@ -39,82 +52,94 @@ API_XML = gl_API.xml \
 COMMON = gl_XML.py glX_XML.py license.py $(API_XML) typeexpr.py
 COMMON_GLX = $(COMMON) glX_API.xml glX_XML.py glX_proto_common.py
 
-INDENT_FLAGS = -i4 -nut -br -brs -npcs -ce -T GLubyte -T GLbyte -T Bool
+all: check-xorg-source $(OUTPUTS) $(SERVER_OUTPUTS)
+
+check-xorg-source:
+       @if ! test -d $(GLX_DIR); then \
+               echo "ERROR: Must specify path to xserver checkout; set XORG_BASE."; \
+               exit 1; \
+       fi
 
-all: $(OUTPUTS)
+$(GLX_DIR)/%.c: %.c
+       cp $< $@
 
-server: $(SERVER_OUTPUTS)
+$(GLX_DIR)/%.h: %.h
+       cp $< $@
 
-glprocs.h: $(COMMON) gl_procs.py
-       $(PYTHON2) $(PYTHON_FLAGS) gl_procs.py > glprocs.h
+glprocs.h $(GLX_DIR)/glprocs.h: gl_procs.py $(COMMON)
+       $(PYTHON2) $(PYTHON_FLAGS) $< > $@
 
-glapitemp.h: $(COMMON) gl_apitemp.py
-       $(PYTHON2) $(PYTHON_FLAGS) gl_apitemp.py > glapitemp.h
+glapitemp.h $(GLX_DIR)/glapitemp.h: gl_apitemp.py $(COMMON)
+       $(PYTHON2) $(PYTHON_FLAGS) $< > $@
 
-glapioffsets.h: $(COMMON) gl_offsets.py
-       $(PYTHON2) $(PYTHON_FLAGS) gl_offsets.py > glapioffsets.h
+glapioffsets.h $(GLX_DIR)/glapioffsets.h: gl_offsets.py $(COMMON)
+       $(PYTHON2) $(PYTHON_FLAGS) $< > $@
 
-glapitable.h: $(COMMON) gl_table.py
-       $(PYTHON2) $(PYTHON_FLAGS) gl_table.py > glapitable.h
+glapitable.h $(GLX_DIR)/glapitable.h: gl_table.py $(COMMON)
+       $(PYTHON2) $(PYTHON_FLAGS) $< > $@
 
-dispatch.h: $(COMMON) gl_table.py
-       $(PYTHON2) $(PYTHON_FLAGS) gl_table.py -m remap_table > dispatch.h
+dispatch.h $(GLX_DIR)/dispatch.h: gl_table.py $(COMMON)
+       $(PYTHON2) $(PYTHON_FLAGS) $< -m remap_table > $@
 
-../main/enums.c: $(COMMON) gl_enums.py
-       $(PYTHON2) $(PYTHON_FLAGS) gl_enums.py > ../main/enums.c
+../main/enums.c: gl_enums.py $(COMMON)
+       $(PYTHON2) $(PYTHON_FLAGS) $< > $@
 
-../x86/glapi_x86.S: $(COMMON) gl_x86_asm.py
-       $(PYTHON2) $(PYTHON_FLAGS) gl_x86_asm.py > ../x86/glapi_x86.S
+../x86/glapi_x86.S: gl_x86_asm.py $(COMMON)
+       $(PYTHON2) $(PYTHON_FLAGS) $< > $@
 
-../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
+../x86-64/glapi_x86-64.S: gl_x86-64_asm.py $(COMMON)
+       $(PYTHON2) $(PYTHON_FLAGS) $< > $@
 
-../sparc/glapi_sparc.S: $(COMMON) gl_SPARC_asm.py
-       $(PYTHON2) $(PYTHON_FLAGS) gl_SPARC_asm.py > ../sparc/glapi_sparc.S
+../sparc/glapi_sparc.S: gl_SPARC_asm.py $(COMMON)
+       $(PYTHON2) $(PYTHON_FLAGS) $< > $@
 
 
-../drivers/dri/common/extension_helper.h: $(COMMON) extension_helper.py
-       $(PYTHON2) $(PYTHON_FLAGS) extension_helper.py > ../drivers/dri/common/extension_helper.h
+../drivers/dri/common/extension_helper.h: extension_helper.py $(COMMON)
+       $(PYTHON2) $(PYTHON_FLAGS) $< > $@
 
-../../glx/x11/indirect.c: $(COMMON_GLX) glX_proto_send.py
-       $(PYTHON2) $(PYTHON_FLAGS) glX_proto_send.py -m proto | indent $(INDENT_FLAGS) > ../../glx/x11/indirect.c
+../../glx/x11/indirect.c: glX_proto_send.py $(COMMON_GLX)
+       $(PYTHON2) $(PYTHON_FLAGS) $< -m proto | $(INDENT) $(INDENT_FLAGS) > $@
 
-../../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.h: glX_proto_send.py $(COMMON_GLX)
+       $(PYTHON2) $(PYTHON_FLAGS) $< -m init_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_init.c: glX_proto_send.py $(COMMON_GLX)
+       $(PYTHON2) $(PYTHON_FLAGS) $< -m 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_ | indent $(INDENT_FLAGS) > ../../glx/x11/indirect_size.h
+../../glx/x11/indirect_size.h $(GLX_DIR)/indirect_size.h: glX_proto_size.py $(COMMON_GLX)
+       $(PYTHON2) $(PYTHON_FLAGS) $< -m size_h --only-set -h _INDIRECT_SIZE_H_ \
+         | $(INDENT) $(INDENT_FLAGS) > $@
 
-../../glx/x11/indirect_size.c: $(COMMON_GLX) glX_proto_size.py
-       $(PYTHON2) $(PYTHON_FLAGS) glX_proto_size.py -m size_c --only-set | indent $(INDENT_FLAGS) > ../../glx/x11/indirect_size.c
+../../glx/x11/indirect_size.c: glX_proto_size.py $(COMMON_GLX)
+       $(PYTHON2) $(PYTHON_FLAGS) $< -m size_c --only-set \
+         | $(INDENT) $(INDENT_FLAGS) > $@
 
-$(GLX_DIR)/indirect_dispatch.c: $(COMMON_GLX) glX_proto_recv.py
-       $(PYTHON2) $(PYTHON_FLAGS) glX_proto_recv.py -m dispatch_c > $@
+$(GLX_DIR)/indirect_dispatch.c: glX_proto_recv.py $(COMMON_GLX)
+       $(PYTHON2) $(PYTHON_FLAGS) $< -m dispatch_c > $@
 
-$(GLX_DIR)/indirect_dispatch_swap.c: $(COMMON_GLX) glX_proto_recv.py
-       $(PYTHON2) $(PYTHON_FLAGS) glX_proto_recv.py -m dispatch_c -s > $@
+$(GLX_DIR)/indirect_dispatch_swap.c: glX_proto_recv.py $(COMMON_GLX)
+       $(PYTHON2) $(PYTHON_FLAGS) $< -m dispatch_c -s > $@
 
-$(GLX_DIR)/indirect_dispatch.h: $(COMMON_GLX) glX_proto_recv.py glX_API.xml
-       $(PYTHON2) $(PYTHON_FLAGS) glX_proto_recv.py -m dispatch_h -f gl_and_glX_API.xml -s > $@
+$(GLX_DIR)/indirect_dispatch.h: glX_proto_recv.py gl_and_glX_API.xml $(COMMON_GLX)
+       $(PYTHON2) $(PYTHON_FLAGS) $< -m dispatch_h -f gl_and_glX_API.xml -s > $@
 
-$(GLX_DIR)/indirect_size_get.h: $(COMMON_GLX) glX_proto_size.py
-       $(PYTHON2) $(PYTHON_FLAGS) glX_proto_size.py -m size_h --only-get -h '_INDIRECT_SIZE_GET_H_' | indent $(INDENT_FLAGS) > $@
+$(GLX_DIR)/indirect_size_get.h: glX_proto_size.py $(COMMON_GLX)
+       $(PYTHON2) $(PYTHON_FLAGS) $< -m size_h --only-get -h '_INDIRECT_SIZE_GET_H_' \
+         | $(INDENT) $(INDENT_FLAGS) > $@
 
-$(GLX_DIR)/indirect_size_get.c: $(COMMON_GLX) glX_proto_size.py
-       $(PYTHON2) $(PYTHON_FLAGS) glX_proto_size.py -m size_c | indent $(INDENT_FLAGS) > $@
+$(GLX_DIR)/indirect_size_get.c: glX_proto_size.py $(COMMON_GLX)
+       $(PYTHON2) $(PYTHON_FLAGS) $< -m size_c | $(INDENT) $(INDENT_FLAGS) > $@
 
-$(GLX_DIR)/indirect_reqsize.h: $(COMMON_GLX) glX_proto_size.py
-       $(PYTHON2) $(PYTHON_FLAGS) glX_proto_size.py -m reqsize_h --only-get -h '_INDIRECT_SIZE_GET_H_' | indent $(INDENT_FLAGS) -l200 > $@
+$(GLX_DIR)/indirect_reqsize.h: glX_proto_size.py $(COMMON_GLX)
+       $(PYTHON2) $(PYTHON_FLAGS) $< -m reqsize_h --only-get -h '_INDIRECT_SIZE_GET_H_' \
+         | $(INDENT) $(INDENT_FLAGS) -l200 > $@
 
-$(GLX_DIR)/indirect_reqsize.c: $(COMMON_GLX) glX_proto_size.py
-       $(PYTHON2) $(PYTHON_FLAGS) glX_proto_size.py -m reqsize_c | indent $(INDENT_FLAGS) > $@
+$(GLX_DIR)/indirect_reqsize.c: glX_proto_size.py $(COMMON_GLX)
+       $(PYTHON2) $(PYTHON_FLAGS) $< -m reqsize_c | $(INDENT) $(INDENT_FLAGS) > $@
 
-$(GLX_DIR)/indirect_table.c: $(COMMON_GLX) glX_server_table.py glX_API.xml
-       $(PYTHON2) $(PYTHON_FLAGS) glX_server_table.py -f gl_and_glX_API.xml > $@
+$(GLX_DIR)/indirect_table.c: glX_server_table.py gl_and_glX_API.xml $(COMMON_GLX)
+       $(PYTHON2) $(PYTHON_FLAGS) $< -f gl_and_glX_API.xml > $@
 
 clean:
-       rm -f *~ *.pyo
-       rm -f $(OUTPUTS)
+       -rm -f *~ *.pyo
+       -rm -f $(OUTPUTS)
index 455fc6a56764429cd88a232423055075eb7ab234..9e02aa498ee891bd1181230a51e05b99ea824239 100644 (file)
     </function>
 </category>
 
-<!--
 <category name="GLX_SGIX_pbuffer" number="50" window_system="glX">
     <function name="CreateGLXPbufferSGIX">
         <glx vendorpriv="65543"/>
         <glx vendorpriv="65546"/>
     </function>
 </category>
--->
 
 <category name="GLX_MESA_copy_sub_buffer" number="215">
     <function name="CopySubBufferMESA">
index 1b5c3239e0143daafbded5c9495763ddf041708c..4c2e0f95bf4ff3a7763cd94a5725b2b172b94d02 100644 (file)
@@ -115,7 +115,12 @@ class glx_function(gl_XML.gl_function):
        def process_element(self, element):
                gl_XML.gl_function.process_element(self, element)
 
-               self.vectorequiv = element.nsProp( "vectorequiv", None )
+               # If the function already has a vector equivalent set, don't
+               # set it again.  This can happen if an alias to a function
+               # appears after the function that it aliases.
+
+               if not self.vectorequiv:
+                       self.vectorequiv = element.nsProp("vectorequiv", None)
 
 
                name = element.nsProp("name", None)
@@ -132,48 +137,47 @@ class glx_function(gl_XML.gl_function):
 
                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)
-
-                                       if sop:
-                                               self.glx_sop = int(sop)
-
-                                       if vop:
-                                               self.glx_vendorpriv = int(vop)
-                                               self.glx_vendorpriv_names.append(name)
-
-                                       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' )
+                       if child.type == "element" and 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)
+
+                               if sop:
+                                       self.glx_sop = int(sop)
+
+                               if vop:
+                                       self.glx_vendorpriv = int(vop)
+                                       self.glx_vendorpriv_names.append(name)
+
+                               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
 
@@ -553,6 +557,7 @@ class glx_function_iterator:
 
        def next(self):
                f = self.iterator.next()
+
                if f.client_supported_for_indirect():
                        return f
                else:
index 1b6a5f3890cd1b343e17650f6b69a53d0a2fb010..b00b8a1ba6d712df074672b86b7eea27feff9aa0 100644 (file)
@@ -373,7 +373,7 @@ const GLuint __glXDefaultPixelStore[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 1 };
                                print '{'
                                print '    __GLXcontext * const gc = __glXGetCurrentContext();'
                                print ''
-                               print '    if (gc->isDirect) {'
+                               print '    if (gc->driContext) {'
                                print '    %sCALL_%s(GET_DISPATCH(), (%s));' % (ret_string, func.name, func.get_called_parameter_string())
                                print '    } else {'
                                footer = '}\n}\n'
@@ -511,7 +511,7 @@ generic_%u_byte( GLint rop, const void * ptr )
                return
 
 
-       def common_func_print_just_start(self, f):
+       def common_func_print_just_start(self, f, name):
                print '    __GLXcontext * const gc = __glXGetCurrentContext();'
 
                # The only reason that single and vendor private commands need
@@ -529,7 +529,7 @@ generic_%u_byte( GLint rop, const void * ptr )
 
                if not f.glx_rop:
                        for p in f.parameterIterateOutputs():
-                               if p.is_image():
+                               if p.is_image() and (p.img_format != "GL_COLOR_INDEX" or p.img_type != "GL_BITMAP"):
                                        print '    const __GLXattribute * const state = gc->client_state_private;'
                                        break
 
@@ -545,11 +545,23 @@ generic_%u_byte( GLint rop, const void * ptr )
                        print '    %s retval = (%s) 0;' % (f.return_type, f.return_type)
 
 
+               if name != None and name not in f.glx_vendorpriv_names:
+                       print '#ifndef USE_XCB'
                self.emit_packet_size_calculation(f, 0)
+               if name != None and name not in f.glx_vendorpriv_names:
+                       print '#endif'
 
                condition_list = []
                for p in f.parameterIterateCounters():
                        condition_list.append( "%s >= 0" % (p.name) )
+                       # 'counter' parameters cannot be negative
+                       print "    if (%s < 0) {" % p.name
+                       print "        __glXSetError(gc, GL_INVALID_VALUE);"
+                       if f.return_type != 'void':
+                               print "        return 0;"
+                       else:
+                               print "        return;"
+                       print "    }"
 
                if skip_condition:
                        condition_list.append( skip_condition )
@@ -567,7 +579,7 @@ generic_%u_byte( GLint rop, const void * ptr )
 
 
        def printSingleFunction(self, f, name):
-               self.common_func_print_just_start(f)
+               self.common_func_print_just_start(f, name)
 
                if self.debug:
                        print '        printf( "Enter %%s...\\n", "gl%s" );' % (f.name)
@@ -739,7 +751,7 @@ generic_%u_byte( GLint rop, const void * ptr )
                        return
 
 
-               if self.common_func_print_just_start(f):
+               if self.common_func_print_just_start(f, None):
                        trailer = "    }"
                else:
                        trailer = None
@@ -791,7 +803,7 @@ generic_%u_byte( GLint rop, const void * ptr )
                                        print '    generic_%u_byte( %s, %s );' % (cmdlen, f.opcode_real_name(), p.name)
                                        return
 
-               if self.common_func_print_just_start(f):
+               if self.common_func_print_just_start(f, None):
                        trailer = "    }"
                else:
                        trailer = None
index ef4a309cd6b7f2f2828cf67ddc869f7070fabc9a..2d8a967ba797c6aecfd3ae5e3e7e62a09fd523b8 100644 (file)
         <size name="GetTexParameterfv" mode="get"/>
         <size name="GetTexParameteriv" mode="get"/>
     </enum>
-    <enum name="MAX_3D_TEXTURE_SIZE"                      value="0x8073"/>
+    <enum name="MAX_3D_TEXTURE_SIZE"           count="1"  value="0x8073">
+        <size name="Get" mode="get"/>
+    </enum>
     <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>
     <enum name="POINT_SIZE_MIN"                count="1"  value="0x8126">
         <size name="PointParameterfvEXT"/>
+        <size name="Get" mode="get"/>
     </enum>
     <enum name="POINT_SIZE_MAX"                count="1"  value="0x8127">
         <size name="PointParameterfvEXT"/>
+        <size name="Get" mode="get"/>
     </enum>
     <enum name="POINT_FADE_THRESHOLD_SIZE"     count="1"  value="0x8128">
         <size name="PointParameterfvEXT"/>
+        <size name="Get" mode="get"/>
     </enum>
     <enum name="POINT_DISTANCE_ATTENUATION"    count="3"  value="0x8129">
         <size name="PointParameterfvEXT"/>
+        <size name="Get" mode="get"/>
     </enum>
     <enum name="GENERATE_MIPMAP"               count="1"  value="0x8191">
         <size name="TexParameterfv"/>
 </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="BUFFER_SIZE_ARB"               count="1"  value="0x8764">
+        <size name="GetBufferParameterivARB" mode="get"/>
+    </enum>
+    <enum name="BUFFER_USAGE_ARB"              count="1"  value="0x8765">
+        <size name="GetBufferParameterivARB" mode="get"/>
+    </enum>
+    <enum name="ARRAY_BUFFER_BINDING_ARB"      count="1"  value="0x8894">
+        <size name="Get" mode="get"/>
+    </enum>
+    <enum name="ELEMENT_ARRAY_BUFFER_BINDING_ARB" count="1" value="0x8895">
+        <size name="Get" mode="get"/>
+    </enum>
+    <enum name="VERTEX_ARRAY_BUFFER_BINDING_ARB" count="1" value="0x8896">
+        <size name="Get" mode="get"/>
+    </enum>
+    <enum name="NORMAL_ARRAY_BUFFER_BINDING_ARB" count="1" value="0x8897">
+        <size name="Get" mode="get"/>
+    </enum>
+    <enum name="COLOR_ARRAY_BUFFER_BINDING_ARB" count="1" value="0x8898">
+        <size name="Get" mode="get"/>
+    </enum>
+    <enum name="INDEX_ARRAY_BUFFER_BINDING_ARB" count="1" value="0x8899">
+        <size name="Get" mode="get"/>
+    </enum>
+    <enum name="TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB" count="1" value="0x889A">
+        <size name="Get" mode="get"/>
+    </enum>
+    <enum name="EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB" count="1" value="0x889B">
+        <size name="Get" mode="get"/>
+    </enum>
+    <enum name="SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB" count="1" value="0x889C">
+        <size name="Get" mode="get"/>
+    </enum>
+    <enum name="FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB" count="1" value="0x889D">
+        <size name="Get" mode="get"/>
+    </enum>
+    <enum name="WEIGHT_ARRAY_BUFFER_BINDING_ARB" count="1" value="0x889E">
+        <size name="Get" mode="get"/>
+    </enum>
+    <enum name="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB" count="1" value="0x889F">
+        <size name="GetVertexAttribdvARB" mode="get"/>
+        <size name="GetVertexAttribfvARB" mode="get"/>
+        <size name="GetVertexAttribivARB" mode="get"/>
+    </enum>
     <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_ACCESS_ARB"             count="1"  value="0x88BB">
+        <size name="GetBufferParameterivARB" mode="get"/>
+    </enum>
+    <enum name="BUFFER_MAPPED_ARB"             count="1"  value="0x88BC">
+        <size name="GetBufferParameterivARB" mode="get"/>
+    </enum>
     <enum name="BUFFER_MAP_POINTER_ARB"                   value="0x88BD"/>
     <enum name="STREAM_DRAW_ARB"                          value="0x88E0"/>
     <enum name="STREAM_READ_ARB"                          value="0x88E1"/>
     <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"/>
+    <type name="intptrARB"   size="4"                  glx_name="CARD32"/>
+    <type name="sizeiptrARB" size="4"  unsigned="true" glx_name="CARD32"/>
 
     <function name="BindBufferARB" offset="assign">
         <param name="target" type="GLenum"/>
 
     <function name="BufferDataARB" offset="assign">
         <param name="target" type="GLenum"/>
-        <param name="size" type="GLsizeiptrARB"/>
-        <param name="data" type="const GLvoid *"/>
+        <param name="size" type="GLsizeiptrARB" counter="true"/>
+        <param name="data" type="const GLvoid *" count="size" img_null_flag="true"/>
         <param name="usage" type="GLenum"/>
         <glx ignore="true"/>
     </function>
     <function name="BufferSubDataARB" offset="assign">
         <param name="target" type="GLenum"/>
         <param name="offset" type="GLintptrARB"/>
-        <param name="size" type="GLsizeiptrARB"/>
-        <param name="data" type="const GLvoid *"/>
+        <param name="size" type="GLsizeiptrARB" counter="true"/>
+        <param name="data" type="const GLvoid *" count="size"/>
         <glx ignore="true"/>
     </function>
 
     <function name="DeleteBuffersARB" offset="assign">
-        <param name="n" type="GLsizei"/>
-        <param name="buffer" type="const GLuint *"/>
+        <param name="n" type="GLsizei" counter="true"/>
+        <param name="buffer" type="const GLuint *" count="n"/>
         <glx ignore="true"/>
     </function>
 
     <function name="GetBufferParameterivARB" offset="assign">
         <param name="target" type="GLenum"/>
         <param name="pname" type="GLenum"/>
-        <param name="params" type="GLint *" output="true"/>
+        <param name="params" type="GLint *" output="true" variable_param="pname"/>
         <glx ignore="true"/>
     </function>
 
     <function name="GetBufferSubDataARB" offset="assign">
         <param name="target" type="GLenum"/>
         <param name="offset" type="GLintptrARB"/>
-        <param name="size" type="GLsizeiptrARB"/>
-        <param name="data" type="GLvoid *" output="true"/>
+        <param name="size" type="GLsizeiptrARB" counter="true"/>
+        <param name="data" type="GLvoid *" output="true" count="size"/>
         <glx ignore="true"/>
     </function>
 
 <category name="GL_EXT_framebuffer_blit" number="316">
     <enum name="READ_FRAMEBUFFER_EXT" value="0x8CA8"/>
     <enum name="DRAW_FRAMEBUFFER_EXT" value="0x8CA9"/>
-    <enum name="DRAW_FRAMEBUFFER_BINDING_EXT" value="0x8CA6"/>
-    <enum name="READ_FRAMEBUFFER_BINDING_EXT" value="0x8CAA"/>
+    <enum name="DRAW_FRAMEBUFFER_BINDING_EXT" count="1" value="0x8CA6">
+        <size name="Get" mode="get"/>
+    </enum>
+    <enum name="READ_FRAMEBUFFER_BINDING_EXT" count="1" value="0x8CAA">
+        <size name="Get" mode="get"/>
+    </enum>
     <function name="BlitFramebufferEXT" offset="assign" static_dispatch="false">
         <param name="srcX0" type="GLint"/>
         <param name="srcY0" type="GLint"/>
index 09cc8cfcde20ce01e2eed4f6523fae9889516cb1..56ddf7c25acceea2bf038c37e30235d2b1ac41f5 100644 (file)
@@ -28,6 +28,9 @@
  * truly reusable outside of Mesa.  First, the glheader.h include must go.
  */
 
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
 
 #include "main/glheader.h"
 #include "glthread.h"
diff --git a/src/mesa/glapi/sources b/src/mesa/glapi/sources
deleted file mode 100644 (file)
index 1d5c252..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-MESA_GLAPI_SOURCES = \
-glapi.c \
-glthread.c
-
-MESA_GLAPI_HEADERS = \
-dispatch.h \
-glapi.h \
-glapioffsets.h \
-glapitable.h \
-glapitemp.h \
-glprocs.h \
-glthread.h
index 2eb96ae3f4ea645e209a89b58909ca67148e7b22..bbc5933ab9fee2a7939a4b537781aafde5677a15 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  7.0.1
+ * Version:  7.1
  *
  * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
 #include "state.h"
 
 
+/**
+ * Find the max index in the given element/index buffer
+ */
+static GLuint
+max_buffer_index(GLcontext *ctx, GLuint count, GLenum type,
+                 const void *indices,
+                 struct gl_buffer_object *elementBuf)
+{
+   const GLubyte *map = NULL;
+   GLuint max = 0;
+   GLint i;
+
+   if (elementBuf->Name) {
+      /* elements are in a user-defined buffer object.  need to map it */
+      map = ctx->Driver.MapBuffer(ctx,
+                                  GL_ELEMENT_ARRAY_BUFFER_ARB,
+                                  GL_READ_ONLY,
+                                  elementBuf);
+      /* Actual address is the sum of pointers */
+      indices = (const GLvoid *) ADD_POINTERS(map, (const GLubyte *) indices);
+   }
+
+   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 (map) {
+      ctx->Driver.UnmapBuffer(ctx,
+                              GL_ELEMENT_ARRAY_BUFFER_ARB,
+                              ctx->Array.ElementArrayBufferObj);
+   }
+
+   return max;
+}
+
+
 GLboolean
 _mesa_validate_DrawElements(GLcontext *ctx,
                            GLenum mode, GLsizei count, GLenum type,
@@ -67,16 +116,15 @@ _mesa_validate_DrawElements(GLcontext *ctx,
 
    /* Vertex buffer object tests */
    if (ctx->Array.ElementArrayBufferObj->Name) {
+      /* use indices in the buffer object */
       GLuint indexBytes;
 
-      /* use indices in the buffer object */
       if (!ctx->Array.ElementArrayBufferObj->Size) {
          _mesa_warning(ctx,
                        "glDrawElements called with empty array elements buffer");
          return GL_FALSE;
       }
 
-      /* make sure count doesn't go outside buffer bounds */
       if (type == GL_UNSIGNED_INT) {
          indexBytes = count * sizeof(GLuint);
       }
@@ -88,6 +136,7 @@ _mesa_validate_DrawElements(GLcontext *ctx,
          indexBytes = count * sizeof(GLushort);
       }
 
+      /* make sure count doesn't go outside buffer bounds */
       if (indexBytes > (GLuint) ctx->Array.ElementArrayBufferObj->Size) {
          _mesa_warning(ctx, "glDrawElements index out of buffer bounds");
          return GL_FALSE;
@@ -101,39 +150,8 @@ _mesa_validate_DrawElements(GLcontext *ctx,
 
    if (ctx->Const.CheckArrayBounds) {
       /* find max array index */
-      const GLubyte *map;
-      GLuint max = 0;
-      GLint i;
-
-      map = ctx->Driver.MapBuffer(ctx,
-                                  GL_ELEMENT_ARRAY_BUFFER_ARB,
-                                  GL_READ_ONLY,
-                                  ctx->Array.ElementArrayBufferObj);
-
-      /* Actual address is the sum of pointers */
-      indices = (const GLvoid *) ADD_POINTERS(map, (const GLubyte *) indices);
-
-      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];
-      }
-
-      ctx->Driver.UnmapBuffer(ctx,
-                              GL_ELEMENT_ARRAY_BUFFER_ARB,
-                              ctx->Array.ElementArrayBufferObj);
-
+      GLuint max = max_buffer_index(ctx, count, type, indices,
+                                    ctx->Array.ElementArrayBufferObj);
       if (max >= ctx->Array._MaxElement) {
          /* the max element is out of bounds of one or more enabled arrays */
          return GL_FALSE;
@@ -186,36 +204,35 @@ _mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode,
 
    /* Vertex buffer object tests */
    if (ctx->Array.ElementArrayBufferObj->Name) {
-      /* XXX re-use code from above? */
+      /* use indices in the buffer object */
+      GLuint indexBytes;
+
+      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);
+      }
+
+      /* make sure count doesn't go outside buffer bounds */
+      if (indexBytes > ctx->Array.ElementArrayBufferObj->Size) {
+         _mesa_warning(ctx, "glDrawRangeElements index out of buffer bounds");
+         return GL_FALSE;
+      }
    }
    else {
-      /* not using VBO */
+      /* not using VBO */
       if (!indices)
          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];
-      }
+      GLuint max = max_buffer_index(ctx, count, type, indices,
+                                    ctx->Array.ElementArrayBufferObj);
       if (max >= ctx->Array._MaxElement) {
          /* the max element is out of bounds of one or more enabled arrays */
          return GL_FALSE;
@@ -236,8 +253,9 @@ _mesa_validate_DrawArrays(GLcontext *ctx,
 {
    ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
 
-   if (count < 0) {
-      _mesa_error(ctx, GL_INVALID_VALUE, "glDrawArrays(count)" );
+   if (count <= 0) {
+      if (count < 0)
+         _mesa_error(ctx, GL_INVALID_VALUE, "glDrawArrays(count)" );
       return GL_FALSE;
    }
 
index 7179fba3db32c43c0b309d8bbeb435b4e5b6cb0e..32d86ce149092595b7e183fcefe0798a224263d9 100644 (file)
 #include "texobj.h"
 #include "texparam.h"
 #include "texstate.h"
+#include "varray.h"
 #include "mtypes.h"
 #include "math/m_xform.h"
 
+/**
+ * Special struct for saving/restoring texture state (GL_TEXTURE_BIT)
+ */
+struct texture_state
+{
+   struct gl_texture_attrib Texture;  /**< The usual context state */
+
+   /** to save per texture object state (wrap modes, filters, etc): */
+   struct gl_texture_object SavedObj[MAX_TEXTURE_UNITS][NUM_TEXTURE_TARGETS];
+
+   /**
+    * To save references to texture objects (so they don't get accidentally
+    * deleted while saved in the attribute stack).
+    */
+   struct gl_texture_object *SavedTexRef[MAX_TEXTURE_UNITS][NUM_TEXTURE_TARGETS];
+};
+
 
 /**
  * Allocate a new attribute state node.  These nodes have a
@@ -345,47 +363,61 @@ _mesa_PushAttrib(GLbitfield mask)
    }
 
    if (mask & GL_TEXTURE_BIT) {
-      struct gl_texture_attrib *attr;
+      struct texture_state *texstate = CALLOC_STRUCT(texture_state);
       GLuint u;
 
+      if (!texstate) {
+         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib(GL_TEXTURE_BIT)");
+         goto end;
+      }
+
       _mesa_lock_context_textures(ctx);
-      /* Bump the texture object reference counts so that they don't
-       * inadvertantly get deleted.
+
+      /* copy/save the bulk of texture state here */
+      _mesa_memcpy(&texstate->Texture, &ctx->Texture, sizeof(ctx->Texture));
+
+      /* Save references to the currently bound texture objects so they don't
+       * accidentally get deleted while referenced in the attribute 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++;
-        ctx->Texture.Unit[u].Current1DArray->RefCount++;
-        ctx->Texture.Unit[u].Current2DArray->RefCount++;
+         _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_1D_INDEX],
+                                ctx->Texture.Unit[u].Current1D);
+         _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_2D_INDEX],
+                                ctx->Texture.Unit[u].Current2D);
+         _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_3D_INDEX],
+                                ctx->Texture.Unit[u].Current3D);
+         _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_CUBE_INDEX],
+                                ctx->Texture.Unit[u].CurrentCubeMap);
+         _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_RECT_INDEX],
+                                ctx->Texture.Unit[u].CurrentRect);
+         _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_1D_ARRAY_INDEX],
+                                ctx->Texture.Unit[u].Current1DArray);
+         _mesa_reference_texobj(&texstate->SavedTexRef[u][TEXTURE_2D_ARRAY_INDEX],
+                                ctx->Texture.Unit[u].Current2DArray);
       }
 
-      attr = MALLOC_STRUCT( gl_texture_attrib );
-      MEMCPY( attr, &ctx->Texture, sizeof(struct gl_texture_attrib) );
-      /* copy state of the currently bound texture objects */
+      /* copy state/contents 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);
-         _mesa_copy_texture_object(&attr->Unit[u].Saved1DArray,
-                                   attr->Unit[u].Current1DArray);
-         _mesa_copy_texture_object(&attr->Unit[u].Saved2DArray,
-                                   attr->Unit[u].Current2DArray);
+         _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_1D_INDEX],
+                                   ctx->Texture.Unit[u].Current1D);
+         _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_2D_INDEX],
+                                   ctx->Texture.Unit[u].Current2D);
+         _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_3D_INDEX],
+                                   ctx->Texture.Unit[u].Current3D);
+         _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_CUBE_INDEX],
+                                   ctx->Texture.Unit[u].CurrentCubeMap);
+         _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_RECT_INDEX],
+                                   ctx->Texture.Unit[u].CurrentRect);
+         _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_1D_ARRAY_INDEX],
+                                   ctx->Texture.Unit[u].Current1DArray);
+         _mesa_copy_texture_object(&texstate->SavedObj[u][TEXTURE_2D_ARRAY_INDEX],
+                                   ctx->Texture.Unit[u].Current2DArray);
       }
 
       _mesa_unlock_context_textures(ctx);
 
       newnode = new_attrib_node( GL_TEXTURE_BIT );
-      newnode->data = attr;
+      newnode->data = texstate;
       newnode->next = head;
       head = newnode;
    }
@@ -421,6 +453,7 @@ _mesa_PushAttrib(GLbitfield mask)
       head = newnode;
    }
 
+end:
    ctx->AttribStack[ctx->AttribStackDepth] = head;
    ctx->AttribStackDepth++;
 }
@@ -630,14 +663,19 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable)
 }
 
 
+/**
+ * Pop/restore texture attribute/group state.
+ */
 static void
-pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib)
+pop_texture_group(GLcontext *ctx, struct texture_state *texstate)
 {
    GLuint u;
 
+   _mesa_lock_context_textures(ctx);
+
    for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
-      const struct gl_texture_unit *unit = &texAttrib->Unit[u];
-      GLuint i;
+      const struct gl_texture_unit *unit = &texstate->Texture.Unit[u];
+      GLuint tgt;
 
       _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + u);
       _mesa_set_enable(ctx, GL_TEXTURE_1D,
@@ -730,53 +768,33 @@ pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib)
                        1 << unit->Combine.ScaleShiftA);
       }
 
-      /* Restore texture object state */
-      for (i = 0; i < NUM_TEXTURE_TARGETS; i++) {
-         GLenum target = 0;
+      /* Restore texture object state for each target */
+      for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) {
          const struct gl_texture_object *obj = NULL;
          GLfloat bordColor[4];
+         GLenum target;
 
-         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;
-         case 5:
-            if (!ctx->Extensions.MESA_texture_array)
-               continue;
-            target = GL_TEXTURE_1D_ARRAY_EXT;
-            obj = &unit->Saved1DArray;
-            break;
-         case 6:
-            if (!ctx->Extensions.MESA_texture_array)
-               continue;
-            target = GL_TEXTURE_2D_ARRAY_EXT;
-            obj = &unit->Saved2DArray;
-            break;
-         default:
-            ; /* silence warnings */
+         obj = &texstate->SavedObj[u][tgt];
+
+         /* don't restore state for unsupported targets to prevent
+          * raising GL errors.
+          */
+         if (obj->Target == GL_TEXTURE_CUBE_MAP_ARB &&
+             !ctx->Extensions.ARB_texture_cube_map) {
+            continue;
+         }
+         else if (obj->Target == GL_TEXTURE_RECTANGLE_NV &&
+                  !ctx->Extensions.NV_texture_rectangle) {
+            continue;
+         }
+         else if ((obj->Target == GL_TEXTURE_1D_ARRAY_EXT ||
+                   obj->Target == GL_TEXTURE_2D_ARRAY_EXT) &&
+                  !ctx->Extensions.MESA_texture_array) {
+            continue;
          }
 
+         target = obj->Target;
+
          _mesa_BindTexture(target, obj->Name);
 
          bordColor[0] = CHAN_TO_FLOAT(obj->BorderColor[0]);
@@ -784,8 +802,8 @@ pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib)
          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_TexParameterf(target, GL_TEXTURE_PRIORITY, obj->Priority);
          _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);
@@ -811,25 +829,17 @@ pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib)
             _mesa_TexParameterf(target, GL_SHADOW_AMBIENT_SGIX,
                                 obj->ShadowAmbient);
          }
+      }
 
+      /* remove saved references to the texture objects */
+      for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) {
+         _mesa_reference_texobj(&texstate->SavedTexRef[u][tgt], NULL);
       }
    }
-   _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--;
-      ctx->Texture.Unit[u].Current1DArray->RefCount--;
-      ctx->Texture.Unit[u].Current2DArray->RefCount--;
-   }
+   _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + texstate->Texture.CurrentUnit);
+
+   _mesa_unlock_context_textures(ctx);
 }
 
 
@@ -1098,10 +1108,11 @@ _mesa_PopAttrib(void)
                                    (GLint) point->CoordReplace[u]);
                   }
                   _mesa_set_enable(ctx, GL_POINT_SPRITE_NV,point->PointSprite);
-                  _mesa_PointParameteri(GL_POINT_SPRITE_R_MODE_NV,
-                                        ctx->Point.SpriteRMode);
+                  if (ctx->Extensions.NV_point_sprite)
+                     _mesa_PointParameteri(GL_POINT_SPRITE_R_MODE_NV,
+                                          ctx->Point.SpriteRMode);
                   _mesa_PointParameterf(GL_POINT_SPRITE_COORD_ORIGIN,
-                                        (GLfloat)ctx->Point.SpriteOrigin);
+                                           (GLfloat)ctx->Point.SpriteOrigin);
                }
             }
             break;
@@ -1208,9 +1219,9 @@ _mesa_PopAttrib(void)
          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);
+               struct texture_state *texstate
+                  = (struct texture_state *) attr->data;
+               pop_texture_group(ctx, texstate);
               ctx->NewState |= _NEW_TEXTURE;
             }
             break;
@@ -1409,8 +1420,10 @@ _mesa_PopClientAttrib(void)
             adjust_buffer_object_ref_counts(&ctx->Array, -1);
         
             ctx->Array.ActiveTexture = data->ActiveTexture;
-           ctx->Array.LockFirst = data->LockFirst;
-           ctx->Array.LockCount = data->LockCount;
+           if (data->LockCount != 0)
+              _mesa_LockArraysEXT(data->LockFirst, data->LockCount);
+           else if (ctx->Array.LockCount)
+              _mesa_UnlockArraysEXT();
 
            _mesa_BindVertexArrayAPPLE( data->ArrayObj->Name );
            
@@ -1447,6 +1460,42 @@ _mesa_PopClientAttrib(void)
 }
 
 
+/**
+ * Free any attribute state data that might be attached to the context.
+ */
+void
+_mesa_free_attrib_data(GLcontext *ctx)
+{
+   while (ctx->AttribStackDepth > 0) {
+      struct gl_attrib_node *attr, *next;
+
+      ctx->AttribStackDepth--;
+      attr = ctx->AttribStack[ctx->AttribStackDepth];
+
+      while (attr) {
+         if (attr->kind == GL_TEXTURE_BIT) {
+            struct texture_state *texstate = (struct texture_state*)attr->data;
+            GLuint u, tgt;
+            /* clear references to the saved texture objects */
+            for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
+               for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) {
+                  _mesa_reference_texobj(&texstate->SavedTexRef[u][tgt], NULL);
+               }
+            }
+         }
+         else {
+            /* any other chunks of state that requires special handling? */
+         }
+
+         next = attr->next;
+         _mesa_free(attr->data);
+         _mesa_free(attr);
+         attr = next;
+      }
+   }
+}
+
+
 void _mesa_init_attrib( GLcontext *ctx )
 {
    /* Renderer and client attribute stacks */
index 09d75196b23b294237e496b0c3aca2c86a0a84a9..2cf8fe693453a12414cb468f85be3714c966d3ab 100644 (file)
@@ -1,18 +1,8 @@
-/**
- * \file attrib.h
- * Attribute stacks.
- * 
- * \if subset
- * (No-op)
- *
- * \endif
- */
-
 /*
  * Mesa 3-D graphics library
- * Version:  5.1
+ * Version:  7.1
  *
- * Copyright (C) 1999-2003  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -32,8 +22,6 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
-
-
 #ifndef ATTRIB_H
 #define ATTRIB_H
 
@@ -58,10 +46,14 @@ _mesa_PopClientAttrib( void );
 extern void 
 _mesa_init_attrib( GLcontext *ctx );
 
+extern void 
+_mesa_free_attrib_data( GLcontext *ctx );
+
 #else
 
 /** No-op */
 #define _mesa_init_attrib( c ) ((void)0)
+#define _mesa_free_attrib_data( c ) ((void)0)
 
 #endif
 
index ecdb4d219c8e9ddce89826e28bfc6c5bbd85bd0f..68491359e84c02812dcfdffaee025fd7d567b1f9 100644 (file)
@@ -439,6 +439,89 @@ _mesa_init_buffer_objects( GLcontext *ctx )
    ctx->Array.ElementArrayBufferObj = ctx->Array.NullBufferObj;
 }
 
+/**
+ * Bind the specified target to buffer for the specified context.
+ */
+static void
+bind_buffer_object(GLcontext *ctx, GLenum target, GLuint buffer)
+{
+   struct gl_buffer_object *oldBufObj;
+   struct gl_buffer_object *newBufObj = NULL;
+   struct gl_buffer_object **bindTarget = NULL;
+
+   switch (target) {
+   case GL_ARRAY_BUFFER_ARB:
+      bindTarget = &ctx->Array.ArrayBufferObj;
+      break;
+   case GL_ELEMENT_ARRAY_BUFFER_ARB:
+      bindTarget = &ctx->Array.ElementArrayBufferObj;
+      break;
+   case GL_PIXEL_PACK_BUFFER_EXT:
+      bindTarget = &ctx->Pack.BufferObj;
+      break;
+   case GL_PIXEL_UNPACK_BUFFER_EXT:
+      bindTarget = &ctx->Unpack.BufferObj;
+      break;
+   default:
+      _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferARB(target)");
+      return;
+   }
+
+   /* Get pointer to old buffer object (to be unbound) */
+   oldBufObj = get_buffer(ctx, target);
+   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 */
+      newBufObj = _mesa_lookup_bufferobj(ctx, buffer);
+      if (!newBufObj) {
+         /* if this is a new buffer object id, allocate a buffer object now */
+         ASSERT(ctx->Driver.NewBufferObject);
+         newBufObj = ctx->Driver.NewBufferObject(ctx, buffer, target);
+         if (!newBufObj) {
+            _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindBufferARB");
+            return;
+         }
+         _mesa_HashInsert(ctx->Shared->BufferObjects, buffer, newBufObj);
+      }
+   }
+   
+   /* bind new buffer */
+   _mesa_reference_buffer_object(ctx, bindTarget, newBufObj);
+
+   /* Pass BindBuffer call to device driver */
+   if (ctx->Driver.BindBuffer && newBufObj)
+      ctx->Driver.BindBuffer( ctx, target, newBufObj );
+}
+
+
+/**
+ * Update the default buffer objects in the given context to reference those
+ * specified in the shared state and release those referencing the old 
+ * shared state.
+ */
+void
+_mesa_update_default_objects_buffer_objects(GLcontext *ctx)
+{
+   /* Bind the NullBufferObj to remove references to those
+    * in the shared context hash table.
+    */
+   bind_buffer_object( ctx, GL_ARRAY_BUFFER_ARB, 0);
+   bind_buffer_object( ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
+   bind_buffer_object( ctx, GL_PIXEL_PACK_BUFFER_ARB, 0);
+   bind_buffer_object( ctx, GL_PIXEL_UNPACK_BUFFER_ARB, 0);
+}
+
 
 /**
  * When we're about to read pixel data out of a PBO (via glDrawPixels,
@@ -677,64 +760,9 @@ void GLAPIENTRY
 _mesa_BindBufferARB(GLenum target, GLuint buffer)
 {
    GET_CURRENT_CONTEXT(ctx);
-   struct gl_buffer_object *oldBufObj;
-   struct gl_buffer_object *newBufObj = NULL;
-   struct gl_buffer_object **bindTarget = NULL;
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   switch (target) {
-      case GL_ARRAY_BUFFER_ARB:
-         bindTarget = &ctx->Array.ArrayBufferObj;
-         break;
-      case GL_ELEMENT_ARRAY_BUFFER_ARB:
-         bindTarget = &ctx->Array.ElementArrayBufferObj;
-         break;
-      case GL_PIXEL_PACK_BUFFER_EXT:
-         bindTarget = &ctx->Pack.BufferObj;
-         break;
-      case GL_PIXEL_UNPACK_BUFFER_EXT:
-         bindTarget = &ctx->Unpack.BufferObj;
-         break;
-      default:
-         _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferARB(target)");
-         return;
-   }
-
-   /* Get pointer to old buffer object (to be unbound) */
-   oldBufObj = get_buffer(ctx, target);
-   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 */
-      newBufObj = _mesa_lookup_bufferobj(ctx, buffer);
-      if (!newBufObj) {
-         /* if this is a new buffer object id, allocate a buffer object now */
-         ASSERT(ctx->Driver.NewBufferObject);
-        newBufObj = ctx->Driver.NewBufferObject(ctx, buffer, target);
-         if (!newBufObj) {
-            _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindBufferARB");
-            return;
-         }
-          _mesa_HashInsert(ctx->Shared->BufferObjects, buffer, newBufObj);
-      }
-   }
-   
-   /* bind new buffer */
-   _mesa_reference_buffer_object(ctx, bindTarget, newBufObj);
-
-   /* Pass BindBuffer call to device driver */
-   if (ctx->Driver.BindBuffer && newBufObj)
-      ctx->Driver.BindBuffer( ctx, target, newBufObj );
+   bind_buffer_object(ctx, target, buffer);
 }
 
 
@@ -794,7 +822,7 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
             _mesa_BindBufferARB( GL_PIXEL_UNPACK_BUFFER_EXT, 0 );
          }
 
-        /* The ID is immediately freed for re-use */
+         /* The ID is immediately freed for re-use */
          _mesa_HashRemove(ctx->Shared->BufferObjects, bufObj->Name);
          _mesa_reference_buffer_object(ctx, &bufObj, NULL);
       }
index 2f908c5c35d68fac71d859b4413aaad44a84d0d8..3c08f0083cf64fcb08fa96a57e718da958fe1c6a 100644 (file)
@@ -38,6 +38,9 @@
 extern void
 _mesa_init_buffer_objects( GLcontext *ctx );
 
+extern void
+_mesa_update_default_objects_buffer_objects(GLcontext *ctx);
+
 extern struct gl_buffer_object *
 _mesa_new_buffer_object( GLcontext *ctx, GLuint name, GLenum target );
 
@@ -103,7 +106,6 @@ extern void
 _mesa_unmap_drawpix_pbo(GLcontext *ctx,
                         const struct gl_pixelstore_attrib *unpack);
 
-
 extern void *
 _mesa_map_readpix_pbo(GLcontext *ctx,
                       const struct gl_pixelstore_attrib *pack,
index 1d07c68633c28d6940c2ce380f298db3826621b1..5dd85de272a1a942e9178720f6a852ae72bd90c3 100644 (file)
@@ -133,6 +133,14 @@ draw_buffer_enum_to_bitmask(GLenum buffer)
          return BUFFER_BIT_COLOR2;
       case GL_COLOR_ATTACHMENT3_EXT:
          return BUFFER_BIT_COLOR3;
+      case GL_COLOR_ATTACHMENT4_EXT:
+         return BUFFER_BIT_COLOR4;
+      case GL_COLOR_ATTACHMENT5_EXT:
+         return BUFFER_BIT_COLOR5;
+      case GL_COLOR_ATTACHMENT6_EXT:
+         return BUFFER_BIT_COLOR6;
+      case GL_COLOR_ATTACHMENT7_EXT:
+         return BUFFER_BIT_COLOR7;
       default:
          /* error */
          return BAD_MASK;
@@ -182,6 +190,14 @@ read_buffer_enum_to_index(GLenum buffer)
          return BUFFER_COLOR2;
       case GL_COLOR_ATTACHMENT3_EXT:
          return BUFFER_COLOR3;
+      case GL_COLOR_ATTACHMENT4_EXT:
+         return BUFFER_COLOR4;
+      case GL_COLOR_ATTACHMENT5_EXT:
+         return BUFFER_COLOR5;
+      case GL_COLOR_ATTACHMENT6_EXT:
+         return BUFFER_COLOR6;
+      case GL_COLOR_ATTACHMENT7_EXT:
+         return BUFFER_COLOR7;
       default:
          /* error */
          return -1;
@@ -196,6 +212,20 @@ read_buffer_enum_to_index(GLenum buffer)
  * \sa _mesa_DrawBuffersARB
  *
  * \param buffer  buffer token such as GL_LEFT or GL_FRONT_AND_BACK, etc.
+ *
+ * Note that the behaviour of this function depends on whether the
+ * current ctx->DrawBuffer is a window-system framebuffer (Name=0) or
+ * a user-created framebuffer object (Name!=0).
+ *   In the former case, we update the per-context ctx->Color.DrawBuffer
+ *   state var _and_ the FB's ColorDrawBuffer state.
+ *   In the later case, we update the FB's ColorDrawBuffer state only.
+ *
+ * Furthermore, upon a MakeCurrent() or BindFramebuffer() call, if the
+ * new FB is a window system FB, we need to re-update the FB's
+ * ColorDrawBuffer state to match the context.  This is handled in
+ * _mesa_update_framebuffer().
+ *
+ * See the GL_EXT_framebuffer_object spec for more info.
  */
 void GLAPIENTRY
 _mesa_DrawBuffer(GLenum buffer)
@@ -315,45 +345,16 @@ _mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers)
 
 
 /**
- * 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.
- * \param ctx  current context
- * \param output  which fragment program output
- * \param buffer  buffer to write to (like GL_LEFT)
- * \param destMask  BUFFER_* bitmask
- *                  (like BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT).
- */
-static void
-set_color_output(GLcontext *ctx, GLuint output, GLenum buffer,
-                 GLbitfield destMask)
-{
-   struct gl_framebuffer *fb = ctx->DrawBuffer;
-
-   ASSERT(output < ctx->Const.MaxDrawBuffers);
-
-   /* Set per-FBO state */
-   fb->ColorDrawBuffer[output] = buffer;
-   fb->_ColorDrawBufferMask[output] = destMask;
-   /* not really needed, will be set later */
-   fb->_NumColorDrawBuffers[output] = 0;
-
-   if (fb->Name == 0)
-   /* Set traditional state var */
-      ctx->Color.DrawBuffer[output] = buffer;
-}
-
-
-/**
- * Helper routine used by _mesa_DrawBuffer, _mesa_DrawBuffersARB and
- * other places (window fbo fixup) to set fbo (and the old ctx) fields.
+ * Helper function to set the GL_DRAW_BUFFER state in the context and
+ * current FBO.
+ *
  * All error checking will have been done prior to calling this function
  * so nothing should go wrong at this point.
+ *
  * \param ctx  current context
  * \param n    number of color outputs to set
  * \param buffers  array[n] of colorbuffer names, like GL_LEFT.
- * \param destMask  array[n] of BUFFER_* bitmasks which correspond to the
+ * \param destMask  array[n] of BUFFER_BIT_* bitmasks which correspond to the
  *                  colorbuffer names.  (i.e. GL_FRONT_AND_BACK =>
  *                  BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT).
  */
@@ -361,13 +362,13 @@ void
 _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers,
                   const GLbitfield *destMask)
 {
+   struct gl_framebuffer *fb = ctx->DrawBuffer;
    GLbitfield mask[MAX_DRAW_BUFFERS];
-   GLuint output;
 
    if (!destMask) {
       /* compute destMask values now */
-      const GLbitfield supportedMask
-         = supported_buffer_bitmask(ctx, ctx->DrawBuffer);
+      const GLbitfield supportedMask = supported_buffer_bitmask(ctx, fb);
+      GLuint output;
       for (output = 0; output < n; output++) {
          mask[output] = draw_buffer_enum_to_bitmask(buffers[output]);
          ASSERT(mask[output] != BAD_MASK);
@@ -376,56 +377,75 @@ _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers,
       destMask = mask;
    }
 
-   for (output = 0; output < n; output++) {
-      set_color_output(ctx, output, buffers[output], destMask[output]);
+   if (n == 1) {
+      GLuint buf, count = 0;
+      /* init to -1 to help catch errors */
+      fb->_ColorDrawBufferIndexes[0] = -1;
+      for (buf = 0; buf < BUFFER_COUNT; buf++) {
+         if (destMask[0] & (1 << buf)) {
+            fb->_ColorDrawBufferIndexes[count] = buf;
+            count++;
+         }
+      }
+      fb->ColorDrawBuffer[0] = buffers[0];
+      fb->_NumColorDrawBuffers = count;
+   }
+   else {
+      GLuint buf, count = 0;
+      for (buf = 0; buf < n; buf++ ) {
+         if (destMask[buf]) {
+            fb->_ColorDrawBufferIndexes[buf] = _mesa_ffs(destMask[buf]) - 1;
+            fb->ColorDrawBuffer[buf] = buffers[buf];
+            count = buf + 1;
+         }
+         else {
+            fb->_ColorDrawBufferIndexes[buf] = -1;
+         }
+      }
+      /* set remaining outputs to -1 (GL_NONE) */
+      while (buf < ctx->Const.MaxDrawBuffers) {
+         fb->_ColorDrawBufferIndexes[buf] = -1;
+         fb->ColorDrawBuffer[buf] = GL_NONE;
+         buf++;
+      }
+      fb->_NumColorDrawBuffers = count;
    }
 
-   /* set remaining color outputs to NONE */
-   for (output = n; output < ctx->Const.MaxDrawBuffers; output++) {
-      set_color_output(ctx, output, GL_NONE, 0x0);
+   if (fb->Name == 0) {
+      /* also set context drawbuffer state */
+      GLuint buf;
+      for (buf = 0; buf < ctx->Const.MaxDrawBuffers; buf++) {
+         ctx->Color.DrawBuffer[buf] = fb->ColorDrawBuffer[buf];
+      }
    }
 
    ctx->NewState |= _NEW_BUFFERS;
 }
 
 
-GLboolean
-_mesa_readbuffer_update_fields(GLcontext *ctx, GLenum buffer)
+/**
+ * Like \sa _mesa_drawbuffers(), this is a helper function for setting
+ * GL_READ_BUFFER state in the context and current FBO.
+ * \param ctx  the rendering context
+ * \param buffer  GL_FRONT, GL_BACK, GL_COLOR_ATTACHMENT0, etc.
+ * \param bufferIndex  the numerical index corresponding to 'buffer'
+ */
+void
+_mesa_readbuffer(GLcontext *ctx, GLenum buffer, GLint bufferIndex)
 {
-   struct gl_framebuffer *fb;
-   GLbitfield supportedMask;
-   GLint srcBuffer;
-
-   fb = ctx->ReadBuffer;
-
-   if (MESA_VERBOSE & VERBOSE_API)
-      _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer));
-
-   if (fb->Name > 0 && buffer == GL_NONE) {
-      /* This is legal for user-created framebuffer objects */
-      srcBuffer = -1;
-   }
-   else {
-      /* general case / window-system framebuffer */
-      srcBuffer = read_buffer_enum_to_index(buffer);
-      if (srcBuffer == -1) {
-         _mesa_error(ctx, GL_INVALID_ENUM, "glReadBuffer(buffer=0x%x)", buffer);
-         return GL_FALSE;
-      }
-      supportedMask = supported_buffer_bitmask(ctx, fb);
-      if (((1 << srcBuffer) & supportedMask) == 0) {
-         _mesa_error(ctx, GL_INVALID_OPERATION, "glReadBuffer(buffer=0x%x)", buffer);
-         return GL_FALSE;
-      }
-   }
+   struct gl_framebuffer *fb = ctx->ReadBuffer;
 
    if (fb->Name == 0) {
+      /* Only update the per-context READ_BUFFER state if we're bound to
+       * a window-system framebuffer.
+       */
       ctx->Pixel.ReadBuffer = buffer;
    }
+
    fb->ColorReadBuffer = buffer;
-   fb->_ColorReadBufferIndex = srcBuffer;
+   fb->_ColorReadBufferIndex = bufferIndex;
 
-   return GL_TRUE;
+   ctx->NewState |= _NEW_PIXEL;
 }
 
 
@@ -437,15 +457,43 @@ _mesa_readbuffer_update_fields(GLcontext *ctx, GLenum buffer)
 void GLAPIENTRY
 _mesa_ReadBuffer(GLenum buffer)
 {
+   struct gl_framebuffer *fb;
+   GLbitfield supportedMask;
+   GLint srcBuffer;
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
 
    if (MESA_VERBOSE & VERBOSE_API)
       _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer));
 
-   if (!_mesa_readbuffer_update_fields(ctx, buffer))
-      return;
+   fb = ctx->ReadBuffer;
+
+   if (MESA_VERBOSE & VERBOSE_API)
+      _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer));
+
+   if (fb->Name > 0 && buffer == GL_NONE) {
+      /* This is legal for user-created framebuffer objects */
+      srcBuffer = -1;
+   }
+   else {
+      /* general case / window-system framebuffer */
+      srcBuffer = read_buffer_enum_to_index(buffer);
+      if (srcBuffer == -1) {
+         _mesa_error(ctx, GL_INVALID_ENUM,
+                     "glReadBuffer(buffer=0x%x)", buffer);
+         return;
+      }
+      supportedMask = supported_buffer_bitmask(ctx, fb);
+      if (((1 << srcBuffer) & supportedMask) == 0) {
+         _mesa_error(ctx, GL_INVALID_OPERATION,
+                     "glReadBuffer(buffer=0x%x)", buffer);
+         return;
+      }
+   }
+
+   /* OK, all error checking has been completed now */
 
+   _mesa_readbuffer(ctx, buffer, srcBuffer);
    ctx->NewState |= _NEW_BUFFERS;
 
    /*
index 53d5fb80d40beb19ae53667e5eb91f84b59ece1d..8a7e7b5c1f0e56a21db1e959ffd3e01e5c58d84b 100644 (file)
@@ -5,9 +5,9 @@
 
 /*
  * Mesa 3-D graphics library
- * Version:  6.5
+ * Version:  7.1
  *
- * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -46,8 +46,8 @@ extern void
 _mesa_drawbuffers(GLcontext *ctx, GLuint n, const GLenum *buffers,
                   const GLbitfield *destMask);
 
-extern GLboolean
-_mesa_readbuffer_update_fields(GLcontext *ctx, GLenum buffer);
+extern void
+_mesa_readbuffer(GLcontext *ctx, GLenum buffer, GLint bufferIndex);
 
 extern void GLAPIENTRY
 _mesa_ReadBuffer( GLenum mode );
index 434685984d1f463eb38135836fd4912ff137c55d..a6257f9b982da24d97a7ae8a6993e69cefe30fae 100644 (file)
@@ -114,8 +114,6 @@ _mesa_Clear( GLbitfield mask )
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
 
-   FLUSH_CURRENT(ctx, 0);
-
    if (MESA_VERBOSE & VERBOSE_API)
       _mesa_debug(ctx, "glClear 0x%x\n", mask);
 
@@ -138,7 +136,9 @@ _mesa_Clear( GLbitfield mask )
       return;
    }
 
-   if (ctx->DrawBuffer->Width == 0 || ctx->DrawBuffer->Height == 0)
+   if (ctx->DrawBuffer->Width == 0 || ctx->DrawBuffer->Height == 0 ||
+       ctx->DrawBuffer->_Xmin >= ctx->DrawBuffer->_Xmax ||
+       ctx->DrawBuffer->_Ymin >= ctx->DrawBuffer->_Ymax)
       return;
 
    if (ctx->RenderMode == GL_RENDER) {
@@ -155,7 +155,10 @@ _mesa_Clear( GLbitfield mask )
        */
       bufferMask = 0;
       if (mask & GL_COLOR_BUFFER_BIT) {
-         bufferMask |= ctx->DrawBuffer->_ColorDrawBufferMask[0];
+         GLuint i;
+         for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
+            bufferMask |= (1 << ctx->DrawBuffer->_ColorDrawBufferIndexes[i]);
+         }
       }
 
       if ((mask & GL_DEPTH_BUFFER_BIT)
index f8109ec755c42f0e3d40b22f0982bb23e58ab709..882e2f224aeedccec08c17db52504b821238e4db 100644 (file)
 /** For GL_ARB_vertex_shader */
 /*@{*/
 #define MAX_VERTEX_ATTRIBS 16
-#define MAX_VERTEX_TEXTURE_IMAGE_UNITS 0
+#define MAX_VERTEX_TEXTURE_IMAGE_UNITS MAX_TEXTURE_UNITS
 #define MAX_COMBINED_TEXTURE_IMAGE_UNITS (MAX_TEXTURE_IMAGE_UNITS + MAX_VERTEX_TEXTURE_IMAGE_UNITS)
 /*@}*/
 
index ed3faecf0dbb00cca216ac726a095cac936e5b2d..96a8c30106a27e5206f8ede556857790b9a26b87 100644 (file)
@@ -6,9 +6,9 @@
 
 /*
  * Mesa 3-D graphics library
- * Version:  6.5
+ * Version:  7.1
  *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -809,7 +809,7 @@ _mesa_init_current(GLcontext *ctx)
    }
 
    /* redo 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_WEIGHT], 1.0, 0.0, 0.0, 0.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 );
@@ -1064,7 +1064,28 @@ init_attrib_groups(GLcontext *ctx)
    /* Miscellaneous */
    ctx->NewState = _NEW_ALL;
    ctx->ErrorValue = (GLenum) GL_NO_ERROR;
-   ctx->_Facing = 0;
+
+   return GL_TRUE;
+}
+
+
+/**
+ * Update default objects in a GL context with respect to shared state.
+ *
+ * \param ctx GL context.
+ *
+ * Removes references to old default objects, (texture objects, program
+ * objects, etc.) and changes to reference those from the current shared
+ * state.
+ */
+static GLboolean
+update_default_objects(GLcontext *ctx)
+{
+   assert(ctx);
+
+   _mesa_update_default_objects_program(ctx);
+   _mesa_update_default_objects_texture(ctx);
+   _mesa_update_default_objects_buffer_objects(ctx);
 
    return GL_TRUE;
 }
@@ -1274,18 +1295,19 @@ _mesa_create_context(const GLvisual *visual,
 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);
-   }
-   else {
-      /* unreference WinSysDraw/Read buffers */
-      _mesa_unreference_framebuffer(&ctx->WinSysDrawBuffer);
-      _mesa_unreference_framebuffer(&ctx->WinSysReadBuffer);
-      _mesa_unreference_framebuffer(&ctx->DrawBuffer);
-      _mesa_unreference_framebuffer(&ctx->ReadBuffer);
+   if (!_mesa_get_current_context()){
+      /* No current context, but we may need one in order to delete
+       * texture objs, etc.  So temporarily bind the context now.
+       */
+      _mesa_make_current(ctx, NULL, NULL);
    }
 
+   /* unreference WinSysDraw/Read buffers */
+   _mesa_unreference_framebuffer(&ctx->WinSysDrawBuffer);
+   _mesa_unreference_framebuffer(&ctx->WinSysReadBuffer);
+   _mesa_unreference_framebuffer(&ctx->DrawBuffer);
+   _mesa_unreference_framebuffer(&ctx->ReadBuffer);
+
    _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, NULL);
    _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL);
    _mesa_reference_vertprog(ctx, &ctx->VertexProgram._TnlProgram, NULL);
@@ -1294,6 +1316,7 @@ _mesa_free_context_data( GLcontext *ctx )
    _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL);
    _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, NULL);
 
+   _mesa_free_attrib_data(ctx);
    _mesa_free_lighting_data( ctx );
 #if FEATURE_evaluators
    _mesa_free_eval_data( ctx );
@@ -1331,6 +1354,11 @@ _mesa_free_context_data( GLcontext *ctx )
 
    if (ctx->Extensions.String)
       _mesa_free((void *) ctx->Extensions.String);
+
+   /* unbind the context if it's currently bound */
+   if (ctx == _mesa_get_current_context()) {
+      _mesa_make_current(NULL, NULL, NULL);
+   }
 }
 
 
@@ -1562,8 +1590,6 @@ void
 _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
                     GLframebuffer *readBuffer )
 {
-   GET_CURRENT_CONTEXT(oldCtx);
-
    if (MESA_VERBOSE & VERBOSE_API)
       _mesa_debug(newCtx, "_mesa_make_current()\n");
 
@@ -1588,13 +1614,6 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
    _glapi_set_context((void *) newCtx);
    ASSERT(_mesa_get_current_context() == newCtx);
 
-   if (oldCtx) {
-      _mesa_unreference_framebuffer(&oldCtx->WinSysDrawBuffer);
-      _mesa_unreference_framebuffer(&oldCtx->WinSysReadBuffer);
-      _mesa_unreference_framebuffer(&oldCtx->DrawBuffer);
-      _mesa_unreference_framebuffer(&oldCtx->ReadBuffer);
-   }
-         
    if (!newCtx) {
       _glapi_set_dispatch(NULL);  /* none current */
    }
@@ -1614,10 +1633,12 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
           * or not bound to a user-created FBO.
           */
          if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) {
-         /* fix up the fb fields - these will end up wrong otherwise
-          * if the DRIdrawable changes, and everything relies on them.
-          * This is a bit messy (same as needed in _mesa_BindFramebufferEXT)
-         */
+            /* KW: merge conflict here, revisit. 
+             */
+            /* fix up the fb fields - these will end up wrong otherwise
+             * if the DRIdrawable changes, and everything relies on them.
+             * This is a bit messy (same as needed in _mesa_BindFramebufferEXT)
+             */
             unsigned int i;
             GLenum buffers[MAX_DRAW_BUFFERS];
 
@@ -1631,9 +1652,11 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
          }
          if (!newCtx->ReadBuffer || newCtx->ReadBuffer->Name == 0) {
             _mesa_reference_framebuffer(&newCtx->ReadBuffer, readBuffer);
-            _mesa_readbuffer_update_fields(newCtx, newCtx->Pixel.ReadBuffer);
          }
 
+         /* XXX only set this flag if we're really changing the draw/read
+          * framebuffer bindings.
+          */
         newCtx->NewState |= _NEW_BUFFERS;
 
 #if 1
@@ -1701,12 +1724,18 @@ 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);
-      }
+      struct gl_shared_state *oldSharedState = ctx->Shared;
+
       ctx->Shared = ctxToShare->Shared;
       ctx->Shared->RefCount++;
+
+      update_default_objects(ctx);
+
+      oldSharedState->RefCount--;
+      if (oldSharedState->RefCount == 0) {
+         free_shared_state(ctx, oldSharedState);
+      }
+
       return GL_TRUE;
    }
    else {
index 9423b66a7d8ac08eab51ce4b3ac023f95ca1522b..54f1af911d3b95d0942278af356469fd65d4f791 100644 (file)
@@ -275,10 +275,12 @@ do {                                                                      \
    (((CTX)->Light.Enabled &&                                           \
      (CTX)->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)    \
     || (CTX)->Fog.ColorSumEnabled                                      \
-    || ((CTX)->VertexProgram._Enabled &&                               \
-        ((CTX)->VertexProgram.Current->Base.InputsRead & VERT_BIT_COLOR1)) \
-    || ((CTX)->FragmentProgram._Enabled &&                             \
-        ((CTX)->FragmentProgram.Current->Base.InputsRead & FRAG_BIT_COL1)) \
+    || ((CTX)->VertexProgram._Current &&                               \
+        ((CTX)->VertexProgram._Current != (CTX)->VertexProgram._TnlProgram) &&    \
+        ((CTX)->VertexProgram._Current->Base.InputsRead & VERT_BIT_COLOR1)) \
+    || ((CTX)->FragmentProgram._Current &&                             \
+        ((CTX)->FragmentProgram._Current != (CTX)->FragmentProgram._TexEnvProgram) &&  \
+        ((CTX)->FragmentProgram._Current->Base.InputsRead & FRAG_BIT_COL1)) \
    )
 
 
index 7fb0a211d7aa8c9483117e8e9f837c8cc8d91019..ddb38030bf7394937665cdd9713abacc81bc3210 100644 (file)
@@ -456,8 +456,8 @@ struct dd_function_table {
     */
    void (*GetCompressedTexImage)(GLcontext *ctx, GLenum target, GLint level,
                                  GLvoid *img,
-                                 const struct gl_texture_object *texObj,
-                                 const struct gl_texture_image *texImage);
+                                 struct gl_texture_object *texObj,
+                                 struct gl_texture_image *texImage);
 
    /**
     * Called to query number of bytes of storage needed to store the
@@ -504,6 +504,11 @@ struct dd_function_table {
     */
    void (*FreeTexImageData)( GLcontext *ctx, struct gl_texture_image *tImage );
 
+   /** Map texture image data into user space */
+   void (*MapTexture)( GLcontext *ctx, struct gl_texture_object *tObj );
+   /** Unmap texture images from user space */
+   void (*UnmapTexture)( GLcontext *ctx, struct gl_texture_object *tObj );
+
    /**
     * Note: no context argument.  This function doesn't initially look
     * like it belongs here, except that the driver is the only entity
index d4990bb795ffe4c133d17a171b1d1e71254ffb6f..fb54d6184d95bc451ec195aae3695603e0b7705a 100644 (file)
@@ -213,7 +213,7 @@ put_values_z24(GLcontext *ctx, struct gl_renderbuffer *z24rb, GLuint count,
                const void *values, const GLubyte *mask)
 {
    struct gl_renderbuffer *dsrb = z24rb->Wrapped;
-   const GLubyte *src = (const GLubyte *) values;
+   const GLuint *src = (const GLuint *) values;
    ASSERT(z24rb->DataType == GL_UNSIGNED_INT);
    ASSERT(dsrb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT);
    ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
diff --git a/src/mesa/main/descrip.mms b/src/mesa/main/descrip.mms
new file mode 100644 (file)
index 0000000..3ef215f
--- /dev/null
@@ -0,0 +1,228 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen  joukj@hrem.nano.tudelft.nl
+# Last revision : 2 October 2007
+
+.first
+       define gl [---.include.gl]
+       define math [-.math]
+       define shader [-.shader]
+       define glapi [-.glapi]
+       define main [-.main]
+
+.include [---]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [---.include],[-.glapi],[-.shader]
+LIBDIR = [---.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)/float=ieee/ieee=denorm
+
+SOURCES =accum.c \
+       api_arrayelt.c \
+       api_loopback.c \
+       api_noop.c \
+       api_validate.c \
+       attrib.c \
+       arrayobj.c \
+       blend.c \
+       bufferobj.c \
+       buffers.c \
+       clip.c \
+       colortab.c \
+       context.c \
+       convolve.c \
+       debug.c \
+       depth.c \
+       depthstencil.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 \
+       mipmap.c \
+       mm.c \
+       pixel.c \
+       points.c \
+       polygon.c \
+       rastpos.c \
+       rbadaptors.c \
+       renderbuffer.c \
+       shaders.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 \
+       queryobj.c \
+       rbadaptors.c
+
+OBJECTS=accum.obj,\
+api_arrayelt.obj,\
+api_loopback.obj,\
+api_noop.obj,\
+api_validate.obj,\
+arrayobj.obj,\
+attrib.obj,\
+blend.obj,\
+bufferobj.obj,\
+buffers.obj,\
+clip.obj,\
+colortab.obj,\
+context.obj,\
+convolve.obj,\
+debug.obj,\
+depth.obj,\
+depthstencil.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,\
+mipmap.obj,\
+mm.obj,\
+pixel.obj,\
+points.obj,\
+polygon.obj,\
+rastpos.obj,\
+renderbuffer.obj,\
+shaders.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,\
+queryobj.obj,\
+rbadaptors.obj
+
+##### RULES #####
+
+VERSION=Mesa V3.4
+
+##### TARGETS #####
+# Make the library
+$(LIBDIR)$(GL_LIB) : $(OBJECTS)
+  @ $(MAKELIB) $(LIBDIR)$(GL_LIB) $(OBJECTS)
+
+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
+arrayobj.obj : arrayobj.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
+depthstencil.obj : depthstencil.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
+mipmap.obj : mipmap.c
+mm.obj : mm.c
+pixel.obj : pixel.c
+points.obj : points.c
+polygon.obj : polygon.c
+rastpos.obj : rastpos.c
+rbadaptors.obj : rbadaptors.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
+shaders.obj : shaders.c
+queryobj.obj : queryobj.c
+rbadaptors.obj : rbadaptors.c
index ffe6dbfe08a925c2d317dc38e856787f043c8fb8..f7660930a9c39e8d7c90b9deef6f601591f25c1d 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.1
+ * Version:  7.1
  *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -612,9 +612,9 @@ destroy_list(GLcontext *ctx, GLuint list)
 
 
 /*
- * Translate the nth element of list from type to GLuint.
+ * Translate the nth element of list from <type> to GLint.
  */
-static GLuint
+static GLint
 translate_id(GLsizei n, GLenum type, const GLvoid * list)
 {
    GLbyte *bptr;
@@ -628,37 +628,40 @@ translate_id(GLsizei n, GLenum type, const GLvoid * list)
    switch (type) {
    case GL_BYTE:
       bptr = (GLbyte *) list;
-      return (GLuint) *(bptr + n);
+      return (GLint) bptr[n];
    case GL_UNSIGNED_BYTE:
       ubptr = (GLubyte *) list;
-      return (GLuint) *(ubptr + n);
+      return (GLint) ubptr[n];
    case GL_SHORT:
       sptr = (GLshort *) list;
-      return (GLuint) *(sptr + n);
+      return (GLint) sptr[n];
    case GL_UNSIGNED_SHORT:
       usptr = (GLushort *) list;
-      return (GLuint) *(usptr + n);
+      return (GLint) usptr[n];
    case GL_INT:
       iptr = (GLint *) list;
-      return (GLuint) *(iptr + n);
+      return iptr[n];
    case GL_UNSIGNED_INT:
       uiptr = (GLuint *) list;
-      return (GLuint) *(uiptr + n);
+      return (GLint) uiptr[n];
    case GL_FLOAT:
       fptr = (GLfloat *) list;
-      return (GLuint) *(fptr + n);
+      return (GLint) FLOORF(fptr[n]);
    case GL_2_BYTES:
       ubptr = ((GLubyte *) list) + 2 * n;
-      return (GLuint) *ubptr * 256 + (GLuint) * (ubptr + 1);
+      return (GLint) ubptr[0] * 256
+           + (GLint) ubptr[1];
    case GL_3_BYTES:
       ubptr = ((GLubyte *) list) + 3 * n;
-      return (GLuint) * ubptr * 65536
-           + (GLuint) *(ubptr + 1) * 256 + (GLuint) * (ubptr + 2);
+      return (GLint) ubptr[0] * 65536
+           + (GLint) ubptr[1] * 256
+           + (GLint) 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);
+      return (GLint) ubptr[0] * 16777216
+           + (GLint) ubptr[1] * 65536
+           + (GLint) ubptr[2] * 256
+           + (GLint) ubptr[3];
    default:
       return 0;
    }
@@ -1000,10 +1003,10 @@ _mesa_save_CallLists(GLsizei n, GLenum type, const GLvoid * lists)
    }
 
    for (i = 0; i < n; i++) {
-      GLuint list = translate_id(i, type, lists);
+      GLint list = translate_id(i, type, lists);
       Node *n = ALLOC_INSTRUCTION(ctx, OPCODE_CALL_LIST_OFFSET, 2);
       if (n) {
-         n[1].ui = list;
+         n[1].i = list;
          n[2].b = typeErrorFlag;
       }
    }
@@ -2723,21 +2726,20 @@ save_PolygonMode(GLenum face, GLenum mode)
 }
 
 
-/*
- * Polygon stipple must have been upacked already!
- */
 static void GLAPIENTRY
 save_PolygonStipple(const GLubyte * pattern)
 {
    GET_CURRENT_CONTEXT(ctx);
+   GLvoid *image = unpack_image(2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP,
+                                pattern, &ctx->Unpack);
    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 = _mesa_malloc(32 * 4);
-      data = n[1].data;         /* This needed for Acorn compiler */
-      MEMCPY(data, pattern, 32 * 4);
+      n[1].data = image; 
+   }
+   else if (image) {
+      _mesa_free(image);
    }
    if (ctx->ExecuteFlag) {
       CALL_PolygonStipple(ctx->Exec, ((GLubyte *) pattern));
@@ -3253,6 +3255,36 @@ save_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
 }
 
 
+static void GLAPIENTRY
+save_StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref,
+                            GLuint mask)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   /* GL_FRONT */
+   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
+   if (n) {
+      n[1].e = GL_FRONT;
+      n[2].e = frontfunc;
+      n[3].i = ref;
+      n[4].ui = mask;
+   }
+   /* GL_BACK */
+   n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
+   if (n) {
+      n[1].e = GL_BACK;
+      n[2].e = backfunc;
+      n[3].i = ref;
+      n[4].ui = mask;
+   }
+   if (ctx->ExecuteFlag) {
+      CALL_StencilFuncSeparate(ctx->Exec, (GL_FRONT, frontfunc, ref, mask));
+      CALL_StencilFuncSeparate(ctx->Exec, (GL_BACK, backfunc, ref, mask));
+   }
+}
+
+
 static void GLAPIENTRY
 save_StencilMaskSeparate(GLenum face, GLuint mask)
 {
@@ -5587,6 +5619,27 @@ save_VertexAttrib4fvARB(GLuint index, const GLfloat * v)
 }
 
 
+/* GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */
+
+static void GLAPIENTRY
+exec_BindAttribLocationARB(GLuint program, GLuint index, const GLchar *name)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   FLUSH_VERTICES(ctx, 0);
+   CALL_BindAttribLocationARB(ctx->Exec, (program, index, name));
+}
+
+static GLint GLAPIENTRY
+exec_GetAttribLocationARB(GLuint program, const GLchar *name)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   FLUSH_VERTICES(ctx, 0);
+   return CALL_GetAttribLocationARB(ctx->Exec, (program, name));
+}
+/* XXX more shader functions needed here */
+
+
+
 #if FEATURE_EXT_framebuffer_blit
 static void GLAPIENTRY
 save_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
@@ -5695,7 +5748,7 @@ execute_list(GLcontext *ctx, GLuint list)
    if (!dlist)
       return;
 
-   ctx->ListState.CallStack[ctx->ListState.CallDepth++] = dlist;
+   ctx->ListState.CallDepth++;
 
    if (ctx->Driver.BeginCallList)
       ctx->Driver.BeginCallList(ctx, dlist);
@@ -5762,7 +5815,8 @@ execute_list(GLcontext *ctx, GLuint list)
                _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);
+               GLuint list = (GLuint) (ctx->List.ListBase + n[1].i);
+               execute_list(ctx, list);
             }
             break;
          case OPCODE_CLEAR:
@@ -6126,7 +6180,12 @@ execute_list(GLcontext *ctx, GLuint list)
             CALL_PolygonMode(ctx->Exec, (n[1].e, n[2].e));
             break;
          case OPCODE_POLYGON_STIPPLE:
-            CALL_PolygonStipple(ctx->Exec, ((GLubyte *) n[1].data));
+            {
+               const struct gl_pixelstore_attrib save = ctx->Unpack;
+               ctx->Unpack = ctx->DefaultPacking;
+               CALL_PolygonStipple(ctx->Exec, ((GLubyte *) n[1].data));
+               ctx->Unpack = save;      /* restore */
+            }
             break;
          case OPCODE_POLYGON_OFFSET:
             CALL_PolygonOffset(ctx->Exec, (n[1].f, n[2].f));
@@ -6577,7 +6636,7 @@ execute_list(GLcontext *ctx, GLuint list)
    if (ctx->Driver.EndCallList)
       ctx->Driver.EndCallList(ctx);
 
-   ctx->ListState.CallStack[ctx->ListState.CallDepth--] = NULL;
+   ctx->ListState.CallDepth--;
 }
 
 
@@ -6808,7 +6867,6 @@ void GLAPIENTRY
 _mesa_CallLists(GLsizei n, GLenum type, const GLvoid * lists)
 {
    GET_CURRENT_CONTEXT(ctx);
-   GLuint list;
    GLint i;
    GLboolean save_compile_flag;
 
@@ -6840,8 +6898,8 @@ _mesa_CallLists(GLsizei n, GLenum type, const GLvoid * lists)
    ctx->CompileFlag = GL_FALSE;
 
    for (i = 0; i < n; i++) {
-      list = translate_id(i, type, lists);
-      execute_list(ctx, ctx->List.ListBase + list);
+      GLuint list = (GLuint) (ctx->List.ListBase + translate_id(i, type, lists));
+      execute_list(ctx, list);
    }
 
    ctx->CompileFlag = save_compile_flag;
@@ -7821,6 +7879,9 @@ _mesa_init_dlist_table(struct _glapi_table *table)
    SET_StencilMaskSeparate(table, save_StencilMaskSeparate);
    SET_StencilOpSeparate(table, save_StencilOpSeparate);
 
+   /* ATI_separate_stencil */ 
+   SET_StencilFuncSeparateATI(table, save_StencilFuncSeparateATI);
+
    /* GL_ARB_imaging */
    /* Not all are supported */
    SET_BlendColor(table, save_BlendColor);
@@ -8118,6 +8179,11 @@ _mesa_init_dlist_table(struct _glapi_table *table)
    SET_BlitFramebufferEXT(table, save_BlitFramebufferEXT);
 #endif
 
+   /* ARB 30/31/32. GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */
+   SET_BindAttribLocationARB(table, exec_BindAttribLocationARB);
+   SET_GetAttribLocationARB(table, exec_GetAttribLocationARB);
+   /* XXX additional functions need to be implemented here! */
+
    /* 299. GL_EXT_blend_equation_separate */
    SET_BlendEquationSeparateEXT(table, save_BlendEquationSeparateEXT);
 
index 6db198ea3bbd2c0b918f13988a2ca36615b16816..13cfa0e756e28d2573c6c3e5c71530731fd47f5a 100644 (file)
@@ -218,7 +218,7 @@ _mesa_Bitmap( GLsizei width, GLsizei height,
 
    if (ctx->RenderMode == GL_RENDER) {
       /* Truncate, to satisfy conformance tests (matches SGI's OpenGL). */
-      const GLfloat epsilon = (const GLfloat)0.0001;
+      const GLfloat epsilon = 0.0001F;
       GLint x = IFLOOR(ctx->Current.RasterPos[0] + epsilon - xorig);
       GLint y = IFLOOR(ctx->Current.RasterPos[1] + epsilon - yorig);
 
index 9dc55d4e69fd91b88b36b89fc91be7d689543e2f..248df1badca3b43a4768dd24051c4982e27f9579 100644 (file)
@@ -5,9 +5,9 @@
 
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.1
+ * Version:  7.0.3
  *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -38,6 +38,7 @@
 #include "enums.h"
 #include "math/m_matrix.h"
 #include "math/m_xform.h"
+#include "api_arrayelt.h"
 
 
 
@@ -136,6 +137,9 @@ client_state(GLcontext *ctx, GLenum cap, GLboolean state)
 
    FLUSH_VERTICES(ctx, _NEW_ARRAY);
    ctx->Array.NewState |= flag;
+
+   _ae_invalidate_state(ctx, _NEW_ARRAY);
+
    *var = state;
 
    if (state)
@@ -373,18 +377,24 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean 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)
@@ -523,18 +533,21 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean 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)
@@ -885,6 +898,10 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean 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
index 8ce6b51d17cd494d179aa37c2897817b3d7f6edf..15e7d5b96ce713d3e72e9456b63bfe34673ca815 100644 (file)
@@ -88,7 +88,6 @@ LONGSTRING static const char enum_string_table[] =
    "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_ATTACHED_SHADERS\0"
@@ -456,7 +455,6 @@ LONGSTRING static const char enum_string_table[] =
    "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"
@@ -1787,7 +1785,7 @@ LONGSTRING static const char enum_string_table[] =
    "GL_ZOOM_Y\0"
    ;
 
-static const enum_elt all_enums[1750] =
+static const enum_elt all_enums[1748] =
 {
    {     0, 0x00000600 }, /* GL_2D */
    {     6, 0x00001407 }, /* GL_2_BYTES */
@@ -1842,2990 +1840,2988 @@ static const enum_elt all_enums[1750] =
    {   830, 0x00001504 }, /* GL_AND_INVERTED */
    {   846, 0x00001502 }, /* GL_AND_REVERSE */
    {   861, 0x00008892 }, /* GL_ARRAY_BUFFER */
-   {   877, 0x00008892 }, /* GL_ARRAY_BUFFER_ARB */
-   {   897, 0x00008894 }, /* GL_ARRAY_BUFFER_BINDING */
-   {   921, 0x00008894 }, /* GL_ARRAY_BUFFER_BINDING_ARB */
-   {   949, 0x00008B85 }, /* GL_ATTACHED_SHADERS */
-   {   969, 0x00008645 }, /* GL_ATTRIB_ARRAY_POINTER_NV */
-   {   996, 0x00008623 }, /* GL_ATTRIB_ARRAY_SIZE_NV */
-   {  1020, 0x00008624 }, /* GL_ATTRIB_ARRAY_STRIDE_NV */
-   {  1046, 0x00008625 }, /* GL_ATTRIB_ARRAY_TYPE_NV */
-   {  1070, 0x00000BB0 }, /* GL_ATTRIB_STACK_DEPTH */
-   {  1092, 0x00000D80 }, /* GL_AUTO_NORMAL */
-   {  1107, 0x00000409 }, /* GL_AUX0 */
-   {  1115, 0x0000040A }, /* GL_AUX1 */
-   {  1123, 0x0000040B }, /* GL_AUX2 */
-   {  1131, 0x0000040C }, /* GL_AUX3 */
-   {  1139, 0x00000C00 }, /* GL_AUX_BUFFERS */
-   {  1154, 0x00000405 }, /* GL_BACK */
-   {  1162, 0x00000402 }, /* GL_BACK_LEFT */
-   {  1175, 0x00000403 }, /* GL_BACK_RIGHT */
-   {  1189, 0x000080E0 }, /* GL_BGR */
-   {  1196, 0x000080E1 }, /* GL_BGRA */
-   {  1204, 0x00001A00 }, /* GL_BITMAP */
-   {  1214, 0x00000704 }, /* GL_BITMAP_TOKEN */
-   {  1230, 0x00000BE2 }, /* GL_BLEND */
-   {  1239, 0x00008005 }, /* GL_BLEND_COLOR */
-   {  1254, 0x00008005 }, /* GL_BLEND_COLOR_EXT */
-   {  1273, 0x00000BE0 }, /* GL_BLEND_DST */
-   {  1286, 0x000080CA }, /* GL_BLEND_DST_ALPHA */
-   {  1305, 0x000080C8 }, /* GL_BLEND_DST_RGB */
-   {  1322, 0x00008009 }, /* GL_BLEND_EQUATION */
-   {  1340, 0x0000883D }, /* GL_BLEND_EQUATION_ALPHA */
-   {  1364, 0x0000883D }, /* GL_BLEND_EQUATION_ALPHA_EXT */
-   {  1392, 0x00008009 }, /* GL_BLEND_EQUATION_EXT */
-   {  1414, 0x00008009 }, /* GL_BLEND_EQUATION_RGB_EXT */
-   {  1440, 0x00000BE1 }, /* GL_BLEND_SRC */
-   {  1453, 0x000080CB }, /* GL_BLEND_SRC_ALPHA */
-   {  1472, 0x000080C9 }, /* GL_BLEND_SRC_RGB */
-   {  1489, 0x00001905 }, /* GL_BLUE */
-   {  1497, 0x00000D1B }, /* GL_BLUE_BIAS */
-   {  1510, 0x00000D54 }, /* GL_BLUE_BITS */
-   {  1523, 0x00000D1A }, /* GL_BLUE_SCALE */
-   {  1537, 0x00008B56 }, /* GL_BOOL */
-   {  1545, 0x00008B56 }, /* GL_BOOL_ARB */
-   {  1557, 0x00008B57 }, /* GL_BOOL_VEC2 */
-   {  1570, 0x00008B57 }, /* GL_BOOL_VEC2_ARB */
-   {  1587, 0x00008B58 }, /* GL_BOOL_VEC3 */
-   {  1600, 0x00008B58 }, /* GL_BOOL_VEC3_ARB */
-   {  1617, 0x00008B59 }, /* GL_BOOL_VEC4 */
-   {  1630, 0x00008B59 }, /* GL_BOOL_VEC4_ARB */
-   {  1647, 0x000088BB }, /* GL_BUFFER_ACCESS */
-   {  1664, 0x000088BB }, /* GL_BUFFER_ACCESS_ARB */
-   {  1685, 0x000088BC }, /* GL_BUFFER_MAPPED */
-   {  1702, 0x000088BC }, /* GL_BUFFER_MAPPED_ARB */
-   {  1723, 0x000088BD }, /* GL_BUFFER_MAP_POINTER */
-   {  1745, 0x000088BD }, /* GL_BUFFER_MAP_POINTER_ARB */
-   {  1771, 0x00008764 }, /* GL_BUFFER_SIZE */
-   {  1786, 0x00008764 }, /* GL_BUFFER_SIZE_ARB */
-   {  1805, 0x00008765 }, /* GL_BUFFER_USAGE */
-   {  1821, 0x00008765 }, /* GL_BUFFER_USAGE_ARB */
-   {  1841, 0x00001400 }, /* GL_BYTE */
-   {  1849, 0x00002A24 }, /* GL_C3F_V3F */
-   {  1860, 0x00002A26 }, /* GL_C4F_N3F_V3F */
-   {  1875, 0x00002A22 }, /* GL_C4UB_V2F */
-   {  1887, 0x00002A23 }, /* GL_C4UB_V3F */
-   {  1899, 0x00000901 }, /* GL_CCW */
-   {  1906, 0x00002900 }, /* GL_CLAMP */
-   {  1915, 0x0000812D }, /* GL_CLAMP_TO_BORDER */
-   {  1934, 0x0000812D }, /* GL_CLAMP_TO_BORDER_ARB */
-   {  1957, 0x0000812D }, /* GL_CLAMP_TO_BORDER_SGIS */
-   {  1981, 0x0000812F }, /* GL_CLAMP_TO_EDGE */
-   {  1998, 0x0000812F }, /* GL_CLAMP_TO_EDGE_SGIS */
-   {  2020, 0x00001500 }, /* GL_CLEAR */
-   {  2029, 0x000084E1 }, /* GL_CLIENT_ACTIVE_TEXTURE */
-   {  2054, 0x000084E1 }, /* GL_CLIENT_ACTIVE_TEXTURE_ARB */
-   {  2083, 0xFFFFFFFF }, /* GL_CLIENT_ALL_ATTRIB_BITS */
-   {  2109, 0x00000BB1 }, /* GL_CLIENT_ATTRIB_STACK_DEPTH */
-   {  2138, 0x00000001 }, /* GL_CLIENT_PIXEL_STORE_BIT */
-   {  2164, 0x00000002 }, /* GL_CLIENT_VERTEX_ARRAY_BIT */
-   {  2191, 0x00003000 }, /* GL_CLIP_PLANE0 */
-   {  2206, 0x00003001 }, /* GL_CLIP_PLANE1 */
-   {  2221, 0x00003002 }, /* GL_CLIP_PLANE2 */
-   {  2236, 0x00003003 }, /* GL_CLIP_PLANE3 */
-   {  2251, 0x00003004 }, /* GL_CLIP_PLANE4 */
-   {  2266, 0x00003005 }, /* GL_CLIP_PLANE5 */
-   {  2281, 0x000080F0 }, /* GL_CLIP_VOLUME_CLIPPING_HINT_EXT */
-   {  2314, 0x00000A00 }, /* GL_COEFF */
-   {  2323, 0x00001800 }, /* GL_COLOR */
-   {  2332, 0x00008076 }, /* GL_COLOR_ARRAY */
-   {  2347, 0x00008898 }, /* GL_COLOR_ARRAY_BUFFER_BINDING */
-   {  2377, 0x00008898 }, /* GL_COLOR_ARRAY_BUFFER_BINDING_ARB */
-   {  2411, 0x00008090 }, /* GL_COLOR_ARRAY_POINTER */
-   {  2434, 0x00008081 }, /* GL_COLOR_ARRAY_SIZE */
-   {  2454, 0x00008083 }, /* GL_COLOR_ARRAY_STRIDE */
-   {  2476, 0x00008082 }, /* GL_COLOR_ARRAY_TYPE */
-   {  2496, 0x00008CE0 }, /* GL_COLOR_ATTACHMENT0_EXT */
-   {  2521, 0x00008CEA }, /* GL_COLOR_ATTACHMENT10_EXT */
-   {  2547, 0x00008CEB }, /* GL_COLOR_ATTACHMENT11_EXT */
-   {  2573, 0x00008CEC }, /* GL_COLOR_ATTACHMENT12_EXT */
-   {  2599, 0x00008CED }, /* GL_COLOR_ATTACHMENT13_EXT */
-   {  2625, 0x00008CEE }, /* GL_COLOR_ATTACHMENT14_EXT */
-   {  2651, 0x00008CEF }, /* GL_COLOR_ATTACHMENT15_EXT */
-   {  2677, 0x00008CE1 }, /* GL_COLOR_ATTACHMENT1_EXT */
-   {  2702, 0x00008CE2 }, /* GL_COLOR_ATTACHMENT2_EXT */
-   {  2727, 0x00008CE3 }, /* GL_COLOR_ATTACHMENT3_EXT */
-   {  2752, 0x00008CE4 }, /* GL_COLOR_ATTACHMENT4_EXT */
-   {  2777, 0x00008CE5 }, /* GL_COLOR_ATTACHMENT5_EXT */
-   {  2802, 0x00008CE6 }, /* GL_COLOR_ATTACHMENT6_EXT */
-   {  2827, 0x00008CE7 }, /* GL_COLOR_ATTACHMENT7_EXT */
-   {  2852, 0x00008CE8 }, /* GL_COLOR_ATTACHMENT8_EXT */
-   {  2877, 0x00008CE9 }, /* GL_COLOR_ATTACHMENT9_EXT */
-   {  2902, 0x00004000 }, /* GL_COLOR_BUFFER_BIT */
-   {  2922, 0x00000C22 }, /* GL_COLOR_CLEAR_VALUE */
-   {  2943, 0x00001900 }, /* GL_COLOR_INDEX */
-   {  2958, 0x00001603 }, /* GL_COLOR_INDEXES */
-   {  2975, 0x00000BF2 }, /* GL_COLOR_LOGIC_OP */
-   {  2993, 0x00000B57 }, /* GL_COLOR_MATERIAL */
-   {  3011, 0x00000B55 }, /* GL_COLOR_MATERIAL_FACE */
-   {  3034, 0x00000B56 }, /* GL_COLOR_MATERIAL_PARAMETER */
-   {  3062, 0x000080B1 }, /* GL_COLOR_MATRIX */
-   {  3078, 0x000080B1 }, /* GL_COLOR_MATRIX_SGI */
-   {  3098, 0x000080B2 }, /* GL_COLOR_MATRIX_STACK_DEPTH */
-   {  3126, 0x000080B2 }, /* GL_COLOR_MATRIX_STACK_DEPTH_SGI */
-   {  3158, 0x00008458 }, /* GL_COLOR_SUM */
-   {  3171, 0x00008458 }, /* GL_COLOR_SUM_ARB */
-   {  3188, 0x000080D0 }, /* GL_COLOR_TABLE */
-   {  3203, 0x000080DD }, /* GL_COLOR_TABLE_ALPHA_SIZE */
-   {  3229, 0x000080DD }, /* GL_COLOR_TABLE_ALPHA_SIZE_EXT */
-   {  3259, 0x000080DD }, /* GL_COLOR_TABLE_ALPHA_SIZE_SGI */
-   {  3289, 0x000080D7 }, /* GL_COLOR_TABLE_BIAS */
-   {  3309, 0x000080D7 }, /* GL_COLOR_TABLE_BIAS_SGI */
-   {  3333, 0x000080DC }, /* GL_COLOR_TABLE_BLUE_SIZE */
-   {  3358, 0x000080DC }, /* GL_COLOR_TABLE_BLUE_SIZE_EXT */
-   {  3387, 0x000080DC }, /* GL_COLOR_TABLE_BLUE_SIZE_SGI */
-   {  3416, 0x000080D8 }, /* GL_COLOR_TABLE_FORMAT */
-   {  3438, 0x000080D8 }, /* GL_COLOR_TABLE_FORMAT_EXT */
-   {  3464, 0x000080D8 }, /* GL_COLOR_TABLE_FORMAT_SGI */
-   {  3490, 0x000080DB }, /* GL_COLOR_TABLE_GREEN_SIZE */
-   {  3516, 0x000080DB }, /* GL_COLOR_TABLE_GREEN_SIZE_EXT */
-   {  3546, 0x000080DB }, /* GL_COLOR_TABLE_GREEN_SIZE_SGI */
-   {  3576, 0x000080DF }, /* GL_COLOR_TABLE_INTENSITY_SIZE */
-   {  3606, 0x000080DF }, /* GL_COLOR_TABLE_INTENSITY_SIZE_EXT */
-   {  3640, 0x000080DF }, /* GL_COLOR_TABLE_INTENSITY_SIZE_SGI */
-   {  3674, 0x000080DE }, /* GL_COLOR_TABLE_LUMINANCE_SIZE */
-   {  3704, 0x000080DE }, /* GL_COLOR_TABLE_LUMINANCE_SIZE_EXT */
-   {  3738, 0x000080DE }, /* GL_COLOR_TABLE_LUMINANCE_SIZE_SGI */
-   {  3772, 0x000080DA }, /* GL_COLOR_TABLE_RED_SIZE */
-   {  3796, 0x000080DA }, /* GL_COLOR_TABLE_RED_SIZE_EXT */
-   {  3824, 0x000080DA }, /* GL_COLOR_TABLE_RED_SIZE_SGI */
-   {  3852, 0x000080D6 }, /* GL_COLOR_TABLE_SCALE */
-   {  3873, 0x000080D6 }, /* GL_COLOR_TABLE_SCALE_SGI */
-   {  3898, 0x000080D9 }, /* GL_COLOR_TABLE_WIDTH */
-   {  3919, 0x000080D9 }, /* GL_COLOR_TABLE_WIDTH_EXT */
-   {  3944, 0x000080D9 }, /* GL_COLOR_TABLE_WIDTH_SGI */
-   {  3969, 0x00000C23 }, /* GL_COLOR_WRITEMASK */
-   {  3988, 0x00008570 }, /* GL_COMBINE */
-   {  3999, 0x00008503 }, /* GL_COMBINE4 */
-   {  4011, 0x00008572 }, /* GL_COMBINE_ALPHA */
-   {  4028, 0x00008572 }, /* GL_COMBINE_ALPHA_ARB */
-   {  4049, 0x00008572 }, /* GL_COMBINE_ALPHA_EXT */
-   {  4070, 0x00008570 }, /* GL_COMBINE_ARB */
-   {  4085, 0x00008570 }, /* GL_COMBINE_EXT */
-   {  4100, 0x00008571 }, /* GL_COMBINE_RGB */
-   {  4115, 0x00008571 }, /* GL_COMBINE_RGB_ARB */
-   {  4134, 0x00008571 }, /* GL_COMBINE_RGB_EXT */
-   {  4153, 0x0000884E }, /* GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT */
-   {  4189, 0x0000884E }, /* GL_COMPARE_R_TO_TEXTURE */
-   {  4213, 0x0000884E }, /* GL_COMPARE_R_TO_TEXTURE_ARB */
-   {  4241, 0x00001300 }, /* GL_COMPILE */
-   {  4252, 0x00001301 }, /* GL_COMPILE_AND_EXECUTE */
-   {  4275, 0x00008B81 }, /* GL_COMPILE_STATUS */
-   {  4293, 0x000084E9 }, /* GL_COMPRESSED_ALPHA */
-   {  4313, 0x000084E9 }, /* GL_COMPRESSED_ALPHA_ARB */
-   {  4337, 0x000084EC }, /* GL_COMPRESSED_INTENSITY */
-   {  4361, 0x000084EC }, /* GL_COMPRESSED_INTENSITY_ARB */
-   {  4389, 0x000084EA }, /* GL_COMPRESSED_LUMINANCE */
-   {  4413, 0x000084EB }, /* GL_COMPRESSED_LUMINANCE_ALPHA */
-   {  4443, 0x000084EB }, /* GL_COMPRESSED_LUMINANCE_ALPHA_ARB */
-   {  4477, 0x000084EA }, /* GL_COMPRESSED_LUMINANCE_ARB */
-   {  4505, 0x000084ED }, /* GL_COMPRESSED_RGB */
-   {  4523, 0x000084EE }, /* GL_COMPRESSED_RGBA */
-   {  4542, 0x000084EE }, /* GL_COMPRESSED_RGBA_ARB */
-   {  4565, 0x000086B1 }, /* GL_COMPRESSED_RGBA_FXT1_3DFX */
-   {  4594, 0x000083F1 }, /* GL_COMPRESSED_RGBA_S3TC_DXT1_EXT */
-   {  4627, 0x000083F2 }, /* GL_COMPRESSED_RGBA_S3TC_DXT3_EXT */
-   {  4660, 0x000083F3 }, /* GL_COMPRESSED_RGBA_S3TC_DXT5_EXT */
-   {  4693, 0x000084ED }, /* GL_COMPRESSED_RGB_ARB */
-   {  4715, 0x000086B0 }, /* GL_COMPRESSED_RGB_FXT1_3DFX */
-   {  4743, 0x000083F0 }, /* GL_COMPRESSED_RGB_S3TC_DXT1_EXT */
-   {  4775, 0x000086A3 }, /* GL_COMPRESSED_TEXTURE_FORMATS */
-   {  4805, 0x00008576 }, /* GL_CONSTANT */
-   {  4817, 0x00008003 }, /* GL_CONSTANT_ALPHA */
-   {  4835, 0x00008003 }, /* GL_CONSTANT_ALPHA_EXT */
-   {  4857, 0x00008576 }, /* GL_CONSTANT_ARB */
-   {  4873, 0x00001207 }, /* GL_CONSTANT_ATTENUATION */
-   {  4897, 0x00008151 }, /* GL_CONSTANT_BORDER_HP */
-   {  4919, 0x00008001 }, /* GL_CONSTANT_COLOR */
-   {  4937, 0x00008001 }, /* GL_CONSTANT_COLOR_EXT */
-   {  4959, 0x00008576 }, /* GL_CONSTANT_EXT */
-   {  4975, 0x00008010 }, /* GL_CONVOLUTION_1D */
-   {  4993, 0x00008011 }, /* GL_CONVOLUTION_2D */
-   {  5011, 0x00008154 }, /* GL_CONVOLUTION_BORDER_COLOR */
-   {  5039, 0x00008154 }, /* GL_CONVOLUTION_BORDER_COLOR_HP */
-   {  5070, 0x00008013 }, /* GL_CONVOLUTION_BORDER_MODE */
-   {  5097, 0x00008013 }, /* GL_CONVOLUTION_BORDER_MODE_EXT */
-   {  5128, 0x00008015 }, /* GL_CONVOLUTION_FILTER_BIAS */
-   {  5155, 0x00008015 }, /* GL_CONVOLUTION_FILTER_BIAS_EXT */
-   {  5186, 0x00008014 }, /* GL_CONVOLUTION_FILTER_SCALE */
-   {  5214, 0x00008014 }, /* GL_CONVOLUTION_FILTER_SCALE_EXT */
-   {  5246, 0x00008017 }, /* GL_CONVOLUTION_FORMAT */
-   {  5268, 0x00008017 }, /* GL_CONVOLUTION_FORMAT_EXT */
-   {  5294, 0x00008019 }, /* GL_CONVOLUTION_HEIGHT */
-   {  5316, 0x00008019 }, /* GL_CONVOLUTION_HEIGHT_EXT */
-   {  5342, 0x00008018 }, /* GL_CONVOLUTION_WIDTH */
-   {  5363, 0x00008018 }, /* GL_CONVOLUTION_WIDTH_EXT */
-   {  5388, 0x00008862 }, /* GL_COORD_REPLACE */
-   {  5405, 0x00008862 }, /* GL_COORD_REPLACE_ARB */
-   {  5426, 0x00008862 }, /* GL_COORD_REPLACE_NV */
-   {  5446, 0x00001503 }, /* GL_COPY */
-   {  5454, 0x0000150C }, /* GL_COPY_INVERTED */
-   {  5471, 0x00000706 }, /* GL_COPY_PIXEL_TOKEN */
-   {  5491, 0x00000B44 }, /* GL_CULL_FACE */
-   {  5504, 0x00000B45 }, /* GL_CULL_FACE_MODE */
-   {  5522, 0x000081AA }, /* GL_CULL_VERTEX_EXT */
-   {  5541, 0x000081AC }, /* GL_CULL_VERTEX_EYE_POSITION_EXT */
-   {  5573, 0x000081AB }, /* GL_CULL_VERTEX_OBJECT_POSITION_EXT */
-   {  5608, 0x00008626 }, /* GL_CURRENT_ATTRIB_NV */
-   {  5629, 0x00000001 }, /* GL_CURRENT_BIT */
-   {  5644, 0x00000B00 }, /* GL_CURRENT_COLOR */
-   {  5661, 0x00008453 }, /* GL_CURRENT_FOG_COORD */
-   {  5682, 0x00008453 }, /* GL_CURRENT_FOG_COORDINATE */
-   {  5708, 0x00000B01 }, /* GL_CURRENT_INDEX */
-   {  5725, 0x00008641 }, /* GL_CURRENT_MATRIX_ARB */
-   {  5747, 0x00008845 }, /* GL_CURRENT_MATRIX_INDEX_ARB */
-   {  5775, 0x00008641 }, /* GL_CURRENT_MATRIX_NV */
-   {  5796, 0x00008640 }, /* GL_CURRENT_MATRIX_STACK_DEPTH_ARB */
-   {  5830, 0x00008640 }, /* GL_CURRENT_MATRIX_STACK_DEPTH_NV */
-   {  5863, 0x00000B02 }, /* GL_CURRENT_NORMAL */
-   {  5881, 0x00008843 }, /* GL_CURRENT_PALETTE_MATRIX_ARB */
-   {  5911, 0x00008B8D }, /* GL_CURRENT_PROGRAM */
-   {  5930, 0x00008865 }, /* GL_CURRENT_QUERY */
-   {  5947, 0x00008865 }, /* GL_CURRENT_QUERY_ARB */
-   {  5968, 0x00000B04 }, /* GL_CURRENT_RASTER_COLOR */
-   {  5992, 0x00000B09 }, /* GL_CURRENT_RASTER_DISTANCE */
-   {  6019, 0x00000B05 }, /* GL_CURRENT_RASTER_INDEX */
-   {  6043, 0x00000B07 }, /* GL_CURRENT_RASTER_POSITION */
-   {  6070, 0x00000B08 }, /* GL_CURRENT_RASTER_POSITION_VALID */
-   {  6103, 0x00000B06 }, /* GL_CURRENT_RASTER_TEXTURE_COORDS */
-   {  6136, 0x00008459 }, /* GL_CURRENT_SECONDARY_COLOR */
-   {  6163, 0x00000B03 }, /* GL_CURRENT_TEXTURE_COORDS */
-   {  6189, 0x00008626 }, /* GL_CURRENT_VERTEX_ATTRIB */
-   {  6214, 0x00008626 }, /* GL_CURRENT_VERTEX_ATTRIB_ARB */
-   {  6243, 0x000086A8 }, /* GL_CURRENT_WEIGHT_ARB */
-   {  6265, 0x00000900 }, /* GL_CW */
-   {  6271, 0x0000875B }, /* GL_DEBUG_ASSERT_MESA */
-   {  6292, 0x00008759 }, /* GL_DEBUG_OBJECT_MESA */
-   {  6313, 0x0000875A }, /* GL_DEBUG_PRINT_MESA */
-   {  6333, 0x00002101 }, /* GL_DECAL */
-   {  6342, 0x00001E03 }, /* GL_DECR */
-   {  6350, 0x00008508 }, /* GL_DECR_WRAP */
-   {  6363, 0x00008508 }, /* GL_DECR_WRAP_EXT */
-   {  6380, 0x00008B80 }, /* GL_DELETE_STATUS */
-   {  6397, 0x00001801 }, /* GL_DEPTH */
-   {  6406, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT_EXT */
-   {  6430, 0x00000D1F }, /* GL_DEPTH_BIAS */
-   {  6444, 0x00000D56 }, /* GL_DEPTH_BITS */
-   {  6458, 0x00008891 }, /* GL_DEPTH_BOUNDS_EXT */
-   {  6478, 0x00008890 }, /* GL_DEPTH_BOUNDS_TEST_EXT */
-   {  6503, 0x00000100 }, /* GL_DEPTH_BUFFER_BIT */
-   {  6523, 0x0000864F }, /* GL_DEPTH_CLAMP_NV */
-   {  6541, 0x00000B73 }, /* GL_DEPTH_CLEAR_VALUE */
-   {  6562, 0x00001902 }, /* GL_DEPTH_COMPONENT */
-   {  6581, 0x000081A5 }, /* GL_DEPTH_COMPONENT16 */
-   {  6602, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_ARB */
-   {  6627, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_SGIX */
-   {  6653, 0x000081A6 }, /* GL_DEPTH_COMPONENT24 */
-   {  6674, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_ARB */
-   {  6699, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_SGIX */
-   {  6725, 0x000081A7 }, /* GL_DEPTH_COMPONENT32 */
-   {  6746, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_ARB */
-   {  6771, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_SGIX */
-   {  6797, 0x00000B74 }, /* GL_DEPTH_FUNC */
-   {  6811, 0x00000B70 }, /* GL_DEPTH_RANGE */
-   {  6826, 0x00000D1E }, /* GL_DEPTH_SCALE */
-   {  6841, 0x000084F9 }, /* GL_DEPTH_STENCIL_NV */
-   {  6861, 0x0000886F }, /* GL_DEPTH_STENCIL_TO_BGRA_NV */
-   {  6889, 0x0000886E }, /* GL_DEPTH_STENCIL_TO_RGBA_NV */
-   {  6917, 0x00000B71 }, /* GL_DEPTH_TEST */
-   {  6931, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE */
-   {  6953, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE_ARB */
-   {  6979, 0x00000B72 }, /* GL_DEPTH_WRITEMASK */
-   {  6998, 0x00001201 }, /* GL_DIFFUSE */
-   {  7009, 0x00000BD0 }, /* GL_DITHER */
-   {  7019, 0x00000A02 }, /* GL_DOMAIN */
-   {  7029, 0x00001100 }, /* GL_DONT_CARE */
-   {  7042, 0x000086AE }, /* GL_DOT3_RGB */
-   {  7054, 0x000086AF }, /* GL_DOT3_RGBA */
-   {  7067, 0x000086AF }, /* GL_DOT3_RGBA_ARB */
-   {  7084, 0x00008741 }, /* GL_DOT3_RGBA_EXT */
-   {  7101, 0x000086AE }, /* GL_DOT3_RGB_ARB */
-   {  7117, 0x00008740 }, /* GL_DOT3_RGB_EXT */
-   {  7133, 0x0000140A }, /* GL_DOUBLE */
-   {  7143, 0x00000C32 }, /* GL_DOUBLEBUFFER */
-   {  7159, 0x00000C01 }, /* GL_DRAW_BUFFER */
-   {  7174, 0x00008825 }, /* GL_DRAW_BUFFER0 */
-   {  7190, 0x00008825 }, /* GL_DRAW_BUFFER0_ARB */
-   {  7210, 0x00008825 }, /* GL_DRAW_BUFFER0_ATI */
-   {  7230, 0x00008826 }, /* GL_DRAW_BUFFER1 */
-   {  7246, 0x0000882F }, /* GL_DRAW_BUFFER10 */
-   {  7263, 0x0000882F }, /* GL_DRAW_BUFFER10_ARB */
-   {  7284, 0x0000882F }, /* GL_DRAW_BUFFER10_ATI */
-   {  7305, 0x00008830 }, /* GL_DRAW_BUFFER11 */
-   {  7322, 0x00008830 }, /* GL_DRAW_BUFFER11_ARB */
-   {  7343, 0x00008830 }, /* GL_DRAW_BUFFER11_ATI */
-   {  7364, 0x00008831 }, /* GL_DRAW_BUFFER12 */
-   {  7381, 0x00008831 }, /* GL_DRAW_BUFFER12_ARB */
-   {  7402, 0x00008831 }, /* GL_DRAW_BUFFER12_ATI */
-   {  7423, 0x00008832 }, /* GL_DRAW_BUFFER13 */
-   {  7440, 0x00008832 }, /* GL_DRAW_BUFFER13_ARB */
-   {  7461, 0x00008832 }, /* GL_DRAW_BUFFER13_ATI */
-   {  7482, 0x00008833 }, /* GL_DRAW_BUFFER14 */
-   {  7499, 0x00008833 }, /* GL_DRAW_BUFFER14_ARB */
-   {  7520, 0x00008833 }, /* GL_DRAW_BUFFER14_ATI */
-   {  7541, 0x00008834 }, /* GL_DRAW_BUFFER15 */
-   {  7558, 0x00008834 }, /* GL_DRAW_BUFFER15_ARB */
-   {  7579, 0x00008834 }, /* GL_DRAW_BUFFER15_ATI */
-   {  7600, 0x00008826 }, /* GL_DRAW_BUFFER1_ARB */
-   {  7620, 0x00008826 }, /* GL_DRAW_BUFFER1_ATI */
-   {  7640, 0x00008827 }, /* GL_DRAW_BUFFER2 */
-   {  7656, 0x00008827 }, /* GL_DRAW_BUFFER2_ARB */
-   {  7676, 0x00008827 }, /* GL_DRAW_BUFFER2_ATI */
-   {  7696, 0x00008828 }, /* GL_DRAW_BUFFER3 */
-   {  7712, 0x00008828 }, /* GL_DRAW_BUFFER3_ARB */
-   {  7732, 0x00008828 }, /* GL_DRAW_BUFFER3_ATI */
-   {  7752, 0x00008829 }, /* GL_DRAW_BUFFER4 */
-   {  7768, 0x00008829 }, /* GL_DRAW_BUFFER4_ARB */
-   {  7788, 0x00008829 }, /* GL_DRAW_BUFFER4_ATI */
-   {  7808, 0x0000882A }, /* GL_DRAW_BUFFER5 */
-   {  7824, 0x0000882A }, /* GL_DRAW_BUFFER5_ARB */
-   {  7844, 0x0000882A }, /* GL_DRAW_BUFFER5_ATI */
-   {  7864, 0x0000882B }, /* GL_DRAW_BUFFER6 */
-   {  7880, 0x0000882B }, /* GL_DRAW_BUFFER6_ARB */
-   {  7900, 0x0000882B }, /* GL_DRAW_BUFFER6_ATI */
-   {  7920, 0x0000882C }, /* GL_DRAW_BUFFER7 */
-   {  7936, 0x0000882C }, /* GL_DRAW_BUFFER7_ARB */
-   {  7956, 0x0000882C }, /* GL_DRAW_BUFFER7_ATI */
-   {  7976, 0x0000882D }, /* GL_DRAW_BUFFER8 */
-   {  7992, 0x0000882D }, /* GL_DRAW_BUFFER8_ARB */
-   {  8012, 0x0000882D }, /* GL_DRAW_BUFFER8_ATI */
-   {  8032, 0x0000882E }, /* GL_DRAW_BUFFER9 */
-   {  8048, 0x0000882E }, /* GL_DRAW_BUFFER9_ARB */
-   {  8068, 0x0000882E }, /* GL_DRAW_BUFFER9_ATI */
-   {  8088, 0x00008CA6 }, /* GL_DRAW_FRAMEBUFFER_BINDING_EXT */
-   {  8120, 0x00008CA9 }, /* GL_DRAW_FRAMEBUFFER_EXT */
-   {  8144, 0x00000705 }, /* GL_DRAW_PIXEL_TOKEN */
-   {  8164, 0x00000304 }, /* GL_DST_ALPHA */
-   {  8177, 0x00000306 }, /* GL_DST_COLOR */
-   {  8190, 0x000088EA }, /* GL_DYNAMIC_COPY */
-   {  8206, 0x000088EA }, /* GL_DYNAMIC_COPY_ARB */
-   {  8226, 0x000088E8 }, /* GL_DYNAMIC_DRAW */
-   {  8242, 0x000088E8 }, /* GL_DYNAMIC_DRAW_ARB */
-   {  8262, 0x000088E9 }, /* GL_DYNAMIC_READ */
-   {  8278, 0x000088E9 }, /* GL_DYNAMIC_READ_ARB */
-   {  8298, 0x00000B43 }, /* GL_EDGE_FLAG */
-   {  8311, 0x00008079 }, /* GL_EDGE_FLAG_ARRAY */
-   {  8330, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */
-   {  8364, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB */
-   {  8402, 0x00008093 }, /* GL_EDGE_FLAG_ARRAY_POINTER */
-   {  8429, 0x0000808C }, /* GL_EDGE_FLAG_ARRAY_STRIDE */
-   {  8455, 0x00008893 }, /* GL_ELEMENT_ARRAY_BUFFER */
-   {  8479, 0x00008893 }, /* GL_ELEMENT_ARRAY_BUFFER_ARB */
-   {  8507, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */
-   {  8539, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB */
-   {  8575, 0x00001600 }, /* GL_EMISSION */
-   {  8587, 0x00002000 }, /* GL_ENABLE_BIT */
-   {  8601, 0x00000202 }, /* GL_EQUAL */
-   {  8610, 0x00001509 }, /* GL_EQUIV */
-   {  8619, 0x00010000 }, /* GL_EVAL_BIT */
-   {  8631, 0x00000800 }, /* GL_EXP */
-   {  8638, 0x00000801 }, /* GL_EXP2 */
-   {  8646, 0x00001F03 }, /* GL_EXTENSIONS */
-   {  8660, 0x00002400 }, /* GL_EYE_LINEAR */
-   {  8674, 0x00002502 }, /* GL_EYE_PLANE */
-   {  8687, 0x0000855C }, /* GL_EYE_PLANE_ABSOLUTE_NV */
-   {  8712, 0x0000855B }, /* GL_EYE_RADIAL_NV */
-   {  8729, 0x00000000 }, /* GL_FALSE */
-   {  8738, 0x00001101 }, /* GL_FASTEST */
-   {  8749, 0x00001C01 }, /* GL_FEEDBACK */
-   {  8761, 0x00000DF0 }, /* GL_FEEDBACK_BUFFER_POINTER */
-   {  8788, 0x00000DF1 }, /* GL_FEEDBACK_BUFFER_SIZE */
-   {  8812, 0x00000DF2 }, /* GL_FEEDBACK_BUFFER_TYPE */
-   {  8836, 0x00001B02 }, /* GL_FILL */
-   {  8844, 0x00001D00 }, /* GL_FLAT */
-   {  8852, 0x00001406 }, /* GL_FLOAT */
-   {  8861, 0x00008B5A }, /* GL_FLOAT_MAT2 */
-   {  8875, 0x00008B5A }, /* GL_FLOAT_MAT2_ARB */
-   {  8893, 0x00008B5B }, /* GL_FLOAT_MAT3 */
-   {  8907, 0x00008B5B }, /* GL_FLOAT_MAT3_ARB */
-   {  8925, 0x00008B5C }, /* GL_FLOAT_MAT4 */
-   {  8939, 0x00008B5C }, /* GL_FLOAT_MAT4_ARB */
-   {  8957, 0x00008B50 }, /* GL_FLOAT_VEC2 */
-   {  8971, 0x00008B50 }, /* GL_FLOAT_VEC2_ARB */
-   {  8989, 0x00008B51 }, /* GL_FLOAT_VEC3 */
-   {  9003, 0x00008B51 }, /* GL_FLOAT_VEC3_ARB */
-   {  9021, 0x00008B52 }, /* GL_FLOAT_VEC4 */
-   {  9035, 0x00008B52 }, /* GL_FLOAT_VEC4_ARB */
-   {  9053, 0x00000B60 }, /* GL_FOG */
-   {  9060, 0x00000080 }, /* GL_FOG_BIT */
-   {  9071, 0x00000B66 }, /* GL_FOG_COLOR */
-   {  9084, 0x00008451 }, /* GL_FOG_COORD */
-   {  9097, 0x00008451 }, /* GL_FOG_COORDINATE */
-   {  9115, 0x00008457 }, /* GL_FOG_COORDINATE_ARRAY */
-   {  9139, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */
-   {  9178, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB */
-   {  9221, 0x00008456 }, /* GL_FOG_COORDINATE_ARRAY_POINTER */
-   {  9253, 0x00008455 }, /* GL_FOG_COORDINATE_ARRAY_STRIDE */
-   {  9284, 0x00008454 }, /* GL_FOG_COORDINATE_ARRAY_TYPE */
-   {  9313, 0x00008450 }, /* GL_FOG_COORDINATE_SOURCE */
-   {  9338, 0x00008457 }, /* GL_FOG_COORD_ARRAY */
-   {  9357, 0x0000889D }, /* GL_FOG_COORD_ARRAY_BUFFER_BINDING */
-   {  9391, 0x00008456 }, /* GL_FOG_COORD_ARRAY_POINTER */
-   {  9418, 0x00008455 }, /* GL_FOG_COORD_ARRAY_STRIDE */
-   {  9444, 0x00008454 }, /* GL_FOG_COORD_ARRAY_TYPE */
-   {  9468, 0x00008450 }, /* GL_FOG_COORD_SRC */
-   {  9485, 0x00000B62 }, /* GL_FOG_DENSITY */
-   {  9500, 0x0000855A }, /* GL_FOG_DISTANCE_MODE_NV */
-   {  9524, 0x00000B64 }, /* GL_FOG_END */
-   {  9535, 0x00000C54 }, /* GL_FOG_HINT */
-   {  9547, 0x00000B61 }, /* GL_FOG_INDEX */
-   {  9560, 0x00000B65 }, /* GL_FOG_MODE */
-   {  9572, 0x00008198 }, /* GL_FOG_OFFSET_SGIX */
-   {  9591, 0x00008199 }, /* GL_FOG_OFFSET_VALUE_SGIX */
-   {  9616, 0x00000B63 }, /* GL_FOG_START */
-   {  9629, 0x00008452 }, /* GL_FRAGMENT_DEPTH */
-   {  9647, 0x00008804 }, /* GL_FRAGMENT_PROGRAM_ARB */
-   {  9671, 0x00008B30 }, /* GL_FRAGMENT_SHADER */
-   {  9690, 0x00008B30 }, /* GL_FRAGMENT_SHADER_ARB */
-   {  9713, 0x00008B8B }, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT */
-   {  9748, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT */
-   {  9790, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT */
-   {  9832, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT */
-   {  9881, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT */
-   {  9933, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */
-   {  9977, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT */
-   { 10021, 0x00008CA6 }, /* GL_FRAMEBUFFER_BINDING_EXT */
-   { 10048, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE_EXT */
-   { 10076, 0x00008D40 }, /* GL_FRAMEBUFFER_EXT */
-   { 10095, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT */
-   { 10136, 0x00008CD9 }, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */
-   { 10177, 0x00008CDB }, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT */
-   { 10219, 0x00008CD8 }, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */
-   { 10270, 0x00008CDA }, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */
-   { 10308, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT */
-   { 10357, 0x00008CDC }, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT */
-   { 10399, 0x00008CDE }, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */
-   { 10431, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED_EXT */
-   { 10462, 0x00000404 }, /* GL_FRONT */
-   { 10471, 0x00000408 }, /* GL_FRONT_AND_BACK */
-   { 10489, 0x00000B46 }, /* GL_FRONT_FACE */
-   { 10503, 0x00000400 }, /* GL_FRONT_LEFT */
-   { 10517, 0x00000401 }, /* GL_FRONT_RIGHT */
-   { 10532, 0x00008006 }, /* GL_FUNC_ADD */
-   { 10544, 0x00008006 }, /* GL_FUNC_ADD_EXT */
-   { 10560, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT */
-   { 10585, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT_EXT */
-   { 10614, 0x0000800A }, /* GL_FUNC_SUBTRACT */
-   { 10631, 0x0000800A }, /* GL_FUNC_SUBTRACT_EXT */
-   { 10652, 0x00008191 }, /* GL_GENERATE_MIPMAP */
-   { 10671, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT */
-   { 10695, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT_SGIS */
-   { 10724, 0x00008191 }, /* GL_GENERATE_MIPMAP_SGIS */
-   { 10748, 0x00000206 }, /* GL_GEQUAL */
-   { 10758, 0x00008009 }, /* GL_GL_BLEND_EQUATION_RGB */
-   { 10783, 0x00008C4A }, /* GL_GL_COMPRESSED_SLUMINANCE */
-   { 10811, 0x00008C4B }, /* GL_GL_COMPRESSED_SLUMINANCE_ALPHA */
-   { 10845, 0x00008C48 }, /* GL_GL_COMPRESSED_SRGB */
-   { 10867, 0x00008C49 }, /* GL_GL_COMPRESSED_SRGB_ALPHA */
-   { 10895, 0x0000845F }, /* GL_GL_CURRENT_RASTER_SECONDARY_COLOR */
-   { 10932, 0x00008B65 }, /* GL_GL_FLOAT_MAT2x3 */
-   { 10951, 0x00008B66 }, /* GL_GL_FLOAT_MAT2x4 */
-   { 10970, 0x00008B67 }, /* GL_GL_FLOAT_MAT3x2 */
-   { 10989, 0x00008B68 }, /* GL_GL_FLOAT_MAT3x4 */
-   { 11008, 0x00008B69 }, /* GL_GL_FLOAT_MAT4x2 */
-   { 11027, 0x00008B6A }, /* GL_GL_FLOAT_MAT4x3 */
-   { 11046, 0x000088EB }, /* GL_GL_PIXEL_PACK_BUFFER */
-   { 11070, 0x000088ED }, /* GL_GL_PIXEL_PACK_BUFFER_BINDING */
-   { 11102, 0x000088EC }, /* GL_GL_PIXEL_UNPACK_BUFFER */
-   { 11128, 0x000088EF }, /* GL_GL_PIXEL_UNPACK_BUFFER_BINDING */
-   { 11162, 0x00008C46 }, /* GL_GL_SLUMINANCE */
-   { 11179, 0x00008C47 }, /* GL_GL_SLUMINANCE8 */
-   { 11197, 0x00008C45 }, /* GL_GL_SLUMINANCE8_ALPHA8 */
-   { 11222, 0x00008C44 }, /* GL_GL_SLUMINANCE_ALPHA */
-   { 11245, 0x00008C40 }, /* GL_GL_SRGB */
-   { 11256, 0x00008C41 }, /* GL_GL_SRGB8 */
-   { 11268, 0x00008C43 }, /* GL_GL_SRGB8_ALPHA8 */
-   { 11287, 0x00008C42 }, /* GL_GL_SRGB_ALPHA */
-   { 11304, 0x00000204 }, /* GL_GREATER */
-   { 11315, 0x00001904 }, /* GL_GREEN */
-   { 11324, 0x00000D19 }, /* GL_GREEN_BIAS */
-   { 11338, 0x00000D53 }, /* GL_GREEN_BITS */
-   { 11352, 0x00000D18 }, /* GL_GREEN_SCALE */
-   { 11367, 0x00008000 }, /* GL_HINT_BIT */
-   { 11379, 0x00008024 }, /* GL_HISTOGRAM */
-   { 11392, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE */
-   { 11416, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE_EXT */
-   { 11444, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE */
-   { 11467, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE_EXT */
-   { 11494, 0x00008024 }, /* GL_HISTOGRAM_EXT */
-   { 11511, 0x00008027 }, /* GL_HISTOGRAM_FORMAT */
-   { 11531, 0x00008027 }, /* GL_HISTOGRAM_FORMAT_EXT */
-   { 11555, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE */
-   { 11579, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE_EXT */
-   { 11607, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE */
-   { 11635, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE_EXT */
-   { 11667, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE */
-   { 11689, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE_EXT */
-   { 11715, 0x0000802D }, /* GL_HISTOGRAM_SINK */
-   { 11733, 0x0000802D }, /* GL_HISTOGRAM_SINK_EXT */
-   { 11755, 0x00008026 }, /* GL_HISTOGRAM_WIDTH */
-   { 11774, 0x00008026 }, /* GL_HISTOGRAM_WIDTH_EXT */
-   { 11797, 0x0000862A }, /* GL_IDENTITY_NV */
-   { 11812, 0x00008150 }, /* GL_IGNORE_BORDER_HP */
-   { 11832, 0x00008B9B }, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */
-   { 11872, 0x00008B9A }, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */
-   { 11910, 0x00001E02 }, /* GL_INCR */
-   { 11918, 0x00008507 }, /* GL_INCR_WRAP */
-   { 11931, 0x00008507 }, /* GL_INCR_WRAP_EXT */
-   { 11948, 0x00008077 }, /* GL_INDEX_ARRAY */
-   { 11963, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING */
-   { 11993, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING_ARB */
-   { 12027, 0x00008091 }, /* GL_INDEX_ARRAY_POINTER */
-   { 12050, 0x00008086 }, /* GL_INDEX_ARRAY_STRIDE */
-   { 12072, 0x00008085 }, /* GL_INDEX_ARRAY_TYPE */
-   { 12092, 0x00000D51 }, /* GL_INDEX_BITS */
-   { 12106, 0x00000C20 }, /* GL_INDEX_CLEAR_VALUE */
-   { 12127, 0x00000BF1 }, /* GL_INDEX_LOGIC_OP */
-   { 12145, 0x00000C30 }, /* GL_INDEX_MODE */
-   { 12159, 0x00000D13 }, /* GL_INDEX_OFFSET */
-   { 12175, 0x00000D12 }, /* GL_INDEX_SHIFT */
-   { 12190, 0x00000C21 }, /* GL_INDEX_WRITEMASK */
-   { 12209, 0x00008B84 }, /* GL_INFO_LOG_LENGTH */
-   { 12228, 0x00001404 }, /* GL_INT */
-   { 12235, 0x00008049 }, /* GL_INTENSITY */
-   { 12248, 0x0000804C }, /* GL_INTENSITY12 */
-   { 12263, 0x0000804C }, /* GL_INTENSITY12_EXT */
-   { 12282, 0x0000804D }, /* GL_INTENSITY16 */
-   { 12297, 0x0000804D }, /* GL_INTENSITY16_EXT */
-   { 12316, 0x0000804A }, /* GL_INTENSITY4 */
-   { 12330, 0x0000804A }, /* GL_INTENSITY4_EXT */
-   { 12348, 0x0000804B }, /* GL_INTENSITY8 */
-   { 12362, 0x0000804B }, /* GL_INTENSITY8_EXT */
-   { 12380, 0x00008049 }, /* GL_INTENSITY_EXT */
-   { 12397, 0x00008575 }, /* GL_INTERPOLATE */
-   { 12412, 0x00008575 }, /* GL_INTERPOLATE_ARB */
-   { 12431, 0x00008575 }, /* GL_INTERPOLATE_EXT */
-   { 12450, 0x00008B53 }, /* GL_INT_VEC2 */
-   { 12462, 0x00008B53 }, /* GL_INT_VEC2_ARB */
-   { 12478, 0x00008B54 }, /* GL_INT_VEC3 */
-   { 12490, 0x00008B54 }, /* GL_INT_VEC3_ARB */
-   { 12506, 0x00008B55 }, /* GL_INT_VEC4 */
-   { 12518, 0x00008B55 }, /* GL_INT_VEC4_ARB */
-   { 12534, 0x00000500 }, /* GL_INVALID_ENUM */
-   { 12550, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION_EXT */
-   { 12587, 0x00000502 }, /* GL_INVALID_OPERATION */
-   { 12608, 0x00000501 }, /* GL_INVALID_VALUE */
-   { 12625, 0x0000862B }, /* GL_INVERSE_NV */
-   { 12639, 0x0000862D }, /* GL_INVERSE_TRANSPOSE_NV */
-   { 12663, 0x0000150A }, /* GL_INVERT */
-   { 12673, 0x00001E00 }, /* GL_KEEP */
-   { 12681, 0x00000406 }, /* GL_LEFT */
-   { 12689, 0x00000203 }, /* GL_LEQUAL */
-   { 12699, 0x00000201 }, /* GL_LESS */
-   { 12707, 0x00004000 }, /* GL_LIGHT0 */
-   { 12717, 0x00004001 }, /* GL_LIGHT1 */
-   { 12727, 0x00004002 }, /* GL_LIGHT2 */
-   { 12737, 0x00004003 }, /* GL_LIGHT3 */
-   { 12747, 0x00004004 }, /* GL_LIGHT4 */
-   { 12757, 0x00004005 }, /* GL_LIGHT5 */
-   { 12767, 0x00004006 }, /* GL_LIGHT6 */
-   { 12777, 0x00004007 }, /* GL_LIGHT7 */
-   { 12787, 0x00000B50 }, /* GL_LIGHTING */
-   { 12799, 0x00000040 }, /* GL_LIGHTING_BIT */
-   { 12815, 0x00000B53 }, /* GL_LIGHT_MODEL_AMBIENT */
-   { 12838, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL */
-   { 12867, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL_EXT */
-   { 12900, 0x00000B51 }, /* GL_LIGHT_MODEL_LOCAL_VIEWER */
-   { 12928, 0x00000B52 }, /* GL_LIGHT_MODEL_TWO_SIDE */
-   { 12952, 0x00001B01 }, /* GL_LINE */
-   { 12960, 0x00002601 }, /* GL_LINEAR */
-   { 12970, 0x00001208 }, /* GL_LINEAR_ATTENUATION */
-   { 12992, 0x00008170 }, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */
-   { 13022, 0x0000844F }, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */
-   { 13053, 0x00002703 }, /* GL_LINEAR_MIPMAP_LINEAR */
-   { 13077, 0x00002701 }, /* GL_LINEAR_MIPMAP_NEAREST */
-   { 13102, 0x00000001 }, /* GL_LINES */
-   { 13111, 0x00000004 }, /* GL_LINE_BIT */
-   { 13123, 0x00000002 }, /* GL_LINE_LOOP */
-   { 13136, 0x00000707 }, /* GL_LINE_RESET_TOKEN */
-   { 13156, 0x00000B20 }, /* GL_LINE_SMOOTH */
-   { 13171, 0x00000C52 }, /* GL_LINE_SMOOTH_HINT */
-   { 13191, 0x00000B24 }, /* GL_LINE_STIPPLE */
-   { 13207, 0x00000B25 }, /* GL_LINE_STIPPLE_PATTERN */
-   { 13231, 0x00000B26 }, /* GL_LINE_STIPPLE_REPEAT */
-   { 13254, 0x00000003 }, /* GL_LINE_STRIP */
-   { 13268, 0x00000702 }, /* GL_LINE_TOKEN */
-   { 13282, 0x00000B21 }, /* GL_LINE_WIDTH */
-   { 13296, 0x00000B23 }, /* GL_LINE_WIDTH_GRANULARITY */
-   { 13322, 0x00000B22 }, /* GL_LINE_WIDTH_RANGE */
-   { 13342, 0x00008B82 }, /* GL_LINK_STATUS */
-   { 13357, 0x00000B32 }, /* GL_LIST_BASE */
-   { 13370, 0x00020000 }, /* GL_LIST_BIT */
-   { 13382, 0x00000B33 }, /* GL_LIST_INDEX */
-   { 13396, 0x00000B30 }, /* GL_LIST_MODE */
-   { 13409, 0x00000101 }, /* GL_LOAD */
-   { 13417, 0x00000BF1 }, /* GL_LOGIC_OP */
-   { 13429, 0x00000BF0 }, /* GL_LOGIC_OP_MODE */
-   { 13446, 0x00008CA1 }, /* GL_LOWER_LEFT */
-   { 13460, 0x00001909 }, /* GL_LUMINANCE */
-   { 13473, 0x00008041 }, /* GL_LUMINANCE12 */
-   { 13488, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12 */
-   { 13511, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12_EXT */
-   { 13538, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4 */
-   { 13560, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4_EXT */
-   { 13586, 0x00008041 }, /* GL_LUMINANCE12_EXT */
-   { 13605, 0x00008042 }, /* GL_LUMINANCE16 */
-   { 13620, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16 */
-   { 13643, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16_EXT */
-   { 13670, 0x00008042 }, /* GL_LUMINANCE16_EXT */
-   { 13689, 0x0000803F }, /* GL_LUMINANCE4 */
-   { 13703, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4 */
-   { 13724, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4_EXT */
-   { 13749, 0x0000803F }, /* GL_LUMINANCE4_EXT */
-   { 13767, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2 */
-   { 13788, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2_EXT */
-   { 13813, 0x00008040 }, /* GL_LUMINANCE8 */
-   { 13827, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8 */
-   { 13848, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8_EXT */
-   { 13873, 0x00008040 }, /* GL_LUMINANCE8_EXT */
-   { 13891, 0x0000190A }, /* GL_LUMINANCE_ALPHA */
-   { 13910, 0x00000D90 }, /* GL_MAP1_COLOR_4 */
-   { 13926, 0x00000DD0 }, /* GL_MAP1_GRID_DOMAIN */
-   { 13946, 0x00000DD1 }, /* GL_MAP1_GRID_SEGMENTS */
-   { 13968, 0x00000D91 }, /* GL_MAP1_INDEX */
-   { 13982, 0x00000D92 }, /* GL_MAP1_NORMAL */
-   { 13997, 0x00000D93 }, /* GL_MAP1_TEXTURE_COORD_1 */
-   { 14021, 0x00000D94 }, /* GL_MAP1_TEXTURE_COORD_2 */
-   { 14045, 0x00000D95 }, /* GL_MAP1_TEXTURE_COORD_3 */
-   { 14069, 0x00000D96 }, /* GL_MAP1_TEXTURE_COORD_4 */
-   { 14093, 0x00000D97 }, /* GL_MAP1_VERTEX_3 */
-   { 14110, 0x00000D98 }, /* GL_MAP1_VERTEX_4 */
-   { 14127, 0x00008660 }, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */
-   { 14155, 0x0000866A }, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */
-   { 14184, 0x0000866B }, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */
-   { 14213, 0x0000866C }, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */
-   { 14242, 0x0000866D }, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */
-   { 14271, 0x0000866E }, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */
-   { 14300, 0x0000866F }, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */
-   { 14329, 0x00008661 }, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */
-   { 14357, 0x00008662 }, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */
-   { 14385, 0x00008663 }, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */
-   { 14413, 0x00008664 }, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */
-   { 14441, 0x00008665 }, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */
-   { 14469, 0x00008666 }, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */
-   { 14497, 0x00008667 }, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */
-   { 14525, 0x00008668 }, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */
-   { 14553, 0x00008669 }, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */
-   { 14581, 0x00000DB0 }, /* GL_MAP2_COLOR_4 */
-   { 14597, 0x00000DD2 }, /* GL_MAP2_GRID_DOMAIN */
-   { 14617, 0x00000DD3 }, /* GL_MAP2_GRID_SEGMENTS */
-   { 14639, 0x00000DB1 }, /* GL_MAP2_INDEX */
-   { 14653, 0x00000DB2 }, /* GL_MAP2_NORMAL */
-   { 14668, 0x00000DB3 }, /* GL_MAP2_TEXTURE_COORD_1 */
-   { 14692, 0x00000DB4 }, /* GL_MAP2_TEXTURE_COORD_2 */
-   { 14716, 0x00000DB5 }, /* GL_MAP2_TEXTURE_COORD_3 */
-   { 14740, 0x00000DB6 }, /* GL_MAP2_TEXTURE_COORD_4 */
-   { 14764, 0x00000DB7 }, /* GL_MAP2_VERTEX_3 */
-   { 14781, 0x00000DB8 }, /* GL_MAP2_VERTEX_4 */
-   { 14798, 0x00008670 }, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */
-   { 14826, 0x0000867A }, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */
-   { 14855, 0x0000867B }, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */
-   { 14884, 0x0000867C }, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */
-   { 14913, 0x0000867D }, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */
-   { 14942, 0x0000867E }, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */
-   { 14971, 0x0000867F }, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */
-   { 15000, 0x00008671 }, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */
-   { 15028, 0x00008672 }, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */
-   { 15056, 0x00008673 }, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */
-   { 15084, 0x00008674 }, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */
-   { 15112, 0x00008675 }, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */
-   { 15140, 0x00008676 }, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */
-   { 15168, 0x00008677 }, /* GL_MAP2_VERTEX_ATTRIB7_4_NV */
-   { 15196, 0x00008678 }, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */
-   { 15224, 0x00008679 }, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */
-   { 15252, 0x00000D10 }, /* GL_MAP_COLOR */
-   { 15265, 0x00000D11 }, /* GL_MAP_STENCIL */
-   { 15280, 0x000088C0 }, /* GL_MATRIX0_ARB */
-   { 15295, 0x00008630 }, /* GL_MATRIX0_NV */
-   { 15309, 0x000088CA }, /* GL_MATRIX10_ARB */
-   { 15325, 0x000088CB }, /* GL_MATRIX11_ARB */
-   { 15341, 0x000088CC }, /* GL_MATRIX12_ARB */
-   { 15357, 0x000088CD }, /* GL_MATRIX13_ARB */
-   { 15373, 0x000088CE }, /* GL_MATRIX14_ARB */
-   { 15389, 0x000088CF }, /* GL_MATRIX15_ARB */
-   { 15405, 0x000088D0 }, /* GL_MATRIX16_ARB */
-   { 15421, 0x000088D1 }, /* GL_MATRIX17_ARB */
-   { 15437, 0x000088D2 }, /* GL_MATRIX18_ARB */
-   { 15453, 0x000088D3 }, /* GL_MATRIX19_ARB */
-   { 15469, 0x000088C1 }, /* GL_MATRIX1_ARB */
-   { 15484, 0x00008631 }, /* GL_MATRIX1_NV */
-   { 15498, 0x000088D4 }, /* GL_MATRIX20_ARB */
-   { 15514, 0x000088D5 }, /* GL_MATRIX21_ARB */
-   { 15530, 0x000088D6 }, /* GL_MATRIX22_ARB */
-   { 15546, 0x000088D7 }, /* GL_MATRIX23_ARB */
-   { 15562, 0x000088D8 }, /* GL_MATRIX24_ARB */
-   { 15578, 0x000088D9 }, /* GL_MATRIX25_ARB */
-   { 15594, 0x000088DA }, /* GL_MATRIX26_ARB */
-   { 15610, 0x000088DB }, /* GL_MATRIX27_ARB */
-   { 15626, 0x000088DC }, /* GL_MATRIX28_ARB */
-   { 15642, 0x000088DD }, /* GL_MATRIX29_ARB */
-   { 15658, 0x000088C2 }, /* GL_MATRIX2_ARB */
-   { 15673, 0x00008632 }, /* GL_MATRIX2_NV */
-   { 15687, 0x000088DE }, /* GL_MATRIX30_ARB */
-   { 15703, 0x000088DF }, /* GL_MATRIX31_ARB */
-   { 15719, 0x000088C3 }, /* GL_MATRIX3_ARB */
-   { 15734, 0x00008633 }, /* GL_MATRIX3_NV */
-   { 15748, 0x000088C4 }, /* GL_MATRIX4_ARB */
-   { 15763, 0x00008634 }, /* GL_MATRIX4_NV */
-   { 15777, 0x000088C5 }, /* GL_MATRIX5_ARB */
-   { 15792, 0x00008635 }, /* GL_MATRIX5_NV */
-   { 15806, 0x000088C6 }, /* GL_MATRIX6_ARB */
-   { 15821, 0x00008636 }, /* GL_MATRIX6_NV */
-   { 15835, 0x000088C7 }, /* GL_MATRIX7_ARB */
-   { 15850, 0x00008637 }, /* GL_MATRIX7_NV */
-   { 15864, 0x000088C8 }, /* GL_MATRIX8_ARB */
-   { 15879, 0x000088C9 }, /* GL_MATRIX9_ARB */
-   { 15894, 0x00008844 }, /* GL_MATRIX_INDEX_ARRAY_ARB */
-   { 15920, 0x00008849 }, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */
-   { 15954, 0x00008846 }, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */
-   { 15985, 0x00008848 }, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */
-   { 16018, 0x00008847 }, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */
-   { 16049, 0x00000BA0 }, /* GL_MATRIX_MODE */
-   { 16064, 0x00008840 }, /* GL_MATRIX_PALETTE_ARB */
-   { 16086, 0x00008008 }, /* GL_MAX */
-   { 16093, 0x00008073 }, /* GL_MAX_3D_TEXTURE_SIZE */
-   { 16116, 0x000088FF }, /* GL_MAX_ARRAY_TEXTURE_LAYERS_EXT */
-   { 16148, 0x00000D35 }, /* GL_MAX_ATTRIB_STACK_DEPTH */
-   { 16174, 0x00000D3B }, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */
-   { 16207, 0x00008177 }, /* GL_MAX_CLIPMAP_DEPTH_SGIX */
-   { 16233, 0x00008178 }, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */
-   { 16267, 0x00000D32 }, /* GL_MAX_CLIP_PLANES */
-   { 16286, 0x00008CDF }, /* GL_MAX_COLOR_ATTACHMENTS_EXT */
-   { 16315, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */
-   { 16347, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI */
-   { 16383, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */
-   { 16419, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB */
-   { 16459, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT */
-   { 16485, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT_EXT */
-   { 16515, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH */
-   { 16540, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH_EXT */
-   { 16569, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */
-   { 16598, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB */
-   { 16631, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS */
-   { 16651, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ARB */
-   { 16675, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ATI */
-   { 16699, 0x000080E9 }, /* GL_MAX_ELEMENTS_INDICES */
-   { 16723, 0x000080E8 }, /* GL_MAX_ELEMENTS_VERTICES */
-   { 16748, 0x00000D30 }, /* GL_MAX_EVAL_ORDER */
-   { 16766, 0x00008008 }, /* GL_MAX_EXT */
-   { 16777, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */
-   { 16812, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB */
-   { 16851, 0x00000D31 }, /* GL_MAX_LIGHTS */
-   { 16865, 0x00000B31 }, /* GL_MAX_LIST_NESTING */
-   { 16885, 0x00008841 }, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */
-   { 16923, 0x00000D36 }, /* GL_MAX_MODELVIEW_STACK_DEPTH */
-   { 16952, 0x00000D37 }, /* GL_MAX_NAME_STACK_DEPTH */
-   { 16976, 0x00008842 }, /* GL_MAX_PALETTE_MATRICES_ARB */
-   { 17004, 0x00000D34 }, /* GL_MAX_PIXEL_MAP_TABLE */
-   { 17027, 0x000088B1 }, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */
-   { 17064, 0x0000880B }, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */
-   { 17100, 0x000088AD }, /* GL_MAX_PROGRAM_ATTRIBS_ARB */
-   { 17127, 0x000088F5 }, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */
-   { 17156, 0x000088B5 }, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */
-   { 17190, 0x000088F4 }, /* GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */
-   { 17226, 0x000088F6 }, /* GL_MAX_PROGRAM_IF_DEPTH_NV */
-   { 17253, 0x000088A1 }, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */
-   { 17285, 0x000088B4 }, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */
-   { 17321, 0x000088F8 }, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */
-   { 17350, 0x000088F7 }, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */
-   { 17379, 0x0000862F }, /* GL_MAX_PROGRAM_MATRICES_ARB */
-   { 17407, 0x0000862E }, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */
-   { 17445, 0x000088B3 }, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
-   { 17489, 0x0000880E }, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
-   { 17532, 0x000088AF }, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */
-   { 17566, 0x000088A3 }, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
-   { 17605, 0x000088AB }, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */
-   { 17642, 0x000088A7 }, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */
-   { 17680, 0x00008810 }, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
-   { 17723, 0x0000880F }, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
-   { 17766, 0x000088A9 }, /* GL_MAX_PROGRAM_PARAMETERS_ARB */
-   { 17796, 0x000088A5 }, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */
-   { 17827, 0x0000880D }, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */
-   { 17863, 0x0000880C }, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */
-   { 17899, 0x00000D38 }, /* GL_MAX_PROJECTION_STACK_DEPTH */
-   { 17929, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */
-   { 17963, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_NV */
-   { 17996, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE_EXT */
-   { 18025, 0x00008504 }, /* GL_MAX_SHININESS_NV */
-   { 18045, 0x00008505 }, /* GL_MAX_SPOT_EXPONENT_NV */
-   { 18069, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS */
-   { 18091, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS_ARB */
-   { 18117, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS */
-   { 18144, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS_ARB */
-   { 18175, 0x000084FD }, /* GL_MAX_TEXTURE_LOD_BIAS */
-   { 18199, 0x000084FF }, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */
-   { 18233, 0x00000D33 }, /* GL_MAX_TEXTURE_SIZE */
-   { 18253, 0x00000D39 }, /* GL_MAX_TEXTURE_STACK_DEPTH */
-   { 18280, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS */
-   { 18301, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS_ARB */
-   { 18326, 0x0000862F }, /* GL_MAX_TRACK_MATRICES_NV */
-   { 18351, 0x0000862E }, /* GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */
-   { 18386, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS */
-   { 18408, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS_ARB */
-   { 18434, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS */
-   { 18456, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS_ARB */
-   { 18482, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */
-   { 18516, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */
-   { 18554, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */
-   { 18587, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB */
-   { 18624, 0x000086A4 }, /* GL_MAX_VERTEX_UNITS_ARB */
-   { 18648, 0x00000D3A }, /* GL_MAX_VIEWPORT_DIMS */
-   { 18669, 0x00008007 }, /* GL_MIN */
-   { 18676, 0x0000802E }, /* GL_MINMAX */
-   { 18686, 0x0000802E }, /* GL_MINMAX_EXT */
-   { 18700, 0x0000802F }, /* GL_MINMAX_FORMAT */
-   { 18717, 0x0000802F }, /* GL_MINMAX_FORMAT_EXT */
-   { 18738, 0x00008030 }, /* GL_MINMAX_SINK */
-   { 18753, 0x00008030 }, /* GL_MINMAX_SINK_EXT */
-   { 18772, 0x00008007 }, /* GL_MIN_EXT */
-   { 18783, 0x00008370 }, /* GL_MIRRORED_REPEAT */
-   { 18802, 0x00008370 }, /* GL_MIRRORED_REPEAT_ARB */
-   { 18825, 0x00008370 }, /* GL_MIRRORED_REPEAT_IBM */
-   { 18848, 0x00008742 }, /* GL_MIRROR_CLAMP_ATI */
-   { 18868, 0x00008742 }, /* GL_MIRROR_CLAMP_EXT */
-   { 18888, 0x00008912 }, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */
-   { 18918, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_ATI */
-   { 18946, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */
-   { 18974, 0x00001700 }, /* GL_MODELVIEW */
-   { 18987, 0x00001700 }, /* GL_MODELVIEW0_ARB */
-   { 19005, 0x0000872A }, /* GL_MODELVIEW10_ARB */
-   { 19024, 0x0000872B }, /* GL_MODELVIEW11_ARB */
-   { 19043, 0x0000872C }, /* GL_MODELVIEW12_ARB */
-   { 19062, 0x0000872D }, /* GL_MODELVIEW13_ARB */
-   { 19081, 0x0000872E }, /* GL_MODELVIEW14_ARB */
-   { 19100, 0x0000872F }, /* GL_MODELVIEW15_ARB */
-   { 19119, 0x00008730 }, /* GL_MODELVIEW16_ARB */
-   { 19138, 0x00008731 }, /* GL_MODELVIEW17_ARB */
-   { 19157, 0x00008732 }, /* GL_MODELVIEW18_ARB */
-   { 19176, 0x00008733 }, /* GL_MODELVIEW19_ARB */
-   { 19195, 0x0000850A }, /* GL_MODELVIEW1_ARB */
-   { 19213, 0x00008734 }, /* GL_MODELVIEW20_ARB */
-   { 19232, 0x00008735 }, /* GL_MODELVIEW21_ARB */
-   { 19251, 0x00008736 }, /* GL_MODELVIEW22_ARB */
-   { 19270, 0x00008737 }, /* GL_MODELVIEW23_ARB */
-   { 19289, 0x00008738 }, /* GL_MODELVIEW24_ARB */
-   { 19308, 0x00008739 }, /* GL_MODELVIEW25_ARB */
-   { 19327, 0x0000873A }, /* GL_MODELVIEW26_ARB */
-   { 19346, 0x0000873B }, /* GL_MODELVIEW27_ARB */
-   { 19365, 0x0000873C }, /* GL_MODELVIEW28_ARB */
-   { 19384, 0x0000873D }, /* GL_MODELVIEW29_ARB */
-   { 19403, 0x00008722 }, /* GL_MODELVIEW2_ARB */
-   { 19421, 0x0000873E }, /* GL_MODELVIEW30_ARB */
-   { 19440, 0x0000873F }, /* GL_MODELVIEW31_ARB */
-   { 19459, 0x00008723 }, /* GL_MODELVIEW3_ARB */
-   { 19477, 0x00008724 }, /* GL_MODELVIEW4_ARB */
-   { 19495, 0x00008725 }, /* GL_MODELVIEW5_ARB */
-   { 19513, 0x00008726 }, /* GL_MODELVIEW6_ARB */
-   { 19531, 0x00008727 }, /* GL_MODELVIEW7_ARB */
-   { 19549, 0x00008728 }, /* GL_MODELVIEW8_ARB */
-   { 19567, 0x00008729 }, /* GL_MODELVIEW9_ARB */
-   { 19585, 0x00000BA6 }, /* GL_MODELVIEW_MATRIX */
-   { 19605, 0x00008629 }, /* GL_MODELVIEW_PROJECTION_NV */
-   { 19632, 0x00000BA3 }, /* GL_MODELVIEW_STACK_DEPTH */
-   { 19657, 0x00002100 }, /* GL_MODULATE */
-   { 19669, 0x00008744 }, /* GL_MODULATE_ADD_ATI */
-   { 19689, 0x00008745 }, /* GL_MODULATE_SIGNED_ADD_ATI */
-   { 19716, 0x00008746 }, /* GL_MODULATE_SUBTRACT_ATI */
-   { 19741, 0x00000103 }, /* GL_MULT */
-   { 19749, 0x0000809D }, /* GL_MULTISAMPLE */
-   { 19764, 0x000086B2 }, /* GL_MULTISAMPLE_3DFX */
-   { 19784, 0x0000809D }, /* GL_MULTISAMPLE_ARB */
-   { 19803, 0x20000000 }, /* GL_MULTISAMPLE_BIT */
-   { 19822, 0x20000000 }, /* GL_MULTISAMPLE_BIT_3DFX */
-   { 19846, 0x20000000 }, /* GL_MULTISAMPLE_BIT_ARB */
-   { 19869, 0x00008534 }, /* GL_MULTISAMPLE_FILTER_HINT_NV */
-   { 19899, 0x00002A25 }, /* GL_N3F_V3F */
-   { 19910, 0x00000D70 }, /* GL_NAME_STACK_DEPTH */
-   { 19930, 0x0000150E }, /* GL_NAND */
-   { 19938, 0x00002600 }, /* GL_NEAREST */
-   { 19949, 0x0000844E }, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */
-   { 19980, 0x0000844D }, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */
-   { 20012, 0x00002702 }, /* GL_NEAREST_MIPMAP_LINEAR */
-   { 20037, 0x00002700 }, /* GL_NEAREST_MIPMAP_NEAREST */
-   { 20063, 0x00000200 }, /* GL_NEVER */
-   { 20072, 0x00001102 }, /* GL_NICEST */
-   { 20082, 0x00000000 }, /* GL_NONE */
-   { 20090, 0x00001505 }, /* GL_NOOP */
-   { 20098, 0x00001508 }, /* GL_NOR */
-   { 20105, 0x00000BA1 }, /* GL_NORMALIZE */
-   { 20118, 0x00008075 }, /* GL_NORMAL_ARRAY */
-   { 20134, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING */
-   { 20165, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING_ARB */
-   { 20200, 0x0000808F }, /* GL_NORMAL_ARRAY_POINTER */
-   { 20224, 0x0000807F }, /* GL_NORMAL_ARRAY_STRIDE */
-   { 20247, 0x0000807E }, /* GL_NORMAL_ARRAY_TYPE */
-   { 20268, 0x00008511 }, /* GL_NORMAL_MAP */
-   { 20282, 0x00008511 }, /* GL_NORMAL_MAP_ARB */
-   { 20300, 0x00008511 }, /* GL_NORMAL_MAP_NV */
-   { 20317, 0x00000205 }, /* GL_NOTEQUAL */
-   { 20329, 0x00000000 }, /* GL_NO_ERROR */
-   { 20341, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */
-   { 20375, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB */
-   { 20413, 0x00008B89 }, /* GL_OBJECT_ACTIVE_ATTRIBUTES_ARB */
-   { 20445, 0x00008B8A }, /* GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB */
-   { 20487, 0x00008B86 }, /* GL_OBJECT_ACTIVE_UNIFORMS_ARB */
-   { 20517, 0x00008B87 }, /* GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB */
-   { 20557, 0x00008B85 }, /* GL_OBJECT_ATTACHED_OBJECTS_ARB */
-   { 20588, 0x00008B81 }, /* GL_OBJECT_COMPILE_STATUS_ARB */
-   { 20617, 0x00008B80 }, /* GL_OBJECT_DELETE_STATUS_ARB */
-   { 20645, 0x00008B84 }, /* GL_OBJECT_INFO_LOG_LENGTH_ARB */
-   { 20675, 0x00002401 }, /* GL_OBJECT_LINEAR */
-   { 20692, 0x00008B82 }, /* GL_OBJECT_LINK_STATUS_ARB */
-   { 20718, 0x00002501 }, /* GL_OBJECT_PLANE */
-   { 20734, 0x00008B88 }, /* GL_OBJECT_SHADER_SOURCE_LENGTH_ARB */
-   { 20769, 0x00008B4F }, /* GL_OBJECT_SUBTYPE_ARB */
-   { 20791, 0x00008B4E }, /* GL_OBJECT_TYPE_ARB */
-   { 20810, 0x00008B83 }, /* GL_OBJECT_VALIDATE_STATUS_ARB */
-   { 20840, 0x00008165 }, /* GL_OCCLUSION_TEST_HP */
-   { 20861, 0x00008166 }, /* GL_OCCLUSION_TEST_RESULT_HP */
-   { 20889, 0x00000001 }, /* GL_ONE */
-   { 20896, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA */
-   { 20924, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA_EXT */
-   { 20956, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR */
-   { 20984, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR_EXT */
-   { 21016, 0x00000305 }, /* GL_ONE_MINUS_DST_ALPHA */
-   { 21039, 0x00000307 }, /* GL_ONE_MINUS_DST_COLOR */
-   { 21062, 0x00000303 }, /* GL_ONE_MINUS_SRC_ALPHA */
-   { 21085, 0x00000301 }, /* GL_ONE_MINUS_SRC_COLOR */
-   { 21108, 0x00008598 }, /* GL_OPERAND0_ALPHA */
-   { 21126, 0x00008598 }, /* GL_OPERAND0_ALPHA_ARB */
-   { 21148, 0x00008598 }, /* GL_OPERAND0_ALPHA_EXT */
-   { 21170, 0x00008590 }, /* GL_OPERAND0_RGB */
-   { 21186, 0x00008590 }, /* GL_OPERAND0_RGB_ARB */
-   { 21206, 0x00008590 }, /* GL_OPERAND0_RGB_EXT */
-   { 21226, 0x00008599 }, /* GL_OPERAND1_ALPHA */
-   { 21244, 0x00008599 }, /* GL_OPERAND1_ALPHA_ARB */
-   { 21266, 0x00008599 }, /* GL_OPERAND1_ALPHA_EXT */
-   { 21288, 0x00008591 }, /* GL_OPERAND1_RGB */
-   { 21304, 0x00008591 }, /* GL_OPERAND1_RGB_ARB */
-   { 21324, 0x00008591 }, /* GL_OPERAND1_RGB_EXT */
-   { 21344, 0x0000859A }, /* GL_OPERAND2_ALPHA */
-   { 21362, 0x0000859A }, /* GL_OPERAND2_ALPHA_ARB */
-   { 21384, 0x0000859A }, /* GL_OPERAND2_ALPHA_EXT */
-   { 21406, 0x00008592 }, /* GL_OPERAND2_RGB */
-   { 21422, 0x00008592 }, /* GL_OPERAND2_RGB_ARB */
-   { 21442, 0x00008592 }, /* GL_OPERAND2_RGB_EXT */
-   { 21462, 0x0000859B }, /* GL_OPERAND3_ALPHA_NV */
-   { 21483, 0x00008593 }, /* GL_OPERAND3_RGB_NV */
-   { 21502, 0x00001507 }, /* GL_OR */
-   { 21508, 0x00000A01 }, /* GL_ORDER */
-   { 21517, 0x0000150D }, /* GL_OR_INVERTED */
-   { 21532, 0x0000150B }, /* GL_OR_REVERSE */
-   { 21546, 0x00000505 }, /* GL_OUT_OF_MEMORY */
-   { 21563, 0x00000D05 }, /* GL_PACK_ALIGNMENT */
-   { 21581, 0x0000806C }, /* GL_PACK_IMAGE_HEIGHT */
-   { 21602, 0x00008758 }, /* GL_PACK_INVERT_MESA */
-   { 21622, 0x00000D01 }, /* GL_PACK_LSB_FIRST */
-   { 21640, 0x00000D02 }, /* GL_PACK_ROW_LENGTH */
-   { 21659, 0x0000806B }, /* GL_PACK_SKIP_IMAGES */
-   { 21679, 0x00000D04 }, /* GL_PACK_SKIP_PIXELS */
-   { 21699, 0x00000D03 }, /* GL_PACK_SKIP_ROWS */
-   { 21717, 0x00000D00 }, /* GL_PACK_SWAP_BYTES */
-   { 21736, 0x00008B92 }, /* GL_PALETTE4_R5_G6_B5_OES */
-   { 21761, 0x00008B94 }, /* GL_PALETTE4_RGB5_A1_OES */
-   { 21785, 0x00008B90 }, /* GL_PALETTE4_RGB8_OES */
-   { 21806, 0x00008B93 }, /* GL_PALETTE4_RGBA4_OES */
-   { 21828, 0x00008B91 }, /* GL_PALETTE4_RGBA8_OES */
-   { 21850, 0x00008B97 }, /* GL_PALETTE8_R5_G6_B5_OES */
-   { 21875, 0x00008B99 }, /* GL_PALETTE8_RGB5_A1_OES */
-   { 21899, 0x00008B95 }, /* GL_PALETTE8_RGB8_OES */
-   { 21920, 0x00008B98 }, /* GL_PALETTE8_RGBA4_OES */
-   { 21942, 0x00008B96 }, /* GL_PALETTE8_RGBA8_OES */
-   { 21964, 0x00000700 }, /* GL_PASS_THROUGH_TOKEN */
-   { 21986, 0x00000C50 }, /* GL_PERSPECTIVE_CORRECTION_HINT */
-   { 22017, 0x00000C79 }, /* GL_PIXEL_MAP_A_TO_A */
-   { 22037, 0x00000CB9 }, /* GL_PIXEL_MAP_A_TO_A_SIZE */
-   { 22062, 0x00000C78 }, /* GL_PIXEL_MAP_B_TO_B */
-   { 22082, 0x00000CB8 }, /* GL_PIXEL_MAP_B_TO_B_SIZE */
-   { 22107, 0x00000C77 }, /* GL_PIXEL_MAP_G_TO_G */
-   { 22127, 0x00000CB7 }, /* GL_PIXEL_MAP_G_TO_G_SIZE */
-   { 22152, 0x00000C75 }, /* GL_PIXEL_MAP_I_TO_A */
-   { 22172, 0x00000CB5 }, /* GL_PIXEL_MAP_I_TO_A_SIZE */
-   { 22197, 0x00000C74 }, /* GL_PIXEL_MAP_I_TO_B */
-   { 22217, 0x00000CB4 }, /* GL_PIXEL_MAP_I_TO_B_SIZE */
-   { 22242, 0x00000C73 }, /* GL_PIXEL_MAP_I_TO_G */
-   { 22262, 0x00000CB3 }, /* GL_PIXEL_MAP_I_TO_G_SIZE */
-   { 22287, 0x00000C70 }, /* GL_PIXEL_MAP_I_TO_I */
-   { 22307, 0x00000CB0 }, /* GL_PIXEL_MAP_I_TO_I_SIZE */
-   { 22332, 0x00000C72 }, /* GL_PIXEL_MAP_I_TO_R */
-   { 22352, 0x00000CB2 }, /* GL_PIXEL_MAP_I_TO_R_SIZE */
-   { 22377, 0x00000C76 }, /* GL_PIXEL_MAP_R_TO_R */
-   { 22397, 0x00000CB6 }, /* GL_PIXEL_MAP_R_TO_R_SIZE */
-   { 22422, 0x00000C71 }, /* GL_PIXEL_MAP_S_TO_S */
-   { 22442, 0x00000CB1 }, /* GL_PIXEL_MAP_S_TO_S_SIZE */
-   { 22467, 0x00000020 }, /* GL_PIXEL_MODE_BIT */
-   { 22485, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING_EXT */
-   { 22518, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER_EXT */
-   { 22543, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING_EXT */
-   { 22578, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER_EXT */
-   { 22605, 0x00001B00 }, /* GL_POINT */
-   { 22614, 0x00000000 }, /* GL_POINTS */
-   { 22624, 0x00000002 }, /* GL_POINT_BIT */
-   { 22637, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION */
-   { 22667, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_ARB */
-   { 22701, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_EXT */
-   { 22735, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_SGIS */
-   { 22770, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE */
-   { 22799, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_ARB */
-   { 22832, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_EXT */
-   { 22865, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_SGIS */
-   { 22899, 0x00000B11 }, /* GL_POINT_SIZE */
-   { 22913, 0x00000B13 }, /* GL_POINT_SIZE_GRANULARITY */
-   { 22939, 0x00008127 }, /* GL_POINT_SIZE_MAX */
-   { 22957, 0x00008127 }, /* GL_POINT_SIZE_MAX_ARB */
-   { 22979, 0x00008127 }, /* GL_POINT_SIZE_MAX_EXT */
-   { 23001, 0x00008127 }, /* GL_POINT_SIZE_MAX_SGIS */
-   { 23024, 0x00008126 }, /* GL_POINT_SIZE_MIN */
-   { 23042, 0x00008126 }, /* GL_POINT_SIZE_MIN_ARB */
-   { 23064, 0x00008126 }, /* GL_POINT_SIZE_MIN_EXT */
-   { 23086, 0x00008126 }, /* GL_POINT_SIZE_MIN_SGIS */
-   { 23109, 0x00000B12 }, /* GL_POINT_SIZE_RANGE */
-   { 23129, 0x00000B10 }, /* GL_POINT_SMOOTH */
-   { 23145, 0x00000C51 }, /* GL_POINT_SMOOTH_HINT */
-   { 23166, 0x00008861 }, /* GL_POINT_SPRITE */
-   { 23182, 0x00008861 }, /* GL_POINT_SPRITE_ARB */
-   { 23202, 0x00008CA0 }, /* GL_POINT_SPRITE_COORD_ORIGIN */
-   { 23231, 0x00008861 }, /* GL_POINT_SPRITE_NV */
-   { 23250, 0x00008863 }, /* GL_POINT_SPRITE_R_MODE_NV */
-   { 23276, 0x00000701 }, /* GL_POINT_TOKEN */
-   { 23291, 0x00000009 }, /* GL_POLYGON */
-   { 23302, 0x00000008 }, /* GL_POLYGON_BIT */
-   { 23317, 0x00000B40 }, /* GL_POLYGON_MODE */
-   { 23333, 0x00008039 }, /* GL_POLYGON_OFFSET_BIAS */
-   { 23356, 0x00008038 }, /* GL_POLYGON_OFFSET_FACTOR */
-   { 23381, 0x00008037 }, /* GL_POLYGON_OFFSET_FILL */
-   { 23404, 0x00002A02 }, /* GL_POLYGON_OFFSET_LINE */
-   { 23427, 0x00002A01 }, /* GL_POLYGON_OFFSET_POINT */
-   { 23451, 0x00002A00 }, /* GL_POLYGON_OFFSET_UNITS */
-   { 23475, 0x00000B41 }, /* GL_POLYGON_SMOOTH */
-   { 23493, 0x00000C53 }, /* GL_POLYGON_SMOOTH_HINT */
-   { 23516, 0x00000B42 }, /* GL_POLYGON_STIPPLE */
-   { 23535, 0x00000010 }, /* GL_POLYGON_STIPPLE_BIT */
-   { 23558, 0x00000703 }, /* GL_POLYGON_TOKEN */
-   { 23575, 0x00001203 }, /* GL_POSITION */
-   { 23587, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */
-   { 23619, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI */
-   { 23655, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */
-   { 23688, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI */
-   { 23725, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */
-   { 23756, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI */
-   { 23791, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */
-   { 23823, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI */
-   { 23859, 0x000080D2 }, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */
-   { 23892, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */
-   { 23924, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI */
-   { 23960, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */
-   { 23993, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI */
-   { 24030, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS */
-   { 24060, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS_SGI */
-   { 24094, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE */
-   { 24125, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE_SGI */
-   { 24160, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS */
-   { 24191, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS_EXT */
-   { 24226, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE */
-   { 24258, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE_EXT */
-   { 24294, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS */
-   { 24324, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS_EXT */
-   { 24358, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE */
-   { 24389, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE_EXT */
-   { 24424, 0x000080D1 }, /* GL_POST_CONVOLUTION_COLOR_TABLE */
-   { 24456, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS */
-   { 24487, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS_EXT */
-   { 24522, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE */
-   { 24554, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE_EXT */
-   { 24590, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS */
-   { 24619, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS_EXT */
-   { 24652, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE */
-   { 24682, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE_EXT */
-   { 24716, 0x0000817B }, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */
-   { 24755, 0x00008179 }, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */
-   { 24788, 0x0000817C }, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */
-   { 24828, 0x0000817A }, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */
-   { 24862, 0x00008578 }, /* GL_PREVIOUS */
-   { 24874, 0x00008578 }, /* GL_PREVIOUS_ARB */
-   { 24890, 0x00008578 }, /* GL_PREVIOUS_EXT */
-   { 24906, 0x00008577 }, /* GL_PRIMARY_COLOR */
-   { 24923, 0x00008577 }, /* GL_PRIMARY_COLOR_ARB */
-   { 24944, 0x00008577 }, /* GL_PRIMARY_COLOR_EXT */
-   { 24965, 0x000088B0 }, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */
-   { 24998, 0x00008805 }, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */
-   { 25030, 0x000088AC }, /* GL_PROGRAM_ATTRIBS_ARB */
-   { 25053, 0x00008677 }, /* GL_PROGRAM_BINDING_ARB */
-   { 25076, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_ARB */
-   { 25106, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_NV */
-   { 25135, 0x00008874 }, /* GL_PROGRAM_ERROR_STRING_ARB */
-   { 25163, 0x00008876 }, /* GL_PROGRAM_FORMAT_ARB */
-   { 25185, 0x00008875 }, /* GL_PROGRAM_FORMAT_ASCII_ARB */
-   { 25213, 0x000088A0 }, /* GL_PROGRAM_INSTRUCTIONS_ARB */
-   { 25241, 0x00008627 }, /* GL_PROGRAM_LENGTH_ARB */
-   { 25263, 0x00008627 }, /* GL_PROGRAM_LENGTH_NV */
-   { 25284, 0x000088B2 }, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
-   { 25324, 0x00008808 }, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
-   { 25363, 0x000088AE }, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */
-   { 25393, 0x000088A2 }, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
-   { 25428, 0x000088AA }, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */
-   { 25461, 0x000088A6 }, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */
-   { 25495, 0x0000880A }, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
-   { 25534, 0x00008809 }, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
-   { 25573, 0x00008B40 }, /* GL_PROGRAM_OBJECT_ARB */
-   { 25595, 0x000088A8 }, /* GL_PROGRAM_PARAMETERS_ARB */
-   { 25621, 0x00008644 }, /* GL_PROGRAM_PARAMETER_NV */
-   { 25645, 0x00008647 }, /* GL_PROGRAM_RESIDENT_NV */
-   { 25668, 0x00008628 }, /* GL_PROGRAM_STRING_ARB */
-   { 25690, 0x00008628 }, /* GL_PROGRAM_STRING_NV */
-   { 25711, 0x00008646 }, /* GL_PROGRAM_TARGET_NV */
-   { 25732, 0x000088A4 }, /* GL_PROGRAM_TEMPORARIES_ARB */
-   { 25759, 0x00008807 }, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */
-   { 25791, 0x00008806 }, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */
-   { 25823, 0x000088B6 }, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */
-   { 25858, 0x00001701 }, /* GL_PROJECTION */
-   { 25872, 0x00000BA7 }, /* GL_PROJECTION_MATRIX */
-   { 25893, 0x00000BA4 }, /* GL_PROJECTION_STACK_DEPTH */
-   { 25919, 0x000080D3 }, /* GL_PROXY_COLOR_TABLE */
-   { 25940, 0x00008025 }, /* GL_PROXY_HISTOGRAM */
-   { 25959, 0x00008025 }, /* GL_PROXY_HISTOGRAM_EXT */
-   { 25982, 0x000080D5 }, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */
-   { 26021, 0x000080D4 }, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */
-   { 26059, 0x00008063 }, /* GL_PROXY_TEXTURE_1D */
-   { 26079, 0x00008C19 }, /* GL_PROXY_TEXTURE_1D_ARRAY_EXT */
-   { 26109, 0x00008063 }, /* GL_PROXY_TEXTURE_1D_EXT */
-   { 26133, 0x00008064 }, /* GL_PROXY_TEXTURE_2D */
-   { 26153, 0x00008C1B }, /* GL_PROXY_TEXTURE_2D_ARRAY_EXT */
-   { 26183, 0x00008064 }, /* GL_PROXY_TEXTURE_2D_EXT */
-   { 26207, 0x00008070 }, /* GL_PROXY_TEXTURE_3D */
-   { 26227, 0x000080BD }, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */
-   { 26260, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP */
-   { 26286, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP_ARB */
-   { 26316, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */
-   { 26347, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_NV */
-   { 26377, 0x00002003 }, /* GL_Q */
-   { 26382, 0x00001209 }, /* GL_QUADRATIC_ATTENUATION */
-   { 26407, 0x00000007 }, /* GL_QUADS */
-   { 26416, 0x00008614 }, /* GL_QUAD_MESH_SUN */
-   { 26433, 0x00000008 }, /* GL_QUAD_STRIP */
-   { 26447, 0x00008864 }, /* GL_QUERY_COUNTER_BITS */
-   { 26469, 0x00008864 }, /* GL_QUERY_COUNTER_BITS_ARB */
-   { 26495, 0x00008866 }, /* GL_QUERY_RESULT */
-   { 26511, 0x00008866 }, /* GL_QUERY_RESULT_ARB */
-   { 26531, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE */
-   { 26557, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE_ARB */
-   { 26587, 0x00002002 }, /* GL_R */
-   { 26592, 0x00002A10 }, /* GL_R3_G3_B2 */
-   { 26604, 0x00019262 }, /* GL_RASTER_POSITION_UNCLIPPED_IBM */
-   { 26637, 0x00000C02 }, /* GL_READ_BUFFER */
-   { 26652, 0x00008CAA }, /* GL_READ_FRAMEBUFFER_BINDING_EXT */
-   { 26684, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER_EXT */
-   { 26708, 0x000088B8 }, /* GL_READ_ONLY */
-   { 26721, 0x000088B8 }, /* GL_READ_ONLY_ARB */
-   { 26738, 0x000088BA }, /* GL_READ_WRITE */
-   { 26752, 0x000088BA }, /* GL_READ_WRITE_ARB */
-   { 26770, 0x00001903 }, /* GL_RED */
-   { 26777, 0x00008016 }, /* GL_REDUCE */
-   { 26787, 0x00008016 }, /* GL_REDUCE_EXT */
-   { 26801, 0x00000D15 }, /* GL_RED_BIAS */
-   { 26813, 0x00000D52 }, /* GL_RED_BITS */
-   { 26825, 0x00000D14 }, /* GL_RED_SCALE */
-   { 26838, 0x00008512 }, /* GL_REFLECTION_MAP */
-   { 26856, 0x00008512 }, /* GL_REFLECTION_MAP_ARB */
-   { 26878, 0x00008512 }, /* GL_REFLECTION_MAP_NV */
-   { 26899, 0x00001C00 }, /* GL_RENDER */
-   { 26909, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING_EXT */
-   { 26937, 0x00008D41 }, /* GL_RENDERBUFFER_EXT */
-   { 26957, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT_EXT */
-   { 26984, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT_EXT */
-   { 27020, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH_EXT */
-   { 27046, 0x00001F01 }, /* GL_RENDERER */
-   { 27058, 0x00000C40 }, /* GL_RENDER_MODE */
-   { 27073, 0x00002901 }, /* GL_REPEAT */
-   { 27083, 0x00001E01 }, /* GL_REPLACE */
-   { 27094, 0x00008062 }, /* GL_REPLACE_EXT */
-   { 27109, 0x00008153 }, /* GL_REPLICATE_BORDER_HP */
-   { 27132, 0x0000803A }, /* GL_RESCALE_NORMAL */
-   { 27150, 0x0000803A }, /* GL_RESCALE_NORMAL_EXT */
-   { 27172, 0x00000102 }, /* GL_RETURN */
-   { 27182, 0x00001907 }, /* GL_RGB */
-   { 27189, 0x00008052 }, /* GL_RGB10 */
-   { 27198, 0x00008059 }, /* GL_RGB10_A2 */
-   { 27210, 0x00008059 }, /* GL_RGB10_A2_EXT */
-   { 27226, 0x00008052 }, /* GL_RGB10_EXT */
-   { 27239, 0x00008053 }, /* GL_RGB12 */
-   { 27248, 0x00008053 }, /* GL_RGB12_EXT */
-   { 27261, 0x00008054 }, /* GL_RGB16 */
-   { 27270, 0x00008054 }, /* GL_RGB16_EXT */
-   { 27283, 0x0000804E }, /* GL_RGB2_EXT */
-   { 27295, 0x0000804F }, /* GL_RGB4 */
-   { 27303, 0x0000804F }, /* GL_RGB4_EXT */
-   { 27315, 0x000083A1 }, /* GL_RGB4_S3TC */
-   { 27328, 0x00008050 }, /* GL_RGB5 */
-   { 27336, 0x00008057 }, /* GL_RGB5_A1 */
-   { 27347, 0x00008057 }, /* GL_RGB5_A1_EXT */
-   { 27362, 0x00008050 }, /* GL_RGB5_EXT */
-   { 27374, 0x00008051 }, /* GL_RGB8 */
-   { 27382, 0x00008051 }, /* GL_RGB8_EXT */
-   { 27394, 0x00001908 }, /* GL_RGBA */
-   { 27402, 0x0000805A }, /* GL_RGBA12 */
-   { 27412, 0x0000805A }, /* GL_RGBA12_EXT */
-   { 27426, 0x0000805B }, /* GL_RGBA16 */
-   { 27436, 0x0000805B }, /* GL_RGBA16_EXT */
-   { 27450, 0x00008055 }, /* GL_RGBA2 */
-   { 27459, 0x00008055 }, /* GL_RGBA2_EXT */
-   { 27472, 0x00008056 }, /* GL_RGBA4 */
-   { 27481, 0x000083A5 }, /* GL_RGBA4_DXT5_S3TC */
-   { 27500, 0x00008056 }, /* GL_RGBA4_EXT */
-   { 27513, 0x000083A3 }, /* GL_RGBA4_S3TC */
-   { 27527, 0x00008058 }, /* GL_RGBA8 */
-   { 27536, 0x00008058 }, /* GL_RGBA8_EXT */
-   { 27549, 0x000083A4 }, /* GL_RGBA_DXT5_S3TC */
-   { 27567, 0x00000C31 }, /* GL_RGBA_MODE */
-   { 27580, 0x000083A2 }, /* GL_RGBA_S3TC */
-   { 27593, 0x000083A0 }, /* GL_RGB_S3TC */
-   { 27605, 0x00008573 }, /* GL_RGB_SCALE */
-   { 27618, 0x00008573 }, /* GL_RGB_SCALE_ARB */
-   { 27635, 0x00008573 }, /* GL_RGB_SCALE_EXT */
-   { 27652, 0x00000407 }, /* GL_RIGHT */
-   { 27661, 0x00002000 }, /* GL_S */
-   { 27666, 0x00008B5D }, /* GL_SAMPLER_1D */
-   { 27680, 0x00008B61 }, /* GL_SAMPLER_1D_SHADOW */
-   { 27701, 0x00008B5E }, /* GL_SAMPLER_2D */
-   { 27715, 0x00008B62 }, /* GL_SAMPLER_2D_SHADOW */
-   { 27736, 0x00008B5F }, /* GL_SAMPLER_3D */
-   { 27750, 0x00008B60 }, /* GL_SAMPLER_CUBE */
-   { 27766, 0x000080A9 }, /* GL_SAMPLES */
-   { 27777, 0x000086B4 }, /* GL_SAMPLES_3DFX */
-   { 27793, 0x000080A9 }, /* GL_SAMPLES_ARB */
-   { 27808, 0x00008914 }, /* GL_SAMPLES_PASSED */
-   { 27826, 0x00008914 }, /* GL_SAMPLES_PASSED_ARB */
-   { 27848, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE */
-   { 27876, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE_ARB */
-   { 27908, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE */
-   { 27931, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE_ARB */
-   { 27958, 0x000080A8 }, /* GL_SAMPLE_BUFFERS */
-   { 27976, 0x000086B3 }, /* GL_SAMPLE_BUFFERS_3DFX */
-   { 27999, 0x000080A8 }, /* GL_SAMPLE_BUFFERS_ARB */
-   { 28021, 0x000080A0 }, /* GL_SAMPLE_COVERAGE */
-   { 28040, 0x000080A0 }, /* GL_SAMPLE_COVERAGE_ARB */
-   { 28063, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT */
-   { 28089, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT_ARB */
-   { 28119, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE */
-   { 28144, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE_ARB */
-   { 28173, 0x00080000 }, /* GL_SCISSOR_BIT */
-   { 28188, 0x00000C10 }, /* GL_SCISSOR_BOX */
-   { 28203, 0x00000C11 }, /* GL_SCISSOR_TEST */
-   { 28219, 0x0000845E }, /* GL_SECONDARY_COLOR_ARRAY */
-   { 28244, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */
-   { 28284, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB */
-   { 28328, 0x0000845D }, /* GL_SECONDARY_COLOR_ARRAY_POINTER */
-   { 28361, 0x0000845A }, /* GL_SECONDARY_COLOR_ARRAY_SIZE */
-   { 28391, 0x0000845C }, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */
-   { 28423, 0x0000845B }, /* GL_SECONDARY_COLOR_ARRAY_TYPE */
-   { 28453, 0x00001C02 }, /* GL_SELECT */
-   { 28463, 0x00000DF3 }, /* GL_SELECTION_BUFFER_POINTER */
-   { 28491, 0x00000DF4 }, /* GL_SELECTION_BUFFER_SIZE */
-   { 28516, 0x00008012 }, /* GL_SEPARABLE_2D */
-   { 28532, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR */
-   { 28559, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR_EXT */
-   { 28590, 0x0000150F }, /* GL_SET */
-   { 28597, 0x00008B48 }, /* GL_SHADER_OBJECT_ARB */
-   { 28618, 0x00008B88 }, /* GL_SHADER_SOURCE_LENGTH */
-   { 28642, 0x00008B4F }, /* GL_SHADER_TYPE */
-   { 28657, 0x00000B54 }, /* GL_SHADE_MODEL */
-   { 28672, 0x00008B8C }, /* GL_SHADING_LANGUAGE_VERSION */
-   { 28700, 0x000080BF }, /* GL_SHADOW_AMBIENT_SGIX */
-   { 28723, 0x000081FB }, /* GL_SHARED_TEXTURE_PALETTE_EXT */
-   { 28753, 0x00001601 }, /* GL_SHININESS */
-   { 28766, 0x00001402 }, /* GL_SHORT */
-   { 28775, 0x000081F9 }, /* GL_SINGLE_COLOR */
-   { 28791, 0x000081F9 }, /* GL_SINGLE_COLOR_EXT */
-   { 28811, 0x000085CC }, /* GL_SLICE_ACCUM_SUN */
-   { 28830, 0x00001D01 }, /* GL_SMOOTH */
-   { 28840, 0x00000B23 }, /* GL_SMOOTH_LINE_WIDTH_GRANULARITY */
-   { 28873, 0x00000B22 }, /* GL_SMOOTH_LINE_WIDTH_RANGE */
-   { 28900, 0x00000B13 }, /* GL_SMOOTH_POINT_SIZE_GRANULARITY */
-   { 28933, 0x00000B12 }, /* GL_SMOOTH_POINT_SIZE_RANGE */
-   { 28960, 0x00008588 }, /* GL_SOURCE0_ALPHA */
-   { 28977, 0x00008588 }, /* GL_SOURCE0_ALPHA_ARB */
-   { 28998, 0x00008588 }, /* GL_SOURCE0_ALPHA_EXT */
-   { 29019, 0x00008580 }, /* GL_SOURCE0_RGB */
-   { 29034, 0x00008580 }, /* GL_SOURCE0_RGB_ARB */
-   { 29053, 0x00008580 }, /* GL_SOURCE0_RGB_EXT */
-   { 29072, 0x00008589 }, /* GL_SOURCE1_ALPHA */
-   { 29089, 0x00008589 }, /* GL_SOURCE1_ALPHA_ARB */
-   { 29110, 0x00008589 }, /* GL_SOURCE1_ALPHA_EXT */
-   { 29131, 0x00008581 }, /* GL_SOURCE1_RGB */
-   { 29146, 0x00008581 }, /* GL_SOURCE1_RGB_ARB */
-   { 29165, 0x00008581 }, /* GL_SOURCE1_RGB_EXT */
-   { 29184, 0x0000858A }, /* GL_SOURCE2_ALPHA */
-   { 29201, 0x0000858A }, /* GL_SOURCE2_ALPHA_ARB */
-   { 29222, 0x0000858A }, /* GL_SOURCE2_ALPHA_EXT */
-   { 29243, 0x00008582 }, /* GL_SOURCE2_RGB */
-   { 29258, 0x00008582 }, /* GL_SOURCE2_RGB_ARB */
-   { 29277, 0x00008582 }, /* GL_SOURCE2_RGB_EXT */
-   { 29296, 0x0000858B }, /* GL_SOURCE3_ALPHA_NV */
-   { 29316, 0x00008583 }, /* GL_SOURCE3_RGB_NV */
-   { 29334, 0x00001202 }, /* GL_SPECULAR */
-   { 29346, 0x00002402 }, /* GL_SPHERE_MAP */
-   { 29360, 0x00001206 }, /* GL_SPOT_CUTOFF */
-   { 29375, 0x00001204 }, /* GL_SPOT_DIRECTION */
-   { 29393, 0x00001205 }, /* GL_SPOT_EXPONENT */
-   { 29410, 0x00008588 }, /* GL_SRC0_ALPHA */
-   { 29424, 0x00008580 }, /* GL_SRC0_RGB */
-   { 29436, 0x00008589 }, /* GL_SRC1_ALPHA */
-   { 29450, 0x00008581 }, /* GL_SRC1_RGB */
-   { 29462, 0x0000858A }, /* GL_SRC2_ALPHA */
-   { 29476, 0x00008582 }, /* GL_SRC2_RGB */
-   { 29488, 0x00000302 }, /* GL_SRC_ALPHA */
-   { 29501, 0x00000308 }, /* GL_SRC_ALPHA_SATURATE */
-   { 29523, 0x00000300 }, /* GL_SRC_COLOR */
-   { 29536, 0x00000503 }, /* GL_STACK_OVERFLOW */
-   { 29554, 0x00000504 }, /* GL_STACK_UNDERFLOW */
-   { 29573, 0x000088E6 }, /* GL_STATIC_COPY */
-   { 29588, 0x000088E6 }, /* GL_STATIC_COPY_ARB */
-   { 29607, 0x000088E4 }, /* GL_STATIC_DRAW */
-   { 29622, 0x000088E4 }, /* GL_STATIC_DRAW_ARB */
-   { 29641, 0x000088E5 }, /* GL_STATIC_READ */
-   { 29656, 0x000088E5 }, /* GL_STATIC_READ_ARB */
-   { 29675, 0x00001802 }, /* GL_STENCIL */
-   { 29686, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT_EXT */
-   { 29712, 0x00008801 }, /* GL_STENCIL_BACK_FAIL */
-   { 29733, 0x00008801 }, /* GL_STENCIL_BACK_FAIL_ATI */
-   { 29758, 0x00008800 }, /* GL_STENCIL_BACK_FUNC */
-   { 29779, 0x00008800 }, /* GL_STENCIL_BACK_FUNC_ATI */
-   { 29804, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */
-   { 29836, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI */
-   { 29872, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */
-   { 29904, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI */
-   { 29940, 0x00008CA3 }, /* GL_STENCIL_BACK_REF */
-   { 29960, 0x00008CA4 }, /* GL_STENCIL_BACK_VALUE_MASK */
-   { 29987, 0x00008CA5 }, /* GL_STENCIL_BACK_WRITEMASK */
-   { 30013, 0x00000D57 }, /* GL_STENCIL_BITS */
-   { 30029, 0x00000400 }, /* GL_STENCIL_BUFFER_BIT */
-   { 30051, 0x00000B91 }, /* GL_STENCIL_CLEAR_VALUE */
-   { 30074, 0x00000B94 }, /* GL_STENCIL_FAIL */
-   { 30090, 0x00000B92 }, /* GL_STENCIL_FUNC */
-   { 30106, 0x00001901 }, /* GL_STENCIL_INDEX */
-   { 30123, 0x00008D49 }, /* GL_STENCIL_INDEX16_EXT */
-   { 30146, 0x00008D46 }, /* GL_STENCIL_INDEX1_EXT */
-   { 30168, 0x00008D47 }, /* GL_STENCIL_INDEX4_EXT */
-   { 30190, 0x00008D48 }, /* GL_STENCIL_INDEX8_EXT */
-   { 30212, 0x00008D45 }, /* GL_STENCIL_INDEX_EXT */
-   { 30233, 0x00000B95 }, /* GL_STENCIL_PASS_DEPTH_FAIL */
-   { 30260, 0x00000B96 }, /* GL_STENCIL_PASS_DEPTH_PASS */
-   { 30287, 0x00000B97 }, /* GL_STENCIL_REF */
-   { 30302, 0x00000B90 }, /* GL_STENCIL_TEST */
-   { 30318, 0x00008910 }, /* GL_STENCIL_TEST_TWO_SIDE_EXT */
-   { 30347, 0x00000B93 }, /* GL_STENCIL_VALUE_MASK */
-   { 30369, 0x00000B98 }, /* GL_STENCIL_WRITEMASK */
-   { 30390, 0x00000C33 }, /* GL_STEREO */
-   { 30400, 0x000088E2 }, /* GL_STREAM_COPY */
-   { 30415, 0x000088E2 }, /* GL_STREAM_COPY_ARB */
-   { 30434, 0x000088E0 }, /* GL_STREAM_DRAW */
-   { 30449, 0x000088E0 }, /* GL_STREAM_DRAW_ARB */
-   { 30468, 0x000088E1 }, /* GL_STREAM_READ */
-   { 30483, 0x000088E1 }, /* GL_STREAM_READ_ARB */
-   { 30502, 0x00000D50 }, /* GL_SUBPIXEL_BITS */
-   { 30519, 0x000084E7 }, /* GL_SUBTRACT */
-   { 30531, 0x000084E7 }, /* GL_SUBTRACT_ARB */
-   { 30547, 0x00002001 }, /* GL_T */
-   { 30552, 0x00002A2A }, /* GL_T2F_C3F_V3F */
-   { 30567, 0x00002A2C }, /* GL_T2F_C4F_N3F_V3F */
-   { 30586, 0x00002A29 }, /* GL_T2F_C4UB_V3F */
-   { 30602, 0x00002A2B }, /* GL_T2F_N3F_V3F */
-   { 30617, 0x00002A27 }, /* GL_T2F_V3F */
-   { 30628, 0x00002A2D }, /* GL_T4F_C4F_N3F_V4F */
-   { 30647, 0x00002A28 }, /* GL_T4F_V4F */
-   { 30658, 0x00008031 }, /* GL_TABLE_TOO_LARGE_EXT */
-   { 30681, 0x00001702 }, /* GL_TEXTURE */
-   { 30692, 0x000084C0 }, /* GL_TEXTURE0 */
-   { 30704, 0x000084C0 }, /* GL_TEXTURE0_ARB */
-   { 30720, 0x000084C1 }, /* GL_TEXTURE1 */
-   { 30732, 0x000084CA }, /* GL_TEXTURE10 */
-   { 30745, 0x000084CA }, /* GL_TEXTURE10_ARB */
-   { 30762, 0x000084CB }, /* GL_TEXTURE11 */
-   { 30775, 0x000084CB }, /* GL_TEXTURE11_ARB */
-   { 30792, 0x000084CC }, /* GL_TEXTURE12 */
-   { 30805, 0x000084CC }, /* GL_TEXTURE12_ARB */
-   { 30822, 0x000084CD }, /* GL_TEXTURE13 */
-   { 30835, 0x000084CD }, /* GL_TEXTURE13_ARB */
-   { 30852, 0x000084CE }, /* GL_TEXTURE14 */
-   { 30865, 0x000084CE }, /* GL_TEXTURE14_ARB */
-   { 30882, 0x000084CF }, /* GL_TEXTURE15 */
-   { 30895, 0x000084CF }, /* GL_TEXTURE15_ARB */
-   { 30912, 0x000084D0 }, /* GL_TEXTURE16 */
-   { 30925, 0x000084D0 }, /* GL_TEXTURE16_ARB */
-   { 30942, 0x000084D1 }, /* GL_TEXTURE17 */
-   { 30955, 0x000084D1 }, /* GL_TEXTURE17_ARB */
-   { 30972, 0x000084D2 }, /* GL_TEXTURE18 */
-   { 30985, 0x000084D2 }, /* GL_TEXTURE18_ARB */
-   { 31002, 0x000084D3 }, /* GL_TEXTURE19 */
-   { 31015, 0x000084D3 }, /* GL_TEXTURE19_ARB */
-   { 31032, 0x000084C1 }, /* GL_TEXTURE1_ARB */
-   { 31048, 0x000084C2 }, /* GL_TEXTURE2 */
-   { 31060, 0x000084D4 }, /* GL_TEXTURE20 */
-   { 31073, 0x000084D4 }, /* GL_TEXTURE20_ARB */
-   { 31090, 0x000084D5 }, /* GL_TEXTURE21 */
-   { 31103, 0x000084D5 }, /* GL_TEXTURE21_ARB */
-   { 31120, 0x000084D6 }, /* GL_TEXTURE22 */
-   { 31133, 0x000084D6 }, /* GL_TEXTURE22_ARB */
-   { 31150, 0x000084D7 }, /* GL_TEXTURE23 */
-   { 31163, 0x000084D7 }, /* GL_TEXTURE23_ARB */
-   { 31180, 0x000084D8 }, /* GL_TEXTURE24 */
-   { 31193, 0x000084D8 }, /* GL_TEXTURE24_ARB */
-   { 31210, 0x000084D9 }, /* GL_TEXTURE25 */
-   { 31223, 0x000084D9 }, /* GL_TEXTURE25_ARB */
-   { 31240, 0x000084DA }, /* GL_TEXTURE26 */
-   { 31253, 0x000084DA }, /* GL_TEXTURE26_ARB */
-   { 31270, 0x000084DB }, /* GL_TEXTURE27 */
-   { 31283, 0x000084DB }, /* GL_TEXTURE27_ARB */
-   { 31300, 0x000084DC }, /* GL_TEXTURE28 */
-   { 31313, 0x000084DC }, /* GL_TEXTURE28_ARB */
-   { 31330, 0x000084DD }, /* GL_TEXTURE29 */
-   { 31343, 0x000084DD }, /* GL_TEXTURE29_ARB */
-   { 31360, 0x000084C2 }, /* GL_TEXTURE2_ARB */
-   { 31376, 0x000084C3 }, /* GL_TEXTURE3 */
-   { 31388, 0x000084DE }, /* GL_TEXTURE30 */
-   { 31401, 0x000084DE }, /* GL_TEXTURE30_ARB */
-   { 31418, 0x000084DF }, /* GL_TEXTURE31 */
-   { 31431, 0x000084DF }, /* GL_TEXTURE31_ARB */
-   { 31448, 0x000084C3 }, /* GL_TEXTURE3_ARB */
-   { 31464, 0x000084C4 }, /* GL_TEXTURE4 */
-   { 31476, 0x000084C4 }, /* GL_TEXTURE4_ARB */
-   { 31492, 0x000084C5 }, /* GL_TEXTURE5 */
-   { 31504, 0x000084C5 }, /* GL_TEXTURE5_ARB */
-   { 31520, 0x000084C6 }, /* GL_TEXTURE6 */
-   { 31532, 0x000084C6 }, /* GL_TEXTURE6_ARB */
-   { 31548, 0x000084C7 }, /* GL_TEXTURE7 */
-   { 31560, 0x000084C7 }, /* GL_TEXTURE7_ARB */
-   { 31576, 0x000084C8 }, /* GL_TEXTURE8 */
-   { 31588, 0x000084C8 }, /* GL_TEXTURE8_ARB */
-   { 31604, 0x000084C9 }, /* GL_TEXTURE9 */
-   { 31616, 0x000084C9 }, /* GL_TEXTURE9_ARB */
-   { 31632, 0x00000DE0 }, /* GL_TEXTURE_1D */
-   { 31646, 0x00008C18 }, /* GL_TEXTURE_1D_ARRAY_EXT */
-   { 31670, 0x00000DE1 }, /* GL_TEXTURE_2D */
-   { 31684, 0x00008C1A }, /* GL_TEXTURE_2D_ARRAY_EXT */
-   { 31708, 0x0000806F }, /* GL_TEXTURE_3D */
-   { 31722, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE */
-   { 31744, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE_EXT */
-   { 31770, 0x0000813C }, /* GL_TEXTURE_BASE_LEVEL */
-   { 31792, 0x00008068 }, /* GL_TEXTURE_BINDING_1D */
-   { 31814, 0x00008C1C }, /* GL_TEXTURE_BINDING_1D_ARRAY_EXT */
-   { 31846, 0x00008069 }, /* GL_TEXTURE_BINDING_2D */
-   { 31868, 0x00008C1D }, /* GL_TEXTURE_BINDING_2D_ARRAY_EXT */
-   { 31900, 0x0000806A }, /* GL_TEXTURE_BINDING_3D */
-   { 31922, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP */
-   { 31950, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP_ARB */
-   { 31982, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */
-   { 32015, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_NV */
-   { 32047, 0x00040000 }, /* GL_TEXTURE_BIT */
-   { 32062, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE */
-   { 32083, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE_EXT */
-   { 32108, 0x00001005 }, /* GL_TEXTURE_BORDER */
-   { 32126, 0x00001004 }, /* GL_TEXTURE_BORDER_COLOR */
-   { 32150, 0x00008171 }, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */
-   { 32181, 0x00008176 }, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */
-   { 32211, 0x00008172 }, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */
-   { 32241, 0x00008175 }, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */
-   { 32276, 0x00008173 }, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */
-   { 32307, 0x00008174 }, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */
-   { 32345, 0x000080BC }, /* GL_TEXTURE_COLOR_TABLE_SGI */
-   { 32372, 0x000081EF }, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */
-   { 32404, 0x000080BF }, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
-   { 32438, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC */
-   { 32462, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC_ARB */
-   { 32490, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE */
-   { 32514, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE_ARB */
-   { 32542, 0x0000819B }, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */
-   { 32575, 0x0000819A }, /* GL_TEXTURE_COMPARE_SGIX */
-   { 32599, 0x00001003 }, /* GL_TEXTURE_COMPONENTS */
-   { 32621, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED */
-   { 32643, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED_ARB */
-   { 32669, 0x000086A3 }, /* GL_TEXTURE_COMPRESSED_FORMATS_ARB */
-   { 32703, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */
-   { 32736, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB */
-   { 32773, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT */
-   { 32801, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT_ARB */
-   { 32833, 0x00008078 }, /* GL_TEXTURE_COORD_ARRAY */
-   { 32856, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */
-   { 32894, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB */
-   { 32936, 0x00008092 }, /* GL_TEXTURE_COORD_ARRAY_POINTER */
-   { 32967, 0x00008088 }, /* GL_TEXTURE_COORD_ARRAY_SIZE */
-   { 32995, 0x0000808A }, /* GL_TEXTURE_COORD_ARRAY_STRIDE */
-   { 33025, 0x00008089 }, /* GL_TEXTURE_COORD_ARRAY_TYPE */
-   { 33053, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP */
-   { 33073, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP_ARB */
-   { 33097, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */
-   { 33128, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB */
-   { 33163, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */
-   { 33194, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB */
-   { 33229, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */
-   { 33260, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB */
-   { 33295, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */
-   { 33326, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB */
-   { 33361, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */
-   { 33392, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB */
-   { 33427, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */
-   { 33458, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB */
-   { 33493, 0x00008071 }, /* GL_TEXTURE_DEPTH */
-   { 33510, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE */
-   { 33532, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE_ARB */
-   { 33558, 0x00002300 }, /* GL_TEXTURE_ENV */
-   { 33573, 0x00002201 }, /* GL_TEXTURE_ENV_COLOR */
-   { 33594, 0x00002200 }, /* GL_TEXTURE_ENV_MODE */
-   { 33614, 0x00008500 }, /* GL_TEXTURE_FILTER_CONTROL */
-   { 33640, 0x00002500 }, /* GL_TEXTURE_GEN_MODE */
-   { 33660, 0x00000C63 }, /* GL_TEXTURE_GEN_Q */
-   { 33677, 0x00000C62 }, /* GL_TEXTURE_GEN_R */
-   { 33694, 0x00000C60 }, /* GL_TEXTURE_GEN_S */
-   { 33711, 0x00000C61 }, /* GL_TEXTURE_GEN_T */
-   { 33728, 0x0000819D }, /* GL_TEXTURE_GEQUAL_R_SGIX */
-   { 33753, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE */
-   { 33775, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE_EXT */
-   { 33801, 0x00001001 }, /* GL_TEXTURE_HEIGHT */
-   { 33819, 0x000080ED }, /* GL_TEXTURE_INDEX_SIZE_EXT */
-   { 33845, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE */
-   { 33871, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE_EXT */
-   { 33901, 0x00001003 }, /* GL_TEXTURE_INTERNAL_FORMAT */
-   { 33928, 0x0000819C }, /* GL_TEXTURE_LEQUAL_R_SGIX */
-   { 33953, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS */
-   { 33973, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS_EXT */
-   { 33997, 0x00008190 }, /* GL_TEXTURE_LOD_BIAS_R_SGIX */
-   { 34024, 0x0000818E }, /* GL_TEXTURE_LOD_BIAS_S_SGIX */
-   { 34051, 0x0000818F }, /* GL_TEXTURE_LOD_BIAS_T_SGIX */
-   { 34078, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE */
-   { 34104, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE_EXT */
-   { 34134, 0x00002800 }, /* GL_TEXTURE_MAG_FILTER */
-   { 34156, 0x00000BA8 }, /* GL_TEXTURE_MATRIX */
-   { 34174, 0x000084FE }, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */
-   { 34204, 0x0000836B }, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */
-   { 34232, 0x00008369 }, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */
-   { 34260, 0x0000836A }, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */
-   { 34288, 0x0000813D }, /* GL_TEXTURE_MAX_LEVEL */
-   { 34309, 0x0000813B }, /* GL_TEXTURE_MAX_LOD */
-   { 34328, 0x00002801 }, /* GL_TEXTURE_MIN_FILTER */
-   { 34350, 0x0000813A }, /* GL_TEXTURE_MIN_LOD */
-   { 34369, 0x00008066 }, /* GL_TEXTURE_PRIORITY */
-   { 34389, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_ARB */
-   { 34414, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_NV */
-   { 34438, 0x0000805C }, /* GL_TEXTURE_RED_SIZE */
-   { 34458, 0x0000805C }, /* GL_TEXTURE_RED_SIZE_EXT */
-   { 34482, 0x00008067 }, /* GL_TEXTURE_RESIDENT */
-   { 34502, 0x00000BA5 }, /* GL_TEXTURE_STACK_DEPTH */
-   { 34525, 0x00008065 }, /* GL_TEXTURE_TOO_LARGE_EXT */
-   { 34550, 0x0000888F }, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */
-   { 34584, 0x00001000 }, /* GL_TEXTURE_WIDTH */
-   { 34601, 0x00008072 }, /* GL_TEXTURE_WRAP_R */
-   { 34619, 0x00002802 }, /* GL_TEXTURE_WRAP_S */
-   { 34637, 0x00002803 }, /* GL_TEXTURE_WRAP_T */
-   { 34655, 0x000088BF }, /* GL_TIME_ELAPSED_EXT */
-   { 34675, 0x00008648 }, /* GL_TRACK_MATRIX_NV */
-   { 34694, 0x00008649 }, /* GL_TRACK_MATRIX_TRANSFORM_NV */
-   { 34723, 0x00001000 }, /* GL_TRANSFORM_BIT */
-   { 34740, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX */
-   { 34766, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX_ARB */
-   { 34796, 0x000088B7 }, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */
-   { 34828, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX */
-   { 34858, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX_ARB */
-   { 34892, 0x0000862C }, /* GL_TRANSPOSE_NV */
-   { 34908, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX */
-   { 34939, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX_ARB */
-   { 34974, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX */
-   { 35002, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX_ARB */
-   { 35034, 0x00000004 }, /* GL_TRIANGLES */
-   { 35047, 0x00000006 }, /* GL_TRIANGLE_FAN */
-   { 35063, 0x00008615 }, /* GL_TRIANGLE_MESH_SUN */
-   { 35084, 0x00000005 }, /* GL_TRIANGLE_STRIP */
-   { 35102, 0x00000001 }, /* GL_TRUE */
-   { 35110, 0x00000CF5 }, /* GL_UNPACK_ALIGNMENT */
-   { 35130, 0x0000806E }, /* GL_UNPACK_IMAGE_HEIGHT */
-   { 35153, 0x00000CF1 }, /* GL_UNPACK_LSB_FIRST */
-   { 35173, 0x00000CF2 }, /* GL_UNPACK_ROW_LENGTH */
-   { 35194, 0x0000806D }, /* GL_UNPACK_SKIP_IMAGES */
-   { 35216, 0x00000CF4 }, /* GL_UNPACK_SKIP_PIXELS */
-   { 35238, 0x00000CF3 }, /* GL_UNPACK_SKIP_ROWS */
-   { 35258, 0x00000CF0 }, /* GL_UNPACK_SWAP_BYTES */
-   { 35279, 0x00001401 }, /* GL_UNSIGNED_BYTE */
-   { 35296, 0x00008362 }, /* GL_UNSIGNED_BYTE_2_3_3_REV */
-   { 35323, 0x00008032 }, /* GL_UNSIGNED_BYTE_3_3_2 */
-   { 35346, 0x00001405 }, /* GL_UNSIGNED_INT */
-   { 35362, 0x00008036 }, /* GL_UNSIGNED_INT_10_10_10_2 */
-   { 35389, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_NV */
-   { 35413, 0x00008368 }, /* GL_UNSIGNED_INT_2_10_10_10_REV */
-   { 35444, 0x00008035 }, /* GL_UNSIGNED_INT_8_8_8_8 */
-   { 35468, 0x00008367 }, /* GL_UNSIGNED_INT_8_8_8_8_REV */
-   { 35496, 0x00001403 }, /* GL_UNSIGNED_SHORT */
-   { 35514, 0x00008366 }, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */
-   { 35544, 0x00008033 }, /* GL_UNSIGNED_SHORT_4_4_4_4 */
-   { 35570, 0x00008365 }, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */
-   { 35600, 0x00008034 }, /* GL_UNSIGNED_SHORT_5_5_5_1 */
-   { 35626, 0x00008363 }, /* GL_UNSIGNED_SHORT_5_6_5 */
-   { 35650, 0x00008364 }, /* GL_UNSIGNED_SHORT_5_6_5_REV */
-   { 35678, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_APPLE */
-   { 35706, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_MESA */
-   { 35733, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */
-   { 35765, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_MESA */
-   { 35796, 0x00008CA2 }, /* GL_UPPER_LEFT */
-   { 35810, 0x00002A20 }, /* GL_V2F */
-   { 35817, 0x00002A21 }, /* GL_V3F */
-   { 35824, 0x00008B83 }, /* GL_VALIDATE_STATUS */
-   { 35843, 0x00001F00 }, /* GL_VENDOR */
-   { 35853, 0x00001F02 }, /* GL_VERSION */
-   { 35864, 0x00008074 }, /* GL_VERTEX_ARRAY */
-   { 35880, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING_APPLE */
-   { 35910, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING */
-   { 35941, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING_ARB */
-   { 35976, 0x0000808E }, /* GL_VERTEX_ARRAY_POINTER */
-   { 36000, 0x0000807A }, /* GL_VERTEX_ARRAY_SIZE */
-   { 36021, 0x0000807C }, /* GL_VERTEX_ARRAY_STRIDE */
-   { 36044, 0x0000807B }, /* GL_VERTEX_ARRAY_TYPE */
-   { 36065, 0x00008650 }, /* GL_VERTEX_ATTRIB_ARRAY0_NV */
-   { 36092, 0x0000865A }, /* GL_VERTEX_ATTRIB_ARRAY10_NV */
-   { 36120, 0x0000865B }, /* GL_VERTEX_ATTRIB_ARRAY11_NV */
-   { 36148, 0x0000865C }, /* GL_VERTEX_ATTRIB_ARRAY12_NV */
-   { 36176, 0x0000865D }, /* GL_VERTEX_ATTRIB_ARRAY13_NV */
-   { 36204, 0x0000865E }, /* GL_VERTEX_ATTRIB_ARRAY14_NV */
-   { 36232, 0x0000865F }, /* GL_VERTEX_ATTRIB_ARRAY15_NV */
-   { 36260, 0x00008651 }, /* GL_VERTEX_ATTRIB_ARRAY1_NV */
-   { 36287, 0x00008652 }, /* GL_VERTEX_ATTRIB_ARRAY2_NV */
-   { 36314, 0x00008653 }, /* GL_VERTEX_ATTRIB_ARRAY3_NV */
-   { 36341, 0x00008654 }, /* GL_VERTEX_ATTRIB_ARRAY4_NV */
-   { 36368, 0x00008655 }, /* GL_VERTEX_ATTRIB_ARRAY5_NV */
-   { 36395, 0x00008656 }, /* GL_VERTEX_ATTRIB_ARRAY6_NV */
-   { 36422, 0x00008657 }, /* GL_VERTEX_ATTRIB_ARRAY7_NV */
-   { 36449, 0x00008658 }, /* GL_VERTEX_ATTRIB_ARRAY8_NV */
-   { 36476, 0x00008659 }, /* GL_VERTEX_ATTRIB_ARRAY9_NV */
-   { 36503, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */
-   { 36541, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB */
-   { 36583, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */
-   { 36614, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB */
-   { 36649, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */
-   { 36683, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB */
-   { 36721, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */
-   { 36752, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB */
-   { 36787, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */
-   { 36815, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB */
-   { 36847, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */
-   { 36877, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB */
-   { 36911, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */
-   { 36939, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB */
-   { 36971, 0x000086A7 }, /* GL_VERTEX_BLEND_ARB */
-   { 36991, 0x00008620 }, /* GL_VERTEX_PROGRAM_ARB */
-   { 37013, 0x0000864A }, /* GL_VERTEX_PROGRAM_BINDING_NV */
-   { 37042, 0x00008620 }, /* GL_VERTEX_PROGRAM_NV */
-   { 37063, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE */
-   { 37092, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_ARB */
-   { 37125, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_NV */
-   { 37157, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE */
-   { 37184, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_ARB */
-   { 37215, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_NV */
-   { 37245, 0x00008B31 }, /* GL_VERTEX_SHADER */
-   { 37262, 0x00008B31 }, /* GL_VERTEX_SHADER_ARB */
-   { 37283, 0x00008621 }, /* GL_VERTEX_STATE_PROGRAM_NV */
-   { 37310, 0x00000BA2 }, /* GL_VIEWPORT */
-   { 37322, 0x00000800 }, /* GL_VIEWPORT_BIT */
-   { 37338, 0x000086AD }, /* GL_WEIGHT_ARRAY_ARB */
-   { 37358, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */
-   { 37389, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB */
-   { 37424, 0x000086AC }, /* GL_WEIGHT_ARRAY_POINTER_ARB */
-   { 37452, 0x000086AB }, /* GL_WEIGHT_ARRAY_SIZE_ARB */
-   { 37477, 0x000086AA }, /* GL_WEIGHT_ARRAY_STRIDE_ARB */
-   { 37504, 0x000086A9 }, /* GL_WEIGHT_ARRAY_TYPE_ARB */
-   { 37529, 0x000086A6 }, /* GL_WEIGHT_SUM_UNITY_ARB */
-   { 37553, 0x000081D4 }, /* GL_WRAP_BORDER_SUN */
-   { 37572, 0x000088B9 }, /* GL_WRITE_ONLY */
-   { 37586, 0x000088B9 }, /* GL_WRITE_ONLY_ARB */
-   { 37604, 0x00001506 }, /* GL_XOR */
-   { 37611, 0x000085B9 }, /* GL_YCBCR_422_APPLE */
-   { 37630, 0x00008757 }, /* GL_YCBCR_MESA */
-   { 37644, 0x00000000 }, /* GL_ZERO */
-   { 37652, 0x00000D16 }, /* GL_ZOOM_X */
-   { 37662, 0x00000D17 }, /* GL_ZOOM_Y */
+   {   877, 0x00008894 }, /* GL_ARRAY_BUFFER_BINDING */
+   {   901, 0x00008894 }, /* GL_ARRAY_BUFFER_BINDING_ARB */
+   {   929, 0x00008B85 }, /* GL_ATTACHED_SHADERS */
+   {   949, 0x00008645 }, /* GL_ATTRIB_ARRAY_POINTER_NV */
+   {   976, 0x00008623 }, /* GL_ATTRIB_ARRAY_SIZE_NV */
+   {  1000, 0x00008624 }, /* GL_ATTRIB_ARRAY_STRIDE_NV */
+   {  1026, 0x00008625 }, /* GL_ATTRIB_ARRAY_TYPE_NV */
+   {  1050, 0x00000BB0 }, /* GL_ATTRIB_STACK_DEPTH */
+   {  1072, 0x00000D80 }, /* GL_AUTO_NORMAL */
+   {  1087, 0x00000409 }, /* GL_AUX0 */
+   {  1095, 0x0000040A }, /* GL_AUX1 */
+   {  1103, 0x0000040B }, /* GL_AUX2 */
+   {  1111, 0x0000040C }, /* GL_AUX3 */
+   {  1119, 0x00000C00 }, /* GL_AUX_BUFFERS */
+   {  1134, 0x00000405 }, /* GL_BACK */
+   {  1142, 0x00000402 }, /* GL_BACK_LEFT */
+   {  1155, 0x00000403 }, /* GL_BACK_RIGHT */
+   {  1169, 0x000080E0 }, /* GL_BGR */
+   {  1176, 0x000080E1 }, /* GL_BGRA */
+   {  1184, 0x00001A00 }, /* GL_BITMAP */
+   {  1194, 0x00000704 }, /* GL_BITMAP_TOKEN */
+   {  1210, 0x00000BE2 }, /* GL_BLEND */
+   {  1219, 0x00008005 }, /* GL_BLEND_COLOR */
+   {  1234, 0x00008005 }, /* GL_BLEND_COLOR_EXT */
+   {  1253, 0x00000BE0 }, /* GL_BLEND_DST */
+   {  1266, 0x000080CA }, /* GL_BLEND_DST_ALPHA */
+   {  1285, 0x000080C8 }, /* GL_BLEND_DST_RGB */
+   {  1302, 0x00008009 }, /* GL_BLEND_EQUATION */
+   {  1320, 0x0000883D }, /* GL_BLEND_EQUATION_ALPHA */
+   {  1344, 0x0000883D }, /* GL_BLEND_EQUATION_ALPHA_EXT */
+   {  1372, 0x00008009 }, /* GL_BLEND_EQUATION_EXT */
+   {  1394, 0x00008009 }, /* GL_BLEND_EQUATION_RGB_EXT */
+   {  1420, 0x00000BE1 }, /* GL_BLEND_SRC */
+   {  1433, 0x000080CB }, /* GL_BLEND_SRC_ALPHA */
+   {  1452, 0x000080C9 }, /* GL_BLEND_SRC_RGB */
+   {  1469, 0x00001905 }, /* GL_BLUE */
+   {  1477, 0x00000D1B }, /* GL_BLUE_BIAS */
+   {  1490, 0x00000D54 }, /* GL_BLUE_BITS */
+   {  1503, 0x00000D1A }, /* GL_BLUE_SCALE */
+   {  1517, 0x00008B56 }, /* GL_BOOL */
+   {  1525, 0x00008B56 }, /* GL_BOOL_ARB */
+   {  1537, 0x00008B57 }, /* GL_BOOL_VEC2 */
+   {  1550, 0x00008B57 }, /* GL_BOOL_VEC2_ARB */
+   {  1567, 0x00008B58 }, /* GL_BOOL_VEC3 */
+   {  1580, 0x00008B58 }, /* GL_BOOL_VEC3_ARB */
+   {  1597, 0x00008B59 }, /* GL_BOOL_VEC4 */
+   {  1610, 0x00008B59 }, /* GL_BOOL_VEC4_ARB */
+   {  1627, 0x000088BB }, /* GL_BUFFER_ACCESS */
+   {  1644, 0x000088BB }, /* GL_BUFFER_ACCESS_ARB */
+   {  1665, 0x000088BC }, /* GL_BUFFER_MAPPED */
+   {  1682, 0x000088BC }, /* GL_BUFFER_MAPPED_ARB */
+   {  1703, 0x000088BD }, /* GL_BUFFER_MAP_POINTER */
+   {  1725, 0x000088BD }, /* GL_BUFFER_MAP_POINTER_ARB */
+   {  1751, 0x00008764 }, /* GL_BUFFER_SIZE */
+   {  1766, 0x00008764 }, /* GL_BUFFER_SIZE_ARB */
+   {  1785, 0x00008765 }, /* GL_BUFFER_USAGE */
+   {  1801, 0x00008765 }, /* GL_BUFFER_USAGE_ARB */
+   {  1821, 0x00001400 }, /* GL_BYTE */
+   {  1829, 0x00002A24 }, /* GL_C3F_V3F */
+   {  1840, 0x00002A26 }, /* GL_C4F_N3F_V3F */
+   {  1855, 0x00002A22 }, /* GL_C4UB_V2F */
+   {  1867, 0x00002A23 }, /* GL_C4UB_V3F */
+   {  1879, 0x00000901 }, /* GL_CCW */
+   {  1886, 0x00002900 }, /* GL_CLAMP */
+   {  1895, 0x0000812D }, /* GL_CLAMP_TO_BORDER */
+   {  1914, 0x0000812D }, /* GL_CLAMP_TO_BORDER_ARB */
+   {  1937, 0x0000812D }, /* GL_CLAMP_TO_BORDER_SGIS */
+   {  1961, 0x0000812F }, /* GL_CLAMP_TO_EDGE */
+   {  1978, 0x0000812F }, /* GL_CLAMP_TO_EDGE_SGIS */
+   {  2000, 0x00001500 }, /* GL_CLEAR */
+   {  2009, 0x000084E1 }, /* GL_CLIENT_ACTIVE_TEXTURE */
+   {  2034, 0x000084E1 }, /* GL_CLIENT_ACTIVE_TEXTURE_ARB */
+   {  2063, 0xFFFFFFFF }, /* GL_CLIENT_ALL_ATTRIB_BITS */
+   {  2089, 0x00000BB1 }, /* GL_CLIENT_ATTRIB_STACK_DEPTH */
+   {  2118, 0x00000001 }, /* GL_CLIENT_PIXEL_STORE_BIT */
+   {  2144, 0x00000002 }, /* GL_CLIENT_VERTEX_ARRAY_BIT */
+   {  2171, 0x00003000 }, /* GL_CLIP_PLANE0 */
+   {  2186, 0x00003001 }, /* GL_CLIP_PLANE1 */
+   {  2201, 0x00003002 }, /* GL_CLIP_PLANE2 */
+   {  2216, 0x00003003 }, /* GL_CLIP_PLANE3 */
+   {  2231, 0x00003004 }, /* GL_CLIP_PLANE4 */
+   {  2246, 0x00003005 }, /* GL_CLIP_PLANE5 */
+   {  2261, 0x000080F0 }, /* GL_CLIP_VOLUME_CLIPPING_HINT_EXT */
+   {  2294, 0x00000A00 }, /* GL_COEFF */
+   {  2303, 0x00001800 }, /* GL_COLOR */
+   {  2312, 0x00008076 }, /* GL_COLOR_ARRAY */
+   {  2327, 0x00008898 }, /* GL_COLOR_ARRAY_BUFFER_BINDING */
+   {  2357, 0x00008898 }, /* GL_COLOR_ARRAY_BUFFER_BINDING_ARB */
+   {  2391, 0x00008090 }, /* GL_COLOR_ARRAY_POINTER */
+   {  2414, 0x00008081 }, /* GL_COLOR_ARRAY_SIZE */
+   {  2434, 0x00008083 }, /* GL_COLOR_ARRAY_STRIDE */
+   {  2456, 0x00008082 }, /* GL_COLOR_ARRAY_TYPE */
+   {  2476, 0x00008CE0 }, /* GL_COLOR_ATTACHMENT0_EXT */
+   {  2501, 0x00008CEA }, /* GL_COLOR_ATTACHMENT10_EXT */
+   {  2527, 0x00008CEB }, /* GL_COLOR_ATTACHMENT11_EXT */
+   {  2553, 0x00008CEC }, /* GL_COLOR_ATTACHMENT12_EXT */
+   {  2579, 0x00008CED }, /* GL_COLOR_ATTACHMENT13_EXT */
+   {  2605, 0x00008CEE }, /* GL_COLOR_ATTACHMENT14_EXT */
+   {  2631, 0x00008CEF }, /* GL_COLOR_ATTACHMENT15_EXT */
+   {  2657, 0x00008CE1 }, /* GL_COLOR_ATTACHMENT1_EXT */
+   {  2682, 0x00008CE2 }, /* GL_COLOR_ATTACHMENT2_EXT */
+   {  2707, 0x00008CE3 }, /* GL_COLOR_ATTACHMENT3_EXT */
+   {  2732, 0x00008CE4 }, /* GL_COLOR_ATTACHMENT4_EXT */
+   {  2757, 0x00008CE5 }, /* GL_COLOR_ATTACHMENT5_EXT */
+   {  2782, 0x00008CE6 }, /* GL_COLOR_ATTACHMENT6_EXT */
+   {  2807, 0x00008CE7 }, /* GL_COLOR_ATTACHMENT7_EXT */
+   {  2832, 0x00008CE8 }, /* GL_COLOR_ATTACHMENT8_EXT */
+   {  2857, 0x00008CE9 }, /* GL_COLOR_ATTACHMENT9_EXT */
+   {  2882, 0x00004000 }, /* GL_COLOR_BUFFER_BIT */
+   {  2902, 0x00000C22 }, /* GL_COLOR_CLEAR_VALUE */
+   {  2923, 0x00001900 }, /* GL_COLOR_INDEX */
+   {  2938, 0x00001603 }, /* GL_COLOR_INDEXES */
+   {  2955, 0x00000BF2 }, /* GL_COLOR_LOGIC_OP */
+   {  2973, 0x00000B57 }, /* GL_COLOR_MATERIAL */
+   {  2991, 0x00000B55 }, /* GL_COLOR_MATERIAL_FACE */
+   {  3014, 0x00000B56 }, /* GL_COLOR_MATERIAL_PARAMETER */
+   {  3042, 0x000080B1 }, /* GL_COLOR_MATRIX */
+   {  3058, 0x000080B1 }, /* GL_COLOR_MATRIX_SGI */
+   {  3078, 0x000080B2 }, /* GL_COLOR_MATRIX_STACK_DEPTH */
+   {  3106, 0x000080B2 }, /* GL_COLOR_MATRIX_STACK_DEPTH_SGI */
+   {  3138, 0x00008458 }, /* GL_COLOR_SUM */
+   {  3151, 0x00008458 }, /* GL_COLOR_SUM_ARB */
+   {  3168, 0x000080D0 }, /* GL_COLOR_TABLE */
+   {  3183, 0x000080DD }, /* GL_COLOR_TABLE_ALPHA_SIZE */
+   {  3209, 0x000080DD }, /* GL_COLOR_TABLE_ALPHA_SIZE_EXT */
+   {  3239, 0x000080DD }, /* GL_COLOR_TABLE_ALPHA_SIZE_SGI */
+   {  3269, 0x000080D7 }, /* GL_COLOR_TABLE_BIAS */
+   {  3289, 0x000080D7 }, /* GL_COLOR_TABLE_BIAS_SGI */
+   {  3313, 0x000080DC }, /* GL_COLOR_TABLE_BLUE_SIZE */
+   {  3338, 0x000080DC }, /* GL_COLOR_TABLE_BLUE_SIZE_EXT */
+   {  3367, 0x000080DC }, /* GL_COLOR_TABLE_BLUE_SIZE_SGI */
+   {  3396, 0x000080D8 }, /* GL_COLOR_TABLE_FORMAT */
+   {  3418, 0x000080D8 }, /* GL_COLOR_TABLE_FORMAT_EXT */
+   {  3444, 0x000080D8 }, /* GL_COLOR_TABLE_FORMAT_SGI */
+   {  3470, 0x000080DB }, /* GL_COLOR_TABLE_GREEN_SIZE */
+   {  3496, 0x000080DB }, /* GL_COLOR_TABLE_GREEN_SIZE_EXT */
+   {  3526, 0x000080DB }, /* GL_COLOR_TABLE_GREEN_SIZE_SGI */
+   {  3556, 0x000080DF }, /* GL_COLOR_TABLE_INTENSITY_SIZE */
+   {  3586, 0x000080DF }, /* GL_COLOR_TABLE_INTENSITY_SIZE_EXT */
+   {  3620, 0x000080DF }, /* GL_COLOR_TABLE_INTENSITY_SIZE_SGI */
+   {  3654, 0x000080DE }, /* GL_COLOR_TABLE_LUMINANCE_SIZE */
+   {  3684, 0x000080DE }, /* GL_COLOR_TABLE_LUMINANCE_SIZE_EXT */
+   {  3718, 0x000080DE }, /* GL_COLOR_TABLE_LUMINANCE_SIZE_SGI */
+   {  3752, 0x000080DA }, /* GL_COLOR_TABLE_RED_SIZE */
+   {  3776, 0x000080DA }, /* GL_COLOR_TABLE_RED_SIZE_EXT */
+   {  3804, 0x000080DA }, /* GL_COLOR_TABLE_RED_SIZE_SGI */
+   {  3832, 0x000080D6 }, /* GL_COLOR_TABLE_SCALE */
+   {  3853, 0x000080D6 }, /* GL_COLOR_TABLE_SCALE_SGI */
+   {  3878, 0x000080D9 }, /* GL_COLOR_TABLE_WIDTH */
+   {  3899, 0x000080D9 }, /* GL_COLOR_TABLE_WIDTH_EXT */
+   {  3924, 0x000080D9 }, /* GL_COLOR_TABLE_WIDTH_SGI */
+   {  3949, 0x00000C23 }, /* GL_COLOR_WRITEMASK */
+   {  3968, 0x00008570 }, /* GL_COMBINE */
+   {  3979, 0x00008503 }, /* GL_COMBINE4 */
+   {  3991, 0x00008572 }, /* GL_COMBINE_ALPHA */
+   {  4008, 0x00008572 }, /* GL_COMBINE_ALPHA_ARB */
+   {  4029, 0x00008572 }, /* GL_COMBINE_ALPHA_EXT */
+   {  4050, 0x00008570 }, /* GL_COMBINE_ARB */
+   {  4065, 0x00008570 }, /* GL_COMBINE_EXT */
+   {  4080, 0x00008571 }, /* GL_COMBINE_RGB */
+   {  4095, 0x00008571 }, /* GL_COMBINE_RGB_ARB */
+   {  4114, 0x00008571 }, /* GL_COMBINE_RGB_EXT */
+   {  4133, 0x0000884E }, /* GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT */
+   {  4169, 0x0000884E }, /* GL_COMPARE_R_TO_TEXTURE */
+   {  4193, 0x0000884E }, /* GL_COMPARE_R_TO_TEXTURE_ARB */
+   {  4221, 0x00001300 }, /* GL_COMPILE */
+   {  4232, 0x00001301 }, /* GL_COMPILE_AND_EXECUTE */
+   {  4255, 0x00008B81 }, /* GL_COMPILE_STATUS */
+   {  4273, 0x000084E9 }, /* GL_COMPRESSED_ALPHA */
+   {  4293, 0x000084E9 }, /* GL_COMPRESSED_ALPHA_ARB */
+   {  4317, 0x000084EC }, /* GL_COMPRESSED_INTENSITY */
+   {  4341, 0x000084EC }, /* GL_COMPRESSED_INTENSITY_ARB */
+   {  4369, 0x000084EA }, /* GL_COMPRESSED_LUMINANCE */
+   {  4393, 0x000084EB }, /* GL_COMPRESSED_LUMINANCE_ALPHA */
+   {  4423, 0x000084EB }, /* GL_COMPRESSED_LUMINANCE_ALPHA_ARB */
+   {  4457, 0x000084EA }, /* GL_COMPRESSED_LUMINANCE_ARB */
+   {  4485, 0x000084ED }, /* GL_COMPRESSED_RGB */
+   {  4503, 0x000084EE }, /* GL_COMPRESSED_RGBA */
+   {  4522, 0x000084EE }, /* GL_COMPRESSED_RGBA_ARB */
+   {  4545, 0x000086B1 }, /* GL_COMPRESSED_RGBA_FXT1_3DFX */
+   {  4574, 0x000083F1 }, /* GL_COMPRESSED_RGBA_S3TC_DXT1_EXT */
+   {  4607, 0x000083F2 }, /* GL_COMPRESSED_RGBA_S3TC_DXT3_EXT */
+   {  4640, 0x000083F3 }, /* GL_COMPRESSED_RGBA_S3TC_DXT5_EXT */
+   {  4673, 0x000084ED }, /* GL_COMPRESSED_RGB_ARB */
+   {  4695, 0x000086B0 }, /* GL_COMPRESSED_RGB_FXT1_3DFX */
+   {  4723, 0x000083F0 }, /* GL_COMPRESSED_RGB_S3TC_DXT1_EXT */
+   {  4755, 0x000086A3 }, /* GL_COMPRESSED_TEXTURE_FORMATS */
+   {  4785, 0x00008576 }, /* GL_CONSTANT */
+   {  4797, 0x00008003 }, /* GL_CONSTANT_ALPHA */
+   {  4815, 0x00008003 }, /* GL_CONSTANT_ALPHA_EXT */
+   {  4837, 0x00008576 }, /* GL_CONSTANT_ARB */
+   {  4853, 0x00001207 }, /* GL_CONSTANT_ATTENUATION */
+   {  4877, 0x00008151 }, /* GL_CONSTANT_BORDER_HP */
+   {  4899, 0x00008001 }, /* GL_CONSTANT_COLOR */
+   {  4917, 0x00008001 }, /* GL_CONSTANT_COLOR_EXT */
+   {  4939, 0x00008576 }, /* GL_CONSTANT_EXT */
+   {  4955, 0x00008010 }, /* GL_CONVOLUTION_1D */
+   {  4973, 0x00008011 }, /* GL_CONVOLUTION_2D */
+   {  4991, 0x00008154 }, /* GL_CONVOLUTION_BORDER_COLOR */
+   {  5019, 0x00008154 }, /* GL_CONVOLUTION_BORDER_COLOR_HP */
+   {  5050, 0x00008013 }, /* GL_CONVOLUTION_BORDER_MODE */
+   {  5077, 0x00008013 }, /* GL_CONVOLUTION_BORDER_MODE_EXT */
+   {  5108, 0x00008015 }, /* GL_CONVOLUTION_FILTER_BIAS */
+   {  5135, 0x00008015 }, /* GL_CONVOLUTION_FILTER_BIAS_EXT */
+   {  5166, 0x00008014 }, /* GL_CONVOLUTION_FILTER_SCALE */
+   {  5194, 0x00008014 }, /* GL_CONVOLUTION_FILTER_SCALE_EXT */
+   {  5226, 0x00008017 }, /* GL_CONVOLUTION_FORMAT */
+   {  5248, 0x00008017 }, /* GL_CONVOLUTION_FORMAT_EXT */
+   {  5274, 0x00008019 }, /* GL_CONVOLUTION_HEIGHT */
+   {  5296, 0x00008019 }, /* GL_CONVOLUTION_HEIGHT_EXT */
+   {  5322, 0x00008018 }, /* GL_CONVOLUTION_WIDTH */
+   {  5343, 0x00008018 }, /* GL_CONVOLUTION_WIDTH_EXT */
+   {  5368, 0x00008862 }, /* GL_COORD_REPLACE */
+   {  5385, 0x00008862 }, /* GL_COORD_REPLACE_ARB */
+   {  5406, 0x00008862 }, /* GL_COORD_REPLACE_NV */
+   {  5426, 0x00001503 }, /* GL_COPY */
+   {  5434, 0x0000150C }, /* GL_COPY_INVERTED */
+   {  5451, 0x00000706 }, /* GL_COPY_PIXEL_TOKEN */
+   {  5471, 0x00000B44 }, /* GL_CULL_FACE */
+   {  5484, 0x00000B45 }, /* GL_CULL_FACE_MODE */
+   {  5502, 0x000081AA }, /* GL_CULL_VERTEX_EXT */
+   {  5521, 0x000081AC }, /* GL_CULL_VERTEX_EYE_POSITION_EXT */
+   {  5553, 0x000081AB }, /* GL_CULL_VERTEX_OBJECT_POSITION_EXT */
+   {  5588, 0x00008626 }, /* GL_CURRENT_ATTRIB_NV */
+   {  5609, 0x00000001 }, /* GL_CURRENT_BIT */
+   {  5624, 0x00000B00 }, /* GL_CURRENT_COLOR */
+   {  5641, 0x00008453 }, /* GL_CURRENT_FOG_COORD */
+   {  5662, 0x00008453 }, /* GL_CURRENT_FOG_COORDINATE */
+   {  5688, 0x00000B01 }, /* GL_CURRENT_INDEX */
+   {  5705, 0x00008641 }, /* GL_CURRENT_MATRIX_ARB */
+   {  5727, 0x00008845 }, /* GL_CURRENT_MATRIX_INDEX_ARB */
+   {  5755, 0x00008641 }, /* GL_CURRENT_MATRIX_NV */
+   {  5776, 0x00008640 }, /* GL_CURRENT_MATRIX_STACK_DEPTH_ARB */
+   {  5810, 0x00008640 }, /* GL_CURRENT_MATRIX_STACK_DEPTH_NV */
+   {  5843, 0x00000B02 }, /* GL_CURRENT_NORMAL */
+   {  5861, 0x00008843 }, /* GL_CURRENT_PALETTE_MATRIX_ARB */
+   {  5891, 0x00008B8D }, /* GL_CURRENT_PROGRAM */
+   {  5910, 0x00008865 }, /* GL_CURRENT_QUERY */
+   {  5927, 0x00008865 }, /* GL_CURRENT_QUERY_ARB */
+   {  5948, 0x00000B04 }, /* GL_CURRENT_RASTER_COLOR */
+   {  5972, 0x00000B09 }, /* GL_CURRENT_RASTER_DISTANCE */
+   {  5999, 0x00000B05 }, /* GL_CURRENT_RASTER_INDEX */
+   {  6023, 0x00000B07 }, /* GL_CURRENT_RASTER_POSITION */
+   {  6050, 0x00000B08 }, /* GL_CURRENT_RASTER_POSITION_VALID */
+   {  6083, 0x00000B06 }, /* GL_CURRENT_RASTER_TEXTURE_COORDS */
+   {  6116, 0x00008459 }, /* GL_CURRENT_SECONDARY_COLOR */
+   {  6143, 0x00000B03 }, /* GL_CURRENT_TEXTURE_COORDS */
+   {  6169, 0x00008626 }, /* GL_CURRENT_VERTEX_ATTRIB */
+   {  6194, 0x00008626 }, /* GL_CURRENT_VERTEX_ATTRIB_ARB */
+   {  6223, 0x000086A8 }, /* GL_CURRENT_WEIGHT_ARB */
+   {  6245, 0x00000900 }, /* GL_CW */
+   {  6251, 0x0000875B }, /* GL_DEBUG_ASSERT_MESA */
+   {  6272, 0x00008759 }, /* GL_DEBUG_OBJECT_MESA */
+   {  6293, 0x0000875A }, /* GL_DEBUG_PRINT_MESA */
+   {  6313, 0x00002101 }, /* GL_DECAL */
+   {  6322, 0x00001E03 }, /* GL_DECR */
+   {  6330, 0x00008508 }, /* GL_DECR_WRAP */
+   {  6343, 0x00008508 }, /* GL_DECR_WRAP_EXT */
+   {  6360, 0x00008B80 }, /* GL_DELETE_STATUS */
+   {  6377, 0x00001801 }, /* GL_DEPTH */
+   {  6386, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT_EXT */
+   {  6410, 0x00000D1F }, /* GL_DEPTH_BIAS */
+   {  6424, 0x00000D56 }, /* GL_DEPTH_BITS */
+   {  6438, 0x00008891 }, /* GL_DEPTH_BOUNDS_EXT */
+   {  6458, 0x00008890 }, /* GL_DEPTH_BOUNDS_TEST_EXT */
+   {  6483, 0x00000100 }, /* GL_DEPTH_BUFFER_BIT */
+   {  6503, 0x0000864F }, /* GL_DEPTH_CLAMP_NV */
+   {  6521, 0x00000B73 }, /* GL_DEPTH_CLEAR_VALUE */
+   {  6542, 0x00001902 }, /* GL_DEPTH_COMPONENT */
+   {  6561, 0x000081A5 }, /* GL_DEPTH_COMPONENT16 */
+   {  6582, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_ARB */
+   {  6607, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_SGIX */
+   {  6633, 0x000081A6 }, /* GL_DEPTH_COMPONENT24 */
+   {  6654, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_ARB */
+   {  6679, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_SGIX */
+   {  6705, 0x000081A7 }, /* GL_DEPTH_COMPONENT32 */
+   {  6726, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_ARB */
+   {  6751, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_SGIX */
+   {  6777, 0x00000B74 }, /* GL_DEPTH_FUNC */
+   {  6791, 0x00000B70 }, /* GL_DEPTH_RANGE */
+   {  6806, 0x00000D1E }, /* GL_DEPTH_SCALE */
+   {  6821, 0x000084F9 }, /* GL_DEPTH_STENCIL_NV */
+   {  6841, 0x0000886F }, /* GL_DEPTH_STENCIL_TO_BGRA_NV */
+   {  6869, 0x0000886E }, /* GL_DEPTH_STENCIL_TO_RGBA_NV */
+   {  6897, 0x00000B71 }, /* GL_DEPTH_TEST */
+   {  6911, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE */
+   {  6933, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE_ARB */
+   {  6959, 0x00000B72 }, /* GL_DEPTH_WRITEMASK */
+   {  6978, 0x00001201 }, /* GL_DIFFUSE */
+   {  6989, 0x00000BD0 }, /* GL_DITHER */
+   {  6999, 0x00000A02 }, /* GL_DOMAIN */
+   {  7009, 0x00001100 }, /* GL_DONT_CARE */
+   {  7022, 0x000086AE }, /* GL_DOT3_RGB */
+   {  7034, 0x000086AF }, /* GL_DOT3_RGBA */
+   {  7047, 0x000086AF }, /* GL_DOT3_RGBA_ARB */
+   {  7064, 0x00008741 }, /* GL_DOT3_RGBA_EXT */
+   {  7081, 0x000086AE }, /* GL_DOT3_RGB_ARB */
+   {  7097, 0x00008740 }, /* GL_DOT3_RGB_EXT */
+   {  7113, 0x0000140A }, /* GL_DOUBLE */
+   {  7123, 0x00000C32 }, /* GL_DOUBLEBUFFER */
+   {  7139, 0x00000C01 }, /* GL_DRAW_BUFFER */
+   {  7154, 0x00008825 }, /* GL_DRAW_BUFFER0 */
+   {  7170, 0x00008825 }, /* GL_DRAW_BUFFER0_ARB */
+   {  7190, 0x00008825 }, /* GL_DRAW_BUFFER0_ATI */
+   {  7210, 0x00008826 }, /* GL_DRAW_BUFFER1 */
+   {  7226, 0x0000882F }, /* GL_DRAW_BUFFER10 */
+   {  7243, 0x0000882F }, /* GL_DRAW_BUFFER10_ARB */
+   {  7264, 0x0000882F }, /* GL_DRAW_BUFFER10_ATI */
+   {  7285, 0x00008830 }, /* GL_DRAW_BUFFER11 */
+   {  7302, 0x00008830 }, /* GL_DRAW_BUFFER11_ARB */
+   {  7323, 0x00008830 }, /* GL_DRAW_BUFFER11_ATI */
+   {  7344, 0x00008831 }, /* GL_DRAW_BUFFER12 */
+   {  7361, 0x00008831 }, /* GL_DRAW_BUFFER12_ARB */
+   {  7382, 0x00008831 }, /* GL_DRAW_BUFFER12_ATI */
+   {  7403, 0x00008832 }, /* GL_DRAW_BUFFER13 */
+   {  7420, 0x00008832 }, /* GL_DRAW_BUFFER13_ARB */
+   {  7441, 0x00008832 }, /* GL_DRAW_BUFFER13_ATI */
+   {  7462, 0x00008833 }, /* GL_DRAW_BUFFER14 */
+   {  7479, 0x00008833 }, /* GL_DRAW_BUFFER14_ARB */
+   {  7500, 0x00008833 }, /* GL_DRAW_BUFFER14_ATI */
+   {  7521, 0x00008834 }, /* GL_DRAW_BUFFER15 */
+   {  7538, 0x00008834 }, /* GL_DRAW_BUFFER15_ARB */
+   {  7559, 0x00008834 }, /* GL_DRAW_BUFFER15_ATI */
+   {  7580, 0x00008826 }, /* GL_DRAW_BUFFER1_ARB */
+   {  7600, 0x00008826 }, /* GL_DRAW_BUFFER1_ATI */
+   {  7620, 0x00008827 }, /* GL_DRAW_BUFFER2 */
+   {  7636, 0x00008827 }, /* GL_DRAW_BUFFER2_ARB */
+   {  7656, 0x00008827 }, /* GL_DRAW_BUFFER2_ATI */
+   {  7676, 0x00008828 }, /* GL_DRAW_BUFFER3 */
+   {  7692, 0x00008828 }, /* GL_DRAW_BUFFER3_ARB */
+   {  7712, 0x00008828 }, /* GL_DRAW_BUFFER3_ATI */
+   {  7732, 0x00008829 }, /* GL_DRAW_BUFFER4 */
+   {  7748, 0x00008829 }, /* GL_DRAW_BUFFER4_ARB */
+   {  7768, 0x00008829 }, /* GL_DRAW_BUFFER4_ATI */
+   {  7788, 0x0000882A }, /* GL_DRAW_BUFFER5 */
+   {  7804, 0x0000882A }, /* GL_DRAW_BUFFER5_ARB */
+   {  7824, 0x0000882A }, /* GL_DRAW_BUFFER5_ATI */
+   {  7844, 0x0000882B }, /* GL_DRAW_BUFFER6 */
+   {  7860, 0x0000882B }, /* GL_DRAW_BUFFER6_ARB */
+   {  7880, 0x0000882B }, /* GL_DRAW_BUFFER6_ATI */
+   {  7900, 0x0000882C }, /* GL_DRAW_BUFFER7 */
+   {  7916, 0x0000882C }, /* GL_DRAW_BUFFER7_ARB */
+   {  7936, 0x0000882C }, /* GL_DRAW_BUFFER7_ATI */
+   {  7956, 0x0000882D }, /* GL_DRAW_BUFFER8 */
+   {  7972, 0x0000882D }, /* GL_DRAW_BUFFER8_ARB */
+   {  7992, 0x0000882D }, /* GL_DRAW_BUFFER8_ATI */
+   {  8012, 0x0000882E }, /* GL_DRAW_BUFFER9 */
+   {  8028, 0x0000882E }, /* GL_DRAW_BUFFER9_ARB */
+   {  8048, 0x0000882E }, /* GL_DRAW_BUFFER9_ATI */
+   {  8068, 0x00008CA6 }, /* GL_DRAW_FRAMEBUFFER_BINDING_EXT */
+   {  8100, 0x00008CA9 }, /* GL_DRAW_FRAMEBUFFER_EXT */
+   {  8124, 0x00000705 }, /* GL_DRAW_PIXEL_TOKEN */
+   {  8144, 0x00000304 }, /* GL_DST_ALPHA */
+   {  8157, 0x00000306 }, /* GL_DST_COLOR */
+   {  8170, 0x000088EA }, /* GL_DYNAMIC_COPY */
+   {  8186, 0x000088EA }, /* GL_DYNAMIC_COPY_ARB */
+   {  8206, 0x000088E8 }, /* GL_DYNAMIC_DRAW */
+   {  8222, 0x000088E8 }, /* GL_DYNAMIC_DRAW_ARB */
+   {  8242, 0x000088E9 }, /* GL_DYNAMIC_READ */
+   {  8258, 0x000088E9 }, /* GL_DYNAMIC_READ_ARB */
+   {  8278, 0x00000B43 }, /* GL_EDGE_FLAG */
+   {  8291, 0x00008079 }, /* GL_EDGE_FLAG_ARRAY */
+   {  8310, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */
+   {  8344, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB */
+   {  8382, 0x00008093 }, /* GL_EDGE_FLAG_ARRAY_POINTER */
+   {  8409, 0x0000808C }, /* GL_EDGE_FLAG_ARRAY_STRIDE */
+   {  8435, 0x00008893 }, /* GL_ELEMENT_ARRAY_BUFFER */
+   {  8459, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */
+   {  8491, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB */
+   {  8527, 0x00001600 }, /* GL_EMISSION */
+   {  8539, 0x00002000 }, /* GL_ENABLE_BIT */
+   {  8553, 0x00000202 }, /* GL_EQUAL */
+   {  8562, 0x00001509 }, /* GL_EQUIV */
+   {  8571, 0x00010000 }, /* GL_EVAL_BIT */
+   {  8583, 0x00000800 }, /* GL_EXP */
+   {  8590, 0x00000801 }, /* GL_EXP2 */
+   {  8598, 0x00001F03 }, /* GL_EXTENSIONS */
+   {  8612, 0x00002400 }, /* GL_EYE_LINEAR */
+   {  8626, 0x00002502 }, /* GL_EYE_PLANE */
+   {  8639, 0x0000855C }, /* GL_EYE_PLANE_ABSOLUTE_NV */
+   {  8664, 0x0000855B }, /* GL_EYE_RADIAL_NV */
+   {  8681, 0x00000000 }, /* GL_FALSE */
+   {  8690, 0x00001101 }, /* GL_FASTEST */
+   {  8701, 0x00001C01 }, /* GL_FEEDBACK */
+   {  8713, 0x00000DF0 }, /* GL_FEEDBACK_BUFFER_POINTER */
+   {  8740, 0x00000DF1 }, /* GL_FEEDBACK_BUFFER_SIZE */
+   {  8764, 0x00000DF2 }, /* GL_FEEDBACK_BUFFER_TYPE */
+   {  8788, 0x00001B02 }, /* GL_FILL */
+   {  8796, 0x00001D00 }, /* GL_FLAT */
+   {  8804, 0x00001406 }, /* GL_FLOAT */
+   {  8813, 0x00008B5A }, /* GL_FLOAT_MAT2 */
+   {  8827, 0x00008B5A }, /* GL_FLOAT_MAT2_ARB */
+   {  8845, 0x00008B5B }, /* GL_FLOAT_MAT3 */
+   {  8859, 0x00008B5B }, /* GL_FLOAT_MAT3_ARB */
+   {  8877, 0x00008B5C }, /* GL_FLOAT_MAT4 */
+   {  8891, 0x00008B5C }, /* GL_FLOAT_MAT4_ARB */
+   {  8909, 0x00008B50 }, /* GL_FLOAT_VEC2 */
+   {  8923, 0x00008B50 }, /* GL_FLOAT_VEC2_ARB */
+   {  8941, 0x00008B51 }, /* GL_FLOAT_VEC3 */
+   {  8955, 0x00008B51 }, /* GL_FLOAT_VEC3_ARB */
+   {  8973, 0x00008B52 }, /* GL_FLOAT_VEC4 */
+   {  8987, 0x00008B52 }, /* GL_FLOAT_VEC4_ARB */
+   {  9005, 0x00000B60 }, /* GL_FOG */
+   {  9012, 0x00000080 }, /* GL_FOG_BIT */
+   {  9023, 0x00000B66 }, /* GL_FOG_COLOR */
+   {  9036, 0x00008451 }, /* GL_FOG_COORD */
+   {  9049, 0x00008451 }, /* GL_FOG_COORDINATE */
+   {  9067, 0x00008457 }, /* GL_FOG_COORDINATE_ARRAY */
+   {  9091, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */
+   {  9130, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB */
+   {  9173, 0x00008456 }, /* GL_FOG_COORDINATE_ARRAY_POINTER */
+   {  9205, 0x00008455 }, /* GL_FOG_COORDINATE_ARRAY_STRIDE */
+   {  9236, 0x00008454 }, /* GL_FOG_COORDINATE_ARRAY_TYPE */
+   {  9265, 0x00008450 }, /* GL_FOG_COORDINATE_SOURCE */
+   {  9290, 0x00008457 }, /* GL_FOG_COORD_ARRAY */
+   {  9309, 0x0000889D }, /* GL_FOG_COORD_ARRAY_BUFFER_BINDING */
+   {  9343, 0x00008456 }, /* GL_FOG_COORD_ARRAY_POINTER */
+   {  9370, 0x00008455 }, /* GL_FOG_COORD_ARRAY_STRIDE */
+   {  9396, 0x00008454 }, /* GL_FOG_COORD_ARRAY_TYPE */
+   {  9420, 0x00008450 }, /* GL_FOG_COORD_SRC */
+   {  9437, 0x00000B62 }, /* GL_FOG_DENSITY */
+   {  9452, 0x0000855A }, /* GL_FOG_DISTANCE_MODE_NV */
+   {  9476, 0x00000B64 }, /* GL_FOG_END */
+   {  9487, 0x00000C54 }, /* GL_FOG_HINT */
+   {  9499, 0x00000B61 }, /* GL_FOG_INDEX */
+   {  9512, 0x00000B65 }, /* GL_FOG_MODE */
+   {  9524, 0x00008198 }, /* GL_FOG_OFFSET_SGIX */
+   {  9543, 0x00008199 }, /* GL_FOG_OFFSET_VALUE_SGIX */
+   {  9568, 0x00000B63 }, /* GL_FOG_START */
+   {  9581, 0x00008452 }, /* GL_FRAGMENT_DEPTH */
+   {  9599, 0x00008804 }, /* GL_FRAGMENT_PROGRAM_ARB */
+   {  9623, 0x00008B30 }, /* GL_FRAGMENT_SHADER */
+   {  9642, 0x00008B30 }, /* GL_FRAGMENT_SHADER_ARB */
+   {  9665, 0x00008B8B }, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT */
+   {  9700, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT */
+   {  9742, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT */
+   {  9784, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT */
+   {  9833, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT */
+   {  9885, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */
+   {  9929, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT */
+   {  9973, 0x00008CA6 }, /* GL_FRAMEBUFFER_BINDING_EXT */
+   { 10000, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE_EXT */
+   { 10028, 0x00008D40 }, /* GL_FRAMEBUFFER_EXT */
+   { 10047, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT */
+   { 10088, 0x00008CD9 }, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */
+   { 10129, 0x00008CDB }, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT */
+   { 10171, 0x00008CD8 }, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */
+   { 10222, 0x00008CDA }, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */
+   { 10260, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT */
+   { 10309, 0x00008CDC }, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT */
+   { 10351, 0x00008CDE }, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */
+   { 10383, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED_EXT */
+   { 10414, 0x00000404 }, /* GL_FRONT */
+   { 10423, 0x00000408 }, /* GL_FRONT_AND_BACK */
+   { 10441, 0x00000B46 }, /* GL_FRONT_FACE */
+   { 10455, 0x00000400 }, /* GL_FRONT_LEFT */
+   { 10469, 0x00000401 }, /* GL_FRONT_RIGHT */
+   { 10484, 0x00008006 }, /* GL_FUNC_ADD */
+   { 10496, 0x00008006 }, /* GL_FUNC_ADD_EXT */
+   { 10512, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT */
+   { 10537, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT_EXT */
+   { 10566, 0x0000800A }, /* GL_FUNC_SUBTRACT */
+   { 10583, 0x0000800A }, /* GL_FUNC_SUBTRACT_EXT */
+   { 10604, 0x00008191 }, /* GL_GENERATE_MIPMAP */
+   { 10623, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT */
+   { 10647, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT_SGIS */
+   { 10676, 0x00008191 }, /* GL_GENERATE_MIPMAP_SGIS */
+   { 10700, 0x00000206 }, /* GL_GEQUAL */
+   { 10710, 0x00008009 }, /* GL_GL_BLEND_EQUATION_RGB */
+   { 10735, 0x00008C4A }, /* GL_GL_COMPRESSED_SLUMINANCE */
+   { 10763, 0x00008C4B }, /* GL_GL_COMPRESSED_SLUMINANCE_ALPHA */
+   { 10797, 0x00008C48 }, /* GL_GL_COMPRESSED_SRGB */
+   { 10819, 0x00008C49 }, /* GL_GL_COMPRESSED_SRGB_ALPHA */
+   { 10847, 0x0000845F }, /* GL_GL_CURRENT_RASTER_SECONDARY_COLOR */
+   { 10884, 0x00008B65 }, /* GL_GL_FLOAT_MAT2x3 */
+   { 10903, 0x00008B66 }, /* GL_GL_FLOAT_MAT2x4 */
+   { 10922, 0x00008B67 }, /* GL_GL_FLOAT_MAT3x2 */
+   { 10941, 0x00008B68 }, /* GL_GL_FLOAT_MAT3x4 */
+   { 10960, 0x00008B69 }, /* GL_GL_FLOAT_MAT4x2 */
+   { 10979, 0x00008B6A }, /* GL_GL_FLOAT_MAT4x3 */
+   { 10998, 0x000088EB }, /* GL_GL_PIXEL_PACK_BUFFER */
+   { 11022, 0x000088ED }, /* GL_GL_PIXEL_PACK_BUFFER_BINDING */
+   { 11054, 0x000088EC }, /* GL_GL_PIXEL_UNPACK_BUFFER */
+   { 11080, 0x000088EF }, /* GL_GL_PIXEL_UNPACK_BUFFER_BINDING */
+   { 11114, 0x00008C46 }, /* GL_GL_SLUMINANCE */
+   { 11131, 0x00008C47 }, /* GL_GL_SLUMINANCE8 */
+   { 11149, 0x00008C45 }, /* GL_GL_SLUMINANCE8_ALPHA8 */
+   { 11174, 0x00008C44 }, /* GL_GL_SLUMINANCE_ALPHA */
+   { 11197, 0x00008C40 }, /* GL_GL_SRGB */
+   { 11208, 0x00008C41 }, /* GL_GL_SRGB8 */
+   { 11220, 0x00008C43 }, /* GL_GL_SRGB8_ALPHA8 */
+   { 11239, 0x00008C42 }, /* GL_GL_SRGB_ALPHA */
+   { 11256, 0x00000204 }, /* GL_GREATER */
+   { 11267, 0x00001904 }, /* GL_GREEN */
+   { 11276, 0x00000D19 }, /* GL_GREEN_BIAS */
+   { 11290, 0x00000D53 }, /* GL_GREEN_BITS */
+   { 11304, 0x00000D18 }, /* GL_GREEN_SCALE */
+   { 11319, 0x00008000 }, /* GL_HINT_BIT */
+   { 11331, 0x00008024 }, /* GL_HISTOGRAM */
+   { 11344, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE */
+   { 11368, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE_EXT */
+   { 11396, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE */
+   { 11419, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE_EXT */
+   { 11446, 0x00008024 }, /* GL_HISTOGRAM_EXT */
+   { 11463, 0x00008027 }, /* GL_HISTOGRAM_FORMAT */
+   { 11483, 0x00008027 }, /* GL_HISTOGRAM_FORMAT_EXT */
+   { 11507, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE */
+   { 11531, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE_EXT */
+   { 11559, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE */
+   { 11587, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE_EXT */
+   { 11619, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE */
+   { 11641, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE_EXT */
+   { 11667, 0x0000802D }, /* GL_HISTOGRAM_SINK */
+   { 11685, 0x0000802D }, /* GL_HISTOGRAM_SINK_EXT */
+   { 11707, 0x00008026 }, /* GL_HISTOGRAM_WIDTH */
+   { 11726, 0x00008026 }, /* GL_HISTOGRAM_WIDTH_EXT */
+   { 11749, 0x0000862A }, /* GL_IDENTITY_NV */
+   { 11764, 0x00008150 }, /* GL_IGNORE_BORDER_HP */
+   { 11784, 0x00008B9B }, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */
+   { 11824, 0x00008B9A }, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */
+   { 11862, 0x00001E02 }, /* GL_INCR */
+   { 11870, 0x00008507 }, /* GL_INCR_WRAP */
+   { 11883, 0x00008507 }, /* GL_INCR_WRAP_EXT */
+   { 11900, 0x00008077 }, /* GL_INDEX_ARRAY */
+   { 11915, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING */
+   { 11945, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING_ARB */
+   { 11979, 0x00008091 }, /* GL_INDEX_ARRAY_POINTER */
+   { 12002, 0x00008086 }, /* GL_INDEX_ARRAY_STRIDE */
+   { 12024, 0x00008085 }, /* GL_INDEX_ARRAY_TYPE */
+   { 12044, 0x00000D51 }, /* GL_INDEX_BITS */
+   { 12058, 0x00000C20 }, /* GL_INDEX_CLEAR_VALUE */
+   { 12079, 0x00000BF1 }, /* GL_INDEX_LOGIC_OP */
+   { 12097, 0x00000C30 }, /* GL_INDEX_MODE */
+   { 12111, 0x00000D13 }, /* GL_INDEX_OFFSET */
+   { 12127, 0x00000D12 }, /* GL_INDEX_SHIFT */
+   { 12142, 0x00000C21 }, /* GL_INDEX_WRITEMASK */
+   { 12161, 0x00008B84 }, /* GL_INFO_LOG_LENGTH */
+   { 12180, 0x00001404 }, /* GL_INT */
+   { 12187, 0x00008049 }, /* GL_INTENSITY */
+   { 12200, 0x0000804C }, /* GL_INTENSITY12 */
+   { 12215, 0x0000804C }, /* GL_INTENSITY12_EXT */
+   { 12234, 0x0000804D }, /* GL_INTENSITY16 */
+   { 12249, 0x0000804D }, /* GL_INTENSITY16_EXT */
+   { 12268, 0x0000804A }, /* GL_INTENSITY4 */
+   { 12282, 0x0000804A }, /* GL_INTENSITY4_EXT */
+   { 12300, 0x0000804B }, /* GL_INTENSITY8 */
+   { 12314, 0x0000804B }, /* GL_INTENSITY8_EXT */
+   { 12332, 0x00008049 }, /* GL_INTENSITY_EXT */
+   { 12349, 0x00008575 }, /* GL_INTERPOLATE */
+   { 12364, 0x00008575 }, /* GL_INTERPOLATE_ARB */
+   { 12383, 0x00008575 }, /* GL_INTERPOLATE_EXT */
+   { 12402, 0x00008B53 }, /* GL_INT_VEC2 */
+   { 12414, 0x00008B53 }, /* GL_INT_VEC2_ARB */
+   { 12430, 0x00008B54 }, /* GL_INT_VEC3 */
+   { 12442, 0x00008B54 }, /* GL_INT_VEC3_ARB */
+   { 12458, 0x00008B55 }, /* GL_INT_VEC4 */
+   { 12470, 0x00008B55 }, /* GL_INT_VEC4_ARB */
+   { 12486, 0x00000500 }, /* GL_INVALID_ENUM */
+   { 12502, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION_EXT */
+   { 12539, 0x00000502 }, /* GL_INVALID_OPERATION */
+   { 12560, 0x00000501 }, /* GL_INVALID_VALUE */
+   { 12577, 0x0000862B }, /* GL_INVERSE_NV */
+   { 12591, 0x0000862D }, /* GL_INVERSE_TRANSPOSE_NV */
+   { 12615, 0x0000150A }, /* GL_INVERT */
+   { 12625, 0x00001E00 }, /* GL_KEEP */
+   { 12633, 0x00000406 }, /* GL_LEFT */
+   { 12641, 0x00000203 }, /* GL_LEQUAL */
+   { 12651, 0x00000201 }, /* GL_LESS */
+   { 12659, 0x00004000 }, /* GL_LIGHT0 */
+   { 12669, 0x00004001 }, /* GL_LIGHT1 */
+   { 12679, 0x00004002 }, /* GL_LIGHT2 */
+   { 12689, 0x00004003 }, /* GL_LIGHT3 */
+   { 12699, 0x00004004 }, /* GL_LIGHT4 */
+   { 12709, 0x00004005 }, /* GL_LIGHT5 */
+   { 12719, 0x00004006 }, /* GL_LIGHT6 */
+   { 12729, 0x00004007 }, /* GL_LIGHT7 */
+   { 12739, 0x00000B50 }, /* GL_LIGHTING */
+   { 12751, 0x00000040 }, /* GL_LIGHTING_BIT */
+   { 12767, 0x00000B53 }, /* GL_LIGHT_MODEL_AMBIENT */
+   { 12790, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL */
+   { 12819, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL_EXT */
+   { 12852, 0x00000B51 }, /* GL_LIGHT_MODEL_LOCAL_VIEWER */
+   { 12880, 0x00000B52 }, /* GL_LIGHT_MODEL_TWO_SIDE */
+   { 12904, 0x00001B01 }, /* GL_LINE */
+   { 12912, 0x00002601 }, /* GL_LINEAR */
+   { 12922, 0x00001208 }, /* GL_LINEAR_ATTENUATION */
+   { 12944, 0x00008170 }, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */
+   { 12974, 0x0000844F }, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */
+   { 13005, 0x00002703 }, /* GL_LINEAR_MIPMAP_LINEAR */
+   { 13029, 0x00002701 }, /* GL_LINEAR_MIPMAP_NEAREST */
+   { 13054, 0x00000001 }, /* GL_LINES */
+   { 13063, 0x00000004 }, /* GL_LINE_BIT */
+   { 13075, 0x00000002 }, /* GL_LINE_LOOP */
+   { 13088, 0x00000707 }, /* GL_LINE_RESET_TOKEN */
+   { 13108, 0x00000B20 }, /* GL_LINE_SMOOTH */
+   { 13123, 0x00000C52 }, /* GL_LINE_SMOOTH_HINT */
+   { 13143, 0x00000B24 }, /* GL_LINE_STIPPLE */
+   { 13159, 0x00000B25 }, /* GL_LINE_STIPPLE_PATTERN */
+   { 13183, 0x00000B26 }, /* GL_LINE_STIPPLE_REPEAT */
+   { 13206, 0x00000003 }, /* GL_LINE_STRIP */
+   { 13220, 0x00000702 }, /* GL_LINE_TOKEN */
+   { 13234, 0x00000B21 }, /* GL_LINE_WIDTH */
+   { 13248, 0x00000B23 }, /* GL_LINE_WIDTH_GRANULARITY */
+   { 13274, 0x00000B22 }, /* GL_LINE_WIDTH_RANGE */
+   { 13294, 0x00008B82 }, /* GL_LINK_STATUS */
+   { 13309, 0x00000B32 }, /* GL_LIST_BASE */
+   { 13322, 0x00020000 }, /* GL_LIST_BIT */
+   { 13334, 0x00000B33 }, /* GL_LIST_INDEX */
+   { 13348, 0x00000B30 }, /* GL_LIST_MODE */
+   { 13361, 0x00000101 }, /* GL_LOAD */
+   { 13369, 0x00000BF1 }, /* GL_LOGIC_OP */
+   { 13381, 0x00000BF0 }, /* GL_LOGIC_OP_MODE */
+   { 13398, 0x00008CA1 }, /* GL_LOWER_LEFT */
+   { 13412, 0x00001909 }, /* GL_LUMINANCE */
+   { 13425, 0x00008041 }, /* GL_LUMINANCE12 */
+   { 13440, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12 */
+   { 13463, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12_EXT */
+   { 13490, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4 */
+   { 13512, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4_EXT */
+   { 13538, 0x00008041 }, /* GL_LUMINANCE12_EXT */
+   { 13557, 0x00008042 }, /* GL_LUMINANCE16 */
+   { 13572, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16 */
+   { 13595, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16_EXT */
+   { 13622, 0x00008042 }, /* GL_LUMINANCE16_EXT */
+   { 13641, 0x0000803F }, /* GL_LUMINANCE4 */
+   { 13655, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4 */
+   { 13676, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4_EXT */
+   { 13701, 0x0000803F }, /* GL_LUMINANCE4_EXT */
+   { 13719, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2 */
+   { 13740, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2_EXT */
+   { 13765, 0x00008040 }, /* GL_LUMINANCE8 */
+   { 13779, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8 */
+   { 13800, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8_EXT */
+   { 13825, 0x00008040 }, /* GL_LUMINANCE8_EXT */
+   { 13843, 0x0000190A }, /* GL_LUMINANCE_ALPHA */
+   { 13862, 0x00000D90 }, /* GL_MAP1_COLOR_4 */
+   { 13878, 0x00000DD0 }, /* GL_MAP1_GRID_DOMAIN */
+   { 13898, 0x00000DD1 }, /* GL_MAP1_GRID_SEGMENTS */
+   { 13920, 0x00000D91 }, /* GL_MAP1_INDEX */
+   { 13934, 0x00000D92 }, /* GL_MAP1_NORMAL */
+   { 13949, 0x00000D93 }, /* GL_MAP1_TEXTURE_COORD_1 */
+   { 13973, 0x00000D94 }, /* GL_MAP1_TEXTURE_COORD_2 */
+   { 13997, 0x00000D95 }, /* GL_MAP1_TEXTURE_COORD_3 */
+   { 14021, 0x00000D96 }, /* GL_MAP1_TEXTURE_COORD_4 */
+   { 14045, 0x00000D97 }, /* GL_MAP1_VERTEX_3 */
+   { 14062, 0x00000D98 }, /* GL_MAP1_VERTEX_4 */
+   { 14079, 0x00008660 }, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */
+   { 14107, 0x0000866A }, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */
+   { 14136, 0x0000866B }, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */
+   { 14165, 0x0000866C }, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */
+   { 14194, 0x0000866D }, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */
+   { 14223, 0x0000866E }, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */
+   { 14252, 0x0000866F }, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */
+   { 14281, 0x00008661 }, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */
+   { 14309, 0x00008662 }, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */
+   { 14337, 0x00008663 }, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */
+   { 14365, 0x00008664 }, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */
+   { 14393, 0x00008665 }, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */
+   { 14421, 0x00008666 }, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */
+   { 14449, 0x00008667 }, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */
+   { 14477, 0x00008668 }, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */
+   { 14505, 0x00008669 }, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */
+   { 14533, 0x00000DB0 }, /* GL_MAP2_COLOR_4 */
+   { 14549, 0x00000DD2 }, /* GL_MAP2_GRID_DOMAIN */
+   { 14569, 0x00000DD3 }, /* GL_MAP2_GRID_SEGMENTS */
+   { 14591, 0x00000DB1 }, /* GL_MAP2_INDEX */
+   { 14605, 0x00000DB2 }, /* GL_MAP2_NORMAL */
+   { 14620, 0x00000DB3 }, /* GL_MAP2_TEXTURE_COORD_1 */
+   { 14644, 0x00000DB4 }, /* GL_MAP2_TEXTURE_COORD_2 */
+   { 14668, 0x00000DB5 }, /* GL_MAP2_TEXTURE_COORD_3 */
+   { 14692, 0x00000DB6 }, /* GL_MAP2_TEXTURE_COORD_4 */
+   { 14716, 0x00000DB7 }, /* GL_MAP2_VERTEX_3 */
+   { 14733, 0x00000DB8 }, /* GL_MAP2_VERTEX_4 */
+   { 14750, 0x00008670 }, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */
+   { 14778, 0x0000867A }, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */
+   { 14807, 0x0000867B }, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */
+   { 14836, 0x0000867C }, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */
+   { 14865, 0x0000867D }, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */
+   { 14894, 0x0000867E }, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */
+   { 14923, 0x0000867F }, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */
+   { 14952, 0x00008671 }, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */
+   { 14980, 0x00008672 }, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */
+   { 15008, 0x00008673 }, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */
+   { 15036, 0x00008674 }, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */
+   { 15064, 0x00008675 }, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */
+   { 15092, 0x00008676 }, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */
+   { 15120, 0x00008677 }, /* GL_MAP2_VERTEX_ATTRIB7_4_NV */
+   { 15148, 0x00008678 }, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */
+   { 15176, 0x00008679 }, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */
+   { 15204, 0x00000D10 }, /* GL_MAP_COLOR */
+   { 15217, 0x00000D11 }, /* GL_MAP_STENCIL */
+   { 15232, 0x000088C0 }, /* GL_MATRIX0_ARB */
+   { 15247, 0x00008630 }, /* GL_MATRIX0_NV */
+   { 15261, 0x000088CA }, /* GL_MATRIX10_ARB */
+   { 15277, 0x000088CB }, /* GL_MATRIX11_ARB */
+   { 15293, 0x000088CC }, /* GL_MATRIX12_ARB */
+   { 15309, 0x000088CD }, /* GL_MATRIX13_ARB */
+   { 15325, 0x000088CE }, /* GL_MATRIX14_ARB */
+   { 15341, 0x000088CF }, /* GL_MATRIX15_ARB */
+   { 15357, 0x000088D0 }, /* GL_MATRIX16_ARB */
+   { 15373, 0x000088D1 }, /* GL_MATRIX17_ARB */
+   { 15389, 0x000088D2 }, /* GL_MATRIX18_ARB */
+   { 15405, 0x000088D3 }, /* GL_MATRIX19_ARB */
+   { 15421, 0x000088C1 }, /* GL_MATRIX1_ARB */
+   { 15436, 0x00008631 }, /* GL_MATRIX1_NV */
+   { 15450, 0x000088D4 }, /* GL_MATRIX20_ARB */
+   { 15466, 0x000088D5 }, /* GL_MATRIX21_ARB */
+   { 15482, 0x000088D6 }, /* GL_MATRIX22_ARB */
+   { 15498, 0x000088D7 }, /* GL_MATRIX23_ARB */
+   { 15514, 0x000088D8 }, /* GL_MATRIX24_ARB */
+   { 15530, 0x000088D9 }, /* GL_MATRIX25_ARB */
+   { 15546, 0x000088DA }, /* GL_MATRIX26_ARB */
+   { 15562, 0x000088DB }, /* GL_MATRIX27_ARB */
+   { 15578, 0x000088DC }, /* GL_MATRIX28_ARB */
+   { 15594, 0x000088DD }, /* GL_MATRIX29_ARB */
+   { 15610, 0x000088C2 }, /* GL_MATRIX2_ARB */
+   { 15625, 0x00008632 }, /* GL_MATRIX2_NV */
+   { 15639, 0x000088DE }, /* GL_MATRIX30_ARB */
+   { 15655, 0x000088DF }, /* GL_MATRIX31_ARB */
+   { 15671, 0x000088C3 }, /* GL_MATRIX3_ARB */
+   { 15686, 0x00008633 }, /* GL_MATRIX3_NV */
+   { 15700, 0x000088C4 }, /* GL_MATRIX4_ARB */
+   { 15715, 0x00008634 }, /* GL_MATRIX4_NV */
+   { 15729, 0x000088C5 }, /* GL_MATRIX5_ARB */
+   { 15744, 0x00008635 }, /* GL_MATRIX5_NV */
+   { 15758, 0x000088C6 }, /* GL_MATRIX6_ARB */
+   { 15773, 0x00008636 }, /* GL_MATRIX6_NV */
+   { 15787, 0x000088C7 }, /* GL_MATRIX7_ARB */
+   { 15802, 0x00008637 }, /* GL_MATRIX7_NV */
+   { 15816, 0x000088C8 }, /* GL_MATRIX8_ARB */
+   { 15831, 0x000088C9 }, /* GL_MATRIX9_ARB */
+   { 15846, 0x00008844 }, /* GL_MATRIX_INDEX_ARRAY_ARB */
+   { 15872, 0x00008849 }, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */
+   { 15906, 0x00008846 }, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */
+   { 15937, 0x00008848 }, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */
+   { 15970, 0x00008847 }, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */
+   { 16001, 0x00000BA0 }, /* GL_MATRIX_MODE */
+   { 16016, 0x00008840 }, /* GL_MATRIX_PALETTE_ARB */
+   { 16038, 0x00008008 }, /* GL_MAX */
+   { 16045, 0x00008073 }, /* GL_MAX_3D_TEXTURE_SIZE */
+   { 16068, 0x000088FF }, /* GL_MAX_ARRAY_TEXTURE_LAYERS_EXT */
+   { 16100, 0x00000D35 }, /* GL_MAX_ATTRIB_STACK_DEPTH */
+   { 16126, 0x00000D3B }, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */
+   { 16159, 0x00008177 }, /* GL_MAX_CLIPMAP_DEPTH_SGIX */
+   { 16185, 0x00008178 }, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */
+   { 16219, 0x00000D32 }, /* GL_MAX_CLIP_PLANES */
+   { 16238, 0x00008CDF }, /* GL_MAX_COLOR_ATTACHMENTS_EXT */
+   { 16267, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */
+   { 16299, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI */
+   { 16335, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */
+   { 16371, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB */
+   { 16411, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT */
+   { 16437, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT_EXT */
+   { 16467, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH */
+   { 16492, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH_EXT */
+   { 16521, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */
+   { 16550, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB */
+   { 16583, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS */
+   { 16603, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ARB */
+   { 16627, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ATI */
+   { 16651, 0x000080E9 }, /* GL_MAX_ELEMENTS_INDICES */
+   { 16675, 0x000080E8 }, /* GL_MAX_ELEMENTS_VERTICES */
+   { 16700, 0x00000D30 }, /* GL_MAX_EVAL_ORDER */
+   { 16718, 0x00008008 }, /* GL_MAX_EXT */
+   { 16729, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */
+   { 16764, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB */
+   { 16803, 0x00000D31 }, /* GL_MAX_LIGHTS */
+   { 16817, 0x00000B31 }, /* GL_MAX_LIST_NESTING */
+   { 16837, 0x00008841 }, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */
+   { 16875, 0x00000D36 }, /* GL_MAX_MODELVIEW_STACK_DEPTH */
+   { 16904, 0x00000D37 }, /* GL_MAX_NAME_STACK_DEPTH */
+   { 16928, 0x00008842 }, /* GL_MAX_PALETTE_MATRICES_ARB */
+   { 16956, 0x00000D34 }, /* GL_MAX_PIXEL_MAP_TABLE */
+   { 16979, 0x000088B1 }, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */
+   { 17016, 0x0000880B }, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */
+   { 17052, 0x000088AD }, /* GL_MAX_PROGRAM_ATTRIBS_ARB */
+   { 17079, 0x000088F5 }, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */
+   { 17108, 0x000088B5 }, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */
+   { 17142, 0x000088F4 }, /* GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */
+   { 17178, 0x000088F6 }, /* GL_MAX_PROGRAM_IF_DEPTH_NV */
+   { 17205, 0x000088A1 }, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */
+   { 17237, 0x000088B4 }, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */
+   { 17273, 0x000088F8 }, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */
+   { 17302, 0x000088F7 }, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */
+   { 17331, 0x0000862F }, /* GL_MAX_PROGRAM_MATRICES_ARB */
+   { 17359, 0x0000862E }, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */
+   { 17397, 0x000088B3 }, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
+   { 17441, 0x0000880E }, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
+   { 17484, 0x000088AF }, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */
+   { 17518, 0x000088A3 }, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
+   { 17557, 0x000088AB }, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */
+   { 17594, 0x000088A7 }, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */
+   { 17632, 0x00008810 }, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
+   { 17675, 0x0000880F }, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
+   { 17718, 0x000088A9 }, /* GL_MAX_PROGRAM_PARAMETERS_ARB */
+   { 17748, 0x000088A5 }, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */
+   { 17779, 0x0000880D }, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */
+   { 17815, 0x0000880C }, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */
+   { 17851, 0x00000D38 }, /* GL_MAX_PROJECTION_STACK_DEPTH */
+   { 17881, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */
+   { 17915, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_NV */
+   { 17948, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE_EXT */
+   { 17977, 0x00008504 }, /* GL_MAX_SHININESS_NV */
+   { 17997, 0x00008505 }, /* GL_MAX_SPOT_EXPONENT_NV */
+   { 18021, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS */
+   { 18043, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS_ARB */
+   { 18069, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS */
+   { 18096, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS_ARB */
+   { 18127, 0x000084FD }, /* GL_MAX_TEXTURE_LOD_BIAS */
+   { 18151, 0x000084FF }, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */
+   { 18185, 0x00000D33 }, /* GL_MAX_TEXTURE_SIZE */
+   { 18205, 0x00000D39 }, /* GL_MAX_TEXTURE_STACK_DEPTH */
+   { 18232, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS */
+   { 18253, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS_ARB */
+   { 18278, 0x0000862F }, /* GL_MAX_TRACK_MATRICES_NV */
+   { 18303, 0x0000862E }, /* GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */
+   { 18338, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS */
+   { 18360, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS_ARB */
+   { 18386, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS */
+   { 18408, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS_ARB */
+   { 18434, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */
+   { 18468, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */
+   { 18506, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */
+   { 18539, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB */
+   { 18576, 0x000086A4 }, /* GL_MAX_VERTEX_UNITS_ARB */
+   { 18600, 0x00000D3A }, /* GL_MAX_VIEWPORT_DIMS */
+   { 18621, 0x00008007 }, /* GL_MIN */
+   { 18628, 0x0000802E }, /* GL_MINMAX */
+   { 18638, 0x0000802E }, /* GL_MINMAX_EXT */
+   { 18652, 0x0000802F }, /* GL_MINMAX_FORMAT */
+   { 18669, 0x0000802F }, /* GL_MINMAX_FORMAT_EXT */
+   { 18690, 0x00008030 }, /* GL_MINMAX_SINK */
+   { 18705, 0x00008030 }, /* GL_MINMAX_SINK_EXT */
+   { 18724, 0x00008007 }, /* GL_MIN_EXT */
+   { 18735, 0x00008370 }, /* GL_MIRRORED_REPEAT */
+   { 18754, 0x00008370 }, /* GL_MIRRORED_REPEAT_ARB */
+   { 18777, 0x00008370 }, /* GL_MIRRORED_REPEAT_IBM */
+   { 18800, 0x00008742 }, /* GL_MIRROR_CLAMP_ATI */
+   { 18820, 0x00008742 }, /* GL_MIRROR_CLAMP_EXT */
+   { 18840, 0x00008912 }, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */
+   { 18870, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_ATI */
+   { 18898, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */
+   { 18926, 0x00001700 }, /* GL_MODELVIEW */
+   { 18939, 0x00001700 }, /* GL_MODELVIEW0_ARB */
+   { 18957, 0x0000872A }, /* GL_MODELVIEW10_ARB */
+   { 18976, 0x0000872B }, /* GL_MODELVIEW11_ARB */
+   { 18995, 0x0000872C }, /* GL_MODELVIEW12_ARB */
+   { 19014, 0x0000872D }, /* GL_MODELVIEW13_ARB */
+   { 19033, 0x0000872E }, /* GL_MODELVIEW14_ARB */
+   { 19052, 0x0000872F }, /* GL_MODELVIEW15_ARB */
+   { 19071, 0x00008730 }, /* GL_MODELVIEW16_ARB */
+   { 19090, 0x00008731 }, /* GL_MODELVIEW17_ARB */
+   { 19109, 0x00008732 }, /* GL_MODELVIEW18_ARB */
+   { 19128, 0x00008733 }, /* GL_MODELVIEW19_ARB */
+   { 19147, 0x0000850A }, /* GL_MODELVIEW1_ARB */
+   { 19165, 0x00008734 }, /* GL_MODELVIEW20_ARB */
+   { 19184, 0x00008735 }, /* GL_MODELVIEW21_ARB */
+   { 19203, 0x00008736 }, /* GL_MODELVIEW22_ARB */
+   { 19222, 0x00008737 }, /* GL_MODELVIEW23_ARB */
+   { 19241, 0x00008738 }, /* GL_MODELVIEW24_ARB */
+   { 19260, 0x00008739 }, /* GL_MODELVIEW25_ARB */
+   { 19279, 0x0000873A }, /* GL_MODELVIEW26_ARB */
+   { 19298, 0x0000873B }, /* GL_MODELVIEW27_ARB */
+   { 19317, 0x0000873C }, /* GL_MODELVIEW28_ARB */
+   { 19336, 0x0000873D }, /* GL_MODELVIEW29_ARB */
+   { 19355, 0x00008722 }, /* GL_MODELVIEW2_ARB */
+   { 19373, 0x0000873E }, /* GL_MODELVIEW30_ARB */
+   { 19392, 0x0000873F }, /* GL_MODELVIEW31_ARB */
+   { 19411, 0x00008723 }, /* GL_MODELVIEW3_ARB */
+   { 19429, 0x00008724 }, /* GL_MODELVIEW4_ARB */
+   { 19447, 0x00008725 }, /* GL_MODELVIEW5_ARB */
+   { 19465, 0x00008726 }, /* GL_MODELVIEW6_ARB */
+   { 19483, 0x00008727 }, /* GL_MODELVIEW7_ARB */
+   { 19501, 0x00008728 }, /* GL_MODELVIEW8_ARB */
+   { 19519, 0x00008729 }, /* GL_MODELVIEW9_ARB */
+   { 19537, 0x00000BA6 }, /* GL_MODELVIEW_MATRIX */
+   { 19557, 0x00008629 }, /* GL_MODELVIEW_PROJECTION_NV */
+   { 19584, 0x00000BA3 }, /* GL_MODELVIEW_STACK_DEPTH */
+   { 19609, 0x00002100 }, /* GL_MODULATE */
+   { 19621, 0x00008744 }, /* GL_MODULATE_ADD_ATI */
+   { 19641, 0x00008745 }, /* GL_MODULATE_SIGNED_ADD_ATI */
+   { 19668, 0x00008746 }, /* GL_MODULATE_SUBTRACT_ATI */
+   { 19693, 0x00000103 }, /* GL_MULT */
+   { 19701, 0x0000809D }, /* GL_MULTISAMPLE */
+   { 19716, 0x000086B2 }, /* GL_MULTISAMPLE_3DFX */
+   { 19736, 0x0000809D }, /* GL_MULTISAMPLE_ARB */
+   { 19755, 0x20000000 }, /* GL_MULTISAMPLE_BIT */
+   { 19774, 0x20000000 }, /* GL_MULTISAMPLE_BIT_3DFX */
+   { 19798, 0x20000000 }, /* GL_MULTISAMPLE_BIT_ARB */
+   { 19821, 0x00008534 }, /* GL_MULTISAMPLE_FILTER_HINT_NV */
+   { 19851, 0x00002A25 }, /* GL_N3F_V3F */
+   { 19862, 0x00000D70 }, /* GL_NAME_STACK_DEPTH */
+   { 19882, 0x0000150E }, /* GL_NAND */
+   { 19890, 0x00002600 }, /* GL_NEAREST */
+   { 19901, 0x0000844E }, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */
+   { 19932, 0x0000844D }, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */
+   { 19964, 0x00002702 }, /* GL_NEAREST_MIPMAP_LINEAR */
+   { 19989, 0x00002700 }, /* GL_NEAREST_MIPMAP_NEAREST */
+   { 20015, 0x00000200 }, /* GL_NEVER */
+   { 20024, 0x00001102 }, /* GL_NICEST */
+   { 20034, 0x00000000 }, /* GL_NONE */
+   { 20042, 0x00001505 }, /* GL_NOOP */
+   { 20050, 0x00001508 }, /* GL_NOR */
+   { 20057, 0x00000BA1 }, /* GL_NORMALIZE */
+   { 20070, 0x00008075 }, /* GL_NORMAL_ARRAY */
+   { 20086, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING */
+   { 20117, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING_ARB */
+   { 20152, 0x0000808F }, /* GL_NORMAL_ARRAY_POINTER */
+   { 20176, 0x0000807F }, /* GL_NORMAL_ARRAY_STRIDE */
+   { 20199, 0x0000807E }, /* GL_NORMAL_ARRAY_TYPE */
+   { 20220, 0x00008511 }, /* GL_NORMAL_MAP */
+   { 20234, 0x00008511 }, /* GL_NORMAL_MAP_ARB */
+   { 20252, 0x00008511 }, /* GL_NORMAL_MAP_NV */
+   { 20269, 0x00000205 }, /* GL_NOTEQUAL */
+   { 20281, 0x00000000 }, /* GL_NO_ERROR */
+   { 20293, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */
+   { 20327, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB */
+   { 20365, 0x00008B89 }, /* GL_OBJECT_ACTIVE_ATTRIBUTES_ARB */
+   { 20397, 0x00008B8A }, /* GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB */
+   { 20439, 0x00008B86 }, /* GL_OBJECT_ACTIVE_UNIFORMS_ARB */
+   { 20469, 0x00008B87 }, /* GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB */
+   { 20509, 0x00008B85 }, /* GL_OBJECT_ATTACHED_OBJECTS_ARB */
+   { 20540, 0x00008B81 }, /* GL_OBJECT_COMPILE_STATUS_ARB */
+   { 20569, 0x00008B80 }, /* GL_OBJECT_DELETE_STATUS_ARB */
+   { 20597, 0x00008B84 }, /* GL_OBJECT_INFO_LOG_LENGTH_ARB */
+   { 20627, 0x00002401 }, /* GL_OBJECT_LINEAR */
+   { 20644, 0x00008B82 }, /* GL_OBJECT_LINK_STATUS_ARB */
+   { 20670, 0x00002501 }, /* GL_OBJECT_PLANE */
+   { 20686, 0x00008B88 }, /* GL_OBJECT_SHADER_SOURCE_LENGTH_ARB */
+   { 20721, 0x00008B4F }, /* GL_OBJECT_SUBTYPE_ARB */
+   { 20743, 0x00008B4E }, /* GL_OBJECT_TYPE_ARB */
+   { 20762, 0x00008B83 }, /* GL_OBJECT_VALIDATE_STATUS_ARB */
+   { 20792, 0x00008165 }, /* GL_OCCLUSION_TEST_HP */
+   { 20813, 0x00008166 }, /* GL_OCCLUSION_TEST_RESULT_HP */
+   { 20841, 0x00000001 }, /* GL_ONE */
+   { 20848, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA */
+   { 20876, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA_EXT */
+   { 20908, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR */
+   { 20936, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR_EXT */
+   { 20968, 0x00000305 }, /* GL_ONE_MINUS_DST_ALPHA */
+   { 20991, 0x00000307 }, /* GL_ONE_MINUS_DST_COLOR */
+   { 21014, 0x00000303 }, /* GL_ONE_MINUS_SRC_ALPHA */
+   { 21037, 0x00000301 }, /* GL_ONE_MINUS_SRC_COLOR */
+   { 21060, 0x00008598 }, /* GL_OPERAND0_ALPHA */
+   { 21078, 0x00008598 }, /* GL_OPERAND0_ALPHA_ARB */
+   { 21100, 0x00008598 }, /* GL_OPERAND0_ALPHA_EXT */
+   { 21122, 0x00008590 }, /* GL_OPERAND0_RGB */
+   { 21138, 0x00008590 }, /* GL_OPERAND0_RGB_ARB */
+   { 21158, 0x00008590 }, /* GL_OPERAND0_RGB_EXT */
+   { 21178, 0x00008599 }, /* GL_OPERAND1_ALPHA */
+   { 21196, 0x00008599 }, /* GL_OPERAND1_ALPHA_ARB */
+   { 21218, 0x00008599 }, /* GL_OPERAND1_ALPHA_EXT */
+   { 21240, 0x00008591 }, /* GL_OPERAND1_RGB */
+   { 21256, 0x00008591 }, /* GL_OPERAND1_RGB_ARB */
+   { 21276, 0x00008591 }, /* GL_OPERAND1_RGB_EXT */
+   { 21296, 0x0000859A }, /* GL_OPERAND2_ALPHA */
+   { 21314, 0x0000859A }, /* GL_OPERAND2_ALPHA_ARB */
+   { 21336, 0x0000859A }, /* GL_OPERAND2_ALPHA_EXT */
+   { 21358, 0x00008592 }, /* GL_OPERAND2_RGB */
+   { 21374, 0x00008592 }, /* GL_OPERAND2_RGB_ARB */
+   { 21394, 0x00008592 }, /* GL_OPERAND2_RGB_EXT */
+   { 21414, 0x0000859B }, /* GL_OPERAND3_ALPHA_NV */
+   { 21435, 0x00008593 }, /* GL_OPERAND3_RGB_NV */
+   { 21454, 0x00001507 }, /* GL_OR */
+   { 21460, 0x00000A01 }, /* GL_ORDER */
+   { 21469, 0x0000150D }, /* GL_OR_INVERTED */
+   { 21484, 0x0000150B }, /* GL_OR_REVERSE */
+   { 21498, 0x00000505 }, /* GL_OUT_OF_MEMORY */
+   { 21515, 0x00000D05 }, /* GL_PACK_ALIGNMENT */
+   { 21533, 0x0000806C }, /* GL_PACK_IMAGE_HEIGHT */
+   { 21554, 0x00008758 }, /* GL_PACK_INVERT_MESA */
+   { 21574, 0x00000D01 }, /* GL_PACK_LSB_FIRST */
+   { 21592, 0x00000D02 }, /* GL_PACK_ROW_LENGTH */
+   { 21611, 0x0000806B }, /* GL_PACK_SKIP_IMAGES */
+   { 21631, 0x00000D04 }, /* GL_PACK_SKIP_PIXELS */
+   { 21651, 0x00000D03 }, /* GL_PACK_SKIP_ROWS */
+   { 21669, 0x00000D00 }, /* GL_PACK_SWAP_BYTES */
+   { 21688, 0x00008B92 }, /* GL_PALETTE4_R5_G6_B5_OES */
+   { 21713, 0x00008B94 }, /* GL_PALETTE4_RGB5_A1_OES */
+   { 21737, 0x00008B90 }, /* GL_PALETTE4_RGB8_OES */
+   { 21758, 0x00008B93 }, /* GL_PALETTE4_RGBA4_OES */
+   { 21780, 0x00008B91 }, /* GL_PALETTE4_RGBA8_OES */
+   { 21802, 0x00008B97 }, /* GL_PALETTE8_R5_G6_B5_OES */
+   { 21827, 0x00008B99 }, /* GL_PALETTE8_RGB5_A1_OES */
+   { 21851, 0x00008B95 }, /* GL_PALETTE8_RGB8_OES */
+   { 21872, 0x00008B98 }, /* GL_PALETTE8_RGBA4_OES */
+   { 21894, 0x00008B96 }, /* GL_PALETTE8_RGBA8_OES */
+   { 21916, 0x00000700 }, /* GL_PASS_THROUGH_TOKEN */
+   { 21938, 0x00000C50 }, /* GL_PERSPECTIVE_CORRECTION_HINT */
+   { 21969, 0x00000C79 }, /* GL_PIXEL_MAP_A_TO_A */
+   { 21989, 0x00000CB9 }, /* GL_PIXEL_MAP_A_TO_A_SIZE */
+   { 22014, 0x00000C78 }, /* GL_PIXEL_MAP_B_TO_B */
+   { 22034, 0x00000CB8 }, /* GL_PIXEL_MAP_B_TO_B_SIZE */
+   { 22059, 0x00000C77 }, /* GL_PIXEL_MAP_G_TO_G */
+   { 22079, 0x00000CB7 }, /* GL_PIXEL_MAP_G_TO_G_SIZE */
+   { 22104, 0x00000C75 }, /* GL_PIXEL_MAP_I_TO_A */
+   { 22124, 0x00000CB5 }, /* GL_PIXEL_MAP_I_TO_A_SIZE */
+   { 22149, 0x00000C74 }, /* GL_PIXEL_MAP_I_TO_B */
+   { 22169, 0x00000CB4 }, /* GL_PIXEL_MAP_I_TO_B_SIZE */
+   { 22194, 0x00000C73 }, /* GL_PIXEL_MAP_I_TO_G */
+   { 22214, 0x00000CB3 }, /* GL_PIXEL_MAP_I_TO_G_SIZE */
+   { 22239, 0x00000C70 }, /* GL_PIXEL_MAP_I_TO_I */
+   { 22259, 0x00000CB0 }, /* GL_PIXEL_MAP_I_TO_I_SIZE */
+   { 22284, 0x00000C72 }, /* GL_PIXEL_MAP_I_TO_R */
+   { 22304, 0x00000CB2 }, /* GL_PIXEL_MAP_I_TO_R_SIZE */
+   { 22329, 0x00000C76 }, /* GL_PIXEL_MAP_R_TO_R */
+   { 22349, 0x00000CB6 }, /* GL_PIXEL_MAP_R_TO_R_SIZE */
+   { 22374, 0x00000C71 }, /* GL_PIXEL_MAP_S_TO_S */
+   { 22394, 0x00000CB1 }, /* GL_PIXEL_MAP_S_TO_S_SIZE */
+   { 22419, 0x00000020 }, /* GL_PIXEL_MODE_BIT */
+   { 22437, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING_EXT */
+   { 22470, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER_EXT */
+   { 22495, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING_EXT */
+   { 22530, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER_EXT */
+   { 22557, 0x00001B00 }, /* GL_POINT */
+   { 22566, 0x00000000 }, /* GL_POINTS */
+   { 22576, 0x00000002 }, /* GL_POINT_BIT */
+   { 22589, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION */
+   { 22619, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_ARB */
+   { 22653, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_EXT */
+   { 22687, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_SGIS */
+   { 22722, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE */
+   { 22751, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_ARB */
+   { 22784, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_EXT */
+   { 22817, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_SGIS */
+   { 22851, 0x00000B11 }, /* GL_POINT_SIZE */
+   { 22865, 0x00000B13 }, /* GL_POINT_SIZE_GRANULARITY */
+   { 22891, 0x00008127 }, /* GL_POINT_SIZE_MAX */
+   { 22909, 0x00008127 }, /* GL_POINT_SIZE_MAX_ARB */
+   { 22931, 0x00008127 }, /* GL_POINT_SIZE_MAX_EXT */
+   { 22953, 0x00008127 }, /* GL_POINT_SIZE_MAX_SGIS */
+   { 22976, 0x00008126 }, /* GL_POINT_SIZE_MIN */
+   { 22994, 0x00008126 }, /* GL_POINT_SIZE_MIN_ARB */
+   { 23016, 0x00008126 }, /* GL_POINT_SIZE_MIN_EXT */
+   { 23038, 0x00008126 }, /* GL_POINT_SIZE_MIN_SGIS */
+   { 23061, 0x00000B12 }, /* GL_POINT_SIZE_RANGE */
+   { 23081, 0x00000B10 }, /* GL_POINT_SMOOTH */
+   { 23097, 0x00000C51 }, /* GL_POINT_SMOOTH_HINT */
+   { 23118, 0x00008861 }, /* GL_POINT_SPRITE */
+   { 23134, 0x00008861 }, /* GL_POINT_SPRITE_ARB */
+   { 23154, 0x00008CA0 }, /* GL_POINT_SPRITE_COORD_ORIGIN */
+   { 23183, 0x00008861 }, /* GL_POINT_SPRITE_NV */
+   { 23202, 0x00008863 }, /* GL_POINT_SPRITE_R_MODE_NV */
+   { 23228, 0x00000701 }, /* GL_POINT_TOKEN */
+   { 23243, 0x00000009 }, /* GL_POLYGON */
+   { 23254, 0x00000008 }, /* GL_POLYGON_BIT */
+   { 23269, 0x00000B40 }, /* GL_POLYGON_MODE */
+   { 23285, 0x00008039 }, /* GL_POLYGON_OFFSET_BIAS */
+   { 23308, 0x00008038 }, /* GL_POLYGON_OFFSET_FACTOR */
+   { 23333, 0x00008037 }, /* GL_POLYGON_OFFSET_FILL */
+   { 23356, 0x00002A02 }, /* GL_POLYGON_OFFSET_LINE */
+   { 23379, 0x00002A01 }, /* GL_POLYGON_OFFSET_POINT */
+   { 23403, 0x00002A00 }, /* GL_POLYGON_OFFSET_UNITS */
+   { 23427, 0x00000B41 }, /* GL_POLYGON_SMOOTH */
+   { 23445, 0x00000C53 }, /* GL_POLYGON_SMOOTH_HINT */
+   { 23468, 0x00000B42 }, /* GL_POLYGON_STIPPLE */
+   { 23487, 0x00000010 }, /* GL_POLYGON_STIPPLE_BIT */
+   { 23510, 0x00000703 }, /* GL_POLYGON_TOKEN */
+   { 23527, 0x00001203 }, /* GL_POSITION */
+   { 23539, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */
+   { 23571, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI */
+   { 23607, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */
+   { 23640, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI */
+   { 23677, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */
+   { 23708, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI */
+   { 23743, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */
+   { 23775, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI */
+   { 23811, 0x000080D2 }, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */
+   { 23844, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */
+   { 23876, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI */
+   { 23912, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */
+   { 23945, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI */
+   { 23982, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS */
+   { 24012, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS_SGI */
+   { 24046, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE */
+   { 24077, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE_SGI */
+   { 24112, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS */
+   { 24143, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS_EXT */
+   { 24178, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE */
+   { 24210, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE_EXT */
+   { 24246, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS */
+   { 24276, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS_EXT */
+   { 24310, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE */
+   { 24341, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE_EXT */
+   { 24376, 0x000080D1 }, /* GL_POST_CONVOLUTION_COLOR_TABLE */
+   { 24408, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS */
+   { 24439, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS_EXT */
+   { 24474, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE */
+   { 24506, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE_EXT */
+   { 24542, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS */
+   { 24571, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS_EXT */
+   { 24604, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE */
+   { 24634, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE_EXT */
+   { 24668, 0x0000817B }, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */
+   { 24707, 0x00008179 }, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */
+   { 24740, 0x0000817C }, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */
+   { 24780, 0x0000817A }, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */
+   { 24814, 0x00008578 }, /* GL_PREVIOUS */
+   { 24826, 0x00008578 }, /* GL_PREVIOUS_ARB */
+   { 24842, 0x00008578 }, /* GL_PREVIOUS_EXT */
+   { 24858, 0x00008577 }, /* GL_PRIMARY_COLOR */
+   { 24875, 0x00008577 }, /* GL_PRIMARY_COLOR_ARB */
+   { 24896, 0x00008577 }, /* GL_PRIMARY_COLOR_EXT */
+   { 24917, 0x000088B0 }, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */
+   { 24950, 0x00008805 }, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */
+   { 24982, 0x000088AC }, /* GL_PROGRAM_ATTRIBS_ARB */
+   { 25005, 0x00008677 }, /* GL_PROGRAM_BINDING_ARB */
+   { 25028, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_ARB */
+   { 25058, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_NV */
+   { 25087, 0x00008874 }, /* GL_PROGRAM_ERROR_STRING_ARB */
+   { 25115, 0x00008876 }, /* GL_PROGRAM_FORMAT_ARB */
+   { 25137, 0x00008875 }, /* GL_PROGRAM_FORMAT_ASCII_ARB */
+   { 25165, 0x000088A0 }, /* GL_PROGRAM_INSTRUCTIONS_ARB */
+   { 25193, 0x00008627 }, /* GL_PROGRAM_LENGTH_ARB */
+   { 25215, 0x00008627 }, /* GL_PROGRAM_LENGTH_NV */
+   { 25236, 0x000088B2 }, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
+   { 25276, 0x00008808 }, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
+   { 25315, 0x000088AE }, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */
+   { 25345, 0x000088A2 }, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
+   { 25380, 0x000088AA }, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */
+   { 25413, 0x000088A6 }, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */
+   { 25447, 0x0000880A }, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
+   { 25486, 0x00008809 }, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
+   { 25525, 0x00008B40 }, /* GL_PROGRAM_OBJECT_ARB */
+   { 25547, 0x000088A8 }, /* GL_PROGRAM_PARAMETERS_ARB */
+   { 25573, 0x00008644 }, /* GL_PROGRAM_PARAMETER_NV */
+   { 25597, 0x00008647 }, /* GL_PROGRAM_RESIDENT_NV */
+   { 25620, 0x00008628 }, /* GL_PROGRAM_STRING_ARB */
+   { 25642, 0x00008628 }, /* GL_PROGRAM_STRING_NV */
+   { 25663, 0x00008646 }, /* GL_PROGRAM_TARGET_NV */
+   { 25684, 0x000088A4 }, /* GL_PROGRAM_TEMPORARIES_ARB */
+   { 25711, 0x00008807 }, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */
+   { 25743, 0x00008806 }, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */
+   { 25775, 0x000088B6 }, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */
+   { 25810, 0x00001701 }, /* GL_PROJECTION */
+   { 25824, 0x00000BA7 }, /* GL_PROJECTION_MATRIX */
+   { 25845, 0x00000BA4 }, /* GL_PROJECTION_STACK_DEPTH */
+   { 25871, 0x000080D3 }, /* GL_PROXY_COLOR_TABLE */
+   { 25892, 0x00008025 }, /* GL_PROXY_HISTOGRAM */
+   { 25911, 0x00008025 }, /* GL_PROXY_HISTOGRAM_EXT */
+   { 25934, 0x000080D5 }, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */
+   { 25973, 0x000080D4 }, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */
+   { 26011, 0x00008063 }, /* GL_PROXY_TEXTURE_1D */
+   { 26031, 0x00008C19 }, /* GL_PROXY_TEXTURE_1D_ARRAY_EXT */
+   { 26061, 0x00008063 }, /* GL_PROXY_TEXTURE_1D_EXT */
+   { 26085, 0x00008064 }, /* GL_PROXY_TEXTURE_2D */
+   { 26105, 0x00008C1B }, /* GL_PROXY_TEXTURE_2D_ARRAY_EXT */
+   { 26135, 0x00008064 }, /* GL_PROXY_TEXTURE_2D_EXT */
+   { 26159, 0x00008070 }, /* GL_PROXY_TEXTURE_3D */
+   { 26179, 0x000080BD }, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */
+   { 26212, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP */
+   { 26238, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP_ARB */
+   { 26268, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */
+   { 26299, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_NV */
+   { 26329, 0x00002003 }, /* GL_Q */
+   { 26334, 0x00001209 }, /* GL_QUADRATIC_ATTENUATION */
+   { 26359, 0x00000007 }, /* GL_QUADS */
+   { 26368, 0x00008614 }, /* GL_QUAD_MESH_SUN */
+   { 26385, 0x00000008 }, /* GL_QUAD_STRIP */
+   { 26399, 0x00008864 }, /* GL_QUERY_COUNTER_BITS */
+   { 26421, 0x00008864 }, /* GL_QUERY_COUNTER_BITS_ARB */
+   { 26447, 0x00008866 }, /* GL_QUERY_RESULT */
+   { 26463, 0x00008866 }, /* GL_QUERY_RESULT_ARB */
+   { 26483, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE */
+   { 26509, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE_ARB */
+   { 26539, 0x00002002 }, /* GL_R */
+   { 26544, 0x00002A10 }, /* GL_R3_G3_B2 */
+   { 26556, 0x00019262 }, /* GL_RASTER_POSITION_UNCLIPPED_IBM */
+   { 26589, 0x00000C02 }, /* GL_READ_BUFFER */
+   { 26604, 0x00008CAA }, /* GL_READ_FRAMEBUFFER_BINDING_EXT */
+   { 26636, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER_EXT */
+   { 26660, 0x000088B8 }, /* GL_READ_ONLY */
+   { 26673, 0x000088B8 }, /* GL_READ_ONLY_ARB */
+   { 26690, 0x000088BA }, /* GL_READ_WRITE */
+   { 26704, 0x000088BA }, /* GL_READ_WRITE_ARB */
+   { 26722, 0x00001903 }, /* GL_RED */
+   { 26729, 0x00008016 }, /* GL_REDUCE */
+   { 26739, 0x00008016 }, /* GL_REDUCE_EXT */
+   { 26753, 0x00000D15 }, /* GL_RED_BIAS */
+   { 26765, 0x00000D52 }, /* GL_RED_BITS */
+   { 26777, 0x00000D14 }, /* GL_RED_SCALE */
+   { 26790, 0x00008512 }, /* GL_REFLECTION_MAP */
+   { 26808, 0x00008512 }, /* GL_REFLECTION_MAP_ARB */
+   { 26830, 0x00008512 }, /* GL_REFLECTION_MAP_NV */
+   { 26851, 0x00001C00 }, /* GL_RENDER */
+   { 26861, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING_EXT */
+   { 26889, 0x00008D41 }, /* GL_RENDERBUFFER_EXT */
+   { 26909, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT_EXT */
+   { 26936, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT_EXT */
+   { 26972, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH_EXT */
+   { 26998, 0x00001F01 }, /* GL_RENDERER */
+   { 27010, 0x00000C40 }, /* GL_RENDER_MODE */
+   { 27025, 0x00002901 }, /* GL_REPEAT */
+   { 27035, 0x00001E01 }, /* GL_REPLACE */
+   { 27046, 0x00008062 }, /* GL_REPLACE_EXT */
+   { 27061, 0x00008153 }, /* GL_REPLICATE_BORDER_HP */
+   { 27084, 0x0000803A }, /* GL_RESCALE_NORMAL */
+   { 27102, 0x0000803A }, /* GL_RESCALE_NORMAL_EXT */
+   { 27124, 0x00000102 }, /* GL_RETURN */
+   { 27134, 0x00001907 }, /* GL_RGB */
+   { 27141, 0x00008052 }, /* GL_RGB10 */
+   { 27150, 0x00008059 }, /* GL_RGB10_A2 */
+   { 27162, 0x00008059 }, /* GL_RGB10_A2_EXT */
+   { 27178, 0x00008052 }, /* GL_RGB10_EXT */
+   { 27191, 0x00008053 }, /* GL_RGB12 */
+   { 27200, 0x00008053 }, /* GL_RGB12_EXT */
+   { 27213, 0x00008054 }, /* GL_RGB16 */
+   { 27222, 0x00008054 }, /* GL_RGB16_EXT */
+   { 27235, 0x0000804E }, /* GL_RGB2_EXT */
+   { 27247, 0x0000804F }, /* GL_RGB4 */
+   { 27255, 0x0000804F }, /* GL_RGB4_EXT */
+   { 27267, 0x000083A1 }, /* GL_RGB4_S3TC */
+   { 27280, 0x00008050 }, /* GL_RGB5 */
+   { 27288, 0x00008057 }, /* GL_RGB5_A1 */
+   { 27299, 0x00008057 }, /* GL_RGB5_A1_EXT */
+   { 27314, 0x00008050 }, /* GL_RGB5_EXT */
+   { 27326, 0x00008051 }, /* GL_RGB8 */
+   { 27334, 0x00008051 }, /* GL_RGB8_EXT */
+   { 27346, 0x00001908 }, /* GL_RGBA */
+   { 27354, 0x0000805A }, /* GL_RGBA12 */
+   { 27364, 0x0000805A }, /* GL_RGBA12_EXT */
+   { 27378, 0x0000805B }, /* GL_RGBA16 */
+   { 27388, 0x0000805B }, /* GL_RGBA16_EXT */
+   { 27402, 0x00008055 }, /* GL_RGBA2 */
+   { 27411, 0x00008055 }, /* GL_RGBA2_EXT */
+   { 27424, 0x00008056 }, /* GL_RGBA4 */
+   { 27433, 0x000083A5 }, /* GL_RGBA4_DXT5_S3TC */
+   { 27452, 0x00008056 }, /* GL_RGBA4_EXT */
+   { 27465, 0x000083A3 }, /* GL_RGBA4_S3TC */
+   { 27479, 0x00008058 }, /* GL_RGBA8 */
+   { 27488, 0x00008058 }, /* GL_RGBA8_EXT */
+   { 27501, 0x000083A4 }, /* GL_RGBA_DXT5_S3TC */
+   { 27519, 0x00000C31 }, /* GL_RGBA_MODE */
+   { 27532, 0x000083A2 }, /* GL_RGBA_S3TC */
+   { 27545, 0x000083A0 }, /* GL_RGB_S3TC */
+   { 27557, 0x00008573 }, /* GL_RGB_SCALE */
+   { 27570, 0x00008573 }, /* GL_RGB_SCALE_ARB */
+   { 27587, 0x00008573 }, /* GL_RGB_SCALE_EXT */
+   { 27604, 0x00000407 }, /* GL_RIGHT */
+   { 27613, 0x00002000 }, /* GL_S */
+   { 27618, 0x00008B5D }, /* GL_SAMPLER_1D */
+   { 27632, 0x00008B61 }, /* GL_SAMPLER_1D_SHADOW */
+   { 27653, 0x00008B5E }, /* GL_SAMPLER_2D */
+   { 27667, 0x00008B62 }, /* GL_SAMPLER_2D_SHADOW */
+   { 27688, 0x00008B5F }, /* GL_SAMPLER_3D */
+   { 27702, 0x00008B60 }, /* GL_SAMPLER_CUBE */
+   { 27718, 0x000080A9 }, /* GL_SAMPLES */
+   { 27729, 0x000086B4 }, /* GL_SAMPLES_3DFX */
+   { 27745, 0x000080A9 }, /* GL_SAMPLES_ARB */
+   { 27760, 0x00008914 }, /* GL_SAMPLES_PASSED */
+   { 27778, 0x00008914 }, /* GL_SAMPLES_PASSED_ARB */
+   { 27800, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE */
+   { 27828, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE_ARB */
+   { 27860, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE */
+   { 27883, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE_ARB */
+   { 27910, 0x000080A8 }, /* GL_SAMPLE_BUFFERS */
+   { 27928, 0x000086B3 }, /* GL_SAMPLE_BUFFERS_3DFX */
+   { 27951, 0x000080A8 }, /* GL_SAMPLE_BUFFERS_ARB */
+   { 27973, 0x000080A0 }, /* GL_SAMPLE_COVERAGE */
+   { 27992, 0x000080A0 }, /* GL_SAMPLE_COVERAGE_ARB */
+   { 28015, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT */
+   { 28041, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT_ARB */
+   { 28071, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE */
+   { 28096, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE_ARB */
+   { 28125, 0x00080000 }, /* GL_SCISSOR_BIT */
+   { 28140, 0x00000C10 }, /* GL_SCISSOR_BOX */
+   { 28155, 0x00000C11 }, /* GL_SCISSOR_TEST */
+   { 28171, 0x0000845E }, /* GL_SECONDARY_COLOR_ARRAY */
+   { 28196, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */
+   { 28236, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB */
+   { 28280, 0x0000845D }, /* GL_SECONDARY_COLOR_ARRAY_POINTER */
+   { 28313, 0x0000845A }, /* GL_SECONDARY_COLOR_ARRAY_SIZE */
+   { 28343, 0x0000845C }, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */
+   { 28375, 0x0000845B }, /* GL_SECONDARY_COLOR_ARRAY_TYPE */
+   { 28405, 0x00001C02 }, /* GL_SELECT */
+   { 28415, 0x00000DF3 }, /* GL_SELECTION_BUFFER_POINTER */
+   { 28443, 0x00000DF4 }, /* GL_SELECTION_BUFFER_SIZE */
+   { 28468, 0x00008012 }, /* GL_SEPARABLE_2D */
+   { 28484, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR */
+   { 28511, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR_EXT */
+   { 28542, 0x0000150F }, /* GL_SET */
+   { 28549, 0x00008B48 }, /* GL_SHADER_OBJECT_ARB */
+   { 28570, 0x00008B88 }, /* GL_SHADER_SOURCE_LENGTH */
+   { 28594, 0x00008B4F }, /* GL_SHADER_TYPE */
+   { 28609, 0x00000B54 }, /* GL_SHADE_MODEL */
+   { 28624, 0x00008B8C }, /* GL_SHADING_LANGUAGE_VERSION */
+   { 28652, 0x000080BF }, /* GL_SHADOW_AMBIENT_SGIX */
+   { 28675, 0x000081FB }, /* GL_SHARED_TEXTURE_PALETTE_EXT */
+   { 28705, 0x00001601 }, /* GL_SHININESS */
+   { 28718, 0x00001402 }, /* GL_SHORT */
+   { 28727, 0x000081F9 }, /* GL_SINGLE_COLOR */
+   { 28743, 0x000081F9 }, /* GL_SINGLE_COLOR_EXT */
+   { 28763, 0x000085CC }, /* GL_SLICE_ACCUM_SUN */
+   { 28782, 0x00001D01 }, /* GL_SMOOTH */
+   { 28792, 0x00000B23 }, /* GL_SMOOTH_LINE_WIDTH_GRANULARITY */
+   { 28825, 0x00000B22 }, /* GL_SMOOTH_LINE_WIDTH_RANGE */
+   { 28852, 0x00000B13 }, /* GL_SMOOTH_POINT_SIZE_GRANULARITY */
+   { 28885, 0x00000B12 }, /* GL_SMOOTH_POINT_SIZE_RANGE */
+   { 28912, 0x00008588 }, /* GL_SOURCE0_ALPHA */
+   { 28929, 0x00008588 }, /* GL_SOURCE0_ALPHA_ARB */
+   { 28950, 0x00008588 }, /* GL_SOURCE0_ALPHA_EXT */
+   { 28971, 0x00008580 }, /* GL_SOURCE0_RGB */
+   { 28986, 0x00008580 }, /* GL_SOURCE0_RGB_ARB */
+   { 29005, 0x00008580 }, /* GL_SOURCE0_RGB_EXT */
+   { 29024, 0x00008589 }, /* GL_SOURCE1_ALPHA */
+   { 29041, 0x00008589 }, /* GL_SOURCE1_ALPHA_ARB */
+   { 29062, 0x00008589 }, /* GL_SOURCE1_ALPHA_EXT */
+   { 29083, 0x00008581 }, /* GL_SOURCE1_RGB */
+   { 29098, 0x00008581 }, /* GL_SOURCE1_RGB_ARB */
+   { 29117, 0x00008581 }, /* GL_SOURCE1_RGB_EXT */
+   { 29136, 0x0000858A }, /* GL_SOURCE2_ALPHA */
+   { 29153, 0x0000858A }, /* GL_SOURCE2_ALPHA_ARB */
+   { 29174, 0x0000858A }, /* GL_SOURCE2_ALPHA_EXT */
+   { 29195, 0x00008582 }, /* GL_SOURCE2_RGB */
+   { 29210, 0x00008582 }, /* GL_SOURCE2_RGB_ARB */
+   { 29229, 0x00008582 }, /* GL_SOURCE2_RGB_EXT */
+   { 29248, 0x0000858B }, /* GL_SOURCE3_ALPHA_NV */
+   { 29268, 0x00008583 }, /* GL_SOURCE3_RGB_NV */
+   { 29286, 0x00001202 }, /* GL_SPECULAR */
+   { 29298, 0x00002402 }, /* GL_SPHERE_MAP */
+   { 29312, 0x00001206 }, /* GL_SPOT_CUTOFF */
+   { 29327, 0x00001204 }, /* GL_SPOT_DIRECTION */
+   { 29345, 0x00001205 }, /* GL_SPOT_EXPONENT */
+   { 29362, 0x00008588 }, /* GL_SRC0_ALPHA */
+   { 29376, 0x00008580 }, /* GL_SRC0_RGB */
+   { 29388, 0x00008589 }, /* GL_SRC1_ALPHA */
+   { 29402, 0x00008581 }, /* GL_SRC1_RGB */
+   { 29414, 0x0000858A }, /* GL_SRC2_ALPHA */
+   { 29428, 0x00008582 }, /* GL_SRC2_RGB */
+   { 29440, 0x00000302 }, /* GL_SRC_ALPHA */
+   { 29453, 0x00000308 }, /* GL_SRC_ALPHA_SATURATE */
+   { 29475, 0x00000300 }, /* GL_SRC_COLOR */
+   { 29488, 0x00000503 }, /* GL_STACK_OVERFLOW */
+   { 29506, 0x00000504 }, /* GL_STACK_UNDERFLOW */
+   { 29525, 0x000088E6 }, /* GL_STATIC_COPY */
+   { 29540, 0x000088E6 }, /* GL_STATIC_COPY_ARB */
+   { 29559, 0x000088E4 }, /* GL_STATIC_DRAW */
+   { 29574, 0x000088E4 }, /* GL_STATIC_DRAW_ARB */
+   { 29593, 0x000088E5 }, /* GL_STATIC_READ */
+   { 29608, 0x000088E5 }, /* GL_STATIC_READ_ARB */
+   { 29627, 0x00001802 }, /* GL_STENCIL */
+   { 29638, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT_EXT */
+   { 29664, 0x00008801 }, /* GL_STENCIL_BACK_FAIL */
+   { 29685, 0x00008801 }, /* GL_STENCIL_BACK_FAIL_ATI */
+   { 29710, 0x00008800 }, /* GL_STENCIL_BACK_FUNC */
+   { 29731, 0x00008800 }, /* GL_STENCIL_BACK_FUNC_ATI */
+   { 29756, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */
+   { 29788, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI */
+   { 29824, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */
+   { 29856, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI */
+   { 29892, 0x00008CA3 }, /* GL_STENCIL_BACK_REF */
+   { 29912, 0x00008CA4 }, /* GL_STENCIL_BACK_VALUE_MASK */
+   { 29939, 0x00008CA5 }, /* GL_STENCIL_BACK_WRITEMASK */
+   { 29965, 0x00000D57 }, /* GL_STENCIL_BITS */
+   { 29981, 0x00000400 }, /* GL_STENCIL_BUFFER_BIT */
+   { 30003, 0x00000B91 }, /* GL_STENCIL_CLEAR_VALUE */
+   { 30026, 0x00000B94 }, /* GL_STENCIL_FAIL */
+   { 30042, 0x00000B92 }, /* GL_STENCIL_FUNC */
+   { 30058, 0x00001901 }, /* GL_STENCIL_INDEX */
+   { 30075, 0x00008D49 }, /* GL_STENCIL_INDEX16_EXT */
+   { 30098, 0x00008D46 }, /* GL_STENCIL_INDEX1_EXT */
+   { 30120, 0x00008D47 }, /* GL_STENCIL_INDEX4_EXT */
+   { 30142, 0x00008D48 }, /* GL_STENCIL_INDEX8_EXT */
+   { 30164, 0x00008D45 }, /* GL_STENCIL_INDEX_EXT */
+   { 30185, 0x00000B95 }, /* GL_STENCIL_PASS_DEPTH_FAIL */
+   { 30212, 0x00000B96 }, /* GL_STENCIL_PASS_DEPTH_PASS */
+   { 30239, 0x00000B97 }, /* GL_STENCIL_REF */
+   { 30254, 0x00000B90 }, /* GL_STENCIL_TEST */
+   { 30270, 0x00008910 }, /* GL_STENCIL_TEST_TWO_SIDE_EXT */
+   { 30299, 0x00000B93 }, /* GL_STENCIL_VALUE_MASK */
+   { 30321, 0x00000B98 }, /* GL_STENCIL_WRITEMASK */
+   { 30342, 0x00000C33 }, /* GL_STEREO */
+   { 30352, 0x000088E2 }, /* GL_STREAM_COPY */
+   { 30367, 0x000088E2 }, /* GL_STREAM_COPY_ARB */
+   { 30386, 0x000088E0 }, /* GL_STREAM_DRAW */
+   { 30401, 0x000088E0 }, /* GL_STREAM_DRAW_ARB */
+   { 30420, 0x000088E1 }, /* GL_STREAM_READ */
+   { 30435, 0x000088E1 }, /* GL_STREAM_READ_ARB */
+   { 30454, 0x00000D50 }, /* GL_SUBPIXEL_BITS */
+   { 30471, 0x000084E7 }, /* GL_SUBTRACT */
+   { 30483, 0x000084E7 }, /* GL_SUBTRACT_ARB */
+   { 30499, 0x00002001 }, /* GL_T */
+   { 30504, 0x00002A2A }, /* GL_T2F_C3F_V3F */
+   { 30519, 0x00002A2C }, /* GL_T2F_C4F_N3F_V3F */
+   { 30538, 0x00002A29 }, /* GL_T2F_C4UB_V3F */
+   { 30554, 0x00002A2B }, /* GL_T2F_N3F_V3F */
+   { 30569, 0x00002A27 }, /* GL_T2F_V3F */
+   { 30580, 0x00002A2D }, /* GL_T4F_C4F_N3F_V4F */
+   { 30599, 0x00002A28 }, /* GL_T4F_V4F */
+   { 30610, 0x00008031 }, /* GL_TABLE_TOO_LARGE_EXT */
+   { 30633, 0x00001702 }, /* GL_TEXTURE */
+   { 30644, 0x000084C0 }, /* GL_TEXTURE0 */
+   { 30656, 0x000084C0 }, /* GL_TEXTURE0_ARB */
+   { 30672, 0x000084C1 }, /* GL_TEXTURE1 */
+   { 30684, 0x000084CA }, /* GL_TEXTURE10 */
+   { 30697, 0x000084CA }, /* GL_TEXTURE10_ARB */
+   { 30714, 0x000084CB }, /* GL_TEXTURE11 */
+   { 30727, 0x000084CB }, /* GL_TEXTURE11_ARB */
+   { 30744, 0x000084CC }, /* GL_TEXTURE12 */
+   { 30757, 0x000084CC }, /* GL_TEXTURE12_ARB */
+   { 30774, 0x000084CD }, /* GL_TEXTURE13 */
+   { 30787, 0x000084CD }, /* GL_TEXTURE13_ARB */
+   { 30804, 0x000084CE }, /* GL_TEXTURE14 */
+   { 30817, 0x000084CE }, /* GL_TEXTURE14_ARB */
+   { 30834, 0x000084CF }, /* GL_TEXTURE15 */
+   { 30847, 0x000084CF }, /* GL_TEXTURE15_ARB */
+   { 30864, 0x000084D0 }, /* GL_TEXTURE16 */
+   { 30877, 0x000084D0 }, /* GL_TEXTURE16_ARB */
+   { 30894, 0x000084D1 }, /* GL_TEXTURE17 */
+   { 30907, 0x000084D1 }, /* GL_TEXTURE17_ARB */
+   { 30924, 0x000084D2 }, /* GL_TEXTURE18 */
+   { 30937, 0x000084D2 }, /* GL_TEXTURE18_ARB */
+   { 30954, 0x000084D3 }, /* GL_TEXTURE19 */
+   { 30967, 0x000084D3 }, /* GL_TEXTURE19_ARB */
+   { 30984, 0x000084C1 }, /* GL_TEXTURE1_ARB */
+   { 31000, 0x000084C2 }, /* GL_TEXTURE2 */
+   { 31012, 0x000084D4 }, /* GL_TEXTURE20 */
+   { 31025, 0x000084D4 }, /* GL_TEXTURE20_ARB */
+   { 31042, 0x000084D5 }, /* GL_TEXTURE21 */
+   { 31055, 0x000084D5 }, /* GL_TEXTURE21_ARB */
+   { 31072, 0x000084D6 }, /* GL_TEXTURE22 */
+   { 31085, 0x000084D6 }, /* GL_TEXTURE22_ARB */
+   { 31102, 0x000084D7 }, /* GL_TEXTURE23 */
+   { 31115, 0x000084D7 }, /* GL_TEXTURE23_ARB */
+   { 31132, 0x000084D8 }, /* GL_TEXTURE24 */
+   { 31145, 0x000084D8 }, /* GL_TEXTURE24_ARB */
+   { 31162, 0x000084D9 }, /* GL_TEXTURE25 */
+   { 31175, 0x000084D9 }, /* GL_TEXTURE25_ARB */
+   { 31192, 0x000084DA }, /* GL_TEXTURE26 */
+   { 31205, 0x000084DA }, /* GL_TEXTURE26_ARB */
+   { 31222, 0x000084DB }, /* GL_TEXTURE27 */
+   { 31235, 0x000084DB }, /* GL_TEXTURE27_ARB */
+   { 31252, 0x000084DC }, /* GL_TEXTURE28 */
+   { 31265, 0x000084DC }, /* GL_TEXTURE28_ARB */
+   { 31282, 0x000084DD }, /* GL_TEXTURE29 */
+   { 31295, 0x000084DD }, /* GL_TEXTURE29_ARB */
+   { 31312, 0x000084C2 }, /* GL_TEXTURE2_ARB */
+   { 31328, 0x000084C3 }, /* GL_TEXTURE3 */
+   { 31340, 0x000084DE }, /* GL_TEXTURE30 */
+   { 31353, 0x000084DE }, /* GL_TEXTURE30_ARB */
+   { 31370, 0x000084DF }, /* GL_TEXTURE31 */
+   { 31383, 0x000084DF }, /* GL_TEXTURE31_ARB */
+   { 31400, 0x000084C3 }, /* GL_TEXTURE3_ARB */
+   { 31416, 0x000084C4 }, /* GL_TEXTURE4 */
+   { 31428, 0x000084C4 }, /* GL_TEXTURE4_ARB */
+   { 31444, 0x000084C5 }, /* GL_TEXTURE5 */
+   { 31456, 0x000084C5 }, /* GL_TEXTURE5_ARB */
+   { 31472, 0x000084C6 }, /* GL_TEXTURE6 */
+   { 31484, 0x000084C6 }, /* GL_TEXTURE6_ARB */
+   { 31500, 0x000084C7 }, /* GL_TEXTURE7 */
+   { 31512, 0x000084C7 }, /* GL_TEXTURE7_ARB */
+   { 31528, 0x000084C8 }, /* GL_TEXTURE8 */
+   { 31540, 0x000084C8 }, /* GL_TEXTURE8_ARB */
+   { 31556, 0x000084C9 }, /* GL_TEXTURE9 */
+   { 31568, 0x000084C9 }, /* GL_TEXTURE9_ARB */
+   { 31584, 0x00000DE0 }, /* GL_TEXTURE_1D */
+   { 31598, 0x00008C18 }, /* GL_TEXTURE_1D_ARRAY_EXT */
+   { 31622, 0x00000DE1 }, /* GL_TEXTURE_2D */
+   { 31636, 0x00008C1A }, /* GL_TEXTURE_2D_ARRAY_EXT */
+   { 31660, 0x0000806F }, /* GL_TEXTURE_3D */
+   { 31674, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE */
+   { 31696, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE_EXT */
+   { 31722, 0x0000813C }, /* GL_TEXTURE_BASE_LEVEL */
+   { 31744, 0x00008068 }, /* GL_TEXTURE_BINDING_1D */
+   { 31766, 0x00008C1C }, /* GL_TEXTURE_BINDING_1D_ARRAY_EXT */
+   { 31798, 0x00008069 }, /* GL_TEXTURE_BINDING_2D */
+   { 31820, 0x00008C1D }, /* GL_TEXTURE_BINDING_2D_ARRAY_EXT */
+   { 31852, 0x0000806A }, /* GL_TEXTURE_BINDING_3D */
+   { 31874, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP */
+   { 31902, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP_ARB */
+   { 31934, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */
+   { 31967, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_NV */
+   { 31999, 0x00040000 }, /* GL_TEXTURE_BIT */
+   { 32014, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE */
+   { 32035, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE_EXT */
+   { 32060, 0x00001005 }, /* GL_TEXTURE_BORDER */
+   { 32078, 0x00001004 }, /* GL_TEXTURE_BORDER_COLOR */
+   { 32102, 0x00008171 }, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */
+   { 32133, 0x00008176 }, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */
+   { 32163, 0x00008172 }, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */
+   { 32193, 0x00008175 }, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */
+   { 32228, 0x00008173 }, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */
+   { 32259, 0x00008174 }, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */
+   { 32297, 0x000080BC }, /* GL_TEXTURE_COLOR_TABLE_SGI */
+   { 32324, 0x000081EF }, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */
+   { 32356, 0x000080BF }, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
+   { 32390, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC */
+   { 32414, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC_ARB */
+   { 32442, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE */
+   { 32466, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE_ARB */
+   { 32494, 0x0000819B }, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */
+   { 32527, 0x0000819A }, /* GL_TEXTURE_COMPARE_SGIX */
+   { 32551, 0x00001003 }, /* GL_TEXTURE_COMPONENTS */
+   { 32573, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED */
+   { 32595, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED_ARB */
+   { 32621, 0x000086A3 }, /* GL_TEXTURE_COMPRESSED_FORMATS_ARB */
+   { 32655, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */
+   { 32688, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB */
+   { 32725, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT */
+   { 32753, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT_ARB */
+   { 32785, 0x00008078 }, /* GL_TEXTURE_COORD_ARRAY */
+   { 32808, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */
+   { 32846, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB */
+   { 32888, 0x00008092 }, /* GL_TEXTURE_COORD_ARRAY_POINTER */
+   { 32919, 0x00008088 }, /* GL_TEXTURE_COORD_ARRAY_SIZE */
+   { 32947, 0x0000808A }, /* GL_TEXTURE_COORD_ARRAY_STRIDE */
+   { 32977, 0x00008089 }, /* GL_TEXTURE_COORD_ARRAY_TYPE */
+   { 33005, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP */
+   { 33025, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP_ARB */
+   { 33049, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */
+   { 33080, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB */
+   { 33115, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */
+   { 33146, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB */
+   { 33181, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */
+   { 33212, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB */
+   { 33247, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */
+   { 33278, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB */
+   { 33313, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */
+   { 33344, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB */
+   { 33379, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */
+   { 33410, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB */
+   { 33445, 0x00008071 }, /* GL_TEXTURE_DEPTH */
+   { 33462, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE */
+   { 33484, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE_ARB */
+   { 33510, 0x00002300 }, /* GL_TEXTURE_ENV */
+   { 33525, 0x00002201 }, /* GL_TEXTURE_ENV_COLOR */
+   { 33546, 0x00002200 }, /* GL_TEXTURE_ENV_MODE */
+   { 33566, 0x00008500 }, /* GL_TEXTURE_FILTER_CONTROL */
+   { 33592, 0x00002500 }, /* GL_TEXTURE_GEN_MODE */
+   { 33612, 0x00000C63 }, /* GL_TEXTURE_GEN_Q */
+   { 33629, 0x00000C62 }, /* GL_TEXTURE_GEN_R */
+   { 33646, 0x00000C60 }, /* GL_TEXTURE_GEN_S */
+   { 33663, 0x00000C61 }, /* GL_TEXTURE_GEN_T */
+   { 33680, 0x0000819D }, /* GL_TEXTURE_GEQUAL_R_SGIX */
+   { 33705, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE */
+   { 33727, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE_EXT */
+   { 33753, 0x00001001 }, /* GL_TEXTURE_HEIGHT */
+   { 33771, 0x000080ED }, /* GL_TEXTURE_INDEX_SIZE_EXT */
+   { 33797, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE */
+   { 33823, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE_EXT */
+   { 33853, 0x00001003 }, /* GL_TEXTURE_INTERNAL_FORMAT */
+   { 33880, 0x0000819C }, /* GL_TEXTURE_LEQUAL_R_SGIX */
+   { 33905, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS */
+   { 33925, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS_EXT */
+   { 33949, 0x00008190 }, /* GL_TEXTURE_LOD_BIAS_R_SGIX */
+   { 33976, 0x0000818E }, /* GL_TEXTURE_LOD_BIAS_S_SGIX */
+   { 34003, 0x0000818F }, /* GL_TEXTURE_LOD_BIAS_T_SGIX */
+   { 34030, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE */
+   { 34056, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE_EXT */
+   { 34086, 0x00002800 }, /* GL_TEXTURE_MAG_FILTER */
+   { 34108, 0x00000BA8 }, /* GL_TEXTURE_MATRIX */
+   { 34126, 0x000084FE }, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */
+   { 34156, 0x0000836B }, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */
+   { 34184, 0x00008369 }, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */
+   { 34212, 0x0000836A }, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */
+   { 34240, 0x0000813D }, /* GL_TEXTURE_MAX_LEVEL */
+   { 34261, 0x0000813B }, /* GL_TEXTURE_MAX_LOD */
+   { 34280, 0x00002801 }, /* GL_TEXTURE_MIN_FILTER */
+   { 34302, 0x0000813A }, /* GL_TEXTURE_MIN_LOD */
+   { 34321, 0x00008066 }, /* GL_TEXTURE_PRIORITY */
+   { 34341, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_ARB */
+   { 34366, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_NV */
+   { 34390, 0x0000805C }, /* GL_TEXTURE_RED_SIZE */
+   { 34410, 0x0000805C }, /* GL_TEXTURE_RED_SIZE_EXT */
+   { 34434, 0x00008067 }, /* GL_TEXTURE_RESIDENT */
+   { 34454, 0x00000BA5 }, /* GL_TEXTURE_STACK_DEPTH */
+   { 34477, 0x00008065 }, /* GL_TEXTURE_TOO_LARGE_EXT */
+   { 34502, 0x0000888F }, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */
+   { 34536, 0x00001000 }, /* GL_TEXTURE_WIDTH */
+   { 34553, 0x00008072 }, /* GL_TEXTURE_WRAP_R */
+   { 34571, 0x00002802 }, /* GL_TEXTURE_WRAP_S */
+   { 34589, 0x00002803 }, /* GL_TEXTURE_WRAP_T */
+   { 34607, 0x000088BF }, /* GL_TIME_ELAPSED_EXT */
+   { 34627, 0x00008648 }, /* GL_TRACK_MATRIX_NV */
+   { 34646, 0x00008649 }, /* GL_TRACK_MATRIX_TRANSFORM_NV */
+   { 34675, 0x00001000 }, /* GL_TRANSFORM_BIT */
+   { 34692, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX */
+   { 34718, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX_ARB */
+   { 34748, 0x000088B7 }, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */
+   { 34780, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX */
+   { 34810, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX_ARB */
+   { 34844, 0x0000862C }, /* GL_TRANSPOSE_NV */
+   { 34860, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX */
+   { 34891, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX_ARB */
+   { 34926, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX */
+   { 34954, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX_ARB */
+   { 34986, 0x00000004 }, /* GL_TRIANGLES */
+   { 34999, 0x00000006 }, /* GL_TRIANGLE_FAN */
+   { 35015, 0x00008615 }, /* GL_TRIANGLE_MESH_SUN */
+   { 35036, 0x00000005 }, /* GL_TRIANGLE_STRIP */
+   { 35054, 0x00000001 }, /* GL_TRUE */
+   { 35062, 0x00000CF5 }, /* GL_UNPACK_ALIGNMENT */
+   { 35082, 0x0000806E }, /* GL_UNPACK_IMAGE_HEIGHT */
+   { 35105, 0x00000CF1 }, /* GL_UNPACK_LSB_FIRST */
+   { 35125, 0x00000CF2 }, /* GL_UNPACK_ROW_LENGTH */
+   { 35146, 0x0000806D }, /* GL_UNPACK_SKIP_IMAGES */
+   { 35168, 0x00000CF4 }, /* GL_UNPACK_SKIP_PIXELS */
+   { 35190, 0x00000CF3 }, /* GL_UNPACK_SKIP_ROWS */
+   { 35210, 0x00000CF0 }, /* GL_UNPACK_SWAP_BYTES */
+   { 35231, 0x00001401 }, /* GL_UNSIGNED_BYTE */
+   { 35248, 0x00008362 }, /* GL_UNSIGNED_BYTE_2_3_3_REV */
+   { 35275, 0x00008032 }, /* GL_UNSIGNED_BYTE_3_3_2 */
+   { 35298, 0x00001405 }, /* GL_UNSIGNED_INT */
+   { 35314, 0x00008036 }, /* GL_UNSIGNED_INT_10_10_10_2 */
+   { 35341, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_NV */
+   { 35365, 0x00008368 }, /* GL_UNSIGNED_INT_2_10_10_10_REV */
+   { 35396, 0x00008035 }, /* GL_UNSIGNED_INT_8_8_8_8 */
+   { 35420, 0x00008367 }, /* GL_UNSIGNED_INT_8_8_8_8_REV */
+   { 35448, 0x00001403 }, /* GL_UNSIGNED_SHORT */
+   { 35466, 0x00008366 }, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */
+   { 35496, 0x00008033 }, /* GL_UNSIGNED_SHORT_4_4_4_4 */
+   { 35522, 0x00008365 }, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */
+   { 35552, 0x00008034 }, /* GL_UNSIGNED_SHORT_5_5_5_1 */
+   { 35578, 0x00008363 }, /* GL_UNSIGNED_SHORT_5_6_5 */
+   { 35602, 0x00008364 }, /* GL_UNSIGNED_SHORT_5_6_5_REV */
+   { 35630, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_APPLE */
+   { 35658, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_MESA */
+   { 35685, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */
+   { 35717, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_MESA */
+   { 35748, 0x00008CA2 }, /* GL_UPPER_LEFT */
+   { 35762, 0x00002A20 }, /* GL_V2F */
+   { 35769, 0x00002A21 }, /* GL_V3F */
+   { 35776, 0x00008B83 }, /* GL_VALIDATE_STATUS */
+   { 35795, 0x00001F00 }, /* GL_VENDOR */
+   { 35805, 0x00001F02 }, /* GL_VERSION */
+   { 35816, 0x00008074 }, /* GL_VERTEX_ARRAY */
+   { 35832, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING_APPLE */
+   { 35862, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING */
+   { 35893, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING_ARB */
+   { 35928, 0x0000808E }, /* GL_VERTEX_ARRAY_POINTER */
+   { 35952, 0x0000807A }, /* GL_VERTEX_ARRAY_SIZE */
+   { 35973, 0x0000807C }, /* GL_VERTEX_ARRAY_STRIDE */
+   { 35996, 0x0000807B }, /* GL_VERTEX_ARRAY_TYPE */
+   { 36017, 0x00008650 }, /* GL_VERTEX_ATTRIB_ARRAY0_NV */
+   { 36044, 0x0000865A }, /* GL_VERTEX_ATTRIB_ARRAY10_NV */
+   { 36072, 0x0000865B }, /* GL_VERTEX_ATTRIB_ARRAY11_NV */
+   { 36100, 0x0000865C }, /* GL_VERTEX_ATTRIB_ARRAY12_NV */
+   { 36128, 0x0000865D }, /* GL_VERTEX_ATTRIB_ARRAY13_NV */
+   { 36156, 0x0000865E }, /* GL_VERTEX_ATTRIB_ARRAY14_NV */
+   { 36184, 0x0000865F }, /* GL_VERTEX_ATTRIB_ARRAY15_NV */
+   { 36212, 0x00008651 }, /* GL_VERTEX_ATTRIB_ARRAY1_NV */
+   { 36239, 0x00008652 }, /* GL_VERTEX_ATTRIB_ARRAY2_NV */
+   { 36266, 0x00008653 }, /* GL_VERTEX_ATTRIB_ARRAY3_NV */
+   { 36293, 0x00008654 }, /* GL_VERTEX_ATTRIB_ARRAY4_NV */
+   { 36320, 0x00008655 }, /* GL_VERTEX_ATTRIB_ARRAY5_NV */
+   { 36347, 0x00008656 }, /* GL_VERTEX_ATTRIB_ARRAY6_NV */
+   { 36374, 0x00008657 }, /* GL_VERTEX_ATTRIB_ARRAY7_NV */
+   { 36401, 0x00008658 }, /* GL_VERTEX_ATTRIB_ARRAY8_NV */
+   { 36428, 0x00008659 }, /* GL_VERTEX_ATTRIB_ARRAY9_NV */
+   { 36455, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */
+   { 36493, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB */
+   { 36535, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */
+   { 36566, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB */
+   { 36601, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */
+   { 36635, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB */
+   { 36673, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */
+   { 36704, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB */
+   { 36739, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */
+   { 36767, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB */
+   { 36799, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */
+   { 36829, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB */
+   { 36863, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */
+   { 36891, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB */
+   { 36923, 0x000086A7 }, /* GL_VERTEX_BLEND_ARB */
+   { 36943, 0x00008620 }, /* GL_VERTEX_PROGRAM_ARB */
+   { 36965, 0x0000864A }, /* GL_VERTEX_PROGRAM_BINDING_NV */
+   { 36994, 0x00008620 }, /* GL_VERTEX_PROGRAM_NV */
+   { 37015, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE */
+   { 37044, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_ARB */
+   { 37077, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_NV */
+   { 37109, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE */
+   { 37136, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_ARB */
+   { 37167, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_NV */
+   { 37197, 0x00008B31 }, /* GL_VERTEX_SHADER */
+   { 37214, 0x00008B31 }, /* GL_VERTEX_SHADER_ARB */
+   { 37235, 0x00008621 }, /* GL_VERTEX_STATE_PROGRAM_NV */
+   { 37262, 0x00000BA2 }, /* GL_VIEWPORT */
+   { 37274, 0x00000800 }, /* GL_VIEWPORT_BIT */
+   { 37290, 0x000086AD }, /* GL_WEIGHT_ARRAY_ARB */
+   { 37310, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */
+   { 37341, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB */
+   { 37376, 0x000086AC }, /* GL_WEIGHT_ARRAY_POINTER_ARB */
+   { 37404, 0x000086AB }, /* GL_WEIGHT_ARRAY_SIZE_ARB */
+   { 37429, 0x000086AA }, /* GL_WEIGHT_ARRAY_STRIDE_ARB */
+   { 37456, 0x000086A9 }, /* GL_WEIGHT_ARRAY_TYPE_ARB */
+   { 37481, 0x000086A6 }, /* GL_WEIGHT_SUM_UNITY_ARB */
+   { 37505, 0x000081D4 }, /* GL_WRAP_BORDER_SUN */
+   { 37524, 0x000088B9 }, /* GL_WRITE_ONLY */
+   { 37538, 0x000088B9 }, /* GL_WRITE_ONLY_ARB */
+   { 37556, 0x00001506 }, /* GL_XOR */
+   { 37563, 0x000085B9 }, /* GL_YCBCR_422_APPLE */
+   { 37582, 0x00008757 }, /* GL_YCBCR_MESA */
+   { 37596, 0x00000000 }, /* GL_ZERO */
+   { 37604, 0x00000D16 }, /* GL_ZOOM_X */
+   { 37614, 0x00000D17 }, /* GL_ZOOM_Y */
 };
 
 static const unsigned reduced_enums[1284] =
 {
-       436, /* GL_FALSE */
-       645, /* GL_LINES */
-       647, /* GL_LINE_LOOP */
-       654, /* GL_LINE_STRIP */
-      1641, /* GL_TRIANGLES */
-      1644, /* GL_TRIANGLE_STRIP */
-      1642, /* GL_TRIANGLE_FAN */
-      1211, /* GL_QUADS */
-      1213, /* GL_QUAD_STRIP */
-      1099, /* GL_POLYGON */
-      1111, /* GL_POLYGON_STIPPLE_BIT */
-      1064, /* GL_PIXEL_MODE_BIT */
-       632, /* GL_LIGHTING_BIT */
-       458, /* GL_FOG_BIT */
+       434, /* GL_FALSE */
+       643, /* GL_LINES */
+       645, /* GL_LINE_LOOP */
+       652, /* GL_LINE_STRIP */
+      1639, /* GL_TRIANGLES */
+      1642, /* GL_TRIANGLE_STRIP */
+      1640, /* GL_TRIANGLE_FAN */
+      1209, /* GL_QUADS */
+      1211, /* GL_QUAD_STRIP */
+      1097, /* GL_POLYGON */
+      1109, /* GL_POLYGON_STIPPLE_BIT */
+      1062, /* GL_PIXEL_MODE_BIT */
+       630, /* GL_LIGHTING_BIT */
+       456, /* GL_FOG_BIT */
          8, /* GL_ACCUM */
-       664, /* GL_LOAD */
-      1253, /* GL_RETURN */
-       937, /* GL_MULT */
+       662, /* GL_LOAD */
+      1251, /* GL_RETURN */
+       935, /* GL_MULT */
         23, /* GL_ADD */
-       953, /* GL_NEVER */
-       622, /* GL_LESS */
-       426, /* GL_EQUAL */
-       621, /* GL_LEQUAL */
-       547, /* GL_GREATER */
-       968, /* GL_NOTEQUAL */
-       522, /* GL_GEQUAL */
+       951, /* GL_NEVER */
+       620, /* GL_LESS */
+       424, /* GL_EQUAL */
+       619, /* GL_LEQUAL */
+       545, /* GL_GREATER */
+       966, /* GL_NOTEQUAL */
+       520, /* GL_GEQUAL */
         46, /* GL_ALWAYS */
-      1386, /* GL_SRC_COLOR */
-       997, /* GL_ONE_MINUS_SRC_COLOR */
-      1384, /* GL_SRC_ALPHA */
-       996, /* GL_ONE_MINUS_SRC_ALPHA */
-       406, /* GL_DST_ALPHA */
-       994, /* GL_ONE_MINUS_DST_ALPHA */
-       407, /* GL_DST_COLOR */
-       995, /* GL_ONE_MINUS_DST_COLOR */
-      1385, /* GL_SRC_ALPHA_SATURATE */
-       510, /* GL_FRONT_LEFT */
-       511, /* GL_FRONT_RIGHT */
-        69, /* GL_BACK_LEFT */
-        70, /* GL_BACK_RIGHT */
-       507, /* GL_FRONT */
-        68, /* GL_BACK */
-       620, /* GL_LEFT */
-      1293, /* GL_RIGHT */
-       508, /* GL_FRONT_AND_BACK */
-        63, /* GL_AUX0 */
-        64, /* GL_AUX1 */
-        65, /* GL_AUX2 */
-        66, /* GL_AUX3 */
-       612, /* GL_INVALID_ENUM */
-       615, /* GL_INVALID_VALUE */
-       614, /* GL_INVALID_OPERATION */
-      1387, /* GL_STACK_OVERFLOW */
-      1388, /* GL_STACK_UNDERFLOW */
-      1022, /* GL_OUT_OF_MEMORY */
-       613, /* GL_INVALID_FRAMEBUFFER_OPERATION_EXT */
+      1384, /* GL_SRC_COLOR */
+       995, /* GL_ONE_MINUS_SRC_COLOR */
+      1382, /* GL_SRC_ALPHA */
+       994, /* GL_ONE_MINUS_SRC_ALPHA */
+       405, /* GL_DST_ALPHA */
+       992, /* GL_ONE_MINUS_DST_ALPHA */
+       406, /* GL_DST_COLOR */
+       993, /* GL_ONE_MINUS_DST_COLOR */
+      1383, /* GL_SRC_ALPHA_SATURATE */
+       508, /* GL_FRONT_LEFT */
+       509, /* GL_FRONT_RIGHT */
+        68, /* GL_BACK_LEFT */
+        69, /* GL_BACK_RIGHT */
+       505, /* GL_FRONT */
+        67, /* GL_BACK */
+       618, /* GL_LEFT */
+      1291, /* GL_RIGHT */
+       506, /* GL_FRONT_AND_BACK */
+        62, /* GL_AUX0 */
+        63, /* GL_AUX1 */
+        64, /* GL_AUX2 */
+        65, /* GL_AUX3 */
+       610, /* GL_INVALID_ENUM */
+       613, /* GL_INVALID_VALUE */
+       612, /* GL_INVALID_OPERATION */
+      1385, /* GL_STACK_OVERFLOW */
+      1386, /* GL_STACK_UNDERFLOW */
+      1020, /* GL_OUT_OF_MEMORY */
+       611, /* 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 */
-      1042, /* GL_PASS_THROUGH_TOKEN */
-      1098, /* GL_POINT_TOKEN */
-       655, /* GL_LINE_TOKEN */
-      1112, /* GL_POLYGON_TOKEN */
-        74, /* GL_BITMAP_TOKEN */
-       405, /* GL_DRAW_PIXEL_TOKEN */
-       271, /* GL_COPY_PIXEL_TOKEN */
-       648, /* GL_LINE_RESET_TOKEN */
-       429, /* GL_EXP */
-       430, /* GL_EXP2 */
-       304, /* GL_CW */
-       116, /* GL_CCW */
-       137, /* GL_COEFF */
-      1019, /* GL_ORDER */
-       344, /* GL_DOMAIN */
-       279, /* GL_CURRENT_COLOR */
-       282, /* GL_CURRENT_INDEX */
-       288, /* GL_CURRENT_NORMAL */
-       300, /* GL_CURRENT_TEXTURE_COORDS */
-       293, /* GL_CURRENT_RASTER_COLOR */
-       295, /* GL_CURRENT_RASTER_INDEX */
-       298, /* GL_CURRENT_RASTER_TEXTURE_COORDS */
-       296, /* GL_CURRENT_RASTER_POSITION */
-       297, /* GL_CURRENT_RASTER_POSITION_VALID */
-       294, /* GL_CURRENT_RASTER_DISTANCE */
-      1091, /* GL_POINT_SMOOTH */
-      1080, /* GL_POINT_SIZE */
-      1090, /* GL_POINT_SIZE_RANGE */
-      1081, /* GL_POINT_SIZE_GRANULARITY */
-       649, /* GL_LINE_SMOOTH */
-       656, /* GL_LINE_WIDTH */
-       658, /* GL_LINE_WIDTH_RANGE */
-       657, /* GL_LINE_WIDTH_GRANULARITY */
-       651, /* GL_LINE_STIPPLE */
-       652, /* GL_LINE_STIPPLE_PATTERN */
-       653, /* GL_LINE_STIPPLE_REPEAT */
-       663, /* GL_LIST_MODE */
-       822, /* GL_MAX_LIST_NESTING */
-       660, /* GL_LIST_BASE */
-       662, /* GL_LIST_INDEX */
-      1101, /* GL_POLYGON_MODE */
-      1108, /* GL_POLYGON_SMOOTH */
-      1110, /* GL_POLYGON_STIPPLE */
-       414, /* GL_EDGE_FLAG */
-       272, /* GL_CULL_FACE */
-       273, /* GL_CULL_FACE_MODE */
-       509, /* GL_FRONT_FACE */
-       631, /* GL_LIGHTING */
-       636, /* GL_LIGHT_MODEL_LOCAL_VIEWER */
-       637, /* GL_LIGHT_MODEL_TWO_SIDE */
-       633, /* GL_LIGHT_MODEL_AMBIENT */
-      1339, /* GL_SHADE_MODEL */
-       168, /* GL_COLOR_MATERIAL_FACE */
-       169, /* GL_COLOR_MATERIAL_PARAMETER */
-       167, /* GL_COLOR_MATERIAL */
-       457, /* GL_FOG */
-       479, /* GL_FOG_INDEX */
-       475, /* GL_FOG_DENSITY */
-       483, /* GL_FOG_START */
-       477, /* GL_FOG_END */
-       480, /* GL_FOG_MODE */
-       459, /* GL_FOG_COLOR */
-       333, /* GL_DEPTH_RANGE */
-       338, /* GL_DEPTH_TEST */
-       341, /* GL_DEPTH_WRITEMASK */
-       321, /* GL_DEPTH_CLEAR_VALUE */
-       332, /* GL_DEPTH_FUNC */
+      1040, /* GL_PASS_THROUGH_TOKEN */
+      1096, /* GL_POINT_TOKEN */
+       653, /* GL_LINE_TOKEN */
+      1110, /* GL_POLYGON_TOKEN */
+        73, /* GL_BITMAP_TOKEN */
+       404, /* GL_DRAW_PIXEL_TOKEN */
+       270, /* GL_COPY_PIXEL_TOKEN */
+       646, /* GL_LINE_RESET_TOKEN */
+       427, /* GL_EXP */
+       428, /* GL_EXP2 */
+       303, /* GL_CW */
+       115, /* GL_CCW */
+       136, /* GL_COEFF */
+      1017, /* GL_ORDER */
+       343, /* GL_DOMAIN */
+       278, /* GL_CURRENT_COLOR */
+       281, /* GL_CURRENT_INDEX */
+       287, /* GL_CURRENT_NORMAL */
+       299, /* GL_CURRENT_TEXTURE_COORDS */
+       292, /* GL_CURRENT_RASTER_COLOR */
+       294, /* GL_CURRENT_RASTER_INDEX */
+       297, /* GL_CURRENT_RASTER_TEXTURE_COORDS */
+       295, /* GL_CURRENT_RASTER_POSITION */
+       296, /* GL_CURRENT_RASTER_POSITION_VALID */
+       293, /* GL_CURRENT_RASTER_DISTANCE */
+      1089, /* GL_POINT_SMOOTH */
+      1078, /* GL_POINT_SIZE */
+      1088, /* GL_POINT_SIZE_RANGE */
+      1079, /* GL_POINT_SIZE_GRANULARITY */
+       647, /* GL_LINE_SMOOTH */
+       654, /* GL_LINE_WIDTH */
+       656, /* GL_LINE_WIDTH_RANGE */
+       655, /* GL_LINE_WIDTH_GRANULARITY */
+       649, /* GL_LINE_STIPPLE */
+       650, /* GL_LINE_STIPPLE_PATTERN */
+       651, /* GL_LINE_STIPPLE_REPEAT */
+       661, /* GL_LIST_MODE */
+       820, /* GL_MAX_LIST_NESTING */
+       658, /* GL_LIST_BASE */
+       660, /* GL_LIST_INDEX */
+      1099, /* GL_POLYGON_MODE */
+      1106, /* GL_POLYGON_SMOOTH */
+      1108, /* GL_POLYGON_STIPPLE */
+       413, /* GL_EDGE_FLAG */
+       271, /* GL_CULL_FACE */
+       272, /* GL_CULL_FACE_MODE */
+       507, /* GL_FRONT_FACE */
+       629, /* GL_LIGHTING */
+       634, /* GL_LIGHT_MODEL_LOCAL_VIEWER */
+       635, /* GL_LIGHT_MODEL_TWO_SIDE */
+       631, /* GL_LIGHT_MODEL_AMBIENT */
+      1337, /* GL_SHADE_MODEL */
+       167, /* GL_COLOR_MATERIAL_FACE */
+       168, /* GL_COLOR_MATERIAL_PARAMETER */
+       166, /* GL_COLOR_MATERIAL */
+       455, /* GL_FOG */
+       477, /* GL_FOG_INDEX */
+       473, /* GL_FOG_DENSITY */
+       481, /* GL_FOG_START */
+       475, /* GL_FOG_END */
+       478, /* GL_FOG_MODE */
+       457, /* GL_FOG_COLOR */
+       332, /* GL_DEPTH_RANGE */
+       337, /* GL_DEPTH_TEST */
+       340, /* GL_DEPTH_WRITEMASK */
+       320, /* GL_DEPTH_CLEAR_VALUE */
+       331, /* GL_DEPTH_FUNC */
         12, /* GL_ACCUM_CLEAR_VALUE */
-      1422, /* GL_STENCIL_TEST */
-      1410, /* GL_STENCIL_CLEAR_VALUE */
-      1412, /* GL_STENCIL_FUNC */
-      1424, /* GL_STENCIL_VALUE_MASK */
-      1411, /* GL_STENCIL_FAIL */
-      1419, /* GL_STENCIL_PASS_DEPTH_FAIL */
-      1420, /* GL_STENCIL_PASS_DEPTH_PASS */
-      1421, /* GL_STENCIL_REF */
-      1425, /* GL_STENCIL_WRITEMASK */
-       791, /* GL_MATRIX_MODE */
-       958, /* GL_NORMALIZE */
-      1731, /* GL_VIEWPORT */
-       932, /* GL_MODELVIEW_STACK_DEPTH */
-      1191, /* GL_PROJECTION_STACK_DEPTH */
-      1620, /* GL_TEXTURE_STACK_DEPTH */
-       930, /* GL_MODELVIEW_MATRIX */
-      1190, /* GL_PROJECTION_MATRIX */
-      1605, /* GL_TEXTURE_MATRIX */
-        61, /* GL_ATTRIB_STACK_DEPTH */
-       127, /* GL_CLIENT_ATTRIB_STACK_DEPTH */
+      1420, /* GL_STENCIL_TEST */
+      1408, /* GL_STENCIL_CLEAR_VALUE */
+      1410, /* GL_STENCIL_FUNC */
+      1422, /* GL_STENCIL_VALUE_MASK */
+      1409, /* GL_STENCIL_FAIL */
+      1417, /* GL_STENCIL_PASS_DEPTH_FAIL */
+      1418, /* GL_STENCIL_PASS_DEPTH_PASS */
+      1419, /* GL_STENCIL_REF */
+      1423, /* GL_STENCIL_WRITEMASK */
+       789, /* GL_MATRIX_MODE */
+       956, /* GL_NORMALIZE */
+      1729, /* GL_VIEWPORT */
+       930, /* GL_MODELVIEW_STACK_DEPTH */
+      1189, /* GL_PROJECTION_STACK_DEPTH */
+      1618, /* GL_TEXTURE_STACK_DEPTH */
+       928, /* GL_MODELVIEW_MATRIX */
+      1188, /* GL_PROJECTION_MATRIX */
+      1603, /* GL_TEXTURE_MATRIX */
+        60, /* GL_ATTRIB_STACK_DEPTH */
+       126, /* GL_CLIENT_ATTRIB_STACK_DEPTH */
         43, /* GL_ALPHA_TEST */
         44, /* GL_ALPHA_TEST_FUNC */
         45, /* GL_ALPHA_TEST_REF */
-       343, /* GL_DITHER */
-        78, /* GL_BLEND_DST */
-        86, /* GL_BLEND_SRC */
-        75, /* GL_BLEND */
-       666, /* GL_LOGIC_OP_MODE */
-       586, /* GL_INDEX_LOGIC_OP */
-       166, /* GL_COLOR_LOGIC_OP */
-        67, /* GL_AUX_BUFFERS */
-       354, /* GL_DRAW_BUFFER */
-      1223, /* GL_READ_BUFFER */
-      1320, /* GL_SCISSOR_BOX */
-      1321, /* GL_SCISSOR_TEST */
-       585, /* GL_INDEX_CLEAR_VALUE */
-       590, /* GL_INDEX_WRITEMASK */
-       163, /* GL_COLOR_CLEAR_VALUE */
-       205, /* GL_COLOR_WRITEMASK */
-       587, /* GL_INDEX_MODE */
-      1287, /* GL_RGBA_MODE */
-       353, /* GL_DOUBLEBUFFER */
-      1426, /* GL_STEREO */
-      1246, /* GL_RENDER_MODE */
-      1043, /* GL_PERSPECTIVE_CORRECTION_HINT */
-      1092, /* GL_POINT_SMOOTH_HINT */
-       650, /* GL_LINE_SMOOTH_HINT */
-      1109, /* GL_POLYGON_SMOOTH_HINT */
-       478, /* GL_FOG_HINT */
-      1586, /* GL_TEXTURE_GEN_S */
-      1587, /* GL_TEXTURE_GEN_T */
-      1585, /* GL_TEXTURE_GEN_R */
-      1584, /* GL_TEXTURE_GEN_Q */
-      1056, /* GL_PIXEL_MAP_I_TO_I */
-      1062, /* GL_PIXEL_MAP_S_TO_S */
-      1058, /* GL_PIXEL_MAP_I_TO_R */
-      1054, /* GL_PIXEL_MAP_I_TO_G */
-      1052, /* GL_PIXEL_MAP_I_TO_B */
-      1050, /* GL_PIXEL_MAP_I_TO_A */
-      1060, /* GL_PIXEL_MAP_R_TO_R */
-      1048, /* GL_PIXEL_MAP_G_TO_G */
-      1046, /* GL_PIXEL_MAP_B_TO_B */
-      1044, /* GL_PIXEL_MAP_A_TO_A */
-      1057, /* GL_PIXEL_MAP_I_TO_I_SIZE */
-      1063, /* GL_PIXEL_MAP_S_TO_S_SIZE */
-      1059, /* GL_PIXEL_MAP_I_TO_R_SIZE */
-      1055, /* GL_PIXEL_MAP_I_TO_G_SIZE */
-      1053, /* GL_PIXEL_MAP_I_TO_B_SIZE */
-      1051, /* GL_PIXEL_MAP_I_TO_A_SIZE */
-      1061, /* GL_PIXEL_MAP_R_TO_R_SIZE */
-      1049, /* GL_PIXEL_MAP_G_TO_G_SIZE */
-      1047, /* GL_PIXEL_MAP_B_TO_B_SIZE */
-      1045, /* GL_PIXEL_MAP_A_TO_A_SIZE */
-      1653, /* GL_UNPACK_SWAP_BYTES */
-      1648, /* GL_UNPACK_LSB_FIRST */
-      1649, /* GL_UNPACK_ROW_LENGTH */
-      1652, /* GL_UNPACK_SKIP_ROWS */
-      1651, /* GL_UNPACK_SKIP_PIXELS */
-      1646, /* GL_UNPACK_ALIGNMENT */
-      1031, /* GL_PACK_SWAP_BYTES */
-      1026, /* GL_PACK_LSB_FIRST */
-      1027, /* GL_PACK_ROW_LENGTH */
-      1030, /* GL_PACK_SKIP_ROWS */
-      1029, /* GL_PACK_SKIP_PIXELS */
-      1023, /* GL_PACK_ALIGNMENT */
-       744, /* GL_MAP_COLOR */
-       745, /* GL_MAP_STENCIL */
-       589, /* GL_INDEX_SHIFT */
-       588, /* GL_INDEX_OFFSET */
-      1235, /* GL_RED_SCALE */
-      1233, /* GL_RED_BIAS */
-      1748, /* GL_ZOOM_X */
-      1749, /* GL_ZOOM_Y */
-       551, /* GL_GREEN_SCALE */
-       549, /* GL_GREEN_BIAS */
-        92, /* GL_BLUE_SCALE */
-        90, /* GL_BLUE_BIAS */
+       342, /* GL_DITHER */
+        77, /* GL_BLEND_DST */
+        85, /* GL_BLEND_SRC */
+        74, /* GL_BLEND */
+       664, /* GL_LOGIC_OP_MODE */
+       584, /* GL_INDEX_LOGIC_OP */
+       165, /* GL_COLOR_LOGIC_OP */
+        66, /* GL_AUX_BUFFERS */
+       353, /* GL_DRAW_BUFFER */
+      1221, /* GL_READ_BUFFER */
+      1318, /* GL_SCISSOR_BOX */
+      1319, /* GL_SCISSOR_TEST */
+       583, /* GL_INDEX_CLEAR_VALUE */
+       588, /* GL_INDEX_WRITEMASK */
+       162, /* GL_COLOR_CLEAR_VALUE */
+       204, /* GL_COLOR_WRITEMASK */
+       585, /* GL_INDEX_MODE */
+      1285, /* GL_RGBA_MODE */
+       352, /* GL_DOUBLEBUFFER */
+      1424, /* GL_STEREO */
+      1244, /* GL_RENDER_MODE */
+      1041, /* GL_PERSPECTIVE_CORRECTION_HINT */
+      1090, /* GL_POINT_SMOOTH_HINT */
+       648, /* GL_LINE_SMOOTH_HINT */
+      1107, /* GL_POLYGON_SMOOTH_HINT */
+       476, /* GL_FOG_HINT */
+      1584, /* GL_TEXTURE_GEN_S */
+      1585, /* GL_TEXTURE_GEN_T */
+      1583, /* GL_TEXTURE_GEN_R */
+      1582, /* GL_TEXTURE_GEN_Q */
+      1054, /* GL_PIXEL_MAP_I_TO_I */
+      1060, /* GL_PIXEL_MAP_S_TO_S */
+      1056, /* GL_PIXEL_MAP_I_TO_R */
+      1052, /* GL_PIXEL_MAP_I_TO_G */
+      1050, /* GL_PIXEL_MAP_I_TO_B */
+      1048, /* GL_PIXEL_MAP_I_TO_A */
+      1058, /* GL_PIXEL_MAP_R_TO_R */
+      1046, /* GL_PIXEL_MAP_G_TO_G */
+      1044, /* GL_PIXEL_MAP_B_TO_B */
+      1042, /* GL_PIXEL_MAP_A_TO_A */
+      1055, /* GL_PIXEL_MAP_I_TO_I_SIZE */
+      1061, /* GL_PIXEL_MAP_S_TO_S_SIZE */
+      1057, /* GL_PIXEL_MAP_I_TO_R_SIZE */
+      1053, /* GL_PIXEL_MAP_I_TO_G_SIZE */
+      1051, /* GL_PIXEL_MAP_I_TO_B_SIZE */
+      1049, /* GL_PIXEL_MAP_I_TO_A_SIZE */
+      1059, /* GL_PIXEL_MAP_R_TO_R_SIZE */
+      1047, /* GL_PIXEL_MAP_G_TO_G_SIZE */
+      1045, /* GL_PIXEL_MAP_B_TO_B_SIZE */
+      1043, /* GL_PIXEL_MAP_A_TO_A_SIZE */
+      1651, /* GL_UNPACK_SWAP_BYTES */
+      1646, /* GL_UNPACK_LSB_FIRST */
+      1647, /* GL_UNPACK_ROW_LENGTH */
+      1650, /* GL_UNPACK_SKIP_ROWS */
+      1649, /* GL_UNPACK_SKIP_PIXELS */
+      1644, /* GL_UNPACK_ALIGNMENT */
+      1029, /* GL_PACK_SWAP_BYTES */
+      1024, /* GL_PACK_LSB_FIRST */
+      1025, /* GL_PACK_ROW_LENGTH */
+      1028, /* GL_PACK_SKIP_ROWS */
+      1027, /* GL_PACK_SKIP_PIXELS */
+      1021, /* GL_PACK_ALIGNMENT */
+       742, /* GL_MAP_COLOR */
+       743, /* GL_MAP_STENCIL */
+       587, /* GL_INDEX_SHIFT */
+       586, /* GL_INDEX_OFFSET */
+      1233, /* GL_RED_SCALE */
+      1231, /* GL_RED_BIAS */
+      1746, /* GL_ZOOM_X */
+      1747, /* GL_ZOOM_Y */
+       549, /* GL_GREEN_SCALE */
+       547, /* GL_GREEN_BIAS */
+        91, /* GL_BLUE_SCALE */
+        89, /* GL_BLUE_BIAS */
         42, /* GL_ALPHA_SCALE */
         40, /* GL_ALPHA_BIAS */
-       334, /* GL_DEPTH_SCALE */
-       315, /* GL_DEPTH_BIAS */
-       817, /* GL_MAX_EVAL_ORDER */
-       821, /* GL_MAX_LIGHTS */
-       800, /* GL_MAX_CLIP_PLANES */
-       865, /* GL_MAX_TEXTURE_SIZE */
-       827, /* GL_MAX_PIXEL_MAP_TABLE */
-       796, /* GL_MAX_ATTRIB_STACK_DEPTH */
-       824, /* GL_MAX_MODELVIEW_STACK_DEPTH */
-       825, /* GL_MAX_NAME_STACK_DEPTH */
-       853, /* GL_MAX_PROJECTION_STACK_DEPTH */
-       866, /* GL_MAX_TEXTURE_STACK_DEPTH */
-       880, /* GL_MAX_VIEWPORT_DIMS */
-       797, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */
-      1433, /* GL_SUBPIXEL_BITS */
-       584, /* GL_INDEX_BITS */
-      1234, /* GL_RED_BITS */
-       550, /* GL_GREEN_BITS */
-        91, /* GL_BLUE_BITS */
+       333, /* GL_DEPTH_SCALE */
+       314, /* GL_DEPTH_BIAS */
+       815, /* GL_MAX_EVAL_ORDER */
+       819, /* GL_MAX_LIGHTS */
+       798, /* GL_MAX_CLIP_PLANES */
+       863, /* GL_MAX_TEXTURE_SIZE */
+       825, /* GL_MAX_PIXEL_MAP_TABLE */
+       794, /* GL_MAX_ATTRIB_STACK_DEPTH */
+       822, /* GL_MAX_MODELVIEW_STACK_DEPTH */
+       823, /* GL_MAX_NAME_STACK_DEPTH */
+       851, /* GL_MAX_PROJECTION_STACK_DEPTH */
+       864, /* GL_MAX_TEXTURE_STACK_DEPTH */
+       878, /* GL_MAX_VIEWPORT_DIMS */
+       795, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */
+      1431, /* GL_SUBPIXEL_BITS */
+       582, /* GL_INDEX_BITS */
+      1232, /* GL_RED_BITS */
+       548, /* GL_GREEN_BITS */
+        90, /* GL_BLUE_BITS */
         41, /* GL_ALPHA_BITS */
-       316, /* GL_DEPTH_BITS */
-      1408, /* GL_STENCIL_BITS */
+       315, /* GL_DEPTH_BITS */
+      1406, /* GL_STENCIL_BITS */
         14, /* GL_ACCUM_RED_BITS */
         13, /* GL_ACCUM_GREEN_BITS */
         10, /* GL_ACCUM_BLUE_BITS */
          9, /* GL_ACCUM_ALPHA_BITS */
-       946, /* GL_NAME_STACK_DEPTH */
-        62, /* GL_AUTO_NORMAL */
-       690, /* GL_MAP1_COLOR_4 */
-       693, /* GL_MAP1_INDEX */
-       694, /* GL_MAP1_NORMAL */
-       695, /* GL_MAP1_TEXTURE_COORD_1 */
-       696, /* GL_MAP1_TEXTURE_COORD_2 */
-       697, /* GL_MAP1_TEXTURE_COORD_3 */
-       698, /* GL_MAP1_TEXTURE_COORD_4 */
-       699, /* GL_MAP1_VERTEX_3 */
-       700, /* GL_MAP1_VERTEX_4 */
-       717, /* GL_MAP2_COLOR_4 */
-       720, /* GL_MAP2_INDEX */
-       721, /* GL_MAP2_NORMAL */
-       722, /* GL_MAP2_TEXTURE_COORD_1 */
-       723, /* GL_MAP2_TEXTURE_COORD_2 */
-       724, /* GL_MAP2_TEXTURE_COORD_3 */
-       725, /* GL_MAP2_TEXTURE_COORD_4 */
-       726, /* GL_MAP2_VERTEX_3 */
-       727, /* GL_MAP2_VERTEX_4 */
-       691, /* GL_MAP1_GRID_DOMAIN */
-       692, /* GL_MAP1_GRID_SEGMENTS */
-       718, /* GL_MAP2_GRID_DOMAIN */
-       719, /* GL_MAP2_GRID_SEGMENTS */
-      1510, /* GL_TEXTURE_1D */
-      1512, /* GL_TEXTURE_2D */
-       439, /* GL_FEEDBACK_BUFFER_POINTER */
-       440, /* GL_FEEDBACK_BUFFER_SIZE */
-       441, /* GL_FEEDBACK_BUFFER_TYPE */
-      1330, /* GL_SELECTION_BUFFER_POINTER */
-      1331, /* GL_SELECTION_BUFFER_SIZE */
-      1623, /* GL_TEXTURE_WIDTH */
-      1591, /* GL_TEXTURE_HEIGHT */
-      1547, /* GL_TEXTURE_COMPONENTS */
-      1531, /* GL_TEXTURE_BORDER_COLOR */
-      1530, /* GL_TEXTURE_BORDER */
-       345, /* GL_DONT_CARE */
-       437, /* GL_FASTEST */
-       954, /* GL_NICEST */
+       944, /* GL_NAME_STACK_DEPTH */
+        61, /* GL_AUTO_NORMAL */
+       688, /* GL_MAP1_COLOR_4 */
+       691, /* GL_MAP1_INDEX */
+       692, /* GL_MAP1_NORMAL */
+       693, /* GL_MAP1_TEXTURE_COORD_1 */
+       694, /* GL_MAP1_TEXTURE_COORD_2 */
+       695, /* GL_MAP1_TEXTURE_COORD_3 */
+       696, /* GL_MAP1_TEXTURE_COORD_4 */
+       697, /* GL_MAP1_VERTEX_3 */
+       698, /* GL_MAP1_VERTEX_4 */
+       715, /* GL_MAP2_COLOR_4 */
+       718, /* GL_MAP2_INDEX */
+       719, /* GL_MAP2_NORMAL */
+       720, /* GL_MAP2_TEXTURE_COORD_1 */
+       721, /* GL_MAP2_TEXTURE_COORD_2 */
+       722, /* GL_MAP2_TEXTURE_COORD_3 */
+       723, /* GL_MAP2_TEXTURE_COORD_4 */
+       724, /* GL_MAP2_VERTEX_3 */
+       725, /* GL_MAP2_VERTEX_4 */
+       689, /* GL_MAP1_GRID_DOMAIN */
+       690, /* GL_MAP1_GRID_SEGMENTS */
+       716, /* GL_MAP2_GRID_DOMAIN */
+       717, /* GL_MAP2_GRID_SEGMENTS */
+      1508, /* GL_TEXTURE_1D */
+      1510, /* GL_TEXTURE_2D */
+       437, /* GL_FEEDBACK_BUFFER_POINTER */
+       438, /* GL_FEEDBACK_BUFFER_SIZE */
+       439, /* GL_FEEDBACK_BUFFER_TYPE */
+      1328, /* GL_SELECTION_BUFFER_POINTER */
+      1329, /* GL_SELECTION_BUFFER_SIZE */
+      1621, /* GL_TEXTURE_WIDTH */
+      1589, /* GL_TEXTURE_HEIGHT */
+      1545, /* GL_TEXTURE_COMPONENTS */
+      1529, /* GL_TEXTURE_BORDER_COLOR */
+      1528, /* GL_TEXTURE_BORDER */
+       344, /* GL_DONT_CARE */
+       435, /* GL_FASTEST */
+       952, /* GL_NICEST */
         47, /* GL_AMBIENT */
-       342, /* GL_DIFFUSE */
-      1373, /* GL_SPECULAR */
-      1113, /* GL_POSITION */
-      1376, /* GL_SPOT_DIRECTION */
-      1377, /* GL_SPOT_EXPONENT */
-      1375, /* GL_SPOT_CUTOFF */
-       245, /* GL_CONSTANT_ATTENUATION */
-       640, /* GL_LINEAR_ATTENUATION */
-      1210, /* GL_QUADRATIC_ATTENUATION */
-       219, /* GL_COMPILE */
-       220, /* GL_COMPILE_AND_EXECUTE */
-       111, /* GL_BYTE */
-      1654, /* GL_UNSIGNED_BYTE */
-      1344, /* GL_SHORT */
-      1663, /* GL_UNSIGNED_SHORT */
-       592, /* GL_INT */
-      1657, /* GL_UNSIGNED_INT */
-       444, /* GL_FLOAT */
+       341, /* GL_DIFFUSE */
+      1371, /* GL_SPECULAR */
+      1111, /* GL_POSITION */
+      1374, /* GL_SPOT_DIRECTION */
+      1375, /* GL_SPOT_EXPONENT */
+      1373, /* GL_SPOT_CUTOFF */
+       244, /* GL_CONSTANT_ATTENUATION */
+       638, /* GL_LINEAR_ATTENUATION */
+      1208, /* GL_QUADRATIC_ATTENUATION */
+       218, /* GL_COMPILE */
+       219, /* GL_COMPILE_AND_EXECUTE */
+       110, /* GL_BYTE */
+      1652, /* GL_UNSIGNED_BYTE */
+      1342, /* GL_SHORT */
+      1661, /* GL_UNSIGNED_SHORT */
+       590, /* GL_INT */
+      1655, /* GL_UNSIGNED_INT */
+       442, /* GL_FLOAT */
          1, /* GL_2_BYTES */
          5, /* GL_3_BYTES */
          7, /* GL_4_BYTES */
-       352, /* GL_DOUBLE */
-       123, /* GL_CLEAR */
+       351, /* GL_DOUBLE */
+       122, /* GL_CLEAR */
         49, /* GL_AND */
         51, /* GL_AND_REVERSE */
-       269, /* GL_COPY */
+       268, /* GL_COPY */
         50, /* GL_AND_INVERTED */
-       956, /* GL_NOOP */
-      1744, /* GL_XOR */
-      1018, /* GL_OR */
-       957, /* GL_NOR */
-       427, /* GL_EQUIV */
-       618, /* GL_INVERT */
-      1021, /* GL_OR_REVERSE */
-       270, /* GL_COPY_INVERTED */
-      1020, /* GL_OR_INVERTED */
-       947, /* GL_NAND */
-      1335, /* GL_SET */
-       424, /* GL_EMISSION */
-      1343, /* GL_SHININESS */
+       954, /* GL_NOOP */
+      1742, /* GL_XOR */
+      1016, /* GL_OR */
+       955, /* GL_NOR */
+       425, /* GL_EQUIV */
+       616, /* GL_INVERT */
+      1019, /* GL_OR_REVERSE */
+       269, /* GL_COPY_INVERTED */
+      1018, /* GL_OR_INVERTED */
+       945, /* GL_NAND */
+      1333, /* GL_SET */
+       422, /* GL_EMISSION */
+      1341, /* GL_SHININESS */
         48, /* GL_AMBIENT_AND_DIFFUSE */
-       165, /* GL_COLOR_INDEXES */
-       897, /* GL_MODELVIEW */
-      1189, /* GL_PROJECTION */
-      1445, /* GL_TEXTURE */
-       138, /* GL_COLOR */
-       313, /* GL_DEPTH */
-      1395, /* GL_STENCIL */
-       164, /* GL_COLOR_INDEX */
-      1413, /* GL_STENCIL_INDEX */
-       322, /* GL_DEPTH_COMPONENT */
-      1230, /* GL_RED */
-       548, /* GL_GREEN */
-        89, /* GL_BLUE */
+       164, /* GL_COLOR_INDEXES */
+       895, /* GL_MODELVIEW */
+      1187, /* GL_PROJECTION */
+      1443, /* GL_TEXTURE */
+       137, /* GL_COLOR */
+       312, /* GL_DEPTH */
+      1393, /* GL_STENCIL */
+       163, /* GL_COLOR_INDEX */
+      1411, /* GL_STENCIL_INDEX */
+       321, /* GL_DEPTH_COMPONENT */
+      1228, /* GL_RED */
+       546, /* GL_GREEN */
+        88, /* GL_BLUE */
         31, /* GL_ALPHA */
-      1254, /* GL_RGB */
-      1273, /* GL_RGBA */
-       668, /* GL_LUMINANCE */
-       689, /* GL_LUMINANCE_ALPHA */
-        73, /* GL_BITMAP */
-      1069, /* GL_POINT */
-       638, /* GL_LINE */
-       442, /* GL_FILL */
-      1239, /* GL_RENDER */
-       438, /* GL_FEEDBACK */
-      1329, /* GL_SELECT */
-       443, /* GL_FLAT */
-      1348, /* GL_SMOOTH */
-       619, /* GL_KEEP */
-      1248, /* GL_REPLACE */
-       575, /* GL_INCR */
-       309, /* GL_DECR */
-      1678, /* GL_VENDOR */
-      1245, /* GL_RENDERER */
-      1679, /* GL_VERSION */
-       431, /* GL_EXTENSIONS */
-      1294, /* GL_S */
-      1436, /* GL_T */
-      1220, /* GL_R */
-      1209, /* GL_Q */
-       933, /* GL_MODULATE */
-       308, /* GL_DECAL */
-      1581, /* GL_TEXTURE_ENV_MODE */
-      1580, /* GL_TEXTURE_ENV_COLOR */
-      1579, /* GL_TEXTURE_ENV */
-       432, /* GL_EYE_LINEAR */
-       980, /* GL_OBJECT_LINEAR */
-      1374, /* GL_SPHERE_MAP */
-      1583, /* GL_TEXTURE_GEN_MODE */
-       982, /* GL_OBJECT_PLANE */
-       433, /* GL_EYE_PLANE */
-       948, /* GL_NEAREST */
-       639, /* GL_LINEAR */
-       952, /* GL_NEAREST_MIPMAP_NEAREST */
-       644, /* GL_LINEAR_MIPMAP_NEAREST */
-       951, /* GL_NEAREST_MIPMAP_LINEAR */
-       643, /* GL_LINEAR_MIPMAP_LINEAR */
-      1604, /* GL_TEXTURE_MAG_FILTER */
-      1612, /* GL_TEXTURE_MIN_FILTER */
-      1625, /* GL_TEXTURE_WRAP_S */
-      1626, /* GL_TEXTURE_WRAP_T */
-       117, /* GL_CLAMP */
-      1247, /* GL_REPEAT */
-      1107, /* GL_POLYGON_OFFSET_UNITS */
-      1106, /* GL_POLYGON_OFFSET_POINT */
-      1105, /* GL_POLYGON_OFFSET_LINE */
-      1221, /* GL_R3_G3_B2 */
-      1675, /* GL_V2F */
-      1676, /* GL_V3F */
-       114, /* GL_C4UB_V2F */
-       115, /* GL_C4UB_V3F */
-       112, /* GL_C3F_V3F */
-       945, /* GL_N3F_V3F */
-       113, /* GL_C4F_N3F_V3F */
-      1441, /* GL_T2F_V3F */
-      1443, /* GL_T4F_V4F */
-      1439, /* GL_T2F_C4UB_V3F */
-      1437, /* GL_T2F_C3F_V3F */
-      1440, /* GL_T2F_N3F_V3F */
-      1438, /* GL_T2F_C4F_N3F_V3F */
-      1442, /* GL_T4F_C4F_N3F_V4F */
-       130, /* GL_CLIP_PLANE0 */
-       131, /* GL_CLIP_PLANE1 */
-       132, /* GL_CLIP_PLANE2 */
-       133, /* GL_CLIP_PLANE3 */
-       134, /* GL_CLIP_PLANE4 */
-       135, /* GL_CLIP_PLANE5 */
-       623, /* GL_LIGHT0 */
-       624, /* GL_LIGHT1 */
-       625, /* GL_LIGHT2 */
-       626, /* GL_LIGHT3 */
-       627, /* GL_LIGHT4 */
-       628, /* GL_LIGHT5 */
-       629, /* GL_LIGHT6 */
-       630, /* GL_LIGHT7 */
-       552, /* GL_HINT_BIT */
-       247, /* GL_CONSTANT_COLOR */
-       992, /* GL_ONE_MINUS_CONSTANT_COLOR */
-       242, /* GL_CONSTANT_ALPHA */
-       990, /* GL_ONE_MINUS_CONSTANT_ALPHA */
-        76, /* GL_BLEND_COLOR */
-       512, /* GL_FUNC_ADD */
-       881, /* GL_MIN */
-       793, /* GL_MAX */
-        81, /* GL_BLEND_EQUATION */
-       516, /* GL_FUNC_SUBTRACT */
-       514, /* GL_FUNC_REVERSE_SUBTRACT */
-       250, /* GL_CONVOLUTION_1D */
-       251, /* GL_CONVOLUTION_2D */
-      1332, /* GL_SEPARABLE_2D */
-       254, /* GL_CONVOLUTION_BORDER_MODE */
-       258, /* GL_CONVOLUTION_FILTER_SCALE */
-       256, /* GL_CONVOLUTION_FILTER_BIAS */
-      1231, /* GL_REDUCE */
-       260, /* GL_CONVOLUTION_FORMAT */
-       264, /* GL_CONVOLUTION_WIDTH */
-       262, /* GL_CONVOLUTION_HEIGHT */
-       808, /* GL_MAX_CONVOLUTION_WIDTH */
-       806, /* GL_MAX_CONVOLUTION_HEIGHT */
-      1146, /* GL_POST_CONVOLUTION_RED_SCALE */
-      1142, /* GL_POST_CONVOLUTION_GREEN_SCALE */
-      1137, /* GL_POST_CONVOLUTION_BLUE_SCALE */
-      1133, /* GL_POST_CONVOLUTION_ALPHA_SCALE */
-      1144, /* GL_POST_CONVOLUTION_RED_BIAS */
-      1140, /* GL_POST_CONVOLUTION_GREEN_BIAS */
-      1135, /* GL_POST_CONVOLUTION_BLUE_BIAS */
-      1131, /* GL_POST_CONVOLUTION_ALPHA_BIAS */
-       553, /* GL_HISTOGRAM */
-      1193, /* GL_PROXY_HISTOGRAM */
-       569, /* GL_HISTOGRAM_WIDTH */
-       559, /* GL_HISTOGRAM_FORMAT */
-       565, /* GL_HISTOGRAM_RED_SIZE */
-       561, /* GL_HISTOGRAM_GREEN_SIZE */
-       556, /* GL_HISTOGRAM_BLUE_SIZE */
-       554, /* GL_HISTOGRAM_ALPHA_SIZE */
-       563, /* GL_HISTOGRAM_LUMINANCE_SIZE */
-       567, /* GL_HISTOGRAM_SINK */
-       882, /* GL_MINMAX */
-       884, /* GL_MINMAX_FORMAT */
-       886, /* GL_MINMAX_SINK */
-      1444, /* GL_TABLE_TOO_LARGE_EXT */
-      1656, /* GL_UNSIGNED_BYTE_3_3_2 */
-      1665, /* GL_UNSIGNED_SHORT_4_4_4_4 */
-      1667, /* GL_UNSIGNED_SHORT_5_5_5_1 */
-      1661, /* GL_UNSIGNED_INT_8_8_8_8 */
-      1658, /* GL_UNSIGNED_INT_10_10_10_2 */
-      1104, /* GL_POLYGON_OFFSET_FILL */
-      1103, /* GL_POLYGON_OFFSET_FACTOR */
-      1102, /* GL_POLYGON_OFFSET_BIAS */
-      1251, /* GL_RESCALE_NORMAL */
+      1252, /* GL_RGB */
+      1271, /* GL_RGBA */
+       666, /* GL_LUMINANCE */
+       687, /* GL_LUMINANCE_ALPHA */
+        72, /* GL_BITMAP */
+      1067, /* GL_POINT */
+       636, /* GL_LINE */
+       440, /* GL_FILL */
+      1237, /* GL_RENDER */
+       436, /* GL_FEEDBACK */
+      1327, /* GL_SELECT */
+       441, /* GL_FLAT */
+      1346, /* GL_SMOOTH */
+       617, /* GL_KEEP */
+      1246, /* GL_REPLACE */
+       573, /* GL_INCR */
+       308, /* GL_DECR */
+      1676, /* GL_VENDOR */
+      1243, /* GL_RENDERER */
+      1677, /* GL_VERSION */
+       429, /* GL_EXTENSIONS */
+      1292, /* GL_S */
+      1434, /* GL_T */
+      1218, /* GL_R */
+      1207, /* GL_Q */
+       931, /* GL_MODULATE */
+       307, /* GL_DECAL */
+      1579, /* GL_TEXTURE_ENV_MODE */
+      1578, /* GL_TEXTURE_ENV_COLOR */
+      1577, /* GL_TEXTURE_ENV */
+       430, /* GL_EYE_LINEAR */
+       978, /* GL_OBJECT_LINEAR */
+      1372, /* GL_SPHERE_MAP */
+      1581, /* GL_TEXTURE_GEN_MODE */
+       980, /* GL_OBJECT_PLANE */
+       431, /* GL_EYE_PLANE */
+       946, /* GL_NEAREST */
+       637, /* GL_LINEAR */
+       950, /* GL_NEAREST_MIPMAP_NEAREST */
+       642, /* GL_LINEAR_MIPMAP_NEAREST */
+       949, /* GL_NEAREST_MIPMAP_LINEAR */
+       641, /* GL_LINEAR_MIPMAP_LINEAR */
+      1602, /* GL_TEXTURE_MAG_FILTER */
+      1610, /* GL_TEXTURE_MIN_FILTER */
+      1623, /* GL_TEXTURE_WRAP_S */
+      1624, /* GL_TEXTURE_WRAP_T */
+       116, /* GL_CLAMP */
+      1245, /* GL_REPEAT */
+      1105, /* GL_POLYGON_OFFSET_UNITS */
+      1104, /* GL_POLYGON_OFFSET_POINT */
+      1103, /* GL_POLYGON_OFFSET_LINE */
+      1219, /* GL_R3_G3_B2 */
+      1673, /* GL_V2F */
+      1674, /* GL_V3F */
+       113, /* GL_C4UB_V2F */
+       114, /* GL_C4UB_V3F */
+       111, /* GL_C3F_V3F */
+       943, /* GL_N3F_V3F */
+       112, /* GL_C4F_N3F_V3F */
+      1439, /* GL_T2F_V3F */
+      1441, /* GL_T4F_V4F */
+      1437, /* GL_T2F_C4UB_V3F */
+      1435, /* GL_T2F_C3F_V3F */
+      1438, /* GL_T2F_N3F_V3F */
+      1436, /* GL_T2F_C4F_N3F_V3F */
+      1440, /* GL_T4F_C4F_N3F_V4F */
+       129, /* GL_CLIP_PLANE0 */
+       130, /* GL_CLIP_PLANE1 */
+       131, /* GL_CLIP_PLANE2 */
+       132, /* GL_CLIP_PLANE3 */
+       133, /* GL_CLIP_PLANE4 */
+       134, /* GL_CLIP_PLANE5 */
+       621, /* GL_LIGHT0 */
+       622, /* GL_LIGHT1 */
+       623, /* GL_LIGHT2 */
+       624, /* GL_LIGHT3 */
+       625, /* GL_LIGHT4 */
+       626, /* GL_LIGHT5 */
+       627, /* GL_LIGHT6 */
+       628, /* GL_LIGHT7 */
+       550, /* GL_HINT_BIT */
+       246, /* GL_CONSTANT_COLOR */
+       990, /* GL_ONE_MINUS_CONSTANT_COLOR */
+       241, /* GL_CONSTANT_ALPHA */
+       988, /* GL_ONE_MINUS_CONSTANT_ALPHA */
+        75, /* GL_BLEND_COLOR */
+       510, /* GL_FUNC_ADD */
+       879, /* GL_MIN */
+       791, /* GL_MAX */
+        80, /* GL_BLEND_EQUATION */
+       514, /* GL_FUNC_SUBTRACT */
+       512, /* GL_FUNC_REVERSE_SUBTRACT */
+       249, /* GL_CONVOLUTION_1D */
+       250, /* GL_CONVOLUTION_2D */
+      1330, /* GL_SEPARABLE_2D */
+       253, /* GL_CONVOLUTION_BORDER_MODE */
+       257, /* GL_CONVOLUTION_FILTER_SCALE */
+       255, /* GL_CONVOLUTION_FILTER_BIAS */
+      1229, /* GL_REDUCE */
+       259, /* GL_CONVOLUTION_FORMAT */
+       263, /* GL_CONVOLUTION_WIDTH */
+       261, /* GL_CONVOLUTION_HEIGHT */
+       806, /* GL_MAX_CONVOLUTION_WIDTH */
+       804, /* GL_MAX_CONVOLUTION_HEIGHT */
+      1144, /* GL_POST_CONVOLUTION_RED_SCALE */
+      1140, /* GL_POST_CONVOLUTION_GREEN_SCALE */
+      1135, /* GL_POST_CONVOLUTION_BLUE_SCALE */
+      1131, /* GL_POST_CONVOLUTION_ALPHA_SCALE */
+      1142, /* GL_POST_CONVOLUTION_RED_BIAS */
+      1138, /* GL_POST_CONVOLUTION_GREEN_BIAS */
+      1133, /* GL_POST_CONVOLUTION_BLUE_BIAS */
+      1129, /* GL_POST_CONVOLUTION_ALPHA_BIAS */
+       551, /* GL_HISTOGRAM */
+      1191, /* GL_PROXY_HISTOGRAM */
+       567, /* GL_HISTOGRAM_WIDTH */
+       557, /* GL_HISTOGRAM_FORMAT */
+       563, /* GL_HISTOGRAM_RED_SIZE */
+       559, /* GL_HISTOGRAM_GREEN_SIZE */
+       554, /* GL_HISTOGRAM_BLUE_SIZE */
+       552, /* GL_HISTOGRAM_ALPHA_SIZE */
+       561, /* GL_HISTOGRAM_LUMINANCE_SIZE */
+       565, /* GL_HISTOGRAM_SINK */
+       880, /* GL_MINMAX */
+       882, /* GL_MINMAX_FORMAT */
+       884, /* GL_MINMAX_SINK */
+      1442, /* GL_TABLE_TOO_LARGE_EXT */
+      1654, /* GL_UNSIGNED_BYTE_3_3_2 */
+      1663, /* GL_UNSIGNED_SHORT_4_4_4_4 */
+      1665, /* GL_UNSIGNED_SHORT_5_5_5_1 */
+      1659, /* GL_UNSIGNED_INT_8_8_8_8 */
+      1656, /* GL_UNSIGNED_INT_10_10_10_2 */
+      1102, /* GL_POLYGON_OFFSET_FILL */
+      1101, /* GL_POLYGON_OFFSET_FACTOR */
+      1100, /* GL_POLYGON_OFFSET_BIAS */
+      1249, /* GL_RESCALE_NORMAL */
         36, /* GL_ALPHA4 */
         38, /* GL_ALPHA8 */
         32, /* GL_ALPHA12 */
         34, /* GL_ALPHA16 */
-       679, /* GL_LUMINANCE4 */
-       685, /* GL_LUMINANCE8 */
-       669, /* GL_LUMINANCE12 */
-       675, /* GL_LUMINANCE16 */
-       680, /* GL_LUMINANCE4_ALPHA4 */
-       683, /* GL_LUMINANCE6_ALPHA2 */
-       686, /* GL_LUMINANCE8_ALPHA8 */
-       672, /* GL_LUMINANCE12_ALPHA4 */
-       670, /* GL_LUMINANCE12_ALPHA12 */
-       676, /* GL_LUMINANCE16_ALPHA16 */
-       593, /* GL_INTENSITY */
-       598, /* GL_INTENSITY4 */
-       600, /* GL_INTENSITY8 */
-       594, /* GL_INTENSITY12 */
-       596, /* GL_INTENSITY16 */
-      1263, /* GL_RGB2_EXT */
-      1264, /* GL_RGB4 */
-      1267, /* GL_RGB5 */
-      1271, /* GL_RGB8 */
-      1255, /* GL_RGB10 */
-      1259, /* GL_RGB12 */
-      1261, /* GL_RGB16 */
-      1278, /* GL_RGBA2 */
-      1280, /* GL_RGBA4 */
-      1268, /* GL_RGB5_A1 */
-      1284, /* GL_RGBA8 */
-      1256, /* GL_RGB10_A2 */
-      1274, /* GL_RGBA12 */
-      1276, /* GL_RGBA16 */
-      1617, /* GL_TEXTURE_RED_SIZE */
-      1589, /* GL_TEXTURE_GREEN_SIZE */
-      1528, /* GL_TEXTURE_BLUE_SIZE */
-      1515, /* GL_TEXTURE_ALPHA_SIZE */
-      1602, /* GL_TEXTURE_LUMINANCE_SIZE */
-      1593, /* GL_TEXTURE_INTENSITY_SIZE */
-      1249, /* GL_REPLACE_EXT */
-      1197, /* GL_PROXY_TEXTURE_1D */
-      1200, /* GL_PROXY_TEXTURE_2D */
-      1621, /* GL_TEXTURE_TOO_LARGE_EXT */
-      1614, /* GL_TEXTURE_PRIORITY */
-      1619, /* GL_TEXTURE_RESIDENT */
-      1518, /* GL_TEXTURE_BINDING_1D */
-      1520, /* GL_TEXTURE_BINDING_2D */
-      1522, /* GL_TEXTURE_BINDING_3D */
-      1028, /* GL_PACK_SKIP_IMAGES */
-      1024, /* GL_PACK_IMAGE_HEIGHT */
-      1650, /* GL_UNPACK_SKIP_IMAGES */
-      1647, /* GL_UNPACK_IMAGE_HEIGHT */
-      1514, /* GL_TEXTURE_3D */
-      1203, /* GL_PROXY_TEXTURE_3D */
-      1576, /* GL_TEXTURE_DEPTH */
-      1624, /* GL_TEXTURE_WRAP_R */
-       794, /* GL_MAX_3D_TEXTURE_SIZE */
-      1680, /* GL_VERTEX_ARRAY */
-       959, /* GL_NORMAL_ARRAY */
-       139, /* GL_COLOR_ARRAY */
-       578, /* GL_INDEX_ARRAY */
-      1555, /* GL_TEXTURE_COORD_ARRAY */
-       415, /* GL_EDGE_FLAG_ARRAY */
-      1685, /* GL_VERTEX_ARRAY_SIZE */
-      1687, /* GL_VERTEX_ARRAY_TYPE */
-      1686, /* GL_VERTEX_ARRAY_STRIDE */
-       964, /* GL_NORMAL_ARRAY_TYPE */
-       963, /* GL_NORMAL_ARRAY_STRIDE */
-       143, /* GL_COLOR_ARRAY_SIZE */
-       145, /* GL_COLOR_ARRAY_TYPE */
-       144, /* GL_COLOR_ARRAY_STRIDE */
-       583, /* GL_INDEX_ARRAY_TYPE */
-       582, /* GL_INDEX_ARRAY_STRIDE */
-      1559, /* GL_TEXTURE_COORD_ARRAY_SIZE */
-      1561, /* GL_TEXTURE_COORD_ARRAY_TYPE */
-      1560, /* GL_TEXTURE_COORD_ARRAY_STRIDE */
-       419, /* GL_EDGE_FLAG_ARRAY_STRIDE */
-      1684, /* GL_VERTEX_ARRAY_POINTER */
-       962, /* GL_NORMAL_ARRAY_POINTER */
-       142, /* GL_COLOR_ARRAY_POINTER */
-       581, /* GL_INDEX_ARRAY_POINTER */
-      1558, /* GL_TEXTURE_COORD_ARRAY_POINTER */
-       418, /* GL_EDGE_FLAG_ARRAY_POINTER */
-       938, /* GL_MULTISAMPLE */
-      1306, /* GL_SAMPLE_ALPHA_TO_COVERAGE */
-      1308, /* GL_SAMPLE_ALPHA_TO_ONE */
-      1313, /* GL_SAMPLE_COVERAGE */
-      1310, /* GL_SAMPLE_BUFFERS */
-      1301, /* GL_SAMPLES */
-      1317, /* GL_SAMPLE_COVERAGE_VALUE */
-      1315, /* GL_SAMPLE_COVERAGE_INVERT */
-       170, /* GL_COLOR_MATRIX */
-       172, /* GL_COLOR_MATRIX_STACK_DEPTH */
-       802, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */
-      1129, /* GL_POST_COLOR_MATRIX_RED_SCALE */
-      1125, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */
-      1120, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */
-      1116, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */
-      1127, /* GL_POST_COLOR_MATRIX_RED_BIAS */
-      1123, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */
-      1118, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */
-      1114, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */
-      1538, /* GL_TEXTURE_COLOR_TABLE_SGI */
-      1204, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */
-      1540, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
-        80, /* GL_BLEND_DST_RGB */
-        88, /* GL_BLEND_SRC_RGB */
-        79, /* GL_BLEND_DST_ALPHA */
-        87, /* GL_BLEND_SRC_ALPHA */
-       176, /* GL_COLOR_TABLE */
-      1139, /* GL_POST_CONVOLUTION_COLOR_TABLE */
-      1122, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */
-      1192, /* GL_PROXY_COLOR_TABLE */
-      1196, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */
-      1195, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */
-       200, /* GL_COLOR_TABLE_SCALE */
-       180, /* GL_COLOR_TABLE_BIAS */
-       185, /* GL_COLOR_TABLE_FORMAT */
-       202, /* GL_COLOR_TABLE_WIDTH */
-       197, /* GL_COLOR_TABLE_RED_SIZE */
-       188, /* GL_COLOR_TABLE_GREEN_SIZE */
-       182, /* GL_COLOR_TABLE_BLUE_SIZE */
-       177, /* GL_COLOR_TABLE_ALPHA_SIZE */
-       194, /* GL_COLOR_TABLE_LUMINANCE_SIZE */
-       191, /* GL_COLOR_TABLE_INTENSITY_SIZE */
-        71, /* GL_BGR */
-        72, /* GL_BGRA */
-       816, /* GL_MAX_ELEMENTS_VERTICES */
-       815, /* GL_MAX_ELEMENTS_INDICES */
-      1592, /* GL_TEXTURE_INDEX_SIZE_EXT */
-       136, /* GL_CLIP_VOLUME_CLIPPING_HINT_EXT */
-      1086, /* GL_POINT_SIZE_MIN */
-      1082, /* GL_POINT_SIZE_MAX */
-      1076, /* GL_POINT_FADE_THRESHOLD_SIZE */
-      1072, /* GL_POINT_DISTANCE_ATTENUATION */
-       118, /* GL_CLAMP_TO_BORDER */
-       121, /* GL_CLAMP_TO_EDGE */
-      1613, /* GL_TEXTURE_MIN_LOD */
-      1611, /* GL_TEXTURE_MAX_LOD */
-      1517, /* GL_TEXTURE_BASE_LEVEL */
-      1610, /* GL_TEXTURE_MAX_LEVEL */
-       572, /* GL_IGNORE_BORDER_HP */
-       246, /* GL_CONSTANT_BORDER_HP */
-      1250, /* GL_REPLICATE_BORDER_HP */
-       252, /* GL_CONVOLUTION_BORDER_COLOR */
-       987, /* GL_OCCLUSION_TEST_HP */
-       988, /* GL_OCCLUSION_TEST_RESULT_HP */
-       641, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */
-      1532, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */
-      1534, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */
-      1536, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */
-      1537, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */
-      1535, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */
-      1533, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */
-       798, /* GL_MAX_CLIPMAP_DEPTH_SGIX */
-       799, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */
-      1149, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */
-      1151, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */
-      1148, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */
-      1150, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */
-      1600, /* GL_TEXTURE_LOD_BIAS_S_SGIX */
-      1601, /* GL_TEXTURE_LOD_BIAS_T_SGIX */
-      1599, /* GL_TEXTURE_LOD_BIAS_R_SGIX */
-       518, /* GL_GENERATE_MIPMAP */
-       519, /* GL_GENERATE_MIPMAP_HINT */
-       481, /* GL_FOG_OFFSET_SGIX */
-       482, /* GL_FOG_OFFSET_VALUE_SGIX */
-      1546, /* GL_TEXTURE_COMPARE_SGIX */
-      1545, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */
-      1596, /* GL_TEXTURE_LEQUAL_R_SGIX */
-      1588, /* GL_TEXTURE_GEQUAL_R_SGIX */
-       323, /* GL_DEPTH_COMPONENT16 */
-       326, /* GL_DEPTH_COMPONENT24 */
-       329, /* GL_DEPTH_COMPONENT32 */
-       274, /* GL_CULL_VERTEX_EXT */
-       276, /* GL_CULL_VERTEX_OBJECT_POSITION_EXT */
-       275, /* GL_CULL_VERTEX_EYE_POSITION_EXT */
-      1741, /* GL_WRAP_BORDER_SUN */
-      1539, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */
-       634, /* GL_LIGHT_MODEL_COLOR_CONTROL */
-      1345, /* GL_SINGLE_COLOR */
-      1333, /* GL_SEPARATE_SPECULAR_COLOR */
-      1342, /* GL_SHARED_TEXTURE_PALETTE_EXT */
-      1655, /* GL_UNSIGNED_BYTE_2_3_3_REV */
-      1668, /* GL_UNSIGNED_SHORT_5_6_5 */
-      1669, /* GL_UNSIGNED_SHORT_5_6_5_REV */
-      1666, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */
-      1664, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */
-      1662, /* GL_UNSIGNED_INT_8_8_8_8_REV */
-      1660, /* GL_UNSIGNED_INT_2_10_10_10_REV */
-      1608, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */
-      1609, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */
-      1607, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */
-       889, /* GL_MIRRORED_REPEAT */
-      1289, /* GL_RGB_S3TC */
-      1266, /* GL_RGB4_S3TC */
-      1288, /* GL_RGBA_S3TC */
-      1283, /* GL_RGBA4_S3TC */
-      1286, /* GL_RGBA_DXT5_S3TC */
-      1281, /* GL_RGBA4_DXT5_S3TC */
-       239, /* GL_COMPRESSED_RGB_S3TC_DXT1_EXT */
-       234, /* GL_COMPRESSED_RGBA_S3TC_DXT1_EXT */
-       235, /* GL_COMPRESSED_RGBA_S3TC_DXT3_EXT */
-       236, /* GL_COMPRESSED_RGBA_S3TC_DXT5_EXT */
-       950, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */
-       949, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */
-       642, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */
-       468, /* GL_FOG_COORDINATE_SOURCE */
-       460, /* GL_FOG_COORD */
-       484, /* GL_FRAGMENT_DEPTH */
-       280, /* GL_CURRENT_FOG_COORD */
-       467, /* GL_FOG_COORDINATE_ARRAY_TYPE */
-       466, /* GL_FOG_COORDINATE_ARRAY_STRIDE */
-       465, /* GL_FOG_COORDINATE_ARRAY_POINTER */
-       462, /* GL_FOG_COORDINATE_ARRAY */
-       174, /* GL_COLOR_SUM */
-       299, /* GL_CURRENT_SECONDARY_COLOR */
-      1326, /* GL_SECONDARY_COLOR_ARRAY_SIZE */
-      1328, /* GL_SECONDARY_COLOR_ARRAY_TYPE */
-      1327, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */
-      1325, /* GL_SECONDARY_COLOR_ARRAY_POINTER */
-      1322, /* GL_SECONDARY_COLOR_ARRAY */
-       528, /* GL_GL_CURRENT_RASTER_SECONDARY_COLOR */
+       677, /* GL_LUMINANCE4 */
+       683, /* GL_LUMINANCE8 */
+       667, /* GL_LUMINANCE12 */
+       673, /* GL_LUMINANCE16 */
+       678, /* GL_LUMINANCE4_ALPHA4 */
+       681, /* GL_LUMINANCE6_ALPHA2 */
+       684, /* GL_LUMINANCE8_ALPHA8 */
+       670, /* GL_LUMINANCE12_ALPHA4 */
+       668, /* GL_LUMINANCE12_ALPHA12 */
+       674, /* GL_LUMINANCE16_ALPHA16 */
+       591, /* GL_INTENSITY */
+       596, /* GL_INTENSITY4 */
+       598, /* GL_INTENSITY8 */
+       592, /* GL_INTENSITY12 */
+       594, /* GL_INTENSITY16 */
+      1261, /* GL_RGB2_EXT */
+      1262, /* GL_RGB4 */
+      1265, /* GL_RGB5 */
+      1269, /* GL_RGB8 */
+      1253, /* GL_RGB10 */
+      1257, /* GL_RGB12 */
+      1259, /* GL_RGB16 */
+      1276, /* GL_RGBA2 */
+      1278, /* GL_RGBA4 */
+      1266, /* GL_RGB5_A1 */
+      1282, /* GL_RGBA8 */
+      1254, /* GL_RGB10_A2 */
+      1272, /* GL_RGBA12 */
+      1274, /* GL_RGBA16 */
+      1615, /* GL_TEXTURE_RED_SIZE */
+      1587, /* GL_TEXTURE_GREEN_SIZE */
+      1526, /* GL_TEXTURE_BLUE_SIZE */
+      1513, /* GL_TEXTURE_ALPHA_SIZE */
+      1600, /* GL_TEXTURE_LUMINANCE_SIZE */
+      1591, /* GL_TEXTURE_INTENSITY_SIZE */
+      1247, /* GL_REPLACE_EXT */
+      1195, /* GL_PROXY_TEXTURE_1D */
+      1198, /* GL_PROXY_TEXTURE_2D */
+      1619, /* GL_TEXTURE_TOO_LARGE_EXT */
+      1612, /* GL_TEXTURE_PRIORITY */
+      1617, /* GL_TEXTURE_RESIDENT */
+      1516, /* GL_TEXTURE_BINDING_1D */
+      1518, /* GL_TEXTURE_BINDING_2D */
+      1520, /* GL_TEXTURE_BINDING_3D */
+      1026, /* GL_PACK_SKIP_IMAGES */
+      1022, /* GL_PACK_IMAGE_HEIGHT */
+      1648, /* GL_UNPACK_SKIP_IMAGES */
+      1645, /* GL_UNPACK_IMAGE_HEIGHT */
+      1512, /* GL_TEXTURE_3D */
+      1201, /* GL_PROXY_TEXTURE_3D */
+      1574, /* GL_TEXTURE_DEPTH */
+      1622, /* GL_TEXTURE_WRAP_R */
+       792, /* GL_MAX_3D_TEXTURE_SIZE */
+      1678, /* GL_VERTEX_ARRAY */
+       957, /* GL_NORMAL_ARRAY */
+       138, /* GL_COLOR_ARRAY */
+       576, /* GL_INDEX_ARRAY */
+      1553, /* GL_TEXTURE_COORD_ARRAY */
+       414, /* GL_EDGE_FLAG_ARRAY */
+      1683, /* GL_VERTEX_ARRAY_SIZE */
+      1685, /* GL_VERTEX_ARRAY_TYPE */
+      1684, /* GL_VERTEX_ARRAY_STRIDE */
+       962, /* GL_NORMAL_ARRAY_TYPE */
+       961, /* GL_NORMAL_ARRAY_STRIDE */
+       142, /* GL_COLOR_ARRAY_SIZE */
+       144, /* GL_COLOR_ARRAY_TYPE */
+       143, /* GL_COLOR_ARRAY_STRIDE */
+       581, /* GL_INDEX_ARRAY_TYPE */
+       580, /* GL_INDEX_ARRAY_STRIDE */
+      1557, /* GL_TEXTURE_COORD_ARRAY_SIZE */
+      1559, /* GL_TEXTURE_COORD_ARRAY_TYPE */
+      1558, /* GL_TEXTURE_COORD_ARRAY_STRIDE */
+       418, /* GL_EDGE_FLAG_ARRAY_STRIDE */
+      1682, /* GL_VERTEX_ARRAY_POINTER */
+       960, /* GL_NORMAL_ARRAY_POINTER */
+       141, /* GL_COLOR_ARRAY_POINTER */
+       579, /* GL_INDEX_ARRAY_POINTER */
+      1556, /* GL_TEXTURE_COORD_ARRAY_POINTER */
+       417, /* GL_EDGE_FLAG_ARRAY_POINTER */
+       936, /* GL_MULTISAMPLE */
+      1304, /* GL_SAMPLE_ALPHA_TO_COVERAGE */
+      1306, /* GL_SAMPLE_ALPHA_TO_ONE */
+      1311, /* GL_SAMPLE_COVERAGE */
+      1308, /* GL_SAMPLE_BUFFERS */
+      1299, /* GL_SAMPLES */
+      1315, /* GL_SAMPLE_COVERAGE_VALUE */
+      1313, /* GL_SAMPLE_COVERAGE_INVERT */
+       169, /* GL_COLOR_MATRIX */
+       171, /* GL_COLOR_MATRIX_STACK_DEPTH */
+       800, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */
+      1127, /* GL_POST_COLOR_MATRIX_RED_SCALE */
+      1123, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */
+      1118, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */
+      1114, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */
+      1125, /* GL_POST_COLOR_MATRIX_RED_BIAS */
+      1121, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */
+      1116, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */
+      1112, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */
+      1536, /* GL_TEXTURE_COLOR_TABLE_SGI */
+      1202, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */
+      1538, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
+        79, /* GL_BLEND_DST_RGB */
+        87, /* GL_BLEND_SRC_RGB */
+        78, /* GL_BLEND_DST_ALPHA */
+        86, /* GL_BLEND_SRC_ALPHA */
+       175, /* GL_COLOR_TABLE */
+      1137, /* GL_POST_CONVOLUTION_COLOR_TABLE */
+      1120, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */
+      1190, /* GL_PROXY_COLOR_TABLE */
+      1194, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */
+      1193, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */
+       199, /* GL_COLOR_TABLE_SCALE */
+       179, /* GL_COLOR_TABLE_BIAS */
+       184, /* GL_COLOR_TABLE_FORMAT */
+       201, /* GL_COLOR_TABLE_WIDTH */
+       196, /* GL_COLOR_TABLE_RED_SIZE */
+       187, /* GL_COLOR_TABLE_GREEN_SIZE */
+       181, /* GL_COLOR_TABLE_BLUE_SIZE */
+       176, /* GL_COLOR_TABLE_ALPHA_SIZE */
+       193, /* GL_COLOR_TABLE_LUMINANCE_SIZE */
+       190, /* GL_COLOR_TABLE_INTENSITY_SIZE */
+        70, /* GL_BGR */
+        71, /* GL_BGRA */
+       814, /* GL_MAX_ELEMENTS_VERTICES */
+       813, /* GL_MAX_ELEMENTS_INDICES */
+      1590, /* GL_TEXTURE_INDEX_SIZE_EXT */
+       135, /* GL_CLIP_VOLUME_CLIPPING_HINT_EXT */
+      1084, /* GL_POINT_SIZE_MIN */
+      1080, /* GL_POINT_SIZE_MAX */
+      1074, /* GL_POINT_FADE_THRESHOLD_SIZE */
+      1070, /* GL_POINT_DISTANCE_ATTENUATION */
+       117, /* GL_CLAMP_TO_BORDER */
+       120, /* GL_CLAMP_TO_EDGE */
+      1611, /* GL_TEXTURE_MIN_LOD */
+      1609, /* GL_TEXTURE_MAX_LOD */
+      1515, /* GL_TEXTURE_BASE_LEVEL */
+      1608, /* GL_TEXTURE_MAX_LEVEL */
+       570, /* GL_IGNORE_BORDER_HP */
+       245, /* GL_CONSTANT_BORDER_HP */
+      1248, /* GL_REPLICATE_BORDER_HP */
+       251, /* GL_CONVOLUTION_BORDER_COLOR */
+       985, /* GL_OCCLUSION_TEST_HP */
+       986, /* GL_OCCLUSION_TEST_RESULT_HP */
+       639, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */
+      1530, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */
+      1532, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */
+      1534, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */
+      1535, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */
+      1533, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */
+      1531, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */
+       796, /* GL_MAX_CLIPMAP_DEPTH_SGIX */
+       797, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */
+      1147, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */
+      1149, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */
+      1146, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */
+      1148, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */
+      1598, /* GL_TEXTURE_LOD_BIAS_S_SGIX */
+      1599, /* GL_TEXTURE_LOD_BIAS_T_SGIX */
+      1597, /* GL_TEXTURE_LOD_BIAS_R_SGIX */
+       516, /* GL_GENERATE_MIPMAP */
+       517, /* GL_GENERATE_MIPMAP_HINT */
+       479, /* GL_FOG_OFFSET_SGIX */
+       480, /* GL_FOG_OFFSET_VALUE_SGIX */
+      1544, /* GL_TEXTURE_COMPARE_SGIX */
+      1543, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */
+      1594, /* GL_TEXTURE_LEQUAL_R_SGIX */
+      1586, /* GL_TEXTURE_GEQUAL_R_SGIX */
+       322, /* GL_DEPTH_COMPONENT16 */
+       325, /* GL_DEPTH_COMPONENT24 */
+       328, /* GL_DEPTH_COMPONENT32 */
+       273, /* GL_CULL_VERTEX_EXT */
+       275, /* GL_CULL_VERTEX_OBJECT_POSITION_EXT */
+       274, /* GL_CULL_VERTEX_EYE_POSITION_EXT */
+      1739, /* GL_WRAP_BORDER_SUN */
+      1537, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */
+       632, /* GL_LIGHT_MODEL_COLOR_CONTROL */
+      1343, /* GL_SINGLE_COLOR */
+      1331, /* GL_SEPARATE_SPECULAR_COLOR */
+      1340, /* GL_SHARED_TEXTURE_PALETTE_EXT */
+      1653, /* GL_UNSIGNED_BYTE_2_3_3_REV */
+      1666, /* GL_UNSIGNED_SHORT_5_6_5 */
+      1667, /* GL_UNSIGNED_SHORT_5_6_5_REV */
+      1664, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */
+      1662, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */
+      1660, /* GL_UNSIGNED_INT_8_8_8_8_REV */
+      1658, /* GL_UNSIGNED_INT_2_10_10_10_REV */
+      1606, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */
+      1607, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */
+      1605, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */
+       887, /* GL_MIRRORED_REPEAT */
+      1287, /* GL_RGB_S3TC */
+      1264, /* GL_RGB4_S3TC */
+      1286, /* GL_RGBA_S3TC */
+      1281, /* GL_RGBA4_S3TC */
+      1284, /* GL_RGBA_DXT5_S3TC */
+      1279, /* GL_RGBA4_DXT5_S3TC */
+       238, /* GL_COMPRESSED_RGB_S3TC_DXT1_EXT */
+       233, /* GL_COMPRESSED_RGBA_S3TC_DXT1_EXT */
+       234, /* GL_COMPRESSED_RGBA_S3TC_DXT3_EXT */
+       235, /* GL_COMPRESSED_RGBA_S3TC_DXT5_EXT */
+       948, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */
+       947, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */
+       640, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */
+       466, /* GL_FOG_COORDINATE_SOURCE */
+       458, /* GL_FOG_COORD */
+       482, /* GL_FRAGMENT_DEPTH */
+       279, /* GL_CURRENT_FOG_COORD */
+       465, /* GL_FOG_COORDINATE_ARRAY_TYPE */
+       464, /* GL_FOG_COORDINATE_ARRAY_STRIDE */
+       463, /* GL_FOG_COORDINATE_ARRAY_POINTER */
+       460, /* GL_FOG_COORDINATE_ARRAY */
+       173, /* GL_COLOR_SUM */
+       298, /* GL_CURRENT_SECONDARY_COLOR */
+      1324, /* GL_SECONDARY_COLOR_ARRAY_SIZE */
+      1326, /* GL_SECONDARY_COLOR_ARRAY_TYPE */
+      1325, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */
+      1323, /* GL_SECONDARY_COLOR_ARRAY_POINTER */
+      1320, /* GL_SECONDARY_COLOR_ARRAY */
+       526, /* GL_GL_CURRENT_RASTER_SECONDARY_COLOR */
         28, /* GL_ALIASED_POINT_SIZE_RANGE */
         27, /* GL_ALIASED_LINE_WIDTH_RANGE */
-      1446, /* GL_TEXTURE0 */
-      1448, /* GL_TEXTURE1 */
-      1470, /* GL_TEXTURE2 */
-      1492, /* GL_TEXTURE3 */
-      1498, /* GL_TEXTURE4 */
-      1500, /* GL_TEXTURE5 */
-      1502, /* GL_TEXTURE6 */
-      1504, /* GL_TEXTURE7 */
-      1506, /* GL_TEXTURE8 */
-      1508, /* GL_TEXTURE9 */
-      1449, /* GL_TEXTURE10 */
-      1451, /* GL_TEXTURE11 */
-      1453, /* GL_TEXTURE12 */
-      1455, /* GL_TEXTURE13 */
-      1457, /* GL_TEXTURE14 */
-      1459, /* GL_TEXTURE15 */
-      1461, /* GL_TEXTURE16 */
-      1463, /* GL_TEXTURE17 */
-      1465, /* GL_TEXTURE18 */
-      1467, /* GL_TEXTURE19 */
-      1471, /* GL_TEXTURE20 */
-      1473, /* GL_TEXTURE21 */
-      1475, /* GL_TEXTURE22 */
-      1477, /* GL_TEXTURE23 */
-      1479, /* GL_TEXTURE24 */
-      1481, /* GL_TEXTURE25 */
-      1483, /* GL_TEXTURE26 */
-      1485, /* GL_TEXTURE27 */
-      1487, /* GL_TEXTURE28 */
-      1489, /* GL_TEXTURE29 */
-      1493, /* GL_TEXTURE30 */
-      1495, /* GL_TEXTURE31 */
+      1444, /* GL_TEXTURE0 */
+      1446, /* GL_TEXTURE1 */
+      1468, /* GL_TEXTURE2 */
+      1490, /* GL_TEXTURE3 */
+      1496, /* GL_TEXTURE4 */
+      1498, /* GL_TEXTURE5 */
+      1500, /* GL_TEXTURE6 */
+      1502, /* GL_TEXTURE7 */
+      1504, /* GL_TEXTURE8 */
+      1506, /* GL_TEXTURE9 */
+      1447, /* GL_TEXTURE10 */
+      1449, /* GL_TEXTURE11 */
+      1451, /* GL_TEXTURE12 */
+      1453, /* GL_TEXTURE13 */
+      1455, /* GL_TEXTURE14 */
+      1457, /* GL_TEXTURE15 */
+      1459, /* GL_TEXTURE16 */
+      1461, /* GL_TEXTURE17 */
+      1463, /* GL_TEXTURE18 */
+      1465, /* GL_TEXTURE19 */
+      1469, /* GL_TEXTURE20 */
+      1471, /* GL_TEXTURE21 */
+      1473, /* GL_TEXTURE22 */
+      1475, /* GL_TEXTURE23 */
+      1477, /* GL_TEXTURE24 */
+      1479, /* GL_TEXTURE25 */
+      1481, /* GL_TEXTURE26 */
+      1483, /* GL_TEXTURE27 */
+      1485, /* GL_TEXTURE28 */
+      1487, /* GL_TEXTURE29 */
+      1491, /* GL_TEXTURE30 */
+      1493, /* GL_TEXTURE31 */
         18, /* GL_ACTIVE_TEXTURE */
-       124, /* GL_CLIENT_ACTIVE_TEXTURE */
-       867, /* GL_MAX_TEXTURE_UNITS */
-      1634, /* GL_TRANSPOSE_MODELVIEW_MATRIX */
-      1637, /* GL_TRANSPOSE_PROJECTION_MATRIX */
-      1639, /* GL_TRANSPOSE_TEXTURE_MATRIX */
-      1631, /* GL_TRANSPOSE_COLOR_MATRIX */
-      1434, /* GL_SUBTRACT */
-       856, /* GL_MAX_RENDERBUFFER_SIZE_EXT */
-       222, /* GL_COMPRESSED_ALPHA */
-       226, /* GL_COMPRESSED_LUMINANCE */
-       227, /* GL_COMPRESSED_LUMINANCE_ALPHA */
-       224, /* GL_COMPRESSED_INTENSITY */
-       230, /* GL_COMPRESSED_RGB */
-       231, /* GL_COMPRESSED_RGBA */
-      1553, /* GL_TEXTURE_COMPRESSION_HINT */
-      1615, /* GL_TEXTURE_RECTANGLE_ARB */
-      1525, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */
-      1207, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */
-       854, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */
-       335, /* GL_DEPTH_STENCIL_NV */
-      1659, /* GL_UNSIGNED_INT_24_8_NV */
-       863, /* GL_MAX_TEXTURE_LOD_BIAS */
-      1606, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */
-       864, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */
-      1582, /* GL_TEXTURE_FILTER_CONTROL */
-      1597, /* GL_TEXTURE_LOD_BIAS */
-       207, /* GL_COMBINE4 */
-       857, /* GL_MAX_SHININESS_NV */
-       858, /* GL_MAX_SPOT_EXPONENT_NV */
-       576, /* GL_INCR_WRAP */
-       310, /* GL_DECR_WRAP */
-       909, /* GL_MODELVIEW1_ARB */
-       965, /* GL_NORMAL_MAP */
-      1236, /* GL_REFLECTION_MAP */
-      1562, /* GL_TEXTURE_CUBE_MAP */
-      1523, /* GL_TEXTURE_BINDING_CUBE_MAP */
-      1570, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */
-      1564, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */
-      1572, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */
-      1566, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */
-      1574, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */
-      1568, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */
-      1205, /* GL_PROXY_TEXTURE_CUBE_MAP */
-       810, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */
-       944, /* GL_MULTISAMPLE_FILTER_HINT_NV */
-       476, /* GL_FOG_DISTANCE_MODE_NV */
-       435, /* GL_EYE_RADIAL_NV */
-       434, /* GL_EYE_PLANE_ABSOLUTE_NV */
-       206, /* GL_COMBINE */
-       213, /* GL_COMBINE_RGB */
-       208, /* GL_COMBINE_ALPHA */
-      1290, /* GL_RGB_SCALE */
+       123, /* GL_CLIENT_ACTIVE_TEXTURE */
+       865, /* GL_MAX_TEXTURE_UNITS */
+      1632, /* GL_TRANSPOSE_MODELVIEW_MATRIX */
+      1635, /* GL_TRANSPOSE_PROJECTION_MATRIX */
+      1637, /* GL_TRANSPOSE_TEXTURE_MATRIX */
+      1629, /* GL_TRANSPOSE_COLOR_MATRIX */
+      1432, /* GL_SUBTRACT */
+       854, /* GL_MAX_RENDERBUFFER_SIZE_EXT */
+       221, /* GL_COMPRESSED_ALPHA */
+       225, /* GL_COMPRESSED_LUMINANCE */
+       226, /* GL_COMPRESSED_LUMINANCE_ALPHA */
+       223, /* GL_COMPRESSED_INTENSITY */
+       229, /* GL_COMPRESSED_RGB */
+       230, /* GL_COMPRESSED_RGBA */
+      1551, /* GL_TEXTURE_COMPRESSION_HINT */
+      1613, /* GL_TEXTURE_RECTANGLE_ARB */
+      1523, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */
+      1205, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */
+       852, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */
+       334, /* GL_DEPTH_STENCIL_NV */
+      1657, /* GL_UNSIGNED_INT_24_8_NV */
+       861, /* GL_MAX_TEXTURE_LOD_BIAS */
+      1604, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */
+       862, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */
+      1580, /* GL_TEXTURE_FILTER_CONTROL */
+      1595, /* GL_TEXTURE_LOD_BIAS */
+       206, /* GL_COMBINE4 */
+       855, /* GL_MAX_SHININESS_NV */
+       856, /* GL_MAX_SPOT_EXPONENT_NV */
+       574, /* GL_INCR_WRAP */
+       309, /* GL_DECR_WRAP */
+       907, /* GL_MODELVIEW1_ARB */
+       963, /* GL_NORMAL_MAP */
+      1234, /* GL_REFLECTION_MAP */
+      1560, /* GL_TEXTURE_CUBE_MAP */
+      1521, /* GL_TEXTURE_BINDING_CUBE_MAP */
+      1568, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */
+      1562, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */
+      1570, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */
+      1564, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */
+      1572, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */
+      1566, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */
+      1203, /* GL_PROXY_TEXTURE_CUBE_MAP */
+       808, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */
+       942, /* GL_MULTISAMPLE_FILTER_HINT_NV */
+       474, /* GL_FOG_DISTANCE_MODE_NV */
+       433, /* GL_EYE_RADIAL_NV */
+       432, /* GL_EYE_PLANE_ABSOLUTE_NV */
+       205, /* GL_COMBINE */
+       212, /* GL_COMBINE_RGB */
+       207, /* GL_COMBINE_ALPHA */
+      1288, /* GL_RGB_SCALE */
         24, /* GL_ADD_SIGNED */
-       603, /* GL_INTERPOLATE */
-       241, /* GL_CONSTANT */
-      1155, /* GL_PRIMARY_COLOR */
-      1152, /* GL_PREVIOUS */
-      1356, /* GL_SOURCE0_RGB */
-      1362, /* GL_SOURCE1_RGB */
-      1368, /* GL_SOURCE2_RGB */
-      1372, /* GL_SOURCE3_RGB_NV */
-      1353, /* GL_SOURCE0_ALPHA */
-      1359, /* GL_SOURCE1_ALPHA */
-      1365, /* GL_SOURCE2_ALPHA */
-      1371, /* GL_SOURCE3_ALPHA_NV */
-      1001, /* GL_OPERAND0_RGB */
-      1007, /* GL_OPERAND1_RGB */
-      1013, /* GL_OPERAND2_RGB */
-      1017, /* GL_OPERAND3_RGB_NV */
-       998, /* GL_OPERAND0_ALPHA */
-      1004, /* GL_OPERAND1_ALPHA */
-      1010, /* GL_OPERAND2_ALPHA */
-      1016, /* GL_OPERAND3_ALPHA_NV */
-      1681, /* GL_VERTEX_ARRAY_BINDING_APPLE */
-      1745, /* GL_YCBCR_422_APPLE */
-      1670, /* GL_UNSIGNED_SHORT_8_8_APPLE */
-      1672, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */
-      1347, /* GL_SLICE_ACCUM_SUN */
-      1212, /* GL_QUAD_MESH_SUN */
-      1643, /* GL_TRIANGLE_MESH_SUN */
-      1719, /* GL_VERTEX_PROGRAM_ARB */
-      1730, /* GL_VERTEX_STATE_PROGRAM_NV */
-      1706, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */
-      1712, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */
-      1714, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */
-      1716, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */
-       301, /* GL_CURRENT_VERTEX_ATTRIB */
-      1168, /* GL_PROGRAM_LENGTH_ARB */
-      1182, /* GL_PROGRAM_STRING_ARB */
-       931, /* GL_MODELVIEW_PROJECTION_NV */
-       571, /* GL_IDENTITY_NV */
-       616, /* GL_INVERSE_NV */
-      1636, /* GL_TRANSPOSE_NV */
-       617, /* GL_INVERSE_TRANSPOSE_NV */
-       840, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */
-       839, /* GL_MAX_PROGRAM_MATRICES_ARB */
-       747, /* GL_MATRIX0_NV */
-       759, /* GL_MATRIX1_NV */
-       771, /* GL_MATRIX2_NV */
-       775, /* GL_MATRIX3_NV */
-       777, /* GL_MATRIX4_NV */
-       779, /* GL_MATRIX5_NV */
-       781, /* GL_MATRIX6_NV */
-       783, /* GL_MATRIX7_NV */
-       286, /* GL_CURRENT_MATRIX_STACK_DEPTH_ARB */
-       283, /* GL_CURRENT_MATRIX_ARB */
-      1722, /* GL_VERTEX_PROGRAM_POINT_SIZE */
-      1725, /* GL_VERTEX_PROGRAM_TWO_SIDE */
-      1180, /* GL_PROGRAM_PARAMETER_NV */
-      1710, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */
-      1184, /* GL_PROGRAM_TARGET_NV */
-      1181, /* GL_PROGRAM_RESIDENT_NV */
-      1628, /* GL_TRACK_MATRIX_NV */
-      1629, /* GL_TRACK_MATRIX_TRANSFORM_NV */
-      1720, /* GL_VERTEX_PROGRAM_BINDING_NV */
-      1162, /* GL_PROGRAM_ERROR_POSITION_ARB */
-       320, /* GL_DEPTH_CLAMP_NV */
-      1688, /* GL_VERTEX_ATTRIB_ARRAY0_NV */
-      1695, /* GL_VERTEX_ATTRIB_ARRAY1_NV */
-      1696, /* GL_VERTEX_ATTRIB_ARRAY2_NV */
-      1697, /* GL_VERTEX_ATTRIB_ARRAY3_NV */
-      1698, /* GL_VERTEX_ATTRIB_ARRAY4_NV */
-      1699, /* GL_VERTEX_ATTRIB_ARRAY5_NV */
-      1700, /* GL_VERTEX_ATTRIB_ARRAY6_NV */
-      1701, /* GL_VERTEX_ATTRIB_ARRAY7_NV */
-      1702, /* GL_VERTEX_ATTRIB_ARRAY8_NV */
-      1703, /* GL_VERTEX_ATTRIB_ARRAY9_NV */
-      1689, /* GL_VERTEX_ATTRIB_ARRAY10_NV */
-      1690, /* GL_VERTEX_ATTRIB_ARRAY11_NV */
-      1691, /* GL_VERTEX_ATTRIB_ARRAY12_NV */
-      1692, /* GL_VERTEX_ATTRIB_ARRAY13_NV */
-      1693, /* GL_VERTEX_ATTRIB_ARRAY14_NV */
-      1694, /* GL_VERTEX_ATTRIB_ARRAY15_NV */
-       701, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */
-       708, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */
-       709, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */
-       710, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */
-       711, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */
-       712, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */
-       713, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */
-       714, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */
-       715, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */
-       716, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */
-       702, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */
-       703, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */
-       704, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */
-       705, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */
-       706, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */
-       707, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */
-       728, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */
-       735, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */
-       736, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */
-       737, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */
-       738, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */
-       739, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */
-       740, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */
-      1161, /* GL_PROGRAM_BINDING_ARB */
-       742, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */
-       743, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */
-       729, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */
-       730, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */
-       731, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */
-       732, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */
-       733, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */
-       734, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */
-      1551, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */
-      1548, /* GL_TEXTURE_COMPRESSED */
-       970, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */
-       240, /* GL_COMPRESSED_TEXTURE_FORMATS */
-       879, /* GL_MAX_VERTEX_UNITS_ARB */
+       601, /* GL_INTERPOLATE */
+       240, /* GL_CONSTANT */
+      1153, /* GL_PRIMARY_COLOR */
+      1150, /* GL_PREVIOUS */
+      1354, /* GL_SOURCE0_RGB */
+      1360, /* GL_SOURCE1_RGB */
+      1366, /* GL_SOURCE2_RGB */
+      1370, /* GL_SOURCE3_RGB_NV */
+      1351, /* GL_SOURCE0_ALPHA */
+      1357, /* GL_SOURCE1_ALPHA */
+      1363, /* GL_SOURCE2_ALPHA */
+      1369, /* GL_SOURCE3_ALPHA_NV */
+       999, /* GL_OPERAND0_RGB */
+      1005, /* GL_OPERAND1_RGB */
+      1011, /* GL_OPERAND2_RGB */
+      1015, /* GL_OPERAND3_RGB_NV */
+       996, /* GL_OPERAND0_ALPHA */
+      1002, /* GL_OPERAND1_ALPHA */
+      1008, /* GL_OPERAND2_ALPHA */
+      1014, /* GL_OPERAND3_ALPHA_NV */
+      1679, /* GL_VERTEX_ARRAY_BINDING_APPLE */
+      1743, /* GL_YCBCR_422_APPLE */
+      1668, /* GL_UNSIGNED_SHORT_8_8_APPLE */
+      1670, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */
+      1345, /* GL_SLICE_ACCUM_SUN */
+      1210, /* GL_QUAD_MESH_SUN */
+      1641, /* GL_TRIANGLE_MESH_SUN */
+      1717, /* GL_VERTEX_PROGRAM_ARB */
+      1728, /* GL_VERTEX_STATE_PROGRAM_NV */
+      1704, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */
+      1710, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */
+      1712, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */
+      1714, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */
+       300, /* GL_CURRENT_VERTEX_ATTRIB */
+      1166, /* GL_PROGRAM_LENGTH_ARB */
+      1180, /* GL_PROGRAM_STRING_ARB */
+       929, /* GL_MODELVIEW_PROJECTION_NV */
+       569, /* GL_IDENTITY_NV */
+       614, /* GL_INVERSE_NV */
+      1634, /* GL_TRANSPOSE_NV */
+       615, /* GL_INVERSE_TRANSPOSE_NV */
+       838, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */
+       837, /* GL_MAX_PROGRAM_MATRICES_ARB */
+       745, /* GL_MATRIX0_NV */
+       757, /* GL_MATRIX1_NV */
+       769, /* GL_MATRIX2_NV */
+       773, /* GL_MATRIX3_NV */
+       775, /* GL_MATRIX4_NV */
+       777, /* GL_MATRIX5_NV */
+       779, /* GL_MATRIX6_NV */
+       781, /* GL_MATRIX7_NV */
+       285, /* GL_CURRENT_MATRIX_STACK_DEPTH_ARB */
+       282, /* GL_CURRENT_MATRIX_ARB */
+      1720, /* GL_VERTEX_PROGRAM_POINT_SIZE */
+      1723, /* GL_VERTEX_PROGRAM_TWO_SIDE */
+      1178, /* GL_PROGRAM_PARAMETER_NV */
+      1708, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */
+      1182, /* GL_PROGRAM_TARGET_NV */
+      1179, /* GL_PROGRAM_RESIDENT_NV */
+      1626, /* GL_TRACK_MATRIX_NV */
+      1627, /* GL_TRACK_MATRIX_TRANSFORM_NV */
+      1718, /* GL_VERTEX_PROGRAM_BINDING_NV */
+      1160, /* GL_PROGRAM_ERROR_POSITION_ARB */
+       319, /* GL_DEPTH_CLAMP_NV */
+      1686, /* GL_VERTEX_ATTRIB_ARRAY0_NV */
+      1693, /* GL_VERTEX_ATTRIB_ARRAY1_NV */
+      1694, /* GL_VERTEX_ATTRIB_ARRAY2_NV */
+      1695, /* GL_VERTEX_ATTRIB_ARRAY3_NV */
+      1696, /* GL_VERTEX_ATTRIB_ARRAY4_NV */
+      1697, /* GL_VERTEX_ATTRIB_ARRAY5_NV */
+      1698, /* GL_VERTEX_ATTRIB_ARRAY6_NV */
+      1699, /* GL_VERTEX_ATTRIB_ARRAY7_NV */
+      1700, /* GL_VERTEX_ATTRIB_ARRAY8_NV */
+      1701, /* GL_VERTEX_ATTRIB_ARRAY9_NV */
+      1687, /* GL_VERTEX_ATTRIB_ARRAY10_NV */
+      1688, /* GL_VERTEX_ATTRIB_ARRAY11_NV */
+      1689, /* GL_VERTEX_ATTRIB_ARRAY12_NV */
+      1690, /* GL_VERTEX_ATTRIB_ARRAY13_NV */
+      1691, /* GL_VERTEX_ATTRIB_ARRAY14_NV */
+      1692, /* GL_VERTEX_ATTRIB_ARRAY15_NV */
+       699, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */
+       706, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */
+       707, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */
+       708, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */
+       709, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */
+       710, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */
+       711, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */
+       712, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */
+       713, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */
+       714, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */
+       700, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */
+       701, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */
+       702, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */
+       703, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */
+       704, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */
+       705, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */
+       726, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */
+       733, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */
+       734, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */
+       735, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */
+       736, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */
+       737, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */
+       738, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */
+      1159, /* GL_PROGRAM_BINDING_ARB */
+       740, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */
+       741, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */
+       727, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */
+       728, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */
+       729, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */
+       730, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */
+       731, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */
+       732, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */
+      1549, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */
+      1546, /* GL_TEXTURE_COMPRESSED */
+       968, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */
+       239, /* GL_COMPRESSED_TEXTURE_FORMATS */
+       877, /* GL_MAX_VERTEX_UNITS_ARB */
         22, /* GL_ACTIVE_VERTEX_UNITS_ARB */
-      1740, /* GL_WEIGHT_SUM_UNITY_ARB */
-      1718, /* GL_VERTEX_BLEND_ARB */
-       303, /* GL_CURRENT_WEIGHT_ARB */
-      1739, /* GL_WEIGHT_ARRAY_TYPE_ARB */
-      1738, /* GL_WEIGHT_ARRAY_STRIDE_ARB */
-      1737, /* GL_WEIGHT_ARRAY_SIZE_ARB */
-      1736, /* GL_WEIGHT_ARRAY_POINTER_ARB */
-      1733, /* GL_WEIGHT_ARRAY_ARB */
-       346, /* GL_DOT3_RGB */
-       347, /* GL_DOT3_RGBA */
-       238, /* GL_COMPRESSED_RGB_FXT1_3DFX */
-       233, /* GL_COMPRESSED_RGBA_FXT1_3DFX */
-       939, /* GL_MULTISAMPLE_3DFX */
-      1311, /* GL_SAMPLE_BUFFERS_3DFX */
-      1302, /* GL_SAMPLES_3DFX */
-       920, /* GL_MODELVIEW2_ARB */
-       923, /* GL_MODELVIEW3_ARB */
-       924, /* GL_MODELVIEW4_ARB */
-       925, /* GL_MODELVIEW5_ARB */
-       926, /* GL_MODELVIEW6_ARB */
-       927, /* GL_MODELVIEW7_ARB */
-       928, /* GL_MODELVIEW8_ARB */
-       929, /* GL_MODELVIEW9_ARB */
-       899, /* GL_MODELVIEW10_ARB */
-       900, /* GL_MODELVIEW11_ARB */
-       901, /* GL_MODELVIEW12_ARB */
-       902, /* GL_MODELVIEW13_ARB */
-       903, /* GL_MODELVIEW14_ARB */
-       904, /* GL_MODELVIEW15_ARB */
-       905, /* GL_MODELVIEW16_ARB */
-       906, /* GL_MODELVIEW17_ARB */
-       907, /* GL_MODELVIEW18_ARB */
-       908, /* GL_MODELVIEW19_ARB */
-       910, /* GL_MODELVIEW20_ARB */
-       911, /* GL_MODELVIEW21_ARB */
-       912, /* GL_MODELVIEW22_ARB */
-       913, /* GL_MODELVIEW23_ARB */
-       914, /* GL_MODELVIEW24_ARB */
-       915, /* GL_MODELVIEW25_ARB */
-       916, /* GL_MODELVIEW26_ARB */
-       917, /* GL_MODELVIEW27_ARB */
-       918, /* GL_MODELVIEW28_ARB */
-       919, /* GL_MODELVIEW29_ARB */
-       921, /* GL_MODELVIEW30_ARB */
-       922, /* GL_MODELVIEW31_ARB */
-       351, /* GL_DOT3_RGB_EXT */
-       349, /* GL_DOT3_RGBA_EXT */
-       893, /* GL_MIRROR_CLAMP_EXT */
-       896, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */
-       934, /* GL_MODULATE_ADD_ATI */
-       935, /* GL_MODULATE_SIGNED_ADD_ATI */
-       936, /* GL_MODULATE_SUBTRACT_ATI */
-      1746, /* GL_YCBCR_MESA */
-      1025, /* GL_PACK_INVERT_MESA */
-       306, /* GL_DEBUG_OBJECT_MESA */
-       307, /* GL_DEBUG_PRINT_MESA */
-       305, /* GL_DEBUG_ASSERT_MESA */
-       107, /* GL_BUFFER_SIZE */
-       109, /* GL_BUFFER_USAGE */
-      1399, /* GL_STENCIL_BACK_FUNC */
-      1397, /* GL_STENCIL_BACK_FAIL */
-      1401, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */
-      1403, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */
-       485, /* GL_FRAGMENT_PROGRAM_ARB */
-      1159, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */
-      1187, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */
-      1186, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */
-      1171, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
-      1177, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
-      1176, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
-       829, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */
-       852, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */
-       851, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */
-       842, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
-       848, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
-       847, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
-       812, /* GL_MAX_DRAW_BUFFERS */
-       355, /* GL_DRAW_BUFFER0 */
-       358, /* GL_DRAW_BUFFER1 */
-       379, /* GL_DRAW_BUFFER2 */
-       382, /* GL_DRAW_BUFFER3 */
-       385, /* GL_DRAW_BUFFER4 */
-       388, /* GL_DRAW_BUFFER5 */
-       391, /* GL_DRAW_BUFFER6 */
-       394, /* GL_DRAW_BUFFER7 */
-       397, /* GL_DRAW_BUFFER8 */
-       400, /* GL_DRAW_BUFFER9 */
-       359, /* GL_DRAW_BUFFER10 */
-       362, /* GL_DRAW_BUFFER11 */
-       365, /* GL_DRAW_BUFFER12 */
-       368, /* GL_DRAW_BUFFER13 */
-       371, /* GL_DRAW_BUFFER14 */
-       374, /* GL_DRAW_BUFFER15 */
-        82, /* GL_BLEND_EQUATION_ALPHA */
-       792, /* GL_MATRIX_PALETTE_ARB */
-       823, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */
-       826, /* GL_MAX_PALETTE_MATRICES_ARB */
-       289, /* GL_CURRENT_PALETTE_MATRIX_ARB */
-       786, /* GL_MATRIX_INDEX_ARRAY_ARB */
-       284, /* GL_CURRENT_MATRIX_INDEX_ARB */
-       788, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */
-       790, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */
-       789, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */
-       787, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */
-      1577, /* GL_TEXTURE_DEPTH_SIZE */
-       339, /* GL_DEPTH_TEXTURE_MODE */
-      1543, /* GL_TEXTURE_COMPARE_MODE */
-      1541, /* GL_TEXTURE_COMPARE_FUNC */
-       217, /* GL_COMPARE_R_TO_TEXTURE */
-      1093, /* GL_POINT_SPRITE */
-       266, /* GL_COORD_REPLACE */
-      1097, /* GL_POINT_SPRITE_R_MODE_NV */
-      1214, /* GL_QUERY_COUNTER_BITS */
-       291, /* GL_CURRENT_QUERY */
-      1216, /* GL_QUERY_RESULT */
-      1218, /* GL_QUERY_RESULT_AVAILABLE */
-       873, /* GL_MAX_VERTEX_ATTRIBS */
-      1708, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */
-       337, /* GL_DEPTH_STENCIL_TO_RGBA_NV */
-       336, /* GL_DEPTH_STENCIL_TO_BGRA_NV */
-       859, /* GL_MAX_TEXTURE_COORDS */
-       861, /* GL_MAX_TEXTURE_IMAGE_UNITS */
-      1164, /* GL_PROGRAM_ERROR_STRING_ARB */
-      1166, /* GL_PROGRAM_FORMAT_ASCII_ARB */
-      1165, /* GL_PROGRAM_FORMAT_ARB */
-      1622, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */
-       318, /* GL_DEPTH_BOUNDS_TEST_EXT */
-       317, /* GL_DEPTH_BOUNDS_EXT */
+      1738, /* GL_WEIGHT_SUM_UNITY_ARB */
+      1716, /* GL_VERTEX_BLEND_ARB */
+       302, /* GL_CURRENT_WEIGHT_ARB */
+      1737, /* GL_WEIGHT_ARRAY_TYPE_ARB */
+      1736, /* GL_WEIGHT_ARRAY_STRIDE_ARB */
+      1735, /* GL_WEIGHT_ARRAY_SIZE_ARB */
+      1734, /* GL_WEIGHT_ARRAY_POINTER_ARB */
+      1731, /* GL_WEIGHT_ARRAY_ARB */
+       345, /* GL_DOT3_RGB */
+       346, /* GL_DOT3_RGBA */
+       237, /* GL_COMPRESSED_RGB_FXT1_3DFX */
+       232, /* GL_COMPRESSED_RGBA_FXT1_3DFX */
+       937, /* GL_MULTISAMPLE_3DFX */
+      1309, /* GL_SAMPLE_BUFFERS_3DFX */
+      1300, /* GL_SAMPLES_3DFX */
+       918, /* GL_MODELVIEW2_ARB */
+       921, /* GL_MODELVIEW3_ARB */
+       922, /* GL_MODELVIEW4_ARB */
+       923, /* GL_MODELVIEW5_ARB */
+       924, /* GL_MODELVIEW6_ARB */
+       925, /* GL_MODELVIEW7_ARB */
+       926, /* GL_MODELVIEW8_ARB */
+       927, /* GL_MODELVIEW9_ARB */
+       897, /* GL_MODELVIEW10_ARB */
+       898, /* GL_MODELVIEW11_ARB */
+       899, /* GL_MODELVIEW12_ARB */
+       900, /* GL_MODELVIEW13_ARB */
+       901, /* GL_MODELVIEW14_ARB */
+       902, /* GL_MODELVIEW15_ARB */
+       903, /* GL_MODELVIEW16_ARB */
+       904, /* GL_MODELVIEW17_ARB */
+       905, /* GL_MODELVIEW18_ARB */
+       906, /* GL_MODELVIEW19_ARB */
+       908, /* GL_MODELVIEW20_ARB */
+       909, /* GL_MODELVIEW21_ARB */
+       910, /* GL_MODELVIEW22_ARB */
+       911, /* GL_MODELVIEW23_ARB */
+       912, /* GL_MODELVIEW24_ARB */
+       913, /* GL_MODELVIEW25_ARB */
+       914, /* GL_MODELVIEW26_ARB */
+       915, /* GL_MODELVIEW27_ARB */
+       916, /* GL_MODELVIEW28_ARB */
+       917, /* GL_MODELVIEW29_ARB */
+       919, /* GL_MODELVIEW30_ARB */
+       920, /* GL_MODELVIEW31_ARB */
+       350, /* GL_DOT3_RGB_EXT */
+       348, /* GL_DOT3_RGBA_EXT */
+       891, /* GL_MIRROR_CLAMP_EXT */
+       894, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */
+       932, /* GL_MODULATE_ADD_ATI */
+       933, /* GL_MODULATE_SIGNED_ADD_ATI */
+       934, /* GL_MODULATE_SUBTRACT_ATI */
+      1744, /* GL_YCBCR_MESA */
+      1023, /* GL_PACK_INVERT_MESA */
+       305, /* GL_DEBUG_OBJECT_MESA */
+       306, /* GL_DEBUG_PRINT_MESA */
+       304, /* GL_DEBUG_ASSERT_MESA */
+       106, /* GL_BUFFER_SIZE */
+       108, /* GL_BUFFER_USAGE */
+      1397, /* GL_STENCIL_BACK_FUNC */
+      1395, /* GL_STENCIL_BACK_FAIL */
+      1399, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */
+      1401, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */
+       483, /* GL_FRAGMENT_PROGRAM_ARB */
+      1157, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */
+      1185, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */
+      1184, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */
+      1169, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
+      1175, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
+      1174, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
+       827, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */
+       850, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */
+       849, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */
+       840, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
+       846, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
+       845, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
+       810, /* GL_MAX_DRAW_BUFFERS */
+       354, /* GL_DRAW_BUFFER0 */
+       357, /* GL_DRAW_BUFFER1 */
+       378, /* GL_DRAW_BUFFER2 */
+       381, /* GL_DRAW_BUFFER3 */
+       384, /* GL_DRAW_BUFFER4 */
+       387, /* GL_DRAW_BUFFER5 */
+       390, /* GL_DRAW_BUFFER6 */
+       393, /* GL_DRAW_BUFFER7 */
+       396, /* GL_DRAW_BUFFER8 */
+       399, /* GL_DRAW_BUFFER9 */
+       358, /* GL_DRAW_BUFFER10 */
+       361, /* GL_DRAW_BUFFER11 */
+       364, /* GL_DRAW_BUFFER12 */
+       367, /* GL_DRAW_BUFFER13 */
+       370, /* GL_DRAW_BUFFER14 */
+       373, /* GL_DRAW_BUFFER15 */
+        81, /* GL_BLEND_EQUATION_ALPHA */
+       790, /* GL_MATRIX_PALETTE_ARB */
+       821, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */
+       824, /* GL_MAX_PALETTE_MATRICES_ARB */
+       288, /* GL_CURRENT_PALETTE_MATRIX_ARB */
+       784, /* GL_MATRIX_INDEX_ARRAY_ARB */
+       283, /* GL_CURRENT_MATRIX_INDEX_ARB */
+       786, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */
+       788, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */
+       787, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */
+       785, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */
+      1575, /* GL_TEXTURE_DEPTH_SIZE */
+       338, /* GL_DEPTH_TEXTURE_MODE */
+      1541, /* GL_TEXTURE_COMPARE_MODE */
+      1539, /* GL_TEXTURE_COMPARE_FUNC */
+       216, /* GL_COMPARE_R_TO_TEXTURE */
+      1091, /* GL_POINT_SPRITE */
+       265, /* GL_COORD_REPLACE */
+      1095, /* GL_POINT_SPRITE_R_MODE_NV */
+      1212, /* GL_QUERY_COUNTER_BITS */
+       290, /* GL_CURRENT_QUERY */
+      1214, /* GL_QUERY_RESULT */
+      1216, /* GL_QUERY_RESULT_AVAILABLE */
+       871, /* GL_MAX_VERTEX_ATTRIBS */
+      1706, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */
+       336, /* GL_DEPTH_STENCIL_TO_RGBA_NV */
+       335, /* GL_DEPTH_STENCIL_TO_BGRA_NV */
+       857, /* GL_MAX_TEXTURE_COORDS */
+       859, /* GL_MAX_TEXTURE_IMAGE_UNITS */
+      1162, /* GL_PROGRAM_ERROR_STRING_ARB */
+      1164, /* GL_PROGRAM_FORMAT_ASCII_ARB */
+      1163, /* GL_PROGRAM_FORMAT_ARB */
+      1620, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */
+       317, /* GL_DEPTH_BOUNDS_TEST_EXT */
+       316, /* GL_DEPTH_BOUNDS_EXT */
         52, /* GL_ARRAY_BUFFER */
-       420, /* GL_ELEMENT_ARRAY_BUFFER */
-        54, /* GL_ARRAY_BUFFER_BINDING */
-       422, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */
-      1682, /* GL_VERTEX_ARRAY_BUFFER_BINDING */
-       960, /* GL_NORMAL_ARRAY_BUFFER_BINDING */
-       140, /* GL_COLOR_ARRAY_BUFFER_BINDING */
-       579, /* GL_INDEX_ARRAY_BUFFER_BINDING */
-      1556, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */
-       416, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */
-      1323, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */
-       463, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */
-      1734, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */
-      1704, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */
-      1167, /* GL_PROGRAM_INSTRUCTIONS_ARB */
-       835, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */
-      1173, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
-       844, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
-      1185, /* GL_PROGRAM_TEMPORARIES_ARB */
-       850, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */
-      1175, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */
-       846, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */
-      1179, /* GL_PROGRAM_PARAMETERS_ARB */
-       849, /* GL_MAX_PROGRAM_PARAMETERS_ARB */
-      1174, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */
-       845, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */
-      1160, /* GL_PROGRAM_ATTRIBS_ARB */
-       830, /* GL_MAX_PROGRAM_ATTRIBS_ARB */
-      1172, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */
-       843, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */
-      1158, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */
-       828, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */
-      1170, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
-       841, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
-       836, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */
-       832, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */
-      1188, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */
-      1633, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */
-      1226, /* GL_READ_ONLY */
-      1742, /* GL_WRITE_ONLY */
-      1228, /* GL_READ_WRITE */
-       101, /* GL_BUFFER_ACCESS */
-       103, /* GL_BUFFER_MAPPED */
-       105, /* GL_BUFFER_MAP_POINTER */
-      1627, /* GL_TIME_ELAPSED_EXT */
-       746, /* GL_MATRIX0_ARB */
-       758, /* GL_MATRIX1_ARB */
-       770, /* GL_MATRIX2_ARB */
-       774, /* GL_MATRIX3_ARB */
-       776, /* GL_MATRIX4_ARB */
-       778, /* GL_MATRIX5_ARB */
-       780, /* GL_MATRIX6_ARB */
-       782, /* GL_MATRIX7_ARB */
-       784, /* GL_MATRIX8_ARB */
-       785, /* GL_MATRIX9_ARB */
-       748, /* GL_MATRIX10_ARB */
-       749, /* GL_MATRIX11_ARB */
-       750, /* GL_MATRIX12_ARB */
-       751, /* GL_MATRIX13_ARB */
-       752, /* GL_MATRIX14_ARB */
-       753, /* GL_MATRIX15_ARB */
-       754, /* GL_MATRIX16_ARB */
-       755, /* GL_MATRIX17_ARB */
-       756, /* GL_MATRIX18_ARB */
-       757, /* GL_MATRIX19_ARB */
-       760, /* GL_MATRIX20_ARB */
-       761, /* GL_MATRIX21_ARB */
-       762, /* GL_MATRIX22_ARB */
-       763, /* GL_MATRIX23_ARB */
-       764, /* GL_MATRIX24_ARB */
-       765, /* GL_MATRIX25_ARB */
-       766, /* GL_MATRIX26_ARB */
-       767, /* GL_MATRIX27_ARB */
-       768, /* GL_MATRIX28_ARB */
-       769, /* GL_MATRIX29_ARB */
-       772, /* GL_MATRIX30_ARB */
-       773, /* GL_MATRIX31_ARB */
-      1429, /* GL_STREAM_DRAW */
-      1431, /* GL_STREAM_READ */
-      1427, /* GL_STREAM_COPY */
-      1391, /* GL_STATIC_DRAW */
-      1393, /* GL_STATIC_READ */
-      1389, /* GL_STATIC_COPY */
-       410, /* GL_DYNAMIC_DRAW */
-       412, /* GL_DYNAMIC_READ */
-       408, /* GL_DYNAMIC_COPY */
-       535, /* GL_GL_PIXEL_PACK_BUFFER */
-       537, /* GL_GL_PIXEL_UNPACK_BUFFER */
-       536, /* GL_GL_PIXEL_PACK_BUFFER_BINDING */
-       538, /* GL_GL_PIXEL_UNPACK_BUFFER_BINDING */
-       833, /* GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */
-       831, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */
-       834, /* GL_MAX_PROGRAM_IF_DEPTH_NV */
-       838, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */
-       837, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */
-       795, /* GL_MAX_ARRAY_TEXTURE_LAYERS_EXT */
-      1423, /* GL_STENCIL_TEST_TWO_SIDE_EXT */
+       419, /* GL_ELEMENT_ARRAY_BUFFER */
+        53, /* GL_ARRAY_BUFFER_BINDING */
+       420, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */
+      1680, /* GL_VERTEX_ARRAY_BUFFER_BINDING */
+       958, /* GL_NORMAL_ARRAY_BUFFER_BINDING */
+       139, /* GL_COLOR_ARRAY_BUFFER_BINDING */
+       577, /* GL_INDEX_ARRAY_BUFFER_BINDING */
+      1554, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */
+       415, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */
+      1321, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */
+       461, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */
+      1732, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */
+      1702, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */
+      1165, /* GL_PROGRAM_INSTRUCTIONS_ARB */
+       833, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */
+      1171, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
+       842, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
+      1183, /* GL_PROGRAM_TEMPORARIES_ARB */
+       848, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */
+      1173, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */
+       844, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */
+      1177, /* GL_PROGRAM_PARAMETERS_ARB */
+       847, /* GL_MAX_PROGRAM_PARAMETERS_ARB */
+      1172, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */
+       843, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */
+      1158, /* GL_PROGRAM_ATTRIBS_ARB */
+       828, /* GL_MAX_PROGRAM_ATTRIBS_ARB */
+      1170, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */
+       841, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */
+      1156, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */
+       826, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */
+      1168, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
+       839, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
+       834, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */
+       830, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */
+      1186, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */
+      1631, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */
+      1224, /* GL_READ_ONLY */
+      1740, /* GL_WRITE_ONLY */
+      1226, /* GL_READ_WRITE */
+       100, /* GL_BUFFER_ACCESS */
+       102, /* GL_BUFFER_MAPPED */
+       104, /* GL_BUFFER_MAP_POINTER */
+      1625, /* GL_TIME_ELAPSED_EXT */
+       744, /* GL_MATRIX0_ARB */
+       756, /* GL_MATRIX1_ARB */
+       768, /* GL_MATRIX2_ARB */
+       772, /* GL_MATRIX3_ARB */
+       774, /* GL_MATRIX4_ARB */
+       776, /* GL_MATRIX5_ARB */
+       778, /* GL_MATRIX6_ARB */
+       780, /* GL_MATRIX7_ARB */
+       782, /* GL_MATRIX8_ARB */
+       783, /* GL_MATRIX9_ARB */
+       746, /* GL_MATRIX10_ARB */
+       747, /* GL_MATRIX11_ARB */
+       748, /* GL_MATRIX12_ARB */
+       749, /* GL_MATRIX13_ARB */
+       750, /* GL_MATRIX14_ARB */
+       751, /* GL_MATRIX15_ARB */
+       752, /* GL_MATRIX16_ARB */
+       753, /* GL_MATRIX17_ARB */
+       754, /* GL_MATRIX18_ARB */
+       755, /* GL_MATRIX19_ARB */
+       758, /* GL_MATRIX20_ARB */
+       759, /* GL_MATRIX21_ARB */
+       760, /* GL_MATRIX22_ARB */
+       761, /* GL_MATRIX23_ARB */
+       762, /* GL_MATRIX24_ARB */
+       763, /* GL_MATRIX25_ARB */
+       764, /* GL_MATRIX26_ARB */
+       765, /* GL_MATRIX27_ARB */
+       766, /* GL_MATRIX28_ARB */
+       767, /* GL_MATRIX29_ARB */
+       770, /* GL_MATRIX30_ARB */
+       771, /* GL_MATRIX31_ARB */
+      1427, /* GL_STREAM_DRAW */
+      1429, /* GL_STREAM_READ */
+      1425, /* GL_STREAM_COPY */
+      1389, /* GL_STATIC_DRAW */
+      1391, /* GL_STATIC_READ */
+      1387, /* GL_STATIC_COPY */
+       409, /* GL_DYNAMIC_DRAW */
+       411, /* GL_DYNAMIC_READ */
+       407, /* GL_DYNAMIC_COPY */
+       533, /* GL_GL_PIXEL_PACK_BUFFER */
+       535, /* GL_GL_PIXEL_UNPACK_BUFFER */
+       534, /* GL_GL_PIXEL_PACK_BUFFER_BINDING */
+       536, /* GL_GL_PIXEL_UNPACK_BUFFER_BINDING */
+       831, /* GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */
+       829, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */
+       832, /* GL_MAX_PROGRAM_IF_DEPTH_NV */
+       836, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */
+       835, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */
+       793, /* GL_MAX_ARRAY_TEXTURE_LAYERS_EXT */
+      1421, /* GL_STENCIL_TEST_TWO_SIDE_EXT */
         17, /* GL_ACTIVE_STENCIL_FACE_EXT */
-       894, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */
-      1304, /* GL_SAMPLES_PASSED */
-       486, /* GL_FRAGMENT_SHADER */
-      1728, /* GL_VERTEX_SHADER */
-      1178, /* GL_PROGRAM_OBJECT_ARB */
-      1336, /* GL_SHADER_OBJECT_ARB */
-       819, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */
-       877, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */
-       871, /* GL_MAX_VARYING_FLOATS */
-       875, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */
-       804, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */
-       985, /* GL_OBJECT_TYPE_ARB */
-      1338, /* GL_SHADER_TYPE */
-       451, /* GL_FLOAT_VEC2 */
-       453, /* GL_FLOAT_VEC3 */
-       455, /* GL_FLOAT_VEC4 */
-       606, /* GL_INT_VEC2 */
-       608, /* GL_INT_VEC3 */
-       610, /* GL_INT_VEC4 */
-        93, /* GL_BOOL */
-        95, /* GL_BOOL_VEC2 */
-        97, /* GL_BOOL_VEC3 */
-        99, /* GL_BOOL_VEC4 */
-       445, /* GL_FLOAT_MAT2 */
-       447, /* GL_FLOAT_MAT3 */
-       449, /* GL_FLOAT_MAT4 */
-      1295, /* GL_SAMPLER_1D */
-      1297, /* GL_SAMPLER_2D */
-      1299, /* GL_SAMPLER_3D */
-      1300, /* GL_SAMPLER_CUBE */
-      1296, /* GL_SAMPLER_1D_SHADOW */
-      1298, /* GL_SAMPLER_2D_SHADOW */
-       529, /* GL_GL_FLOAT_MAT2x3 */
-       530, /* GL_GL_FLOAT_MAT2x4 */
-       531, /* GL_GL_FLOAT_MAT3x2 */
-       532, /* GL_GL_FLOAT_MAT3x4 */
-       533, /* GL_GL_FLOAT_MAT4x2 */
-       534, /* GL_GL_FLOAT_MAT4x3 */
-       312, /* GL_DELETE_STATUS */
-       221, /* GL_COMPILE_STATUS */
-       659, /* GL_LINK_STATUS */
-      1677, /* GL_VALIDATE_STATUS */
-       591, /* GL_INFO_LOG_LENGTH */
-        56, /* GL_ATTACHED_SHADERS */
+       892, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */
+      1302, /* GL_SAMPLES_PASSED */
+       484, /* GL_FRAGMENT_SHADER */
+      1726, /* GL_VERTEX_SHADER */
+      1176, /* GL_PROGRAM_OBJECT_ARB */
+      1334, /* GL_SHADER_OBJECT_ARB */
+       817, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */
+       875, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */
+       869, /* GL_MAX_VARYING_FLOATS */
+       873, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */
+       802, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */
+       983, /* GL_OBJECT_TYPE_ARB */
+      1336, /* GL_SHADER_TYPE */
+       449, /* GL_FLOAT_VEC2 */
+       451, /* GL_FLOAT_VEC3 */
+       453, /* GL_FLOAT_VEC4 */
+       604, /* GL_INT_VEC2 */
+       606, /* GL_INT_VEC3 */
+       608, /* GL_INT_VEC4 */
+        92, /* GL_BOOL */
+        94, /* GL_BOOL_VEC2 */
+        96, /* GL_BOOL_VEC3 */
+        98, /* GL_BOOL_VEC4 */
+       443, /* GL_FLOAT_MAT2 */
+       445, /* GL_FLOAT_MAT3 */
+       447, /* GL_FLOAT_MAT4 */
+      1293, /* GL_SAMPLER_1D */
+      1295, /* GL_SAMPLER_2D */
+      1297, /* GL_SAMPLER_3D */
+      1298, /* GL_SAMPLER_CUBE */
+      1294, /* GL_SAMPLER_1D_SHADOW */
+      1296, /* GL_SAMPLER_2D_SHADOW */
+       527, /* GL_GL_FLOAT_MAT2x3 */
+       528, /* GL_GL_FLOAT_MAT2x4 */
+       529, /* GL_GL_FLOAT_MAT3x2 */
+       530, /* GL_GL_FLOAT_MAT3x4 */
+       531, /* GL_GL_FLOAT_MAT4x2 */
+       532, /* GL_GL_FLOAT_MAT4x3 */
+       311, /* GL_DELETE_STATUS */
+       220, /* GL_COMPILE_STATUS */
+       657, /* GL_LINK_STATUS */
+      1675, /* GL_VALIDATE_STATUS */
+       589, /* GL_INFO_LOG_LENGTH */
+        55, /* GL_ATTACHED_SHADERS */
         20, /* GL_ACTIVE_UNIFORMS */
         21, /* GL_ACTIVE_UNIFORM_MAX_LENGTH */
-      1337, /* GL_SHADER_SOURCE_LENGTH */
+      1335, /* GL_SHADER_SOURCE_LENGTH */
         15, /* GL_ACTIVE_ATTRIBUTES */
         16, /* GL_ACTIVE_ATTRIBUTE_MAX_LENGTH */
-       488, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT */
-      1340, /* GL_SHADING_LANGUAGE_VERSION */
-       290, /* GL_CURRENT_PROGRAM */
-      1034, /* GL_PALETTE4_RGB8_OES */
-      1036, /* GL_PALETTE4_RGBA8_OES */
-      1032, /* GL_PALETTE4_R5_G6_B5_OES */
-      1035, /* GL_PALETTE4_RGBA4_OES */
-      1033, /* GL_PALETTE4_RGB5_A1_OES */
-      1039, /* GL_PALETTE8_RGB8_OES */
-      1041, /* GL_PALETTE8_RGBA8_OES */
-      1037, /* GL_PALETTE8_R5_G6_B5_OES */
-      1040, /* GL_PALETTE8_RGBA4_OES */
-      1038, /* GL_PALETTE8_RGB5_A1_OES */
-       574, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */
-       573, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */
-      1511, /* GL_TEXTURE_1D_ARRAY_EXT */
-      1198, /* GL_PROXY_TEXTURE_1D_ARRAY_EXT */
-      1513, /* GL_TEXTURE_2D_ARRAY_EXT */
-      1201, /* GL_PROXY_TEXTURE_2D_ARRAY_EXT */
-      1519, /* GL_TEXTURE_BINDING_1D_ARRAY_EXT */
-      1521, /* GL_TEXTURE_BINDING_2D_ARRAY_EXT */
-       543, /* GL_GL_SRGB */
-       544, /* GL_GL_SRGB8 */
-       546, /* GL_GL_SRGB_ALPHA */
-       545, /* GL_GL_SRGB8_ALPHA8 */
-       542, /* GL_GL_SLUMINANCE_ALPHA */
-       541, /* GL_GL_SLUMINANCE8_ALPHA8 */
-       539, /* GL_GL_SLUMINANCE */
-       540, /* GL_GL_SLUMINANCE8 */
-       526, /* GL_GL_COMPRESSED_SRGB */
-       527, /* GL_GL_COMPRESSED_SRGB_ALPHA */
-       524, /* GL_GL_COMPRESSED_SLUMINANCE */
-       525, /* GL_GL_COMPRESSED_SLUMINANCE_ALPHA */
-      1095, /* GL_POINT_SPRITE_COORD_ORIGIN */
-       667, /* GL_LOWER_LEFT */
-      1674, /* GL_UPPER_LEFT */
-      1405, /* GL_STENCIL_BACK_REF */
-      1406, /* GL_STENCIL_BACK_VALUE_MASK */
-      1407, /* GL_STENCIL_BACK_WRITEMASK */
-       403, /* GL_DRAW_FRAMEBUFFER_BINDING_EXT */
-      1240, /* GL_RENDERBUFFER_BINDING_EXT */
-      1225, /* GL_READ_FRAMEBUFFER_EXT */
-       404, /* GL_DRAW_FRAMEBUFFER_EXT */
-      1224, /* GL_READ_FRAMEBUFFER_BINDING_EXT */
-       490, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT */
-       489, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT */
-       494, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT */
-       492, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT */
-       491, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT */
-       496, /* GL_FRAMEBUFFER_COMPLETE_EXT */
-       498, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT */
-       503, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT */
-       501, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */
-       499, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */
-       502, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */
-       500, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT */
-       504, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT */
-       506, /* GL_FRAMEBUFFER_UNSUPPORTED_EXT */
-       505, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */
-       801, /* GL_MAX_COLOR_ATTACHMENTS_EXT */
-       146, /* GL_COLOR_ATTACHMENT0_EXT */
-       153, /* GL_COLOR_ATTACHMENT1_EXT */
-       154, /* GL_COLOR_ATTACHMENT2_EXT */
-       155, /* GL_COLOR_ATTACHMENT3_EXT */
-       156, /* GL_COLOR_ATTACHMENT4_EXT */
-       157, /* GL_COLOR_ATTACHMENT5_EXT */
-       158, /* GL_COLOR_ATTACHMENT6_EXT */
-       159, /* GL_COLOR_ATTACHMENT7_EXT */
-       160, /* GL_COLOR_ATTACHMENT8_EXT */
-       161, /* GL_COLOR_ATTACHMENT9_EXT */
-       147, /* GL_COLOR_ATTACHMENT10_EXT */
-       148, /* GL_COLOR_ATTACHMENT11_EXT */
-       149, /* GL_COLOR_ATTACHMENT12_EXT */
-       150, /* GL_COLOR_ATTACHMENT13_EXT */
-       151, /* GL_COLOR_ATTACHMENT14_EXT */
-       152, /* GL_COLOR_ATTACHMENT15_EXT */
-       314, /* GL_DEPTH_ATTACHMENT_EXT */
-      1396, /* GL_STENCIL_ATTACHMENT_EXT */
-       497, /* GL_FRAMEBUFFER_EXT */
-      1241, /* GL_RENDERBUFFER_EXT */
-      1244, /* GL_RENDERBUFFER_WIDTH_EXT */
-      1242, /* GL_RENDERBUFFER_HEIGHT_EXT */
-      1243, /* GL_RENDERBUFFER_INTERNAL_FORMAT_EXT */
-      1418, /* GL_STENCIL_INDEX_EXT */
-      1415, /* GL_STENCIL_INDEX1_EXT */
-      1416, /* GL_STENCIL_INDEX4_EXT */
-      1417, /* GL_STENCIL_INDEX8_EXT */
-      1414, /* GL_STENCIL_INDEX16_EXT */
-       428, /* GL_EVAL_BIT */
-      1222, /* GL_RASTER_POSITION_UNCLIPPED_IBM */
-       661, /* GL_LIST_BIT */
-      1527, /* GL_TEXTURE_BIT */
-      1319, /* GL_SCISSOR_BIT */
+       486, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT */
+      1338, /* GL_SHADING_LANGUAGE_VERSION */
+       289, /* GL_CURRENT_PROGRAM */
+      1032, /* GL_PALETTE4_RGB8_OES */
+      1034, /* GL_PALETTE4_RGBA8_OES */
+      1030, /* GL_PALETTE4_R5_G6_B5_OES */
+      1033, /* GL_PALETTE4_RGBA4_OES */
+      1031, /* GL_PALETTE4_RGB5_A1_OES */
+      1037, /* GL_PALETTE8_RGB8_OES */
+      1039, /* GL_PALETTE8_RGBA8_OES */
+      1035, /* GL_PALETTE8_R5_G6_B5_OES */
+      1038, /* GL_PALETTE8_RGBA4_OES */
+      1036, /* GL_PALETTE8_RGB5_A1_OES */
+       572, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */
+       571, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */
+      1509, /* GL_TEXTURE_1D_ARRAY_EXT */
+      1196, /* GL_PROXY_TEXTURE_1D_ARRAY_EXT */
+      1511, /* GL_TEXTURE_2D_ARRAY_EXT */
+      1199, /* GL_PROXY_TEXTURE_2D_ARRAY_EXT */
+      1517, /* GL_TEXTURE_BINDING_1D_ARRAY_EXT */
+      1519, /* GL_TEXTURE_BINDING_2D_ARRAY_EXT */
+       541, /* GL_GL_SRGB */
+       542, /* GL_GL_SRGB8 */
+       544, /* GL_GL_SRGB_ALPHA */
+       543, /* GL_GL_SRGB8_ALPHA8 */
+       540, /* GL_GL_SLUMINANCE_ALPHA */
+       539, /* GL_GL_SLUMINANCE8_ALPHA8 */
+       537, /* GL_GL_SLUMINANCE */
+       538, /* GL_GL_SLUMINANCE8 */
+       524, /* GL_GL_COMPRESSED_SRGB */
+       525, /* GL_GL_COMPRESSED_SRGB_ALPHA */
+       522, /* GL_GL_COMPRESSED_SLUMINANCE */
+       523, /* GL_GL_COMPRESSED_SLUMINANCE_ALPHA */
+      1093, /* GL_POINT_SPRITE_COORD_ORIGIN */
+       665, /* GL_LOWER_LEFT */
+      1672, /* GL_UPPER_LEFT */
+      1403, /* GL_STENCIL_BACK_REF */
+      1404, /* GL_STENCIL_BACK_VALUE_MASK */
+      1405, /* GL_STENCIL_BACK_WRITEMASK */
+       402, /* GL_DRAW_FRAMEBUFFER_BINDING_EXT */
+      1238, /* GL_RENDERBUFFER_BINDING_EXT */
+      1223, /* GL_READ_FRAMEBUFFER_EXT */
+       403, /* GL_DRAW_FRAMEBUFFER_EXT */
+      1222, /* GL_READ_FRAMEBUFFER_BINDING_EXT */
+       488, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT */
+       487, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT */
+       492, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT */
+       490, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT */
+       489, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT */
+       494, /* GL_FRAMEBUFFER_COMPLETE_EXT */
+       496, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT */
+       501, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT */
+       499, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */
+       497, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */
+       500, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */
+       498, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT */
+       502, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT */
+       504, /* GL_FRAMEBUFFER_UNSUPPORTED_EXT */
+       503, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */
+       799, /* GL_MAX_COLOR_ATTACHMENTS_EXT */
+       145, /* GL_COLOR_ATTACHMENT0_EXT */
+       152, /* GL_COLOR_ATTACHMENT1_EXT */
+       153, /* GL_COLOR_ATTACHMENT2_EXT */
+       154, /* GL_COLOR_ATTACHMENT3_EXT */
+       155, /* GL_COLOR_ATTACHMENT4_EXT */
+       156, /* GL_COLOR_ATTACHMENT5_EXT */
+       157, /* GL_COLOR_ATTACHMENT6_EXT */
+       158, /* GL_COLOR_ATTACHMENT7_EXT */
+       159, /* GL_COLOR_ATTACHMENT8_EXT */
+       160, /* GL_COLOR_ATTACHMENT9_EXT */
+       146, /* GL_COLOR_ATTACHMENT10_EXT */
+       147, /* GL_COLOR_ATTACHMENT11_EXT */
+       148, /* GL_COLOR_ATTACHMENT12_EXT */
+       149, /* GL_COLOR_ATTACHMENT13_EXT */
+       150, /* GL_COLOR_ATTACHMENT14_EXT */
+       151, /* GL_COLOR_ATTACHMENT15_EXT */
+       313, /* GL_DEPTH_ATTACHMENT_EXT */
+      1394, /* GL_STENCIL_ATTACHMENT_EXT */
+       495, /* GL_FRAMEBUFFER_EXT */
+      1239, /* GL_RENDERBUFFER_EXT */
+      1242, /* GL_RENDERBUFFER_WIDTH_EXT */
+      1240, /* GL_RENDERBUFFER_HEIGHT_EXT */
+      1241, /* GL_RENDERBUFFER_INTERNAL_FORMAT_EXT */
+      1416, /* GL_STENCIL_INDEX_EXT */
+      1413, /* GL_STENCIL_INDEX1_EXT */
+      1414, /* GL_STENCIL_INDEX4_EXT */
+      1415, /* GL_STENCIL_INDEX8_EXT */
+      1412, /* GL_STENCIL_INDEX16_EXT */
+       426, /* GL_EVAL_BIT */
+      1220, /* GL_RASTER_POSITION_UNCLIPPED_IBM */
+       659, /* GL_LIST_BIT */
+      1525, /* GL_TEXTURE_BIT */
+      1317, /* GL_SCISSOR_BIT */
         29, /* GL_ALL_ATTRIB_BITS */
-       941, /* GL_MULTISAMPLE_BIT */
+       939, /* GL_MULTISAMPLE_BIT */
         30, /* GL_ALL_CLIENT_ATTRIB_BITS */
 };
 
index 0fe85af93e0c98addd7302d7144aac3dee74ccaf..f95c31862a5e2510659098f67e3b083409af08d8 100644 (file)
@@ -65,9 +65,17 @@ static struct mem_block *exec_heap = NULL;
 static unsigned char *exec_mem = NULL;
 
 
-static void
+static int
 init_heap(void)
 {
+#ifdef MESA_SELINUX
+   if (is_selinux_enabled()) {
+      if (!security_get_boolean_active("allow_execmem") ||
+         !security_get_boolean_pending("allow_execmem"))
+         return 0;
+   }
+#endif
+
    if (!exec_heap)
       exec_heap = mmInit( 0, EXEC_HEAP_SIZE );
    
@@ -75,6 +83,8 @@ init_heap(void)
       exec_mem = (unsigned char *) mmap(0, EXEC_HEAP_SIZE, 
                                        PROT_EXEC | PROT_READ | PROT_WRITE, 
                                        MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+
+   return (exec_mem != NULL);
 }
 
 
@@ -86,7 +96,8 @@ _mesa_exec_malloc(GLuint size)
 
    _glthread_LOCK_MUTEX(exec_mutex);
 
-   init_heap();
+   if (!init_heap())
+      goto bail;
 
    if (exec_heap) {
       size = (size + 31) & ~31;
@@ -97,7 +108,8 @@ _mesa_exec_malloc(GLuint size)
       addr = exec_mem + block->ofs;
    else 
       _mesa_printf("_mesa_exec_malloc failed\n");
-   
+
+bail:
    _glthread_UNLOCK_MUTEX(exec_mutex);
    
    return addr;
index e5279e7f3ebafb58e3b57c8ef111216e11807829..8dfbfeb62e43b06a21a228af0d7bcc08a0d0b712 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.1
+ * Version:  7.1
  *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -204,7 +204,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx)
    ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
 #endif
 #if FEATURE_ARB_shading_language_120
-   ctx->Extensions.ARB_shading_language_120 = GL_TRUE;
+   ctx->Extensions.ARB_shading_language_120 = GL_FALSE; /* not quite done */
 #endif
    ctx->Extensions.ARB_shadow = GL_TRUE;
    ctx->Extensions.ARB_texture_border_clamp = GL_TRUE;
@@ -309,6 +309,7 @@ _mesa_enable_imaging_extensions(GLcontext *ctx)
 {
    ctx->Extensions.ARB_imaging = GL_TRUE;
    ctx->Extensions.EXT_blend_color = 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;
@@ -353,7 +354,6 @@ _mesa_enable_1_4_extensions(GLcontext *ctx)
    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;
@@ -419,7 +419,7 @@ _mesa_enable_2_1_extensions(GLcontext *ctx)
    ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
 #endif
 #ifdef FEATURE_ARB_shading_language_120
-   ctx->Extensions.ARB_shading_language_120 = GL_TRUE;
+   ctx->Extensions.ARB_shading_language_120 = GL_FALSE; /* not quite done */
 #endif
 }
 
index b5605a199c584e42a8f01aa75b01e9c6b449895e..dd06327972bb57ea15ede9a8f9861eadd8618751 100644 (file)
@@ -983,9 +983,11 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
    }
 
    FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+
    if (ctx->Driver.Flush) {  
       ctx->Driver.Flush(ctx);
    }
+
    if (framebuffer) {
       /* Binding a user-created framebuffer object */
       newFb = _mesa_lookup_framebuffer(ctx, framebuffer);
@@ -1019,32 +1021,18 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
     * XXX check if re-binding same buffer and skip some of this code.
     */
 
-   /* for window-framebuffers, re-initialize the fbo values, as they
-      could be wrong (makecurrent with a new drawable while still a fbo
-      was bound will lead to default init fbo values).
-      note that therefore the context ReadBuffer/DrawBuffer values are not
-      valid while fbo's are bound!!! */
    if (bindReadBuf) {
       _mesa_reference_framebuffer(&ctx->ReadBuffer, newFbread);
-      if (!newFbread->Name) {
-         _mesa_readbuffer_update_fields(ctx, ctx->Pixel.ReadBuffer);
-      }
    }
 
    if (bindDrawBuf) {
       /* check if old FB had any texture attachments */
       check_end_texture_render(ctx, ctx->DrawBuffer);
+
       /* check if time to delete this framebuffer */
       _mesa_reference_framebuffer(&ctx->DrawBuffer, newFb);
-      if (!newFb->Name) {
-         GLuint i;
-         GLenum buffers[MAX_DRAW_BUFFERS];
-         for(i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
-            buffers[i] = ctx->Color.DrawBuffer[i];
-         }
-         _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers, buffers, NULL);
-      }
-      else {
+
+      if (newFb->Name != 0) {
          /* check if newly bound framebuffer has any texture attachments */
          check_begin_texture_render(ctx, newFb);
       }
index 494743f1349f751abd2f7e135c694f4eb9deadde..af78363ad3a028ec06d37114cedf2d15bf40ecb4 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "glheader.h"
 #include "imports.h"
+#include "buffers.h"
 #include "context.h"
 #include "depthstencil.h"
 #include "mtypes.h"
@@ -108,8 +109,9 @@ _mesa_new_framebuffer(GLcontext *ctx, GLuint name)
    if (fb) {
       fb->Name = name;
       fb->RefCount = 1;
+      fb->_NumColorDrawBuffers = 1;
       fb->ColorDrawBuffer[0] = GL_COLOR_ATTACHMENT0_EXT;
-      fb->_ColorDrawBufferMask[0] = BUFFER_BIT_COLOR0;
+      fb->_ColorDrawBufferIndexes[0] = BUFFER_COLOR0;
       fb->ColorReadBuffer = GL_COLOR_ATTACHMENT0_EXT;
       fb->_ColorReadBufferIndex = BUFFER_COLOR0;
       fb->Delete = _mesa_destroy_framebuffer;
@@ -138,16 +140,18 @@ _mesa_initialize_framebuffer(struct gl_framebuffer *fb, const GLvisual *visual)
    /* save the visual */
    fb->Visual = *visual;
 
-   /* Init glRead/DrawBuffer state */
+   /* Init read/draw renderbuffer state */
    if (visual->doubleBufferMode) {
+      fb->_NumColorDrawBuffers = 1;
       fb->ColorDrawBuffer[0] = GL_BACK;
-      fb->_ColorDrawBufferMask[0] = BUFFER_BIT_BACK_LEFT;
+      fb->_ColorDrawBufferIndexes[0] = BUFFER_BACK_LEFT;
       fb->ColorReadBuffer = GL_BACK;
       fb->_ColorReadBufferIndex = BUFFER_BACK_LEFT;
    }
    else {
+      fb->_NumColorDrawBuffers = 1;
       fb->ColorDrawBuffer[0] = GL_FRONT;
-      fb->_ColorDrawBufferMask[0] = BUFFER_BIT_FRONT_LEFT;
+      fb->_ColorDrawBufferIndexes[0] = BUFFER_FRONT_LEFT;
       fb->ColorReadBuffer = GL_FRONT;
       fb->_ColorReadBufferIndex = BUFFER_FRONT_LEFT;
    }
@@ -660,8 +664,53 @@ _mesa_update_stencil_buffer(GLcontext *ctx,
 }
 
 
+/*
+ * Example DrawBuffers scenarios:
+ *
+ * 1. glDrawBuffer(GL_FRONT_AND_BACK), fixed-func or shader writes to
+ * "gl_FragColor" or program writes to the "result.color" register:
+ *
+ *   fragment color output   renderbuffer
+ *   ---------------------   ---------------
+ *   color[0]                Front, Back
+ *
+ *
+ * 2. glDrawBuffers(3, [GL_FRONT, GL_AUX0, GL_AUX1]), shader writes to
+ * gl_FragData[i] or program writes to result.color[i] registers:
+ *
+ *   fragment color output   renderbuffer
+ *   ---------------------   ---------------
+ *   color[0]                Front
+ *   color[1]                Aux0
+ *   color[3]                Aux1
+ *
+ *
+ * 3. glDrawBuffers(3, [GL_FRONT, GL_AUX0, GL_AUX1]) and shader writes to
+ * gl_FragColor, or fixed function:
+ *
+ *   fragment color output   renderbuffer
+ *   ---------------------   ---------------
+ *   color[0]                Front, Aux0, Aux1
+ *
+ *
+ * In either case, the list of renderbuffers is stored in the
+ * framebuffer->_ColorDrawBuffers[] array and
+ * framebuffer->_NumColorDrawBuffers indicates the number of buffers.
+ * The renderer (like swrast) has to look at the current fragment shader
+ * to see if it writes to gl_FragColor vs. gl_FragData[i] to determine
+ * how to map color outputs to renderbuffers.
+ *
+ * Note that these two calls are equivalent (for fixed function fragment
+ * shading anyway):
+ *   a)  glDrawBuffer(GL_FRONT_AND_BACK);  (assuming non-stereo framebuffer)
+ *   b)  glDrawBuffers(2, [GL_FRONT_LEFT, GL_BACK_LEFT]);
+ */
+
+
+
+
 /**
- * Update the list of color drawing renderbuffer pointers.
+ * Update the (derived) list of color drawing renderbuffer pointers.
  * Later, when we're rendering we'll loop from 0 to _NumColorDrawBuffers
  * writing colors.
  */
@@ -670,42 +719,23 @@ update_color_draw_buffers(GLcontext *ctx, struct gl_framebuffer *fb)
 {
    GLuint output;
 
-   /*
-    * Fragment programs can write to multiple colorbuffers with
-    * the GL_ARB_draw_buffers extension.
-    */
-   for (output = 0; output < ctx->Const.MaxDrawBuffers; output++) {
-      GLbitfield bufferMask = fb->_ColorDrawBufferMask[output];
-      GLuint count = 0;
-      GLuint i;
-      if (!fb->DeletePending) {
-         /* We need the inner loop here because glDrawBuffer(GL_FRONT_AND_BACK)
-          * can specify writing to two or four color buffers (for example).
-          */
-         for (i = 0; bufferMask && i < BUFFER_COUNT; i++) {
-            const GLuint bufferBit = 1 << i;
-            if (bufferBit & bufferMask) {
-               struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer;
-               if (rb && rb->Width > 0 && rb->Height > 0) {
-                  fb->_ColorDrawBuffers[output][count] = rb;
-                  count++;
-               }
-               else {
-                  /*
-                  _mesa_warning(ctx, "DrawBuffer names a missing buffer!\n");
-                  */
-               }
-               bufferMask &= ~bufferBit;
-            }
-         }
+   /* set 0th buffer to NULL now in case _NumColorDrawBuffers is zero */
+   fb->_ColorDrawBuffers[0] = NULL;
+
+   for (output = 0; output < fb->_NumColorDrawBuffers; output++) {
+      GLint buf = fb->_ColorDrawBufferIndexes[output];
+      if (buf >= 0) {
+         fb->_ColorDrawBuffers[output] = fb->Attachment[buf].Renderbuffer;
+      }
+      else {
+         fb->_ColorDrawBuffers[output] = NULL;
       }
-      fb->_NumColorDrawBuffers[output] = count;
    }
 }
 
 
 /**
- * Update the color read renderbuffer pointer.
+ * Update the (derived) color read renderbuffer pointer.
  * Unlike the DrawBuffer, we can only read from one (or zero) color buffers.
  */
 static void
@@ -727,19 +757,51 @@ update_color_read_buffer(GLcontext *ctx, struct gl_framebuffer *fb)
 }
 
 
+/**
+ * Update a gl_framebuffer's derived state.
+ *
+ * Specifically, update these framebuffer fields:
+ *    _ColorDrawBuffers
+ *    _NumColorDrawBuffers
+ *    _ColorReadBuffer
+ *    _DepthBuffer
+ *    _StencilBuffer
+ *
+ * If the framebuffer is user-created, make sure it's complete.
+ *
+ * The following functions (at least) can effect framebuffer state:
+ * glReadBuffer, glDrawBuffer, glDrawBuffersARB, glFramebufferRenderbufferEXT,
+ * glRenderbufferStorageEXT.
+ */
 static void
 update_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
 {
-   /* Completeness only matters for user-created framebuffers */
-   if (fb->Name != 0) {
-      /* XXX: EXT_framebuffer_blit:
-         framebuffer must still be complete wrt read/draw? */
+   if (fb->Name == 0) {
+      /* This is a window-system framebuffer */
+      /* Need to update the FB's GL_DRAW_BUFFER state to match the
+       * context state (GL_READ_BUFFER too).
+       */
+      if (fb->ColorDrawBuffer[0] != ctx->Color.DrawBuffer[0]) {
+         _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers,
+                           ctx->Color.DrawBuffer, NULL);
+      }
+      if (fb->ColorReadBuffer != ctx->Pixel.ReadBuffer) {
+         
+      }
+   }
+   else {
+      /* This is a user-created framebuffer.
+       * Completeness only matters for user-created framebuffers.
+       */
       _mesa_test_framebuffer_completeness(ctx, fb);
       _mesa_update_framebuffer_visual(fb);
    }
 
-   /* update_color_draw/read_buffers not needed for
-      read/draw only fb, but shouldn't hurt ??? */
+   /* Strictly speaking, we don't need to update the draw-state
+    * if this FB is bound as ctx->ReadBuffer (and conversely, the
+    * read-state if this FB is bound as ctx->DrawBuffer), but no
+    * harm.
+    */
    update_color_draw_buffers(ctx, fb);
    update_color_read_buffer(ctx, fb);
    _mesa_update_depth_buffer(ctx, fb, BUFFER_DEPTH);
@@ -748,28 +810,19 @@ update_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
    compute_depth_max(fb);
 }
 
+
 /**
  * Update state related to the current draw/read framebuffers.
- * Specifically, update these framebuffer fields:
- *    _ColorDrawBuffers
- *    _NumColorDrawBuffers
- *    _ColorReadBuffer
- *    _DepthBuffer
- *    _StencilBuffer
- * If the current framebuffer is user-created, make sure it's complete.
- * The following functions can effect this state:  glReadBuffer,
- * glDrawBuffer, glDrawBuffersARB, glFramebufferRenderbufferEXT,
- * glRenderbufferStorageEXT.
  */
 void
 _mesa_update_framebuffer(GLcontext *ctx)
 {
-   struct gl_framebuffer *fb = ctx->DrawBuffer;
-   struct gl_framebuffer *fbread = ctx->ReadBuffer;
+   struct gl_framebuffer *drawFb = ctx->DrawBuffer;
+   struct gl_framebuffer *readFb = ctx->ReadBuffer;
 
-   update_framebuffer(ctx, fb);
-   if (fbread != fb)
-      update_framebuffer(ctx, fbread);
+   update_framebuffer(ctx, drawFb);
+   if (readFb != drawFb)
+      update_framebuffer(ctx, readFb);
 }
 
 
index 4674c44a3f2d734afec74c3d175be422d6ea4d9c..ae6afef17dab035fa3157644125b75fcc5c408e9 100644 (file)
@@ -1873,6 +1873,10 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
          CHECK_EXT1(EXT_framebuffer_object, "GetBooleanv");
          params[0] = INT_TO_BOOLEAN(ctx->Const.MaxRenderbufferSize);
          break;
+      case GL_READ_FRAMEBUFFER_BINDING_EXT:
+         CHECK_EXT1(EXT_framebuffer_blit, "GetBooleanv");
+         params[0] = INT_TO_BOOLEAN(ctx->ReadBuffer->Name);
+         break;
       case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB:
          CHECK_EXT1(ARB_fragment_shader, "GetBooleanv");
          params[0] = INT_TO_BOOLEAN(ctx->Const.FragmentProgram.MaxUniformComponents);
@@ -3717,6 +3721,10 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
          CHECK_EXT1(EXT_framebuffer_object, "GetFloatv");
          params[0] = (GLfloat)(ctx->Const.MaxRenderbufferSize);
          break;
+      case GL_READ_FRAMEBUFFER_BINDING_EXT:
+         CHECK_EXT1(EXT_framebuffer_blit, "GetFloatv");
+         params[0] = (GLfloat)(ctx->ReadBuffer->Name);
+         break;
       case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB:
          CHECK_EXT1(ARB_fragment_shader, "GetFloatv");
          params[0] = (GLfloat)(ctx->Const.FragmentProgram.MaxUniformComponents);
@@ -5561,6 +5569,10 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
          CHECK_EXT1(EXT_framebuffer_object, "GetIntegerv");
          params[0] = ctx->Const.MaxRenderbufferSize;
          break;
+      case GL_READ_FRAMEBUFFER_BINDING_EXT:
+         CHECK_EXT1(EXT_framebuffer_blit, "GetIntegerv");
+         params[0] = ctx->ReadBuffer->Name;
+         break;
       case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB:
          CHECK_EXT1(ARB_fragment_shader, "GetIntegerv");
          params[0] = ctx->Const.FragmentProgram.MaxUniformComponents;
index 653deefa72667cbae560775d4be277b62a1bc796..decc9dd52a634f42bf0e4feefd245b39958dcdb3 100644 (file)
@@ -980,6 +980,11 @@ StateVars = [
          ["ctx->Const.MaxRenderbufferSize"], "",
          ["EXT_framebuffer_object"] ),
 
+       # GL_EXT_framebuffer_blit
+       # NOTE: GL_DRAW_FRAMEBUFFER_BINDING_EXT == GL_FRAMEBUFFER_BINDING_EXT
+       ( "GL_READ_FRAMEBUFFER_BINDING_EXT", GLint, ["ctx->ReadBuffer->Name"], "",
+         ["EXT_framebuffer_blit"] ),
+
        # GL_ARB_fragment_shader
        ( "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB", GLint,
          ["ctx->Const.FragmentProgram.MaxUniformComponents"], "",
index 89daa0e21db63d1027478677d6b444c76572a439..1a82ccce59a253145481489a62294813366d08b6 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.2
+ * Version:  7.1
  *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -85,7 +85,7 @@ compute_version(const GLcontext *ctx)
                               ctx->Extensions.ARB_texture_non_power_of_two &&
                               ctx->Extensions.EXT_blend_equation_separate);
    const GLboolean ver_2_1 = (ver_2_0 &&
-                              ctx->Extensions.ARB_shading_language_120 &&
+                              /*ctx->Extensions.ARB_shading_language_120 &&*/
                               ctx->Extensions.EXT_pixel_buffer_object &&
                               ctx->Extensions.EXT_texture_sRGB);
    if (ver_2_1)
@@ -121,12 +121,6 @@ _mesa_GetString( GLenum name )
    static const char *vendor = "Brian Paul";
    static const char *renderer = "Mesa";
 
-#if FEATURE_ARB_shading_language_120_foo /* support not complete! */
-   static const char *sl_version = "1.20";
-#elif FEATURE_ARB_shading_language_100
-   static const char *sl_version = "1.10";
-#endif
-
    if (!ctx)
       return NULL;
 
@@ -154,8 +148,10 @@ _mesa_GetString( GLenum name )
          return (const GLubyte *) ctx->Extensions.String;
 #if FEATURE_ARB_shading_language_100
       case GL_SHADING_LANGUAGE_VERSION_ARB:
-         if (ctx->Extensions.ARB_shading_language_100)
-            return (const GLubyte *) sl_version;
+         if (ctx->Extensions.ARB_shading_language_120)
+            return (const GLubyte *) "1.20";
+         else if (ctx->Extensions.ARB_shading_language_100)
+            return (const GLubyte *) "1.10";
          goto error;
 #endif
 #if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program || \
index f0f97c218c2266255953dee5edc17e35bddd87bd..3d413659ec180bccddfaeca3941de63a6c1419be 100644 (file)
 #ifndef GLHEADER_H
 #define GLHEADER_H
 
-/* This allows Mesa to be integrated into XFree86 */
-#ifdef HAVE_DIX_CONFIG_H
-#include "dix-config.h"
-#endif
-
 #include <assert.h>
 #include <ctype.h>
 #if defined(__alpha__) && defined(CCPML)
 #  include <stdint.h>
 #endif
 
+/* For platforms that have the C99 standard uint*_t,
+   but not the commonly used u_int*_t */
+#if defined(__sun)
+# define u_int8_t uint8_t
+# define u_int16_t uint16_t
+# define u_int32_t uint32_t
+# define u_int64_t uint64_t
+# define u_intptr_t uintptr_t
+#endif
+
+/* Sun compilers define __i386 instead of the gcc-style __i386__ */
+#ifdef __SUNPRO_C
+# if !defined(__i386__) && defined(__i386)
+#  define __i386__
+# elif !defined(__amd64__) && defined(__amd64)
+#  define __amd64__
+# elif !defined(__sparc__) && defined(__sparc)
+#  define __sparc__
+# endif
+# if !defined(__volatile)
+#  define __volatile volatile
+# endif
+#endif
+
 #if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(BUILD_FOR_SNAP)
 #  define __WIN32__
 #  define finite _finite
 #  define INLINE inline
 #elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
 #  define INLINE __inline
+#elif defined(__SUNPRO_C) && defined(__C99FEATURES__)
+#  define INLINE inline
+#  define __inline inline
+#  define __inline__ inline
+#elif (__STDC_VERSION__ >= 199901L) /* C99 */
+#  define INLINE inline
 #else
 #  define INLINE
 #endif
 #endif
 
 
-#if !defined __GNUC__ || __GNUC__ < 3
+#if (!defined(__GNUC__) || __GNUC__ < 3) && (!defined(__IBMC__) || __IBMC__ < 900)
 #  define __builtin_expect(x, y) x
 #endif
 
  * 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 __STDC_VERSION__ < 199901L
-# if ((!defined __GNUC__) || (__GNUC__ < 2)) && (!defined __xlC__) && \
+#ifndef __FUNCTION__
+# if defined(__VMS)
+#  define __FUNCTION__ "VMS$NL:"
+# elif ((!defined __GNUC__) || (__GNUC__ < 2)) && (!defined __xlC__) && \
       (!defined(_MSC_VER) || _MSC_VER < 1300)
-#  define __FUNCTION__ "<unknown>"
+#  if (__STDC_VERSION__ >= 199901L) /* C99 */ || \
+    (defined(__SUNPRO_C) && defined(__C99FEATURES__))
+#   define __FUNCTION__ __func__
+#  else
+#   define __FUNCTION__ "<unknown>"
+#  endif
 # endif
 #endif
 
index 52c4999e16e90723bc691ffb1cbb8be75ef9fa65..bd38e0c3d8c732a7e012fcc1bbc03d9616940512 100644 (file)
@@ -849,7 +849,7 @@ _mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels,
          return NULL;
       }
 
-      if (packing->SkipPixels == 0) {
+      if ((packing->SkipPixels & 7) == 0) {
          _mesa_memcpy( dst, src, width_in_bytes );
          if (packing->LsbFirst) {
             flip_bytes( dst, width_in_bytes );
@@ -941,7 +941,7 @@ _mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source,
       if (!dst)
          return;
 
-      if (packing->SkipPixels == 0) {
+      if ((packing->SkipPixels & 7) == 0) {
          _mesa_memcpy( dst, src, width_in_bytes );
          if (packing->LsbFirst) {
             flip_bytes( dst, width_in_bytes );
@@ -960,20 +960,20 @@ _mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source,
                if (*s & srcMask) {
                   *d |= dstMask;
                }
-               if (srcMask == 128) {
-                  srcMask = 1;
+               if (srcMask == 1) {
+                  srcMask = 128;
                   s++;
                }
                else {
-                  srcMask = srcMask << 1;
+                  srcMask = srcMask >> 1;
                }
-               if (dstMask == 1) {
-                  dstMask = 128;
+               if (dstMask == 128) {
+                  dstMask = 1;
                   d++;
                   *d = 0;
                }
                else {
-                  dstMask = dstMask >> 1;
+                  dstMask = dstMask << 1;
                }
             }
          }
@@ -4214,7 +4214,7 @@ _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n,
 
    switch (dstType) {
    case GL_UNSIGNED_BYTE:
-      if (sizeof(GLstencil) == 8) {
+      if (sizeof(GLstencil) == 1) {
          _mesa_memcpy( dest, source, n );
       }
       else {
@@ -4226,14 +4226,11 @@ _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n,
       }
       break;
    case GL_BYTE:
-      if (sizeof(GLstencil) == 8) {
-         _mesa_memcpy( dest, source, n );
-      }
-      else {
+      {
          GLbyte *dst = (GLbyte *) dest;
          GLuint i;
          for (i=0;i<n;i++) {
-            dst[i] = (GLbyte) source[i];
+            dst[i] = (GLbyte) (source[i] & 0x7f);
          }
       }
       break;
@@ -4278,7 +4275,7 @@ _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n,
          GLint *dst = (GLint *) dest;
          GLuint i;
          for (i=0;i<n;i++) {
-            *dst++ = (GLint) source[i];
+            dst[i] = (GLint) source[i];
          }
          if (dstPacking->SwapBytes) {
             _mesa_swap4( (GLuint *) dst, n );
index 7231fa699cbd6de1804314a700dfa4c67027bde9..6cfd7ccc723c930622490471818194465f79d88c 100644 (file)
@@ -104,6 +104,8 @@ _mesa_align_malloc(size_t bytes, unsigned long alignment)
 
    (void) posix_memalign(& mem, alignment, bytes);
    return mem;
+#elif defined(_WIN32) && defined(_MSC_VER)
+   return _aligned_malloc(bytes, alignment);
 #else
    uintptr_t ptr, buf;
 
@@ -143,6 +145,15 @@ _mesa_align_calloc(size_t bytes, unsigned long alignment)
       (void) memset(mem, 0, bytes);
    }
 
+   return mem;
+#elif defined(_WIN32) && defined(_MSC_VER)
+   void *mem;
+
+   mem = _aligned_malloc(bytes, alignment);
+   if (mem != NULL) {
+      (void) memset(mem, 0, bytes);
+   }
+
    return mem;
 #else
    uintptr_t ptr, buf;
@@ -180,6 +191,8 @@ _mesa_align_free(void *ptr)
 {
 #if defined(HAVE_POSIX_MEMALIGN)
    free(ptr);
+#elif defined(_WIN32) && defined(_MSC_VER)
+   _aligned_free(ptr);
 #else
    void **cubbyHole = (void **) ((char *) ptr - sizeof(void *));
    void *realAddr = *cubbyHole;
@@ -194,6 +207,10 @@ void *
 _mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize,
                     unsigned long alignment)
 {
+#if defined(_WIN32) && defined(_MSC_VER)
+   (void) oldSize;
+   return _aligned_realloc(oldBuffer, newSize, alignment);
+#else
    const size_t copySize = (oldSize < newSize) ? oldSize : newSize;
    void *newBuf = _mesa_align_malloc(newSize, alignment);
    if (newBuf && oldBuffer && copySize > 0) {
@@ -202,6 +219,7 @@ _mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize,
    if (oldBuffer)
       _mesa_align_free(oldBuffer);
    return newBuf;
+#endif
 }
 
 
@@ -541,25 +559,28 @@ _mesa_pow(double x, double y)
 int
 _mesa_ffs(int32_t i)
 {
-#if (defined(_WIN32) && !defined(__MINGW32__) ) || defined(__IBMC__) || defined(__IBMCPP__)
-   register int32_t bit = 1;
-   if ((i & 0xffff) == 0) {
-      bit += 16;
-      i >>= 16;
-   }
-   if ((i & 0xff) == 0) {
-      bit += 8;
-      i >>= 8;
-   }
-   if ((i & 0xf) == 0) {
-      bit += 4;
-      i >>= 4;
-   }
-   if ((i & 0x3) == 0) {
-      bit += 2;
-      i >>= 2;
+#if (defined(_WIN32) ) || defined(__IBMC__) || defined(__IBMCPP__)
+   register int bit = 0;
+   if (i != 0) {
+      if ((i & 0xffff) == 0) {
+         bit += 16;
+         i >>= 16;
+      }
+      if ((i & 0xff) == 0) {
+         bit += 8;
+         i >>= 8;
+      }
+      if ((i & 0xf) == 0) {
+         bit += 4;
+         i >>= 4;
+      }
+      while ((i & 1) == 0) {
+         bit++;
+         i >>= 1;
+      }
+      bit++;
    }
-   return (i) ? (bit + ((i + 1) & 0x01)) : 0;
+   return bit;
 #else
    return ffs(i);
 #endif
index d91a1366b07ac9747bc89f72c327b0eb2a7cb99a..0e6e301fdeb6291625ab143d286fe1046ed93a47 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.2
+ * Version:  7.1
  *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -159,12 +159,13 @@ typedef union { GLfloat f; GLint i; } fi_type;
  ***/
 #if defined(__i386__) || defined(__386__) || defined(__sparc__) || \
     defined(__s390x__) || defined(__powerpc__) || \
-    defined(__amd64__) || \
+    defined(__x86_64__) || \
     defined(ia64) || defined(__ia64__) || \
     defined(__hppa__) || defined(hpux) || \
     defined(__mips) || defined(_MIPS_ARCH) || \
     defined(__arm__) || \
     defined(__sh__) || defined(__m32r__) || \
+    (defined(__sun) && defined(_IEEE_754)) || \
     (defined(__alpha__) && (defined(__IEEE_FLOAT) || !defined(VMS)))
 #define USE_IEEE
 #define IEEE_ONE 0x3f800000
index f37d1f216fc94796212de3ea1d1f2375903727ca..d4db960f1b9a500e2c672a7c6da32f386760f13d 100644 (file)
@@ -53,6 +53,11 @@ _mesa_ShadeModel( GLenum mode )
 
    FLUSH_VERTICES(ctx, _NEW_LIGHT);
    ctx->Light.ShadeModel = mode;
+   if (mode == GL_FLAT)
+      ctx->_TriangleCaps |= DD_FLATSHADE;
+   else
+      ctx->_TriangleCaps &= ~DD_FLATSHADE;
+
    if (ctx->Driver.ShadeModel)
       ctx->Driver.ShadeModel( ctx, mode );
 }
@@ -179,6 +184,7 @@ _mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params )
    GET_CURRENT_CONTEXT(ctx);
    GLint i = (GLint) (light - GL_LIGHT0);
    GLfloat temp[4];
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    if (i < 0 || i >= (GLint) ctx->Const.MaxLights) {
       _mesa_error( ctx, GL_INVALID_ENUM, "glLight(light=0x%x)", light );
@@ -441,6 +447,10 @@ _mesa_LightModelfv( GLenum pname, const GLfloat *params )
            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)
index 0c2dbf915a1901503bb9a7f8867e902601e0c7ed..81d0d33abb405ab9fd1ad5fbb246daedb447b213 100644 (file)
@@ -56,6 +56,11 @@ _mesa_LineWidth( GLfloat width )
    FLUSH_VERTICES(ctx, _NEW_LINE);
    ctx->Line.Width = width;
 
+   if (width != 1.0F)
+      ctx->_TriangleCaps |= DD_LINE_WIDTH;
+   else
+      ctx->_TriangleCaps &= ~DD_LINE_WIDTH;
+
    if (ctx->Driver.LineWidth)
       ctx->Driver.LineWidth(ctx, width);
 }
index 061378f3b77bcba8b45ff24dde441bae93eff84c..d35fa6734c80e4257e8607ddce58811a22695120 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.2
+ * Version:  7.1
  *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -452,9 +452,9 @@ make_1d_mipmap(GLenum datatype, GLuint comps, GLint border,
 static void
 make_2d_mipmap(GLenum datatype, GLuint comps, GLint border,
                GLint srcWidth, GLint srcHeight,
-               GLint srcRowStride, const GLubyte *srcPtr,
+               GLint srcRowBytes, const GLubyte *srcPtr,
                GLint dstWidth, GLint dstHeight,
-               GLint dstRowStride, GLubyte *dstPtr)
+               GLint dstRowBytes, GLubyte *dstPtr)
 {
    const GLint bpt = bytes_per_pixel(datatype, comps);
    const GLint srcWidthNB = srcWidth - 2 * border;  /* sizes w/out border */
@@ -464,16 +464,16 @@ make_2d_mipmap(GLenum datatype, GLuint comps, GLint border,
    GLubyte *dst;
    GLint row;
 
-   if (!srcRowStride)
-      srcRowStride = bpt * srcWidth;
+   if (!srcRowBytes)
+      srcRowBytes = bpt * srcWidth;
 
-   if (!dstRowStride)
-      dstRowStride = bpt * dstWidth;
+   if (!dstRowBytes)
+      dstRowBytes = bpt * dstWidth;
 
    /* Compute src and dst pointers, skipping any border */
    srcA = srcPtr + border * ((srcWidth + 1) * bpt);
    if (srcHeight > 1) 
-      srcB = srcA + srcRowStride;
+      srcB = srcA + srcRowBytes;
    else
       srcB = srcA;
    dst = dstPtr + border * ((dstWidth + 1) * bpt);
@@ -481,9 +481,9 @@ make_2d_mipmap(GLenum datatype, GLuint comps, GLint border,
    for (row = 0; row < dstHeightNB; row++) {
       do_row(datatype, comps, srcWidthNB, srcA, srcB,
              dstWidthNB, dst);
-      srcA += 2 * srcRowStride;
-      srcB += 2 * srcRowStride;
-      dst += dstRowStride;
+      srcA += 2 * srcRowBytes;
+      srcB += 2 * srcRowBytes;
+      dst += dstRowBytes;
    }
 
    /* This is ugly but probably won't be used much */
@@ -541,10 +541,10 @@ make_2d_mipmap(GLenum datatype, GLuint comps, GLint border,
 static void
 make_3d_mipmap(GLenum datatype, GLuint comps, GLint border,
                GLint srcWidth, GLint srcHeight, GLint srcDepth,
-               GLint srcRowStride,
+               GLint srcRowBytes,
                const GLubyte *srcPtr,
                GLint dstWidth, GLint dstHeight, GLint dstDepth,
-               GLint dstRowStride,
+               GLint dstRowBytes,
                GLubyte *dstPtr)
 {
    const GLint bpt = bytes_per_pixel(datatype, comps);
@@ -573,10 +573,10 @@ make_3d_mipmap(GLenum datatype, GLuint comps, GLint border,
    bytesPerSrcImage = srcWidth * srcHeight * bpt;
    bytesPerDstImage = dstWidth * dstHeight * bpt;
 
-   if (!srcRowStride)
-      srcRowStride = srcWidth * bpt;
-   if (!dstRowStride)
-      dstRowStride = dstWidth * bpt;
+   if (!srcRowBytes)
+      srcRowBytes = srcWidth * bpt;
+   if (!dstRowBytes)
+      dstRowBytes = dstWidth * bpt;
 
    /* Offset between adjacent src images to be averaged together */
    srcImageOffset = (srcDepth == dstDepth) ? 0 : bytesPerSrcImage;
@@ -600,13 +600,13 @@ make_3d_mipmap(GLenum datatype, GLuint comps, GLint border,
    for (img = 0; img < dstDepthNB; img++) {
       /* first source image pointer, skipping border */
       const GLubyte *imgSrcA = srcPtr
-         + (bytesPerSrcImage + srcRowStride + border) * bpt * border
+         + (bytesPerSrcImage + srcRowBytes + 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 + dstRowStride + border) * bpt * border
+         + (bytesPerDstImage + dstRowBytes + border) * bpt * border
          + img * bytesPerDstImage;
 
       /* setup the four source row pointers and the dest row pointer */
@@ -627,11 +627,11 @@ make_3d_mipmap(GLenum datatype, GLuint comps, GLint border,
          do_row(datatype, comps, srcWidthNB, tmpRowA, tmpRowB,
                 dstWidthNB, dstImgRow);
          /* advance to next rows */
-         srcImgARowA += srcRowStride + srcRowOffset;
-         srcImgARowB += srcRowStride + srcRowOffset;
-         srcImgBRowA += srcRowStride + srcRowOffset;
-         srcImgBRowB += srcRowStride + srcRowOffset;
-         dstImgRow += dstRowStride;
+         srcImgARowA += srcRowBytes + srcRowOffset;
+         srcImgARowB += srcRowBytes + srcRowOffset;
+         srcImgBRowA += srcRowBytes + srcRowOffset;
+         srcImgBRowB += srcRowBytes + srcRowOffset;
+         dstImgRow += dstRowBytes;
       }
    }
 
@@ -664,9 +664,9 @@ make_3d_mipmap(GLenum datatype, GLuint comps, GLint border,
 
             /* do border along [img][row=dstHeight-1][col=0] */
             src = srcPtr + (img * 2 + 1) * bytesPerSrcImage
-                         + (srcHeight - 1) * srcRowStride;
+                         + (srcHeight - 1) * srcRowBytes;
             dst = dstPtr + (img + 1) * bytesPerDstImage
-                         + (dstHeight - 1) * dstRowStride;
+                         + (dstHeight - 1) * dstRowBytes;
             MEMCPY(dst, src, bpt);
 
             /* do border along [img][row=0][col=dstWidth-1] */
@@ -698,9 +698,9 @@ make_3d_mipmap(GLenum datatype, GLuint comps, GLint border,
 
             /* do border along [img][row=dstHeight-1][col=0] */
             src = srcPtr + (img * 2 + 1) * bytesPerSrcImage
-                         + (srcHeight - 1) * srcRowStride;
+                         + (srcHeight - 1) * srcRowBytes;
             dst = dstPtr + (img + 1) * bytesPerDstImage
-                         + (dstHeight - 1) * dstRowStride;
+                         + (dstHeight - 1) * dstRowBytes;
             do_row(datatype, comps, 1, src, src + srcImageOffset, 1, dst);
 
             /* do border along [img][row=0][col=dstWidth-1] */
@@ -731,8 +731,8 @@ make_1d_stack_mipmap(GLenum datatype, GLuint comps, GLint border,
    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 GLint srcRowBytes = bpt * srcRowBytes;
+   const GLint dstRowBytes = bpt * dstRowBytes;
    const GLubyte *src;
    GLubyte *dst;
    GLint row;
@@ -744,8 +744,8 @@ make_1d_stack_mipmap(GLenum datatype, GLuint comps, GLint border,
    for (row = 0; row < dstHeightNB; row++) {
       do_row(datatype, comps, srcWidthNB, src, src,
              dstWidthNB, dst);
-      src += srcRowStride;
-      dst += dstRowStride;
+      src += srcRowBytes;
+      dst += dstRowBytes;
    }
 
    if (border) {
@@ -767,10 +767,10 @@ make_1d_stack_mipmap(GLenum datatype, GLuint comps, GLint border,
 static void
 make_2d_stack_mipmap(GLenum datatype, GLuint comps, GLint border,
                      GLint srcWidth, GLint srcHeight,
-                     GLint srcRowStride,
+                     GLint srcRowBytes,
                      const GLubyte *srcPtr,
                      GLint dstWidth, GLint dstHeight, GLint dstDepth,
-                     GLint dstRowStride,
+                     GLint dstRowBytes,
                      GLubyte *dstPtr)
 {
    const GLint bpt = bytes_per_pixel(datatype, comps);
@@ -783,16 +783,16 @@ make_2d_stack_mipmap(GLenum datatype, GLuint comps, GLint border,
    GLint layer;
    GLint row;
 
-   if (!srcRowStride)
-      srcRowStride = bpt * srcWidth;
+   if (!srcRowBytes)
+      srcRowBytes = bpt * srcWidth;
 
-   if (!dstRowStride)
-      dstRowStride = bpt * dstWidth;
+   if (!dstRowBytes)
+      dstRowBytes = bpt * dstWidth;
 
    /* Compute src and dst pointers, skipping any border */
    srcA = srcPtr + border * ((srcWidth + 1) * bpt);
    if (srcHeight > 1) 
-      srcB = srcA + srcRowStride;
+      srcB = srcA + srcRowBytes;
    else
       srcB = srcA;
    dst = dstPtr + border * ((dstWidth + 1) * bpt);
@@ -801,9 +801,9 @@ make_2d_stack_mipmap(GLenum datatype, GLuint comps, GLint border,
       for (row = 0; row < dstHeightNB; row++) {
          do_row(datatype, comps, srcWidthNB, srcA, srcB,
                 dstWidthNB, dst);
-         srcA += 2 * srcRowStride;
-         srcB += 2 * srcRowStride;
-         dst += dstRowStride;
+         srcA += 2 * srcRowBytes;
+         srcB += 2 * srcRowBytes;
+         dst += dstRowBytes;
       }
 
       /* This is ugly but probably won't be used much */
@@ -867,10 +867,10 @@ _mesa_generate_mipmap_level(GLenum target,
                             GLenum datatype, GLuint comps,
                             GLint border,
                             GLint srcWidth, GLint srcHeight, GLint srcDepth,
-                            GLint srcRowStride,
+                            GLint srcRowBytes,
                             const GLubyte *srcData,
                             GLint dstWidth, GLint dstHeight, GLint dstDepth,
-                            GLint dstRowStride,
+                            GLint dstRowBytes,
                             GLubyte *dstData)
 {
    switch (target) {
@@ -887,13 +887,13 @@ _mesa_generate_mipmap_level(GLenum target,
    case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
    case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
       make_2d_mipmap(datatype, comps, border,
-                     srcWidth, srcHeight, srcRowStride, srcData,
-                     dstWidth, dstHeight, dstRowStride, dstData);
+                     srcWidth, srcHeight, srcRowBytes, srcData,
+                     dstWidth, dstHeight, dstRowBytes, dstData);
       break;
    case GL_TEXTURE_3D:
       make_3d_mipmap(datatype, comps, border,
-                     srcWidth, srcHeight, srcDepth, srcRowStride, srcData,
-                     dstWidth, dstHeight, dstDepth, dstRowStride, dstData);
+                     srcWidth, srcHeight, srcDepth, srcRowBytes, srcData,
+                     dstWidth, dstHeight, dstDepth, dstRowBytes, dstData);
       break;
    case GL_TEXTURE_1D_ARRAY_EXT:
       make_1d_stack_mipmap(datatype, comps, border,
@@ -902,8 +902,8 @@ _mesa_generate_mipmap_level(GLenum target,
       break;
    case GL_TEXTURE_2D_ARRAY_EXT:
       make_2d_stack_mipmap(datatype, comps, border,
-                           srcWidth, srcHeight, srcRowStride, srcData,
-                           dstWidth, dstHeight, dstDepth, dstRowStride, dstData);
+                           srcWidth, srcHeight, srcRowBytes, srcData,
+                           dstWidth, dstHeight, dstDepth, dstRowBytes, dstData);
       break;
    case GL_TEXTURE_RECTANGLE_NV:
       /* no mipmaps, do nothing */
@@ -991,7 +991,8 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
       GLint  components, size;
       GLchan *dst;
 
-      assert(texObj->Target == GL_TEXTURE_2D);
+      assert(texObj->Target == GL_TEXTURE_2D ||
+             texObj->Target == GL_TEXTURE_CUBE_MAP_ARB);
 
       if (srcImage->_BaseFormat == GL_RGB) {
          convertFormat = &_mesa_texformat_rgb;
@@ -1139,14 +1140,14 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
          GLubyte *temp;
          /* compress image from dstData into dstImage->Data */
          const GLenum srcFormat = convertFormat->BaseFormat;
-         GLint dstRowStride
+         GLint dstRowBytes
             = _mesa_compressed_row_stride(dstImage->TexFormat->MesaFormat, dstWidth);
          ASSERT(srcFormat == GL_RGB || srcFormat == GL_RGBA);
          dstImage->TexFormat->StoreImage(ctx, 2, dstImage->_BaseFormat,
                                          dstImage->TexFormat,
                                          dstImage->Data,
                                          0, 0, 0, /* dstX/Y/Zoffset */
-                                         dstRowStride, 0, /* strides */
+                                         dstRowBytes, 0, /* strides */
                                          dstWidth, dstHeight, 1, /* size */
                                          srcFormat, CHAN_TYPE,
                                          dstData, /* src data, actually */
@@ -1171,7 +1172,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
 void
 _mesa_rescale_teximage2d(GLuint bytesPerPixel,
                         GLuint srcStrideInPixels,
-                        GLuint dstRowStride,
+                        GLuint dstRowBytes,
                         GLint srcWidth, GLint srcHeight,
                         GLint dstWidth, GLint dstHeight,
                         const GLvoid *srcImage, GLvoid *dstImage)
@@ -1185,7 +1186,7 @@ _mesa_rescale_teximage2d(GLuint bytesPerPixel,
         GLint srcCol = col WOP wScale;                                 \
         dst[col] = src[srcRow * srcStrideInPixels + srcCol];           \
       }                                                                        \
-      dst = (TYPE *) ((GLubyte *) dst + dstRowStride);                 \
+      dst = (TYPE *) ((GLubyte *) dst + dstRowBytes);                  \
    }                                                                   \
 
 #define RESCALE_IMAGE( TYPE )                                          \
@@ -1243,7 +1244,7 @@ do {                                                                      \
 void
 _mesa_upscale_teximage2d(GLsizei inWidth, GLsizei inHeight,
                          GLsizei outWidth, GLsizei outHeight,
-                         GLint comps, const GLchan *src, GLint srcRowStride,
+                         GLint comps, const GLchan *src, GLint srcRowBytes,
                          GLchan *dest )
 {
    GLint i, j, k;
@@ -1262,7 +1263,7 @@ _mesa_upscale_teximage2d(GLsizei inWidth, GLsizei inHeight,
          const GLint jj = j % inWidth;
          for (k = 0; k < comps; k++) {
             dest[(i * outWidth + j) * comps + k]
-               = src[ii * srcRowStride + jj * comps + k];
+               = src[ii * srcRowBytes + jj * comps + k];
          }
       }
    }
index a5e1cf6a276c58fa54414a6240edf1b6236a9ec4..8e4f6a2e663d4b75accbbbb2eec700e08d29be87 100644 (file)
@@ -1369,7 +1369,7 @@ struct gl_texture_image
    GLboolean IsCompressed;     /**< GL_ARB_texture_compression */
    GLuint CompressedSize;      /**< GL_ARB_texture_compression */
 
-   GLuint RowStride;           /**< == Width unless IsClientData and padded */
+   GLuint RowStride;           /**< Padded width in units of texels */
    GLuint *ImageOffsets;        /**< if 3D texture: array [Depth] of offsets to
                                      each 2D slice in 'Data', in texels */
    GLvoid *Data;               /**< Image data, accessed via FetchTexel() */
@@ -1540,17 +1540,6 @@ struct gl_texture_unit
 
    struct gl_texture_object *_Current; /**< Points to really enabled tex obj */
 
-   /** These are used for glPush/PopAttrib */
-   /*@{*/
-   struct gl_texture_object Saved1D;
-   struct gl_texture_object Saved2D;
-   struct gl_texture_object Saved3D;
-   struct gl_texture_object SavedCubeMap;
-   struct gl_texture_object SavedRect;
-   struct gl_texture_object Saved1DArray;
-   struct gl_texture_object Saved2DArray;
-   /*@}*/
-
    /** GL_SGI_texture_color_table */
    /*@{*/
    struct gl_color_table ColorTable;
@@ -1560,6 +1549,7 @@ struct gl_texture_unit
 };
 
 
+
 /**
  * Texture attribute group (GL_TEXTURE_BIT).
  */
@@ -1579,17 +1569,7 @@ struct gl_texture_attrib
 
    struct gl_texture_unit Unit[MAX_TEXTURE_UNITS];
 
-#if 0
-   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;
-   struct gl_texture_object *Proxy1DArray;
-   struct gl_texture_object *Proxy2DArray;
-#else
    struct gl_texture_object *ProxyTex[NUM_TEXTURE_TARGETS];
-#endif
 
    /** GL_EXT_shared_texture_palette */
    GLboolean SharedPalette;
@@ -2426,13 +2406,11 @@ struct gl_framebuffer
    GLenum ColorDrawBuffer[MAX_DRAW_BUFFERS];
    GLenum ColorReadBuffer;
 
-   /* These are computed from ColorDrawBuffer and ColorReadBuffer */
-   GLbitfield _ColorDrawBufferMask[MAX_DRAW_BUFFERS]; /* Mask of BUFFER_BIT_* flags */
+   /** Computed from ColorDraw/ReadBuffer above */
+   GLuint _NumColorDrawBuffers;
+   GLint _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS]; /**< BUFFER_x or -1 */
    GLint _ColorReadBufferIndex; /* -1 = None */
-
-   /* These are computed from _ColorDrawBufferMask and _ColorReadBufferIndex */
-   GLuint _NumColorDrawBuffers[MAX_DRAW_BUFFERS];
-   struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS][4];
+   struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS];
    struct gl_renderbuffer *_ColorReadBuffer;
 
    /** The Actual depth/stencil buffers to use.  May be wrappers around the
@@ -2899,7 +2877,6 @@ struct mesa_display_list
  */
 struct gl_dlist_state
 {
-   struct mesa_display_list *CallStack[MAX_LIST_NESTING];
    GLuint CallDepth;           /**< Current recursion calling depth */
 
    struct mesa_display_list *CurrentList;
@@ -3074,7 +3051,10 @@ struct __GLcontextRec
 
    /** \name Derived state */
    /*@{*/
-   GLbitfield _TriangleCaps;      /**< bitwise-or of DD_* flags */
+   /** Bitwise-or of DD_* flags.  Note that this bitfield may be used before
+    * state validation so they need to always be current.
+    */
+   GLbitfield _TriangleCaps;
    GLbitfield _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */
    GLfloat _EyeZDir[3];
    GLfloat _ModelViewInvScale;
@@ -3090,12 +3070,6 @@ struct __GLcontextRec
 
    struct gl_list_extensions ListExt; /**< driver dlist extensions */
 
-
-   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 For debugging/development only */
    /*@{*/
    GLboolean FirstTimeCurrent;
index fbedbcb22c497756a6e607f76c0d08070c73bb38..7e189a0a8c9dcec51e193c11d9337309d453d5fb 100644 (file)
@@ -5,7 +5,7 @@
 
 /*
  * Mesa 3-D graphics library
- * Version:  7.0
+ * Version:  7.1
  *
  * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
@@ -77,8 +77,13 @@ _mesa_PointParameteri( GLenum pname, GLint param )
 void GLAPIENTRY
 _mesa_PointParameteriv( GLenum pname, const GLint *params )
 {
-   const GLfloat value = (GLfloat) params[0];
-   _mesa_PointParameterfv(pname, &value);
+   GLfloat p[3];
+   p[0] = (GLfloat) params[0];
+   if (pname == GL_DISTANCE_ATTENUATION_EXT) {
+      p[1] = (GLfloat) params[1];
+      p[2] = (GLfloat) params[2];
+   }
+   _mesa_PointParameterfv(pname, p);
 }
 
 
@@ -105,6 +110,11 @@ _mesa_PointParameterfv( GLenum pname, const GLfloat *params)
             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;
          }
          else {
             _mesa_error(ctx, GL_INVALID_ENUM,
index fd02e5a652d89252351a4363b8fac28f173d7f54..564250b881cf10c3cdae0481fdeea63d265fbe9d 100644 (file)
@@ -167,6 +167,11 @@ _mesa_PolygonMode( GLenum face, GLenum mode )
       return;
    }
 
+   if (ctx->Polygon.FrontMode == GL_FILL && ctx->Polygon.BackMode == GL_FILL)
+      ctx->_TriangleCaps &= ~DD_TRI_UNFILLED;
+   else
+      ctx->_TriangleCaps |= DD_TRI_UNFILLED;
+
    if (ctx->Driver.PolygonMode)
       ctx->Driver.PolygonMode(ctx, face, mode);
 }
index d355f78a0efbf98b2ac1184c6f91d4edf0042589..030c43365fe9f30686e381a79d632c255d6e3ea3 100644 (file)
 #include "texstate.h"
 
 
+
+
+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.
  */
@@ -176,7 +188,7 @@ update_program(GLcontext *ctx)
    ctx->FragmentProgram._Enabled = ctx->FragmentProgram.Enabled
       && ctx->FragmentProgram.Current->Base.Instructions;
    ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled
-      && ctx->ATIFragmentShader.Current->Instructions;
+      && ctx->ATIFragmentShader.Current->Instructions[0];
 
    /*
     * Set the ctx->VertexProgram._Current and ctx->FragmentProgram._Current
@@ -194,77 +206,87 @@ update_program(GLcontext *ctx)
     * come up, or matter.
     */
 
-   /**
-    ** Fragment program
-    **/
-#if 1
-   /* XXX get rid of this someday? */
-   ctx->FragmentProgram._Active = GL_FALSE;
-#endif
-   if (shProg && shProg->LinkStatus && shProg->FragmentProgram) {
-      /* user-defined fragment shader */
+   _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL);
+
+   if (shProg && shProg->LinkStatus) {
+      /* Use shader programs */
+      /* XXX this isn't quite right, since we may have either a vertex
+       * _or_ fragment shader (not always both).
+       */
+      _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
+                               shProg->VertexProgram);
       _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
                                shProg->FragmentProgram);
    }
-   else if (ctx->FragmentProgram._Enabled) {
-      /* use user-defined fragment program */
-      _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
-                               ctx->FragmentProgram.Current);
+   else {
+      if (ctx->FragmentProgram._Enabled) {
+         /* use user-defined vertex program */
+         _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
+                                  ctx->FragmentProgram.Current);
+      }
+      else if (ctx->FragmentProgram._MaintainTexEnvProgram) {
+         /* Use fragment program generated from fixed-function state.
+          */
+         _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
+                                  _mesa_get_fixed_func_fragment_program(ctx));
+         _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram,
+                                  ctx->FragmentProgram._Current);
+      }
+      else {
+         /* no fragment program */
+         _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL);
+      }
+
+      /* Examine vertex program after fragment program as
+       * _mesa_get_fixed_func_vertex_program() needs to know active
+       * fragprog inputs.
+       */
+      if (ctx->VertexProgram._Enabled) {
+         /* use user-defined vertex program */
+         _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
+                                  ctx->VertexProgram.Current);
+      }
+      else if (ctx->VertexProgram._MaintainTnlProgram) {
+         /* Use vertex program generated from fixed-function state.
+          */
+         _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
+                                  _mesa_get_fixed_func_vertex_program(ctx));
+         _mesa_reference_vertprog(ctx, &ctx->VertexProgram._TnlProgram,
+                                  ctx->VertexProgram._Current);
+      }
+      else {
+         /* no vertex program */
+         _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL);
+      }
    }
-   else if (ctx->FragmentProgram._MaintainTexEnvProgram) {
-      /* fragment program generated from fixed-function state */
-      _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
-                               _mesa_get_fixed_func_fragment_program(ctx));
-      _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram,
-                               ctx->FragmentProgram._Current);
 
-      /* XXX get rid of this confusing stuff someday? */
-      ctx->FragmentProgram._Active = ctx->FragmentProgram._Enabled;
+   if (ctx->VertexProgram._Current)
+      assert(ctx->VertexProgram._Current->Base.Parameters);
+   if (ctx->FragmentProgram._Current)
+      assert(ctx->FragmentProgram._Current->Base.Parameters);
+
+
+   /* XXX: get rid of _Active flag.
+    */
+#if 1
+   ctx->FragmentProgram._Active = ctx->FragmentProgram._Enabled;
+   if (ctx->FragmentProgram._MaintainTexEnvProgram &&
+       !ctx->FragmentProgram._Enabled) {
       if (ctx->FragmentProgram._UseTexEnvProgram)
-         ctx->FragmentProgram._Active = GL_TRUE;
-   }
-   else {
-      /* no fragment program */
-      _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL);
+        ctx->FragmentProgram._Active = GL_TRUE;
    }
+#endif
 
+   /* Let the driver know what's happening:
+    */
    if (ctx->FragmentProgram._Current != prevFP && ctx->Driver.BindProgram) {
       ctx->Driver.BindProgram(ctx, GL_FRAGMENT_PROGRAM_ARB,
-                         (struct gl_program *) ctx->FragmentProgram._Current);
-   }
-
-   /**
-    ** Vertex program
-    **/
-#if 1
-   /* XXX get rid of this someday? */
-   _mesa_reference_vertprog(ctx, &ctx->VertexProgram._TnlProgram, NULL);
-#endif
-   if (shProg && shProg->LinkStatus && shProg->VertexProgram) {
-      /* user-defined vertex shader */
-      _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
-                               shProg->VertexProgram);
-   }
-   else if (ctx->VertexProgram._Enabled) {
-      /* use user-defined vertex program */
-      _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
-                               ctx->VertexProgram.Current);
-   }
-   else if (ctx->VertexProgram._MaintainTnlProgram) {
-      /* vertex program generated from fixed-function state */
-      _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
-                               _mesa_get_fixed_func_vertex_program(ctx));
-      _mesa_reference_vertprog(ctx, &ctx->VertexProgram._TnlProgram,
-                               ctx->VertexProgram._Current);
-   }
-   else {
-      /* no vertex program / used fixed-function code */
-      _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL);
+                              (struct gl_program *) ctx->FragmentProgram._Current);
    }
-
+   
    if (ctx->VertexProgram._Current != prevVP && ctx->Driver.BindProgram) {
       ctx->Driver.BindProgram(ctx, GL_VERTEX_PROGRAM_ARB,
-                           (struct gl_program *) ctx->VertexProgram._Current);
+                              (struct gl_program *) ctx->VertexProgram._Current);
    }
 }
 
@@ -315,6 +337,24 @@ update_color(GLcontext *ctx)
 }
 
 
+/*
+ * Check polygon state and set DD_TRI_CULL_FRONT_BACK and/or DD_TRI_OFFSET
+ * in ctx->_TriangleCaps if needed.
+ */
+static void
+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;
+
+   if (   ctx->Polygon.OffsetPoint
+       || ctx->Polygon.OffsetLine
+       || ctx->Polygon.OffsetFill)
+      ctx->_TriangleCaps |= DD_TRI_OFFSET;
+}
+
 
 /**
  * Update the ctx->_TriangleCaps bitfield.
@@ -322,6 +362,7 @@ update_color(GLcontext *ctx)
  * This function must be called after other update_*() functions since
  * there are dependencies on some other derived values.
  */
+#if 0
 static void
 update_tricaps(GLcontext *ctx, GLbitfield new_state)
 {
@@ -387,6 +428,7 @@ update_tricaps(GLcontext *ctx, GLbitfield new_state)
    if (ctx->Stencil._TestTwoSide)
       ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL;
 }
+#endif
 
 
 /**
@@ -422,6 +464,9 @@ _mesa_update_state_locked( GLcontext *ctx )
    if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
       _mesa_update_draw_buffer_bounds( ctx );
 
+   if (new_state & _NEW_POLYGON)
+      update_polygon( ctx );
+
    if (new_state & _NEW_LIGHT)
       _mesa_update_lighting( ctx );
 
@@ -433,6 +478,9 @@ _mesa_update_state_locked( GLcontext *ctx )
       _mesa_update_pixel( ctx, new_state );
 #endif
 
+   if (new_state & _DD_NEW_SEPARATE_SPECULAR)
+      update_separate_specular( ctx );
+
    if (new_state & (_NEW_ARRAY | _NEW_PROGRAM))
       update_arrays( ctx );
 
@@ -445,9 +493,11 @@ _mesa_update_state_locked( GLcontext *ctx )
    if (new_state & _NEW_COLOR)
       update_color( ctx );
 
+#if 0
    if (new_state & (_NEW_POINT | _NEW_LINE | _NEW_POLYGON | _NEW_LIGHT
                     | _NEW_STENCIL | _DD_NEW_SEPARATE_SPECULAR))
       update_tricaps( ctx, new_state );
+#endif
 
    /* ctx->_NeedEyeCoords is now up to date.
     *
index 16a3ba076fd5acf196470b7abe7dee8b7a1aaa0a..fc151605c9e32319e9a05eba6f1dbeb206536969 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5
+ * Version:  7.1
  *
- * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
index c48063d919244c58f020ff52a326a3c1e7d0e6bb..4f329cdf59be64bf470f03f57adc2603de8ed885 100644 (file)
@@ -577,6 +577,32 @@ const struct gl_texture_format _mesa_texformat_rgb_dxt1 = {
    NULL                                        /* StoreTexel */
 };
 
+#if FEATURE_EXT_texture_sRGB
+const struct gl_texture_format _mesa_texformat_srgb_dxt1 = {
+   MESA_FORMAT_SRGB_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,                                  /* StencilBits */
+   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 */
+   NULL                                        /* StoreTexel */
+};
+#endif
+
 const struct gl_texture_format _mesa_texformat_rgba_dxt1 = {
    MESA_FORMAT_RGBA_DXT1,              /* MesaFormat */
    GL_RGBA,                            /* BaseFormat */
index 6877ef96f21797e1fbeccf5641b65bf7e0e5784f..25e280bc3f32c69b6988b9e92692af4da2ed904b 100644 (file)
@@ -28,6 +28,7 @@
 #include "glheader.h"
 #include "macros.h"
 #include "enums.h"
+#include "shader/program.h"
 #include "shader/prog_parameter.h"
 #include "shader/prog_cache.h"
 #include "shader/prog_instruction.h"
 #include "shader/programopt.h"
 #include "texenvprogram.h"
 
+
+struct texenvprog_cache_item
+{
+   GLuint hash;
+   void *key;
+   struct gl_fragment_program *data;
+   struct texenvprog_cache_item *next;
+};
+
+
 /**
  * This MAX is probably a bit generous, but that's OK.  There can be
  * up to four instructions per texture unit (TEX + 3 for combine),
@@ -59,6 +70,7 @@ struct state_key {
    struct {
       GLuint enabled:1;
       GLuint source_index:3;   /* one of TEXTURE_1D/2D/3D/CUBE/RECT_INDEX */
+      GLuint shadow:1;
       GLuint ScaleShiftRGB:2;
       GLuint ScaleShiftA:2;
 
@@ -201,8 +213,8 @@ static void make_state_key( GLcontext *ctx,  struct state_key *key )
 
    for (i=0;i<MAX_TEXTURE_UNITS;i++) {
       const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
-               
-      if (!texUnit->_ReallyEnabled)
+
+      if (!texUnit->_ReallyEnabled || !texUnit->Enabled)
          continue;
 
       key->unit[i].enabled = 1;
@@ -210,6 +222,7 @@ static void make_state_key( GLcontext *ctx,  struct state_key *key )
 
       key->unit[i].source_index = 
         translate_tex_src_bit(texUnit->_ReallyEnabled);                
+      key->unit[i].shadow = texUnit->_Current->CompareMode == GL_COMPARE_R_TO_TEXTURE;
 
       key->unit[i].NumArgsRGB = texUnit->_CurrentCombine->_NumArgsRGB;
       key->unit[i].NumArgsA = texUnit->_CurrentCombine->_NumArgsA;
@@ -479,7 +492,7 @@ emit_op(struct texenv_fragment_program *p,
 {
    GLuint nr = p->program->Base.NumInstructions++;
    struct prog_instruction *inst = &p->program->Base.Instructions[nr];
-      
+
    assert(nr < MAX_INSTRUCTIONS);
 
    _mesa_init_instructions(inst, 1);
@@ -940,6 +953,10 @@ static void load_texture( struct texenv_fragment_program *p, GLuint unit )
         p->src_texture[unit] = emit_texld( p, OPCODE_TXP,
                                            tmp, WRITEMASK_XYZW, 
                                            unit, dim, texcoord );
+
+        if (p->state->unit[unit].shadow)
+           p->program->Base.ShadowSamplers |= 1 << unit;
+
          p->program->Base.SamplersUsed |= (1 << unit);
          /* This identity mapping should already be in place
           * (see _mesa_init_program_struct()) but let's be safe.
@@ -1173,6 +1190,9 @@ _mesa_get_fixed_func_fragment_program(GLcontext *ctx)
  * If _MaintainTexEnvProgram is set we'll generate a fragment program that
  * implements the current texture env/combine mode.
  * This function generates that program and puts it into effect.
+ *
+ * XXX: remove this function.  currently only called by some drivers,
+ * not by mesa core.  We now handle this properly from inside mesa.
  */
 void
 _mesa_UpdateTexEnvProgram( GLcontext *ctx )
@@ -1184,11 +1204,14 @@ _mesa_UpdateTexEnvProgram( GLcontext *ctx )
    /* If a conventional fragment program/shader isn't in effect... */
    if (!ctx->FragmentProgram._Enabled &&
        (!ctx->Shader.CurrentProgram ||
-        !ctx->Shader.CurrentProgram->FragmentProgram) ) {
+        !ctx->Shader.CurrentProgram->FragmentProgram) ) 
+   {
+      struct gl_fragment_program *newProg;
+
+      newProg = _mesa_get_fixed_func_fragment_program(ctx);
 
-      ctx->FragmentProgram._Current
-         = ctx->FragmentProgram._TexEnvProgram
-         = _mesa_get_fixed_func_fragment_program(ctx);
+      _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, newProg);
+      _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, newProg);
    } 
 
    /* Tell the driver about the change.  Could define a new target for
index 3b6d05612ddebcdba90e52d12e8fa814fd39e5d3..f34b3b8223c8d1354d8ab46cab498e9aa0391afd 100644 (file)
@@ -98,6 +98,7 @@ enum _format {
    MESA_FORMAT_SRGBA8,
    MESA_FORMAT_SL8,
    MESA_FORMAT_SLA8,
+   MESA_FORMAT_SRGB_DXT1,
    /*@}*/
 #endif
 
@@ -173,6 +174,7 @@ extern const struct gl_texture_format _mesa_texformat_srgb8;
 extern const struct gl_texture_format _mesa_texformat_srgba8;
 extern const struct gl_texture_format _mesa_texformat_sl8;
 extern const struct gl_texture_format _mesa_texformat_sla8;
+extern const struct gl_texture_format _mesa_texformat_srgb_dxt1;
 /*@}*/
 #endif
 
index 63939f40111ae3d97d81347ea3ffa92022320430..7499ba7b36ed308b1213a84d288ecc17d270456e 100644 (file)
@@ -1117,6 +1117,7 @@ static void FETCH(ci8)( const struct gl_texture_image *texImage,
          break;;
       default:
          _mesa_problem(ctx, "Bad palette format in fetch_texel_ci8");
+         return;
       }
 #if CHAN_TYPE == GL_UNSIGNED_BYTE
       COPY_4UBV(texel, texelUB);
index 36557f19fd40f47c49b08b076080a77c805d4223..91c41f38c30ef5e7f6cace5c14b5197c565c8106 100644 (file)
@@ -2,7 +2,7 @@
  * Mesa 3-D graphics library
  * Version:  7.1
  *
- * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -2017,7 +2017,7 @@ copytexture_error_check( GLcontext *ctx, GLuint dimensions,
    }
 
    if (is_compressed_format(ctx, internalFormat)) {
-      if (target != GL_TEXTURE_2D) {
+      if (!target_can_be_compressed(ctx, target)) {
          _mesa_error(ctx, GL_INVALID_ENUM,
                      "glCopyTexImage%d(target)", dimensions);
          return GL_TRUE;
@@ -2200,7 +2200,7 @@ copytexsubimage_error_check2( GLcontext *ctx, GLuint dimensions,
    }
 
    if (teximage->IsCompressed) {
-      if (target != GL_TEXTURE_2D) {
+      if (!target_can_be_compressed(ctx, target)) {
          _mesa_error(ctx, GL_INVALID_ENUM,
                      "glCopyTexSubImage%d(target)", dimensions);
          return GL_TRUE;
@@ -2711,8 +2711,8 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat,
       }
       else {
          /* no error, set the tex image parameters */
-         _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
-                                    border, internalFormat);
+         _mesa_init_teximage_fields(ctx, target, texImage, width, height,
+                                    depth, border, internalFormat);
          texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
                                           internalFormat, format, type);
       }
index 20f9c4512c4536404784bac1b267eb76b88e2572..86c54aefc021c3e80fa26793912b11a2fab3608b 100644 (file)
@@ -608,6 +608,24 @@ update_texture_state( GLcontext *ctx )
          _mesa_problem(ctx, "invalid Alpha combine mode in update_texture_state");
         break;
       }
+   }
+
+   /* Determine which texture coordinate sets are actually needed */
+   if (fprog) {
+      const GLuint coordMask = (1 << MAX_TEXTURE_COORD_UNITS) - 1;
+      ctx->Texture._EnabledCoordUnits
+         = (fprog->Base.InputsRead >> FRAG_ATTRIB_TEX0) & coordMask;
+   }
+   else {
+      ctx->Texture._EnabledCoordUnits = ctx->Texture._EnabledUnits;
+   }
+
+   /* Setup texgen for those texture coordinate sets that are in use */
+   for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
+      struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+
+      if (!(ctx->Texture._EnabledCoordUnits & (1 << unit)))
+        continue;
 
       if (texUnit->TexGenEnabled) {
         if (texUnit->TexGenEnabled & S_BIT) {
@@ -630,16 +648,6 @@ update_texture_state( GLcontext *ctx )
       if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY)
         ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(unit);
    }
-
-   /* Determine which texture coordinate sets are actually needed */
-   if (fprog) {
-      const GLuint coordMask = (1 << MAX_TEXTURE_COORD_UNITS) - 1;
-      ctx->Texture._EnabledCoordUnits
-         = (fprog->Base.InputsRead >> FRAG_ATTRIB_TEX0) & coordMask;
-   }
-   else {
-      ctx->Texture._EnabledCoordUnits = ctx->Texture._EnabledUnits;
-   }
 }
 
 
@@ -820,3 +828,27 @@ _mesa_free_texture_data(GLcontext *ctx)
    }
 #endif
 }
+
+
+/**
+ * Update the default texture objects in the given context to reference those
+ * specified in the shared state and release those referencing the old 
+ * shared state.
+ */
+void
+_mesa_update_default_objects_texture(GLcontext *ctx)
+{
+   GLuint i;
+
+   for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
+      struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
+
+      _mesa_reference_texobj(&texUnit->Current1D, ctx->Shared->Default1D);
+      _mesa_reference_texobj(&texUnit->Current2D, ctx->Shared->Default2D);
+      _mesa_reference_texobj(&texUnit->Current3D, ctx->Shared->Default3D);
+      _mesa_reference_texobj(&texUnit->CurrentCubeMap, ctx->Shared->DefaultCubeMap);
+      _mesa_reference_texobj(&texUnit->CurrentRect, ctx->Shared->DefaultRect);
+      _mesa_reference_texobj(&texUnit->Current1DArray, ctx->Shared->Default1DArray);
+      _mesa_reference_texobj(&texUnit->Current2DArray, ctx->Shared->Default2DArray);
+   }
+}
index b5003d5d6ec52edfa55f735a93d9f6aa6196e2b8..a7d7088c621ecc3960b2615176218e3566eb1f72 100644 (file)
@@ -73,6 +73,9 @@ _mesa_init_texture( GLcontext *ctx );
 extern void 
 _mesa_free_texture_data( GLcontext *ctx );
 
+extern void
+_mesa_update_default_objects_texture(GLcontext *ctx);
+
 /*@}*/
 
 #endif
index 0fd6a2daae2f4937efd9a738b029186138e40b0a..57419aa2f3118f4cc39aaac2ab716a3c965e88ec 100644 (file)
@@ -2507,8 +2507,7 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS)
             dstRow += dstRowStride / sizeof(GLuint);
          }
       }
-   }
-   else {
+   } else {
       for (img = 0; img < srcDepth; img++) {
          GLuint *dstRow = (GLuint *) dstAddr
             + dstImageOffsets[dstZoffset + img]
@@ -3802,8 +3801,8 @@ _mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level,
 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)
+                              struct gl_texture_object *texObj,
+                              struct gl_texture_image *texImage)
 {
    GLuint size;
 
index c5813fbeeec657f6736946f95377ce69926a50cc..c9edf14dbc5fe5910c3579c653c8173e858183ba 100644 (file)
@@ -215,8 +215,8 @@ _mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level,
 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);
+                              struct gl_texture_object *texObj,
+                              struct gl_texture_image *texImage);
 
 extern const GLvoid *
 _mesa_validate_pbo_teximage(GLcontext *ctx, GLuint dimensions,
index 9f1fcd9d2627b284747a8d6e299e080df395abbe..9d9b28b5189ad4bbd5b74332e25c7a22ed20cd25 100644 (file)
@@ -499,7 +499,7 @@ void GLAPIENTRY
 _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
                             GLsizei stride, const GLvoid *ptr)
 {
-   const GLboolean normalized = GL_FALSE;
+   GLboolean normalized = GL_FALSE;
    GLsizei elementSize;
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -527,6 +527,7 @@ _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
    /* check for valid 'type' and compute StrideB right away */
    switch (type) {
       case GL_UNSIGNED_BYTE:
+         normalized = GL_TRUE;
          elementSize = size * sizeof(GLubyte);
          break;
       case GL_SHORT:
@@ -865,16 +866,22 @@ _mesa_LockArraysEXT(GLint first, GLsizei count)
    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;
+   if (first < 0) {
+      _mesa_error( ctx, GL_INVALID_VALUE, "glLockArraysEXT(first)" );
+      return;
    }
-   else {
-      ctx->Array.LockFirst = 0;
-      ctx->Array.LockCount = 0;
+   if (count <= 0) {
+      _mesa_error( ctx, GL_INVALID_VALUE, "glLockArraysEXT(count)" );
+      return;
+   }
+   if (ctx->Array.LockCount != 0) {
+      _mesa_error( ctx, GL_INVALID_OPERATION, "glLockArraysEXT(reentry)" );
+      return;
    }
 
+   ctx->Array.LockFirst = first;
+   ctx->Array.LockCount = count;
+
    ctx->NewState |= _NEW_ARRAY;
    ctx->Array.NewState |= _NEW_ARRAY_ALL;
 
@@ -892,6 +899,11 @@ _mesa_UnlockArraysEXT( void )
    if (MESA_VERBOSE & VERBOSE_API)
       _mesa_debug(ctx, "glUnlockArrays\n");
 
+   if (ctx->Array.LockCount == 0) {
+      _mesa_error( ctx, GL_INVALID_OPERATION, "glUnlockArraysEXT(reexit)" );
+      return;
+   }
+
    ctx->Array.LockFirst = 0;
    ctx->Array.LockCount = 0;
    ctx->NewState |= _NEW_ARRAY;
index f557940738e33ba8760f272e29c8854ca3f5271f..97d5c8219d0e765df69751321a606d3a3c498afd 100644 (file)
@@ -150,6 +150,11 @@ _mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count,
                                GLenum type, const GLvoid * const * indices,
                                GLsizei primcount, GLint modestride );
 
+extern void GLAPIENTRY
+_mesa_LockArraysEXT(GLint first, GLsizei count);
+
+extern void GLAPIENTRY
+_mesa_UnlockArraysEXT( void );
 
 
 extern void GLAPIENTRY
index 9229077f42cdf815ef9e3bb19da5f348c04a21af..81034a35d1e596f17f3d4c4e580aa5cb954be85e 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  7.1
+ * Version:  7.3
  *
- * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -29,9 +29,9 @@
 
 /* Mesa version */
 #define MESA_MAJOR 7
-#define MESA_MINOR 1
+#define MESA_MINOR 3
 #define MESA_PATCH 0
-#define MESA_VERSION_STRING "7.1"
+#define MESA_VERSION_STRING "7.3-devel"
 
 /* To make version comparison easy */
 #define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
diff --git a/src/mesa/math/descrip.mms b/src/mesa/math/descrip.mms
new file mode 100644 (file)
index 0000000..3aaa6eb
--- /dev/null
@@ -0,0 +1,47 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen  joukj@hrem.nano.tudelft.nl
+# Last revision : 3 October 2007
+
+.first
+       define gl [---.include.gl]
+       define math [-.math]
+       define glapi [-.glapi]
+       define main [-.main]
+
+.include [---]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [---.include],[-.main],[-.glapi]
+LIBDIR = [---.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)/float=ieee/ieee=denorm
+
+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
index 776c26475e7d58c294eb30e1129e679b01365402..7abe6f2565a097dea159b9f8f6991aeefdd86252 100644 (file)
@@ -185,7 +185,7 @@ extern char *mesa_profile;
 
 #endif
 
-#elif defined(__amd64__)
+#elif defined(__x86_64__)
 
 #define rdtscll(val) do { \
      unsigned int a,d; \
diff --git a/src/mesa/math/sources b/src/mesa/math/sources
deleted file mode 100644 (file)
index 7c7dccc..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-MESA_MATH_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
-
-MESA_MATH_HEADERS = \
-m_clip_tmp.h \
-m_copy_tmp.h \
-m_debug.h \
-m_debug_util.h \
-m_dotprod_tmp.h \
-m_eval.h \
-m_matrix.h \
-m_norm_tmp.h \
-m_trans_tmp.h \
-m_translate.h \
-m_vector.h \
-m_xform.h \
-m_xform_tmp.h \
-mathmod.h
diff --git a/src/mesa/shader/descrip.mms b/src/mesa/shader/descrip.mms
new file mode 100644 (file)
index 0000000..bdac946
--- /dev/null
@@ -0,0 +1,93 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen  joukj@hrem.nano.tudelft.nl
+# Last revision : 27 May 2008
+.first
+       define gl [---.include.gl]
+       define math [-.math]
+       define swrast [-.swrast]
+       define array_cache [-.array_cache]
+       define glapi [-.glapi]
+       define main [-.main]
+       define shader [-.shader]
+
+.include [---]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [---.include],[.grammar],[-.main],[-.glapi],[.slang]
+LIBDIR = [---.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1,"__extension__=")/name=(as_is,short)/float=ieee/ieee=denorm
+
+SOURCES = \
+       atifragshader.c \
+       arbprogparse.c \
+       arbprogram.c \
+       nvfragparse.c \
+       nvprogram.c \
+       nvvertparse.c \
+       program.c \
+       programopt.c \
+       prog_debug.c \
+       prog_execute.c \
+       prog_instruction.c \
+       prog_parameter.c \
+       prog_print.c \
+       prog_statevars.c \
+       shader_api.c prog_uniform.c
+
+OBJECTS = \
+       atifragshader.obj,\
+       arbprogparse.obj,\
+       arbprogram.obj,\
+       nvfragparse.obj,\
+       nvprogram.obj,\
+       nvvertparse.obj,\
+       program.obj,\
+       programopt.obj,\
+       prog_debug.obj,\
+       prog_execute.obj,\
+       prog_instruction.obj,\
+       prog_parameter.obj,\
+       prog_print.obj,\
+       prog_statevars.obj,\
+       shader_api.obj,prog_uniform.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
+arbprogparse.obj : arbprogparse.c
+arbprogram.obj : arbprogram.c
+nvfragparse.obj : nvfragparse.c
+nvprogram.obj : nvprogram.c
+nvvertparse.obj : nvvertparse.c
+program.obj : program.c
+programopt. obj : programopt.c
+prog_debug.obj : prog_debug.c
+prog_execute.obj : prog_execute.c
+prog_instruction.obj : prog_instruction.c
+prog_parameter.obj : prog_parameter.c
+prog_print.obj : prog_print.c
+prog_statevars.obj : prog_statevars.c
+shader_api.obj : shader_api.c
+prog_uniform.obj : prog_uniform.c
diff --git a/src/mesa/shader/grammar/sources b/src/mesa/shader/grammar/sources
deleted file mode 100644 (file)
index a6bbfd3..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-MESA_SHADER_GRAMMAR_SOURCES = \
-grammar_mesa.c
-
-MESA_SHADER_GRAMMAR_HEADERS = \
-grammar.c \
-grammar.h \
-grammar_mesa.h \
-grammar_syn.h
index 5afd9eb1534914c3e880a704c0d9ceb93c413fd4..32b6ff4fd4205d8f7161fd1c17cb178b419dbc7b 100644 (file)
@@ -90,7 +90,8 @@ get_register_pointer(const struct prog_src_register *source,
          const struct gl_program_parameter_list *params;
          ASSERT(source->File == PROGRAM_LOCAL_PARAM ||
                 source->File == PROGRAM_CONSTANT ||
-                source->File == PROGRAM_STATE_VAR);
+                source->File == PROGRAM_STATE_VAR ||
+                source->File == PROGRAM_UNIFORM);
          params = machine->CurProgram->Parameters;
          if (reg < 0 || reg >= (GLint)params->NumParameters)
             return ZeroVec;
index 8acf37c3c08d914b2edc458e694c8dfe290af7a7..d4e31207e8409d7e41172e42f4511f5ec294691e 100644 (file)
@@ -131,7 +131,7 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[],
               ADD_3V(value, p, eye_z);
               NORMALIZE_3FV(value);
               value[3] = 1.0;
-            }                                            
+            }
             return;
          default:
             _mesa_problem(ctx, "Invalid light state in fetch_state");
@@ -235,11 +235,11 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[],
          }
       }
    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);
@@ -369,7 +369,7 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[],
          }
       }
       return;
-               
+
    case STATE_VERTEX_PROGRAM:
       {
          /* state[1] = {STATE_ENV, STATE_LOCAL} */
@@ -469,7 +469,6 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[],
       }                                                  
 
 
-
       case STATE_PT_SCALE:
          value[0] = ctx->Pixel.RedScale;
          value[1] = ctx->Pixel.GreenScale;
@@ -488,6 +487,20 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[],
       case STATE_PCM_BIAS:
          COPY_4V(value, ctx->Pixel.PostColorMatrixBias);
          break;
+      case STATE_SHADOW_AMBIENT:
+         {
+            const int unit = (int) state[2];
+            const struct gl_texture_object *texObj
+               = ctx->Texture.Unit[unit]._Current;
+            if (texObj) {
+               value[0] = texObj->ShadowAmbient;
+               value[1] = texObj->ShadowAmbient;
+               value[2] = texObj->ShadowAmbient;
+               value[3] = texObj->ShadowAmbient;
+            }
+         }
+         return;
+
       default:
          /* unknown state indexes are silently ignored
           *  should be handled by the driver.
@@ -562,6 +575,7 @@ _mesa_program_state_flags(const gl_state_index state[STATE_LENGTH])
    case STATE_INTERNAL:
       switch (state[1]) {
       case STATE_TEXRECT_SCALE:
+      case STATE_SHADOW_AMBIENT:
         return _NEW_TEXTURE;
       case STATE_FOG_PARAMS_OPTIMIZED:
         return _NEW_FOG;
@@ -740,6 +754,9 @@ append_token(char *dst, gl_state_index k)
    case STATE_PCM_BIAS:
       append(dst, "PCMbias");
       break;
+   case STATE_SHADOW_AMBIENT:
+      append(dst, "ShadowAmbient");
+      break;
    default:
       ;
    }
@@ -890,10 +907,101 @@ _mesa_load_state_parameters(GLcontext *ctx,
 
    for (i = 0; i < paramList->NumParameters; i++) {
       if (paramList->Parameters[i].Type == PROGRAM_STATE_VAR) {
-         _mesa_fetch_state(ctx, 
+         _mesa_fetch_state(ctx,
                           (gl_state_index *) paramList->Parameters[i].StateIndexes,
                            paramList->ParameterValues[i]);
       }
    }
 }
 
+
+/**
+ * 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 current vertex program's parameter registers with tracked
+ * matrices (if NV program).  This only needs to be done per
+ * glBegin/glEnd, not per-vertex.
+ */
+void
+_mesa_load_tracked_matrices(GLcontext *ctx)
+{
+   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 values into sequential registers */
+      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);
+      }
+   }
+}
index 7b490e3d630e7773eaec7e3915ee80d6bf1aa2d1..20643ca7947a74dd1b8f3e75b181ecec7c270846 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.2
+ * Version:  7.1
  *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -77,7 +77,7 @@ typedef enum gl_state_index_ {
    STATE_SPECULAR,
    STATE_EMISSION,
    STATE_SHININESS,
-   STATE_HALF_VECTOR,  
+   STATE_HALF_VECTOR,
 
    STATE_POSITION,
    STATE_ATTENUATION,
@@ -94,7 +94,7 @@ typedef enum gl_state_index_ {
    STATE_TEXGEN_OBJECT_Q,
 
    STATE_TEXENV_COLOR,
-       
+
    STATE_DEPTH_RANGE,
 
    STATE_VERTEX_PROGRAM,
@@ -115,6 +115,7 @@ typedef enum gl_state_index_ {
    STATE_PT_BIAS,               /**< Pixel transfer RGBA bias */
    STATE_PCM_SCALE,             /**< Post color matrix RGBA scale */
    STATE_PCM_BIAS,              /**< Post color matrix RGBA bias */
+   STATE_SHADOW_AMBIENT,        /**< ARB_shadow_ambient fail value; token[2] is texture unit index */
    STATE_INTERNAL_DRIVER       /* first available state index for drivers (must be last) */
 } gl_state_index;
 
@@ -133,4 +134,8 @@ extern char *
 _mesa_program_state_string(const gl_state_index state[STATE_LENGTH]);
 
 
+extern void
+_mesa_load_tracked_matrices(GLcontext *ctx);
+
+
 #endif /* PROG_STATEVARS_H */
index f57df3d86dcb3b129647f7c02c8dec9c029bf6ce..25d7c0997bcf8fda8b8a3972b1e952510a92ab68 100644 (file)
@@ -134,8 +134,8 @@ _mesa_longest_uniform_name(const struct gl_uniform_list *list)
    GLint max = 0;
    GLuint i;
    for (i = 0; list && i < list->NumUniforms; i++) {
-      GLuint len = _mesa_strlen(list->Uniforms[i].Name);
-      if (len > (GLuint)max)
+      GLint len = (GLint)_mesa_strlen(list->Uniforms[i].Name);
+      if (len > max)
          max = len;
    }
    return max;
index b03dd24d112942a1aaec7233943aad2c239fe3dc..6263fd277f8a2ea1e86ad3d06c14acf79f78fefe 100644 (file)
@@ -120,6 +120,43 @@ _mesa_free_program_data(GLcontext *ctx)
 }
 
 
+/**
+ * Update the default program objects in the given context to reference those
+ * specified in the shared state and release those referencing the old
+ * shared state.
+ */
+void
+_mesa_update_default_objects_program(GLcontext *ctx)
+{
+#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
+   _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current,
+                            (struct gl_vertex_program *)
+                            ctx->Shared->DefaultVertexProgram);
+   assert(ctx->VertexProgram.Current);
+#endif
+
+#if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program
+   _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current,
+                            (struct gl_fragment_program *)
+                            ctx->Shared->DefaultFragmentProgram);
+   assert(ctx->FragmentProgram.Current);
+#endif
+
+   /* XXX probably move this stuff */
+#if FEATURE_ATI_fragment_shader
+   if (ctx->ATIFragmentShader.Current) {
+      ctx->ATIFragmentShader.Current->RefCount--;
+      if (ctx->ATIFragmentShader.Current->RefCount <= 0) {
+         _mesa_free(ctx->ATIFragmentShader.Current);
+      }
+   }
+   ctx->ATIFragmentShader.Current = (struct ati_fragment_shader *) ctx->Shared->DefaultFragmentShader;
+   assert(ctx->ATIFragmentShader.Current);
+   ctx->ATIFragmentShader.Current->RefCount++;
+#endif
+}
+
+
 /**
  * Set the vertex/fragment program error state (position and error string).
  * This is generally called from within the parsers.
@@ -211,7 +248,7 @@ struct gl_program *
 _mesa_init_fragment_program( GLcontext *ctx, struct gl_fragment_program *prog,
                              GLenum target, GLuint id)
 {
-   if (prog) 
+   if (prog)
       return _mesa_init_program_struct( ctx, &prog->Base, target, id );
    else
       return NULL;
@@ -225,7 +262,7 @@ struct gl_program *
 _mesa_init_vertex_program( GLcontext *ctx, struct gl_vertex_program *prog,
                            GLenum target, GLuint id)
 {
-   if (prog) 
+   if (prog)
       return _mesa_init_program_struct( ctx, &prog->Base, target, id );
    else
       return NULL;
@@ -238,7 +275,7 @@ _mesa_init_vertex_program( GLcontext *ctx, struct gl_vertex_program *prog,
  * 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
@@ -247,19 +284,23 @@ _mesa_init_vertex_program( GLcontext *ctx, struct gl_vertex_program *prog,
 struct gl_program *
 _mesa_new_program(GLcontext *ctx, GLenum target, GLuint id)
 {
+   struct gl_program *prog;
    switch (target) {
    case GL_VERTEX_PROGRAM_ARB: /* == GL_VERTEX_PROGRAM_NV */
-      return _mesa_init_vertex_program(ctx, CALLOC_STRUCT(gl_vertex_program),
+      prog = _mesa_init_vertex_program(ctx, CALLOC_STRUCT(gl_vertex_program),
                                        target, id );
+      break;
    case GL_FRAGMENT_PROGRAM_NV:
    case GL_FRAGMENT_PROGRAM_ARB:
-      return _mesa_init_fragment_program(ctx,
+      prog =_mesa_init_fragment_program(ctx,
                                          CALLOC_STRUCT(gl_fragment_program),
                                          target, id );
+      break;
    default:
       _mesa_problem(ctx, "bad target in _mesa_new_program");
-      return NULL;
+      prog = NULL;
    }
+   return prog;
 }
 
 
@@ -278,7 +319,7 @@ _mesa_delete_program(GLcontext *ctx, struct gl_program *prog)
 
    if (prog == &_mesa_DummyProgram)
       return;
-                 
+
    if (prog->String)
       _mesa_free(prog->String);
 
@@ -341,15 +382,17 @@ _mesa_reference_program(GLcontext *ctx,
 
       /*_glthread_LOCK_MUTEX((*ptr)->Mutex);*/
 #if 0
-      printf("Program %p %u 0x%x  Refcount-- to %d\n",
-             *ptr, (*ptr)->Id, (*ptr)->Target, (*ptr)->RefCount - 1);
+      printf("Program %p ID=%u Target=%s  Refcount-- to %d\n",
+             *ptr, (*ptr)->Id,
+             ((*ptr)->Target == GL_VERTEX_PROGRAM_ARB ? "VP" : "FP"),
+             (*ptr)->RefCount - 1);
 #endif
       ASSERT((*ptr)->RefCount > 0);
       (*ptr)->RefCount--;
 
       deleteFlag = ((*ptr)->RefCount == 0);
       /*_glthread_UNLOCK_MUTEX((*ptr)->Mutex);*/
-      
+
       if (deleteFlag) {
          ASSERT(ctx);
          ctx->Driver.DeleteProgram(ctx, *ptr);
@@ -363,8 +406,10 @@ _mesa_reference_program(GLcontext *ctx,
       /*_glthread_LOCK_MUTEX(prog->Mutex);*/
       prog->RefCount++;
 #if 0
-      printf("Program %p %u 0x%x  Refcount++ to %d\n",
-             prog, prog->Id, prog->Target, prog->RefCount);
+      printf("Program %p ID=%u Target=%s  Refcount++ to %d\n",
+             prog, prog->Id,
+             (prog->Target == GL_VERTEX_PROGRAM_ARB ? "VP" : "FP"),
+             prog->RefCount);
 #endif
       /*_glthread_UNLOCK_MUTEX(prog->Mutex);*/
    }
@@ -402,6 +447,7 @@ _mesa_clone_program(GLcontext *ctx, const struct gl_program *prog)
    clone->InputsRead = prog->InputsRead;
    clone->OutputsWritten = prog->OutputsWritten;
    clone->SamplersUsed = prog->SamplersUsed;
+   clone->ShadowSamplers = prog->ShadowSamplers;
    memcpy(clone->TexturesUsed, prog->TexturesUsed, sizeof(prog->TexturesUsed));
 
    if (prog->Parameters)
@@ -471,7 +517,7 @@ _mesa_insert_instructions(struct gl_program *prog, GLuint start, GLuint count)
    for (i = 0; i < prog->NumInstructions; i++) {
       struct prog_instruction *inst = prog->Instructions + i;
       if (inst->BranchTarget > 0) {
-         if ((GLuint)inst->BranchTarget >= start) {
+         if (inst->BranchTarget >= start) {
             inst->BranchTarget += count;
          }
       }
@@ -504,6 +550,52 @@ _mesa_insert_instructions(struct gl_program *prog, GLuint start, GLuint count)
    return GL_TRUE;
 }
 
+/**
+ * Delete 'count' instructions at 'start' in the given program.
+ * Adjust branch targets accordingly.
+ */
+GLboolean
+_mesa_delete_instructions(struct gl_program *prog, GLuint start, GLuint count)
+{
+   const GLuint origLen = prog->NumInstructions;
+   const GLuint newLen = origLen - count;
+   struct prog_instruction *newInst;
+   GLuint i;
+
+   /* adjust branches */
+   for (i = 0; i < prog->NumInstructions; i++) {
+      struct prog_instruction *inst = prog->Instructions + i;
+      if (inst->BranchTarget > 0) {
+         if (inst->BranchTarget >= start) {
+            inst->BranchTarget -= count;
+         }
+      }
+   }
+
+   /* Alloc storage for new instructions */
+   newInst = _mesa_alloc_instructions(newLen);
+   if (!newInst) {
+      return GL_FALSE;
+   }
+
+   /* Copy 'start' instructions into new instruction buffer */
+   _mesa_copy_instructions(newInst, prog->Instructions, start);
+
+   /* Copy the remaining/tail instructions to new inst buffer */
+   _mesa_copy_instructions(newInst + start,
+                           prog->Instructions + start + count,
+                           newLen - start);
+
+   /* free old instructions */
+   _mesa_free_instructions(prog->Instructions, origLen);
+
+   /* install new instructions */
+   prog->Instructions = newInst;
+   prog->NumInstructions = newLen;
+
+   return GL_TRUE;
+}
+
 
 /**
  * Search instructions for registers that match (oldFile, oldIndex),
index f8bd63233ed73898c2987635dcd214d8dfba3da3..48176162c35fb62e7061cb52721032797d323ca6 100644 (file)
@@ -52,6 +52,9 @@ _mesa_init_program(GLcontext *ctx);
 extern void
 _mesa_free_program_data(GLcontext *ctx);
 
+extern void
+_mesa_update_default_objects_program(GLcontext *ctx);
+
 extern void
 _mesa_set_program_error(GLcontext *ctx, GLint pos, const char *string);
 
@@ -60,13 +63,13 @@ _mesa_find_line_column(const GLubyte *string, const GLubyte *pos,
                        GLint *line, GLint *col);
 
 
-extern struct gl_program * 
-_mesa_init_vertex_program(GLcontext *ctx, 
-                          struct gl_vertex_program *prog, 
+extern struct gl_program *
+_mesa_init_vertex_program(GLcontext *ctx,
+                          struct gl_vertex_program *prog,
                           GLenum target, GLuint id);
 
-extern struct gl_program * 
-_mesa_init_fragment_program(GLcontext *ctx, 
+extern struct gl_program *
+_mesa_init_fragment_program(GLcontext *ctx,
                             struct gl_fragment_program *prog,
                             GLenum target, GLuint id);
 
@@ -108,6 +111,9 @@ _mesa_clone_program(GLcontext *ctx, const struct gl_program *prog);
 extern  GLboolean
 _mesa_insert_instructions(struct gl_program *prog, GLuint start, GLuint count);
 
+extern  GLboolean
+_mesa_delete_instructions(struct gl_program *prog, GLuint start, GLuint count);
+
 extern struct gl_program *
 _mesa_combine_programs(GLcontext *ctx,
                        const struct gl_program *progA,
diff --git a/src/mesa/shader/slang/descrip.mms b/src/mesa/shader/slang/descrip.mms
new file mode 100644 (file)
index 0000000..6eefbcf
--- /dev/null
@@ -0,0 +1,68 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen  joukj@hrem.nano.tudelft.nl
+# Last revision : 3 October 2007
+
+.first
+       define gl [----.include.gl]
+       define math [--.math]
+       define swrast [--.swrast]
+       define array_cache [--.array_cache]
+       define main [--.main]
+       define glapi [--.glapi]
+       define shader [--.shader]
+
+.include [----]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [----.include],[--.main],[--.glapi],[-.slang],[-.grammar],[-]
+LIBDIR = [----.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)/float=ieee/ieee=denorm
+
+SOURCES = \
+       slang_compile.c,slang_preprocess.c
+
+OBJECTS = slang_builtin.obj,slang_codegen.obj,slang_compile.obj,\
+       slang_compile_function.obj,slang_compile_operation.obj,\
+       slang_compile_struct.obj,slang_compile_variable.obj,slang_emit.obj,\
+       slang_ir.obj,slang_label.obj,slang_library_noise.obj,slang_link.obj,\
+       slang_log.obj,slang_mem.obj,slang_preprocess.obj,slang_print.obj,\
+       slang_simplify.obj,slang_storage.obj,slang_typeinfo.obj,\
+       slang_utility.obj,slang_vartable.obj
+
+##### RULES #####
+
+VERSION=Mesa V3.4
+
+##### TARGETS #####
+# Make the library
+$(LIBDIR)$(GL_LIB) : $(OBJECTS)
+  @ library $(LIBDIR)$(GL_LIB) $(OBJECTS)
+
+clean :
+       purge
+       delete *.obj;*
+
+slang_builtin.obj : slang_builtin.c
+slang_codegen.obj : slang_codegen.c
+slang_compile.obj : slang_compile.c
+slang_compile_function.obj : slang_compile_function.c
+slang_compile_operation.obj : slang_compile_operation.c
+slang_compile_struct.obj : slang_compile_struct.c
+slang_compile_variable.obj : slang_compile_variable.c
+slang_emit.obj : slang_emit.c
+slang_ir.obj : slang_ir.c
+slang_label.obj : slang_label.c
+slang_library_noise.obj : slang_library_noise.c
+slang_link.obj : slang_link.c
+slang_log.obj : slang_log.c
+slang_mem.obj : slang_mem.c
+slang_preprocess.obj : slang_preprocess.c
+slang_print.obj : slang_print.c
+slang_simplify.obj : slang_simplify.c
+slang_storage.obj : slang_storage.c
+slang_typeinfo.obj : slang_typeinfo.c
+slang_utility.obj : slang_utility.c
+slang_vartable.obj : slang_vartable.c
old mode 100755 (executable)
new mode 100644 (file)
index dd7d5be6d8b0393eaf648f336dfb1d272f91ec01..d884be2a75df805fe23d39484409f57e5f737065 100644 (file)
@@ -418,7 +418,6 @@ _slang_update_inputs_outputs(struct gl_program *prog)
          maxAddrReg = MAX2(maxAddrReg, inst->DstReg.Index + 1);
       }
    }
-
    prog->NumAddressRegs = maxAddrReg;
 }
 
diff --git a/src/mesa/shader/slang/sources b/src/mesa/shader/slang/sources
deleted file mode 100644 (file)
index 00d617f..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-MESA_SHADER_SLANG_SOURCES = \
-slang_analyse.c \
-slang_assemble_assignment.c \
-slang_assemble.c \
-slang_assemble_conditional.c \
-slang_assemble_constructor.c \
-slang_assemble_typeinfo.c \
-slang_compile.c \
-slang_compile_function.c \
-slang_compile_operation.c \
-slang_compile_struct.c \
-slang_compile_variable.c \
-slang_execute.c \
-slang_execute_x86.c \
-slang_export.c \
-slang_library_texsample.c \
-slang_library_noise.c \
-slang_link.c \
-slang_preprocess.c \
-slang_storage.c \
-slang_utility.c
-
-MESA_SHADER_SLANG_HEADERS = \
-slang_analyse.h \
-slang_assemble.h \
-slang_assemble_assignment.h \
-slang_assemble_conditional.h \
-slang_assemble_constructor.h \
-slang_assemble_typeinfo.h \
-slang_compile.h \
-slang_compile_function.h \
-slang_compile_operation.h \
-slang_compile_struct.h \
-slang_compile_variable.h \
-slang_execute.h \
-slang_export.h \
-slang_library_noise.h \
-slang_library_texsample.h \
-slang_link.h \
-slang_mesa.h \
-slang_preprocess.h \
-slang_storage.h \
-slang_utility.h \
-traverse_wrap.h
diff --git a/src/mesa/shader/sources b/src/mesa/shader/sources
deleted file mode 100644 (file)
index 2787187..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-# List of source files in this directory used for X.org xserver build
-MESA_SHADER_SOURCES = \
-arbprogparse.c \
-arbprogram.c \
-atifragshader.c \
-nvfragparse.c \
-nvprogram.c \
-nvvertexec.c \
-nvvertparse.c \
-program.c \
-programopt.c \
-shaderobjects.c \
-shaderobjects_3dlabs.c
-
-MESA_SHADER_HEADERS = \
-arbprogparse.h \
-arbprogram.h \
-arbprogram_syn.h \
-atifragshader.h \
-nvfragparse.h \
-nvprogram.h \
-nvvertexec.h \
-nvvertparse.h \
-programopt.h \
-program.h \
-program_instruction.h \
-shaderobjects.h \
-shaderobjects_3dlabs.h
diff --git a/src/mesa/sources b/src/mesa/sources
new file mode 100644 (file)
index 0000000..d006191
--- /dev/null
@@ -0,0 +1,299 @@
+### Lists of source files, included by Makefiles
+
+MAIN_SOURCES = \
+       main/api_arrayelt.c \
+       main/api_exec.c \
+       main/api_loopback.c \
+       main/api_noop.c \
+       main/api_validate.c \
+       main/accum.c \
+       main/attrib.c \
+       main/arrayobj.c \
+       main/blend.c \
+       main/bufferobj.c \
+       main/buffers.c \
+       main/clear.c \
+       main/clip.c \
+       main/colortab.c \
+       main/context.c \
+       main/convolve.c \
+       main/debug.c \
+       main/depth.c \
+       main/depthstencil.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/ffvertex_prog.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/mipmap.c \
+       main/mm.c \
+       main/multisample.c \
+       main/pixel.c \
+       main/pixelstore.c \
+       main/points.c \
+       main/polygon.c \
+       main/queryobj.c \
+       main/rastpos.c \
+       main/rbadaptors.c \
+       main/readpix.c \
+       main/renderbuffer.c \
+       main/scissor.c \
+       main/shaders.c \
+       main/state.c \
+       main/stencil.c \
+       main/texcompress.c \
+       main/texcompress_s3tc.c \
+       main/texcompress_fxt1.c \
+       main/texenv.c \
+       main/texenvprogram.c \
+       main/texformat.c \
+       main/texgen.c \
+       main/teximage.c \
+       main/texobj.c \
+       main/texparam.c \
+       main/texrender.c \
+       main/texstate.c \
+       main/texstore.c \
+       main/varray.c \
+       main/vtxfmt.c
+
+GLAPI_SOURCES = \
+       main/dispatch.c \
+       glapi/glapi.c \
+       glapi/glapi_getproc.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
+
+SWRAST_SOURCES = \
+       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_blit.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_fragprog.c \
+       swrast/s_imaging.c \
+       swrast/s_lines.c \
+       swrast/s_logic.c \
+       swrast/s_masking.c \
+       swrast/s_points.c \
+       swrast/s_readpix.c \
+       swrast/s_span.c \
+       swrast/s_stencil.c \
+       swrast/s_texcombine.c \
+       swrast/s_texfilter.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_context.c \
+       tnl/t_pipeline.c \
+       tnl/t_draw.c \
+       tnl/t_rasterpos.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 
+
+VBO_SOURCES = \
+       vbo/vbo_context.c \
+       vbo/vbo_exec.c \
+       vbo/vbo_exec_api.c \
+       vbo/vbo_exec_array.c \
+       vbo/vbo_exec_draw.c \
+       vbo/vbo_exec_eval.c \
+       vbo/vbo_rebase.c \
+       vbo/vbo_split.c \
+       vbo/vbo_split_copy.c \
+       vbo/vbo_split_inplace.c \
+       vbo/vbo_save.c \
+       vbo/vbo_save_api.c \
+       vbo/vbo_save_draw.c \
+       vbo/vbo_save_loopback.c 
+
+
+SHADER_SOURCES = \
+       shader/arbprogparse.c \
+       shader/arbprogram.c \
+       shader/atifragshader.c \
+       shader/grammar/grammar_mesa.c \
+       shader/nvfragparse.c \
+       shader/nvprogram.c \
+       shader/nvvertparse.c \
+       shader/program.c \
+       shader/prog_cache.c \
+       shader/prog_debug.c \
+       shader/prog_execute.c \
+       shader/prog_instruction.c \
+       shader/prog_parameter.c \
+       shader/prog_print.c \
+       shader/prog_statevars.c \
+       shader/prog_uniform.c \
+       shader/programopt.c \
+       shader/shader_api.c \
+
+SLANG_SOURCES =        \
+       shader/slang/slang_builtin.c    \
+       shader/slang/slang_codegen.c    \
+       shader/slang/slang_compile.c    \
+       shader/slang/slang_compile_function.c   \
+       shader/slang/slang_compile_operation.c  \
+       shader/slang/slang_compile_struct.c     \
+       shader/slang/slang_compile_variable.c   \
+       shader/slang/slang_emit.c       \
+       shader/slang/slang_ir.c \
+       shader/slang/slang_label.c      \
+       shader/slang/slang_library_noise.c      \
+       shader/slang/slang_link.c       \
+       shader/slang/slang_log.c        \
+       shader/slang/slang_mem.c        \
+       shader/slang/slang_preprocess.c \
+       shader/slang/slang_print.c      \
+       shader/slang/slang_simplify.c   \
+       shader/slang/slang_storage.c    \
+       shader/slang/slang_typeinfo.c   \
+       shader/slang/slang_vartable.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
+
+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
+
+
+
+### All the core C sources
+
+MESA_SOURCES = \
+       $(MAIN_SOURCES)         \
+       $(MATH_SOURCES)         \
+       $(VBO_SOURCES)          \
+       $(TNL_SOURCES)          \
+       $(SHADER_SOURCES)       \
+       $(SWRAST_SOURCES)       \
+       $(SWRAST_SETUP_SOURCES) \
+       $(COMMON_DRIVER_SOURCES) \
+       $(ASM_C_SOURCES)        \
+       $(SLANG_SOURCES)
+
+ALL_SOURCES = \
+       $(MESA_SOURCES)         \
+       $(GLAPI_SOURCES)        \
+       $(MESA_ASM_SOURCES)             \
+       $(COMMON_DRIVER_SOURCES)
+
+
+### Object files
+
+MESA_OBJECTS = \
+       $(MESA_SOURCES:.c=.o) \
+       $(MESA_ASM_SOURCES:.S=.o)
+
+GLAPI_OBJECTS = \
+       $(GLAPI_SOURCES:.c=.o) \
+       $(GLAPI_ASM_SOURCES:.S=.o)
+
+
+COMMON_DRIVER_OBJECTS = $(COMMON_DRIVER_SOURCES:.c=.o)
+
+
+
+### Include directories
+
+INCLUDE_DIRS = \
+       -I$(TOP)/include \
+       -I$(TOP)/src/mesa
index 80df3b0506d5d2269878b4279d0517769aaa6c9a..d07fd2517a7804ef17ba7ee590a3c5b76e74d35b 100644 (file)
@@ -95,7 +95,7 @@ update_framebuffer_state( struct st_context *st )
    struct pipe_framebuffer_state *framebuffer = &st->state.framebuffer;
    struct gl_framebuffer *fb = st->ctx->DrawBuffer;
    struct st_renderbuffer *strb;
-   GLuint i, j;
+   GLuint i;
 
    memset(framebuffer, 0, sizeof(*framebuffer));
 
@@ -108,20 +108,18 @@ update_framebuffer_state( struct st_context *st )
     * to determine which surfaces to draw to
     */
    framebuffer->num_cbufs = 0;
-   for (j = 0; j < MAX_DRAW_BUFFERS; j++) {
-      for (i = 0; i < fb->_NumColorDrawBuffers[j]; i++) {
-         strb = st_renderbuffer(fb->_ColorDrawBuffers[j][i]);
-
-         /*printf("--------- framebuffer surface rtt %p\n", strb->rtt);*/
-         if (strb->rtt) {
-            /* rendering to a GL texture, may have to update surface */
-            update_renderbuffer_surface(st, strb);
-         }
+   for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
+      strb = st_renderbuffer(fb->_ColorDrawBuffers[i]);
 
-         assert(strb->surface);
-         framebuffer->cbufs[framebuffer->num_cbufs] = strb->surface;
-         framebuffer->num_cbufs++;
+      /*printf("--------- framebuffer surface rtt %p\n", strb->rtt);*/
+      if (strb->rtt) {
+         /* rendering to a GL texture, may have to update surface */
+         update_renderbuffer_surface(st, strb);
       }
+      
+      assert(strb->surface);
+      framebuffer->cbufs[framebuffer->num_cbufs] = strb->surface;
+      framebuffer->num_cbufs++;
    }
 
    strb = st_renderbuffer(fb->Attachment[BUFFER_DEPTH].Renderbuffer);
@@ -146,6 +144,7 @@ update_framebuffer_state( struct st_context *st )
 
    cso_set_framebuffer(st->cso_context, framebuffer);
 
+#if 0
    if (fb->_ColorDrawBufferMask[0] & BUFFER_BIT_FRONT_LEFT) {
       if (st->frontbuffer_status == FRONT_STATUS_COPY_OF_BACK) {
          /* XXX copy back buf to front? */
@@ -153,6 +152,12 @@ update_framebuffer_state( struct st_context *st )
       /* we're assuming we'll really draw to the front buffer */
       st->frontbuffer_status = FRONT_STATUS_DIRTY;
    }
+#else
+#if !defined(PIPE_OS_WINDOWS)
+#warning "fix me"
+#endif
+   st->frontbuffer_status = FRONT_STATUS_DIRTY;
+#endif
 }
 
 
index 327bafeb986ed113015c19abdc9356d7e0e07dfd..285262347205b0cb59dd6cf5ca435e2dce030b6b 100644 (file)
@@ -79,7 +79,7 @@ st_BlitFramebuffer(GLcontext *ctx,
       struct st_renderbuffer *srcRb = 
          st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
       struct st_renderbuffer *dstRb = 
-         st_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]);
+         st_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]);
       struct pipe_surface *srcSurf = srcRb->surface;
       struct pipe_surface *dstSurf = dstRb->surface;
 
index 066124f8f30a5fd9e4b729d05ddf58b6f0d34b59..09545aa8fb870c53170a2e9b9106ab076eee76de 100644 (file)
@@ -40,7 +40,7 @@
 #include "st_context.h"
 #include "st_cb_strings.h"
 
-#define ST_VERSION_STRING "0.1"
+#define ST_VERSION_STRING "0.2"
 
 static const GLubyte *
 st_get_string(GLcontext * ctx, GLenum name)
diff --git a/src/mesa/swrast/descrip.mms b/src/mesa/swrast/descrip.mms
new file mode 100644 (file)
index 0000000..0b23deb
--- /dev/null
@@ -0,0 +1,82 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen  joukj@hrem.nano.tudelft.nl
+# Last revision : 3 October 2007
+
+.first
+       define gl [---.include.gl]
+       define math [-.math]
+       define swrast [-.swrast]
+       define array_cache [-.array_cache]
+       define glapi [-.glapi]
+       define main [-.main]
+       define shader [-.shader]
+
+.include [---]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [---.include],[-.main],[-.glapi],[-.shader],[-.shader.slang]
+LIBDIR = [---.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)/float=ieee/ieee=denorm
+
+SOURCES = s_aaline.c s_aatriangle.c s_accum.c s_alpha.c \
+       s_bitmap.c s_blend.c s_blit.c s_buffers.c s_context.c \
+       s_copypix.c s_depth.c s_fragprog.c \
+        s_drawpix.c s_feedback.c s_fog.c s_imaging.c s_lines.c s_logic.c \
+       s_masking.c s_points.c s_readpix.c \
+       s_span.c s_stencil.c s_texstore.c s_texcombine.c s_texfilter.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_blit.obj,s_fragprog.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_points.obj,s_readpix.obj,s_span.obj,s_stencil.obj,\
+       s_texstore.obj,s_texcombine.obj,s_texfilter.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_blit.obj : s_blit.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_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_texcombine.obj : s_texcombine.c
+s_texfilter.obj : s_texfilter.c
+s_triangle.obj : s_triangle.c
+s_zoom.obj : s_zoom.c
+s_fragprog.obj : s_fragprog.c
index e7911fec3b5536bf98cdb539bff0cdf4aa1a583b..ca08203d8315178b555cc6e1aa067dc8252a59b5 100644 (file)
@@ -141,6 +141,7 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1)
 
    INIT_SPAN(line.span, GL_LINE);
    line.span.arrayMask = SPAN_XY | SPAN_COVERAGE;
+   line.span.facing = swrast->PointLineFacing;
    line.xAdj = line.dx / line.len * line.halfWidth;
    line.yAdj = line.dy / line.len * line.halfWidth;
 
index 42d74a16328481470edf9a2c51f6371c2dbe3072..0827b3db9eb90e54491b56461a9aa0fb3a89a1c4 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.3
+ * Version:  7.0.3
  *
  * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
@@ -65,7 +65,7 @@
    GLfloat attrPlane[FRAG_ATTRIB_MAX][4][4];
    GLfloat wPlane[4];  /* win[3] */
 #endif
-   GLfloat bf = SWRAST_CONTEXT(ctx)->_BackfaceSign;
+   GLfloat bf = SWRAST_CONTEXT(ctx)->_BackfaceCullSign;
    
    (void) swrast;
 
    majDx = vMax->attrib[FRAG_ATTRIB_WPOS][0] - vMin->attrib[FRAG_ATTRIB_WPOS][0];
    majDy = vMax->attrib[FRAG_ATTRIB_WPOS][1] - vMin->attrib[FRAG_ATTRIB_WPOS][1];
 
+   /* front/back-face determination and cullling */
    {
       const GLfloat botDx = vMid->attrib[FRAG_ATTRIB_WPOS][0] - vMin->attrib[FRAG_ATTRIB_WPOS][0];
       const GLfloat botDy = vMid->attrib[FRAG_ATTRIB_WPOS][1] - vMin->attrib[FRAG_ATTRIB_WPOS][1];
       if (area * bf < 0 || area == 0 || IS_INF_OR_NAN(area))
         return;
       ltor = (GLboolean) (area < 0.0F);
+
+      span.facing = area * swrast->_BackfaceSign > 0.0F;
    }
 
    /* Plane equation setup:
          }
 
          /* skip fragments with zero coverage */
-         while (startX >= 0) {
+         while (startX > 0) {
             coverage = compute_coveragef(pMin, pMax, pMid, startX, iy);
             if (coverage > 0.0F)
                break;
             /* (cx,cy) = center of fragment */
             const GLfloat cx = ix + 0.5F, cy = iy + 0.5F;
             SWspanarrays *array = span.array;
+            ASSERT(ix >= 0);
 #ifdef DO_INDEX
             array->coverage[ix] = (GLfloat) compute_coveragei(pMin, pMax, pMid, ix, iy);
 #else
index 13a42fdf53e0e646f724b86af9f690a1b2bffef9..1d1cdf23d1f8dff986724c290e293de37655a0bd 100644 (file)
@@ -525,8 +525,8 @@ accum_return(GLcontext *ctx, GLfloat value,
          }
 
          /* store colors */
-         for (buffer = 0; buffer < fb->_NumColorDrawBuffers[0]; buffer++) {
-            struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[0][buffer];
+         for (buffer = 0; buffer < fb->_NumColorDrawBuffers; buffer++) {
+            struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[buffer];
             if (masking) {
                _swrast_mask_rgba_span(ctx, rb, &span);
             }
index 7fd8945354555ada2e8130a9b786a4494543b46c..95c83432a9c6cf9dbb85621c160b68ca6f816b64 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.2
+ * Version:  7.1
  *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -880,7 +880,8 @@ blend_general(GLcontext *ctx, GLuint n, const GLubyte mask[],
       }
    }
    else {
-      blend_general_float(ctx, n, mask, rgbaF, destF, chanType);
+      blend_general_float(ctx, n, mask, (GLfloat (*)[4]) src,
+                          (GLfloat (*)[4]) dst, chanType);
    }
 }
 
index 0e12dfa1da63ca74096ac1256137a2a87ea30c43..bc4b2ac62517a8e02d1b52a940b5998be9a62426 100644 (file)
@@ -135,7 +135,7 @@ blit_nearest(GLcontext *ctx,
    switch (buffer) {
    case GL_COLOR_BUFFER_BIT:
       readRb = ctx->ReadBuffer->_ColorReadBuffer;
-      drawRb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+      drawRb = ctx->DrawBuffer->_ColorDrawBuffers[0];
       comps = 4;
       break;
    case GL_DEPTH_BUFFER_BIT:
@@ -319,7 +319,7 @@ blit_linear(GLcontext *ctx,
             GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1)
 {
    struct gl_renderbuffer *readRb = ctx->ReadBuffer->_ColorReadBuffer;
-   struct gl_renderbuffer *drawRb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+   struct gl_renderbuffer *drawRb = ctx->DrawBuffer->_ColorDrawBuffers[0];
 
    const GLint srcWidth = ABS(srcX1 - srcX0);
    const GLint dstWidth = ABS(dstX1 - dstX0);
@@ -493,7 +493,7 @@ simple_blit(GLcontext *ctx,
    switch (buffer) {
    case GL_COLOR_BUFFER_BIT:
       readRb = ctx->ReadBuffer->_ColorReadBuffer;
-      drawRb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+      drawRb = ctx->DrawBuffer->_ColorDrawBuffers[0];
       comps = 4;
       break;
    case GL_DEPTH_BUFFER_BIT:
@@ -745,6 +745,9 @@ _swrast_BlitFramebuffer(GLcontext *ctx,
    };
    GLint i;
 
+   if (!ctx->DrawBuffer->_NumColorDrawBuffers)
+      return;
+
    if (!clip_blit(ctx, &srcX0, &srcY0, &srcX1, &srcY1,
                   &dstX0, &dstY0, &dstX1, &dstY1)) {
       return;
index a70f4745872c4344305630b2651de575ea86d74f..9e87d6d485725c9f01975c98d0fecfd6158fd2bb 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.2
+ * Version:  7.1
  *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -251,7 +251,7 @@ static void
 clear_color_buffers(GLcontext *ctx)
 {
    GLboolean masking;
-   GLuint i;
+   GLuint buf;
 
    if (ctx->Visual.rgbMode) {
       if (ctx->Color.ColorMask[0] && 
@@ -265,7 +265,7 @@ clear_color_buffers(GLcontext *ctx)
       }
    }
    else {
-      struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+      struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];
       const GLuint indexBits = (1 << rb->IndexBits) - 1;
       if ((ctx->Color.IndexMask & indexBits) == indexBits) {
          masking = GL_FALSE;
@@ -275,8 +275,8 @@ clear_color_buffers(GLcontext *ctx)
       }
    }
 
-   for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers[0]; i++) {
-      struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][i];
+   for (buf = 0; buf < ctx->DrawBuffer->_NumColorDrawBuffers; buf++) {
+      struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[buf];
       if (ctx->Visual.rgbMode) {
          if (masking) {
             clear_rgba_buffer_with_masking(ctx, rb);
@@ -331,7 +331,8 @@ _swrast_Clear(GLcontext *ctx, GLbitfield buffers)
 
    /* do software clearing here */
    if (buffers) {
-      if (buffers & ctx->DrawBuffer->_ColorDrawBufferMask[0]) {
+      if ((buffers & BUFFER_BITS_COLOR)
+          && (ctx->DrawBuffer->_NumColorDrawBuffers > 0)) {
          clear_color_buffers(ctx);
       }
       if (buffers & BUFFER_BIT_DEPTH) {
index 4d9b956f856ae9c8576c76fc767c125e86104bef..2dea89539923ad8af6416651e021adc052ede246 100644 (file)
@@ -2,7 +2,7 @@
  * Mesa 3-D graphics library
  * Version:  7.1
  *
- * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -33,6 +33,7 @@
 #include "main/mtypes.h"
 #include "teximage.h"
 #include "swrast.h"
+#include "shader/prog_parameter.h"
 #include "shader/prog_statevars.h"
 #include "s_blend.h"
 #include "s_context.h"
@@ -87,7 +88,7 @@ _swrast_update_rasterflags( GLcontext *ctx )
     * 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) {
+   if (ctx->DrawBuffer->_NumColorDrawBuffers != 1) {
       /* more than one color buffer designated for writing (or zero buffers) */
       rasterMask |= MULTI_DRAW_BIT;
    }
@@ -117,8 +118,8 @@ _swrast_update_rasterflags( GLcontext *ctx )
 
 
 /**
- * Examine polycon culls tate to compute the _BackfaceSign field.
- * _BackfaceSign will be 0 if no culling, -1 if culling back-faces,
+ * Examine polygon cull state to compute the _BackfaceCullSign field.
+ * _BackfaceCullSign will be 0 if no culling, -1 if culling back-faces,
  * and 1 if culling front-faces.  The Polygon FrontFace state also
  * factors in.
  */
@@ -128,31 +129,32 @@ _swrast_update_polygon( GLcontext *ctx )
    GLfloat backface_sign;
 
    if (ctx->Polygon.CullFlag) {
-      backface_sign = 1.0;
       switch (ctx->Polygon.CullFaceMode) {
       case GL_BACK:
-        if (ctx->Polygon.FrontFace == GL_CCW)
-           backface_sign = -1.0;
+         backface_sign = -1.0;
         break;
       case GL_FRONT:
-        if (ctx->Polygon.FrontFace != GL_CCW)
-           backface_sign = -1.0;
+         backface_sign = 1.0;
         break;
       case GL_FRONT_AND_BACK:
          /* fallthrough */
       default:
         backface_sign = 0.0;
-        break;
       }
    }
    else {
       backface_sign = 0.0;
    }
 
-   SWRAST_CONTEXT(ctx)->_BackfaceSign = backface_sign;
+   SWRAST_CONTEXT(ctx)->_BackfaceCullSign = backface_sign;
+
+   /* This is for front/back-face determination, but not for culling */
+   SWRAST_CONTEXT(ctx)->_BackfaceSign
+      = (ctx->Polygon.FrontFace == GL_CW) ? -1.0 : 1.0;
 }
 
 
+
 /**
  * Update the _PreferPixelFog field to indicate if we need to compute
  * fog blend factors (from the fog coords) per-fragment.
@@ -500,6 +502,13 @@ _swrast_invalidate_state( GLcontext *ctx, GLbitfield new_state )
       new_state = ~0;
    }
 
+   {
+      const struct gl_fragment_program *fp = ctx->FragmentProgram._Current;
+      if (fp && (fp->Base.Parameters->StateFlags & new_state)) {
+         _mesa_load_state_parameters(ctx, fp->Base.Parameters);
+      }
+   }
+
    if (new_state & swrast->InvalidateTriangleMask)
       swrast->Triangle = _swrast_validate_triangle;
 
@@ -598,44 +607,6 @@ _swrast_update_active_attribs(GLcontext *ctx)
 }
 
 
-/**
- * Update the swrast->_ColorOutputsMask which indicates which color
- * renderbuffers (aka rendertargets) are being written to by the current
- * fragment program.
- * We also take glDrawBuffers() into account to skip outputs that are
- * set to GL_NONE.
- */
-static void
-_swrast_update_color_outputs(GLcontext *ctx)
-{
-   SWcontext *swrast = SWRAST_CONTEXT(ctx);
-   const struct gl_framebuffer *fb = ctx->DrawBuffer;
-
-   swrast->_ColorOutputsMask = 0;
-   swrast->_NumColorOutputs = 0;
-
-   if (ctx->FragmentProgram._Current) {
-      const GLbitfield outputsWritten
-         = ctx->FragmentProgram._Current->Base.OutputsWritten;
-      GLuint output;
-      for (output = 0; output < ctx->Const.MaxDrawBuffers; output++) {
-         if ((outputsWritten & (1 << (FRAG_RESULT_DATA0 + output)))
-             && (fb->_NumColorDrawBuffers[output] > 0)) {
-            swrast->_ColorOutputsMask |= (1 << output);
-            swrast->_NumColorOutputs = output + 1;
-         }
-      }
-   }
-   if (swrast->_ColorOutputsMask == 0x0) {
-      /* no fragment program, or frag prog didn't write to gl_FragData[] */
-      if (fb->_NumColorDrawBuffers[0] > 0) {
-         swrast->_ColorOutputsMask = 0x1;
-         swrast->_NumColorOutputs = 1;
-      }
-   }
-}
-
-
 void
 _swrast_validate_derived( GLcontext *ctx )
 {
@@ -685,9 +656,6 @@ _swrast_validate_derived( GLcontext *ctx )
                               _NEW_TEXTURE))
          _swrast_update_active_attribs(ctx);
 
-      if (swrast->NewState & (_NEW_PROGRAM | _NEW_BUFFERS))
-         _swrast_update_color_outputs(ctx);
-
       swrast->NewState = 0;
       swrast->StateChanges = 0;
       swrast->InvalidateState = _swrast_invalidate_state;
@@ -766,6 +734,12 @@ _swrast_ResetLineStipple( GLcontext *ctx )
    SWRAST_CONTEXT(ctx)->StippleCounter = 0;
 }
 
+void
+_swrast_SetFacing(GLcontext *ctx, GLuint facing)
+{
+   SWRAST_CONTEXT(ctx)->PointLineFacing = facing;
+}
+
 void
 _swrast_allow_vertex_fog( GLcontext *ctx, GLboolean value )
 {
@@ -869,6 +843,8 @@ _swrast_DestroyContext( GLcontext *ctx )
    }
 
    FREE( swrast->SpanArrays );
+   if (swrast->ZoomedArrays)
+      FREE( swrast->ZoomedArrays );
    FREE( swrast->TexelBuffer );
    FREE( swrast );
 
index daa07e15783af7dfd0cd555c8d7390c65d8cf122..a511d1c9a173d9207672b0548dd56c977a06e206 100644 (file)
@@ -128,17 +128,14 @@ typedef struct
     * _swrast_validate_derived():
     */
    GLbitfield _RasterMask;
-   GLfloat _BackfaceSign;
+   GLfloat _BackfaceSign;      /** +1 or -1 */
+   GLfloat _BackfaceCullSign;  /** +1, 0, or -1 */
    GLboolean _PreferPixelFog;    /* Compute fog blend factor per fragment? */
    GLboolean _AnyTextureCombine;
    GLboolean _FogEnabled;
    GLboolean _DeferredTexture;
    GLenum _FogMode;  /* either GL_FOG_MODE or fragment program's fog mode */
 
-   /** Multiple render targets */
-   GLbitfield _ColorOutputsMask;
-   GLuint _NumColorOutputs;
-
    /** List/array of the fragment attributes to interpolate */
    GLuint _ActiveAttribs[FRAG_ATTRIB_MAX];
    /** Same info, but as a bitmask */
@@ -156,6 +153,7 @@ typedef struct
    /* Working values:
     */
    GLuint StippleCounter;    /**< Line stipple counter */
+   GLuint PointLineFacing;
    GLbitfield NewState;
    GLuint StateChanges;
    GLenum Primitive;    /* current primitive being drawn (ala glBegin) */
@@ -208,6 +206,7 @@ typedef struct
     * on some systems.
     */
    SWspanarrays *SpanArrays;
+   SWspanarrays *ZoomedArrays;  /**< For pixel zooming */
 
    /**
     * Used to buffer N GL_POINTS, instead of rendering one by one.
index 7385a9942c95c53b2a6753c35afc21198b327999..b5ffb6aa1e39b141937246ea1046bc5bf2fc658f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.3
+ * Version:  7.1
  *
  * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
@@ -71,13 +71,20 @@ regions_overlap(GLint srcx, GLint srcy,
    }
    else {
       /* add one pixel of slop when zooming, just to be safe */
-      if ((srcx > dstx + (width * zoomX) + 1) || (srcx + width + 1 < dstx)) {
+      if (srcx > (dstx + ((zoomX > 0.0F) ? (width * zoomX + 1.0F) : 0.0F))) {
+         /* src is completely right of dest */
+         return GL_FALSE;
+      }
+      else if (srcx + width + 1.0F < dstx + ((zoomX > 0.0F) ? 0.0F : (width * zoomX))) {
+         /* src is completely left of dest */
          return GL_FALSE;
       }
       else if ((srcy < dsty) && (srcy + height < dsty + (height * zoomY))) {
+         /* src is completely below dest */
          return GL_FALSE;
       }
       else if ((srcy > dsty) && (srcy + height > dsty + (height * zoomY))) {
+         /* src is completely above dest */
          return GL_FALSE;
       }
       else {
@@ -823,10 +830,10 @@ fast_copy_pixels(GLcontext *ctx,
    }
 
    if (type == GL_COLOR) {
-      if (dstFb->_NumColorDrawBuffers[0] != 1)
+      if (dstFb->_NumColorDrawBuffers != 1)
          return GL_FALSE;
       srcRb = srcFb->_ColorReadBuffer;
-      dstRb = dstFb->_ColorDrawBuffers[0][0];
+      dstRb = dstFb->_ColorDrawBuffers[0];
    }
    else if (type == GL_STENCIL) {
       srcRb = srcFb->_StencilBuffer;
index d1120d2cee5b10ab6c863aeb625a9fe91a75369c..72398f9ec130ce96bf1d1103e7df08641982bac3 100644 (file)
@@ -53,8 +53,8 @@ fast_draw_rgba_pixels(GLcontext *ctx, GLint x, GLint y,
                       const GLvoid *pixels)
 {
    const GLint imgX = x, imgY = y;
-   struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];
-   const GLenum rbType = rb->DataType;
+   struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];
+   GLenum rbType;
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
    SWspan span;
    GLboolean simpleZoom;
@@ -62,6 +62,11 @@ fast_draw_rgba_pixels(GLcontext *ctx, GLint x, GLint y,
    struct gl_pixelstore_attrib unpack;
    GLint destX, destY, drawWidth, drawHeight; /* post clipping */
 
+   if (!rb)
+      return GL_TRUE; /* no-op */
+
+   rbType = rb->DataType;
+
    if ((swrast->_RasterMask & ~CLIP_BIT) ||
        ctx->Texture._EnabledCoordUnits ||
        userUnpack->SwapBytes ||
@@ -608,8 +613,8 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
                        IMAGE_POST_CONVOLUTION_SCALE_BIAS);
    }
 
-   if (ctx->DrawBuffer->_NumColorDrawBuffers[0] > 0 &&
-       ctx->DrawBuffer->_ColorDrawBuffers[0][0]->DataType != GL_FLOAT &&
+   if (ctx->DrawBuffer->_NumColorDrawBuffers > 0 &&
+       ctx->DrawBuffer->_ColorDrawBuffers[0]->DataType != GL_FLOAT &&
        ctx->Color.ClampFragmentColor != GL_FALSE) {
       /* need to clamp colors before applying fragment ops */
       transferOps |= IMAGE_CLAMP_BIT;
@@ -834,9 +839,11 @@ _swrast_DrawPixels( GLcontext *ctx,
    if (swrast->NewState)
       _swrast_validate_derived( ctx );
 
-   pixels = _mesa_map_drawpix_pbo(ctx, unpack, pixels);
-   if (!pixels)
-      return;
+    pixels = _mesa_map_drawpix_pbo(ctx, unpack, pixels);
+    if (!pixels) {
+       RENDER_FINISH(swrast,ctx);
+       return;
+    }
 
    switch (format) {
    case GL_STENCIL_INDEX:
@@ -873,11 +880,9 @@ _swrast_DrawPixels( GLcontext *ctx,
       /* don't return yet, clean-up */
    }
 
-end:
-
    RENDER_FINISH(swrast,ctx);
 
-   _mesa_unmap_drawpix_pbo(ctx, unpack);
+   _mesa_unmap_drapix_pbo(ctx, unpack);
 }
 
 
index 8eeb40f7c53a9a8f488930b3682a05238a4d27dc..525cf9d72457b383388fe7ff578a919916b606ba 100644 (file)
@@ -44,7 +44,8 @@ fetch_texel_lod( GLcontext *ctx, const GLfloat texcoord[4], GLfloat lambda,
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
    const struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current;
 
-   lambda = CLAMP(lambda, texObj->MinLod, texObj->MaxLod);
+   if (texObj)
+      lambda = CLAMP(lambda, texObj->MinLod, texObj->MaxLod);
 
    /* XXX use a float-valued TextureSample routine here!!! */
    swrast->TextureSample[unit](ctx, texObj, 1, (const GLfloat (*)[4]) texcoord,
@@ -68,20 +69,23 @@ fetch_texel_deriv( GLcontext *ctx, const GLfloat texcoord[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;
+   GLfloat lambda;
    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]) + lodBias;
+   if (texObj) {
+      const struct gl_texture_image *texImg = texObj->Image[0][texObj->BaseLevel];
+      const GLfloat texW = (GLfloat) texImg->WidthScale;
+      const GLfloat texH = (GLfloat) texImg->HeightScale;
 
-   lambda = CLAMP(lambda, texObj->MinLod, texObj->MaxLod);
+      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]) + lodBias;
+
+      lambda = CLAMP(lambda, texObj->MinLod, texObj->MaxLod);
+   }
 
    swrast->TextureSample[unit](ctx, texObj, 1, (const GLfloat (*)[4]) texcoord,
                                &lambda, &rgba);
@@ -124,7 +128,8 @@ init_machine(GLcontext *ctx, struct gl_program_machine *machine,
    /* if running a GLSL program (not ARB_fragment_program) */
    if (ctx->Shader.CurrentProgram) {
       /* Store front/back facing value in register FOGC.Y */
-      machine->Attribs[FRAG_ATTRIB_FOGC][col][1] = (GLfloat) ctx->_Facing;
+      machine->Attribs[FRAG_ATTRIB_FOGC][col][1] = 1.0 - span->facing;
+      /* Note FOGC.ZW is gl_PointCoord if drawing a sprite */
    }
 
    machine->CurElement = col;
@@ -171,11 +176,11 @@ run_program(GLcontext *ctx, SWspan *span, GLuint start, GLuint end)
                 * Note that colors beyond 0 and 1 will overwrite other
                 * attributes, such as FOGC, TEX0, TEX1, etc.  That's OK.
                 */
-               GLuint output;
-               for (output = 0; output < swrast->_NumColorOutputs; output++) {
-                  if (outputsWritten & (1 << (FRAG_RESULT_DATA0 + output))) {
-                     COPY_4V(span->array->attribs[FRAG_ATTRIB_COL0+output][i],
-                             machine->Outputs[FRAG_RESULT_DATA0 + output]);
+               GLuint buf;
+               for (buf = 0; buf < ctx->DrawBuffer->_NumColorDrawBuffers; buf++) {
+                  if (outputsWritten & (1 << (FRAG_RESULT_DATA0 + buf))) {
+                     COPY_4V(span->array->attribs[FRAG_ATTRIB_COL0 + buf][i],
+                             machine->Outputs[FRAG_RESULT_DATA0 + buf]);
                   }
                }
             }
index 1accfc67e2ce66ff1f32e0c10845913a1bf2e23e..1abf8d6c7f3d1a8c84a95787abd2e9a20ff74358 100644 (file)
@@ -308,6 +308,9 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
    span.interpMask = interpFlags;
    span.arrayMask = SPAN_XY;
 
+   span.facing = swrast->PointLineFacing;
+
+
    /*
     * Draw
     */
index 9f52da980c7c5d866e35ae91bb9bc5219e222cc4..22639c58ff706c3bf93ed033ca5c3c5f007d8212 100644 (file)
    } while(0)
 
 
+
+/**
+ * Get/compute the point size.
+ * The size may come from a vertex shader, or computed with attentuation
+ * or just the glPointSize value.
+ * Must also clamp to user-defined range and implmentation limits.
+ */
+static INLINE GLfloat
+get_size(const GLcontext *ctx, const SWvertex *vert, GLboolean smoothed)
+{
+   GLfloat size;
+
+   if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) {
+      /* use vertex's point size */
+      size = vert->pointSize;
+   }
+   else {
+      /* use constant point size */
+      size = ctx->Point.Size;
+   }
+   /* always clamp to user-specified limits */
+   size = CLAMP(size, ctx->Point.MinSize, ctx->Point.MaxSize);
+   /* clamp to implementation limits */
+   if (smoothed)
+      size = CLAMP(size, ctx->Const.MinPointSizeAA, ctx->Const.MaxPointSizeAA);
+   else
+      size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize);
+
+   return size;
+}
+
+
 /**
  * Draw a point sprite
  */
@@ -68,23 +100,14 @@ sprite_point(GLcontext *ctx, const SWvertex *vert)
       span.z = (GLuint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F);
    span.zStep = 0;
 
-   /* compute size */
-   if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) {
-      /* use vertex's point size */
-      /* first, clamp attenuated size to the user-specifed range */
-      size = CLAMP(vert->pointSize, ctx->Point.MinSize, ctx->Point.MaxSize);
-   }
-   else {
-      /* use constant point size */
-      size = ctx->Point.Size;
-   }
-   /* clamp to non-AA implementation limits */
-   size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize);
+   size = get_size(ctx, vert, GL_FALSE);
 
    /* span init */
    INIT_SPAN(span, GL_POINT);
    span.interpMask = SPAN_Z | SPAN_RGBA;
 
+   span.facing = swrast->PointLineFacing;
+
    span.red   = ChanToFixed(vert->color[0]);
    span.green = ChanToFixed(vert->color[1]);
    span.blue  = ChanToFixed(vert->color[2]);
@@ -186,9 +209,10 @@ sprite_point(GLcontext *ctx, const SWvertex *vert)
       }
       else {
          /* even size */
-         xmin = (GLint) x - iRadius + 1;
+         /* 0.501 factor allows conformance to pass */
+         xmin = (GLint) (x + 0.501) - iRadius;
          xmax = xmin + iSize - 1;
-         ymin = (GLint) y - iRadius + 1;
+         ymin = (GLint) (y + 0.501) - iRadius;
          ymax = ymin + iSize - 1;
       }
 
@@ -236,18 +260,7 @@ smooth_point(GLcontext *ctx, const SWvertex *vert)
       span.z = (GLuint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F);
    span.zStep = 0;
 
-   /* compute size */
-   if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) {
-      /* use vertex's point size */
-      /* first, clamp attenuated size to the user-specifed range */
-      size = CLAMP(vert->pointSize, ctx->Point.MinSize, ctx->Point.MaxSize);
-   }
-   else {
-      /* use constant point size */
-      size = ctx->Point.Size;
-   }
-   /* clamp to AA implementation limits */
-   size = CLAMP(size, ctx->Const.MinPointSizeAA, ctx->Const.MaxPointSizeAA);
+   size = get_size(ctx, vert, GL_TRUE);
 
    /* alpha attenuation / fade factor */
    if (ctx->Multisample._Enabled) {
@@ -269,6 +282,8 @@ smooth_point(GLcontext *ctx, const SWvertex *vert)
    span.interpMask = SPAN_Z | SPAN_RGBA;
    span.arrayMask = SPAN_COVERAGE | SPAN_MASK;
 
+   span.facing = swrast->PointLineFacing;
+
    span.red   = ChanToFixed(vert->color[0]);
    span.green = ChanToFixed(vert->color[1]);
    span.blue  = ChanToFixed(vert->color[2]);
@@ -370,22 +385,12 @@ large_point(GLcontext *ctx, const SWvertex *vert)
       span.z = (GLuint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F);
    span.zStep = 0;
 
-   /* compute size */
-   if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) {
-      /* use vertex's point size */
-      /* first, clamp attenuated size to the user-specifed range */
-      size = CLAMP(vert->pointSize, ctx->Point.MinSize, ctx->Point.MaxSize);
-   }
-   else {
-      /* use constant point size */
-      size = ctx->Point.Size;
-   }
-   /* clamp to non-AA implementation limits */
-   size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize);
+   size = get_size(ctx, vert, GL_FALSE);
 
    /* span init */
    INIT_SPAN(span, GL_POINT);
    span.arrayMask = SPAN_XY;
+   span.facing = swrast->PointLineFacing;
 
    if (ciMode) {
       span.interpMask = SPAN_Z | SPAN_INDEX;
@@ -435,9 +440,10 @@ large_point(GLcontext *ctx, const SWvertex *vert)
       }
       else {
          /* even size */
-         xmin = (GLint) x - iRadius + 1;
+         /* 0.501 factor allows conformance to pass */
+         xmin = (GLint) (x + 0.501) - iRadius;
          xmax = xmin + iSize - 1;
-         ymin = (GLint) y - iRadius + 1;
+         ymin = (GLint) (y + 0.501) - iRadius;
          ymax = ymin + iSize - 1;
       }
 
@@ -491,16 +497,21 @@ pixel_point(GLcontext *ctx, const SWvertex *vert)
 
    /* check if we need to flush */
    if (span->end >= MAX_WIDTH ||
-       (swrast->_RasterMask & (BLEND_BIT | LOGIC_OP_BIT | MASKING_BIT))) {
-      if (ciMode)
-         _swrast_write_index_span(ctx, span);
-      else
-         _swrast_write_rgba_span(ctx, span);
-      span->end = 0;
+       (swrast->_RasterMask & (BLEND_BIT | LOGIC_OP_BIT | MASKING_BIT)) ||
+       span->facing != swrast->PointLineFacing) {
+      if (span->end > 0) {
+         if (ciMode)
+            _swrast_write_index_span(ctx, span);
+         else
+            _swrast_write_rgba_span(ctx, span);
+         span->end = 0;
+      }
    }
 
    count = span->end;
 
+   span->facing = swrast->PointLineFacing;
+
    /* fragment attributes */
    if (ciMode) {
       span->array->index[count] = (GLuint) vert->attrib[FRAG_ATTRIB_CI][0];
index 6186f92899efdd47535abc8dc85eec5402c72658..8fa95ded18d779483b65ec4b276c118ca767da95 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.3
+ * Version:  7.0.3
  *
  * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
@@ -129,7 +129,8 @@ read_depth_pixels( GLcontext *ctx,
          rb->GetRow(ctx, rb, width, x, y, dest);
          /* convert range from 24-bit to 32-bit */
          for (k = 0; k < width; k++) {
-            dest[k] = (dest[k] << 8) | (dest[k] >> 24);
+            /* Note: put MSByte of 24-bit value into LSByte */
+            dest[k] = (dest[k] << 8) | ((dest[k] >> 16) & 0xff);
          }
       }
    }
@@ -569,13 +570,14 @@ _swrast_ReadPixels( GLcontext *ctx,
    /* Do all needed clipping here, so that we can forget about it later */
    if (!_mesa_clip_readpixels(ctx, &x, &y, &width, &height, &clippedPacking)) {
       /* The ReadPixels region is totally outside the window bounds */
-      goto end;
+      RENDER_FINISH(swrast, ctx);
+      return;
    }
 
    pixels = _mesa_map_readpix_pbo(ctx, &clippedPacking, pixels);
    if (!pixels)
       return;
-
+  
    switch (format) {
       case GL_COLOR_INDEX:
          read_index_pixels(ctx, x, y, width, height, type, pixels,
@@ -612,8 +614,6 @@ _swrast_ReadPixels( GLcontext *ctx,
          /* don't return yet, clean-up */
    }
 
-
-end:
    RENDER_FINISH(swrast, ctx);
 
    _mesa_unmap_readpix_pbo(ctx, &clippedPacking);
index 457dc4a6ce22925a19c9dd9436adb779522669a3..01b490f38fc0421473dd65512b4ee0a477eab063 100644 (file)
@@ -64,8 +64,11 @@ _swrast_span_default_attribs(GLcontext *ctx, SWspan *span)
       const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF;
       if (ctx->DrawBuffer->Visual.depthBits <= 16)
          span->z = FloatToFixed(ctx->Current.RasterPos[2] * depthMax + 0.5F);
-      else
-         span->z = (GLint) (ctx->Current.RasterPos[2] * depthMax + 0.5F);
+      else {
+         GLfloat tmpf = ctx->Current.RasterPos[2] * depthMax; 
+         tmpf = MIN2(tmpf, depthMax);
+         span->z = (GLint)tmpf;
+      }
       span->zStep = 0;
       span->interpMask |= SPAN_Z;
    }
@@ -789,6 +792,7 @@ _swrast_write_index_span( GLcontext *ctx, SWspan *span)
    const SWcontext *swrast = SWRAST_CONTEXT(ctx);
    const GLbitfield origInterpMask = span->interpMask;
    const GLbitfield origArrayMask = span->arrayMask;
+   struct gl_framebuffer *fb = ctx->DrawBuffer;
 
    ASSERT(span->end <= MAX_WIDTH);
    ASSERT(span->primitive == GL_POINT  ||  span->primitive == GL_LINE ||
@@ -815,7 +819,7 @@ _swrast_write_index_span( GLcontext *ctx, SWspan *span)
    }
 
    /* Depth bounds test */
-   if (ctx->Depth.BoundsTest && ctx->DrawBuffer->Visual.depthBits > 0) {
+   if (ctx->Depth.BoundsTest && fb->Visual.depthBits > 0) {
       if (!_swrast_depth_bounds_test(ctx, span)) {
          return;
       }
@@ -827,10 +831,10 @@ _swrast_write_index_span( GLcontext *ctx, SWspan *span)
       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);
+            assert(span->array->x[i] >= fb->_Xmin);
+            assert(span->array->x[i] < fb->_Xmax);
+            assert(span->array->y[i] >= fb->_Ymin);
+            assert(span->array->y[i] < fb->_Ymax);
          }
       }
    }
@@ -873,7 +877,7 @@ _swrast_write_index_span( GLcontext *ctx, SWspan *span)
 #endif
 
    /* we have to wait until after occlusion to do this test */
-   if (ctx->Color.DrawBuffer == GL_NONE || ctx->Color.IndexMask == 0) {
+   if (ctx->Color.IndexMask == 0) {
       /* write no pixels */
       span->arrayMask = origArrayMask;
       return;
@@ -909,22 +913,21 @@ _swrast_write_index_span( GLcontext *ctx, SWspan *span)
     * Write to renderbuffers
     */
    {
-      struct gl_framebuffer *fb = ctx->DrawBuffer;
-      const GLuint output = 0; /* only frag progs can write to other outputs */
-      const GLuint numDrawBuffers = fb->_NumColorDrawBuffers[output];
-      GLuint indexSave[MAX_WIDTH];
+      const GLuint numBuffers = fb->_NumColorDrawBuffers;
       GLuint buf;
 
-      if (numDrawBuffers > 1) {
-         /* save indexes for second, third renderbuffer writes */
-         _mesa_memcpy(indexSave, span->array->index,
-                      span->end * sizeof(indexSave[0]));
-      }
+      for (buf = 0; buf < numBuffers; buf++) {
+         struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[buf];
+         GLuint indexSave[MAX_WIDTH];
 
-      for (buf = 0; buf < fb->_NumColorDrawBuffers[output]; buf++) {
-         struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[output][buf];
          ASSERT(rb->_BaseFormat == GL_COLOR_INDEX);
 
+         if (numBuffers > 1) {
+            /* save indexes for second, third renderbuffer writes */
+            _mesa_memcpy(indexSave, span->array->index,
+                         span->end * sizeof(indexSave[0]));
+         }
+
          if (ctx->Color.IndexLogicOpEnabled) {
             _swrast_logicop_ci_span(ctx, rb, span);
          }
@@ -999,7 +1002,7 @@ _swrast_write_index_span( GLcontext *ctx, SWspan *span)
             }
          }
 
-         if (buf + 1 < numDrawBuffers) {
+         if (buf + 1 < numBuffers) {
             /* restore original span values */
             _mesa_memcpy(span->array->index, indexSave,
                          span->end * sizeof(indexSave[0]));
@@ -1116,7 +1119,7 @@ clamp_colors(SWspan *span)
 
 /**
  * Convert the span's color arrays to the given type.
- * The only way 'output' can be greater than one is when we have a fragment
+ * The only way 'output' can be greater than zero is when we have a fragment
  * program that writes to gl_FragData[1] or higher.
  * \param output  which fragment program color output is being processed
  */
@@ -1180,8 +1183,10 @@ shade_texture_span(GLcontext *ctx, SWspan *span)
       if (span->primitive == GL_BITMAP && span->array->ChanType != GL_FLOAT) {
          convert_color_type(span, GL_FLOAT, 0);
       }
-      if (span->primitive != GL_POINT || ctx->Point.PointSprite) {
-         /* for points, we populated the arrays already */
+      if (span->primitive != GL_POINT ||
+         (span->interpMask & SPAN_RGBA) ||
+         ctx->Point.PointSprite) {
+         /* for single-pixel points, we populated the arrays already */
          interpolate_active_attribs(ctx, span, ~0);
       }
       span->array->ChanType = GL_FLOAT;
@@ -1246,7 +1251,6 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)
                              || ctx->ATIFragmentShader._Enabled);
    const GLboolean shaderOrTexture = shader || ctx->Texture._EnabledUnits;
    struct gl_framebuffer *fb = ctx->DrawBuffer;
-   GLuint output;
 
    /*
    printf("%s()  interp 0x%x  array 0x%x\n", __FUNCTION__,
@@ -1396,67 +1400,67 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)
    /*
     * Write to renderbuffers
     */
-   /* Loop over color outputs (GL_ARB_draw_buffers) written by frag prog */
-   for (output = 0; output < swrast->_NumColorOutputs; output++) {
-      if (swrast->_ColorOutputsMask & (1 << output)) {
-        const GLuint numDrawBuffers = fb->_NumColorDrawBuffers[output];
-        GLchan rgbaSave[MAX_WIDTH][4];
-        GLuint buf;
-
-        ASSERT(numDrawBuffers > 0);
-
-        if (fb->_ColorDrawBuffers[output][0]->DataType
-            != span->array->ChanType || output > 0) {
-           convert_color_type(span,
-                              fb->_ColorDrawBuffers[output][0]->DataType,
-                              output);
-        }
-
-        if (numDrawBuffers > 1) {
-           /* save colors for second, third renderbuffer writes */
-           _mesa_memcpy(rgbaSave, span->array->rgba,
-                        4 * span->end * sizeof(GLchan));
-        }
-
-        /* Loop over renderbuffers (i.e. GL_FRONT_AND_BACK) */
-        for (buf = 0; buf < numDrawBuffers; buf++) {
-           struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[output][buf];
-           ASSERT(rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB);
-
-           if (ctx->Color._LogicOpEnabled) {
-              _swrast_logicop_rgba_span(ctx, rb, span);
-           }
-           else if (ctx->Color.BlendEnabled) {
-              _swrast_blend_span(ctx, rb, span);
-           }
-
-           if (colorMask != 0xffffffff) {
-              _swrast_mask_rgba_span(ctx, rb, span);
-           }
-
-           if (span->arrayMask & SPAN_XY) {
-              /* array of pixel coords */
-              ASSERT(rb->PutValues);
-              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);
-              rb->PutRow(ctx, rb, span->end, span->x, span->y,
-                         span->array->rgba,
-                         span->writeAll ? NULL: span->array->mask);
-           }
-
-           if (buf + 1 < numDrawBuffers) {
-              /* restore original span values */
-              _mesa_memcpy(span->array->rgba, rgbaSave,
-                           4 * span->end * sizeof(GLchan));
-           }
-        } /* for buf */
-      } /* if output is written to */
-   } /* for output */
+   {
+      const GLuint numBuffers = fb->_NumColorDrawBuffers;
+      const GLboolean multiFragOutputs = numBuffers > 1;
+      GLuint buf;
+
+      for (buf = 0; buf < numBuffers; buf++) {
+         struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[buf];
+
+         /* color[fragOutput] will be written to buffer[buf] */
+
+         if (rb) {
+            GLchan rgbaSave[MAX_WIDTH][4];
+            const GLuint fragOutput = multiFragOutputs ? buf : 0;
+
+            if (rb->DataType != span->array->ChanType || fragOutput > 0) {
+               convert_color_type(span, rb->DataType, fragOutput);
+            }
+
+            if (!multiFragOutputs && numBuffers > 1) {
+               /* save colors for second, third renderbuffer writes */
+               _mesa_memcpy(rgbaSave, span->array->rgba,
+                            4 * span->end * sizeof(GLchan));
+            }
+
+            ASSERT(rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB);
+
+            if (ctx->Color._LogicOpEnabled) {
+               _swrast_logicop_rgba_span(ctx, rb, span);
+            }
+            else if (ctx->Color.BlendEnabled) {
+               _swrast_blend_span(ctx, rb, span);
+            }
+
+            if (colorMask != 0xffffffff) {
+               _swrast_mask_rgba_span(ctx, rb, span);
+            }
+
+            if (span->arrayMask & SPAN_XY) {
+               /* array of pixel coords */
+               ASSERT(rb->PutValues);
+               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);
+               rb->PutRow(ctx, rb, span->end, span->x, span->y,
+                          span->array->rgba,
+                          span->writeAll ? NULL: span->array->mask);
+            }
+
+            if (!multiFragOutputs && numBuffers > 1) {
+               /* restore original span values */
+               _mesa_memcpy(span->array->rgba, rgbaSave,
+                            4 * span->end * sizeof(GLchan));
+            }
+
+         } /* if rb */
+      } /* for buf */
+   }
 
 end:
    /* restore these values before returning */
index cdb7e4669cefd2a47629c5dfc95418e2f8db8d69..c925922463e61a8ac0b3bf1071b998185fdeb78f 100644 (file)
@@ -923,6 +923,8 @@ stencil_and_ztest_pixels( GLcontext *ctx, SWspan *span, GLuint face )
       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) {
@@ -930,11 +932,12 @@ stencil_and_ztest_pixels( GLcontext *ctx, SWspan *span, GLuint face )
                           n, stencil, mask);
       }
       else {
-         _mesa_memcpy(origMask, mask, n * sizeof(GLubyte));
+         GLubyte tmpMask[MAX_WIDTH]; 
+         _mesa_memcpy(tmpMask, mask, n * sizeof(GLubyte));
 
          _swrast_depth_test_span(ctx, span);
 
-         compute_pass_fail_masks(n, origMask, mask, passMask, failMask);
+         compute_pass_fail_masks(n, tmpMask, mask, passMask, failMask);
 
          if (ctx->Stencil.ZFailFunc[face] != GL_KEEP) {
             apply_stencil_op(ctx, ctx->Stencil.ZFailFunc[face], face,
index bb0fc823e7e7aa098eada5d62e5af6fe74e7fe31..a9e17d4c019e16623cb406ac3e7a67f6c8a43a5c 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.3
+ * Version:  7.0.3
  *
  * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
@@ -213,17 +213,10 @@ lerp_rgba_3d(GLchan result[4], GLfloat a, GLfloat b, GLfloat c,
 
 
 /**
- * Compute the remainder of a divided by b, but be careful with
- * negative values so that GL_REPEAT mode works right.
+ * If A is a signed integer, A % B doesn't give the right value for A < 0
+ * (in terms of texture repeat).  Just casting to unsigned fixes that.
  */
-static INLINE GLint
-repeat_remainder(GLint a, GLint b)
-{
-   if (a >= 0)
-      return a % b;
-   else
-      return (a + 1) % b + b - 1;
-}
+#define REMAINDER(A, B) ((unsigned) (A) % (unsigned) (B))
 
 
 /**
@@ -246,8 +239,8 @@ repeat_remainder(GLint a, GLint b)
          I1 = (I0 + 1) & (SIZE - 1);                                   \
       }                                                                        \
       else {                                                           \
-         I0 = repeat_remainder(IFLOOR(U), SIZE);                       \
-         I1 = repeat_remainder(I0 + 1, SIZE);                          \
+         I0 = REMAINDER(IFLOOR(U), SIZE);                              \
+         I1 = REMAINDER(I0 + 1, SIZE);                                 \
       }                                                                        \
       break;                                                           \
    case GL_CLAMP_TO_EDGE:                                              \
@@ -349,6 +342,7 @@ repeat_remainder(GLint a, GLint b)
       break;                                                           \
    default:                                                            \
       _mesa_problem(ctx, "Bad wrap mode");                             \
+      return;                                                          \
    }                                                                   \
 }
 
@@ -366,7 +360,7 @@ repeat_remainder(GLint a, GLint b)
       if (img->_IsPowerOfTwo)                                          \
          I &= (SIZE - 1);                                              \
       else                                                             \
-         I = repeat_remainder(I, SIZE);                                        \
+         I = REMAINDER(I, SIZE);                                       \
       break;                                                           \
    case GL_CLAMP_TO_EDGE:                                              \
       {                                                                        \
@@ -469,6 +463,7 @@ repeat_remainder(GLint a, GLint b)
       break;                                                           \
    default:                                                            \
       _mesa_problem(ctx, "Bad wrap mode");                             \
+      return;                                                          \
    }                                                                   \
 }
 
@@ -1043,7 +1038,7 @@ sample_2d_linear_repeat(GLcontext *ctx,
    ASSERT(tObj->WrapS == GL_REPEAT);
    ASSERT(tObj->WrapT == GL_REPEAT);
    ASSERT(img->Border == 0);
-   ASSERT(img->_BaseFormat != GL_COLOR_INDEX);
+   ASSERT(img->TexFormat->BaseFormat != GL_COLOR_INDEX);
    ASSERT(img->_IsPowerOfTwo);
 
    COMPUTE_LINEAR_REPEAT_TEXEL_LOCATION(texcoord[0], u, width,  i0, i1);
@@ -1198,7 +1193,8 @@ sample_linear_2d( GLcontext *ctx,
    (void) lambda;
    if (tObj->WrapS == GL_REPEAT &&
        tObj->WrapT == GL_REPEAT &&
-       image->_IsPowerOfTwo) {
+       image->_IsPowerOfTwo &&
+       image->Border == 0) {
       for (i=0;i<n;i++) {
          sample_2d_linear_repeat(ctx, tObj, image, texcoords[i], rgba[i]);
       }
@@ -1237,7 +1233,7 @@ opt_sample_rgb_2d( GLcontext *ctx,
    ASSERT(tObj->WrapS==GL_REPEAT);
    ASSERT(tObj->WrapT==GL_REPEAT);
    ASSERT(img->Border==0);
-   ASSERT(img->_BaseFormat==GL_RGB);
+   ASSERT(img->TexFormat->MesaFormat==MESA_FORMAT_RGB);
    ASSERT(img->_IsPowerOfTwo);
 
    for (k=0; k<n; k++) {
@@ -1278,7 +1274,7 @@ opt_sample_rgba_2d( GLcontext *ctx,
    ASSERT(tObj->WrapS==GL_REPEAT);
    ASSERT(tObj->WrapT==GL_REPEAT);
    ASSERT(img->Border==0);
-   ASSERT(img->_BaseFormat==GL_RGBA);
+   ASSERT(img->TexFormat->MesaFormat==MESA_FORMAT_RGBA);
    ASSERT(img->_IsPowerOfTwo);
 
    for (i = 0; i < n; i++) {
@@ -1308,7 +1304,7 @@ sample_lambda_2d( GLcontext *ctx,
    const GLboolean repeatNoBorderPOT = (tObj->WrapS == GL_REPEAT)
       && (tObj->WrapT == GL_REPEAT)
       && (tImg->Border == 0 && (tImg->Width == tImg->RowStride))
-      && (tImg->_BaseFormat != GL_COLOR_INDEX)
+      && (tImg->TexFormat->BaseFormat != GL_COLOR_INDEX)
       && tImg->_IsPowerOfTwo;
 
    ASSERT(lambda != NULL);
@@ -1323,16 +1319,10 @@ sample_lambda_2d( GLcontext *ctx,
          if (repeatNoBorderPOT) {
             switch (tImg->TexFormat->MesaFormat) {
             case MESA_FORMAT_RGB:
-            case MESA_FORMAT_RGB888:
-            /*case MESA_FORMAT_BGR888:*/
                opt_sample_rgb_2d(ctx, 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, tObj, m, texcoords + minStart,
                                   NULL, rgba + minStart);
                break;
@@ -1386,16 +1376,10 @@ sample_lambda_2d( GLcontext *ctx,
          if (repeatNoBorderPOT) {
             switch (tImg->TexFormat->MesaFormat) {
             case MESA_FORMAT_RGB:
-            case MESA_FORMAT_RGB888:
-            /*case MESA_FORMAT_BGR888:*/
                opt_sample_rgb_2d(ctx, 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, tObj, m, texcoords + magStart,
                                   NULL, rgba + magStart);
                break;
@@ -1872,8 +1856,19 @@ sample_cube_nearest_mipmap_nearest(GLcontext *ctx,
    for (i = 0; i < n; i++) {
       const struct gl_texture_image **images;
       GLfloat newCoord[4];
-      GLint level = nearest_mipmap_level(tObj, lambda[i]);
+      GLint level;
       images = choose_cube_face(tObj, texcoord[i], newCoord);
+
+      /* XXX we actually need to recompute lambda here based on the newCoords.
+       * But we would need the texcoords of adjacent fragments to compute that
+       * properly, and we don't have those here.
+       * For now, do an approximation:  subtracting 1 from the chosen mipmap
+       * level seems to work in some test cases.
+       * The same adjustment is done in the next few functions.
+      */
+      level = nearest_mipmap_level(tObj, lambda[i]);
+      level = MAX2(level - 1, 0);
+
       sample_2d_nearest(ctx, tObj, images[level], newCoord, rgba[i]);
    }
 }
@@ -1891,6 +1886,7 @@ sample_cube_linear_mipmap_nearest(GLcontext *ctx,
       const struct gl_texture_image **images;
       GLfloat newCoord[4];
       GLint level = nearest_mipmap_level(tObj, lambda[i]);
+      level = MAX2(level - 1, 0); /* see comment above */
       images = choose_cube_face(tObj, texcoord[i], newCoord);
       sample_2d_linear(ctx, tObj, images[level], newCoord, rgba[i]);
    }
@@ -1909,6 +1905,7 @@ sample_cube_nearest_mipmap_linear(GLcontext *ctx,
       const struct gl_texture_image **images;
       GLfloat newCoord[4];
       GLint level = linear_mipmap_level(tObj, lambda[i]);
+      level = MAX2(level - 1, 0); /* see comment above */
       images = choose_cube_face(tObj, texcoord[i], newCoord);
       if (level >= tObj->_MaxLevel) {
          sample_2d_nearest(ctx, tObj, images[tObj->_MaxLevel],
@@ -1937,6 +1934,7 @@ sample_cube_linear_mipmap_linear(GLcontext *ctx,
       const struct gl_texture_image **images;
       GLfloat newCoord[4];
       GLint level = linear_mipmap_level(tObj, lambda[i]);
+      level = MAX2(level - 1, 0); /* see comment above */
       images = choose_cube_face(tObj, texcoord[i], newCoord);
       if (level >= tObj->_MaxLevel) {
          sample_2d_linear(ctx, tObj, images[tObj->_MaxLevel],
@@ -2102,7 +2100,7 @@ sample_nearest_rect(GLcontext *ctx,
    ASSERT(tObj->WrapT == GL_CLAMP ||
           tObj->WrapT == GL_CLAMP_TO_EDGE ||
           tObj->WrapT == GL_CLAMP_TO_BORDER);
-   ASSERT(img->_BaseFormat != GL_COLOR_INDEX);
+   ASSERT(img->TexFormat->BaseFormat != GL_COLOR_INDEX);
 
    for (i = 0; i < n; i++) {
       GLint row, col;
@@ -2138,7 +2136,7 @@ sample_linear_rect(GLcontext *ctx,
    ASSERT(tObj->WrapT == GL_CLAMP ||
           tObj->WrapT == GL_CLAMP_TO_EDGE ||
           tObj->WrapT == GL_CLAMP_TO_BORDER);
-   ASSERT(img->_BaseFormat != GL_COLOR_INDEX);
+   ASSERT(img->TexFormat->BaseFormat != GL_COLOR_INDEX);
 
    /* XXX lots of opportunity for optimization in this loop */
    for (i = 0; i < n; i++) {
@@ -2880,8 +2878,8 @@ sample_depth_texture( GLcontext *ctx,
 
    (void) lambda;
 
-   ASSERT(tObj->Image[0][tObj->BaseLevel]->_BaseFormat == GL_DEPTH_COMPONENT ||
-          tObj->Image[0][tObj->BaseLevel]->_BaseFormat == GL_DEPTH_STENCIL_EXT);
+   ASSERT(img->TexFormat->BaseFormat == GL_DEPTH_COMPONENT ||
+          img->TexFormat->BaseFormat == GL_DEPTH_STENCIL_EXT);
 
    ASSERT(tObj->Target == GL_TEXTURE_1D ||
           tObj->Target == GL_TEXTURE_2D ||
@@ -3249,7 +3247,7 @@ sample_depth_texture2(const GLcontext *ctx,
     * GL_TEXTURE_COMPARE_SGIX == GL_TRUE but the current texture object
     * isn't a depth texture.
     */
-   if (texImage->_BaseFormat != GL_DEPTH_COMPONENT) {
+   if (texImage->TexFormat->BaseFormat != GL_DEPTH_COMPONENT) {
       _mesa_problem(ctx,"GL_TEXTURE_COMPARE_SGIX enabled with non-depth texture");
       return;
    }
@@ -3352,7 +3350,7 @@ _swrast_choose_texture_sample_func( GLcontext *ctx,
    }
    else {
       const GLboolean needLambda = (GLboolean) (t->MinFilter != t->MagFilter);
-      const GLenum format = t->Image[0][t->BaseLevel]->_BaseFormat;
+      const GLenum format = t->Image[0][t->BaseLevel]->TexFormat->BaseFormat;
 
       switch (t->Target) {
       case GL_TEXTURE_1D:
index f5d081d7a3f7e65c3b71dd1ae3f0ce49f9d709e6..f3ce590bf38a6c512c457252d9c6f950d75b3490 100644 (file)
@@ -305,7 +305,7 @@ _swrast_copy_teximage1d( GLcontext *ctx, GLenum target, GLint level,
 
    /* GL_SGIS_generate_mipmap */
    if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
-      _mesa_generate_mipmap(ctx, target, texUnit, texObj);
+      ctx->Driver.GenerateMipmap(ctx, target, texObj);
    }
 }
 
@@ -381,7 +381,7 @@ _swrast_copy_teximage2d( GLcontext *ctx, GLenum target, GLint level,
 
    /* GL_SGIS_generate_mipmap */
    if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
-      _mesa_generate_mipmap(ctx, target, texUnit, texObj);
+      ctx->Driver.GenerateMipmap(ctx, target, texObj);
    }
 }
 
@@ -450,7 +450,7 @@ _swrast_copy_texsubimage1d( GLcontext *ctx, GLenum target, GLint level,
 
    /* GL_SGIS_generate_mipmap */
    if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
-      _mesa_generate_mipmap(ctx, target, texUnit, texObj);
+      ctx->Driver.GenerateMipmap(ctx, target, texObj);
    }
 }
 
@@ -526,7 +526,7 @@ _swrast_copy_texsubimage2d( GLcontext *ctx,
 
    /* GL_SGIS_generate_mipmap */
    if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
-      _mesa_generate_mipmap(ctx, target, texUnit, texObj);
+      ctx->Driver.GenerateMipmap(ctx, target, texObj);
    }
 }
 
@@ -599,6 +599,6 @@ _swrast_copy_texsubimage3d( GLcontext *ctx,
 
    /* GL_SGIS_generate_mipmap */
    if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
-      _mesa_generate_mipmap(ctx, target, texUnit, texObj);
+      ctx->Driver.GenerateMipmap(ctx, target, texObj);
    }
 }
index 00cff6635f1bc5e895dfaa68d339d977833c1ec3..f584f6e7f5c22acf7130d84db01b27d6d4d71636 100644 (file)
@@ -58,7 +58,7 @@ _swrast_culltriangle( GLcontext *ctx,
    GLfloat fy = v2->attrib[FRAG_ATTRIB_WPOS][1] - v0->attrib[FRAG_ATTRIB_WPOS][1];
    GLfloat c = ex*fy-ey*fx;
 
-   if (c * SWRAST_CONTEXT(ctx)->_BackfaceSign > 0)
+   if (c * SWRAST_CONTEXT(ctx)->_BackfaceCullSign > 0)
       return 0;
 
    return 1;
@@ -130,7 +130,7 @@ _swrast_culltriangle( GLcontext *ctx,
 #define T_SCALE theight
 
 #define SETUP_CODE                                                     \
-   struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];\
+   struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[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;           \
@@ -139,8 +139,7 @@ _swrast_culltriangle( GLcontext *ctx,
    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 */                                      \
+   if (!rb || !texture) {                                              \
       return;                                                          \
    }
 
@@ -182,7 +181,7 @@ _swrast_culltriangle( GLcontext *ctx,
 #define T_SCALE theight
 
 #define SETUP_CODE                                                     \
-   struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];\
+   struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[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;           \
@@ -191,8 +190,7 @@ _swrast_culltriangle( GLcontext *ctx,
    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 */                                      \
+   if (!rb || !texture) {                                              \
       return;                                                          \
    }
 
index cded4a6c1c414a1715f66b365efe8162a06bfec6..8e3c5b5eebb189d9cedf353ae0ff0628bb905251 100644 (file)
@@ -234,18 +234,18 @@ static void NAME(GLcontext *ctx, const SWvertex *v0,
    /* compute area, oneOverArea and perform backface culling */
    {
       const GLfloat area = eMaj.dx * eBot.dy - eBot.dx * eMaj.dy;
-      /* Do backface culling */
-      if (area * bf < 0.0)
-         return;
 
       if (IS_INF_OR_NAN(area) || area == 0.0F)
          return;
 
-      oneOverArea = 1.0F / area;
-   }
+      if (area * bf * swrast->_BackfaceCullSign < 0.0)
+         return;
 
+      oneOverArea = 1.0F / area;
 
-   span.facing = ctx->_Facing; /* for 2-sided stencil test */
+      /* 0 = front, 1 = back */
+      span.facing = oneOverArea * bf > 0.0F;
+   }
 
    /* Edge setup.  For a triangle strip these could be reused... */
    {
index 48b4d1e24071b42427f78311be5ecbc8cac73ed6..a48eae19259c6b90d435a897b67f6b950cc73756 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.2
+ * Version:  7.1
  *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -130,8 +130,8 @@ static void
 zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span,
            const GLvoid *src, GLenum format )
 {
+   SWcontext *swrast = SWRAST_CONTEXT(ctx);
    SWspan zoomed;
-   SWspanarrays zoomed_arrays;  /* this is big! */
    GLint x0, x1, y0, y1;
    GLint zoomedWidth;
 
@@ -140,6 +140,13 @@ zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span,
       return;  /* totally clipped */
    }
 
+   if (!swrast->ZoomedArrays) {
+      /* allocate on demand */
+      swrast->ZoomedArrays = (SWspanarrays *) CALLOC(sizeof(SWspanarrays));
+      if (!swrast->ZoomedArrays)
+         return;
+   }
+
    zoomedWidth = x1 - x0;
    ASSERT(zoomedWidth > 0);
    ASSERT(zoomedWidth <= MAX_WIDTH);
@@ -151,14 +158,14 @@ zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span,
    INIT_SPAN(zoomed, GL_BITMAP);
    zoomed.x = x0;
    zoomed.end = zoomedWidth;
-   zoomed.array = &zoomed_arrays;
-   zoomed_arrays.ChanType = span->array->ChanType;
-   if (zoomed_arrays.ChanType == GL_UNSIGNED_BYTE)
-      zoomed_arrays.rgba = (GLchan (*)[4]) zoomed_arrays.rgba8;
-   else if (zoomed_arrays.ChanType == GL_UNSIGNED_SHORT)
-      zoomed_arrays.rgba = (GLchan (*)[4]) zoomed_arrays.rgba16;
+   zoomed.array = swrast->ZoomedArrays;
+   zoomed.array->ChanType = span->array->ChanType;
+   if (zoomed.array->ChanType == GL_UNSIGNED_BYTE)
+      zoomed.array->rgba = (GLchan (*)[4]) zoomed.array->rgba8;
+   else if (zoomed.array->ChanType == GL_UNSIGNED_SHORT)
+      zoomed.array->rgba = (GLchan (*)[4]) zoomed.array->rgba16;
    else
-      zoomed_arrays.rgba = (GLchan (*)[4]) zoomed_arrays.attribs[FRAG_ATTRIB_COL0];
+      zoomed.array->rgba = (GLchan (*)[4]) zoomed.array->attribs[FRAG_ATTRIB_COL0];
 
    COPY_4V(zoomed.attrStart[FRAG_ATTRIB_WPOS], span->attrStart[FRAG_ATTRIB_WPOS]);
    COPY_4V(zoomed.attrStepX[FRAG_ATTRIB_WPOS], span->attrStepX[FRAG_ATTRIB_WPOS]);
diff --git a/src/mesa/swrast/sources b/src/mesa/swrast/sources
deleted file mode 100644 (file)
index 9ffd4cc..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-# List of source files in this directory used for X.org xserver build
-MESA_SWRAST_SOURCES = \
-s_aaline.c \
-s_aatriangle.c \
-s_accum.c \
-s_alpha.c \
-s_arbshader.c \
-s_atifragshader.c \
-s_bitmap.c \
-s_blend.c \
-s_blit.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_points.c \
-s_readpix.c \
-s_span.c \
-s_stencil.c \
-s_texcombine.c \
-s_texfilter.c \
-s_texstore.c \
-s_triangle.c \
-s_zoom.c
-
-MESA_SWRAST_HEADERS = \
-s_aaline.h \
-s_aalinetemp.h \
-s_aatriangle.h \
-s_aatritemp.h \
-s_accum.h \
-s_alpha.h \
-s_arbshader.h \
-s_atifragshader.h \
-s_blend.h \
-s_context.h \
-s_depth.h \
-s_drawpix.h \
-s_feedback.h \
-s_fog.h \
-s_lines.h \
-s_linetemp.h \
-s_logic.h \
-s_masking.h \
-s_nvfragprog.h \
-s_points.h \
-s_pointtemp.h \
-s_span.h \
-s_spantemp.h \
-s_stencil.h \
-s_texcombine.h \
-s_texfilter.h \
-s_triangle.h \
-s_trispan.h \
-s_tritemp.h \
-s_zoom.h \
-swrast.h
index 85a27fd55bf534cdce0011fa63f525cf7c4fcf6d..047f7991e645ce4a96bb60bc314530d33dff279a 100644 (file)
@@ -143,6 +143,13 @@ _swrast_Accum(GLcontext *ctx, GLenum op, GLfloat value);
 extern void
 _swrast_ResetLineStipple( GLcontext *ctx );
 
+/**
+ * Indicates front/back facing for subsequent points/lines when drawing
+ * unfilled polygons.  Needed for two-side stencil.
+ */
+extern void
+_swrast_SetFacing(GLcontext *ctx, GLuint facing);
+
 /* These will always render the correct point/line/triangle for the
  * current state.
  *
diff --git a/src/mesa/swrast_setup/descrip.mms b/src/mesa/swrast_setup/descrip.mms
new file mode 100644 (file)
index 0000000..32ffd80
--- /dev/null
@@ -0,0 +1,42 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen  joukj@hrem.nano.tudelft.nl
+# Last revision : 3 October 2007
+
+.first
+       define gl [---.include.gl]
+       define math [-.math]
+       define tnl [-.tnl]
+       define vbo [-.vbo]
+       define swrast [-.swrast]
+       define array_cache [-.array_cache]
+       define glapi [-.glapi]
+       define main [-.main]
+
+.include [---]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [---.include],[-.main],[-.glapi]
+LIBDIR = [---.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)/float=ieee/ieee=denorm
+
+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/src/mesa/swrast_setup/sources b/src/mesa/swrast_setup/sources
deleted file mode 100644 (file)
index dee14b6..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-MESA_SWRAST_SETUP_SOURCES = \
-ss_context.c \
-ss_triangle.c
-
-MESA_SWRAST_SETUP_HEADERS = \
-ss_context.h \
-ss_triangle.h \
-ss_tritmp.h \
-ss_vb.h \
-swrast_setup.h
index fd6935e7be8ccc4d94bb3c458a9d6ccbf01757bf..4ed868ea60695167d94e88f8709c76a696d998ef 100644 (file)
@@ -201,6 +201,9 @@ _swsetup_RenderStart( GLcontext *ctx )
 
    swsetup->NewState = 0;
 
+   /* This will change if drawing unfilled tris */
+   _swrast_SetFacing(ctx, 0);
+
    _swrast_render_start(ctx);
 
    /* Important */
index 9fef7a52eca2bdcb30cbc5867054cdef0bb5703e..54e24c4c44e8d8ee35acd377dc3cc97ecd74e693 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.1
+ * Version:  7.1
  *
- * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -68,6 +68,8 @@ static void _swsetup_render_line_tri( GLcontext *ctx,
          return;
    }
 
+   _swrast_SetFacing(ctx, facing);
+
    if (ctx->Light.ShadeModel == GL_FLAT) {
       COPY_CHAN4(c[0], v0->color);
       COPY_CHAN4(c[1], v1->color);
@@ -127,6 +129,8 @@ static void _swsetup_render_point_tri( GLcontext *ctx,
          return;
    }
 
+   _swrast_SetFacing(ctx, facing);
+
    if (ctx->Light.ShadeModel == GL_FLAT) {
       /* save colors/indexes for v0, v1 vertices */
       COPY_CHAN4(c[0], v0->color);
@@ -290,10 +294,8 @@ void _swsetup_choose_trifuncs( GLcontext *ctx )
        ctx->Polygon.OffsetFill)
       ind |= SS_OFFSET_BIT;
 
-   /* Note: gl_FrontFacing lives in fragment input FOGC.Y at this time */
    if ((ctx->Light.Enabled && ctx->Light.Model.TwoSide) ||
-       (ctx->VertexProgram._Enabled && ctx->VertexProgram.TwoSideEnabled) ||
-       (ctx->FragmentProgram._Current && ctx->FragmentProgram._Current->Base.InputsRead & (1 << FRAG_ATTRIB_FOGC)))
+       (ctx->VertexProgram._Current && ctx->VertexProgram.TwoSideEnabled))
       ind |= SS_TWOSIDE_BIT;
 
    /* We piggyback the two-sided stencil front/back determination on the
@@ -311,6 +313,4 @@ void _swsetup_choose_trifuncs( GLcontext *ctx )
    tnl->Driver.Render.Quad = quad_tab[ind];
    tnl->Driver.Render.Line = swsetup_line;
    tnl->Driver.Render.Points = swsetup_points;
-
-   ctx->_Facing = 0;
 }
index f6b738d60dfc2d3ffb383faaf65ddb885c059cc6..97d2f4a16b19d60604de2bc4d5b7294c301d4692 100644 (file)
@@ -49,7 +49,6 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
    v[1] = &verts[e1];
    v[2] = &verts[e2];
 
-
    if (IND & (SS_TWOSIDE_BIT | SS_OFFSET_BIT | SS_UNFILLED_BIT))
    {
       GLfloat ex = v[0]->attrib[FRAG_ATTRIB_WPOS][0] - v[2]->attrib[FRAG_ATTRIB_WPOS][0];
@@ -61,7 +60,6 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
       if (IND & (SS_TWOSIDE_BIT | SS_UNFILLED_BIT))
       {
         facing = (cc < 0.0) ^ ctx->Polygon._FrontBit;
-         ctx->_Facing = facing;
 
         if (IND & SS_UNFILLED_BIT)
            mode = facing ? ctx->Polygon.BackMode : ctx->Polygon.FrontMode;
@@ -238,14 +236,16 @@ static void TAG(quadfunc)( GLcontext *ctx, GLuint v0,
 {
    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;
+      if (VB->EdgeFlag) { /* XXX this test shouldn't be needed (bug 12614) */
+         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 );
diff --git a/src/mesa/tnl/descrip.mms b/src/mesa/tnl/descrip.mms
new file mode 100644 (file)
index 0000000..f77f672
--- /dev/null
@@ -0,0 +1,67 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen  joukj@hrem.nano.tudelft.nl
+# Last revision : 30 November 2007
+
+.first
+       define gl [---.include.gl]
+       define math [-.math]
+       define vbo [-.vbo]
+       define shader [-.shader]
+       define swrast [-.swrast]
+       define array_cache [-.array_cache]
+       define main [-.main]
+       define glapi [-.glapi]
+       define tnl [-.tnl]
+
+.include [---]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [---.include],[-.main],[-.glapi],[-.shader],[-.shader.slang]
+LIBDIR = [---.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)/float=ieee/ieee=denorm
+
+SOURCES = t_context.c t_draw.c \
+       t_pipeline.c t_vb_fog.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_vertex.c \
+       t_vertex_generic.c t_vp_build.c
+
+OBJECTS = t_context.obj,t_draw.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_vertex.obj,t_vertex_generic.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_context.obj : t_context.c
+t_draw.obj : t_draw.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_vertex.obj : t_vertex.c
+t_vertex_generic.obj : t_vertex_generic.c
+t_vp_build.obj : t_vp_build.c
diff --git a/src/mesa/tnl/sources b/src/mesa/tnl/sources
deleted file mode 100644 (file)
index a0888be..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-# List of source files in this directory used for X.org xserver build
-MESA_TNL_SOURCES = \
-t_context.c \
-t_pipeline.c \
-t_vb_arbprogram.c \
-t_vb_arbprogram_sse.c \
-t_vb_arbshader.c \
-t_vb_cull.c \
-t_vb_fog.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_vertex.c \
-t_vertex_generic.c \
-t_vertex_sse.c \
-t_vp_build.c 
-
-MESA_TNL_HEADERS = \
-t_array_api.h \
-t_array_import.h \
-t_context.h \
-t_pipeline.h \
-t_vb_arbprogram.h \
-t_vb_cliptmp.h \
-t_vb_lighttmp.h \
-t_vb_rendertmp.h \
-t_vertex.h \
-t_vp_build.h \
-tnl.h
index 0ace5c2d6f182f9994cf2189d2c10b48cafc1b4f..dd590917701693e321300ebb16c80ffaf36a4256 100644 (file)
@@ -104,10 +104,10 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state )
    const struct gl_vertex_program *vp = ctx->VertexProgram._Current;
    const struct gl_fragment_program *fp = ctx->FragmentProgram._Current;
 
-   if (new_state & (_NEW_HINT)) {
+   if (new_state & (_NEW_HINT | _NEW_PROGRAM)) {
       ASSERT(tnl->AllowVertexFog || tnl->AllowPixelFog);
-      tnl->_DoVertexFog = (tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST))
-         || !tnl->AllowPixelFog;
+      tnl->_DoVertexFog = ((tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST))
+         || !tnl->AllowPixelFog) && !fp;
    }
 
    tnl->pipeline.new_state |= new_state;
@@ -201,8 +201,8 @@ _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;
+   tnl->_DoVertexFog = ((tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST))
+      || !tnl->AllowPixelFog) && !ctx->FragmentProgram._Current;
 
 }
 
@@ -211,7 +211,7 @@ _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;
+   tnl->_DoVertexFog = ((tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST))
+      || !tnl->AllowPixelFog) && !ctx->FragmentProgram._Current;
 }
 
index a1a46f6b82739a171dcaa43a0e3e03b8ad266dc2..173deff09c4b8ee1ed3f32529180b156e8f394bb 100644 (file)
@@ -1,9 +1,8 @@
-
 /*
  * Mesa 3-D graphics library
- * Version:  6.5
+ * Version:  7.1
  *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -368,7 +367,7 @@ void _tnl_draw_prims( GLcontext *ctx,
                        _tnl_draw_prims );
       return;
    }
-   else if (max_index >= max) {
+   else if (max_index > max) {
       /* The software TNL pipeline has a fixed amount of storage for
        * vertices and it is necessary to split incoming drawing commands
        * if they exceed that limit.
index 2a0ed8852a2b027ba986da59cc85b199622d1308..357ef1e24b5bf4914fe2b3e3b4e31d86eb314ae3 100644 (file)
@@ -199,11 +199,11 @@ 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,
    &_tnl_vertex_program_stage, 
+   &_tnl_fog_coordinate_stage,
    &_tnl_render_stage,
    NULL 
 };
index 00c0979f3f627b1c05a575d89656eb760b1bc12f..f3a7bd49f40189a4ca81ebc92e0365a9d315138a 100644 (file)
@@ -41,7 +41,6 @@
 
 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)
@@ -91,7 +90,8 @@ init_static_data( void )
  * 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.
+ * Note that fogcoords may be negative, if eye z is source absolute
+ * value must be taken earlier.
  * Fog blend factors are in the range [0,1].
  */
 static void
@@ -148,11 +148,11 @@ run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
    struct fog_stage_data *store = FOG_STAGE_DATA(stage);
    GLvector4f *input;
 
-   if (!ctx->Fog.Enabled || ctx->VertexProgram._Current)
-      return GL_TRUE;
 
+   if (!ctx->Fog.Enabled)
+      return GL_TRUE;
 
-   if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT) {
+   if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT && !ctx->VertexProgram._Current) {
       GLuint i;
       GLfloat *coord;
       /* Fog is computed from vertex or fragment Z values */
@@ -169,13 +169,10 @@ run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
          */
         input = &store->fogcoord;
 
-         /* NOTE: negate plane here so we get positive fog coords! */
-        /* NOTE2: this doesn't always work (tests/fog - all frag depth fog
-           coords will be negative). */
-        plane[0] = -m[2];
-        plane[1] = -m[6];
-        plane[2] = -m[10];
-        plane[3] = -m[14];
+        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.
          */
@@ -189,12 +186,12 @@ run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
            NOTE should avoid going through array twice */
         coord = input->start;
         for (i = 0; i < input->count; i++) {
-           input->data[i][0] = FABSF(*coord);
+           *coord = FABSF(*coord);
            STRIDE_F(coord, input->stride);
         }
       }
       else {
-         /* fog coordinates = eye Z coordinates (use ABS later) */
+         /* fog coordinates = eye Z coordinates - need to copy for ABS */
         input = &store->fogcoord;
 
         if (VB->EyePtr->size < 2)
@@ -249,7 +246,6 @@ alloc_fog_data(GLcontext *ctx, struct tnl_pipeline_stage *stage)
       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();
index c778f5d2488204ce3fba0836a5eb620defa0a0c3..f99401ca6d870f09657ae26c72d4afb82fe7ce1b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.3
+ * Version:  7.1
  *
  * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
 #include "swrast/s_context.h"
 #include "swrast/s_texfilter.h"
 
-#include "tnl.h"
-#include "t_context.h"
-#include "t_pipeline.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/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 results[VERT_RESULT_MAX];
+
+   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))
+
+
+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(GLcontext *ctx, struct vp_stage_data *store)
+{
+   TNLcontext *tnl = TNL_CONTEXT(ctx);
+   struct vertex_buffer *VB = &tnl->vb;
+   /* Cliptest and perspective divide.  Clip functions must clear
+    * the clipmask.
+    */
+   store->ormask = 0;
+   store->andmask = CLIP_FRUSTUM_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;
+   }
+
+   /* Test userclip planes.  This contributes to VB->ClipMask.
+    */
+   /** XXX NEW_SLANG _Enabled ??? */
+   if (ctx->Transform.ClipPlanesEnabled && (!ctx->VertexProgram._Enabled ||
+      ctx->VertexProgram.Current->IsPositionInvariant)) {
+      userclip( 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;
+}
 
 
 /**
  * real dependencies on the rest of swrast.  It should probably be
  * moved into main/ someday.
  */
-
 static void
 vp_fetch_texel(GLcontext *ctx, const GLfloat texcoord[4], GLfloat lambda,
                GLuint unit, GLfloat color[4])
@@ -85,22 +204,6 @@ _tnl_program_string(GLcontext *ctx, GLenum target, struct gl_program *program)
 }
 
 
-/*!
- * Private storage for the vertex program pipeline stage.
- */
-struct vp_stage_data {
-   /** The results of running the vertex program go into these arrays. */
-   GLvector4f results[VERT_RESULT_MAX];
-
-   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))
-
-
 /**
  * Initialize virtual machine state prior to executing vertex program.
  */
@@ -139,96 +242,50 @@ init_machine(GLcontext *ctx, struct gl_program_machine *machine)
 
    machine->FetchTexelLod = vp_fetch_texel;
    machine->FetchTexelDeriv = NULL; /* not used by vertex programs */
+
+   machine->Samplers = ctx->VertexProgram._Current->Base.SamplerUnits;
 }
 
 
 /**
- * Copy the 16 elements of a matrix into four consecutive program
- * registers starting at 'pos'.
+ * Map the texture images which the vertex program will access (if any).
  */
 static void
-load_matrix(GLfloat registers[][4], GLuint pos, const GLfloat mat[16])
+map_textures(GLcontext *ctx, const struct gl_vertex_program *vp)
 {
-   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];
-   }
-}
+   GLuint u;
 
+   if (!ctx->Driver.MapTexture)
+      return;
 
-/**
- * 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));
+   for (u = 0; u < ctx->Const.MaxVertexTextureImageUnits; u++) {
+      if (vp->Base.TexturesUsed[u]) {
+         /* Note: _Current *should* correspond to the target indicated
+          * in TexturesUsed[u].
+          */
+         ctx->Driver.MapTexture(ctx, ctx->Texture.Unit[u]._Current);
+      }
+   }
 }
 
 
 /**
- * Load current vertex program's parameter registers with tracked
- * matrices (if NV program).  This only needs to be done per
- * glBegin/glEnd, not per-vertex.
+ * Unmap the texture images which were used by the vertex program (if any).
  */
-void
-_mesa_load_tracked_matrices(GLcontext *ctx)
+static void
+unmap_textures(GLcontext *ctx, const struct gl_vertex_program *vp)
 {
-   GLuint i;
+   GLuint u;
 
-   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;
-      }
+   if (!ctx->Driver.MapTexture)
+      return;
 
-      /* load the matrix values into sequential registers */
-      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);
+   for (u = 0; u < ctx->Const.MaxVertexTextureImageUnits; u++) {
+      if (vp->Base.TexturesUsed[u]) {
+         /* Note: _Current *should* correspond to the target indicated
+          * in TexturesUsed[u].
+          */
+         ctx->Driver.UnmapTexture(ctx, ctx->Texture.Unit[u]._Current);
       }
    }
 }
@@ -259,6 +316,7 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
       _mesa_load_state_parameters(ctx, program->Base.Parameters);
    }
 
+   /* make list of outputs to save some time below */
    numOutputs = 0;
    for (i = 0; i < VERT_RESULT_MAX; i++) {
       if (program->Base.OutputsWritten & (1 << i)) {
@@ -266,6 +324,8 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
       }
    }
 
+   map_textures(ctx, program);
+
    for (i = 0; i < VB->Count; i++) {
       GLuint attr;
 
@@ -317,6 +377,8 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
 #endif
    }
 
+   unmap_textures(ctx, program);
+
    /* Fixup fog and point size results if needed */
    if (program->IsNVProgram) {
       if (ctx->Fog.Enabled &&
@@ -334,12 +396,39 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
       }
    }
 
-   /* Setup the VB pointers so that the next pipeline stages get
-    * their data from the right place (the program output arrays).
-    */
-   VB->ClipPtr = &store->results[VERT_RESULT_HPOS];
-   VB->ClipPtr->size = 4;
-   VB->ClipPtr->count = VB->Count;
+   if (program->IsPositionInvariant) {
+      /* We need the exact same transform as in the fixed function path here
+       * to guarantee invariance, depending on compiler optimization flags
+       * results could be different otherwise.
+       */
+      VB->ClipPtr = TransformRaw( &store->results[0],
+                                 &ctx->_ModelProjectMatrix,
+                                 VB->AttribPtr[0] );
+
+      /* 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;
+      }
+   }
+   else {
+      /* Setup the VB pointers so that the next pipeline stages get
+       * their data from the right place (the program output arrays).
+       */
+      VB->ClipPtr = &store->results[VERT_RESULT_HPOS];
+      VB->ClipPtr->size = 4;
+      VB->ClipPtr->count = VB->Count;
+   }
+
    VB->ColorPtr[0] = &store->results[VERT_RESULT_COL0];
    VB->ColorPtr[1] = &store->results[VERT_RESULT_BFC0];
    VB->SecondaryColorPtr[0] = &store->results[VERT_RESULT_COL1];
@@ -365,41 +454,10 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
       }
    }
 
-   /* Cliptest and perspective divide.  Clip functions must clear
-    * the clipmask.
-    */
-   store->ormask = 0;
-   store->andmask = CLIP_FRUSTUM_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.
+   /* Perform NDC and cliptest operations:
     */
-
-   VB->ClipOrMask = store->ormask;
-   VB->ClipMask = store->clipmask;
-
-   return GL_TRUE;
+   return do_ndc_cliptest(ctx, store);
 }
 
 
index 96def25206bf17c4c0bf1c76a0b1636174d63bf0..53a6e55f4bf662a4618b074a12087ed86c4dd4f2 100644 (file)
 #include "x86/common_x86_asm.h"
 
 
+/**
+ * Number of bytes to allocate for generated SSE functions
+ */
+#define MAX_SSE_CODE_SIZE 1024
+
+
 #define X    0
 #define Y    1
 #define Z    2
@@ -619,7 +625,10 @@ static GLboolean build_vertex_emit( struct x86_program *p )
    x86_pop(&p->func, countEBP);
    x86_ret(&p->func);
 
+   assert(!vtx->emit);
    vtx->emit = (tnl_emit_func)x86_get_func(&p->func);
+
+   assert( (char *) p->func.csr - (char *) p->func.store <= MAX_SSE_CODE_SIZE );
    return GL_TRUE;
 }
 
@@ -644,7 +653,10 @@ void _tnl_generate_sse_emit( GLcontext *ctx )
    p.identity = x86_make_reg(file_XMM, 6);
    p.chan0 = x86_make_reg(file_XMM, 7);
 
-   x86_init_func(&p.func);
+   if (!x86_init_func_size(&p.func, MAX_SSE_CODE_SIZE)) {
+      vtx->emit = NULL;
+      return;
+   }
 
    if (build_vertex_emit(&p)) {
       _tnl_register_fastpath( vtx, GL_TRUE );
index b3b63cd3e4a2d94f01612720d5f09656e4a40fe0..7be4d95af6b6c121a48331109443529b2c833fbc 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5
+ * Version:  7.1
  *
- * Copyright (C) 2006  Tungsten Graphics   All Rights Reserved.
+ * Copyright (C) 2007  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"),
index 4bdbed92df805920e33ed7a8a175cc729bb48f89..4d628aa9a607726e50b3ed71affb07f0e5068a3b 100644 (file)
@@ -1,9 +1,8 @@
-
 /*
  * Mesa 3-D graphics library
- * Version:  3.5
+ * Version:  7.1
  *
- * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
index 0bf32ff3443cf3242e4ea25376237a5326ca8a37..1ae70f4059f221c252b991e3b1dd0aa2502b8ec5 100644 (file)
@@ -155,10 +155,6 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
       {
         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;
@@ -271,7 +267,7 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
            GLfloat bc  = b * ic;
            if ( ac < 0.0f ) ac = -ac;
            if ( bc < 0.0f ) bc = -bc;
-           offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor;
+           offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor / ctx->DrawBuffer->_MRD;
         }
         offset *= ctx->DrawBuffer->_MRD * (REVERSE_DEPTH ? -1.0 : 1.0);
       }
@@ -393,7 +389,7 @@ static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
 
 #if DO_QUAD
 #if DO_FULL_QUAD
-static void TAG(quad)( GLcontext *ctx,
+static void TAG(quadr)( GLcontext *ctx,
                       GLuint e0, GLuint e1, GLuint e2, GLuint e3 )
 {
    struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
@@ -421,10 +417,6 @@ static void TAG(quad)( GLcontext *ctx,
       {
         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;
@@ -547,7 +539,7 @@ static void TAG(quad)( GLcontext *ctx,
            GLfloat bc  = b * ic;
            if ( ac < 0.0f ) ac = -ac;
            if ( bc < 0.0f ) bc = -bc;
-           offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor;
+           offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor / ctx->DrawBuffer->_MRD;
         }
         offset *= ctx->DrawBuffer->_MRD * (REVERSE_DEPTH ? -1.0 : 1.0);
       }
@@ -681,7 +673,7 @@ static void TAG(quad)( GLcontext *ctx,
    }
 }
 #else
-static void TAG(quad)( GLcontext *ctx, GLuint e0,
+static void TAG(quadr)( GLcontext *ctx, GLuint e0,
                       GLuint e1, GLuint e2, GLuint e3 )
 {
    if (DO_UNFILLED) {
@@ -773,7 +765,7 @@ static void TAG(points)( GLcontext *ctx, GLuint first, GLuint last )
 static void TAG(init)( void )
 {
 #if DO_QUAD
-   TAB[IND].quad = TAG(quad);
+   TAB[IND].quad = TAG(quadr);
 #endif
 #if DO_TRI
    TAB[IND].triangle = TAG(triangle);
diff --git a/src/mesa/vbo/descrip.mms b/src/mesa/vbo/descrip.mms
new file mode 100644 (file)
index 0000000..c2a16a0
--- /dev/null
@@ -0,0 +1,62 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen  joukj@hrem.nano.tudelft.nl
+# Last revision : 3 October 2007
+
+.first
+       define gl [---.include.gl]
+       define math [-.math]
+       define vbo [-.vbo]
+       define tnl [-.tnl]
+       define shader [-.shader]
+       define swrast [-.swrast]
+       define swrast_setup [-.swrast_setup]
+       define main [-.main]
+       define glapi [-.glapi]
+
+.include [---]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [---.include],[-.main],[-.glapi],[-.shader],[-.shader.slang]
+LIBDIR = [---.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)/float=ieee/ieee=denorm
+
+SOURCES =vbo_context.c,vbo_exec.c,vbo_exec_api.c,vbo_exec_array.c,\
+       vbo_exec_draw.c,vbo_exec_eval.c,vbo_rebase.c,vbo_save.c,\
+       vbo_save_api.c,vbo_save_draw.c,vbo_save_loopback.c,\
+       vbo_split.c,vbo_split_copy.c,vbo_split_inplace.c
+
+OBJECTS =vbo_context.obj,vbo_exec.obj,vbo_exec_api.obj,vbo_exec_array.obj,\
+       vbo_exec_draw.obj,vbo_exec_eval.obj,vbo_rebase.obj,vbo_save.obj,\
+       vbo_save_api.obj,vbo_save_draw.obj,vbo_save_loopback.obj,\
+       vbo_split.obj,vbo_split_copy.obj,vbo_split_inplace.obj
+
+##### RULES #####
+
+VERSION=Mesa V3.4
+
+##### TARGETS #####
+# Make the library
+$(LIBDIR)$(GL_LIB) : $(OBJECTS)
+  @ library $(LIBDIR)$(GL_LIB) $(OBJECTS)
+
+clean :
+       purge
+       delete *.obj;*
+
+vbo_context.obj : vbo_context.c
+vbo_exec.obj : vbo_exec.c
+vbo_exec_api.obj : vbo_exec_api.c
+vbo_exec_array.obj : vbo_exec_array.c
+vbo_exec_draw.obj : vbo_exec_draw.c
+vbo_exec_eval.obj : vbo_exec_eval.c
+vbo_rebase.obj : vbo_rebase.c
+vbo_save.obj : vbo_save.c
+vbo_save_api.obj : vbo_save_api.c
+vbo_save_draw.obj : vbo_save_draw.c
+vbo_save_loopback.obj : vbo_save_loopback.c
+vbo_split.obj : vbo_split.c
+vbo_split_copy.obj : vbo_split_copy.c
+vbo_split_inplace.obj : vbo_split_inplace.c
index b452ac8a38e2ef1f057f81a72fb54533f6b49d58..bbf745b0c629bf1f25b5b1350ffd755545851d3e 100644 (file)
@@ -114,6 +114,8 @@ static void init_mat_currval(GLcontext *ctx)
    struct gl_client_array *arrays = vbo->mat_currval;
    GLuint i;
 
+   ASSERT(NR_MAT_ATTRIBS == MAT_ATTRIB_MAX);
+
    memset(arrays, 0, sizeof(*arrays) * NR_MAT_ATTRIBS);
 
    /* Set up a constant (StrideB == 0) array for each current
@@ -139,11 +141,7 @@ static void init_mat_currval(GLcontext *ctx)
         break;
       }
 
-      if (i < MAT_ATTRIB_MAX)
-        cl->Ptr = (const void *)ctx->Light.Material.Attrib[i];
-      else 
-        cl->Ptr = (const void *)ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + i];
-
+      cl->Ptr = (const void *)ctx->Light.Material.Attrib[i];
       cl->Type = GL_FLOAT;
       cl->Stride = 0;
       cl->StrideB = 0;
index f497e9a5a55f454f1da2b8326a5be6e362c89bf4..7ec431a237694770771cb14768dbc6a994c330a8 100644 (file)
@@ -200,6 +200,7 @@ static void vbo_exec_bind_arrays( GLcontext *ctx )
             /* Ptr into ordinary app memory */
             arrays[attr].Ptr = (void *) data;
          }
+
         arrays[attr].Size = exec->vtx.attrsz[src];
         arrays[attr].StrideB = exec->vtx.vertex_size * sizeof(GLfloat);
         arrays[attr].Stride = exec->vtx.vertex_size * sizeof(GLfloat);
index e5c4429350e49e99a33df34c7ad8f84b5db8ed97..685cc0fdf6e003eedadfc9e0c4c7e2d50dece62c 100644 (file)
@@ -129,6 +129,13 @@ static GLuint attr_size( const struct gl_client_array *array )
  */
 static GLboolean check_flush( struct copy_context *copy )
 {
+   GLenum mode = copy->dstprim[copy->dstprim_nr].mode; 
+
+   if (GL_TRIANGLE_STRIP == mode &&
+       copy->dstelt_nr & 1) { /* see bug9962 */
+       return GL_FALSE;
+   }
+
    if (copy->dstbuf_nr + 4 > copy->dstbuf_size)
       return GL_TRUE;
 
@@ -458,7 +465,7 @@ static void replay_init( struct copy_context *copy )
       dst->StrideB = copy->vertex_size;
       dst->Ptr = copy->dstbuf + offset;
       dst->Enabled = GL_TRUE;
-      dst->Normalized = GL_TRUE;
+      dst->Normalized = src->Normalized; 
       dst->BufferObj = ctx->Array.NullBufferObj;
       dst->_MaxElement = copy->dstbuf_size; /* may be less! */
 
index ab58aa6c23dde091e7a414ef188b6b7ff65dede1..9c3e9d2adf81f032844df77cf0faecc8f170eeff 100644 (file)
@@ -19,7 +19,7 @@ INCLUDE_DIRS = \
 default: matypes.h
 
 clean:
-       rm -f matypes.h
+       -rm -f matypes.h
 
 
 # need some special rules here, unfortunately
index 667ecf6e589ac328de5c2ed0de3ef1f869fcecec..3f9c9d56ab7dcfdeae89aaa074b15fbd6be3246c 100644 (file)
@@ -1,9 +1,8 @@
-
 /*
  * Mesa 3-D graphics library
- * Version:  3.5
+ * Version:  7.1
  *
- * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -63,7 +62,7 @@ _mesa_x86_64_transform_points4_general:
 
 p4_general_loop:
 
-       movaps (%rdx), %xmm8            /* ox | oy | oz | ow */
+       movups (%rdx), %xmm8            /* ox | oy | oz | ow */
        prefetchw 16(%rdi)
 
        pshufd $0x00, %xmm8, %xmm0      /* ox | ox | ox | ox */
@@ -148,7 +147,7 @@ _mesa_x86_64_transform_points4_3d:
 
 p4_3d_loop:
 
-       movaps (%rdx), %xmm8            /* ox | oy | oz | ow */
+       movups (%rdx), %xmm8            /* ox | oy | oz | ow */
        prefetchw 16(%rdi)
 
        pshufd $0x00, %xmm8, %xmm0      /* ox | ox | ox | ox */
index 09481dc509456b3ed3ca17fcc15f05a779e5f369..aa49a9134aa0ea219c79fb4f24caf57e9e5fc5df 100644 (file)
@@ -17,7 +17,7 @@ INCLUDE_DIRS = \
 default: gen_matypes matypes.h
 
 clean:
-       rm -f matypes.h gen_matypes
+       -rm -f matypes.h gen_matypes
 
 
 gen_matypes: gen_matypes.c
index 3cbcd719960e13b7d8739e9cdb8a2404677411fa..80144b889c72e5b41c12c6934cfeed2eab5a7295 100644 (file)
        .file   "read_rgba_span_x86.S"
 #if !defined(__DJGPP__) && !defined(__MINGW32__) /* this one cries for assyntax.h */
 /* Kevin F. Quinn 2nd July 2006
- * Replace data segment constants with text-segment instructions
-       .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
+ * Replaced data segment constants with text-segment instructions.
  */
 #define        LOAD_MASK(mvins,m1,m2) \
        pushl   $0xff00ff00 ;\
@@ -61,8 +48,7 @@ mask:
        mvins   (%esp), m2      ;\
        addl    $32, %esp
 
-
-/* I implemented these as macros because the appear in quite a few places,
+/* I implemented these as macros because they appear in several places,
  * and I've tweaked them a number of times.  I got tired of changing every
  * place they appear. :)
  */
@@ -99,11 +85,6 @@ _generic_read_RGBA_span_BGRA8888_REV_MMX:
 #ifdef USE_INNER_EMMS
        emms
 #endif
-/* Kevin F. Quinn 2nd July 2006
- * Replace data segment constants with text-segment instructions
-       movq    mask, %mm1
-       movq    mask+16, %mm2
- */
        LOAD_MASK(movq,%mm1,%mm2)
 
        movl    8(%esp), %ebx   /* source pointer */
@@ -201,11 +182,7 @@ _generic_read_RGBA_span_BGRA8888_REV_SSE:
 #ifdef USE_INNER_EMMS
        emms
 #endif
-/* Kevin F. Quinn 2nd July 2006
- * Replace data segment constants with text-segment instructions
-       movq    mask, %mm1
-       movq    mask+16, %mm2
- */
+
        LOAD_MASK(movq,%mm1,%mm2)
 
        movl    16(%esp), %ebx  /* source pointer */
@@ -364,11 +341,6 @@ _generic_read_RGBA_span_BGRA8888_REV_SSE2:
        pushl   %esi
        pushl   %ebx
 
-/* Kevin F. Quinn 2nd July 2006
- * Replace data segment constants with text-segment instructions
-       movdqa  mask, %xmm1
-       movdqa  mask+16, %xmm2
- */
        LOAD_MASK(movdqu,%xmm1,%xmm2)
 
        movl    12(%esp), %ebx  /* source pointer */
@@ -462,7 +434,8 @@ _generic_read_RGBA_span_BGRA8888_REV_SSE2:
        je      .L47
 
        movq    (%ebx), %xmm0
-
+       addl    $8, %ebx
+        
        movdqa  %xmm0, %xmm3
        movdqa  %xmm0, %xmm4
        andps   %xmm1, %xmm0
@@ -476,6 +449,7 @@ _generic_read_RGBA_span_BGRA8888_REV_SSE2:
        orps    %xmm3, %xmm0
 
        movq    %xmm0, (%ecx)
+       addl    $8, %ecx        
 .L47:
 
        testl   $1, %edx
@@ -491,60 +465,12 @@ _generic_read_RGBA_span_BGRA8888_REV_SSE2:
 
 
 
-/* Kevin F. Quinn 2nd July 2006
- * Replace data segment constants with text-segment instructions
- */
-#if 0
-       .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
-#endif
-
 #define MASK_565_L     0x07e0f800
 #define MASK_565_H     0x0000001f
+/* 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
 #define PRESCALE_L 0x00100001
@@ -581,23 +507,17 @@ _generic_read_RGBA_span_RGB565_MMX:
        movl    8(%esp), %edx   /* destination pointer */
        movl    12(%esp), %ecx  /* number of pixels to copy */
 
-/* Kevin F. Quinn 2nd July 2006
- * Replace data segment constants with text-segment instructions
-       movq    mask_565, %mm5
-       movq    prescale, %mm6
-       movq    scale, %mm7
- */
-       pushl   MASK_565_H
-       pushl   MASK_565_L
+       pushl   $MASK_565_H
+       pushl   $MASK_565_L
        movq    (%esp), %mm5
-       pushl   PRESCALE_H
-       pushl   PRESCALE_L
+       pushl   $PRESCALE_H
+       pushl   $PRESCALE_L
        movq    (%esp), %mm6
-       pushl   SCALE_H
-       pushl   SCALE_L
+       pushl   $SCALE_H
+       pushl   $SCALE_L
        movq    (%esp), %mm7
-       pushl   ALPHA_H
-       pushl   ALPHA_L
+       pushl   $ALPHA_H
+       pushl   $ALPHA_L
        movq    (%esp), %mm3
        addl    $32,%esp
 
@@ -648,11 +568,6 @@ _generic_read_RGBA_span_RGB565_MMX:
        /* Always set the alpha value to 0xff.
         */
 
-/* Kevin F. Quinn 2nd July 2006
- * Replace data segment constants with text-segment instructions
-       por     alpha, %mm0
-       por     alpha, %mm2
- */
        por %mm3, %mm0
        por %mm3, %mm2
 
@@ -665,8 +580,6 @@ _generic_read_RGBA_span_RGB565_MMX:
        movq    %mm0, (%edx)
        addl    $8, %edx
 
-
-
        pshufw  $0xaa, %mm4, %mm0
        pshufw  $0xff, %mm4, %mm2
 
@@ -681,11 +594,6 @@ _generic_read_RGBA_span_RGB565_MMX:
        pmulhuw %mm7, %mm0
        pmulhuw %mm7, %mm2
 
-/* Kevin F. Quinn 2nd July 2006
- * Replace data segment constants with text-segment instructions
-       por     alpha, %mm0
-       por     alpha, %mm2
- */
        por %mm3, %mm0
        por %mm3, %mm2
 
@@ -724,11 +632,6 @@ _generic_read_RGBA_span_RGB565_MMX:
        pmulhuw %mm7, %mm0
        pmulhuw %mm7, %mm2
 
-/* Kevin F. Quinn 2nd July 2006
- * Replace data segment constants with text-segment instructions
-       por     alpha, %mm0
-       por     alpha, %mm2
- */
        por %mm3, %mm0
        por %mm3, %mm2
 
@@ -757,10 +660,6 @@ _generic_read_RGBA_span_RGB565_MMX:
 #endif
        pmulhuw %mm7, %mm0
 
-/* Kevin F. Quinn 2nd July 2006
- * Replace data segment constants with text-segment instructions
-       por     alpha, %mm0
- */
        por %mm3, %mm0
 
        packuswb        %mm0, %mm0
index 5c4bab733128285978668013ef72f7cc41edf6a2..5aedf5b04beb16be24275f357c05908f2cf74983 100644 (file)
@@ -1162,11 +1162,12 @@ void x86_init_func( struct x86_function *p )
    p->csr = p->store;
 }
 
-void x86_init_func_size( struct x86_function *p, unsigned code_size )
+int x86_init_func_size( struct x86_function *p, unsigned code_size )
 {
    p->size = code_size;
    p->store = _mesa_exec_malloc(code_size);
    p->csr = p->store;
+   return p->store != NULL;
 }
 
 void x86_release_func( struct x86_function *p )
index c2aa416492ee54eade74a23ef4ea6ae58b63fb7c..f6282f5bd4151117e0e2a69df9199ee04cdf36ec 100644 (file)
@@ -80,7 +80,7 @@ enum sse_cc {
 
 
 void x86_init_func( struct x86_function *p );
-void x86_init_func_size( struct x86_function *p, unsigned code_size );
+int x86_init_func_size( struct x86_function *p, unsigned code_size );
 void x86_release_func( struct x86_function *p );
 void (*x86_get_func( struct x86_function *p ))( void );
 
diff --git a/windows/VC6/progs/glut/glut.dsp b/windows/VC6/progs/glut/glut.dsp
new file mode 100644 (file)
index 0000000..0a67689
--- /dev/null
@@ -0,0 +1,333 @@
+# Microsoft Developer Studio Project File - Name="glut" - Package Owner=<4>\r
+# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
+# ** DO NOT EDIT **\r
+\r
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102\r
+\r
+CFG=glut - Win32 Debug\r
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
+!MESSAGE use the Export Makefile command and run\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "glut.mak".\r
+!MESSAGE \r
+!MESSAGE You can specify a configuration when running NMAKE\r
+!MESSAGE by defining the macro CFG on the command line. For example:\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "glut.mak" CFG="glut - Win32 Debug"\r
+!MESSAGE \r
+!MESSAGE Possible choices for configuration are:\r
+!MESSAGE \r
+!MESSAGE "glut - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")\r
+!MESSAGE "glut - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")\r
+!MESSAGE \r
+\r
+# Begin Project\r
+# PROP AllowPerConfigDependencies 0\r
+# PROP Scc_ProjName ""\r
+# PROP Scc_LocalPath ""\r
+CPP=cl.exe\r
+MTL=midl.exe\r
+RSC=rc.exe\r
+\r
+!IF  "$(CFG)" == "glut - Win32 Release"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 0\r
+# PROP BASE Output_Dir "Release"\r
+# PROP BASE Intermediate_Dir "Release"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 0\r
+# PROP Output_Dir "Release"\r
+# PROP Intermediate_Dir "Release"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GLUT_EXPORTS" /YX /FD /c\r
+# 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\r
+# SUBTRACT CPP /YX\r
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
+# ADD BASE RSC /l 0x409 /d "NDEBUG"\r
+# ADD RSC /l 0x409 /d "NDEBUG"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# 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\r
+# 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"\r
+# Begin Special Build Tool\r
+SOURCE="$(InputPath)"\r
+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\r
+# End Special Build Tool\r
+\r
+!ELSEIF  "$(CFG)" == "glut - Win32 Debug"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 1\r
+# PROP BASE Output_Dir "Debug"\r
+# PROP BASE Intermediate_Dir "Debug"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 1\r
+# PROP Output_Dir "Debug"\r
+# PROP Intermediate_Dir "Debug"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# 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\r
+# 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\r
+# SUBTRACT CPP /YX\r
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32\r
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32\r
+# ADD BASE RSC /l 0x409 /d "_DEBUG"\r
+# ADD RSC /l 0x409 /d "_DEBUG"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# 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\r
+# 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"\r
+# Begin Special Build Tool\r
+SOURCE="$(InputPath)"\r
+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\r
+# End Special Build Tool\r
+\r
+!ENDIF \r
+\r
+# Begin Target\r
+\r
+# Name "glut - Win32 Release"\r
+# Name "glut - Win32 Debug"\r
+# Begin Group "Source Files"\r
+\r
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_8x13.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_9x15.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_bitmap.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_bwidth.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_cindex.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_cmap.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_cursor.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_dials.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_dstr.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_event.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_ext.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_fcb.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_fullscrn.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_gamemode.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_get.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_hel10.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_hel12.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_hel18.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_init.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_input.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_joy.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_key.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_keyctrl.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_keyup.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_mesa.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_modifier.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_mroman.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_overlay.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_roman.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_shapes.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_space.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_stroke.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_swap.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_swidth.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_tablet.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_teapot.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_tr10.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_tr24.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_util.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_vidresize.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_warp.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_win.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glut_winmisc.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\win32_glx.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\win32_menu.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\win32_util.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\win32_winproc.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\win32_x11.c\r
+# End Source File\r
+# End Group\r
+# Begin Group "Header Files"\r
+\r
+# PROP Default_Filter "h;hpp;hxx;hm;inl"\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glutbitmap.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glutint.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glutstroke.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\glutwin32.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\stroke.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\win32_glx.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\..\src\glut\glx\win32_x11.h\r
+# End Source File\r
+# End Group\r
+# Begin Group "Resource Files"\r
+\r
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
+# End Group\r
+# End Target\r
+# End Project\r
diff --git a/windows/VC7/mesa/gdi/gdi.vcproj b/windows/VC7/mesa/gdi/gdi.vcproj
new file mode 100644 (file)
index 0000000..0dc7892
--- /dev/null
@@ -0,0 +1,195 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="7.10"\r
+       Name="gdi"\r
+       SccProjectName=""\r
+       SccLocalPath="">\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"/>\r
+       </Platforms>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="2"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="FALSE"\r
+                       CharacterSet="2">\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/main,../../../../src/mesa/glapi,../../../../src/mesa/swrast,../../../../src/mesa/shader"\r
+                               PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;_USRDLL;GDI_EXPORTS;_DLL;BUILD_GL32;MESA_MINWARN"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="1"\r
+                               PrecompiledHeaderFile=".\Debug/gdi.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="3"\r
+                               SuppressStartupBanner="TRUE"\r
+                               DebugInformationFormat="3"\r
+                               CompileAs="0"/>\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"/>\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalOptions="/MACHINE:I386"\r
+                               AdditionalDependencies="mesa.lib winmm.lib msvcrtd.lib odbc32.lib odbccp32.lib"\r
+                               OutputFile="Debug/OPENGL32.DLL"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="TRUE"\r
+                               AdditionalLibraryDirectories="../mesa/Debug"\r
+                               IgnoreAllDefaultLibraries="TRUE"\r
+                               ModuleDefinitionFile="..\..\..\..\src\mesa\drivers\windows\gdi\mesa.def"\r
+                               GenerateDebugInformation="TRUE"\r
+                               ProgramDatabaseFile=".\Debug/OPENGL32.pdb"\r
+                               ImportLibrary=".\Debug/OPENGL32.lib"/>\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               MkTypLibCompatible="TRUE"\r
+                               SuppressStartupBanner="TRUE"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Debug/gdi.tlb"/>\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                               CommandLine="if not exist ..\..\..\..\lib md ..\..\..\..\lib\r
+copy Debug\OPENGL32.LIB ..\..\..\..\lib\r
+copy Debug\OPENGL32.DLL ..\..\..\..\lib\r
+if exist ..\..\..\..\progs\demos copy Debug\OPENGL32.DLL ..\..\..\..\progs\demos\r
+"/>\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"/>\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"/>\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1033"/>\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"/>\r
+                       <Tool\r
+                               Name="VCManagedWrapperGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCAuxiliaryManagedWrapperGeneratorTool"/>\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="2"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="FALSE"\r
+                       CharacterSet="2">\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="../../main,../../../../include,../../../../src/mesa,../../../../src/mesa/main,../../../../src/mesa/glapi,../../../../src/mesa/swrast,../../../../src/mesa/shader"\r
+                               PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;_USRDLL;GDI_EXPORTS;_DLL;BUILD_GL32;MESA_MINWARN"\r
+                               StringPooling="TRUE"\r
+                               RuntimeLibrary="0"\r
+                               EnableFunctionLevelLinking="TRUE"\r
+                               PrecompiledHeaderFile=".\Release/gdi.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               WarningLevel="3"\r
+                               SuppressStartupBanner="TRUE"\r
+                               CompileAs="0"/>\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"/>\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalOptions="/MACHINE:I386"\r
+                               AdditionalDependencies="mesa.lib winmm.lib msvcrt.lib odbc32.lib odbccp32.lib"\r
+                               OutputFile="Release/OPENGL32.DLL"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="TRUE"\r
+                               AdditionalLibraryDirectories="../mesa/Release"\r
+                               IgnoreAllDefaultLibraries="TRUE"\r
+                               ModuleDefinitionFile="..\..\..\..\src\mesa\drivers\windows\gdi\mesa.def"\r
+                               ProgramDatabaseFile=".\Release/OPENGL32.pdb"\r
+                               ImportLibrary=".\Release/OPENGL32.lib"/>\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               MkTypLibCompatible="TRUE"\r
+                               SuppressStartupBanner="TRUE"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Release/gdi.tlb"/>\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                               CommandLine="if not exist ..\..\..\..\lib md ..\..\..\..\lib\r
+copy Release\OPENGL32.LIB ..\..\..\..\lib\r
+copy Release\OPENGL32.DLL ..\..\..\..\lib\r
+if exist ..\..\..\..\progs\demos copy Release\OPENGL32.DLL ..\..\..\..\progs\demos\r
+"/>\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"/>\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"/>\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1033"/>\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"/>\r
+                       <Tool\r
+                               Name="VCManagedWrapperGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCAuxiliaryManagedWrapperGeneratorTool"/>\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\drivers\common\driverfuncs.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\drivers\windows\gdi\mesa.def">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\drivers\windows\gdi\wgl.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\drivers\windows\gdi\wmesa.c">\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl">\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\drivers\windows\gdi\colors.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\drivers\common\driverfuncs.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\drivers\windows\gdi\wmesadef.h">\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/windows/VC7/mesa/glu/glu.vcproj b/windows/VC7/mesa/glu/glu.vcproj
new file mode 100644 (file)
index 0000000..3f05731
--- /dev/null
@@ -0,0 +1,766 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="7.10"\r
+       Name="glu"\r
+       SccProjectName=""\r
+       SccLocalPath="">\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"/>\r
+       </Platforms>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="2"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="FALSE"\r
+                       CharacterSet="2">\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="../../../../include;../../../../src/glu/sgi/include;../../../../src/glu/sgi/libnurbs/interface;../../../../src/glu/sgi/libnurbs/internals;../../../../src/glu/sgi/libnurbs/nurbtess"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;GLU_EXPORTS;BUILD_GL32;LIBRARYBUILD"\r
+                               StringPooling="TRUE"\r
+                               RuntimeLibrary="0"\r
+                               EnableFunctionLevelLinking="TRUE"\r
+                               PrecompiledHeaderFile=".\Release/glu.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               WarningLevel="3"\r
+                               SuppressStartupBanner="TRUE"/>\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"/>\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalOptions="/MACHINE:I386"\r
+                               AdditionalDependencies="msvcrt.lib winmm.lib odbc32.lib odbccp32.lib opengl32.lib"\r
+                               OutputFile="Release/GLU32.DLL"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="TRUE"\r
+                               AdditionalLibraryDirectories="../gdi/Release"\r
+                               IgnoreAllDefaultLibraries="TRUE"\r
+                               ModuleDefinitionFile="..\..\..\..\src\glu\sgi\glu.def"\r
+                               ProgramDatabaseFile=".\Release/GLU32.pdb"\r
+                               ImportLibrary=".\Release/GLU32.lib"/>\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               MkTypLibCompatible="TRUE"\r
+                               SuppressStartupBanner="TRUE"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Release/glu.tlb"/>\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                               CommandLine="if not exist ..\..\..\..\lib md ..\..\..\..\lib\r
+copy Release\GLU32.LIB ..\..\..\..\lib\r
+copy Release\GLU32.DLL ..\..\..\..\lib\r
+if exist ..\..\..\..\progs\demos copy Release\GLU32.DLL ..\..\..\..\progs\demos\r
+"/>\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"/>\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"/>\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1033"/>\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"/>\r
+                       <Tool\r
+                               Name="VCManagedWrapperGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCAuxiliaryManagedWrapperGeneratorTool"/>\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="2"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="FALSE"\r
+                       CharacterSet="2">\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="../../../../include;../../../../src/glu/sgi/include;../../../../src/glu/sgi/libnurbs/interface;../../../../src/glu/sgi/libnurbs/internals;../../../../src/glu/sgi/libnurbs/nurbtess"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;GLU_EXPORTS;BUILD_GL32;LIBRARYBUILD"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="1"\r
+                               PrecompiledHeaderFile=".\Debug/glu.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               WarningLevel="3"\r
+                               SuppressStartupBanner="TRUE"\r
+                               DebugInformationFormat="3"/>\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"/>\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalOptions="/MACHINE:I386"\r
+                               AdditionalDependencies="msvcrtd.lib winmm.lib odbc32.lib odbccp32.lib opengl32.lib"\r
+                               OutputFile="Debug/GLU32.DLL"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="TRUE"\r
+                               AdditionalLibraryDirectories="../gdi/Debug"\r
+                               IgnoreAllDefaultLibraries="TRUE"\r
+                               ModuleDefinitionFile="..\..\..\..\src\glu\sgi\glu.def"\r
+                               GenerateDebugInformation="TRUE"\r
+                               ProgramDatabaseFile=".\Debug/GLU32.pdb"\r
+                               ImportLibrary=".\Debug/GLU32.lib"/>\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               MkTypLibCompatible="TRUE"\r
+                               SuppressStartupBanner="TRUE"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Debug/glu.tlb"/>\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                               CommandLine="if not exist ..\..\..\..\lib md ..\..\..\..\lib\r
+copy Debug\GLU32.LIB ..\..\..\..\lib\r
+copy Debug\GLU32.DLL ..\..\..\..\lib\r
+if exist ..\..\..\..\progs\demos copy Debug\GLU32.DLL ..\..\..\..\progs\demos\r
+"/>\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"/>\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"/>\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1033"/>\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"/>\r
+                       <Tool\r
+                               Name="VCManagedWrapperGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCAuxiliaryManagedWrapperGeneratorTool"/>\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\dict.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libutil\error.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\geom.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\glu.def">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libutil\glue.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\memalloc.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\mesh.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libutil\mipmap.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\normal.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\priorityq-heap.c">\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       ExcludedFromBuild="TRUE">\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"/>\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       ExcludedFromBuild="TRUE">\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"/>\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\priorityq.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libutil\project.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libutil\quad.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libutil\registry.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\render.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\sweep.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\tess.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\tessmono.c">\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl">\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\arc.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\arcsorter.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\arctess.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\backend.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\basiccrveval.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\basicsurfeval.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\bezierarc.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\bezierEval.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\bezierPatch.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\bezierPatchMesh.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\bin.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\bufpool.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\cachingeval.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\coveandtiler.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\curve.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\curvelist.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\dataTransform.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\defines.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\definitions.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\dict-list.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\dict.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\directedLine.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\displaylist.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\displaymode.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\flist.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\flistsorter.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\geom.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glcurveval.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glimports.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\glimports.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glrenderer.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glsurfeval.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libutil\gluint.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\include\gluos.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\gridline.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\gridtrimvertex.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\gridvertex.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\gridWrap.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\hull.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\jarcloc.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\knotvector.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mapdesc.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\maplist.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\memalloc.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\mesh.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mesher.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoChain.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoPolyPart.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\monotonizer.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoTriangulation.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\myassert.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mymath.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mysetjmp.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\mystdio.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\mystdio.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\mystdlib.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\mystdlib.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mystring.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\normal.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\nurbsconsts.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\nurbstess.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\partitionX.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\partitionY.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\patch.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\patchlist.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\polyDBG.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\polyUtil.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\primitiveStream.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\priorityq-heap.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\priorityq-sort.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\priorityq.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\pwlarc.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\quicksort.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\quilt.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\reader.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\rectBlock.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\render.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\renderhints.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleComp.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompBot.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompRight.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompTop.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampledLine.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleMonoPoly.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\searchTree.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\simplemath.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\slicer.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\sorter.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\subdivider.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\sweep.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\tess.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\tessmono.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\trimline.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\trimregion.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\trimvertex.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\trimvertpool.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\types.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\uarray.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\varray.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\zlassert.h">\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="C++ files"\r
+                       Filter=".cc">\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\arc.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\arcsorter.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\arctess.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\backend.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\basiccrveval.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\basicsurfeval.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\bezierEval.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\bezierPatch.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\bezierPatchMesh.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\bin.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\bufpool.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\cachingeval.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\ccw.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\coveandtiler.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\curve.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\curvelist.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\curvesub.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\dataTransform.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\directedLine.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\displaylist.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\flist.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\flistsorter.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glcurveval.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glinterface.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glrenderer.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glsurfeval.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\gridWrap.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\hull.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\incurveeval.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\insurfeval.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\intersect.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\knotvector.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mapdesc.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mapdescv.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\maplist.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mesher.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoChain.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoPolyPart.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\monotonizer.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoTriangulation.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\monoTriangulationBackend.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mycode.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\nurbsinterfac.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\nurbstess.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\partitionX.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\partitionY.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\patch.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\patchlist.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\polyDBG.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\polyUtil.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\primitiveStream.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\quicksort.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\quilt.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\reader.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\README">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\rectBlock.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\renderhints.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleComp.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompBot.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompRight.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompTop.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampledLine.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleMonoPoly.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\searchTree.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\slicer.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\sorter.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\splitarcs.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\subdivider.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\tobezier.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\trimline.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\trimregion.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\trimvertpool.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\uarray.cc">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\varray.cc">\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">\r
+               </Filter>\r
+               <File\r
+                       RelativePath="..\..\..\..\src\glu\sgi\libtess\alg-outline">\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/windows/VC7/mesa/mesa.sln b/windows/VC7/mesa/mesa.sln
new file mode 100644 (file)
index 0000000..ae47790
--- /dev/null
@@ -0,0 +1,47 @@
+Microsoft Visual Studio Solution File, Format Version 8.00\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gdi", "gdi\gdi.vcproj", "{A1B24907-E196-4826-B6AF-26723629B633}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {2120C974-2717-4709-B44F-D6E6D0A56448} = {2120C974-2717-4709-B44F-D6E6D0A56448}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glu", "glu\glu.vcproj", "{2E50FDAF-430B-475B-AE6B-60B68F2875BA}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mesa", "mesa\mesa.vcproj", "{2120C974-2717-4709-B44F-D6E6D0A56448}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osmesa", "osmesa\osmesa.vcproj", "{8D6CD423-383B-49E7-81BC-D20C70B07DF5}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {A1B24907-E196-4826-B6AF-26723629B633} = {A1B24907-E196-4826-B6AF-26723629B633}\r
+       EndProjectSection\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfiguration) = preSolution\r
+               Debug = Debug\r
+               Release = Release\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfiguration) = postSolution\r
+               {A1B24907-E196-4826-B6AF-26723629B633}.Debug.ActiveCfg = Debug|Win32\r
+               {A1B24907-E196-4826-B6AF-26723629B633}.Debug.Build.0 = Debug|Win32\r
+               {A1B24907-E196-4826-B6AF-26723629B633}.Release.ActiveCfg = Release|Win32\r
+               {A1B24907-E196-4826-B6AF-26723629B633}.Release.Build.0 = Release|Win32\r
+               {2E50FDAF-430B-475B-AE6B-60B68F2875BA}.Debug.ActiveCfg = Debug|Win32\r
+               {2E50FDAF-430B-475B-AE6B-60B68F2875BA}.Debug.Build.0 = Debug|Win32\r
+               {2E50FDAF-430B-475B-AE6B-60B68F2875BA}.Release.ActiveCfg = Release|Win32\r
+               {2E50FDAF-430B-475B-AE6B-60B68F2875BA}.Release.Build.0 = Release|Win32\r
+               {2120C974-2717-4709-B44F-D6E6D0A56448}.Debug.ActiveCfg = Debug|Win32\r
+               {2120C974-2717-4709-B44F-D6E6D0A56448}.Debug.Build.0 = Debug|Win32\r
+               {2120C974-2717-4709-B44F-D6E6D0A56448}.Release.ActiveCfg = Release|Win32\r
+               {2120C974-2717-4709-B44F-D6E6D0A56448}.Release.Build.0 = Release|Win32\r
+               {8D6CD423-383B-49E7-81BC-D20C70B07DF5}.Debug.ActiveCfg = Debug|Win32\r
+               {8D6CD423-383B-49E7-81BC-D20C70B07DF5}.Debug.Build.0 = Debug|Win32\r
+               {8D6CD423-383B-49E7-81BC-D20C70B07DF5}.Release.ActiveCfg = Release|Win32\r
+               {8D6CD423-383B-49E7-81BC-D20C70B07DF5}.Release.Build.0 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(ExtensibilityGlobals) = postSolution\r
+       EndGlobalSection\r
+       GlobalSection(ExtensibilityAddIns) = postSolution\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/windows/VC7/mesa/mesa/mesa.vcproj b/windows/VC7/mesa/mesa/mesa.vcproj
new file mode 100644 (file)
index 0000000..8a68258
--- /dev/null
@@ -0,0 +1,1227 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="7.10"\r
+       Name="mesa"\r
+       SccProjectName=""\r
+       SccLocalPath="">\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"/>\r
+       </Platforms>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="4"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="FALSE"\r
+                       CharacterSet="2">\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               AdditionalOptions="/Zm1000 "\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/glapi,../../../../src/mesa/main,../../../../src/mesa/shader,../../../../src/mesa/shader/slang,../../../../src/mesa/shader/grammar"\r
+                               PreprocessorDefinitions="NDEBUG,WIN32,_LIB,_DLL,BUILD_GL32,MESA_MINWARN"\r
+                               StringPooling="TRUE"\r
+                               RuntimeLibrary="4"\r
+                               EnableFunctionLevelLinking="TRUE"\r
+                               UsePrecompiledHeader="2"\r
+                               PrecompiledHeaderFile=".\Release/mesa.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               WarningLevel="3"\r
+                               SuppressStartupBanner="TRUE"\r
+                               CompileAs="0"/>\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"/>\r
+                       <Tool\r
+                               Name="VCLibrarianTool"\r
+                               OutputFile=".\Release\mesa.lib"\r
+                               SuppressStartupBanner="TRUE"/>\r
+                       <Tool\r
+                               Name="VCMIDLTool"/>\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"/>\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"/>\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"/>\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1033"/>\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCManagedWrapperGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCAuxiliaryManagedWrapperGeneratorTool"/>\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="4"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="FALSE"\r
+                       CharacterSet="2">\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               AdditionalOptions="/Zm1000 "\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/glapi,../../../../src/mesa/main,../../../../src/mesa/shader,../../../../src/mesa/shader/slang,../../../../src/mesa/shader/grammar"\r
+                               PreprocessorDefinitions="_DEBUG,WIN32,_LIB,_DLL,BUILD_GL32,MESA_MINWARN"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="5"\r
+                               PrecompiledHeaderFile=".\Debug/mesa.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="3"\r
+                               SuppressStartupBanner="TRUE"\r
+                               DebugInformationFormat="3"\r
+                               CompileAs="0"/>\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"/>\r
+                       <Tool\r
+                               Name="VCLibrarianTool"\r
+                               OutputFile=".\Debug\mesa.lib"\r
+                               SuppressStartupBanner="TRUE"/>\r
+                       <Tool\r
+                               Name="VCMIDLTool"/>\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"/>\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"/>\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"/>\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1033"/>\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCManagedWrapperGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCAuxiliaryManagedWrapperGeneratorTool"/>\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\accum.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\api_arrayelt.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\api_loopback.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\api_noop.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\api_validate.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\arbprogparse.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\arbprogram.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\arrayobj.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\atifragshader.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\attrib.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\blend.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\bufferobj.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\buffers.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\clip.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\colortab.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\context.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\convolve.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\debug.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\depth.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\depthstencil.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\dispatch.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\dlist.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\drawpix.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\enable.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\enums.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\eval.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\execmem.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\extensions.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\fbobject.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\feedback.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\fog.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\framebuffer.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\get.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\getstring.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\glapi\glapi.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\glapi\glthread.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar.c">\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       ExcludedFromBuild="TRUE">\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"/>\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       ExcludedFromBuild="TRUE">\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"/>\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar_crt.c">\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       ExcludedFromBuild="TRUE">\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"/>\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar_mesa.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\hash.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\hint.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\histogram.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\image.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\imports.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\light.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\lines.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_debug_clip.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_debug_norm.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_debug_xform.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_eval.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_matrix.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_translate.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_vector.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_xform.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\matrix.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\mipmap.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\mm.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\nvfragparse.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\nvprogram.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\nvvertparse.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\pixel.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\points.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\polygon.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_debug.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_execute.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_instruction.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_parameter.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_print.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_statevars.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\program.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\programopt.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\queryobj.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\rastpos.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\rbadaptors.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\renderbuffer.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_aaline.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_aatriangle.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_accum.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_alpha.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_atifragshader.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_bitmap.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_blend.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_blit.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_buffers.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_context.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_copypix.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_depth.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_drawpix.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_feedback.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_fog.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_fragprog.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_imaging.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_lines.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_logic.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_masking.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_points.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_readpix.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_span.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_stencil.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_texcombine.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_texfilter.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_texstore.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_triangle.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_zoom.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\shader_api.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\shaders.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_builtin.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_codegen.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_compile.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_compile_function.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_compile_operation.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_compile_struct.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_compile_variable.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_emit.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_ir.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_label.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_library_noise.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_link.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_log.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_mem.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_preprocess.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_print.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_simplify.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_storage.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_typeinfo.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_utility.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_vartable.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast_setup\ss_context.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast_setup\ss_triangle.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\state.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\stencil.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_context.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_draw.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_pipeline.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_cull.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_fog.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_light.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_normals.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_points.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_program.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_render.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_texgen.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_texmat.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_vertex.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vertex.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vertex_generic.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vp_build.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texcompress.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texcompress_fxt1.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texcompress_s3tc.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texenvprogram.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texformat.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\teximage.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texobj.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texrender.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texstate.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texstore.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\varray.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_context.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_exec.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_exec_api.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_exec_array.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_exec_draw.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_exec_eval.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_rebase.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_save.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_save_api.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_save_draw.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_save_loopback.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_split.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_split_copy.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_split_inplace.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\vsnprintf.c">\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       ExcludedFromBuild="TRUE">\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"/>\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       ExcludedFromBuild="TRUE">\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"/>\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\vtxfmt.c">\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl">\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\array_cache\ac_context.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\array_cache\acache.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\accum.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\api_arrayelt.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\api_eval.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\api_loopback.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\api_noop.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\api_validate.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\arbprogparse.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\arbprogram.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\arbprogram_syn.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\atifragshader.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\attrib.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\blend.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\bufferobj.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\buffers.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\clip.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\colormac.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\colortab.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\config.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\context.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\convolve.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\dd.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\debug.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\depth.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\depthstencil.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\dlist.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\drawpix.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\enable.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\enums.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\eval.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\extensions.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\fbobject.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\feedback.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\fog.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\framebuffer.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\get.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\glapi\glapi.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\glapi\glapioffsets.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\glapi\glapitable.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\glapi\glapitemp.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\glheader.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\glapi\glprocs.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\glapi\glthread.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar_crt.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar_mesa.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar_syn.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\hash.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\hint.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\histogram.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\image.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\imports.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\light.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\lines.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_clip_tmp.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_copy_tmp.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_debug.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_debug_util.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_dotprod_tmp.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_eval.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_matrix.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_norm_tmp.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_trans_tmp.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_translate.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_vector.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_xform.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_xform_tmp.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\macros.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\mathmod.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\matrix.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\mm.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\mtypes.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\nvfragparse.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\nvprogram.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\nvvertexec.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\nvvertparse.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\pixel.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\points.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\polygon.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_debug.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_execute.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_instruction.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_parameter.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_print.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_statevars.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\program.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\programopt.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\queryobj.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\rastpos.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\renderbuffer.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_aaline.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_aalinetemp.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_aatriangle.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_aatritemp.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_accum.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_alpha.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_atifragshader.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_blend.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_context.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_depth.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_drawpix.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_feedback.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_fog.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_fragprog.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_lines.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_linetemp.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_logic.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_masking.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_nvfragprog.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_points.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_pointtemp.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_span.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_spantemp.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_stencil.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_texcombine.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_texfilter.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_triangle.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_trispan.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_tritemp.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_zoom.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\shader_api.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\shaders.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\simple_list.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_builtin.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_codegen.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_compile.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_compile_function.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_compile_operation.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_compile_struct.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_compile_variable.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_emit.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_ir.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_label.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_library_noise.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_link.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_log.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_mem.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_preprocess.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_print.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_simplify.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_storage.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_typeinfo.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_utility.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_vartable.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast_setup\ss_context.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast_setup\ss_triangle.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast_setup\ss_tritmp.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast_setup\ss_vb.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\state.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\stencil.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\swrast.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast_setup\swrast_setup.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_context.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_pipeline.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_cliptmp.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_lighttmp.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_rendertmp.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vertex.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vp_build.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texcompress.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texenvprogram.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texformat.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texformat_tmp.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\teximage.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texobj.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texrender.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texstate.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texstore.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\tnl.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\varray.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_attrib.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_attrib_tmp.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_context.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_exec.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_save.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_split.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\version.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\vtxfmt.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\vtxfmt_tmp.h">\r
+                       </File>\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/windows/VC7/mesa/osmesa/osmesa.vcproj b/windows/VC7/mesa/osmesa/osmesa.vcproj
new file mode 100644 (file)
index 0000000..553dad7
--- /dev/null
@@ -0,0 +1,182 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="7.10"\r
+       Name="osmesa"\r
+       SccProjectName=""\r
+       SccLocalPath="">\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"/>\r
+       </Platforms>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="2"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="FALSE"\r
+                       CharacterSet="2">\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/main,../../../../src/mesa/glapi,../../../../src/mesa/swrast,../../../../src/mesa/shader"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;OSMESA_EXPORTS"\r
+                               StringPooling="TRUE"\r
+                               RuntimeLibrary="0"\r
+                               EnableFunctionLevelLinking="TRUE"\r
+                               PrecompiledHeaderFile=".\Release/osmesa.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               WarningLevel="3"\r
+                               SuppressStartupBanner="TRUE"\r
+                               CompileAs="0"/>\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"/>\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalOptions="/MACHINE:I386"\r
+                               AdditionalDependencies="opengl32.lib winmm.lib msvcrt.lib odbc32.lib odbccp32.lib"\r
+                               OutputFile="Release/OSMESA32.DLL"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="TRUE"\r
+                               AdditionalLibraryDirectories="../gdi/Release"\r
+                               IgnoreAllDefaultLibraries="TRUE"\r
+                               ModuleDefinitionFile="..\..\..\..\src\mesa\drivers\osmesa\osmesa.def"\r
+                               ProgramDatabaseFile=".\Release/OSMESA32.pdb"\r
+                               ImportLibrary=".\Release/OSMESA32.lib"/>\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               MkTypLibCompatible="TRUE"\r
+                               SuppressStartupBanner="TRUE"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Release/osmesa.tlb"/>\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                               CommandLine="if not exist ..\..\..\..\lib md ..\..\..\..\lib\r
+copy Release\OSMESA32.LIB ..\..\..\..\lib\r
+copy Release\OSMESA32.DLL ..\..\..\..\lib\r
+if exist ..\..\..\..\progs\demos copy Release\OSMESA32.DLL ..\..\..\..\progs\demos\r
+"/>\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"/>\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"/>\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1033"/>\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"/>\r
+                       <Tool\r
+                               Name="VCManagedWrapperGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCAuxiliaryManagedWrapperGeneratorTool"/>\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="2"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="FALSE"\r
+                       CharacterSet="2">\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/main,../../../../src/mesa/glapi,../../../../src/mesa/swrast,../../../../src/mesa/shader"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;OSMESA_EXPORTS"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="1"\r
+                               PrecompiledHeaderFile=".\Debug/osmesa.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               WarningLevel="3"\r
+                               SuppressStartupBanner="TRUE"\r
+                               DebugInformationFormat="3"\r
+                               CompileAs="0"/>\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"/>\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalOptions="/MACHINE:I386"\r
+                               AdditionalDependencies="opengl32.lib winmm.lib msvcrtd.lib odbc32.lib odbccp32.lib"\r
+                               OutputFile="Debug/OSMESA32.DLL"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="TRUE"\r
+                               AdditionalLibraryDirectories="../gdi/Debug"\r
+                               IgnoreAllDefaultLibraries="TRUE"\r
+                               ModuleDefinitionFile="..\..\..\..\src\mesa\drivers\osmesa\osmesa.def"\r
+                               GenerateDebugInformation="TRUE"\r
+                               ProgramDatabaseFile=".\Debug/OSMESA32.pdb"\r
+                               ImportLibrary=".\Debug/OSMESA32.lib"/>\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               MkTypLibCompatible="TRUE"\r
+                               SuppressStartupBanner="TRUE"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Debug/osmesa.tlb"/>\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                               CommandLine="if not exist ..\..\..\..\lib md ..\..\..\..\lib\r
+copy Debug\OSMESA32.LIB ..\..\..\..\lib\r
+copy Debug\OSMESA32.DLL ..\..\..\..\lib\r
+if exist ..\..\..\..\progs\demos copy Debug\OSMESA32.DLL ..\..\..\..\progs\demos\r
+"/>\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"/>\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"/>\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1033"/>\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"/>\r
+                       <Tool\r
+                               Name="VCManagedWrapperGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCAuxiliaryManagedWrapperGeneratorTool"/>\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\drivers\common\driverfuncs.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\drivers\osmesa\osmesa.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\drivers\osmesa\osmesa.def">\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl">\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/windows/VC7/progs/glut/glut.vcproj b/windows/VC7/progs/glut/glut.vcproj
new file mode 100644 (file)
index 0000000..a9387f6
--- /dev/null
@@ -0,0 +1,322 @@
+<?xml version="1.0" encoding = "Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="7.00"\r
+       Name="glut"\r
+       SccProjectName=""\r
+       SccLocalPath="">\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"/>\r
+       </Platforms>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="2"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="FALSE"\r
+                       CharacterSet="2">\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="../../../../include"\r
+                               PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;_DLL;_USRDLL;GLUT_EXPORTS;MESA;BUILD_GL32"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="1"\r
+                               PrecompiledHeaderFile=".\Debug/glut.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               WarningLevel="3"\r
+                               SuppressStartupBanner="TRUE"\r
+                               DebugInformationFormat="3"\r
+                               CompileAs="0"/>\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"/>\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalOptions="/MACHINE:I386"\r
+                               AdditionalDependencies="winmm.lib msvcrtd.lib oldnames.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib"\r
+                               OutputFile="Debug/GLUT32.DLL"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="TRUE"\r
+                               AdditionalLibraryDirectories="../../mesa/Debug"\r
+                               IgnoreAllDefaultLibraries="TRUE"\r
+                               GenerateDebugInformation="TRUE"\r
+                               ProgramDatabaseFile=".\Debug/GLUT32.pdb"\r
+                               ImportLibrary=".\Debug/GLUT32.lib"/>\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               MkTypLibCompatible="TRUE"\r
+                               SuppressStartupBanner="TRUE"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Debug/glut.tlb"/>\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                               CommandLine="if not exist ..\..\..\..\lib md ..\..\..\..\lib\r
+copy Debug\GLUT32.LIB ..\..\..\..\lib\r
+copy Debug\GLUT32.DLL ..\..\..\..\lib\r
+if exist ..\..\..\..\progs\demos copy Debug\GLUT32.DLL ..\..\..\..\progs\demos\r
+"/>\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"/>\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"/>\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1033"/>\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"/>\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="2"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="FALSE"\r
+                       CharacterSet="2">\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="../../../../include"\r
+                               PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;_DLL;_USRDLL;GLUT_EXPORTS;MESA;BUILD_GL32"\r
+                               StringPooling="TRUE"\r
+                               RuntimeLibrary="0"\r
+                               EnableFunctionLevelLinking="TRUE"\r
+                               PrecompiledHeaderFile=".\Release/glut.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               WarningLevel="3"\r
+                               SuppressStartupBanner="TRUE"\r
+                               CompileAs="0"/>\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"/>\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalOptions="/MACHINE:I386"\r
+                               AdditionalDependencies="opengl32.lib glu32.lib winmm.lib msvcrt.lib oldnames.lib odbc32.lib odbccp32.lib"\r
+                               OutputFile="Release/GLUT32.DLL"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="TRUE"\r
+                               AdditionalLibraryDirectories="../../mesa/Release"\r
+                               IgnoreAllDefaultLibraries="TRUE"\r
+                               ProgramDatabaseFile=".\Release/GLUT32.pdb"\r
+                               ImportLibrary=".\Release/GLUT32.lib"/>\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               MkTypLibCompatible="TRUE"\r
+                               SuppressStartupBanner="TRUE"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Release/glut.tlb"/>\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                               CommandLine="if not exist ..\..\..\..\lib md ..\..\..\..\lib\r
+copy Release\GLUT32.LIB ..\..\..\..\lib\r
+copy Release\GLUT32.DLL ..\..\..\..\lib\r
+if exist ..\..\..\..\progs\demos copy Release\GLUT32.DLL ..\..\..\..\progs\demos\r
+"/>\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"/>\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"/>\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1033"/>\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"/>\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"/>\r
+               </Configuration>\r
+       </Configurations>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_8x13.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_9x15.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_bitmap.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_bwidth.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_cindex.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_cmap.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_cursor.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_dials.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_dstr.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_event.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_ext.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_fcb.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_fullscrn.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_gamemode.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_get.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_hel10.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_hel12.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_hel18.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_init.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_input.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_joy.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_key.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_keyctrl.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_keyup.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_mesa.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_modifier.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_mroman.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_overlay.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_roman.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_shapes.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_space.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_stroke.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_swap.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_swidth.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_tablet.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_teapot.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_tr10.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_tr24.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_util.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_vidresize.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_warp.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_win.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_winmisc.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\win32_glx.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\win32_menu.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\win32_util.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\win32_winproc.c">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\win32_x11.c">\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl">\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glutbitmap.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glutint.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glutstroke.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glutwin32.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\stroke.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\win32_glx.h">\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\win32_x11.h">\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/windows/VC8/mesa/gdi/gdi.vcproj b/windows/VC8/mesa/gdi/gdi.vcproj
new file mode 100644 (file)
index 0000000..7b3efc4
--- /dev/null
@@ -0,0 +1,264 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="gdi"\r
+       ProjectGUID="{A1B24907-E196-4826-B6AF-26723629B633}"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               MkTypLibCompatible="true"\r
+                               SuppressStartupBanner="true"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Debug/gdi.tlb"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/main,../../../../src/mesa/glapi,../../../../src/mesa/swrast,../../../../src/mesa/shader"\r
+                               PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;_USRDLL;GDI_EXPORTS;_DLL;BUILD_GL32;MESA_MINWARN"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="1"\r
+                               PrecompiledHeaderFile=".\Debug/gdi.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="3"\r
+                               SuppressStartupBanner="true"\r
+                               DebugInformationFormat="3"\r
+                               CompileAs="0"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalOptions="/MACHINE:I386"\r
+                               AdditionalDependencies="mesa.lib msvcrtd.lib gdi32.lib user32.lib winmm.lib odbc32.lib odbccp32.lib"\r
+                               OutputFile="Debug/OPENGL32.DLL"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               AdditionalLibraryDirectories="../mesa/Debug"\r
+                               IgnoreAllDefaultLibraries="true"\r
+                               ModuleDefinitionFile="..\..\..\..\src\mesa\drivers\windows\gdi\mesa.def"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/OPENGL32.pdb"\r
+                               ImportLibrary=".\Debug/OPENGL32.lib"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                               CommandLine="if not exist ..\..\..\..\lib md ..\..\..\..\lib&#x0D;&#x0A;copy Debug\OPENGL32.LIB ..\..\..\..\lib&#x0D;&#x0A;copy Debug\OPENGL32.DLL ..\..\..\..\lib&#x0D;&#x0A;if exist ..\..\..\..\progs\demos copy Debug\OPENGL32.DLL ..\..\..\..\progs\demos&#x0D;&#x0A;"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               MkTypLibCompatible="true"\r
+                               SuppressStartupBanner="true"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Release/gdi.tlb"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="../../main,../../../../include,../../../../src/mesa,../../../../src/mesa/main,../../../../src/mesa/glapi,../../../../src/mesa/swrast,../../../../src/mesa/shader"\r
+                               PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;_USRDLL;GDI_EXPORTS;_DLL;BUILD_GL32;MESA_MINWARN"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="0"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/gdi.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               WarningLevel="3"\r
+                               SuppressStartupBanner="true"\r
+                               CompileAs="0"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalOptions="/MACHINE:I386"\r
+                               AdditionalDependencies="mesa.lib winmm.lib gdi32.lib user32.lib msvcrt.lib odbc32.lib odbccp32.lib"\r
+                               OutputFile="Release/OPENGL32.DLL"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               AdditionalLibraryDirectories="../mesa/Release"\r
+                               IgnoreAllDefaultLibraries="true"\r
+                               ModuleDefinitionFile="..\..\..\..\src\mesa\drivers\windows\gdi\mesa.def"\r
+                               ProgramDatabaseFile=".\Release/OPENGL32.pdb"\r
+                               ImportLibrary=".\Release/OPENGL32.lib"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                               CommandLine="if not exist ..\..\..\..\lib md ..\..\..\..\lib&#x0D;&#x0A;copy Release\OPENGL32.LIB ..\..\..\..\lib&#x0D;&#x0A;copy Release\OPENGL32.DLL ..\..\..\..\lib&#x0D;&#x0A;if exist ..\..\..\..\progs\demos copy Release\OPENGL32.DLL ..\..\..\..\progs\demos&#x0D;&#x0A;"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\drivers\common\driverfuncs.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\drivers\windows\gdi\mesa.def"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\drivers\windows\gdi\wgl.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\drivers\windows\gdi\wmesa.c"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\drivers\windows\gdi\colors.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\drivers\common\driverfuncs.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\include\GL\wmesa.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\drivers\windows\gdi\wmesadef.h"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
+                       >\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/windows/VC8/mesa/glu/glu.vcproj b/windows/VC8/mesa/glu/glu.vcproj
new file mode 100644 (file)
index 0000000..016b0b9
--- /dev/null
@@ -0,0 +1,1022 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="glu"\r
+       ProjectGUID="{2E50FDAF-430B-475B-AE6B-60B68F2875BA}"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               MkTypLibCompatible="true"\r
+                               SuppressStartupBanner="true"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Release/glu.tlb"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="../../../../include;../../../../src/glu/sgi/include;../../../../src/glu/sgi/libnurbs/interface;../../../../src/glu/sgi/libnurbs/internals;../../../../src/glu/sgi/libnurbs/nurbtess"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;GLU_EXPORTS;BUILD_GL32;LIBRARYBUILD;_CRT_SECURE_NO_DEPRECATE"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="0"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/glu.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               WarningLevel="3"\r
+                               SuppressStartupBanner="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalOptions="/MACHINE:I386"\r
+                               AdditionalDependencies="msvcrt.lib winmm.lib odbc32.lib odbccp32.lib opengl32.lib"\r
+                               OutputFile="Release/GLU32.DLL"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               AdditionalLibraryDirectories="../gdi/Release"\r
+                               IgnoreAllDefaultLibraries="true"\r
+                               ModuleDefinitionFile="..\..\..\..\src\glu\sgi\glu.def"\r
+                               ProgramDatabaseFile=".\Release/GLU32.pdb"\r
+                               ImportLibrary=".\Release/GLU32.lib"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                               CommandLine="if not exist ..\..\..\..\lib md ..\..\..\..\lib&#x0D;&#x0A;copy Release\GLU32.LIB ..\..\..\..\lib&#x0D;&#x0A;copy Release\GLU32.DLL ..\..\..\..\lib&#x0D;&#x0A;if exist ..\..\..\..\progs\demos copy Release\GLU32.DLL ..\..\..\..\progs\demos&#x0D;&#x0A;"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               MkTypLibCompatible="true"\r
+                               SuppressStartupBanner="true"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Debug/glu.tlb"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="../../../../include;../../../../src/glu/sgi/include;../../../../src/glu/sgi/libnurbs/interface;../../../../src/glu/sgi/libnurbs/internals;../../../../src/glu/sgi/libnurbs/nurbtess"\r
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;GLU_EXPORTS;BUILD_GL32;LIBRARYBUILD;_CRT_SECURE_NO_DEPRECATE"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="1"\r
+                               PrecompiledHeaderFile=".\Debug/glu.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               WarningLevel="3"\r
+                               SuppressStartupBanner="true"\r
+                               DebugInformationFormat="3"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalOptions="/MACHINE:I386"\r
+                               AdditionalDependencies="msvcrtd.lib winmm.lib odbc32.lib odbccp32.lib opengl32.lib"\r
+                               OutputFile="Debug/GLU32.DLL"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               AdditionalLibraryDirectories="../gdi/Debug"\r
+                               IgnoreAllDefaultLibraries="true"\r
+                               ModuleDefinitionFile="..\..\..\..\src\glu\sgi\glu.def"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/GLU32.pdb"\r
+                               ImportLibrary=".\Debug/GLU32.lib"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                               CommandLine="if not exist ..\..\..\..\lib md ..\..\..\..\lib&#x0D;&#x0A;copy Debug\GLU32.LIB ..\..\..\..\lib&#x0D;&#x0A;copy Debug\GLU32.DLL ..\..\..\..\lib&#x0D;&#x0A;if exist ..\..\..\..\progs\demos copy Debug\GLU32.DLL ..\..\..\..\progs\demos&#x0D;&#x0A;"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\dict.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libutil\error.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\geom.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\glu.def"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libutil\glue.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\memalloc.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\mesh.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libutil\mipmap.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\normal.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\priorityq-heap.c"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       ExcludedFromBuild="true"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       ExcludedFromBuild="true"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\priorityq.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libutil\project.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libutil\quad.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libutil\registry.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\render.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\sweep.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\tess.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\tessmono.c"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\arc.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\arcsorter.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\arctess.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\backend.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\basiccrveval.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\basicsurfeval.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\bezierarc.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\bezierEval.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\bezierPatch.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\bezierPatchMesh.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\bin.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\bufpool.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\cachingeval.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\coveandtiler.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\curve.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\curvelist.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\dataTransform.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\defines.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\definitions.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\dict-list.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\dict.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\directedLine.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\displaylist.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\displaymode.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\flist.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\flistsorter.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\geom.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glcurveval.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glimports.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\glimports.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glrenderer.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glsurfeval.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libutil\gluint.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\include\gluos.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\gridline.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\gridtrimvertex.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\gridvertex.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\gridWrap.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\hull.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\jarcloc.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\knotvector.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mapdesc.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\maplist.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\memalloc.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\mesh.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mesher.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoChain.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoPolyPart.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\monotonizer.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoTriangulation.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\myassert.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mymath.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mysetjmp.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\mystdio.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\mystdio.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\mystdlib.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\mystdlib.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mystring.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\normal.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\nurbsconsts.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\nurbstess.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\partitionX.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\partitionY.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\patch.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\patchlist.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\polyDBG.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\polyUtil.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\primitiveStream.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\priorityq-heap.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\priorityq-sort.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\priorityq.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\pwlarc.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\quicksort.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\quilt.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\reader.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\rectBlock.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\render.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\renderhints.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleComp.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompBot.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompRight.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompTop.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampledLine.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleMonoPoly.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\searchTree.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\simplemath.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\slicer.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\sorter.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\subdivider.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\sweep.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\tess.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\tessmono.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\trimline.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\trimregion.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\trimvertex.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\trimvertpool.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\types.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\uarray.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\varray.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\zlassert.h"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="C++ files"\r
+                       Filter=".cc"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\arc.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\arcsorter.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\arctess.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\backend.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\basiccrveval.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\basicsurfeval.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\bezierEval.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\bezierPatch.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\bezierPatchMesh.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\bin.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\bufpool.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\cachingeval.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\ccw.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\coveandtiler.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\curve.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\curvelist.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\curvesub.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\dataTransform.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\directedLine.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\displaylist.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\flist.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\flistsorter.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glcurveval.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glinterface.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glrenderer.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glsurfeval.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\gridWrap.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\hull.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\incurveeval.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\insurfeval.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\intersect.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\knotvector.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mapdesc.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mapdescv.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\maplist.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mesher.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoChain.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoPolyPart.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\monotonizer.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoTriangulation.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\monoTriangulationBackend.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mycode.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\nurbsinterfac.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\nurbstess.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\partitionX.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\partitionY.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\patch.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\patchlist.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\polyDBG.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\polyUtil.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\primitiveStream.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\quicksort.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\quilt.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\reader.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libtess\README"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\rectBlock.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\renderhints.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleComp.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompBot.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompRight.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompTop.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampledLine.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleMonoPoly.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\searchTree.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\slicer.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\sorter.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\splitarcs.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\subdivider.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\tobezier.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\trimline.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\trimregion.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\trimvertpool.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\uarray.cc"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\varray.cc"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
+                       >\r
+               </Filter>\r
+               <File\r
+                       RelativePath="..\..\..\..\src\glu\sgi\libtess\alg-outline"\r
+                       >\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/windows/VC8/mesa/mesa.sln b/windows/VC8/mesa/mesa.sln
new file mode 100644 (file)
index 0000000..5eff488
--- /dev/null
@@ -0,0 +1,46 @@
+Microsoft Visual Studio Solution File, Format Version 9.00\r
+# Visual C++ Express 2005\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gdi", "gdi\gdi.vcproj", "{A1B24907-E196-4826-B6AF-26723629B633}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {2120C974-2717-4709-B44F-D6E6D0A56448} = {2120C974-2717-4709-B44F-D6E6D0A56448}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glu", "glu\glu.vcproj", "{2E50FDAF-430B-475B-AE6B-60B68F2875BA}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {A1B24907-E196-4826-B6AF-26723629B633} = {A1B24907-E196-4826-B6AF-26723629B633}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mesa", "mesa\mesa.vcproj", "{2120C974-2717-4709-B44F-D6E6D0A56448}"\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osmesa", "osmesa\osmesa.vcproj", "{8D6CD423-383B-49E7-81BC-D20C70B07DF5}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {A1B24907-E196-4826-B6AF-26723629B633} = {A1B24907-E196-4826-B6AF-26723629B633}\r
+       EndProjectSection\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Win32 = Debug|Win32\r
+               Release|Win32 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {A1B24907-E196-4826-B6AF-26723629B633}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {A1B24907-E196-4826-B6AF-26723629B633}.Debug|Win32.Build.0 = Debug|Win32\r
+               {A1B24907-E196-4826-B6AF-26723629B633}.Release|Win32.ActiveCfg = Release|Win32\r
+               {A1B24907-E196-4826-B6AF-26723629B633}.Release|Win32.Build.0 = Release|Win32\r
+               {2E50FDAF-430B-475B-AE6B-60B68F2875BA}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {2E50FDAF-430B-475B-AE6B-60B68F2875BA}.Debug|Win32.Build.0 = Debug|Win32\r
+               {2E50FDAF-430B-475B-AE6B-60B68F2875BA}.Release|Win32.ActiveCfg = Release|Win32\r
+               {2E50FDAF-430B-475B-AE6B-60B68F2875BA}.Release|Win32.Build.0 = Release|Win32\r
+               {2120C974-2717-4709-B44F-D6E6D0A56448}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {2120C974-2717-4709-B44F-D6E6D0A56448}.Debug|Win32.Build.0 = Debug|Win32\r
+               {2120C974-2717-4709-B44F-D6E6D0A56448}.Release|Win32.ActiveCfg = Release|Win32\r
+               {2120C974-2717-4709-B44F-D6E6D0A56448}.Release|Win32.Build.0 = Release|Win32\r
+               {8D6CD423-383B-49E7-81BC-D20C70B07DF5}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {8D6CD423-383B-49E7-81BC-D20C70B07DF5}.Debug|Win32.Build.0 = Debug|Win32\r
+               {8D6CD423-383B-49E7-81BC-D20C70B07DF5}.Release|Win32.ActiveCfg = Release|Win32\r
+               {8D6CD423-383B-49E7-81BC-D20C70B07DF5}.Release|Win32.Build.0 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/windows/VC8/mesa/mesa/mesa.vcproj b/windows/VC8/mesa/mesa/mesa.vcproj
new file mode 100644 (file)
index 0000000..acbbf18
--- /dev/null
@@ -0,0 +1,1761 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="mesa"\r
+       ProjectGUID="{2120C974-2717-4709-B44F-D6E6D0A56448}"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="4"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               AdditionalOptions="/Zm1000 "\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/glapi,../../../../src/mesa/main,../../../../src/mesa/shader,../../../../src/mesa/shader/slang,../../../../src/mesa/shader/grammar"\r
+                               PreprocessorDefinitions="NDEBUG,WIN32,_LIB,_DLL,BUILD_GL32,MESA_MINWARN"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="0"\r
+                               EnableFunctionLevelLinking="true"\r
+                               UsePrecompiledHeader="0"\r
+                               PrecompiledHeaderFile=".\Release/mesa.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               WarningLevel="3"\r
+                               SuppressStartupBanner="true"\r
+                               CompileAs="0"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLibrarianTool"\r
+                               OutputFile=".\Release\mesa.lib"\r
+                               SuppressStartupBanner="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="4"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               AdditionalOptions="/Zm1000 "\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/glapi,../../../../src/mesa/main,../../../../src/mesa/shader,../../../../src/mesa/shader/slang,../../../../src/mesa/shader/grammar"\r
+                               PreprocessorDefinitions="_DEBUG,WIN32,_LIB,_DLL,BUILD_GL32,MESA_MINWARN"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="1"\r
+                               PrecompiledHeaderFile=".\Debug/mesa.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="3"\r
+                               SuppressStartupBanner="true"\r
+                               DebugInformationFormat="3"\r
+                               CompileAs="0"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLibrarianTool"\r
+                               OutputFile=".\Debug\mesa.lib"\r
+                               SuppressStartupBanner="true"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\accum.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\api_arrayelt.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\api_loopback.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\api_noop.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\api_validate.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\arbprogparse.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\arbprogram.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\arrayobj.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\atifragshader.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\attrib.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\blend.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\bufferobj.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\buffers.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\clip.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\colortab.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\context.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\convolve.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\debug.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\depth.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\depthstencil.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\dispatch.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\dlist.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\drawpix.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\enable.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\enums.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\eval.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\execmem.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\extensions.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\fbobject.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\feedback.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\fog.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\framebuffer.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\get.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\getstring.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\glapi\glapi.c"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\glapi\glthread.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar.c"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       ExcludedFromBuild="true"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       ExcludedFromBuild="true"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar_crt.c"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       ExcludedFromBuild="true"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       ExcludedFromBuild="true"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar_mesa.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\hash.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\hint.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\histogram.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\image.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\imports.c"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\light.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\lines.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_debug_clip.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_debug_norm.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_debug_xform.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_eval.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_matrix.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_translate.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_vector.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_xform.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\matrix.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\mipmap.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\mm.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\nvfragparse.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\nvprogram.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\nvvertparse.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\pixel.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\points.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\polygon.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_debug.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_execute.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_instruction.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_parameter.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_print.c"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_statevars.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_uniform.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\program.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\programopt.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\queryobj.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\rastpos.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\rbadaptors.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\renderbuffer.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_aaline.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_aatriangle.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_accum.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_alpha.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_atifragshader.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_bitmap.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_blend.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_blit.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_buffers.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_context.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_copypix.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_depth.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_drawpix.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_feedback.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_fog.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_fragprog.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_imaging.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_lines.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_logic.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_masking.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_points.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_readpix.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_span.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_stencil.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_texcombine.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_texfilter.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_texstore.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_triangle.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_zoom.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\shader_api.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\shaders.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_builtin.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_codegen.c"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_compile.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_compile_function.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_compile_operation.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_compile_struct.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_compile_variable.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_emit.c"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_ir.c"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_label.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_library_noise.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_link.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_log.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_mem.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_preprocess.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_print.c"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                               PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_simplify.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_storage.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_typeinfo.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_utility.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_vartable.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast_setup\ss_context.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast_setup\ss_triangle.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\state.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\stencil.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_context.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_draw.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_pipeline.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_cull.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_fog.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_light.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_normals.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_points.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_program.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_render.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_texgen.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_texmat.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_vertex.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vertex.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vertex_generic.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vp_build.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texcompress.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texcompress_fxt1.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texcompress_s3tc.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texenvprogram.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texformat.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\teximage.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texobj.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texrender.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texstate.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texstore.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\varray.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_context.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_exec.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_exec_api.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_exec_array.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_exec_draw.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_exec_eval.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_rebase.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_save.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_save_api.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_save_draw.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_save_loopback.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_split.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_split_copy.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_split_inplace.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\vsnprintf.c"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       ExcludedFromBuild="true"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       ExcludedFromBuild="true"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCLCompilerTool"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\vtxfmt.c"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\accum.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\api_arrayelt.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\api_eval.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\api_loopback.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\api_noop.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\api_validate.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\arbprogparse.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\arbprogram.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\arbprogram_syn.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\atifragshader.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\attrib.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\blend.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\bufferobj.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\buffers.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\clip.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\colormac.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\colortab.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\config.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\context.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\convolve.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\dd.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\debug.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\depth.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\depthstencil.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\dlist.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\drawpix.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\enable.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\enums.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\eval.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\extensions.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\fbobject.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\feedback.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\fog.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\framebuffer.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\get.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\glapi\glapi.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\glapi\glapioffsets.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\glapi\glapitable.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\glapi\glapitemp.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\glheader.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\glapi\glprocs.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\glapi\glthread.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar_crt.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar_mesa.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar_syn.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\hash.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\hint.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\histogram.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\image.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\imports.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\light.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\lines.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_clip_tmp.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_copy_tmp.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_debug.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_debug_util.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_dotprod_tmp.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_eval.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_matrix.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_norm_tmp.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_trans_tmp.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_translate.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_vector.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_xform.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\m_xform_tmp.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\macros.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\math\mathmod.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\matrix.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\mm.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\mtypes.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\nvfragparse.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\nvprogram.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\nvvertparse.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\pixel.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\points.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\polygon.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_debug.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_execute.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_instruction.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_parameter.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_print.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_statevars.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\prog_uniform.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\program.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\programopt.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\queryobj.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\rastpos.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\rbadaptors.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\renderbuffer.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_aaline.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_aalinetemp.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_aatriangle.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_aatritemp.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_accum.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_alpha.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_atifragshader.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_blend.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_context.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_depth.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_drawpix.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_feedback.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_fog.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_fragprog.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_lines.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_linetemp.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_logic.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_masking.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_points.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_pointtemp.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_span.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_spantemp.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_stencil.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_texcombine.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_texfilter.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_triangle.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_trispan.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_tritemp.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\s_zoom.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\shader_api.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\shaders.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\simple_list.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_builtin.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_codegen.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_compile.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_compile_function.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_compile_operation.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_compile_struct.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_compile_variable.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_emit.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_ir.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_label.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_library_noise.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_link.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_log.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_mem.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_preprocess.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_print.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_simplify.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_storage.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_typeinfo.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_utility.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\shader\slang\slang_vartable.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast_setup\ss_context.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast_setup\ss_triangle.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast_setup\ss_tritmp.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast_setup\ss_vb.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\state.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\stencil.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast\swrast.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\swrast_setup\swrast_setup.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_context.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_pipeline.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_cliptmp.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_lighttmp.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vb_rendertmp.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vertex.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\t_vp_build.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texcompress.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texenvprogram.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texformat.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texformat_tmp.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\teximage.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texobj.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texrender.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texstate.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texstore.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\tnl\tnl.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\varray.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_attrib.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_attrib_tmp.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_context.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_exec.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_save.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\vbo\vbo_split.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\version.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\vtxfmt.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\vtxfmt_tmp.h"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/windows/VC8/progs/glut/glut.vcproj b/windows/VC8/progs/glut/glut.vcproj
new file mode 100644 (file)
index 0000000..72b3266
--- /dev/null
@@ -0,0 +1,449 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="glut"\r
+       ProjectGUID="{0234F0D2-C8A6-4C4D-93E7-0E2248049C67}"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory=".\Debug"\r
+                       IntermediateDirectory=".\Debug"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               MkTypLibCompatible="true"\r
+                               SuppressStartupBanner="true"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Debug/glut.tlb"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories="../../../../include"\r
+                               PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;_DLL;_USRDLL;GLUT_EXPORTS;MESA;BUILD_GL32;_CRT_SECURE_NO_DEPRECATE"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="1"\r
+                               PrecompiledHeaderFile=".\Debug/glut.pch"\r
+                               AssemblerListingLocation=".\Debug/"\r
+                               ObjectFile=".\Debug/"\r
+                               ProgramDataBaseFileName=".\Debug/"\r
+                               WarningLevel="3"\r
+                               SuppressStartupBanner="true"\r
+                               DebugInformationFormat="3"\r
+                               CompileAs="0"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="_DEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalOptions="/MACHINE:I386"\r
+                               AdditionalDependencies="winmm.lib msvcrtd.lib gdi32.lib user32.lib oldnames.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib"\r
+                               OutputFile="Debug/GLUT32.DLL"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               AdditionalLibraryDirectories="../../mesa/Debug"\r
+                               IgnoreAllDefaultLibraries="true"\r
+                               GenerateDebugInformation="true"\r
+                               ProgramDatabaseFile=".\Debug/GLUT32.pdb"\r
+                               ImportLibrary=".\Debug/GLUT32.lib"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                               CommandLine="if not exist ..\..\..\..\lib md ..\..\..\..\lib&#x0D;&#x0A;copy Debug\GLUT32.LIB ..\..\..\..\lib&#x0D;&#x0A;copy Debug\GLUT32.DLL ..\..\..\..\lib&#x0D;&#x0A;if exist ..\..\..\..\progs\demos copy Debug\GLUT32.DLL ..\..\..\..\progs\demos&#x0D;&#x0A;"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory=".\Release"\r
+                       IntermediateDirectory=".\Release"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"\r
+                       UseOfMFC="0"\r
+                       ATLMinimizesCRunTimeLibraryUsage="false"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               MkTypLibCompatible="true"\r
+                               SuppressStartupBanner="true"\r
+                               TargetEnvironment="1"\r
+                               TypeLibraryName=".\Release/glut.tlb"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               InlineFunctionExpansion="1"\r
+                               AdditionalIncludeDirectories="../../../../include"\r
+                               PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;_DLL;_USRDLL;GLUT_EXPORTS;MESA;BUILD_GL32;_CRT_SECURE_NO_DEPRECATE"\r
+                               StringPooling="true"\r
+                               RuntimeLibrary="0"\r
+                               EnableFunctionLevelLinking="true"\r
+                               PrecompiledHeaderFile=".\Release/glut.pch"\r
+                               AssemblerListingLocation=".\Release/"\r
+                               ObjectFile=".\Release/"\r
+                               ProgramDataBaseFileName=".\Release/"\r
+                               WarningLevel="3"\r
+                               SuppressStartupBanner="true"\r
+                               CompileAs="0"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG"\r
+                               Culture="1033"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalOptions="/MACHINE:I386"\r
+                               AdditionalDependencies="opengl32.lib glu32.lib user32.lib winmm.lib gdi32.lib msvcrt.lib oldnames.lib odbc32.lib odbccp32.lib"\r
+                               OutputFile="Release/GLUT32.DLL"\r
+                               LinkIncremental="1"\r
+                               SuppressStartupBanner="true"\r
+                               AdditionalLibraryDirectories="../../mesa/Release"\r
+                               IgnoreAllDefaultLibraries="true"\r
+                               ProgramDatabaseFile=".\Release/GLUT32.pdb"\r
+                               ImportLibrary=".\Release/GLUT32.lib"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                               CommandLine="if not exist ..\..\..\..\lib md ..\..\..\..\lib&#x0D;&#x0A;copy Release\GLUT32.LIB ..\..\..\..\lib&#x0D;&#x0A;copy Release\GLUT32.DLL ..\..\..\..\lib&#x0D;&#x0A;if exist ..\..\..\..\progs\demos copy Release\GLUT32.DLL ..\..\..\..\progs\demos&#x0D;&#x0A;"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_8x13.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_9x15.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_bitmap.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_bwidth.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_cindex.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_cmap.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_cursor.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_dials.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_dstr.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_event.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_ext.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_fcb.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_fullscrn.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_gamemode.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_get.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_hel10.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_hel12.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_hel18.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_init.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_input.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_joy.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_key.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_keyctrl.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_keyup.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_mesa.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_modifier.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_mroman.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_overlay.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_roman.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_shapes.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_space.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_stroke.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_swap.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_swidth.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_tablet.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_teapot.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_tr10.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_tr24.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_util.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_vidresize.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_warp.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_win.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glut_winmisc.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\win32_glx.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\win32_menu.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\win32_util.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\win32_winproc.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\win32_x11.c"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glutbitmap.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glutint.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glutstroke.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\glutwin32.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\stroke.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\win32_glx.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\glut\glx\win32_x11.h"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
+                       >\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r